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

Acessing neighbouring values in specific directions

Register Blogs Members List Search Today's Posts Mark Forums Read

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

Old   January 25, 2011, 05:01
Default
  #2
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Delft, Netherlands
Posts: 919
Rep Power: 17
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, 11:30
Default
  #3
Senior Member
 
Nakul
Join Date: Apr 2010
Location: India
Posts: 147
Rep Power: 7
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, 11:36
Default
  #4
Senior Member
 
Matthias Voß
Join Date: Mar 2009
Location: Berlin, Germany
Posts: 446
Rep Power: 11
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, 13:09
Default
  #5
Senior Member
 
Nakul
Join Date: Apr 2010
Location: India
Posts: 147
Rep Power: 7
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, 05:32
Default
  #6
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Delft, Netherlands
Posts: 919
Rep Power: 17
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, 13:04
Default
  #7
RoE
New Member
 
Roland Engberg
Join Date: Jan 2011
Posts: 14
Rep Power: 6
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, 22:17
Default
  #8
lin
Senior Member
 
Hua Zen
Join Date: Mar 2009
Posts: 114
Rep Power: 8
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, 06:23
Default
  #9
RoE
New Member
 
Roland Engberg
Join Date: Jan 2011
Posts: 14
Rep Power: 6
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: 5
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: 12
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

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Constant velocity of the material Sas CFX 15 July 13, 2010 08:56
Simulation of a single bubble with a VOF-method Suzzn CFX 18 October 2, 2009 04:18
mass flow in is not equal to mass flow out saii CFX 2 September 18, 2009 08:07
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 09:15


All times are GMT -4. The time now is 03:40.