CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Cell size (x,y,z) (http://www.cfd-online.com/Forums/openfoam-programming-development/80038-cell-size-x-y-z.html)

Armin September 13, 2010 14:59

Cell size (x,y,z)
 
Hi folks,

I'm trying to write an apllication on openfoam wich utilizes the surface compression to produce an initial condition as a wave in a two phase environment, in this code I need to call the individual cells in a loop and use their height, length and depth(x,y,z Dimensions) ,

The problem is, I don't seem to find the access function for that, the only thing I find is the V() access function which gives the volume of the cell.

So in desperation , I am open to any suggestion.

Thanks,

l_r_mcglashan September 14, 2010 04:39

You can get a list of vertices using mesh.points();

Have you looked at fvMesh, polyMesh and primitiveMesh in the doxygen pages? Between them there must be the functionality you're looking for.

Armin September 14, 2010 06:11

Hi l_r_mcglashan

thanks for the reply, I will look it up in Doxygen, then I would keep ya posted later today

Armin September 14, 2010 06:17

Quote:

Originally Posted by l_r_mcglashan (Post 275105)
You can get a list of vertices using mesh.points();

Have you looked at fvMesh, polyMesh and primitiveMesh in the doxygen pages? Between them there must be the functionality you're looking for.

Hi l_r_mcglashan

thanks for the reply, I will look it up in Doxygen, then I would keep ya posted later today

Armin September 14, 2010 09:34

Quote:

Originally Posted by l_r_mcglashan (Post 275105)
You can get a list of vertices using mesh.points();

Have you looked at fvMesh, polyMesh and primitiveMesh in the doxygen pages? Between them there must be the functionality you're looking for.

Hi I looked up the things you told but , I cant get a hang of it!
It's weird because OpenFOAM should use the dimensions to calculate the volume of cell V(). I dont know how else could it do that????

any other suggestions??

l_r_mcglashan September 14, 2010 09:44

If you click through the documentation you'll find the cell volume calculation in the function:
Code:

Foam::primitiveMesh::makeCellCentresAndVols
I assume your grid is made up of lots of squares/cubes? What exactly are you trying to calculate?

Armin September 14, 2010 10:38

Quote:

Originally Posted by l_r_mcglashan (Post 275164)
If you click through the documentation you'll find the cell volume calculation in the function:
Code:

Foam::primitiveMesh::makeCellCentresAndVols
I assume your grid is made up of lots of squares/cubes? What exactly are you trying to calculate?


Yep that's right,

it's actually just a box, but with an insane amount of cells. because it is needed to validate our calculations in next step of the work.
as a initial condition a simple wave is being introduced to the interface of the water-air, and it would vibrate to become a line .

the things is we have written a code already that puts the wave at the interface, but every time we change the Mesh we have to change the code with the new cell sizes. (it is something like setFieldsdict in dam break example)
I just want to automate it so that it could change itself after every change in Mesh.

Did I make it clear? :)

I still haven't found any useful access function for the cell dim.:)

Thanks

l_r_mcglashan September 14, 2010 10:46

Ok, why do you need the dimensions of the cell? Are the centres/faces not enough?

Armin September 14, 2010 11:27

Quote:

Originally Posted by l_r_mcglashan (Post 275179)
Ok, why do you need the dimensions of the cell? Are the centres/faces not enough?

the code needs it to specify if the individual cells are actually in the gas or liquid phase. These are the cells which are at the gas-liquid interface.

respectively these cells would be assigned a number between 0 and 1. 0 for gas phase and 1 for liquid.
So it's not enough to have the center, the hight of the cell gives us actually how much of the cell is placed in liquid or gas phase , and the number makes it understandable for OpenFOAM.

ngj September 14, 2010 11:47

Hi Armin

What you need to do is the following:

Code:

const faceList & ff = mesh.faces();
const pointField & pp = mesh.points();

forAll ( mesh.C(), celli)
{
    const cell & cc = mesh.cells()[celli];
    labelList pLabels(cc.labels(ff));
    pointField pLocal(pLabels.size(), vector::zero);

    forAll (pLabels, pointi)
          pLobal[pointi] = pp[pLabels[pointi]];

    scalar xDim = Foam::max(pLocal & vector(1,0,0)) - Foam::min(pLocal & vector(1,0,0));

    // And similar for yDim and zDim
}

Please be aware that the above code has not been compiled. Further, the functionality you look for is not directly found in OF hence the above perhaps a bit cumbersome routine.

Best regards,

Niels

Armin September 14, 2010 12:45

Quote:

Originally Posted by ngj (Post 275193)
Hi Armin

What you need to do is the following:

Code:

const faceList & ff = mesh.faces();
const pointField & pp = mesh.points();

forAll ( mesh.C(), celli)
{
    const cell & cc = mesh.cells()[celli];
    labelList pLabels(cc.labels(ff));
    pointField pLocal(pLabels.size(), vector::zero);

    forAll (pLabels, pointi)
          pLobal[pointi] = pp[pLabels[pointi]];

    scalar xDim = Foam::max(pLocal & vector(1,0,0)) - Foam::min(pLocal & vector(1,0,0));

    // And similar for yDim and zDim
}

Please be aware that the above code has not been compiled. Further, the functionality you look for is not directly found in OF hence the above perhaps a bit cumbersome routine.

Best regards,

Niels



Works like a charm, thanks a bunch .


PS:
Although for users who would use this code later,there is a minor dictation error. the correct one would be:

const faceList & ff = mesh.faces(); const pointField & pp = mesh.points(); forAll ( mesh.C(), celli) { const cell & cc = mesh.cells()[celli]; labelList pLabels(cc.labels(ff)); pointField pLocal(pLabels.size(), vector::zero); forAll (pLabels, pointi) pLocal[pointi] = pp[pLabels[pointi]]; scalar xDim = Foam::max(pLocal & vector(1,0,0)) - Foam::min(pLocal & vector(1,0,0)); // And similar for yDim and zDim }


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