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/)
-   -   Averaging over neighbouring cells in parallel (http://www.cfd-online.com/Forums/openfoam-programming-development/86173-averaging-over-neighbouring-cells-parallel.html)

jposunz March 16, 2011 08:09

Averaging over neighbouring cells in parallel
 
Hi everyone,

I'm having trouble working out how to access neighbouring points when running my application in parallel. As part of my algorithm I need to filter/smooth the values of the Reynolds stresses based on the neighbouring cells. It works fine in serial but in parallel it generates problematic results as the cellCells() call only returns the neighbours on the same processor. I've read lots of posts and found some info referring to PStream and globalMesh but must admit I'm a novice at parallel programming so any help would be great. I thought there may be a simple way to tell the application to look across the entire domain when doing the averaging? Here's my code as it is:

forAll(mesh_.cells(), cellI)
{
const labelList& nbrs = mesh_.cellCells()[cellI];

scalar volCell = mesh_.V()[cellI];

scalar volume = volCell;
scalar volRxx = volCell * R_[cellI].xx();
scalar volRxy = volCell * R_[cellI].xy();
scalar volRxz = volCell * R_[cellI].xz();
scalar volRyy = volCell * R_[cellI].yy();
scalar volRyz = volCell * R_[cellI].yz();
scalar volRzz = volCell * R_[cellI].zz();

forAll(nbrs,nbrI)
{

scalar volCell = mesh_.V()[nbrs[nbrI]];

volume += volCell;
volRxx += volCell * R_[nbrs[nbrI]].xx();
volRxy += volCell * R_[nbrs[nbrI]].xy();
volRxz += volCell * R_[nbrs[nbrI]].xz();
volRyy += volCell * R_[nbrs[nbrI]].yy();
volRyz += volCell * R_[nbrs[nbrI]].yz();
volRzz += volCell * R_[nbrs[nbrI]].zz();
}

Rbuffer[cellI].xx() = volRxx/volume;
Rbuffer[cellI].xy() = volRxy/volume;
Rbuffer[cellI].xz() = volRxz/volume;
Rbuffer[cellI].yy() = volRyy/volume;
Rbuffer[cellI].yz() = volRyz/volume;
Rbuffer[cellI].zz() = volRzz/volume;

}

Thanks!

jposunz March 22, 2011 00:28

Noone with any ideas? I've spent a lot of time looking through source code for something similar but haven't come up with anything yet.

Thanks!

eugene April 11, 2011 16:46

All coupled boundaries of geometric fields have a member function called "patchNeighbourField". I think this should do what you need provided the property you want is stored in a geometric field.

Otherwise you want to use the syncTools, but that's a bit more complicated.

Eugene


All times are GMT -4. The time now is 09:46.