Previous: Computational grid preparation Up: Computational grid preparation Next: Running the simulation

This is an automatically generated documentation by LaTeX2HTML utility. In case of any issue, please, contact us at info@cfdsupport.com.

Mesh generation

  • First of all, before using the snappyHexMesh mesher, it is necessary to generate an orthogonal grid around the whole computational domain. Use blockMesh to do it. Result may be seen on picture crossref 3.

    # blockMesh

  • There are some preseeded vertices of the computational domain in file system/blockMeshDict and all other parameters necessary to generate a starting mesh.
  • The reader can get more information about this utility e.g. in the chapter “Motorbike” of the basic CFD support manual.
  • Now let’s start generating the mesh using snappyHexMesh.
  • Setup of snappyHexMesh is located in the file system/snappyHexMeshDict.

  • Mesh generation is done in three steps:
  • Each step has its own group of settings and each one can be run independently of others as specified by the initial three boolean switches (lines 21 to 23).
    castellatedMesh true;
    snap            true;
    addLayers       false;
    // Geometry. Definition of all surfaces. All surfaces are of class
    // searchableSurface.
    // Surfaces are used
    // - to specify refinement for any mesh cell intersecting it
    // - to specify refinement for any mesh cell inside/outside/near
    // - to 'snap' the mesh boundary to the surface
            type triSurfaceMesh;
            name car;
            type searchableBox;
            min (-18 0 -2);
            max (-5 2 2);

  • Listing of snappyHexMeshDict shows us that castellatedMeshsnapaddLayers could be activated or deactivated using the keywords true or false.
  • The main part of snappyHexMeshDict is in the section geometry. The names of the STL file(s) and/or the definitions of other refinement regions will be given here. In our case the file combi.stl is used.
  • It is possible to define as many refinement regions as one wants. There will be one refinement region in our case named refinementBox. The name can be completely arbitrary, though.
  • The refinement region can be a block (box) or sphere or possibly some other available shapes; see $FOAM$ \_$SRC/meshTools/searchableSurface.
  • The size of the refinement region refinementBox is defined by two points. They are the vertices of the body diagonal of the box.
  • These vertices have to be specified in a positive order. The first point has to have all its coordinates minimal while the second one maximal.
  • The setup of castellatedMesh is thoroughly commented in the snappyHexMeshDict and it is not going to be discussed in this manual.

  • A very interesting group is the refinementSurfaces.
                // Surface-wise min and max refinement level
                level (4 5);
  • refinementSurface level sets up the number of subdivisions (halvings) of the original mesh generated by blockMesh (in our case it is our car model – car).
  • The degree of the subdivision is specified by level (a b), which sets the minimal (a) and maximal (b) number of cell halvings of the original blockMesh mesh. For example, if level (1 2) is specified for some surface, the adjacent cells will be subdivided once or twice, depending on the local curvature of the surface.
  • As the curvature of the surface rises, also the subdivision level of cells adjacent to the surface is being chosen nearer to its available maximum.

  • The subdivision levels for refinement regions defined in the section geometry are given in the section refinementRegions.
                mode inside;
                levels ((1E15 2));
  • The mode inside means that the refinement will be done only inside of the box. The list levels contains one pair of values, of which the first one is not used and the second gives the actual level of the subdivision.
  • There exist also two other modes, which are described in comments in snappyHexMeshDict.

  • The section addLayersControls sets the parameters of the mesh in the boundary layer. 17.1
    // Settings for the layer addition.
        // Are the thickness parameters below relative to the undistorted
        // size of the refined cell outside layer (true) or absolute sizes (false).
        relativeSizes true;
        // Per final patch (so not geometry!) the layer information
                nSurfaceLayers 1;
        // Expansion factor for layer mesh
        expansionRatio 1;
        //- Wanted thickness of final added cell layer. If multiple layers
        //  is the
        //  thickness of the layer furthest away from the wall.
        //  Relative to undistorted size of cell outside layer.
        //  is the thickness of the layer furthest away from the wall.
        //  See relativeSizes parameter.
        finalLayerThickness 0.15;
        //- Minimum thickness of cell layer. If for any reason layer
        //  cannot be above minThickness do not add layer.
        //  Relative to undistorted size of cell outside layer.
        minThickness 0.05;

  • The cell thickness in boundary layer can be set as relative with respect to the original cell size or as absolute.
  • The parameter relativeSizes switches between the two possibilities.
  • The section layers specifies the count of added surface layers per every wall.
  • The quotient of boundary layer expansion is set by expansionRatio.
  • finalLayerThickness defines required maximal thickness of cells in boundary layer.
  • minThickness defines minimal required boundary layer thickness.

  • The meshing of a large mesh could be time consuming; therefore, snappyHexMesh offers the possibility to mesh the geometry in parallel.
  • Firstly, the computational domain has to be divided using the utility decomposePar. The number of parts has to correspond to the number of CPUs that are going to be used.
  • To run snappyHexMesh one has to run the following commands: 17.2
    # decomposePar
    # mpiexec -np 2 snappyHexMesh -overwrite -parallel > log.snappy &
  • When the meshing is done one can reconstruct the new mesh by running the command:
    # reconstructParMesh -constant -mergeTol 1e-6