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/)
-   -   Loop over Points of a boundary / patch (http://www.cfd-online.com/Forums/openfoam-programming-development/114092-loop-over-points-boundary-patch.html)

fredo490 March 5, 2013 06:47

Loop over Points of a boundary / patch
 
Dear all,
I am looking for a code able to loop over the points of a patch. From my research it seems that there is no member to find the points of a face. How can we get from a known face the corresponding nodes ?

My idea is to get an algorithm like this
- get patch id
- loop over face of the patch
- loop over the points of the faces
-> do a point treatment (an arbitraty movement in my case)

Thx in advance

fumiya March 5, 2013 08:49

meshPoints() function
 
You can use the meshPoints() function.
The following thread will be of help:
http://www.cfd-online.com/Forums/ope...ary-patch.html

Fumiya

fredo490 March 7, 2013 04:19

Your link is quite useful ! It's not perfect but still really good. I guess there is no elegant way to do what I want.

Thx.

Fanfei May 25, 2015 04:34

Quote:

Originally Posted by fredo490 (Post 411613)
Dear all,
I am looking for a code able to loop over the points of a patch. From my research it seems that there is no member to find the points of a face. How can we get from a known face the corresponding nodes ?

My idea is to get an algorithm like this
- get patch id
- loop over face of the patch
- loop over the points of the faces
-> do a point treatment (an arbitraty movement in my case)

Thx in advance

Hi fredo:
Have you solve this question now. I have the same problem to access the nodes of face. could you give me a hints. Thanks.
Best regards
Fan Fei

blais.bruno July 8, 2015 10:52

Quote:

Originally Posted by Fanfei (Post 547536)
Hi fredo:
Have you solve this question now. I have the same problem to access the nodes of face. could you give me a hints. Thanks.
Best regards
Fan Fei

There is a good way to loop over a patch.

Here is an example (somebody might correct me, this is not perfect) on how to loop over a boundary patch of which the name is "left". Then you get the position at the center of the face and you apply a function, let's say a cosine in this case.

Code:

      label inletPatchID = mesh.boundaryMesh().findPatchID("left"); //Patch identifier of the boundary condition
           
            fvPatchScalarField& wallP = p.boundaryField()[inletPatchID];  // Obtain a patchScalar field on the BC

            forAll(wallP, faceI)  // Loop over each face of the patch
            {
                vector pos(mesh.Cf().boundaryField()[inletPatchID][faceI]);
                x = pos[0];
                y = pos[1];
                wallP[faceI]=Foam::cos(PI*x)*Foam::cos(PI*y);;
            }

Cheers

Fanfei July 8, 2015 10:57

Quote:

Originally Posted by blais.bruno (Post 554487)
There is a good way to loop over a patch.

Here is an example (somebody might correct me, this is not perfect) on how to loop over a boundary patch of which the name is "left". Then you get the position at the center of the face and you apply a function, let's say a cosine in this case.

Code:

      label inletPatchID = mesh.boundaryMesh().findPatchID("left"); //Patch identifier of the boundary condition
           
            fvPatchScalarField& wallP = p.boundaryField()[inletPatchID];  // Obtain a patchScalar field on the BC

            forAll(wallP, faceI)  // Loop over each face of the patch
            {
                vector pos(mesh.Cf().boundaryField()[inletPatchID][faceI]);
                x = pos[0];
                y = pos[1];
                wallP[faceI]=Foam::cos(PI*x)*Foam::cos(PI*y);;
            }

Cheers

Hi
Thanks for you reply me. this problem i have solved. I use lablist to access to the face vertices series number and use mesh.points() to get the coordinate of points.

Best regards
Fan Fei


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