Importing complex meshes into Eilmer3 through cgns

As reported in pdf-user-guide, complex meshes can be imported to Eilmer3 either trough PLOT3D/VTK format. The only issue is that in the conversion process, boundary condition information is lost, an therefore this information has to be filled in the e3prep job script manually.

Meshing software (such as ICEM) can include boundary conditions information in numerous output formats, for example multiblock output, which is a plain ASCII topology format, or others for specific solvers, like Vulcan ASCII format. Nevertheless especial licenses are required for these [1]. The output to CGNS does not need a license.

The procedure is explained using ICEM, but any other software can be used if boundary conditions and mesh can be writen to CGNS

Required Libraries

CGNS is a binary format, and requires specific libraries to deal with it. The required libraries are

  • HDF5: This is one of the underlaying data structures CGNS may

    relies on. CGNS used to have its own data structure (ADF), but is moving towards the implementation on HDF5. Today CGNS files may be written in both formats. Install HDF5 libraries because they will be needed in one step.

  • CGNS: libraries. There are also numerous tools for conversion

    between formats, grid viewers, and CGNS files handling. Cgnsviewer is a useful tool to “see” what it inside a CGNS file.

  • Pycgns: CGNS supported libraries are typically called from C++

    or Fortran. Nevertheless, since Eilmer3 preprocessing uses Python, Pycgns will be used instead. This uses SWIG to map some of the CGNS functions into Python. You will need to install Oliver Borm’s package for Python 2.x There is also a copy of this package in /cfcfd3/extern/python-cgns

Mesh generation in CGNS

  • Generate a multiblock mesh as usual. Parts names will be the names of your boundary conditions so make sure you have all of them well defined. Interior faces or edges will be merged by Eilmer3 preprocessor, so you not need to name them (ICEM will do it).
  • In Solver output select cgns.
  • In family boundary conditions you have to create a BCTYPE for each part defined. Does not mater what kind of BC you use (wall, inflow etc) because we will use only the name of the part. Volumes in 3D or faces in 2D do not need to tagged, because they will be written by default by ICEM. Same procedure for naming convention could be applied to any other meshing SW.
  • In output file, select: Structured format, the name of the file in output file. To the question create default BC patches? say yes. This will write DEFAULT_EDGES or DEFAULT_SUBFACES names for interior non tagged edges or faces, then later Eilmer3 will fuse them.
  • Write the file in CGNS version 2.4 (ADF). Apparently there is a bug somewhere in ICEM implementation of HDF5, and CGNS HDF5 format V3.0 will not be well written.
  • Now we have a cgns file in ADF format. Pycgns uses cgns HDF5 format. So we can use the tool (from CGNS Tools): adf2hdf. The use is adf2hdf my_adf_file my_hdf_file, from any terminal.
  • Now we have a CGNS in HDF5 format. Is all what we need from the meshing SW side.

Especial considerations for 2D grids.

For 2D grids, we have to make sure that the faces have the same IJK convention as Eilmer3.

Make sure that all the blocks have the origin in topologically bottom left corner, I running to the right, and J running up. K will be therefore positive see e3_block. By default, ICEM will not take care of the orientations for you in 2D, and you may end up with several of them with -K (giving negative volumes in Eilmer3).

For dozens of faces, could be painful to look for the inverted ones and flip them (edit mesh->reorient domains). But there is one dirty trick. If you extrude the mesh a little bit by translation (making it 3D), then converting to 2D again (it will remove the 3D blocks), and then removing all the faces that where not originally part of your 2D model: the resulting faces will have all K in the same direction (since ICEM checks the consistency of the volumes). Now you can flip all the faces all together to get Eilmer3 convention, not face by face.

Eilmer3 Input

The main Python module for E3prep that reads the CGNS file and put it into Eilmer3 is It is part of the Eilmer3 modules. Uses Pycgns functions, and was developed by Paul Petrie-Repar and Peter Jacobs. Minor modifications were added by Jorge Sancho. Hopefully there is no need to modify this file.

Eilmer3 job file for e3prep should then have the following lines:

GridFile = 'MyFile.cgns' #name of your file

from import_cgns_grid import read_ICEM_CGNS_grids
cgns_data = read_ICEM_CGNS_grids(GridFile, labelStem='mesh1')
nblk = cgns_data['nblock']

The above lines read and import cgns_data dictionary with all the information of the CGNS file. Now we will read the blocks. Initial condition is labeled as initial:

blk_list =[]
if (gdata.dimensions == 2):
    for ib in range (nblk):
    for ib in range (nblk):

All the blocks are identified and loaded, now the only information remaining is your boundary conditions. You have to create the translation between your named ICEM parts, and Eilmer3 boundary conditions. An example of this translation is described bellow. In this case INLET ICEM part is a SUP_IN Eilmer3 with inflow condition. FUEL ICEM part, is a ADIABATIC Eilmer3, and so on. In the cgns_data dictionary, faces are 2D faces for 3D cases, and 1D lines for 2D cases, hopefully this does not create confusion:

for bc in cgns_data['bcs']:
    face = bc['face']
    block = bc['block']
    bcname = bc['type']
    if (bcname == 'INLET'):
        blk_list[block].set_BC(face, 'SUP_IN', inflow_condition = inflow)
    elif (bcname == 'FUEL'):
        blk_list[block].set_BC(face, "ADIABATIC")
    elif (bcname == 'INJECTOR'):
        blk_list[block].set_BC(face, "ADIABATIC")
    elif (bcname == 'WALLS'):
        blk_list[block].set_BC(face, "ADIABATIC")
    elif (bcname == 'TWALL'):
        blk_list[block].set_BC(face, "SLIP_WALL")
    elif (bcname == 'OUT'):
        blk_list[block].set_BC(face, "EXTRAPOLATE_OUT")
    elif (bcname == 'DEFAULT_EDGE'):
        print "internal", bcname
        print "WARNING: Unknown boundary condition: ", bcname

That was all we need for Eilmer3 e3prep file.


[1]Dirty tricks may be used in case ASCII files are needed from an ICEM multiblock format without an especial license. For example the ICEM command ic_str_dump_topo_inf mytopofile will dump all topology information and BC to an ASCII file. With this file, and blocks node coordinates, would be possible to re-write this procedure entirely in ASCII.

Table Of Contents

Previous topic


Next topic


This Page