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"

JoeFriend March 23, 2017 12:48

Hi! I'm having a similar problem...I need to access a temperature field in a patch from a different region.

When you said "you just have to add these lines to the main program", you meant chtMultiRegionFoam, right? Then, how did you excecute this in your code for creating a mesh in an specific region?

Hope you see this post! Or if any one else knows anything related to this, I would be very grateful!

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