# How to get the heighth,length of a 2D cell?

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

November 24, 2009, 04:43
How to get the heighth,length of a 2D cell?
#1
Member

jingjing
Join Date: Mar 2009
Location: shanghai,China
Posts: 30
Rep Power: 10
I want to improve my postprocessing tool for my wave tank to make it suitable for a wave tank with non-uniform mesh.In order to get the average value of a field with non-uniform mesh,I have to calculate the size of each cell (the heigt,length,width of a rectangular cell) as a weight factor,but I don't know how to get this kind of geomertric information of a cell.
One method is to get the coordinate value of the vertices of a cell,then make one subtract another.But I
can't go on at the detail.
Code:
```
forAll(mesh.cellCentres,cellid)
{

if(abs(mesh.cellCentres[cellid].x()-x)<=deltaX/2)  //deltaX:the length of a cell, choose out the cells at the x point along the 2D wave tank

{
ncells++;
sumField+=field[cellid]*deltaY;//deltaY: the height of a cell
weight+=deltaY;

Info<<ncells<<"cell No"<< cellid <<"field value"<<field[cellid]<<endl;
}

}

sumField=sumField/weight;  //the average value of the gamma field at the x point along the wave tank```
The question is , how to calculate the deltaX,deltaY according to the cellid that has been chosen out.

in the following short script:
Code:
```const labelList patchCells = this->patch().faceCells();
const fvPatchScalarField& gamma=patch().lookupPatchField<volScalarField,scalar >("gamma");
const pointField& points = mesh.points();
forAll(patchCells,i)
{
labelList cellpoints=mesh.cellPoints(patchCells[i]);
label size=cellpoints.size();
for(int j=0,j<size,j++)    //???如何读取单元尺寸
{
points[cellpoints[j]].y()

...
gamma[patchCells[i]]*...
waveAtWavemaker_=...
｝```
I know something about how to access the coordinate value of a vertex of a cell,but I don't know how to access two vertices at the same time, if I could, of course I will get the height of a cell(2D)

Is there anyone can help me?Thanks

two attachments: the old version of the wave tank postprocessing tool,
and another is a new version waiting to be improved to postprocess the non-uniform mesh wave tank.
Attached Files
 waveElevationVStime.C (4.5 KB, 6 views) an improved version.C (4.2 KB, 7 views)

 December 2, 2009, 22:05 #2 Member   Richard Kenny Join Date: Mar 2009 Posts: 64 Rep Power: 11 isn't it possible to simply use gAverage (volume averaging)? Richard

 May 4, 2014, 16:49 #3 New Member   Join Date: Oct 2013 Posts: 19 Rep Power: 6 Hey guys, Do you know how i can find the deltaX, deltaY and deltaZ of a cell? I can use some thing like "scalar dx = mesh.C()[0].x() * 2.;" for serial, but for parallel case it needs many considerations... So do you know any simple function?

 March 25, 2015, 07:47 Did you get an answer to get dx, dy and dz? #4 New Member   Sam Fredriksson Join Date: Dec 2010 Posts: 20 Rep Power: 9 Did you get an answer to get dx, dy and dz?

June 8, 2016, 06:59
#5
Member

Lennart
Join Date: Feb 2016
Posts: 42
Rep Power: 4
Hey guys,

Quote:
 Originally Posted by Daniel73 Hey guys, Do you know how i can find the deltaX, deltaY and deltaZ of a cell? I can use some thing like "scalar dx = mesh.C()[0].x() * 2.;" for serial, but for parallel case it needs many considerations... So do you know any simple function?
Quote:
 Originally Posted by safre Did you get an answer to get dx, dy and dz?
Not sure if you're still interested in this (your question is from 2014), but this is how you can get the distances between cells:
Code:
`mesh.delta()`
It returns cell distances for each face as surfaceVectorField and is implemented as:
Code:
```forAll(owner, facei)

{
delta[facei] = C[neighbour[facei]] - C[owner[facei]];
}```
in fvMeshGeometry.C

 January 8, 2018, 19:16 #6 Member   Taher Chegini Join Date: Nov 2014 Location: Houston, Texas Posts: 85 Rep Power: 5 In case someone was looking for a complete answer, here is the code to get the deltas in each direction for each cell: Code: ```const surfaceVectorField& deltas = mesh().delta(); forAll(deltas, I) { Info<< "dx[" << I << "] = " << deltas[I].x() <

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post sebastian_vogl OpenFOAM Programming & Development 1 October 11, 2016 13:17 sebastian_vogl OpenFOAM Running, Solving & CFD 0 October 27, 2009 09:47 michele OpenFOAM Other Meshers: ICEM, Star, Ansys, Pointwise, GridPro, Ansa, ... 2 July 15, 2005 04:15 AB Siemens 6 November 15, 2004 05:41 CMB Siemens 1 December 4, 2003 05:05

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