Sig Turbomachinery Utilities CGNS Converters

From OpenFOAMWiki
Revision as of 13:52, 8 November 2008 by MBeaudoin (Talk | contribs)

1 Introduction

The CFD General Notation System (CGNS) file converters cgnsToFoam and foamToCGNS allow for the conversion back and forth between OpenFOAM cases and files in CGNS format.

The converters support:

  • import and export of grid information
    • importing structured and unstructured grid from CGNS format file
    • exporting OpenFOAM grid format to unstructured grid CGNS format
  • import and export of boundary conditions information, including periodic or cyclic BCs
  • import and export of flow solutions


Using CGNS files, one can easily transfer CFD information like mesh and flow solutions between OpenFOAM and many commercial CFD applications (mesh generators, solvers, etc).

For more information on the CGNS file format, visit the following site: http://cgns.sourceforge.net/

2 Installing the CGNS converters

The CGNS file converters are available from the SourceForge.NET site http://openfoam-extend.wiki.sourceforge.net/ through a Subversion source code repository.

The converters source code currently resides in the Breeder section of the repository, under the TurboMachinery OpenFOAM Special Interest Group (OSIG) section.

For more information on the structure of the Subversion repository for the openfoam-extend project on SourceForge.NET, see the following presentation from the 2nd OpenFOAM Workshop: Open Subversion Repository Access For OpenFOAM

For browsing the openfoam-extend Subversion repository, follow this URL: http://openfoam-extend.svn.sourceforge.net/viewvc/openfoam-extend/

The CGNS converters are based on the following components:

  • cgnslib_2.5  : CGNS Mid-Level library
  • cgnstools_2.5 : optional package from http://cgns.sourceforge.net/. Tools for viewing and editing CGNS files
  • libcgnsoo_3.0 : C++ wrapper for the CGNS Mid-Level library
  • cgnsToFoam  : CGNS file conversion to OpenFOAM
  • foamToCGNS  : OpenFOAM conversion to CGNS file


2.1 Downloading the CGNS converters and companion libraries

The easiest way to retrieve the CGNS converters source code is to download the whole TurboMachinery section of the Breeder from the openfoam-extend Subversion repository.

  • For OpenFOAM 1.5
cd $WM_PROJECT_USER_DIR
svn checkout https://openfoam-extend.svn.sourceforge.net/svnroot/openfoam-extend/trunk/Breeder_1.5/OSIG/TurboMachinery
  • For OpenFOAM 1.4.1
cd $WM_PROJECT_USER_DIR
svn checkout https://openfoam-extend.svn.sourceforge.net/svnroot/openfoam-extend/trunk/Breeder/OSIG/TurboMachinery


It is also possible to download the converters, companion libraries and tutorial individually. Take note however that if the relative installation locations of the different converters components are modified, the files Make/options for cgnsToFoam and foamToCGNS will need to be adjusted accordingly.

For example, for OpenFOAM 1.5:

  • The CGNS converters:
svn checkout https://openfoam-extend.svn.sourceforge.net/svnroot/openfoam-extend/trunk/Breeder_1.5/OSIG/TurboMachinery/applications
  • The companion libraries:
svn checkout https://openfoam-extend.svn.sourceforge.net/svnroot/openfoam-extend/trunk/Breeder_1.5/OSIG/TurboMachinery/src
  • The test cases:
svn checkout https://openfoam-extend.svn.sourceforge.net/svnroot/openfoam-extend/trunk/Breeder_1.5/OSIG/TurboMachinery/tutorials


NB: For the remaining of this document, we will assume that the whole TurboMachinery section of the Breeder_1.5 was download in the directory $WM_PROJECT_USER_DIR

2.2 Compiling the companion libraries

cd $WM_PROJECT_USER_DIR/TurboMachinery/src
./Allclean
./Allwmake

2.3 Compiling the CGNS converters

cd $WM_PROJECT_USER_DIR/TurboMachinery/applications
./Allclean
./Allwmake

3 Testing the CGNS converters

cd $WM_PROJECT_USER_DIR/TurboMachinery/tutorials/cgnsConverters
./Allclean
./Allrun

3.1 Test case: test1

A cgsnsToFoam test case

3.2 Test case: test2

A foamToCGNS test case.

An example for converting periodic boundary conditions

3.3 Test case: test3

Reusing a foamToCGNS output as an inpput for a cgsnsToFoam test case.

An example for converting periodic boundary conditions

4 Basic documentation

4.1 cgnsToFoam

% cgnsToFoam --help

  Usage: cgnsToFoam <CGNS file> [-saveSolutions] [-cyclicRotX angle_nn_degree] [-cyclicRotY angle_in_degree] [-cyclicRotZ angle_in_degree] 
                                [-mergeTolerance tolerance for matching identical nodes: fraction of smallest edge. Default value=0.1] 
                                [-zone zoneList] [-mapUnknown] [-debug] [-help] [-dryrun] [-case dir] [-cfxCompatibility] 
                                [-cyclicMatchFaceTolFactor tolerance for matching cyclic faces: fraction of the smallest edge. Default value= 0.1] 
                                [-matchCyclicBC bc1:bc2] [-separatePatches] [-rho Volumic_density. Default value=1.0] 
                                [-novalidationMesh] [-use2DElementsAsPatches]  [-help] [-doc] [-srcDoc]


  • Description of the command-line options for cgnsToFoam:
-case Case directory
-cfxCompatibility
-cyclicMatchFaceTolFactor Tolerance factor for matching cyclic faces: fraction of the smallest edge. Default value= 0.1
-saveSolutions
-cyclicRotX angle_nn_degree
-cyclicRotY angle_in_degree
-cyclicRotZ angle_in_degree
-mergeTolerance tolerance for matching identical nodes: fraction of smallest edge. Default value=0.1
-zone zoneList
-mapUnknown
-debug
-help
-dryrun
-matchCyclicBC bc1:bc2
-separatePatches
-rho Volumic_density. Default value=1.0
-novalidationMesh
-use2DElementsAsPatches
-help
-doc
-srcDoc

4.2 foamToCGNS

% foamToCGNS -help

  Usage: foamToCGNS [-noZero] [-allowuserdefinedfields] [-exportcyclics] [-help] [-case dir] [-constant] 
                    [-rho Volumic_density. Default value: 1.0] [-latestTime] [-time time]  [-help] [-doc] [-srcDoc]

Description of the command-line options for fomToCGNS:

[-noZero] 
[-allowuserdefinedfields] 
[-exportcyclics] 
[-help] 
[-case dir] 
[-constant] 
[-rho Volumic_density. Default value: 1.0] 
[-latestTime] 
[-time time]  
[-help] 
[-doc] 
[-srcDoc]

5 Use cases