Loop over Points of a boundary / patch

 User Name Remember Me Password
 Register Blogs Members List Search Today's Posts Mark Forums Read

 March 5, 2013, 06:47 Loop over Points of a boundary / patch #1 Senior Member   HECKMANN Frédéric Join Date: Jul 2010 Posts: 237 Rep Power: 10 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

 March 5, 2013, 08:49 meshPoints() function #2 Senior Member   Fumiya Nozaki Join Date: Jun 2010 Location: Yokohama, Japan Posts: 217 Blog Entries: 1 Rep Power: 11 You can use the meshPoints() function. The following thread will be of help: http://www.cfd-online.com/Forums/ope...ary-patch.html Fumiya

 March 7, 2013, 04:19 #3 Senior Member   HECKMANN Frédéric Join Date: Jul 2010 Posts: 237 Rep Power: 10 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.

May 25, 2015, 04:34
#4
Member

Fei Fan
Join Date: Jun 2013
Location: NanJing, China
Posts: 54
Rep Power: 6
Quote:
 Originally Posted by fredo490 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

July 8, 2015, 10:52
#5
Member

Bruno Blais
Join Date: Sep 2013
Posts: 66
Rep Power: 6
Quote:
 Originally Posted by Fanfei 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

July 8, 2015, 10:57
#6
Member

Fei Fan
Join Date: Jun 2013
Location: NanJing, China
Posts: 54
Rep Power: 6
Quote:
 Originally Posted by blais.bruno 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

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post clo OpenFOAM Other Meshers: ICEM, Star, Ansys, Pointwise, GridPro, Ansa, ... 33 September 26, 2012 04:04 Kryo OpenFOAM Native Meshers: snappyHexMesh and Others 8 September 13, 2012 09:28 sega OpenFOAM Native Meshers: blockMesh 3 September 28, 2010 12:46 Kart OpenFOAM Meshing & Mesh Conversion 1 February 4, 2010 05:38 ivanyao OpenFOAM Running, Solving & CFD 2 March 11, 2009 03:34

All times are GMT -4. The time now is 16:54.

 Contact Us - CFD Online - Privacy Statement - Top