Difference between revisions of "Contrib gmshFoam"

From OpenFOAMWiki
(Created the page and documented the installation procedure)
 
(described some parts of the Usage section)
Line 5: Line 5:
 
== Short description ==
 
== Short description ==
  
A conceptual implementation of a total Gmsh pre/mid/post-processing environment for OpenFOAM.
+
A conceptual implementation of a total Gmsh pre/mid/post-processing environment for OpenFOAM. "Conceptual," or "proof-of-concept," because it is still very preliminary.
  
 
== Installation ==
 
== Installation ==
Line 33: Line 33:
 
$ ./Allwmake
 
$ ./Allwmake
 
</bash>
 
</bash>
 +
With this step the followings will be installed:
 +
* Into <tt>$(FOAM_USER_APPBIN)</tt>: <tt>gmsh2ToFoam</tt>, <tt>foamToGmsh</tt>, <tt>gmshFoam</tt> (a <tt>sh</tt> script), <tt>gmshFoamMonitor</tt>
 +
* Into <tt>$(FOAM_USER_LIBBIN)</tt>: <tt>libgmshFoam.so</tt>, <tt>libgmshMessageStream.so</tt>
  
 
3. Apply the patch included in the gmshFoam package to Gmsh sources, and build/install Gmsh.
 
3. Apply the patch included in the gmshFoam package to Gmsh sources, and build/install Gmsh.
Line 55: Line 58:
  
 
Note that the options given to <tt>configure</tt> in the example above are the minimal ones to build Gmsh with OpenFOAM support. You need to give extra appropriate options to build Gmsh with other packages such as Tetgen, Triangle or OpenCASCADE.
 
Note that the options given to <tt>configure</tt> in the example above are the minimal ones to build Gmsh with OpenFOAM support. You need to give extra appropriate options to build Gmsh with other packages such as Tetgen, Triangle or OpenCASCADE.
 +
 +
The final binary executable will be installed into <tt>~/OpenFOAM/linuxAMD64/gmsh-2.0.7/bin</tt>.
  
 
4. Add the path to Gmsh in one of the setup scripts. For example add the following line to the last of <tt>~/OpenFOAM/OpenFOAM-1.3/.bashrc</tt>.
 
4. Add the path to Gmsh in one of the setup scripts. For example add the following line to the last of <tt>~/OpenFOAM/OpenFOAM-1.3/.bashrc</tt>.
Line 61: Line 66:
  
 
== Usage ==
 
== Usage ==
 +
 +
=== Gmsh ===
 +
 +
The version of Gmsh built following the installation procedure above has the following capabilities:
 +
 +
* direct exporting of generated meshes by OpenFOAM polyMesh format -- by choosing "File" -> "Save As..." and selecting "OpenFOAM polyMesh (*.foam)" as the exporting format. The mesh will be written into the <tt>constant</tt> directory under the directory with the specified name (the optional extension "<tt>.foam</tt>" will be removed).
 +
 +
* direct importing of OpenFOAM fields in a case direcotry as postprocessing views -- by choosing <tt>system/controlDict</tt> in the "File" -> "Open..." or "Merge..." dialog (optionally you can filter the files in the list by selecting "OpenFOAM case (controlDict)" as the importing format). Of course you can do the same thing by directly specifying the <tt>system/controlDict</tt> file as a command-line argument when launching Gmsh.
 +
 +
* the option string <tt>foam</tt> is also available as an argument of the <tt>-format</tt> option.
 +
 +
* (... plus more features, to be documented)
 +
 +
=== gmshFoam ===
 +
<bash>gmshFoam <root> <case> [-monitor or <a .geo file>]
 +
</bash>
 +
 +
(... to be documented)
 +
 +
=== gmshFoamMonitor ===
 +
 +
The utility is a helper application which is to be launched from Gmsh and thus not meant to be run directly from a shell.
 +
 +
(... to be documented)
  
 
=== gmsh2ToFoam ===
 
=== gmsh2ToFoam ===
 +
<tt>Gmsh2ToFoam</tt> is the standalone version of the direct mesh exporter in Gmsh. The <tt>gmsh2ToFoam</tt> that comes with this package has all the features that the original <tt>[[Contrib_gmsh2ToFoam|gmsh2ToFoam]]</tt> has, plus
 +
 +
