Can we have access to cells coordinates?
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 |
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 |
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 |
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. |
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, |
Quote:
|
Nikos suggest to create a "field" for a scalar as follows:
http://www.cfd-online.com/Forums/ope...neloodles.html #12 Quote:
|
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 |
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? |
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.
|
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 |
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:
Regards Jamal |
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).
|
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 |
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. |
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?
|
Hi Immortality,
Did you consider using the sample-tool? Either as post-processing tool or as functionObject during simulation... Cheers, L |
as post-processing
|
All times are GMT -4. The time now is 02:26. |