Sig Numerical Optimization / Tips & Tricks

From OpenFOAMWiki

1 Basic procedure of mesh generation with cfMesh

For geometry creation to mesh with cfMesh the easiest way is to use .stl file type because it is supported in most CAD software. Key is to export each patch as separated .stl file (in ASCII type. NOT BINARY!!!) and then combine those files in one .stl file with added names of patches. The procedure is thoroughly explained in thread: Salome and cfMesh parametrization.

Turbine example for creation of boundery layers on all patches
Multiple inlet example example for creation of boundery layers on all patches

Bash script to combine created .stl files can be found in tutorials page, in tutorial: Parametric Ahmed body. General tip to use cfMesh can be seen in thread: cfMesh tip

For boundary layer generation, it is important to have connected patch surfaces. This means your patch needs to be made of connected surfaces in open or closed way, as cfMesh captures feature edges at the border between the two patches or where it finds a feature edge defined by the user. For example:

  • in the turbine example, surfaces of each blade should form patch for it self.
  • in case with multiple seperated inlets, each inlet surface needs to be patch for it self.

To get good meshes it is recommended to follow these extra guidelines for the following specific mesh generators.

1.1 cartesian2DMesh

Cartesian2DMesh proves to be a very good mesh generator to be included in the optimization routine, because of its easy to understand input file and fast speed in generating the required mesh. In addition, it is able to generate boundary layers with ease, compared to other open-source mesh generators.

While working with this tool, the following guidelines have to be followed in order to avoid mistakes and unproper meshing:

  • in 2D, the geometry should be drawn in the x-y plane (the default plane in the 2D draw of Salome). A geometry placed in the x-z or y-z plane will cause errors.
  • the geometry should only be made of external patches. These patches can be easily selected and named using Salome (New entity -> Group -> Create group -> Surfaces (3rd bottom on the top-right). Front and back patches should not be included, as cartesian2DMesh will generate these patches itself (naming it topEmptyFaces and bottomEmptyFaces).
  • Input files .fms or .ftr are also recommended in cartesian2DMesh. It is possible to convert an .stl to .ftr using the command surfaceConvert geometry.stl

With .ftr geometries, it is possible to specify patch types which are transferred onto the resulting mesh in the meshing process. This is an advantage which simplifies the process of setting up a simulation.

1.2 cartesianMesh

For cartesianMesh it is enough to follow basic cfMesh procedure described above.

1.3 tetMesh