* a simplified <tt>checkMesh</tt> test: turned on by default. Use <tt>-noCheckMesh</tt> to turn off.
 +
* automatic launching of Gmsh: automatically launches Gmsh with "<tt>gmsh -3</tt>" when a file with the <tt>.geo</tt> extension is specified; then converts the produced <tt>.msh</tt> file to the OpenFOAM format.
 +
* verbosity control: verbosity can be controlled by <tt>-verbosity <verbosity></tt> where <tt><verbosity></tt> is a number from 0 to 5 (the default is 3, along with the default setting of the Gmsh <tt>General.Verbosity</tt> variable).
 +
* a faceZone naming bugfix.
 +
 +
For other features, see the original <tt>[[Contrib_gmsh2ToFoam|gmsh2ToFoam]]</tt> page.
  
 
=== foamToGmsh ===
 
=== foamToGmsh ===
  
=== Gmsh ===
+
<bash>$ foamToGmsh <root> <case> [-splitTimeStepsByMeshMotion] [-startTime <time>] [-verbosity <verbosity>]
 +
</bash>
 +
<tt>FoamToGmsh</tt> is the standalone version of the direct field data importer in Gmsh. It converts OpenFOAM fields in a case directory to Gmsh view file format of ASCII type. A view file is created for a field with field name + extension "<tt>.pos</tt>" under the <tt><case>/Gmsh</tt> directory.
  
=== gmshFoam ===
+
* <tt>-splitTimeStepsByMeshMotion</tt>: splits the view files everytime a mesh motion is detected (by the presence of a "polyMesh/points" file). Actually, the option is a byproduct of a failed attempt to implement moving mesh handling into Gmsh, so even I myself don't know what the option is good for (don't worry, the moving mesh handling is implemented by a different way).
 +
* <tt>-startTime <time></tt>: selects the timeName where the conversion starts. "latestTime" for only converting the latest time instant.
 +
* <tt>-verbosity <verbosity></tt>: same as in gmsh2ToFoam.
 +
 
 +
== Technical ==
  
 
== Download ==
 
== Download ==

Revision as of 14:10, 11 April 2007

(The documentation work is still underway - more to come in the following days!)

Valid versions: OF version 13.png

1 Short description

A conceptual implementation of a total Gmsh pre/mid/post-processing environment for OpenFOAM. "Conceptual," or "proof-of-concept," because it is still very preliminary.

2 Installation

2.1 Prerequisites

  • The gmshFoam-20070411 package: Download from the Download section below.
  • gmsh-2.0.7-source.tgz: You need the source distribution of Gmsh.
  • The autoconf utility that comes with your linux distribution.

2.2 Installation procedure

In the following procedure, as an example the home directory is assumed to be the author's own home directory:

  • The home directory: /home/ohshima

The gmshFoam and Gmsh packages are assumed to be downloaded into:

  • The gmshFoam package: /home/ohshima/OpenFOAM/ohshima-1.3/applications/utilities
  • The Gmsh source package: /home/ohshima/OpenFOAM/linuxAMD64

1. Setup the OpenFOAM environment.

$ source ~/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/bashrc

2. Build the libraries and standalone utilities.

$ cd ~/OpenFOAM/ohshima-1.3/applications/utilities
$ tar -zxf gmshFoam-20070411.tar.gz
$ cd gmshFoam-20070411
$ ./Allwmake

With this step the followings will be installed:

  • Into $(FOAM_USER_APPBIN): gmsh2ToFoam, foamToGmsh, gmshFoam (a sh script), gmshFoamMonitor
  • Into $(FOAM_USER_LIBBIN): libgmshFoam.so, libgmshMessageStream.so

3. Apply the patch included in the gmshFoam package to Gmsh sources, and build/install Gmsh.

$ cd ~/OpenFOAM/linuxAMD64
$ tar -zxf gmsh-2.0.7-source.tgz
$ mv gmsh-2.0.7 gmsh-2.0.7-src
$ cd gmsh-2.0.7-src
$ patch -p1 < ~/OpenFOAM/ohshima-1.3/applications/utilities/gmshFoam-20070411/gmsh-2.0.7-foam-20070410.diff
$ autoconf
$ ./configure --prefix=/home/ohshima/OpenFOAM/linuxAMD64/gmsh-2.0.7 \
  --with-foam-prefix=/home/ohshima/OpenFOAM/ohshima-1.3/applications/utilities/gmshFoam-20070411
