CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Loop over Points of a boundary / patch

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 3 Post By blais.bruno

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 5, 2013, 05:47
Default Loop over Points of a boundary / patch
  #1
Senior Member
 
HECKMANN Frédéric
Join Date: Jul 2010
Posts: 249
Rep Power: 16
fredo490 is on a distinguished road
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
fredo490 is offline   Reply With Quote

Old   March 5, 2013, 07:49
Default meshPoints() function
  #2
Senior Member
 
fumiya's Avatar
 
Fumiya Nozaki
Join Date: Jun 2010
Location: Yokohama, Japan
Posts: 266
Blog Entries: 1
Rep Power: 18
fumiya is on a distinguished road
You can use the meshPoints() function.
The following thread will be of help:
http://www.cfd-online.com/Forums/ope...ary-patch.html

Fumiya
fumiya is offline   Reply With Quote

Old   March 7, 2013, 03:19
Default
  #3
Senior Member
 
HECKMANN Frédéric
Join Date: Jul 2010
Posts: 249
Rep Power: 16
fredo490 is on a distinguished road
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.
fredo490 is offline   Reply With Quote

Old   May 25, 2015, 04:34
Default
  #4
Member
 
Fei Fan
Join Date: Jun 2013
Location: NanJing, China
Posts: 54
Rep Power: 12
Fanfei is on a distinguished road
Quote:
Originally Posted by fredo490 View Post
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
Fanfei is offline   Reply With Quote

Old   July 8, 2015, 10:52
Default
  #5
Member
 
Bruno Blais
Join Date: Sep 2013
Location: Canada
Posts: 64
Rep Power: 12
blais.bruno is on a distinguished road
Quote:
Originally Posted by Fanfei View Post
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
zatralias, Luttappy and erinsam like this.
blais.bruno is offline   Reply With Quote

Old   July 8, 2015, 10:57
Default
  #6
Member
 
Fei Fan
Join Date: Jun 2013
Location: NanJing, China
Posts: 54
Rep Power: 12
Fanfei is on a distinguished road
Quote:
Originally Posted by blais.bruno View Post
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
Fanfei is offline   Reply With Quote

Reply


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 Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[snappyHexMesh] Add Mesh Layers doesnt work on the whole surface Kryo OpenFOAM Meshing & Mesh Conversion 13 February 17, 2022 07:34
[Commercial meshers] Using starToFoam clo OpenFOAM Meshing & Mesh Conversion 33 September 26, 2012 04:04
[blockMesh] Cyclic BC's: Possible face ordering problem? (Channel flow) sega OpenFOAM Meshing & Mesh Conversion 3 September 28, 2010 12:46
[Other] StarToFoam error Kart OpenFOAM Meshing & Mesh Conversion 1 February 4, 2010 04:38
CheckMeshbs errors ivanyao OpenFOAM Running, Solving & CFD 2 March 11, 2009 02:34


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