CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)

Hi there,
My first time to log on!
I am a newbie at OF and I have got one question.Is it possible to have access to cells coordinates? things like cells (i,j,k)
For this equation:
volScalarField exsray = exp(-beta*y);
beta is also volScalarField and y is the y-coordinate.
Can somebody help me out please?
BR

 villet August 14, 2009 08:53

This may look a bit tricky, but you can get the y-coordinate (scalarField) at cell center like this:

mesh.C().component(vector::Y)

or

mesh.C().component(1)

so use it in the place of "y" in your equation. Basically "mesh.C()" is a vector field of cell center coordinates. I'm sure after this it's easier to look for more examples.

Ville

 kathrin_kissling August 14, 2009 09:27

take a look in the primitiveMesh, fvMesh and polyMesh class. You can reach this information eather in the code or by using the doxygen. (Just use the search function)
There you will find a lot of useful functions.

For more Information try to search for the paper primitiveMesh, polyMesh, fvMesh - The OpenFOAM mesh hierarchy by Alberto Passalacqua and Jaswinder Pal Singh. It must be out there.

Regards

Kathi

 sandy August 14, 2009 10:56

Hi guys, look at here: http://www.tfd.chalmers.se/~hani/kurser/OS_CFD_2008/primitiveMeshDraftVersion.pdf.

However, I ever tried to find out all vertex coodinates of some cell or face from constant/PolyMesh but not the central position of a cell.

 kathrin_kissling August 15, 2009 04:16

Hi Sandy,

maybe I my answer was a bit unclear.
I didn't mean you should read each cell centre from constant/polyMesh. It is not possible. constant/polyMesh just stores the cell vertices, their connection to the faces and the connectivity (its in owner and neighbors). In earlier versions there was also the connection to the cells stored, but this was removed some time ago.
Apart from all that, you don't want to read it from files, do you?

To access all other values apart from that, you must apply some macros in code. For example: (in fvMesh class)
cellVolumes mesh.V()
cellCentres mesh.C()
faceCentres mesh.Cf()

fvMesh class is located in src/finiteVolume/fvMesh

mesh is usually declared as fvMesh& mesh = yourDesiredVariable.mesh()

yourDesiredVariable may be everything like U, pd, gamma,... defined with a mesh structure lying in the background.

Best regards,

Kathi

Hi guys!
Thank you so much answering,so grateful to you!!
I will take a look at the primitiveMesh,as I'm downloading the document you're proposing me I guess I'll have more understanding about it.
I'll keep you aware.
Best Regards,

Hi guys,
I tried to use this "mesh.C().component(vector::Y)" as you advised and it works well but I think I'm gonna take a look at the documents you recomended to gain more understanding
Thank you so much,nice of you!!!
Best Regards,

 sandy August 18, 2009 05:59

Quote:
 Originally Posted by kathrin_kissling (Post 226439) mesh is usually declared as fvMesh& mesh = yourDesiredVariable.mesh() yourDesiredVariable may be everything like U, pd, gamma,... defined with a mesh structure lying in the background. Best regards, Kathi
Hi Kathi, if that, I also can defined some scalars with a mesh structure, for example the driving pressure gradient (gradP) et al., right? Whether or not it means I actually creat a field for this scalar gradP and can use a probe of it in ControlDict of some case? Thanks.

 sandy August 18, 2009 06:11

Nikos suggest to create a "field" for a scalar as follows:

http://www.cfd-online.com/Forums/ope...neloodles.html #12

Quote:
Are there some differences to your methods in order to create a field for a scalar? Thanks.

 kathrin_kissling August 18, 2009 07:06

Hi sandy,

what are you actually trying? Do you want to declare any volScalarField with mesh structure? Than go with Nikos way.
What I explained to Ariannah is how to get the mesh structure back from a volVectorField/volScalarField/volTensorField...
This is what Adriannah needed for reaching the cellCentres. You need the mesh structure.
Its two totally different things to do.

If you can explain to me what your exact problem is, I can try to help you.

Best regards
Kathi

 sandy August 18, 2009 20:33

Hi Kathi, please don't mind me to offset away from this topic. I ever declared a volScalarField in createFields.H of my case as similar as Nikons:

volScalarField FieldOnes
(
IOobject
(
"FieldOnes",
runTime.timeName(),
mesh,
IOobject::AUTO_WRITE
),
);

But, its values could not been exported in the directory. I don't know why. I guess I missed somthing. Maybe I should firstly define it in some basic class? So, when your posts refered to the fvMesh to define any "yourDesiredVariable", I misunderstand I can get any Field definition and declaration by this way. Sorry...

However, do you know how to create and export a scalar Field totally defined by yourself?

 sandy August 20, 2009 05:42

Hi Kathi, I can also get some point sources quickly from the Probe Location (Filters<Alphabetical<Probe Location<point source) in paraFoam. However, do you know the coordinate in it is the cell central position or vertex value? Thanks.

 kathrin_kissling August 20, 2009 08:38

Hi Sandy,

sorry for the delay.
The createFields.H is called by a solver, right?
Try
volScalarField FieldOnes
(
IOobject
(
"FieldOnes",
runTime.timeName(),
mesh,
IOobject::AUTO_WRITE
),
);

for any calculation.

If you jsut want to have a volScalarField filled with 1 try
volScalarField FieldOnes
(
IOobject
(
"FieldOnes",
runTime.timeName(),
mesh,
IOobject::AUTO_WRITE
),
mesh,
dimsionedScalar("one", dimless, 1)
);

The probes are cellCentres I think, but I'm not sure about that.

Regards

Kathi

 aujamal20 November 19, 2012 13:29

Dear all

I need to creat a temperature field file along with cell centre information(x,y,z) in every time step. I have tried different options to do that but failed. Following are the line from createFields.H to create T

Quote:
 Info<< "Reading field T\n" << endl; volScalarField T ( IOobject ( "T", mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh );
I need to know that how i can modifiy these lines to get desired T field with cell coordinates.

Regards

Jamal

 Lieven November 19, 2012 15:05

You can use the writeCellCentres tool to obtain the coordinates of each cell. This way you get four files giving you coordinates (ccx, ccy, ccz) and T-field (T).

 aujamal20 November 20, 2012 06:44

Dear

thanks for your response and now i am able to get cell coordinate files. I am not sure wheather temperature values are arranged in the same sequence as the coordinate files. Do you? As i need to have the temperature profile according to the cell location.

Regards

 Lieven November 20, 2012 07:06

They are arranged in exactly the same way. So if you would combine the four files into one you would get (x,y,z,T) data

From that point on its up to you how to process the data. If you have Matlab at your disposal, one of the options you have is using triScatteredInterp to obtain an interpolating function. Check out http://www.mathworks.nl/help/matlab/...redinterp.html for more information on this.

 immortality February 17, 2013 18:09

dear Lieven is it possible to obtain pressure,velocity and temperature at a specific cell center(that is neighbor of a boundary patch) with "writeCellCentres"?how?is it possible without need to programming?

 Lieven February 19, 2013 06:53

Hi Immortality,

Did you consider using the sample-tool? Either as post-processing tool or as functionObject during simulation...

Cheers,

L

 immortality February 19, 2013 15:02

as post-processing

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