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/)
-   -   Access faces in multiregion case (http://www.cfd-online.com/Forums/openfoam-programming-development/112771-access-faces-multiregion-case.html)

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 http://www.cfd-online.com/Forums/ope...tml#post298405

Code:

// 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

Michael

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:

Code:

    timeSelector::addOptions();
#  include "addRegionOption.H"

and replace
Code:

#  include "createMesh.H"
by
Code:

#  include "createNamedMesh.H"
Michael


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