CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Access faces in multiregion case (https://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

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.