CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Accessing neighbor cells fields (http://www.cfd-online.com/Forums/openfoam-programming-development/110466-accessing-neighbor-cells-fields.html)

antoniofct December 11, 2012 16:11

Accessing neighbor cells fields
 
Hello all,

I am trying to do an average of cells neighbors. For instance, if I want to get an average of Temperature in the internal field I can easily type

Code:

sum(T.internalField())/mesh.nCells()
.

What could be the function to do it just in cell neighbors? Could it be inside geometricField.C?

Thanks!

António

duongquaphim December 11, 2012 16:37

I think you need to do a bit more for that:

const labelList& neighbour = mesh.cellCells()[celli]

scalar sum = scalar(0);

forAll(neighbour,i)
{
sum += T[neighbour[i]];
}

sum /= neighbour.size();

And loop over all the cells with that will give you an average of cell neighbours.

You can find more of functions relating to the mesh information in primitiveMesh class.

Duong

antoniofct December 11, 2012 16:41

thanks a lot, I will give it a try!

Antonio

vitor.geraldes@ist.utl.pt May 13, 2015 17:53

This a nice implementation, but, in parallel, it does not recognize neighbour cells if they are in subdomains different from the one of the central cell. Is there a simple implementation to address this problem?


All times are GMT -4. The time now is 04:51.