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

Cell size (x,y,z)

Register Blogs Community New Posts Updated Threads Search

Like Tree29Likes
  • 16 Post By ngj
  • 11 Post By Armin
  • 2 Post By Hxchange

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 13, 2010, 15:59
Default Cell size (x,y,z)
  #1
New Member
 
Armin Gh.
Join Date: Sep 2010
Location: Aachen,Germany
Posts: 29
Rep Power: 16
Armin is on a distinguished road
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,
Armin is offline   Reply With Quote

Old   September 14, 2010, 05:39
Default
  #2
Senior Member
 
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 23
l_r_mcglashan will become famous soon enough
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.
__________________
Laurence R. McGlashan :: Website
l_r_mcglashan is offline   Reply With Quote

Old   September 14, 2010, 07:11
Default
  #3
New Member
 
Armin Gh.
Join Date: Sep 2010
Location: Aachen,Germany
Posts: 29
Rep Power: 16
Armin is on a distinguished road
Hi l_r_mcglashan

thanks for the reply, I will look it up in Doxygen, then I would keep ya posted later today
Armin is offline   Reply With Quote

Old   September 14, 2010, 07:17
Default
  #4
New Member
 
Armin Gh.
Join Date: Sep 2010
Location: Aachen,Germany
Posts: 29
Rep Power: 16
Armin is on a distinguished road
Quote:
Originally Posted by l_r_mcglashan View Post
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 is offline   Reply With Quote

Old   September 14, 2010, 10:34
Default
  #5
New Member
 
Armin Gh.
Join Date: Sep 2010
Location: Aachen,Germany
Posts: 29
Rep Power: 16
Armin is on a distinguished road
Quote:
Originally Posted by l_r_mcglashan View Post
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??
Armin is offline   Reply With Quote

Old   September 14, 2010, 10:44
Default
  #6
Senior Member
 
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 23
l_r_mcglashan will become famous soon enough
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?
__________________
Laurence R. McGlashan :: Website
l_r_mcglashan is offline   Reply With Quote

Old   September 14, 2010, 11:38
Default
  #7
New Member
 
Armin Gh.
Join Date: Sep 2010
Location: Aachen,Germany
Posts: 29
Rep Power: 16
Armin is on a distinguished road
Quote:
Originally Posted by l_r_mcglashan View Post
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
Armin is offline   Reply With Quote

Old   September 14, 2010, 11:46
Default
  #8
Senior Member
 
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 23
l_r_mcglashan will become famous soon enough
Ok, why do you need the dimensions of the cell? Are the centres/faces not enough?
__________________
Laurence R. McGlashan :: Website
l_r_mcglashan is offline   Reply With Quote

Old   September 14, 2010, 12:27
Default
  #9
New Member
 
Armin Gh.
Join Date: Sep 2010
Location: Aachen,Germany
Posts: 29
Rep Power: 16
Armin is on a distinguished road
Quote:
Originally Posted by l_r_mcglashan View Post
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.
Armin is offline   Reply With Quote

Old   September 14, 2010, 12:47
Default
  #10
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,903
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
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
ngj is offline   Reply With Quote

Old   September 14, 2010, 13:45
Default
  #11
New Member
 
Armin Gh.
Join Date: Sep 2010
Location: Aachen,Germany
Posts: 29
Rep Power: 16
Armin is on a distinguished road
Quote:
Originally Posted by ngj View Post
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 }
Armin is offline   Reply With Quote

Old   January 21, 2016, 22:43
Thumbs up
  #12
New Member
 
Yen-Lung Chen
Join Date: Dec 2015
Posts: 1
Rep Power: 0
yl_chen is on a distinguished road
Thanks a lot.
yl_chen is offline   Reply With Quote

Old   August 3, 2016, 13:40
Default How to use the Codes
  #13
New Member
 
yuanyuanzhang
Join Date: Aug 2016
Posts: 1
Rep Power: 0
yuanyuanZhang is on a distinguished road
Hi,
I am relativ new with OpenFoam and can not get, how to use the Codes. Can someone help me?



best regards
Yuanyuan Zhang
yuanyuanZhang is offline   Reply With Quote

Old   December 19, 2016, 10:34
Default Where to put the code in?
  #14
New Member
 
HuangXin
Join Date: Dec 2016
Posts: 7
Rep Power: 10
Hxchange is on a distinguished road
Quote:
Originally Posted by ngj View Post
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

Hey, I have the same question ,and I want to know which file should I add your code into? Sorry I dont konw much about OpenFOAM.
I used snappyMesh and chtMultiRegionSimpleFoam ,where should I put your code into?
I want to get the cooridates of all the cells ,8 points for each cells, instead of only the cell centre points.
Thank you!
hnemati and reespanau like this.
Hxchange is offline   Reply With Quote

Old   January 25, 2018, 22:21
Default
  #15
Senior Member
 
Nguyen Duy Trong
Join Date: Apr 2014
Posts: 124
Rep Power: 12
ndtrong is on a distinguished road
Quote:
Originally Posted by ngj View Post
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
Hi Armin,

Have you check this method for computational domain constituted by multiblock mesh such as for the blockMesh dict of dambreaking case ?
ndtrong is offline   Reply With Quote

Old   May 8, 2020, 00:04
Default
  #16
Senior Member
 
krishna kant
Join Date: Feb 2016
Location: Hyderabad, India
Posts: 133
Rep Power: 10
kk415 is on a distinguished road
Can geometricDelta function be used to directly get the height, length and width?
kk415 is offline   Reply With Quote

Old   April 18, 2021, 13:27
Default
  #17
Member
 
Daniel
Join Date: May 2018
Posts: 43
Rep Power: 8
CFDanielGER is on a distinguished road
Hello everybody,

I have a question out of curiosity. Does the code mentioned earlier by ngj provide for every cell in the domain (so at the end we have a volScalarField) the length in x, y and z direction respectively? I am asking because for my implementation of a new hybrid turbulence model I need the dimensions of each cell in the domain in x, y and z (deltax, deltay and deltaz).

Many thanks for your help!
CFDanielGER is offline   Reply With Quote

Old   June 2, 2023, 04:16
Default
  #18
New Member
 
Charitha Rangana Dissanayaka
Join Date: Mar 2022
Posts: 6
Rep Power: 4
Charitha_Dissanayaka is on a distinguished road
ngj
Senior Member

to where I should put this code.
little bit strugling. if possible please let me know the path.
Charitha_Dissanayaka is offline   Reply With Quote

Old   June 2, 2023, 04:20
Default
  #19
New Member
 
Charitha Rangana Dissanayaka
Join Date: Mar 2022
Posts: 6
Rep Power: 4
Charitha_Dissanayaka is on a distinguished road
To which file this code should enter.
Please explain the path.
Charitha_Dissanayaka is offline   Reply With Quote

Reply


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
Superlinear speedup in OpenFOAM 13 msrinath80 OpenFOAM Running, Solving & CFD 18 March 3, 2015 06:36
OF 1.6 | Ubuntu 9.10 (64bit) | GLIBCXX_3.4.11 not found piprus OpenFOAM Installation 22 February 25, 2010 14:43
fluent add additional zones for the mesh file SSL FLUENT 2 January 26, 2008 12:55
[Commercial meshers] Trimmed cell and embedded refinement mesh conversion issues michele OpenFOAM Meshing & Mesh Conversion 2 July 15, 2005 05:15
Warning 097- AB Siemens 6 November 15, 2004 05:41


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