|
[Sponsors] |
Acessing neighbouring values in specific directions |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
January 24, 2011, 16:31 |
Acessing neighbouring values in specific directions
|
#1 |
New Member
Roland Engberg
Join Date: Jan 2011
Posts: 14
Rep Power: 15 |
Hi!
Is it possible to access values defined at cell faces or neighbouring cells in specific directions, e.g. the faces in the x-direction? For example, I'd like to sweep through the cells, compare the two snGradients in the x-direction in each cell and chose the larger one. Browsing the forum I only found the commands mesh.cellCells(), mesh.owner() and mesh.neighbour() which will give me all neighbouring cells and faces, respectively. Thanks in advance! Roland Last edited by RoE; January 25, 2011 at 04:26. |
|
January 25, 2011, 05:01 |
|
#2 |
Senior Member
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30 |
From what I know this is not possible in OpenFoam due to it's unstructured nature. You'll have to use mesh.cellCells() & co and then start comparing coordinates (mesh[celli].C()) to find the appropriate face on your own.
|
|
January 26, 2011, 11:30 |
|
#3 |
Senior Member
Nakul
Join Date: Apr 2010
Location: India
Posts: 147
Rep Power: 16 |
Hi Anton,
What exactly do you mean by OpenFoam's "unstructured" nature? |
|
January 26, 2011, 11:36 |
|
#4 |
Senior Member
Matthias Voß
Join Date: Mar 2009
Location: Berlin, Germany
Posts: 449
Rep Power: 20 |
hi,
Answer: that it is not of interest how the cell looks like (hex tet prism ,...). it is just a matter of: which faces are related to the cell and what is the neighbor ...in the first place you´re just asking for flow from one face to another,...and afterwards doing some calc to get the cellcenter value from the cellface values. That is why there is some kind of "unstructuredness" in OpenFoam. There is no ijk-direction to cycle over like when thinking about "structured" meshes. neewbie @Anton: sorry... i´ve tagged this thread that´s why i´m answering... no offense. |
|
January 26, 2011, 13:09 |
|
#5 |
Senior Member
Nakul
Join Date: Apr 2010
Location: India
Posts: 147
Rep Power: 16 |
Hi
Thanks for the quick reply. Could please point me to some reference or starting material where I can read more about this sort of structuredness/unstructuredness? (Not necessarily specific to OpenFOAM!!!) |
|
January 27, 2011, 05:32 |
|
#6 |
Senior Member
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30 |
Any basic CFD book will have a section on grids. I like Ferziger, Peric. Other than that, the CFD wiki on this website and even wikipedia have entries about structured and unstructured grids, and you will find thousands of results on google about this topic.
|
|
February 1, 2011, 13:04 |
|
#7 |
New Member
Roland Engberg
Join Date: Jan 2011
Posts: 14
Rep Power: 15 |
Thanks for your help!
The advice to compare the coordinates is especially helpful. As a first test I wanted to extract the neighbours (cellCells) and their coordinates using the following code: fileName outDir = runTime.path()/"data"; mkDir(outDir); OFstream nStream(outDir/"datafile.dat"); const volVectorField& C = mesh.C(); forAll(C,cellI) { const unallocLabelList& neigh = mesh.cellCells()[cellI]; nStream << " Cell: " << cellI << " Neighbours: " << neigh << " Center of Cell: " << C[cellI]; forAll(neigh,neighI) { vector CNeigh = C[neighI]; nStream << " Neighbour: " << neigh[neighI] << " Center of neighbour: " << CNeigh; } nStream <<" " << endl; } The results, however, are a little strange. Here are the first lines of the output file: Cell: 0 Neighbours: 2(1 20) Center of Cell: (0.0025 0.0025 0.005) Neighbour: 1 Center of neighbour: (0.0025 0.0025 0.005) Neighbour: 20 Center of neighbour: (0.0075 0.0025 0.005) The code finds two neighbours (cells 1 and 20) for cell 0 which is correct - cell 0 is a corner of a 2D mesh. It gives the proper coordinates of the center of cell 1. Nevertheless, the coordinates of the first neighbour (cell 1) are erroneous, the code gives the coordinates of cell 0! The coordinates of cell 21 are wrong, too. The code provides the coordinates of cell 1. The results for cell 1 are also erroneous: Cell: 1 Neighbours: 3(0 2 21) Center of Cell: (0.0075 0.0025 0.005) Neighbour: 0 Center of neighbour: (0.0025 0.0025 0.005) Neighbour: 2 Center of neighbour: (0.0075 0.0025 0.005) Neighbour: 21 Center of neighbour: (0.0125 0.0025 0.005) Any advice? Thank you! Roland |
|
February 1, 2011, 22:17 |
|
#8 |
Senior Member
Hua Zen
Join Date: Mar 2009
Posts: 138
Rep Power: 17 |
try to change "vector CNeigh = C[neighI];"
to "vector CNeigh = C[neigh[neighI]];" |
|
February 2, 2011, 06:23 |
|
#9 |
New Member
Roland Engberg
Join Date: Jan 2011
Posts: 14
Rep Power: 15 |
Wonderful - that does the trick!
Thank you very much! Roland |
|
October 3, 2012, 22:11 |
east and north cell values
|
#10 |
Member
,...
Join Date: Apr 2011
Posts: 92
Rep Power: 14 |
Is there any function in OF to give the values of a parameter at the north and east cell of a specific cell, say celli?
|
|
October 4, 2012, 04:38 |
|
#11 |
Senior Member
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 22 |
The answer to your question is in the second post of this topic.
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
mass flow in is not equal to mass flow out | saii | CFX | 12 | March 19, 2018 06:21 |
Simulation of a single bubble with a VOF-method | Suzzn | CFX | 21 | January 29, 2018 01:58 |
Constant velocity of the material | Sas | CFX | 15 | July 13, 2010 09:56 |
Two-Phase Buoyant Flow Issue | Miguel Baritto | CFX | 4 | August 31, 2006 13:02 |
Printing Values on a Specific Surface | Matthew | FLUENT | 1 | February 8, 2006 09:15 |