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

Patch orientation

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

Reply
 
LinkBack Thread Tools Display Modes
Old   September 23, 2012, 19:58
Question Patch orientation
  #1
Member
 
Vitor Vasconcelos
Join Date: Jan 2012
Posts: 33
Rep Power: 5
vitors is on a distinguished road
Hello all,

I'm implementing a boundary condition. I is basically a cylinder in which I need to set a fixedValue or fixedGradient profile.

Better saying, I need to get the faces of this cylinder and define a function for the faces values following the axial direction. I have an idea how to access my patch faces, but I don't know if I can get information among faces to check if they're neighbours in the axial direction.

Trying again: from top to bottom, my cylinder must have fixedValues following a cosinoidal function or a x^2 function.

Let me know if my point is not clear to try to explain in better words.

And thank you very much in advance for any help.

Vitor
vitors is offline   Reply With Quote

Old   September 24, 2012, 02:21
Default
  #2
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 12
Bernhard is on a distinguished road
By far the easiest way to obtain the desired result will be to use groovyBC (part of swak4Foam)
http://openfoamwiki.net/index.php/Contrib/swak4Foam contains source code and a bunch of examples that should get you going.
Bernhard is offline   Reply With Quote

Old   September 27, 2012, 10:56
Question
  #3
Member
 
Vitor Vasconcelos
Join Date: Jan 2012
Posts: 33
Rep Power: 5
vitors is on a distinguished road
Thanks Bernhard.

I took a look on the source code but I could not realize how to get the orientation of cells. Reading openFoam documentation, I saw no method in fvPatch which somehow give me faces orientation.

A newbie question: there is any orientation (xyz axis) in a mesh file? Or every face are identified by its neighbours? More: how to know if a face is over another one?

Maybe these are stupid questions, but I quite new in the CFD field.

Thanks.

Vitor
vitors is offline   Reply With Quote

Old   September 27, 2012, 17:20
Default
  #4
Senior Member
 
kmooney's Avatar
 
Kyle Mooney
Join Date: Jul 2009
Location: Amherst, MA USA - San Diego, CA USA
Posts: 268
Rep Power: 8
kmooney is on a distinguished road
Quote:
Originally Posted by vitors View Post
Thanks Bernhard.

I took a look on the source code but I could not realize how to get the orientation of cells. Reading openFoam documentation, I saw no method in fvPatch which somehow give me faces orientation.

A newbie question: there is any orientation (xyz axis) in a mesh file? Or every face are identified by its neighbours? More: how to know if a face is over another one?

Maybe these are stupid questions, but I quite new in the CFD field.

Thanks.

Vitor
Something like this might work (copied from another cfdonline post.):
Code:
label patchID = mesh.boundaryMesh().findPatchID("myCylinderPatchName"); 

const polyPatch& cPatch = mesh.boundaryMesh()[patchID]; 

vectorList faceNormals(mesh.boundaryField().size(),vector::zero)

forAll(cPatch, faceI) 
{ 
const face& myFace = mesh.boundaryField()[patchID][faceI];
 
faceNormals[faceI] = myFace.normal(mesh.points()); 
}
I wrote this off the top of my head so there might be a bug. If it doesn't work just let me know and I'll fix it! Good luck!

Cheers!
kmooney is offline   Reply With Quote

Old   October 4, 2012, 15:02
Question
  #5
Member
 
Vitor Vasconcelos
Join Date: Jan 2012
Posts: 33
Rep Power: 5
vitors is on a distinguished road
Hello kmooney,

I am studying the code you posted to have a deeper understand of it. Actually, I intend to understand OpenFOAM's classes and structures.

Code:
label patchID = mesh.boundaryMesh().findPatchID("myCylinderPatchName");
const polyPatch& cPatch = mesh.boundaryMesh()[patchID];
vectorList faceNormals(mesh.boundaryField().size(),vector::zero);
forAll(cPatch, faceI)  
{      
    const face& myFace = mesh.boundaryField()[patchID][faceI];       
    faceNormals[faceI] = myFace.normal(mesh.points());
}
At the first line you get que ID of the patch of which I need to get the faces. Ok.

But in the second line, you directly access a position in the boundaryMesh() method (which give us a boundaryMesh) related to the patchID. I can imagine it works, but I could find no method to access on patch, only the patch() method which gives me a list of patches. I feel like using direct access ([]) to a structure I don't know quite unconfortable. Do you have any pointers about documentation on how can I use these datastructures?

I'm frozen in these lines by now. I ask more questions when I arrive to the faceI variable you mentioned in your code.

Thank you very much for the code example and all your help. I have to say is almost impossible to start program in OpenFOAM without help like yours.

Vitor
vitors is offline   Reply With Quote

Old   October 4, 2012, 15:13
Default
  #6
Senior Member
 
kmooney's Avatar
 
Kyle Mooney
Join Date: Jul 2009
Location: Amherst, MA USA - San Diego, CA USA
Posts: 268
Rep Power: 8
kmooney is on a distinguished road
A good place to check for 'documentation' would be in the source code headers (.H files).

In the case of the boundaryMesh access, check out OpenFOAM-version/src/OpenFOAM/lnInclude/polyMesh.H

You'll see a lot of other useful class documentation in this lnInclude folder as well.
kmooney is offline   Reply With Quote

Old   October 4, 2012, 15:27
Default
  #7
Member
 
Vitor Vasconcelos
Join Date: Jan 2012
Posts: 33
Rep Power: 5
vitors is on a distinguished road
Sorry, my fault! I realized now that boundaryMesh() gives me a fvBoundaryMesh instead of a boundaryMesh.

Still learning...

Thanks,

Vitor
vitors is offline   Reply With Quote

Reply

Tags
function in a patch, orientation, patch

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
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
Import gmsh msh to Foam adorean Open Source Meshers: Gmsh, Netgen, CGNS, ... 24 April 27, 2005 08:19
Multicomponent fluid Andrea CFX 2 October 11, 2004 05:12


All times are GMT -4. The time now is 14:26.