CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Pre-Processing (https://www.cfd-online.com/Forums/openfoam-pre-processing/)
-   -   Defining local coordinate system (https://www.cfd-online.com/Forums/openfoam-pre-processing/63631-defining-local-coordinate-system.html)

 bastil April 14, 2009 18:22

Defining local coordinate system

Hi,

I want to define the directions for porosities based on their position in the mesh. Therefore I need a way to automatically define a local coordinate system that has a axis normal to a boundary patch (I know its name). How could this be realised? Looking forward for some advise.

Thanks.

 ngj April 15, 2009 03:43

Hi Bastil

First of all, the following assumes that the boundary patch is plane, thus the "x"-axis will be known as "mesh.Sf()[faceNo_1] / mag(mesh.Sf()[faceNo_1])", and as the patch is assumed to be plane, then a vector defined as

vector yaxis(mesh.Cf()[faceNo_2] - mesh.Cf()[faceNo_1]);
yaxis /= mag(yaxis)

will be perpendicular to the face normal. The final axis, i.e. z-axis, is defined by the cross product of the two above.

Here I assume that you know the face indices of two of the boundary faces on the patch.

Best regards,

Niels

P.S. I use mag(mesh.Sf()[faceNo]) in stead of mesh.magSf() as I have had problems with it returning 0. Unfortunately I have not found where the bug is.

 bastil April 15, 2009 05:21

Quote:
 Originally Posted by ngj (Post 212952) Hi Bastil vector yaxis(mesh.Cf()[faceNo_2] - mesh.Cf()[faceNo_1]); yaxis /= mag(yaxis) will be perpendicular to the face normal. The final axis, i.e. z-axis, is defined by the cross product of the two above. Here I assume that you know the face indices of two of the boundary faces on the patch.
Thanks Niels,

I am not really sure how to use this? Can I write this code into a ControlDict? What about dependencies? Might be very helpful to have a little example.
I know the name of the patch but not the indices of two faces - how can I get this?

Thanks once more.

 ngj April 15, 2009 05:58

Hi Bastil

Now you are talking about controlDict, I thought you simply wanted to make some addition to your solver.
You need to elaborate a bit on what it is you actually want to achieve and especially how.
Further I do not have any examples, as I have never been coding any such thing:)

Best regards,

Niels

 bastil April 15, 2009 07:57

Well I have a mesh where I want to set some porosites. I know the name of the patches surrounding these porous zones and the cell zones of the porous media itself.

I want to have a way to set the local coordinate system for each porosity so that one vector is normal to porous block. In generall this could be done in a program (maybe write a small preprocessing application?) or maybe another way? I have never done this before so I do not really know what is best.

Regards BastiL

 ngj April 15, 2009 08:35

Hi Bastil

Well, it does entirely depend on what you need this local coordinate system for?!?
As you say preprocessing, then a small utility is probably the way forward, and I assume you might get some inspiration from e.g. setFields.

Best regards,

Niels

 bastil April 15, 2009 09:01

Quote:
 Originally Posted by ngj (Post 212996) Hi Bastil Well, it does entirely depend on what you need this local coordinate system for?!?

Sor setting my porosity values. So it is only for preprocessing.

Regards.

 ngj April 15, 2009 11:56

Well, then you need to get the patch properties. The following might suffice:

const label patchID = mesh.boundaryMesh().findPatchID("patchName"); // Get the patch ID
const vectorField & cc = mesh.boundary()[patchID].Cf(); // Get the centroid of the individual boundary faces on the given patch
const vectorField & NN = mesh.boundary()[patchID].Sf(); // Get the normal vector of the individual boundary faces on the given patch

This information should be sufficient to generate the local coordinate system as the one you have requested.

Best regards,

Niels

 Marcus081 February 12, 2010 12:16

Coordinate System Components (v, w, x) ?

1 Attachment(s)
Hi, I have been using the version of ansys 12.1, and the coordinate system appears with these component (v, w, x) , I have not found the form to change it a (x, y, z), since I can do it?

 sega February 13, 2010 07:36

Quote:
 Originally Posted by Marcus081 (Post 245866) Hi, I have been using the version of ansys 12.1, and the coordinate system appears with these component (v, w, x) , I have not found the form to change it a (x, y, z), since I can do it?
If you refer to the new FLUENT version I suggest you put into the FLUENT-Forum. This is OpenFOAM ... :-)

 farahiam February 17, 2011 20:40

to define a new axis/coordinate system for porous media

[QUOTE=ngj;213029]Well, then you need to get the patch properties. The following might suffice:

const label patchID = mesh.boundaryMesh().findPatchID("patchName"); // Get the patch ID
const vectorField & cc = mesh.boundary()[patchID].Cf(); // Get the centroid of the individual boundary faces on the given patch
const vectorField & NN = mesh.boundary()[patchID].Sf(); // Get the normal vector of the individual boundary faces on the given patch

This information should be sufficient to generate the local coordinate system as the one you have requested.

Hi, regarding the information given above, may I know where is it applicable? Where should I put the coding as above? In which file? I have same problem where I need to define the porosity of my intercooler but the intercooler does not follow the same axis as the default one. So, I need to define a new axis for the intercooler.

Can anyone help? Thank you!
Best regards.

 calim_cfd August 8, 2011 08:26

Quote:
 Originally Posted by bastil (Post 212898) Hi, I want to define the directions for porosities based on their position in the mesh. Therefore I need a way to automatically define a local coordinate system that has a axis normal to a boundary patch (I know its name). How could this be realised? Looking forward for some advise. Thanks.
Hello every1!

kinda ressurecting the topic but i got the same issue.. i need to create a local coordinate system, but it is a cylindrical one so that i can indicate it in the porouszone dict and set the resistences??

thx a lot!

 All times are GMT -4. The time now is 13:52.