|
[Sponsors] |
Iterate over nearing cells of a specified cell |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
May 3, 2014, 13:50 |
Iterate over nearing cells of a specified cell
|
#1 |
Member
Join Date: Feb 2012
Posts: 49
Rep Power: 14 |
Hi FOAMers,
I've implemented a user-interpolation in OpenFOAM , but to compute the distance of the current cell to near cells, i have to iterate over all cells which can be costly. So do you have any suggestion on how to iterate over a specified radius of a cell(or coordinate), and not over all cells. (to reduce computation cost) What i'm doing : Code:
forAll(U,cellI) point[XX].x() - mesh.C()[cellI].x() ... Code:
forAll(iterate over nearing cells of point[XX].x()) point[XX].x() - mesh.C()[cellI].x() ... |
|
May 4, 2014, 15:26 |
|
#2 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,902
Rep Power: 37 |
Good evening ooo
You should be able to construct what you want using the following methods in the mesh class: Code:
mesh.cellCells(); mesh.pointCells(); mesh.cellPoints(); Kind regards, Niels
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request. |
|
May 20, 2014, 14:36 |
|
#3 | |
Member
Join Date: Feb 2012
Posts: 49
Rep Power: 14 |
Quote:
Having 2 cell layers (or maximum 3) is enough for me so i'm using this code.(if it works, then i continue to removing duplication by uniqueOrder...) It gives no compilation error, but segmentation error in running. Do you know what's the problem? Code:
labelListList cellCells; forAll(mesh.cells(),cellI) { labelList layer1 = mesh.cellCells()[cellI]; cellCells[cellI].append(layer1) ; for(int i=0; i<layer1.size(); i++) { labelList layer2 = mesh.cellCells()[layer1[i]]; cellCells[cellI].append(layer2); } } |
||
May 20, 2014, 17:52 |
|
#4 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,902
Rep Power: 37 |
You never define the size of cellCells, and afterward you to assign something to the ceellI'th array of cellCells, but it still does not have a size.
If I understand the code correct, the append works on the nested labelList, and not on the outer list. Kind regards, Niels
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request. |
|
May 20, 2014, 18:29 |
|
#5 |
Member
Join Date: Feb 2012
Posts: 49
Rep Power: 14 |
Thank you.
Using dynamic labelLists solved the problem. Last edited by ooo; May 20, 2014 at 20:58. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[ICEM] Error in mesh writing | helios | ANSYS Meshing & Geometry | 21 | August 19, 2021 15:18 |
[snappyHexMesh] SnappyHexMesh for internal Flow | vishwa | OpenFOAM Meshing & Mesh Conversion | 24 | June 27, 2016 09:54 |
How to find the ghost cells in the immersed boundary methods? | cyou | Main CFD Forum | 19 | April 15, 2013 00:00 |
[snappyHexMesh] external flow with snappyHexMesh | chelvistero | OpenFOAM Meshing & Mesh Conversion | 11 | January 15, 2010 20:43 |
[Commercial meshers] Import error Gambit msh file with Cell Type 7 polyhedral cells | philippose | OpenFOAM Meshing & Mesh Conversion | 1 | June 1, 2007 03:58 |