Skip to content

ENH: cellDecomposer: functionObject to map fields to 'tet' mesh.

Mattijs Janssens requested to merge feature-cellDecomposer into develop

New field function object: polyhedral cell conversion

The function object cellDecomposer decomposes cells into 'basic' shapes and maps selected fields onto it (similar to mapFields). The main benefit is for postprocessing OpenFOAM meshes and results with third-party tools that cannot handle polyhedral shapes.

There are two main controls:

  • selection of cells. This takes all the same controls as any fvOption so e.g. selectionMode all or selectionMode cellSet
  • method of decomposition through decomposeType:
    • faceCentre : decompose cells into tets using face centre and cell centre. (hex becomes 6*4 tets)
    • faceDiagonal : decompose cells into tets using face diagonal, similar to the decomposition inside lagrangian tracking. (hex becomes 6*2 tets)
    • pyramid : keep faces intact but create (polygonal-base) pyramids using cell centre. (hex becomes 6 pyramids)
    • faceDiagonalQuads : like faceDiagonal but split faces into quads and triangles instead of just triangles.
    • polyhedral : like faceDiagonalQuads but only decompose non-hex/prism/tet cells in selected set. Used to convert polyhedral mesh into 'simple' mesh.

A typical example to convert all polyhedral cells into a sub-region mesh containing non-polyhedral cells only:

    functions
    {
        cellDecomposer
        {
            // Mandatory entries
            type            cellDecomposer;
            fields          (p U);
            mapRegion       simpleMesh;

            // Decompose type
            decomposeType   polyhedral;
            // Which cells to convert
            selectionMode   all;
        }
    }

This mesh and results can then be handled using the usual -region option:

checkMesh -region simpleMesh
foamToEnsight -region simpleMesh

Another example to convert all cells in a certain geometric region to tetrahedra:

    functions
    {
        cellDecomposer
        {
            // Mandatory entries
            type            cellDecomposer;
            fields          (p U);
            mapRegion       tetMesh;

            // Decompose type
            decomposeType   faceCentre;
            // Which cells to convert
            selectionMode   geometric;
            // Generate cellSet c0 using topoSet commands:
            cellSet         c0;
            selection
            {
                a
                {
                    action  use;
                    source  boxToCell;
                    box     (1 1 1)(0 0 0);
                }
                b
                {
                    action  invert;
                }
            }
        }
    }

Limitations

  • mesh motion is not handled
  • topology change is not handled
  • limited testing
  • decomposing a cell with refinement can lead to multiple faces in between two cells:
    • a hex gets two edges split because edge-connected cells get refined
    • (this hex now is a polyhedral cell)
    • the edge on the original hex would get split into two neighbouring tetrahedra but now the quad in between is split into two triangles, both sharing the same two cells
  • in checkMesh this shows up as
Checking topology...
    ..
  <<Found 2015 neighbouring cells with multiple inbetween faces.
    Upper triangular ordering OK.
  <<Writing 4034 unordered faces to set upperTriangularFace
  • splitting complex cells can quite easily generate geometrically invalid cells, e.g.
***High aspect ratio cells found, Max aspect ratio: 1.59875e+96, number of cells 99
  <<Writing 99 cells with high aspect ratio to set highAspectRatioCells
    Minimum face area = 1.34886e-06. Maximum face area = 1.00344.  Face area magnitudes OK.
 ***Zero or negative cell volume detected.  Minimum negative volume: -3.55077e-07, Number of negative volume cells: 99
  <<Writing 99 zero volume cells to set zeroVolumeCells
    Mesh non-orthogonality Max: 158.664 average: 21.4979
Edited by Andrew Heather

Merge request reports