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

Loop over Points of a boundary / patch

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   March 5, 2013, 06:47
Default Loop over Points of a boundary / patch
  #1
Senior Member
 
HECKMANN Frédéric
Join Date: Jul 2010
Posts: 236
Rep Power: 8
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, 08:49
Default meshPoints() function
  #2
Senior Member
 
Fumiya Nozaki
Join Date: Jun 2010
Location: Yokohama, Japan
Posts: 170
Rep Power: 7
fumiya is on a distinguished road
You can use the meshPoints() function.
The following thread will be of help:
Order of points in a boundary patch

Fumiya
fumiya is offline   Reply With Quote

Old   March 7, 2013, 04:19
Default
  #3
Senior Member
 
HECKMANN Frédéric
Join Date: Jul 2010
Posts: 236
Rep Power: 8
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: 44
Rep Power: 4
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
New Member
 
Bruno Blais
Join Date: Sep 2013
Location: Canada
Posts: 24
Rep Power: 3
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
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: 44
Rep Power: 4
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

Thread Tools
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using starToFoam clo OpenFOAM Other Meshers: ICEM, Star, Ansys, Pointwise, GridPro, Ansa, ... 33 September 26, 2012 04:04
Add Mesh Layers doesnt work on the whole surface Kryo OpenFOAM Native Meshers: snappyHexMesh and Others 8 September 13, 2012 09:28
Cyclic BC's: Possible face ordering problem? (Channel flow) sega OpenFOAM Native Meshers: blockMesh 3 September 28, 2010 12:46
StarToFoam error Kart OpenFOAM Meshing & Mesh Conversion 1 February 4, 2010 05:38
CheckMeshbs errors ivanyao OpenFOAM Running, Solving & CFD 2 March 11, 2009 03:34


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