CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Patch orientation (https://www.cfd-online.com/Forums/openfoam-programming-development/107307-patch-orientation.html)

vitors September 23, 2012 19:58

Patch orientation
 
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

Bernhard September 24, 2012 02:21

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.

vitors September 27, 2012 10:56

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

kmooney September 27, 2012 17:20

Quote:

Originally Posted by vitors (Post 383933)
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!

vitors October 4, 2012 15:02

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

kmooney October 4, 2012 15:13

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.

vitors October 4, 2012 15:27

Sorry, my fault! I realized now that boundaryMesh() gives me a fvBoundaryMesh instead of a boundaryMesh.

Still learning...

Thanks,

Vitor


All times are GMT -4. The time now is 07:06.