Nabla Logo programmer
  Advanced Search
  
  Send us a comment/query
 
  Back to main web site
 
  OpenFOAM guides
  - User guide
  - Programmer’s guide
 
  Index
 
  Changes from OpenFOAM 2.2 to 2.3
 
  Trademarks in the guides
  ©2000-2007 Nabla Ltd.

A.1 Writing a mesh converter

The advice to a user writing a mesh converter is that once you have the capability to write lists of points, faces, cells and boundary in the format described in the next paragraph, contact Nabla Ltd. and we will be able to assist finishing the converter using the polyMesh class constructor in OpenFOAM. We strongly recommend that you do not try to write the mesh files yourself for two reasons: 1) we already have the necessary code to do this; 2) polyMesh reorganizes the point, face cell and boundary ordering to ensure efficient running of the solver. In particular, the faces in the mesh will be reordered in the upper triangular order, i.e. the ordering of the faces depends on the ordering of the cells. Writing the files yourself will not guarantee that the ordering is optimised for OpenFOAM.

The format of the lists that you should be able to write are described below and should adhere to the validity constraints in 6.1.1.

Points
A list of vectors. <x/y/z-coord> are floating point numbers.


<number of points>
(
    (<x-coord> <y-coord> <z-coord>)
    ...
)
    
Faces
Ordering of points in a face is crucial. <point label> is a positive integer, including zero. All faces must be either internal to the mesh, i.e. belonging to two cells, or belong to both a cell and a boundary patch.


<number of faces>
(
    <number of points in face> ( <point label1> <point label2> ... )
    ...
)
    
Cells
Ordering of faces in a cell is not important. <face label> is a positive integer, including zero.


<number of cells>
(
    <number of faces in cell> ( <face label1> <face label2>  ... )
    ...
)
    
Boundary
A list of patches where a patch is itself a list of face labels, where all faces will share the same boundary condition. Ordering of patches or faces in the patch is not important.


<number of patches>
(
    <number of faces in patch 0> ( <face label1> <face label2> ... )
    <number of faces in patch 1> ( <face label1> <face label2> ... )
    ...
)
    

A.1.1 Example point, face, cell and boundary lists

The format described above is very close to the OpenFOAM file format and we reiterate that once a user develops a mesh converter to this point, the existing library functions of OpenFOAM should be used to complete the job. An example set of lists for a simple mesh consisting of 4 hexahedra and 4 boundary patches is given below to provide final confirmation of the format.

Points
 


18
(
(0 0 0)
(0.5 0 0)
(1 0 0)
(0 0.5 0)
(0.5 0.5 0)
(1 0.5 0)
(0 1 0)
(0.5 1 0)
(1 1 0)
(0 0 0.3)
(0.5 0 0.3)
(1 0 0.3)
(0 0.5 0.3)
(0.5 0.5 0.3)
(1 0.5 0.3)
(0 1 0.3)
(0.5 1 0.3)
(1 1 0.3)
)
    
Faces
 


20
(
4 (1 4 13 10)
4 (3 12 13 4)
4 (4 13 14 5)
4 (4 7 16 13)
4 (6 15 16 7)
4 (7 16 17 8)
4 (0 1 10 9)
4 (1 2 11 10)
4 (0 9 12 3)
4 (3 12 15 6)
4 (2 5 14 11)
4 (5 8 17 14)
4 (0 3 4 1)
4 (3 6 7 4)
4 (1 4 5 2)
4 (4 7 8 5)
4 (9 10 13 12)
4 (12 13 16 15)
4 (10 11 14 13)
4 (13 14 17 16)
)
    
Cells
 


4
(
6 (8 0 6 1 12 16)
6 (0 10 7 2 14 18)
6 (9 3 1 4 13 17)
6 (3 11 2 5 15 19)
)
    
Boundary
 


4
(
    2 (5 4)
    2 (6 7)
    4 (10 11 8 9)
    8 (12 13 14 15 16 17 18 19)
)