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 15: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 15: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 15:41

thanks a lot, I will give it a try!

Antonio


All times are GMT -4. The time now is 22:07.