...
checking for main in -lhdf5... no
checking for main in -lgmshMessageStream... yes    <<--- This line shows the detection of OpenFOAM libraries!
checking for grep that handles long lines and -e... /usr/bin/grep
...
$ make
$ make install
$ cd ..; rm -rf gmsh-2.0.7-src

Please make sure proper OpenFOAM environment variables are set up before building Gmsh because the configure script uses the environment variables to detect the gmshFoam and OpenFOAM libraries. Also, don't forget to run autoconf before running configure.

Note that the options given to configure in the example above are the minimal ones to build Gmsh with OpenFOAM support. You need to give extra appropriate options to build Gmsh with other packages such as Tetgen, Triangle or OpenCASCADE.

The final binary executable will be installed into ~/OpenFOAM/linuxAMD64/gmsh-2.0.7/bin.

4. Add the path to Gmsh in one of the setup scripts. For example add the following line to the last of ~/OpenFOAM/OpenFOAM-1.3/.bashrc.

export PATH="$WM_PROJECT_INST_DIR/$WM_ARCH/gmsh-2.0.7/bin:$PATH"

3 Usage

3.1 Gmsh

The version of Gmsh built following the installation procedure above has the following capabilities:

  • direct exporting of generated meshes by OpenFOAM polyMesh format -- by choosing "File" -> "Save As..." and selecting "OpenFOAM polyMesh (*.foam)" as the exporting format. The mesh will be written into the constant directory under the directory with the specified name (the optional extension ".foam" will be removed).
  • direct importing of OpenFOAM fields in a case direcotry as postprocessing views -- by choosing system/controlDict in the "File" -> "Open..." or "Merge..." dialog (optionally you can filter the files in the list by selecting "OpenFOAM case (controlDict)" as the importing format). Of course you can do the same thing by directly specifying the system/controlDict file as a command-line argument when launching Gmsh.
  • the option string foam is also available as an argument of the -format option.
  • (... plus more features, to be documented)

3.2 gmshFoam

gmshFoam <root> <case> [-monitor or <a .geo file>]

(... to be documented)

3.3 gmshFoamMonitor

The utility is a helper application which is to be launched from Gmsh and thus not meant to be run directly from a shell.

(... to be documented)

3.4 gmsh2ToFoam

Gmsh2ToFoam is the standalone version of the direct mesh exporter in Gmsh. The gmsh2ToFoam that comes with this package has all the features that the original gmsh2ToFoam has, plus

  • a simplified checkMesh test: turned on by default. Use -noCheckMesh to turn off.
  • automatic launching of Gmsh: automatically launches Gmsh with "gmsh -3" when a file with the .geo extension is specified; then converts the produced .msh file to the OpenFOAM format.
  • verbosity control: verbosity can be controlled by -verbosity <verbosity> where <verbosity> is a number from 0 to 5 (the default is 3, along with the default setting of the Gmsh General.Verbosity variable).
  • a faceZone naming bugfix.

For other features, see the original gmsh2ToFoam page.

3.5 foamToGmsh

$ foamToGmsh <root> <case> [-splitTimeStepsByMeshMotion] [-startTime <time>] [-verbosity <verbosity>]

FoamToGmsh is the standalone version of the direct field data importer in Gmsh. It converts OpenFOAM fields in a case directory to Gmsh view file format of ASCII type. A view file is created for a field with field name + extension ".pos" under the <case>/Gmsh directory.

  • -splitTimeStepsByMeshMotion: splits the view files everytime a mesh motion is detected (by the presence of a "polyMesh/points" file). Actually, the option is a byproduct of a failed attempt to implement moving mesh handling into Gmsh, so even I myself don't know what the option is good for (don't worry, the moving mesh handling is implemented by a different way).
  • -startTime
  • <tt>-verbosity <verbosity></tt>: same as in gmsh2ToFoam.

4 Technical

5 Download

gmshFoam-20070411.tar.gz: The gmshFoam package

You also need to download <tt>gmsh-2.0.7-source.tgz</tt> from the Gmsh website.

6 History

7islands 12:43, 11 Apr 2007 (CEST):

  • Initial upload.