Difference between revisions of "Contrib Parallelized Native OpenFOAM Reader for ParaView"

From OpenFOAMWiki
(Added Filter->Surface Flow incompatibility issue)
(update for the 20080324 version)
Line 1: Line 1:
Although VTK included in ParaView3 has an OpenFOAM reader (and tips for enabling the reader is documented [[Tip_Build_A_Paraview3_Plugin|here]]), it still lacks a number of essential features to be practially used. Since on Windows native reader, rather than PVFoamReader/vtkFoam/paraFoam, is the only feasible approach to get OpenFOAM data into ParaView, I re-coded the reader from ground up and posted to [http://openfoam.cfd-online.com/cgi-bin/forum/show.cgi?tpc=1&post=17466#POST17466 the Message Board]. This page is meant as the documentation for the reader.
+
The OpenFOAM reader included in ParaView3 (tips for enabling the reader is documented [[Tip_Build_A_Paraview3_Plugin|here]]) lacks a number of essential features to be practially used, so I re-coded the reader from ground up and posted to [http://openfoam.cfd-online.com/cgi-bin/forum/show.cgi?tpc=1&post=17466#POST17466 the Message Board]. This page is meant as the documentation for the reader.
  
 
=Features=
 
=Features=
  
* Supports the ParaView 3.3 CVS development version (as of Oct. 22, 2007). Also tested a bit with the 3.2-series and it seems to work.
+
The reader
 +
* supports the ParaView 3.3 CVS development version (as of Mar. 24, 2008) and the 3.2.1 released version.
  
* Tested under Linux x86, x86_64, VS2003.net/2005 on Windows and Mac OS X Leopard (10.5).
+
* is tested under Linux x86, x86_64, VS2003.net/2008 on Windows and Mac OS X Leopard (10.5).
  
* Supports volScalarField, volVectorField, lagrangian (of class Cloud) scalarField, lagrangian vectorField. Currently no support for point/surface nor symmTensor/tensor fields (See Notes below to use the lagrangian feature).
+
* has improved performance and compatibility over the reader included in the ParaView sources.
  
* Supports compressed(gzipped)/uncompressed-ascii/double precision binary data formats. Single precision binary format is not supported.
+
* supports all combinations of vol/point/lagrangian (of class Cloud)-Scalar/Vector/SphericalTensor/SymmTensor/Tensor fields (See Notes below to use the lagrangian feature).
  
* Improved performance. You should find the reader a lot faster than the previous versions.
+
* supports compressed(gzipped)/uncompressed-ascii/double precision binary data formats. Single precision binary format is not supported.
  
* Neat user interface. Patch and array selection lists are now offered.
+
* has a builtin cell data to point data filter (not as accurate as the volPoint interpolator in paraFoam but supposed to be better than the one in ParaView, see Notes below)
 +
* has a neat user interface. Patch and array selection lists are now offered.
  
 
=Installation=
 
=Installation=
  
 
1. Get the ParaView3 source.
 
1. Get the ParaView3 source.
 +
*For 3.3-CVS:
 
<bash>cvs -d :pserver:anoncvs@www.paraview.org:/cvsroot/ParaView3 login
 
<bash>cvs -d :pserver:anoncvs@www.paraview.org:/cvsroot/ParaView3 login
 
     (respond with empty password)
 
     (respond with empty password)
cvs -d :pserver:anoncvs@www.paraview.org:/cvsroot/ParaView3 co ParaView3
+
cvs -d :pserver:anoncvs@www.paraview.org:/cvsroot/ParaView3 co ParaView3</bash>
</bash>
+
*For 3.2.1:
 +
<bash>tar -zxf paraview-3.2.1.tar.gz
 +
ln -s ParaView3.2.1 ParaView3</bash> (a symbolic link is required for the reader package to be correctly unpacked)
  
 
2. Untar the package at the parent directory of ParaView3 source tree
 
2. Untar the package at the parent directory of ParaView3 source tree
 
(the directory where you issued the above cvs commands). This will
 
(the directory where you issued the above cvs commands). This will
 
overwrite the reader code included in the source tree.
 
overwrite the reader code included in the source tree.
<bash>tar jxf vtkOpenFOAMReader-YYYYMMDD.tar.bz2
+
<bash>tar jxf vtkOpenFOAMReader-YYYYMMDD.tar.bz2</bash>
</bash>
+
3. Patch the XML code at the parent dirctory.
3. Patch the XML codes at the parent dirctory of ParaView3.
+
<bash>patch -b -p0 < readers.xml.diff</bash>
<bash>patch -b -p0 < ParaViewReaders.xml.diff
+
*For 3.2.1: add the following piece into ParaView3.2.1/Qt/Components/Resources/XML/ParaViewReaders.xml.
patch -b -p0 < readers.xml.diff
+
<xml><Reader name="OpenFOAMReader"
</bash>
+
          extensions="foam"
 +
          file_description="OpenFOAM Files">
 +
</Reader></xml>
 
4. Build ParaView3 as usual. It is highly recommended to turn on
 
4. Build ParaView3 as usual. It is highly recommended to turn on
compiler optimization (at least -O2) since the reader is dead slow
+
compiler optimization (by setting CMAKE_BUILD_TYPE to Release) since the reader is dead slow
 
without optimization. If you get a bit better performance than
 
without optimization. If you get a bit better performance than
 
paraFoam the optimization is working adequately.
 
paraFoam the optimization is working adequately.
Line 39: Line 46:
 
=Notes=
 
=Notes=
  
* To open an OpenFOAM case, create a symbolic link from controlDict to controlDict.foam and choose controlDict.foam.
+
* To load an OpenFOAM case, you either have to
 +
** create an empty stub file <caseName>.foam right under the case directory, where <caseName> is an arbitrary string other than  the strings that starts with "controlDict," or
 +
** create a symbolic link from controlDict to controlDict.foam and open controlDict.foam.
  
* The reader does not create point-interpolated fields of vol-fields. Use Filter->Cell Data to Point Data to make them (FYI, vector plot with Filter->Glyph also requires point data).
+
* The builtin cell-to-point filter works like a Cell Data to Point Data filter in ParaView in that it just takes the average of cell values connected to a point. The difference is that the builtin filter takes boundary patch values into account. The filter is not as accurate as the volPoint interpolator in paraFoam, which further does inverse distance weighting of cell values.
  
* The reader lists time instances according to descriptions in controlDict when (adjustTimeStep, writeControl) == (yes, adjustableRunTime) or (no, timeStep) (i. e. writing interval is supposed to be constant in simulated time), or otherwise, lists all valid time directories. This is a different behavior from paraFoam which always lists all valid time directories in a case directory.
+
* The cell-to-point filter is computationally demanding so you can turn it off by deselecting "Create cell-to-point filtered data" on the reader panel.
  
* The reader lists array names according to the "object" entry in FoamFile header, whereas paraFoam lists according to the file name of the object. So you need a valid FoamFile header for every object.
+
* Several compile-time performance-related configuration options are now provided at the beginning of vtkOpenFOAMReader.cxx. With defaults the reader
 +
** omits CRC checks for gzipped files (except on Windows)
 +
** counts line numbers where the FoamFile parser is reading (if turned off, the line number will always be shown as 0 when the reader issues a parser error in return for a bit of additional performance)
 +
** uses its own string to floating point conversion routine, which is fast but may be a bit inaccurate than the system strtod().
  
* To run Filter->Stream Tracer for a case with polyhedral cells, you have to tetrahedralize it (Filter->Tetrahedralize).
+
* To separate Eulerians and Lagrangians, extract Node 0 for Eulerians and Dataset 1 right under Root with Filter->Extract Block (ParaView 3.3) or group 0 for Eulerians and group 1 for Lagrangians with Extract Group (ParaView 3.2.1).
  
* In order for lagrangians to work you need to create lagrangian fields at the initial timestep in your case. To separate eulerians and lagrangians, extract group 0 for eulerians and group 1 for lagrangians with Filter->Extract Group.
+
* To create a slice with volField data you have to extract internal mesh (dataset 0) or turn off reading patches in the reader panel.
  
* The "Accumulate Patches" checkbox is meant to be used for topo change cases to append patches that don't exist in the initial timestep into the selection list over an animation run. To update the patch selection list after the run, deselect controlDict.foam in Pipeline Browser once and re-select it.
+
* The reader lists time instances according to descriptions in controlDict when (adjustTimeStep, writeControl) == (yes, adjustableRunTime) or (no, timeStep) (i. e. writing interval is supposed to be constant in simulated time), or otherwise, lists all valid time directories. This is a different behavior from paraFoam which always lists all valid time directories in a case directory.
 +
 
 +
* The reader lists array names according to the "object" entry in FoamFile header, whereas paraFoam lists according to the file name of the object. So you need a valid FoamFile header for every object.
  
* Filter->Slice doesn't seem to be working correctly in the current CVS of ParaView3. You need to extract dataset 0 with Filter->Extract Datasets (which represents internalField) or run Filter->Cell Data to Point Data before making a slice.
+
* The Accumulate Patches checkbox in the reader panel is meant to be used for topo change cases to append patches that don't exist in the initial timestep into the selection list over an animation run. To update the patch selection list after the run, deselect controlDict.foam in Pipeline Browser once and re-select it.
  
 
* Handling of boundary conditions is quite poor as of now; if a boundary patch doesn't have a value entry the corresponding patch-internal field value is used (i. e. equivalent to zeroGradient b. c.)
 
* Handling of boundary conditions is quite poor as of now; if a boundary patch doesn't have a value entry the corresponding patch-internal field value is used (i. e. equivalent to zeroGradient b. c.)
Line 61: Line 75:
 
* It looks like Filter->Surface Flow doesn't work because of an incompatibility between what the reader offers as output dataset and what the filter requires as input, i.e. the Surface Flow filter doesn't seem to support composite dataset types, one of which is the type of dataset the reader outputs. Other possibly incompatible filters with the same reason are Append Attributes and Append Datasets (I still haven't confirmed though). Unfortunately no quick workaround come to me.
 
* It looks like Filter->Surface Flow doesn't work because of an incompatibility between what the reader offers as output dataset and what the filter requires as input, i.e. the Surface Flow filter doesn't seem to support composite dataset types, one of which is the type of dataset the reader outputs. Other possibly incompatible filters with the same reason are Append Attributes and Append Datasets (I still haven't confirmed though). Unfortunately no quick workaround come to me.
  
* The reader handles data with double precision while paraFoam handles with single precision.
+
* For binary-formatted Lagrangian positions files the reader only supports the ones created by OF version 1.4 or later.
  
 
* The FoamFile parser is still under development so if you find a bug posting a minimal test case will be highly appreciated.
 
* The FoamFile parser is still under development so if you find a bug posting a minimal test case will be highly appreciated.
Line 68: Line 82:
 
Download from [http://openfoam.cfd-online.com/cgi-bin/forum/show.cgi?tpc=1&post=17466#POST17466 the native reader thread] on the Message Board.
 
Download from [http://openfoam.cfd-online.com/cgi-bin/forum/show.cgi?tpc=1&post=17466#POST17466 the native reader thread] on the Message Board.
  
You can also download prebuilt binaries with the reader included [http://oshima.eng.niigata-u.ac.jp/OpenFOAM/ParaView/ here] (currently only for Windows).
+
You can also download prebuilt binaries with the reader included [http://oshima.eng.niigata-u.ac.jp/OpenFOAM/ParaView/ here] (currently only available for Windows).
  
 
=History=
 
=History=
 +
[[User:7islands|7islands]] 02:58, 28 April 2008 (CEST) (Takuya OSHIMA): update for the 20080324 version.
 +
 
[[User:7islands|7islands]] 09:18, 29 Dec 2007 (CET): some addenda.
 
[[User:7islands|7islands]] 09:18, 29 Dec 2007 (CET): some addenda.
  
 
[[User:7islands|7islands]] 04:36, 16 Dec 2007 (CET) (Takuya OSHIMA): Created this page.
 
[[User:7islands|7islands]] 04:36, 16 Dec 2007 (CET) (Takuya OSHIMA): Created this page.

Revision as of 00:58, 28 April 2008

The OpenFOAM reader included in ParaView3 (tips for enabling the reader is documented here) lacks a number of essential features to be practially used, so I re-coded the reader from ground up and posted to the Message Board. This page is meant as the documentation for the reader.

1 Features

The reader

  • supports the ParaView 3.3 CVS development version (as of Mar. 24, 2008) and the 3.2.1 released version.
  • is tested under Linux x86, x86_64, VS2003.net/2008 on Windows and Mac OS X Leopard (10.5).
  • has improved performance and compatibility over the reader included in the ParaView sources.
  • supports all combinations of vol/point/lagrangian (of class Cloud)-Scalar/Vector/SphericalTensor/SymmTensor/Tensor fields (See Notes below to use the lagrangian feature).
  • supports compressed(gzipped)/uncompressed-ascii/double precision binary data formats. Single precision binary format is not supported.
  • has a builtin cell data to point data filter (not as accurate as the volPoint interpolator in paraFoam but supposed to be better than the one in ParaView, see Notes below)
  • has a neat user interface. Patch and array selection lists are now offered.

2 Installation

1. Get the ParaView3 source.

  • For 3.3-CVS:
cvs -d :pserver:anoncvs@www.paraview.org:/cvsroot/ParaView3 login
    (respond with empty password)
cvs -d :pserver:anoncvs@www.paraview.org:/cvsroot/ParaView3 co ParaView3
  • For 3.2.1:
tar -zxf paraview-3.2.1.tar.gz
ln -s ParaView3.2.1 ParaView3
(a symbolic link is required for the reader package to be correctly unpacked)

2. Untar the package at the parent directory of ParaView3 source tree (the directory where you issued the above cvs commands). This will overwrite the reader code included in the source tree.

tar jxf vtkOpenFOAMReader-YYYYMMDD.tar.bz2

3. Patch the XML code at the parent dirctory.

patch -b -p0 < readers.xml.diff
  • For 3.2.1: add the following piece into ParaView3.2.1/Qt/Components/Resources/XML/ParaViewReaders.xml.
<Reader name="OpenFOAMReader"
          extensions="foam"
          file_description="OpenFOAM Files">
</Reader>

4. Build ParaView3 as usual. It is highly recommended to turn on compiler optimization (by setting CMAKE_BUILD_TYPE to Release) since the reader is dead slow without optimization. If you get a bit better performance than paraFoam the optimization is working adequately.

3 Notes

  • To load an OpenFOAM case, you either have to
    • create an empty stub file <caseName>.foam right under the case directory, where <caseName> is an arbitrary string other than the strings that starts with "controlDict," or
    • create a symbolic link from controlDict to controlDict.foam and open controlDict.foam.
  • The builtin cell-to-point filter works like a Cell Data to Point Data filter in ParaView in that it just takes the average of cell values connected to a point. The difference is that the builtin filter takes boundary patch values into account. The filter is not as accurate as the volPoint interpolator in paraFoam, which further does inverse distance weighting of cell values.
  • The cell-to-point filter is computationally demanding so you can turn it off by deselecting "Create cell-to-point filtered data" on the reader panel.
  • Several compile-time performance-related configuration options are now provided at the beginning of vtkOpenFOAMReader.cxx. With defaults the reader
    • omits CRC checks for gzipped files (except on Windows)
    • counts line numbers where the FoamFile parser is reading (if turned off, the line number will always be shown as 0 when the reader issues a parser error in return for a bit of additional performance)
    • uses its own string to floating point conversion routine, which is fast but may be a bit inaccurate than the system strtod().
  • To separate Eulerians and Lagrangians, extract Node 0 for Eulerians and Dataset 1 right under Root with Filter->Extract Block (ParaView 3.3) or group 0 for Eulerians and group 1 for Lagrangians with Extract Group (ParaView 3.2.1).
  • To create a slice with volField data you have to extract internal mesh (dataset 0) or turn off reading patches in the reader panel.
  • The reader lists time instances according to descriptions in controlDict when (adjustTimeStep, writeControl) == (yes, adjustableRunTime) or (no, timeStep) (i. e. writing interval is supposed to be constant in simulated time), or otherwise, lists all valid time directories. This is a different behavior from paraFoam which always lists all valid time directories in a case directory.
  • The reader lists array names according to the "object" entry in FoamFile header, whereas paraFoam lists according to the file name of the object. So you need a valid FoamFile header for every object.
  • The Accumulate Patches checkbox in the reader panel is meant to be used for topo change cases to append patches that don't exist in the initial timestep into the selection list over an animation run. To update the patch selection list after the run, deselect controlDict.foam in Pipeline Browser once and re-select it.
  • Handling of boundary conditions is quite poor as of now; if a boundary patch doesn't have a value entry the corresponding patch-internal field value is used (i. e. equivalent to zeroGradient b. c.)
  • Mesh which consists of polyMesh/points, polyMesh/faces and polyMesh/cells (old mesh format) is not supported.
  • It looks like Filter->Surface Flow doesn't work because of an incompatibility between what the reader offers as output dataset and what the filter requires as input, i.e. the Surface Flow filter doesn't seem to support composite dataset types, one of which is the type of dataset the reader outputs. Other possibly incompatible filters with the same reason are Append Attributes and Append Datasets (I still haven't confirmed though). Unfortunately no quick workaround come to me.
  • For binary-formatted Lagrangian positions files the reader only supports the ones created by OF version 1.4 or later.
  • The FoamFile parser is still under development so if you find a bug posting a minimal test case will be highly appreciated.

4 Downloads

Download from the native reader thread on the Message Board.

You can also download prebuilt binaries with the reader included here (currently only available for Windows).

5 History

7islands 02:58, 28 April 2008 (CEST) (Takuya OSHIMA): update for the 20080324 version.

7islands 09:18, 29 Dec 2007 (CET): some addenda.

7islands 04:36, 16 Dec 2007 (CET) (Takuya OSHIMA): Created this page.