|
[Sponsors] |
July 20, 2010, 12:27 |
loop through structured mesh by i,j,k
|
#1 |
Senior Member
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30 |
Hello all,
I know I can loop through all cells of a mesh using forAll(mesh.cells(),celli). However, this won't tell me anything about the geometric location of the neighbors. I'd like to only use the neighbors on a certain axis for my further calculations. Does anyone have an idea? In pseudo code, in 2D: Code:
for (i =0; i < mesh.max_i; i++) for (j =0; j < mesh.max_j; i++) // calculation involving mesh.cell[j-1], mesh.cell[j], mesh.cell[j+1] |
|
July 20, 2010, 13:41 |
|
#2 |
Senior Member
Sandeep Menon
Join Date: Mar 2009
Location: Amherst, MA
Posts: 403
Rep Power: 25 |
I suppose you could look at cell-faces, take the dot-product of the unit face-normal with the axis-direction that you want, and check its magnitude. You can then choose the owner/neighbour of those faces to get the adjacent cell.
|
|
July 21, 2010, 06:01 |
|
#3 |
Senior Member
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30 |
Thanks, that got me started! Now I'm facing a weird problem though: Every now and then, instead of a sensible neighbour cellID, I get something way off, eg.
Code:
inner circle, celli: 932 neigh: 962 //makes sense inner circle, celli: 932 neigh: 1751339886 //can't be, grid only has like 1200 cells, using it to access a field naturally leads to a seg fault Code:
vector axis(0, 1, 0); forAll( mesh.C(), celli) { // Neighbour and owner cells to given face const unallocLabelList & nei = mesh.neighbour(); const unallocLabelList & own = mesh.owner(); // This is a list of faces of which the cell is build const cell& cProp = mesh.cells()[celli]; // Loop over all faces forAll(cProp, facei) { label owner = own[cProp[facei]]; label neigh = nei[cProp[facei]]; //find faces in y-direction if (mag(mesh.Sf()[facei] & axis) > 0) { Info << "celli: " << celli << endl; if (owner == celli) { Info << "neigh: " << neigh << endl; } else { // neigh == celli Info << "owner: " << owner << endl; } } } } |
|
July 21, 2010, 06:10 |
|
#4 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,903
Rep Power: 37 |
That would occur, if you are requesting a neighbour for a boundary face. You should make a conditional like
Code:
if (cProp[facei] < own.size()) { // Can ask for both owner and neighbour } else { // Only owner exists } Niels |
|
July 21, 2010, 06:27 |
|
#5 |
Senior Member
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30 |
So my guess is that the large number are boundary cells and could be just filtered out by comparing with mesh.size() [edit: Sorry Niels, didn't see your post while writing this one]. However, I now noticed that I'm not seeing two neighbors as expected on a 2D mesh, but three! Whats going on? Here is an image of cellIDs I got out of paraview.
Looking at cell 31, I want to get 1 and 61 as output. Instead I'm getting: celli: 31 neigh: 61 owner: 31 celli: 31 owner: 31 neigh: NULL celli: 31 neigh: 31 owner: 30 Why is there an inner face, and why am I getting the left neighbor instead of the lower one? |
|
Tags |
cells, index, loop, mesh, neighbor |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[ICEM] Generating Mesh for STL Car in Windtunnel Simulation | tommymoose | ANSYS Meshing & Geometry | 48 | April 15, 2013 05:24 |
Exporting structured mesh from ICEMCFD to Fluent? | jeevan kumar | FLUENT | 1 | January 23, 2012 12:21 |
[ICEM] Unstructure Meshing Around Imported Plot3D Structured Mesh ICEM | kawamatt2 | ANSYS Meshing & Geometry | 17 | December 20, 2011 12:45 |
need reference for structured mesh generation | cfduser03 | Main CFD Forum | 3 | September 7, 2009 10:58 |
Structured mesh of a 3d sharp trailing edge | Gilles | Main CFD Forum | 2 | May 23, 2008 14:23 |