CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Running, Solving & CFD (
-   -   ForAllowner faceI looping (

sampaio July 16, 2008 15:42

Dear all, For some reason, I
Dear all,
For some reason, I need to loop over all faces to do some calculations, that I could not find a way to do with regular field operations.

Then, I decided to do a loop over all owner faces like below, because somehow I needed information from face, owner and neighbour:

Phi is a surfaceScalarField
V is a volScalarField
S is a surfaceScalarField

forAll(owner, f)
Phi[f] =
someComplexOperationsWith(V[owner[f]] , V[neighbour[f]], and S[f])

My first mistake was to assume the boundary faces would be covered in this loop, but later I realized they wouldn't.

My first question is: what happens to processorBoundaryPatches? Are they covered by this loop to garantee that the same code would work for serial and parallel computations? Or do I need to worry about it and do some loop over the boundary like this:

const fvPatchList& patches = mesh.boundary();

forAll(patches, patchi)
const fvPatch& curPatch = patches[patchi];
const fvPatchVectorField& Up = U.boundaryField()[patchi];

if( isType<processorfvpatchvectorfield>(Up)

forAll(curPatch, i)
label faceCelli = curPatch.faceCells()[i];

Second question is: if I have to do this loop (above), and do some similar operations (as in the owner, faceI loop), how do I get the neighbour[f] field (which lies in a different processor).

Finally, is seems that I do not need to worry with cyclic boundary conditions, meaning that the first loop (forAll(owner,f)) includes all faces of patch cyclic. Am I right?

Thanks a lot,

hjasak July 30, 2008 06:24

Hello Luiz, The first loop
Hello Luiz,

The first loop is all fine, and will visit only the internal faces.

The second loop is also fine. You do not want to do anything special on the processor patches, because


would be required all over the code.

In parallel, you wil want each side to do its own bit, referring to local faceCells. On any sort of a coupled patch, deltaCoeffs will be the real one (using neighbour - owner distance across processors) and you need not do anything special. Have a look at ...boundaryCoeffs() and ...internalCoeffs() in any sort of a coupled patch.



All times are GMT -4. The time now is 18:24.