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/)
-   -   Obtaining the number of faces contained in a patch. (http://www.cfd-online.com/Forums/openfoam-programming-development/80599-obtaining-number-faces-contained-patch.html)

Fransje September 30, 2010 08:56

Obtaining the number of faces contained in a patch.
 
Dear Foamers,

I had two questions related to the information depending on a certain patch.
  • First of all, in order to initialize a variable of the right size, I would like to know the number of faces contained in the patch accessed by:
    Code:

    nbr.boundaryMesh()[nbrPatchID]
    Would somebody happen to know how to do this?
  • Secondly I'm trying to obtain the distance of the faces in that patch to the closest wall. I've been using the wallDist class, with the following command
    Code:

    wallDist myWallDistRoutine(nbrMesh);
    volScalarField myWallDistance= myWallDistRoutine.y();

    Which does the job, but works on the total domain mesh, meaning I have to use some trick to relate the local face index from [nbrPatchI] to the global face index from the entire domain.
    I was therefore wondering whether it might be possible to return a submesh containing the information of [nbrPatchI], of type mesh, and feed that to wallDist to obtain the distance to the closest wall?
I hope my questions were clear enough.. If not so, please let me know.

Thank you for your reply!

Francois.

santiagomarquezd September 30, 2010 20:36

Francois, as regards your first question I don't what kind of class is nbr. I'll give you an example with a volScalarField:

T.boundaryField()[nbrPatchID].size()

I think the solution is not far of this. Always remember to look in classes whose your interested in class inherits. In this case size() method is implemented in fvPatch class.

Greetings from Argentina.

Fransje October 1, 2010 06:41

Dear Santiago,

Thank you for your reply!
Coincidentally, your example was exactly what I was looking for, as I am trying to modify the velocity field of a volVectorField. :) It works!

nbrMesh is of type fvMesh, and from that object I'm read a velocity field which I want to adapt. I was trying to get the patch size from the mesh object through the use op some obscure function called .nFaces() contained in primitiveMesh, and inherited via via by fvMesh... :o How to make your life complicated...

Thanks again for your efficient solution!

Does anybody care to give me some hints on how to proceed with my second question? ;)

Greetings from sunny Holland,

Francois

marupio October 3, 2010 11:14

Try whichPatch and whichFace from boundaryMesh.

Fransje October 6, 2010 08:41

Thanks for the tip!


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