CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Programming & Development (
-   -   Neighbour cell centre to face distance (

fportela July 15, 2013 15:03

Neighbour cell centre to face distance
Hello all,

I feel my question is rather simple, but I've trying to solve this for quite a while without any success, so maybe you guys can help.

Consider two patches which are coupled, I need to know the distance between points A and B, where A is the centre of the cells which contain faces on the neighbour patch, and B is the centre of the faces on the neighbour patch.

I could just use the distance from A to the current faces, however, this becomes a problem whenever cyclic conditions come into play...

So, any suggestions?


KlasJ July 19, 2013 09:44

Hi Felipe,

I am not sure that I interpret your question correctly. You want to get the distance from the cell next to the coupled patch to face centre on the neighbouring face?

Perhaps you could be helped by looking at the implementation of the patches. For example have a look at the function delta in the cyclic patch (src/finiteVolume/lnInclude/cyclicFvPatch.C). There you can see how the distance between the cells is calculated as a sum between the distance from the cell to the face for each side of the interface.

Note that the function delta has different meaning depending on the type of patch (src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.H):


//- Return cell-centre to face-centre vector
//  except for coupled patches for which the cell-centre
//  to coupled-cell-centre vector is returned
virtual tmp<vectorField> delta() const;

Hope this was of some help.

Best regards,


fportela July 19, 2013 10:11

Hi Klas,

In fact, what I needed was not the cell-centre to coupled-cell vector (which can be obtained directly from delta()), but rather the coupled-cell-centre to coupled-cell-face vector (the face would be that which is coupled to the original cell).

In the meanwhile the following procedure seems to work:


myPatch.fvPatch::delta() -;
Where myPatch is a coupled patch.

Nevertheless, thanks for the swift reply :)


KlasJ July 19, 2013 10:35

Hi again,

Aha, I understand now.

Yes, it seems reasonable that what you are using works. As found in cyclicFvPatch.C you could get a reference to the neighbouring patch and then ask the patch for delta:


    const cyclicFvPatch& nbrPatch = neighbFvPatch();
    const scalarField deltas(nf() & fvPatch::delta());
    const scalarField nbrDeltas( & nbrPatch.fvPatch::delta());

But also since the coupled delta will anyway only be the difference of the fvPatch::delta for each patch what you are doing should be the same thing.

// Klas

openfoammaofnepo April 15, 2014 11:52

Dear Klas,

About the returned quantities of function delta(), I also read the source files fvPatch.H and fvPatch.C. In the latter, the delta is defined as:


According to fvPatch.H, Cf is face centers while Cn is the neighboring cell centers. I have a question here. for those physical boundary faces (like inlet, outlet, wall..., not inter-processor faces), the cell that contains the boundary faces is always thought of as the owner cell. So here what does it mean by "Cn is the neighboring cell centers"?

After digging the source files, I found that

- for physical boundary faces: delat is Cf-Cn. That is, the delta vector points from the cell (which contains this face) to the face center.
- for inter-processor faces: delta is the vector from the owner (located in the local processor) to the neighbor cells (located in the neighboring processor).

Is what I am saying correct? Any comments are welcome.

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