CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Programming & Development (
-   -   access the values on a patch with its faceID (

FarhadZDH September 11, 2021 08:16

access the values on a patch with its faceID
Hi foamers;

I have a basic problem!

I want to smooth a variable on a boundary patch. so it is important to access the boundary faces in order.

This is what I did so far:

I use boundaryField() member function and forAll loop to handle the faces on a patch. the problem is that the faces are not necessarily consecutive.

Info << variable.boundaryField()[patchID][ii].y() << endl;

Another thing that I am testing is to get the start face of the patch then clearly I have the face id of the rest, that way I access the faces in order, I guess. At this point, I wonder how I can access the face value by using the faceID.

const polyPatch& cPatch = mesh.boundaryMesh()[patchID];
label faceId_start = cPatch.start() ;

forAll(cPatch, faceI)

// index of each face
label faceID = faceId_start +faceI;

// Now how could I access a variable value at faces using faceID



Thanks in advance!

PS: I am searching the resources simultaneously :)
I used blockMesh and snappyHexMesh to create my geometry.

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