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

Accessing dimensions (x, y, z) of cells

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By olesen
  • 1 Post By olesen

 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old   April 30, 2021, 07:37
Default Accessing dimensions (x, y, z) of cells
  #1
Member
 
Daniel
Join Date: May 2018
Posts: 43
Rep Power: 8
CFDanielGER is on a distinguished road
Hello everybody,


for a new hybrid turbulence model I want to implement I need the dimensions of each cell to calculate a new delta. I found a way of calculating the dimensions in each direction (x, y, z) in meter. See code attached:


Code:
  const faceList & ff = this->mesh().faces();
  const pointField & pp = this->mesh().points();
  volScalarField deltax = this->y_;
  volScalarField deltay = this->y_;
  volScalarField deltaz = this->y_;

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

    forAll(pLabels, pointi)
    {
      pLocal[pointi] = pp[pLabels[pointi]];
    }

    dimensionedScalar Convert ("Convert", dimensionSet(0, 1, 0, 0, 0, 0, 0), scalar(1));

    deltax = (Foam::max(pLocal & vector(1,0,0)) - Foam::min(pLocal & vector(1,0,0))) * Convert;
    deltay = (Foam::max(pLocal & vector(0,1,0)) - Foam::min(pLocal & vector(0,1,0))) * Convert;
    deltaz = (Foam::max(pLocal & vector(0,0,1)) - Foam::min(pLocal & vector(0,0,1))) * Convert;
  }
I think the code is working fine, at least it is compiling and a few iterations are running but I have to check further.


But my question is:


Is there a more effective way of computing the cell dimensions in x, y and z than using a forAll loop? I have the impression that this is rather time-consuming when using a large mesh.



Many thanks for your help!


Daniel
CFDanielGER is offline   Reply With Quote

 


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
[ICEM] Problem with prism cells sidharath ANSYS Meshing & Geometry 0 September 1, 2015 07:09
Accessing neighboring cells' cell number Daniel Lattin Siemens 4 October 20, 2006 16:19
physical boundary error!! kris Siemens 2 August 3, 2005 00:32
Accessing neighbouring cells in UDF Hiranya Nath FLUENT 5 March 22, 2002 23:29
Accessing neighboring cells in UDF Christian FLUENT 1 January 18, 2002 22:06


All times are GMT -4. The time now is 16:43.