# Write OpenFOAM meshes

(adapted from http://openfoam.cfd-online.com/cgi-bin/forum/show.cgi?1/1507)

- All meshes are 3D. Use single layer of cells with empty front and back patches to create a 2D simulation.

- Meshes are defined by five files:

points (x y z) point locations

owner, neighbour for every face the (labels of the) cells on either side. The owner cell should be the lowest numbered cell. Boundary faces have -1 as neighbour.

faces for each face an ordered list of point labels. The normal (righthand rule) should point away from the owner cell (so the boundary faces point out of the domain)

The face ordering is quite intricate:

- internal faces get ordered such that when stepping through the higher numbered neighbouring cells in incremental order one also steps through the corresponding faces in incremental order (upper-triangular ordering)

- boundary faces are bunched per patch. The boundary file then tells where the start and size of the patch are in the faces list. For coupled faces there is an additional ordering inside the patch:

- cyclics: should be ordered such that face 'i' is coupled to face 'i + size()/2' where size() is the number of faces of the patch. Additionally the 0th point of a face is considered coupled to the 0th point of its coupled face.

- processor: should be ordered such that face 'i' on one processor is coupled to face 'i' on the neighbouring processor. Same additional constraint on the order of the points in a face as cyclics.