CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM

Acessing neighbouring values in specific directions

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 24, 2011, 15:31
Default Acessing neighbouring values in specific directions
  #1
RoE
New Member
 
Roland Engberg
Join Date: Jan 2011
Posts: 14
Rep Power: 15
RoE is on a distinguished road
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 03:26.
RoE is offline   Reply With Quote

Old   January 25, 2011, 04:01
Default
  #2
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 29
akidess will become famous soon enough
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.
akidess is offline   Reply With Quote

Old   January 26, 2011, 10:30
Default
  #3
Senior Member
 
Nakul
Join Date: Apr 2010
Location: India
Posts: 147
Rep Power: 16
nakul is on a distinguished road
Hi Anton,

What exactly do you mean by OpenFoam's "unstructured" nature?
nakul is offline   Reply With Quote

Old   January 26, 2011, 10:36
Default
  #4
Senior Member
 
Matthias Voß
Join Date: Mar 2009
Location: Berlin, Germany
Posts: 449
Rep Power: 20
mvoss is on a distinguished road
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.
mvoss is offline   Reply With Quote

Old   January 26, 2011, 12:09
Default
  #5
Senior Member
 
Nakul
Join Date: Apr 2010
Location: India
Posts: 147
Rep Power: 16
nakul is on a distinguished road
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!!!)
nakul is offline   Reply With Quote

Old   January 27, 2011, 04:32
Default
  #6
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 29
akidess will become famous soon enough
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.
akidess is offline   Reply With Quote

Old   February 1, 2011, 12:04
Default
  #7
RoE
New Member
 
Roland Engberg
Join Date: Jan 2011
Posts: 14
Rep Power: 15
RoE is on a distinguished road
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
RoE is offline   Reply With Quote

Old   February 1, 2011, 21:17
Default
  #8
lin
Senior Member
 
Hua Zen
Join Date: Mar 2009
Posts: 138
Rep Power: 17
lin is on a distinguished road
try to change "vector CNeigh = C[neighI];"
to
"vector CNeigh = C[neigh[neighI]];"
lin is offline   Reply With Quote

Old   February 2, 2011, 05:23
Default
  #9
RoE
New Member
 
Roland Engberg
Join Date: Jan 2011
Posts: 14
Rep Power: 15
RoE is on a distinguished road
Wonderful - that does the trick!

Thank you very much!
Roland
RoE is offline   Reply With Quote

Old   October 3, 2012, 21:11
Default east and north cell values
  #10
Member
 
,...
Join Date: Apr 2011
Posts: 92
Rep Power: 14
hawkeye321 is an unknown quantity at this point
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?
hawkeye321 is offline   Reply With Quote

Old   October 4, 2012, 03:38
Default
  #11
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 21
Bernhard is on a distinguished road
The answer to your question is in the second post of this topic.
Bernhard is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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 05:21
Simulation of a single bubble with a VOF-method Suzzn CFX 21 January 29, 2018 00:58
Constant velocity of the material Sas CFX 15 July 13, 2010 08:56
Two-Phase Buoyant Flow Issue Miguel Baritto CFX 4 August 31, 2006 12:02
Printing Values on a Specific Surface Matthew FLUENT 1 February 8, 2006 08:15


All times are GMT -4. The time now is 16:33.