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

number of cells in each direction

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

Like Tree1Likes
  • 1 Post By chrisb2244

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 24, 2014, 12:31
Default number of cells in each direction
  #1
Senior Member
 
Join Date: Dec 2011
Posts: 121
Rep Power: 14
fshak92 is on a distinguished road
Hi,

Assume that i have a simple cubic domain with Cartesian grids.
Does anybody know how i can access these values, either with a function, or accessing to the 'blockMeshDict' file.

1) number of cells in each direction. I know mesh.nCells() or mesh.cells().size() returns the total number of cells, but i need the number in each direction.

2) length of the domain (x, y and z)

3) length of cells edges in each direction to have dx, dy and dz.(the cells are uniform in each direction)
(at the moment, i compute dx, dy and dz by computing the distance between cell's centers, but i'm looking for any other ways)

Of course, either (1) or (2) can solve my problem, because having two of those three cases can be used to evaluate the remained one.

Tnx,
fshak92 is offline   Reply With Quote

Old   August 24, 2014, 22:40
Default
  #2
Member
 
Christian Butcher
Join Date: Jul 2013
Location: Japan
Posts: 85
Rep Power: 12
chrisb2244 is on a distinguished road
If you have access to the polyMesh object, then
Code:
 meshObject.edges()[edgeLabel].mag()
returns the scalar length of the edge indexed by the variable 'edgeLabel'. If your edges are all the same length, then that should sort your problems. If only your edges in each direction are the same, then you'll need an edge for each direction.

Using
Code:
 labelList listOfCellEdges(meshObject.cEdges()[cellLabel]);
forAll(listOfCellEdges, edgeI)
{
   // Iterate through the edges of cellI, which if your cells are uniform,
   // can be any cell
   // Use meshObject.edges()[edgeI].vec() to get the vector along the edge, or 
   // meshObject.edges()[edgeI].mag() to get it's magnitude.
}

Comparing these with the directions you're interested in shouldn't be too hard, I don't think. Then you just need to selectively store the ones you're interested in (eg first x, first y, first z direction).


If your region is cube/cuboid, then you can get the range of the directions by taking
Code:
vector extent(mesh_.cellCentres[mesh_.nCells()] - mesh_.cellCentres[0]);
extent += vector(dx, dy, dz) // where dx,y,z are set already, 
// since these take cell centres...
scalar sizeInXDirection = extent[0]; //etc
fshak92 likes this.
chrisb2244 is offline   Reply With Quote

Old   August 26, 2014, 02:35
Default
  #3
Senior Member
 
Jens Höpken
Join Date: Apr 2009
Location: Duisburg, Germany
Posts: 159
Rep Power: 17
jhoepken is on a distinguished road
Send a message via Skype™ to jhoepken
Are you trying to replicate a structured code on the unstructured FV method, implemented in OpenFOAM?
__________________
Blog: sourceflux.de/blog
"The OpenFOAM Technology Primer": sourceflux.de/book
Twitter: @sourceflux_de
Interested in courses on OpenFOAM?
jhoepken is offline   Reply With Quote

Old   August 26, 2014, 04:38
Default
  #4
Senior Member
 
Join Date: Dec 2011
Posts: 121
Rep Power: 14
fshak92 is on a distinguished road
Quote:
Originally Posted by jhoepken View Post
Are you trying to replicate a structured code on the unstructured FV method, implemented in OpenFOAM?
No,for different purpose.
fshak92 is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[mesh manipulation] Mesh Refinement Luiz Eduardo Bittencourt Sampaio (Sampaio) OpenFOAM Meshing & Mesh Conversion 42 January 8, 2017 12:55
Getting crazy with all the problems I have in OpenFoam Nicacio OpenFOAM Running, Solving & CFD 7 June 9, 2014 19:08
Cluster ID's not contiguous in compute-nodes domain. ??? Shogan FLUENT 1 May 28, 2014 15:03
[Other] Number of cells in each direction IvanaS OpenFOAM Meshing & Mesh Conversion 3 April 16, 2013 06:05
Unaligned accesses on IA64 andre OpenFOAM 5 June 23, 2008 10:37


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