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

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

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

Reply
 
LinkBack Thread Tools Display Modes
Old   November 24, 2009, 04:43
Default How to get the heighth,length of a 2D cell?
  #1
Member
 
jingjing
Join Date: Mar 2009
Location: shanghai,China
Posts: 30
Rep Power: 8
zhajingjing is on a distinguished road
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
File Type: c waveElevationVStime.C (4.5 KB, 3 views)
File Type: c an improved version.C (4.2 KB, 4 views)
zhajingjing is offline   Reply With Quote

Old   December 2, 2009, 22:05
Default
  #2
Member
 
Richard Kenny
Join Date: Mar 2009
Posts: 59
Rep Power: 9
richpaj is on a distinguished road
isn't it possible to simply use gAverage (volume averaging)?


Richard
richpaj is offline   Reply With Quote

Old   May 4, 2014, 16:49
Default
  #3
New Member
 
Join Date: Oct 2013
Posts: 19
Rep Power: 3
Daniel73 is on a distinguished road
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?
Daniel73 is offline   Reply With Quote

Old   March 25, 2015, 07:47
Default Did you get an answer to get dx, dy and dz?
  #4
New Member
 
Sam Fredriksson
Join Date: Dec 2010
Posts: 20
Rep Power: 6
safre is on a distinguished road
Did you get an answer to get dx, dy and dz?
safre is offline   Reply With Quote

Reply

Thread Tools
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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to determine the direction of cell face vectors on processor patches sebastian_vogl OpenFOAM Running, Solving & CFD 0 October 27, 2009 09:47
How to determine the direction of cell face vectors on processor patches sebastian_vogl OpenFOAM Programming & Development 0 October 26, 2009 13:10
Trimmed cell and embedded refinement mesh conversion issues michele OpenFOAM Other Meshers: ICEM, Star, Ansys, Pointwise, GridPro, Ansa, ... 2 July 15, 2005 04:15
Warning 097- AB CD-adapco 6 November 15, 2004 05:41
cell to cell relation CMB CD-adapco 1 December 4, 2003 05:05


All times are GMT -4. The time now is 13:56.