CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Programming & Development (
-   -   Access faces in multiregion case (

sailor79 February 5, 2013 06:16

Access faces in multiregion case
Hi folks,

I want to access the faces of a certain patch in a certain region. I do some first tests with the code from the Thread


// Find the patchID of the patch by name
label patchID = mesh.boundaryMesh().findPatchID("movingWall");

// Create a polyPatch for looping
const polyPatch& myPatch = mesh.boundaryMesh()[patchID];

// Initialize patchArea
scalar patchArea = 0.0;

// Loop trhough all faces on the polyPatch, adding their magnitude surface
// area vectors
forAll(myPatch, faceI)
    patchArea += mesh.magSf().boundaryField()[patchID][faceI];

But as I am working with chtMultiRegionFoam and the desired patch is an interface patch created by splitMeshRegions (region1_to_region2) I am not able to access the faces. The patchID becomes "-1" as the patch is defined in the boundary file within the regions-directory.

How do I have to modify the mentioned code?

Thanks for your support


sailor79 February 7, 2013 03:46

I figured out how to access the mesh of a region. Maybe the following information will help other foamers:

You just have to add these lines to the main program:


#  include "addRegionOption.H"

and replace

#  include "createMesh.H"

#  include "createNamedMesh.H"

All times are GMT -4. The time now is 15:19.