OpenFOAM® v2006: New and improved pre-processing

OpenFOAM® v2006: New and improved pre-processing

30/06/2020

Improved blockMesh utility

blockMesh now uses a faster topological merge that works better for high aspect ratio meshes. Where point-based merging is preferrable, mergeType points; can be added to the blockMeshDict or blockMesh -merge-points specified at the command-line.

The new blockMesh -write-vtk option generates a blockTopology.vtu file (VTK, ASCII, XML) that can be loaded and inspected in ParaView, with its cell IDs equivalent to the block numbers. This provides a simple, robust method of inspecting blockMesh structures directly in any version of ParaView without the need for additional plugins.

[Picture]

Using blockMesh to generate duplicate baffles

This release extends the blockMesh utility to generate duplicate baffles. These are duplicate faces where the face-areas are manipulated to obey volume conservation. An example is the cyclicACMI patch where there is a patch providing wall behaviour and a patch providing many-to-many coupled behaviour.

The blockMeshDict can now directly specify these duplicate baffles, e.g.

ACMI1_couple
{
    type            cyclicACMI;
    neighbourPatch  ACMI2_couple;
    nonOverlapPatch ACMI1_blockage;
    faces
    (
        (2 6 5 1)
    );
}
ACMI1_blockage
{
    type wall;
    faces
    (
        (2 6 5 1)
    );
}
ACMI2_couple
{
    type            cyclicACMI;
    neighbourPatch  ACMI1_couple;
    nonOverlapPatch ACMI2_blockage;
    faces
    (
        (8 12 15 11)
    );
}
ACMI2_blockage
{
    type wall;
    faces
    (
        (8 12 15 11)
    );
}
This will generate duplicate baffles where one duplicate set is the coupled behaviour (ACMI1_couple, ACMI2_couple) and the other set the wall behaviour (ACMI1_blockage, ACMI2_blockage). A warning is output during mesh generation:

Trying to specify a boundary face on the face on cell
which already belongs to some other patch
since one specifies 7 faces (2 are duplicate) on a hex (6 sided) shape.

The ’old’ method to generate this topology uses createBaffles with a separate createBafflesDict

Note:

  • If unwillingly the blockMesh defines duplicate boundary faces, this is now a warning instead of a fatal error before. Defining duplicate internal faces still generates a fatal error as before.
  • Using the new blockMesh method the patch ordering might be slightly different (patch empty is now last). This gives a slightly different truncation error in the geometric primitive calculations e.g. cell centres, cell volumes, which might slightly affect the results. Note that this is a generic issue of any algorithm which uses floating point values and the blockMesh method actually uses a more consistent patch ordering where patch empty should be last.

Source code
$FOAM_SRC/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C
Tutorial
$FOAM_TUTORIALS/incompressible/pimpleFoam/RAS/oscillatingInletACMI2D

New ramp function1

This release includes a simple step function as a Function1 modifier. This is useful for cases where a step change from off to on transition is required, and also has provision for a duration. An example is shown in the windshieldCondensation tutorial where it is used to control the inlet velocity field:

// Heater on at 60s
inlet
{
    type            uniformNormalFixedValue;
    uniformValue    constant -2;
    ramp
    {
        type        step;
        start       60;
        duration    1000;
    }
}
This specifies a normal inlet velocity that turns on at 60s.

In older versions this could be specified as a table with a relatively sharp transition, but that approach is less obvious and more prone to input error when adjusting value and/or time points.

Source code
$FOAM_SRC/OpenFOAM/primitives/functions/Function1/step
Tutorial
$FOAM_TUTORIALS/heatTransfer/chtMultiRegionFoam/windshieldCondensation

New expression version of Function1

The Function1 type has been extended to include user-defined expression using the expressions infrastructure added in OpenFOAM-v1912. In these expressions, the evaluation argument is referenced as the pseudo-function arg(), e.g. in the windshieldCondensation tutorial it is used to control the inlet temperature:

// Heater on at 60s
inlet
{
    type            uniformFixedValue;
    uniformValue
    {
        type        expression;
        // arg() is time here
        expression  #{ (arg() < 60) ? 273 : 308 #};
    }
}
This specifies a simple step change in the inlet temperature at 60s.

Source code
$FOAM_SRC/OpenFOAM/expressions/Function1
Tutorial
$FOAM_TUTORIALS/heatTransfer/chtMultiRegionFoam/windshieldCondensation

New expression versions of PatchFunction1

The PatchFunction1 run-time input selection has been extended to include an expression version, which allows user-defined expressions for spatially and temporally-varying values. Spatial variations will typically include the pos() function for the face-centre positions.

inlet
{
    type            uniformFixedValue;
    uniformValue
    {
        type        expression;

        // arg() and time() can be used synonymous here
        expression  #{ time() <= 1 ? 1 : 0 #};
    }
}

Source code
$FOAM_SRC/finiteVolume/expressions/PatchFunction1
Tutorial
$FOAM_TUTORIALS/multiphase/MPPICInterFoam/twoPhasePachuka

New coded PatchFunction1

The PatchFunction1 run-time input selection has been extended to include a coded version, e.g. in the icoFoam lid-driven tutorial in the 0/U field definition:

type            uniformFixedValue;
uniformValue
{
    type            coded;
    // Explictly supply name of generated PatchFunction1. Only needed
    // if entryname ('uniformValue') would clash with existing
    // runtime selection tables.
    name            myExpression;

    code
    #{
        const polyPatch& pp = this->patch();
        const fvMesh& fvm = dynamic_cast<const fvMesh&>
        (
            pp.boundaryMesh().mesh()
        );
        const fvPatch& fvp = fvm.boundary()[pp.index()];

        // Get face centroids
        tmp<vectorField> tfld(tmp<vectorField>::New(fvp.Cf()));

        // Zero out y,z
        tfld.ref().replace(vector::Y, Zero);
        tfld.ref().replace(vector::Z, Zero);
        return tfld;
    #};
}
This provides a velocity where the x-component is set according to the face centre.

Source code
$FOAM_SRC/meshTools/PatchFunction1/CodedField
Tutorial
$FOAM_TUTORIALS/multiphase/icoReactingMultiPhaseInterFoam/poolEvaporation

snappyHexMesh: new disable gap refinement controls

snappyHexMesh includes the option to automatically refine small gaps. In this version this can be optionally disabled for gaps originating from the same surface. This is most easily shown with an example:

refinementRegions
{
    refinezone
    {
        mode        inside;
        levels      ((0.0 0));  // Dummy entry
        gapLevel    (4 0 10);   // Guarantee 4 cells in all gaps
        gapMode     outside;    // If the gap is on the outside of the surface
        gapSelf     false;      // Disable any refinement from same surface
    }
}
The entries above in the snappyHexMeshDict dictionary ensure that:
  • there are at least 4 layers of cells in a gap
  • where a gap is anywhere there are two opposite surfaces with outwards pointing normals: gapMode outside;
  • and the surfaces are differing: gapSelf false;

The geometry is a sphere (green) and a ’square’ with an (unwanted) gap (pink). With disabled ’self’ gap detection the mesh becomes (refinement only, no snapping):

[Picture]
No self-gap-refinement

Compare this to the default method which due to the gap-refinement bleeds through the gap:

[Picture]
With self-gap-refinement

Source code
$FOAM_SRC/mesh/snappyHexMesh/meshRefinement/meshRefinementGapRefine.C
More information
See Issue #1463