CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Native Meshers: blockMesh (
-   -   Does blockMesh create mesh vertices in any particular order (

brooksmoses December 5, 2005 22:20

As I mentioned in a different
As I mentioned in a different thread ("Code to read in results on a BlockMesh-created mesh as structured arrays", under "Postprocessing"), I'm needing to read in some OpenFOAM data into another program that's expecting a structured mesh.

All my meshes are created with blockMesh, which creates a mesh that "looks like" a structured mesh, so I'm hoping I can use that fact to make it easier to read in my data.

Thus, my question: is there any particular order to how blockMesh creates the points in the pointList, and the cells in the cellList? Does it create them by nested loops in the three coordinate directions and number them in that order, or is it more complicated than that? Does it always do them in the same order?

(I know I could figure most of this out with some tests -- except for that last question! So that's why I'm asking.)


mattijs December 6, 2005 05:41

Yes, cells are always created
Yes, cells are always created in i,j,k order. Don't know exactly which comes first though. Try on a simple case.

Don't know about multi-block meshes. Guess still it will do one block after the other. The shared points though will be treated differently.

You can always check the code ($FOAM_UTILITIES/mesh/generation/blockMesh)

hjasak December 6, 2005 05:55

The vertices are created block
The vertices are created block by block in the order of block definition. Once all the blocks are created, there is a multi-pass vertex merge algorithm which always keeps the vertex with the lowest label.

The vertices are created in the blockPoints.C:

for (label k = 0; k <= nk; k++)
for (label j = 0; j <= nj; j++)
for (label i = 0; i <= ni; i++)
label vertexNo = vtxLabel(i, j, k);

vector edgex1 = start*(1.0 - edgeWeights[0][i])
+ xEnd*edgeWeights[0][i];

vector edgex2 = yEnd*(1.0 - edgeWeights[1][i])
+ xyEnd*edgeWeights[1][i];

etc. etc.

In other words, the x (or i) index changes fastest, then j and then k.



brooksmoses December 12, 2005 21:26

Thanks for the advice, both of
Thanks for the advice, both of you; it was quite helpful! (And thanks particularly to Hrv for posting the code and reminding me that the internals of blockMesh really aren't as scary as I thought they might be.)

All times are GMT -4. The time now is 03:39.