CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

Can we have access to cells coordinates?

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

Like Tree4Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 14, 2009, 07:18
Default Can we have access to cells coordinates?
  #1
New Member
 
andrianah scott
Join Date: Aug 2009
Posts: 8
Rep Power: 16
adrianahscott is on a distinguished road
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?
Thanks in advance!
BR
adrianahscott is offline   Reply With Quote

Old   August 14, 2009, 08:53
Default
  #2
Member
 
Ville Tossavainen
Join Date: Mar 2009
Posts: 60
Rep Power: 17
villet is on a distinguished road
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
Luttappy likes this.
villet is offline   Reply With Quote

Old   August 14, 2009, 09:27
Default
  #3
Senior Member
 
Kathrin Kissling
Join Date: Mar 2009
Location: Besigheim, Germany
Posts: 134
Rep Power: 17
kathrin_kissling is on a distinguished road
Hi Adrianah,

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
kathrin_kissling is offline   Reply With Quote

Old   August 14, 2009, 10:56
Default
  #4
Senior Member
 
Sandy Lee
Join Date: Mar 2009
Posts: 213
Rep Power: 18
sandy is on a distinguished road
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.
Venu Angirekula likes this.
sandy is offline   Reply With Quote

Old   August 15, 2009, 04:16
Default
  #5
Senior Member
 
Kathrin Kissling
Join Date: Mar 2009
Location: Besigheim, Germany
Posts: 134
Rep Power: 17
kathrin_kissling is on a distinguished road
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
skyoon likes this.
kathrin_kissling is offline   Reply With Quote

Old   August 15, 2009, 05:54
Default
  #6
New Member
 
andrianah scott
Join Date: Aug 2009
Posts: 8
Rep Power: 16
adrianahscott is on a distinguished road
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,
adrianahscott is offline   Reply With Quote

Old   August 18, 2009, 03:31
Default
  #7
New Member
 
andrianah scott
Join Date: Aug 2009
Posts: 8
Rep Power: 16
adrianahscott is on a distinguished road
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,
adrianahscott is offline   Reply With Quote

Old   August 18, 2009, 05:59
Default
  #8
Senior Member
 
Sandy Lee
Join Date: Mar 2009
Posts: 213
Rep Power: 18
sandy is on a distinguished road
Quote:
Originally Posted by kathrin_kissling View Post

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 is offline   Reply With Quote

Old   August 18, 2009, 06:11
Default
  #9
Senior Member
 
Sandy Lee
Join Date: Mar 2009
Posts: 213
Rep Power: 18
sandy is on a distinguished road
Nikos suggest to create a "field" for a scalar as follows:

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

Quote:
Originally Posted by nikos_fb16 View Post

There you see, that only fields can be probed, not scalars like gradP in channelOodles. So you have to create a field containing the value of gradP (I called it gradPField) in order to get the probes of it.

Creating gradPField:

1. create the following two fields in createFields.H:

volScalarField FieldOnes
(
IOobject
(
"FieldOnes",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,gradP/gradP
);

volScalarField gradPField
(
IOobject
(
"gradPField",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,scalar(0)*gradP
);

Nikos
Are there some differences to your methods in order to create a field for a scalar? Thanks.
sandy is offline   Reply With Quote

Old   August 18, 2009, 07:06
Default
  #10
Senior Member
 
Kathrin Kissling
Join Date: Mar 2009
Location: Besigheim, Germany
Posts: 134
Rep Power: 17
kathrin_kissling is on a distinguished road
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
kathrin_kissling is offline   Reply With Quote

Old   August 18, 2009, 20:33
Default
  #11
Senior Member
 
Sandy Lee
Join Date: Mar 2009
Posts: 213
Rep Power: 18
sandy is on a distinguished road
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::NO_READ,
IOobject::AUTO_WRITE
),
mesh,gradP/gradP
);

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 is offline   Reply With Quote

Old   August 20, 2009, 05:42
Default
  #12
Senior Member
 
Sandy Lee
Join Date: Mar 2009
Posts: 213
Rep Power: 18
sandy is on a distinguished road
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.
sandy is offline   Reply With Quote

Old   August 20, 2009, 08:38
Default
  #13
Senior Member
 
Kathrin Kissling
Join Date: Mar 2009
Location: Besigheim, Germany
Posts: 134
Rep Power: 17
kathrin_kissling is on a distinguished road
Hi Sandy,

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

for any calculation.

forget about the second mesh before the operation gradP/gradP.
If you jsut want to have a volScalarField filled with 1 try
volScalarField FieldOnes
(
IOobject
(
"FieldOnes",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimsionedScalar("one", dimless, 1)
);

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

Regards

Kathi
kathrin_kissling is offline   Reply With Quote

Old   November 19, 2012, 12:29
Default
  #14
Member
 
Jamal
Join Date: May 2012
Location: Freiburg
Posts: 54
Rep Power: 12
aujamal20 is an unknown quantity at this point
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
aujamal20 is offline   Reply With Quote

Old   November 19, 2012, 14:05
Default
  #15
Senior Member
 
Lieven
Join Date: Dec 2011
Location: Leuven, Belgium
Posts: 299
Rep Power: 22
Lieven will become famous soon enough
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).
arsenis likes this.
Lieven is offline   Reply With Quote

Old   November 20, 2012, 05:44
Default
  #16
Member
 
Jamal
Join Date: May 2012
Location: Freiburg
Posts: 54
Rep Power: 12
aujamal20 is an unknown quantity at this point
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
aujamal20 is offline   Reply With Quote

Old   November 20, 2012, 06:06
Default
  #17
Senior Member
 
Lieven
Join Date: Dec 2011
Location: Leuven, Belgium
Posts: 299
Rep Power: 22
Lieven will become famous soon enough
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.
Lieven is offline   Reply With Quote

Old   February 17, 2013, 17:09
Default
  #18
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26
immortality is on a distinguished road
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?
immortality is offline   Reply With Quote

Old   February 19, 2013, 05:53
Default
  #19
Senior Member
 
Lieven
Join Date: Dec 2011
Location: Leuven, Belgium
Posts: 299
Rep Power: 22
Lieven will become famous soon enough
Hi Immortality,

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

Cheers,

L
Lieven is offline   Reply With Quote

Old   February 19, 2013, 14:02
Default
  #20
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26
immortality is on a distinguished road
as post-processing
immortality is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to get node coordinates for free surface cells fred FLUENT 1 August 15, 2014 01:52
[Netgen] Import netgen mesh to OpenFOAM hsieh OpenFOAM Meshing & Mesh Conversion 32 September 13, 2011 05:50
Access to the derivatives of quantities at cells Parsa Zamankhan FLUENT 0 September 18, 2007 19:30
Center coordinates of all the cells in a cellset lizhihua Siemens 0 August 21, 2006 03:59
physical boundary error!! kris Siemens 2 August 3, 2005 00:32


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