diff --git a/ThirdParty/AllMake.stage4 b/ThirdParty/AllMake.stage4
index f415401a8..1d365d8a8 100755
--- a/ThirdParty/AllMake.stage4
+++ b/ThirdParty/AllMake.stage4
@@ -73,12 +73,12 @@ then
if [ -d "$QT_BIN_DIR" -a -r "$QT_BIN_DIR"/qmake ]
then
- ( rpm_make -p ParaView-3.14.1 -s ParaView-3.14.1.spec -u http://www.paraview.org/files/v3.14/ParaView-3.14.1-Source.tar.gz \
+ ( rpm_make -p ParaView-4.0.1 -s ParaView-4.0.1.spec -u http://www.paraview.org/files/v4.0/ParaView-v4.0.1-source.tgz \
-f --define='_qmakePath $QT_BIN_DIR/qmake'
)
else
echo "WARNING: "
- echo "WARNING: Skipping the installation of ParaView-3.12.0."
+ echo "WARNING: Skipping the installation of ParaView-4.0.1."
echo "WARNING: Please make sure the QT_BIN_DIR environment variable properly"
echo "WARNING: initialized in the file prefs.sh or prefs.csh"
echo "WARNING: The command \$QT_BIN_DIR/qmake needs to be valid"
diff --git a/ThirdParty/rpmBuild/SOURCES/ParaView-4.0.1.patch_darwin b/ThirdParty/rpmBuild/SOURCES/ParaView-4.0.1.patch_darwin
new file mode 100644
index 000000000..89a50b9b2
--- /dev/null
+++ b/ThirdParty/rpmBuild/SOURCES/ParaView-4.0.1.patch_darwin
@@ -0,0 +1,12 @@
+diff -ruN ParaView-4.0.1_orig/Applications/ParaView-4.0.1_extra_install_Darwin.cmake ParaView-4.0.1/Applications/ParaView-4.0.1_extra_install_Darwin.cmake
+--- ParaView-4.0.1_orig/Applications/ParaView-4.0.1_extra_install_Darwin.cmake 1969-12-31 19:00:00.000000000 -0500
++++ ParaView-4.0.1/Applications/ParaView-4.0.1_extra_install_Darwin.cmake 2013-10-02 19:00:00.000000000 -0400
+@@ -0,0 +1,8 @@
++#
++# Additional install rules for Mac OS X platforms
++#
++INSTALL (DIRECTORY ../../buildObj/bin/paraview.app
++ DESTINATION ${PV_INSTALL_BIN_DIR}
++ USE_SOURCE_PERMISSIONS
++ COMPONENT Runtime)
++
diff --git a/ThirdParty/rpmBuild/SPECS/ParaView-4.0.1.spec b/ThirdParty/rpmBuild/SPECS/ParaView-4.0.1.spec
new file mode 100644
index 000000000..30a5f5a3c
--- /dev/null
+++ b/ThirdParty/rpmBuild/SPECS/ParaView-4.0.1.spec
@@ -0,0 +1,275 @@
+#------------------------------------------------------------------------------
+# ========= |
+# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+# \\ / O peration |
+# \\ / A nd | Copyright held by original author
+# \\/ M anipulation |
+#------------------------------------------------------------------------------
+# License
+# This file is part of OpenFOAM.
+#
+# OpenFOAM is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version.
+#
+# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with OpenFOAM; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Script
+# RPM spec file for ParaView-4.0.1
+#
+# Description
+# RPM spec file for creating a relocatable RPM
+#
+# Authors:
+# Martin Beaudoin, Hydro-Quebec, (2010)
+# Andreas Feymark, Chalmers University of Technology, (2013)
+#
+#------------------------------------------------------------------------------
+
+# We grab the value of WM_THIRD_PARTY and WM_OPTIONS from the environment variable
+%{expand:%%define _WM_THIRD_PARTY_DIR %(echo $WM_THIRD_PARTY_DIR)}
+%{expand:%%define _WM_OPTIONS %(echo $WM_OPTIONS)}
+
+# Disable the generation of debuginfo packages
+%define debug_package %{nil}
+
+# The topdir needs to point to the $WM_THIRD_PARTY/rpmbuild directory
+%define _topdir %{_WM_THIRD_PARTY_DIR}/rpmBuild
+%define _tmppath %{_topdir}/tmp
+
+# Will install the package directly $WM_THIRD_PARTY_DIR
+# Some comments about package relocation:
+# By using this prefix for the Prefix: parameter in this file, you will make this
+# package relocatable.
+#
+# This is fine, as long as your software is itself relocatable.
+#
+# Simply take note that libraries built with libtool are not relocatable because the
+# prefix we specify will be hard-coded in the library .la files.
+# Ref: http://sourceware.org/autobook/autobook/autobook_80.html
+#
+# In that case, if you ever change the value of the $WM_THIRD_PARTY_DIR, you will
+# not be able to reutilize this RPM, even though it is relocatable. You will need to
+# regenerate the RPM.
+#
+%define _prefix %{_WM_THIRD_PARTY_DIR}
+
+%define name ParaView
+%define release %{_WM_OPTIONS}
+%define version 4.0.1
+
+%define buildroot %{_topdir}/BUILD/%{name}-%{version}-root
+
+BuildRoot: %{buildroot}
+Summary: ParaView
+License: Unkown
+Name: %{name}
+Version: %{version}
+Release: %{release}
+URL: http://www.paraview.org/files/v4.0/
+Source: %url/%{name}-v%{version}-source.tgz
+Prefix: %{_prefix}
+Group: Development/Tools
+Patch0: ParaView-4.0.1.patch_darwin
+
+%define _installPrefix %{_prefix}/packages/%{name}-%{version}/platforms/%{_WM_OPTIONS}
+
+#--------------------------------------------------------------------------
+#
+# Here, we define default compiling options for cmake
+#
+# One can override the option on the commande line : --define='MACRO EXPR'
+#
+%{!?_withVerbose: %define _withVerbose false}
+%{!?_withMesa: %define _withMesa false}
+%{!?_withMPI: %define _withMPI false}
+%{!?_withPython: %define _withPython false}
+%{!?_withQt: %define _withQt true}
+%{!?_qmakePath: %define _qmakePath Undefined}
+%{!?_mesaIncludePath: %define _mesaIncludePath Undefined}
+%{!?_mesaLibPath: %define _mesaLibPath Undefined}
+%{!?_pythonLibPath: %define _pythonLibPath Undefined}
+
+#--------------------------------------------------------------------------
+
+%description
+%{summary}
+
+%prep
+%setup -q -n %{name}-v%{version}-source
+
+%ifos darwin
+%patch0 -p1
+%endif
+
+%build
+#
+# set CMake cache variables
+#
+ addCMakeVariable()
+ {
+ while [ -n "$1" ]
+ do
+ CMAKE_VARIABLES="$CMAKE_VARIABLES -D$1"
+ shift
+ done
+ }
+
+ # export WM settings in a form that GNU configure recognizes
+ [ -n "$WM_CC" ] && export CC="$WM_CC"
+ [ -n "$WM_CXX" ] && export CXX="$WM_CXX"
+ [ -n "$WM_CFLAGS" ] && export CFLAGS="$WM_CFLAGS"
+ [ -n "$WM_CXXFLAGS" ] && export CXXFLAGS="$WM_CXXFLAGS"
+ [ -n "$WM_LDFLAGS" ] && export LDFLAGS="$WM_LDFLAGS"
+
+ set +x
+ echo ""
+ echo "Compilation options:"
+ echo " _withVerbose : %{_withVerbose}"
+ echo " _withMesa : %{_withMesa}"
+ echo " _withMPI : %{_withMPI}"
+ echo " _withPython : %{_withPython}"
+ echo " _withQt : %{_withQt}"
+ echo " _qmakePath : %{_qmakePath}"
+ echo " _mesaIncludePath : %{_mesaIncludePath}"
+ echo " _mesaLibPath : %{_mesaLibPath}"
+ echo " _pythonLibPath : %{_pythonLibPath}"
+ echo ""
+ set -x
+
+ # start with these general settings
+ addCMakeVariable VTK_USE_TK:BOOL=OFF
+ addCMakeVariable BUILD_SHARED_LIBS:BOOL=ON VTK_USE_RPATH:BOOL=OFF
+ addCMakeVariable CMAKE_BUILD_TYPE:STRING=Release
+
+ # include development files in "make install"
+ addCMakeVariable PARAVIEW_INSTALL_DEVELOPMENT_FILES:BOOL=ON
+
+ # new alternative to "make HTMLDocumentation"
+ addCMakeVariable PARAVIEW_GENERATE_PROXY_DOCUMENTATION:BOOL=ON
+
+ %ifos darwin
+ # Additional installation rules for Mac OS X
+ addCMakeVariable PARAVIEW_EXTRA_INSTALL_RULES_FILE:FILEPATH=%{_topdir}/BUILD/%{name}-%{version}/Applications/ParaView-3.8.1_extra_install_Darwin.cmake
+%endif
+
+ # Add the value of _qmakePath for QT_QMAKE_EXECUTABLE
+ addCMakeVariable QT_QMAKE_EXECUTABLE:FILEPATH=%{_qmakePath}
+
+ echo "CMAKE_VARIABLES: $CMAKE_VARIABLES"
+
+ mkdir -p ./buildObj
+ cd ./buildObj
+
+ cmake \
+ -DCMAKE_INSTALL_PREFIX:PATH=%{_installPrefix} \
+ $CMAKE_VARIABLES \
+ ..
+
+ [ -z "$WM_NCOMPPROCS" ] && WM_NCOMPPROCS=1
+ make -j $WM_NCOMPPROCS
+
+%install
+ # On OpenSUSE, rpmbuild, will choke when detecting unreferenced symlinks
+ # created during installation.
+ # Qt version 4.6.3 will generate some unreferenced symlinks when
+ # ParaView is compiled and installed. By enabling the following
+ # environment variable, the command brp-symlink will still complain
+ # about missing link targets, but it won't stop rpmbuild from generating
+ # the final rpm.
+ # For all other Unix distros, this is a no-op.
+ export NO_BRP_STALE_LINK_ERROR=yes
+
+ cd buildObj
+ make install DESTDIR=$RPM_BUILD_ROOT
+
+ # Creation of OpenFOAM specific .csh and .sh files"
+
+ echo ""
+ echo "Generating OpenFOAM specific .csh and .sh files for the package %{name}-%{version}"
+ echo ""
+ #
+ # Generate package specific .sh file for OpenFOAM
+ #
+mkdir -p $RPM_BUILD_ROOT/%{_installPrefix}/etc
+cat << DOT_SH_EOF > $RPM_BUILD_ROOT/%{_installPrefix}/etc/%{name}-%{version}.sh
+# Load %{name}-%{version} libraries and binaries if available
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+export PARAVIEW_DIR=\$WM_THIRD_PARTY_DIR/packages/%{name}-%{version}/platforms/\$WM_OPTIONS
+export PARAVIEW_BIN_DIR=\$PARAVIEW_DIR/bin
+export PARAVIEW_LIB_DIR=\$PARAVIEW_DIR/lib
+export PARAVIEW_INCLUDE_DIR=\$PARAVIEW_DIR/include/paraview-4.0
+
+export PARAVIEW_VERSION=%{version}
+
+# NB: It is important to set the PV_PLUGIN_PATH location to a directory containing only the ParaView plugins.
+# Otherwise, paraview will try to automatically autoload each and every dynamic library it can find in the
+# specified directory to see if a given library is a paraview plugin.
+# In the case of \$FOAM_LIBBIN, with over 80 libraries, this is a total waste of time that will slow down the
+# startup of paraview or even make paraview crash on startup.
+export PV_PLUGIN_PATH=\$FOAM_LIBBIN/paraview_plugins
+
+[ -d \$PARAVIEW_LIB_DIR/paraview-4.0 ] && _foamAddLib \$PARAVIEW_LIB_DIR/paraview-4.0
+
+# Enable access to the package applications if present
+[ -d \$PARAVIEW_BIN_DIR ] && _foamAddPath \$PARAVIEW_BIN_DIR
+
+# Additional binary path if running on Mac OS X
+[ -d \$PARAVIEW_BIN_DIR/paraview.app/Contents/MacOS ] && _foamAddPath \$PARAVIEW_BIN_DIR/paraview.app/Contents/MacOS
+
+DOT_SH_EOF
+
+ #
+ # Generate package specific .csh file for OpenFOAM
+ #
+cat << DOT_CSH_EOF > $RPM_BUILD_ROOT/%{_installPrefix}/etc/%{name}-%{version}.csh
+# Load %{name}-%{version} libraries and binaries if available
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+setenv PARAVIEW_DIR \$WM_THIRD_PARTY_DIR/packages/%{name}-%{version}/platforms/\$WM_OPTIONS
+setenv PARAVIEW_BIN_DIR \$PARAVIEW_DIR/bin
+setenv PARAVIEW_LIB_DIR \$PARAVIEW_DIR/lib
+setenv PARAVIEW_INCLUDE_DIR \$PARAVIEW_DIR/include/paraview-4.0
+
+setenv PARAVIEW_VERSION %{version}
+
+# NB: It is important to set the PV_PLUGIN_PATH location to a directory containing only the ParaView plugins.
+# Otherwise, paraview will try to automatically autoload each and every dynamic library it can find in the
+# specified directory to see if a given library is a paraview plugin.
+# In the case of \$FOAM_LIBBIN, with over 80 libraries, this is a total waste of time that will slow down the
+# startup of paraview or even make paraview crash on startup.
+setenv PV_PLUGIN_PATH \$FOAM_LIBBIN/paraview_plugins
+
+if ( -e \$PARAVIEW_BIN_DIR ) then
+ _foamAddPath \$PARAVIEW_BIN_DIR
+endif
+
+if ( -e \$PARAVIEW_LIB_DIR/paraview-4.0 ) then
+ _foamAddLib \$PARAVIEW_LIB_DIR/paraview-4.0
+endif
+
+
+# Additional binary path if running on Mac OS X
+if ( -e \$PARAVIEW_BIN_DIR/paraview.app/Contents/MacOS ) then
+ _foamAddPath \$PARAVIEW_BIN_DIR/paraview.app/Contents/MacOS
+endif
+DOT_CSH_EOF
+
+ #finally, generate a .tgz file for systems where using rpm for installing packages
+ # as a non-root user might be a problem.
+ (mkdir -p %{_topdir}/TGZS/%{_target_cpu}; cd $RPM_BUILD_ROOT/%{_prefix}; tar -zcvf %{_topdir}/TGZS/%{_target_cpu}/%{name}-%{version}.tgz packages/%{name}-%{version})
+
+%clean
+
+%files
+%defattr(-,root,root)
+%{_installPrefix}
+
diff --git a/applications/utilities/postProcessing/graphics/PV4FoamReader/Allwclean b/applications/utilities/postProcessing/graphics/PV4FoamReader/Allwclean
new file mode 100755
index 000000000..214aeb565
--- /dev/null
+++ b/applications/utilities/postProcessing/graphics/PV4FoamReader/Allwclean
@@ -0,0 +1,8 @@
+#!/bin/sh
+cd ${0%/*} || exit 1 # run from this directory
+set -x
+
+rm -rf PV4FoamReader/Make
+wclean libso vtkPV4Foam
+
+# ----------------------------------------------------------------- end-of-file
diff --git a/applications/utilities/postProcessing/graphics/PV4FoamReader/Allwmake b/applications/utilities/postProcessing/graphics/PV4FoamReader/Allwmake
new file mode 100755
index 000000000..9c596d5aa
--- /dev/null
+++ b/applications/utilities/postProcessing/graphics/PV4FoamReader/Allwmake
@@ -0,0 +1,26 @@
+#!/bin/bash
+cd ${0%/*} || exit 1 # run from this directory
+set -x
+
+if [ -d "$PARAVIEW_DIR" -a -r "$PARAVIEW_DIR" ]
+then
+ case "$PARAVIEW_VERSION" in
+ 4*)
+ wmake libso vtkPV4Foam
+ (
+ cd PV4FoamReader
+ mkdir -p Make/$WM_OPTIONS > /dev/null 2>&1
+ cd Make/$WM_OPTIONS
+ cmake ../..
+ if [ "$WM_ARCH_BASE" == "darwin" ]
+ then
+ sed -i bak -e 's/-dynamiclib /& -undefined dynamic_lookup /' CMakeFiles/PV4FoamReader.dir/link.txt
+ sed -i bak -e 's/-dynamiclib /& -undefined dynamic_lookup /' CMakeFiles/PV4FoamReader_SM.dir/link.txt
+ fi
+ make
+ )
+ ;;
+ esac
+fi
+
+# ----------------------------------------------------------------- end-of-file
diff --git a/applications/utilities/postProcessing/graphics/PV4FoamReader/PV4FoamReader/CMakeLists.txt b/applications/utilities/postProcessing/graphics/PV4FoamReader/PV4FoamReader/CMakeLists.txt
new file mode 100644
index 000000000..79a8becf3
--- /dev/null
+++ b/applications/utilities/postProcessing/graphics/PV4FoamReader/PV4FoamReader/CMakeLists.txt
@@ -0,0 +1,61 @@
+# create a plugin that adds a reader to the ParaView GUI
+# it is added in the file dialog when doing opens/saves.
+
+# The qrc file is processed by Qt's resource compiler (rcc)
+# the qrc file must have a resource prefix of "/ParaViewResources"
+# and ParaView will read anything contained under that prefix
+# the pqReader.xml file contains xml defining readers with their
+# file extensions and descriptions.
+
+cmake_minimum_required(VERSION 2.4)
+
+if(COMMAND cmake_policy)
+ cmake_policy(SET CMP0003 NEW)
+endif(COMMAND cmake_policy)
+
+FIND_PACKAGE(ParaView REQUIRED)
+INCLUDE(${PARAVIEW_USE_FILE})
+
+LINK_DIRECTORIES(
+ $ENV{FOAM_LIBBIN}
+)
+
+INCLUDE_DIRECTORIES(
+ $ENV{WM_PROJECT_DIR}/src/OpenFOAM/lnInclude
+ $ENV{WM_PROJECT_DIR}/src/finiteVolume/lnInclude
+ ${PROJECT_SOURCE_DIR}/../vtkPV4Foam
+)
+
+ADD_DEFINITIONS(
+ -DWM_$ENV{WM_PRECISION_OPTION}
+)
+
+# Set output library destination to plugin folder
+SET(
+ LIBRARY_OUTPUT_PATH $ENV{PV_PLUGIN_PATH}
+ CACHE INTERNAL
+ "Single output directory for building all libraries."
+)
+
+# Build the server-side plugin
+ADD_PARAVIEW_PLUGIN(
+ PV4FoamReader_SM "1.0"
+ SERVER_MANAGER_XML PV4FoamReader_SM.xml
+ SERVER_MANAGER_SOURCES vtkPV4FoamReader.cxx
+)
+
+# Build the client-side plugin
+ADD_PARAVIEW_PLUGIN(
+ PV4FoamReader
+ "1.0"
+ GUI_RESOURCES PV4FoamReader.qrc
+)
+
+TARGET_LINK_LIBRARIES(
+ PV4FoamReader_SM
+ OpenFOAM
+ finiteVolume
+ vtkPV4Foam
+ pqCore
+)
+#-----------------------------------------------------------------------------
diff --git a/applications/utilities/postProcessing/graphics/PV4FoamReader/PV4FoamReader/PV4FoamReader.qrc b/applications/utilities/postProcessing/graphics/PV4FoamReader/PV4FoamReader/PV4FoamReader.qrc
new file mode 100644
index 000000000..c5bfc27b7
--- /dev/null
+++ b/applications/utilities/postProcessing/graphics/PV4FoamReader/PV4FoamReader/PV4FoamReader.qrc
@@ -0,0 +1,5 @@
+
+
+ PV4FoamReader.xml
+
+
diff --git a/applications/utilities/postProcessing/graphics/PV4FoamReader/PV4FoamReader/PV4FoamReader.xml b/applications/utilities/postProcessing/graphics/PV4FoamReader/PV4FoamReader/PV4FoamReader.xml
new file mode 100644
index 000000000..bb940768d
--- /dev/null
+++ b/applications/utilities/postProcessing/graphics/PV4FoamReader/PV4FoamReader/PV4FoamReader.xml
@@ -0,0 +1,6 @@
+
+
+
+
diff --git a/applications/utilities/postProcessing/graphics/PV4FoamReader/PV4FoamReader/PV4FoamReader_SM.xml b/applications/utilities/postProcessing/graphics/PV4FoamReader/PV4FoamReader/PV4FoamReader_SM.xml
new file mode 100644
index 000000000..350a58f0a
--- /dev/null
+++ b/applications/utilities/postProcessing/graphics/PV4FoamReader/PV4FoamReader/PV4FoamReader_SM.xml
@@ -0,0 +1,209 @@
+
+
+
+
+
+
+
+
+ Specifies the filename for the OpenFOAM Reader.
+
+
+
+
+
+
+
+ Available timestep values.
+
+
+
+
+
+
+
+
+
+
+ Extrapolate internalField to non-constraint patches
+
+
+
+
+
+
+ Searches the polyMesh/sets/ directory
+
+
+
+
+
+
+
+ ZoneMesh information is used to find {cell,face,point}Zones.
+ The polyMesh/ directory is only checked on startup.
+
+
+
+
+
+
+
+
+ Show patch names in render window.
+
+
+
+
+
+
+
+ Cache the fvMesh in memory.
+
+
+
+
+
+
+
+
+ A simple way cause a reader GUI modification.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/applications/utilities/postProcessing/graphics/PV4FoamReader/PV4FoamReader/vtkPV4FoamReader.cxx b/applications/utilities/postProcessing/graphics/PV4FoamReader/PV4FoamReader/vtkPV4FoamReader.cxx
new file mode 100644
index 000000000..0d596555b
--- /dev/null
+++ b/applications/utilities/postProcessing/graphics/PV4FoamReader/PV4FoamReader/vtkPV4FoamReader.cxx
@@ -0,0 +1,683 @@
+/*=========================================================================
+
+ Program: Visualization Toolkit
+ Module: $RCSfile: vtkPV4FoamReader.cxx,v $
+
+ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
+ All rights reserved.
+ See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notice for more information.
+
+=========================================================================*/
+
+#include "vtkPV4FoamReader.h"
+
+#include "pqApplicationCore.h"
+#include "pqRenderView.h"
+#include "pqServerManagerModel.h"
+
+// VTK includes
+#include "vtkCallbackCommand.h"
+#include "vtkDataArraySelection.h"
+#include "vtkInformation.h"
+#include "vtkInformationVector.h"
+#include "vtkMultiBlockDataSet.h"
+#include "vtkObjectFactory.h"
+#include "vtkSMRenderViewProxy.h"
+#include "vtkStreamingDemandDrivenPipeline.h"
+#include "vtkStringArray.h"
+
+// Foam includes
+#include "vtkPV4Foam.H"
+
+vtkCxxRevisionMacro(vtkPV4FoamReader, "$Revision: 1.5$");
+vtkStandardNewMacro(vtkPV4FoamReader);
+
+#undef EXPERIMENTAL_TIME_CACHING
+
+vtkPV4FoamReader::vtkPV4FoamReader()
+{
+ Debug = 0;
+ vtkDebugMacro(<<"Constructor");
+
+ SetNumberOfInputPorts(0);
+
+ FileName = NULL;
+ foamData_ = NULL;
+
+ output0_ = NULL;
+
+#ifdef VTKPV4FOAM_DUALPORT
+ // Add second output for the Lagrangian
+ this->SetNumberOfOutputPorts(2);
+ vtkMultiBlockDataSet *lagrangian = vtkMultiBlockDataSet::New();
+ lagrangian->ReleaseData();
+
+ this->GetExecutive()->SetOutputData(1, lagrangian);
+ lagrangian->Delete();
+#endif
+
+ TimeStepRange[0] = 0;
+ TimeStepRange[1] = 0;
+
+ CacheMesh = 1;
+
+ ExtrapolatePatches = 0;
+ IncludeSets = 0;
+ IncludeZones = 0;
+ ShowPatchNames = 0;
+
+ UpdateGUI = 0;
+
+ PartSelection = vtkDataArraySelection::New();
+ VolFieldSelection = vtkDataArraySelection::New();
+ PointFieldSelection = vtkDataArraySelection::New();
+ LagrangianFieldSelection = vtkDataArraySelection::New();
+
+ // Setup the selection callback to modify this object when an array
+ // selection is changed.
+ SelectionObserver = vtkCallbackCommand::New();
+ SelectionObserver->SetCallback
+ (
+ &vtkPV4FoamReader::SelectionModifiedCallback
+ );
+ SelectionObserver->SetClientData(this);
+
+ PartSelection->AddObserver
+ (
+ vtkCommand::ModifiedEvent,
+ this->SelectionObserver
+ );
+ VolFieldSelection->AddObserver
+ (
+ vtkCommand::ModifiedEvent,
+ this->SelectionObserver
+ );
+ PointFieldSelection->AddObserver
+ (
+ vtkCommand::ModifiedEvent,
+ this->SelectionObserver
+ );
+ LagrangianFieldSelection->AddObserver
+ (
+ vtkCommand::ModifiedEvent,
+ this->SelectionObserver
+ );
+}
+
+
+vtkPV4FoamReader::~vtkPV4FoamReader()
+{
+ vtkDebugMacro(<<"Deconstructor");
+
+ delete foamData_;
+
+ if (FileName)
+ {
+ delete [] FileName;
+ }
+
+ if (output0_)
+ {
+ output0_->Delete();
+ }
+
+
+ PartSelection->RemoveObserver(this->SelectionObserver);
+ VolFieldSelection->RemoveObserver(this->SelectionObserver);
+ PointFieldSelection->RemoveObserver(this->SelectionObserver);
+ LagrangianFieldSelection->RemoveObserver(this->SelectionObserver);
+
+ SelectionObserver->Delete();
+
+ PartSelection->Delete();
+ VolFieldSelection->Delete();
+ PointFieldSelection->Delete();
+ LagrangianFieldSelection->Delete();
+}
+
+
+// Do everything except set the output info
+int vtkPV4FoamReader::RequestInformation
+(
+ vtkInformation* vtkNotUsed(request),
+ vtkInformationVector** vtkNotUsed(inputVector),
+ vtkInformationVector* outputVector
+)
+{
+ vtkDebugMacro(<<"RequestInformation");
+
+ if (Foam::vtkPV4Foam::debug)
+ {
+ cout<<"REQUEST_INFORMATION\n";
+ }
+
+ if (!FileName)
+ {
+ vtkErrorMacro("FileName has to be specified!");
+ return 0;
+ }
+
+ int nInfo = outputVector->GetNumberOfInformationObjects();
+
+ if (Foam::vtkPV4Foam::debug)
+ {
+ cout<<"RequestInformation with " << nInfo << " item(s)\n";
+ for (int infoI = 0; infoI < nInfo; ++infoI)
+ {
+ outputVector->GetInformationObject(infoI)->Print(cout);
+ }
+ }
+
+ if (!foamData_)
+ {
+ foamData_ = new Foam::vtkPV4Foam(FileName, this);
+ }
+ else
+ {
+ foamData_->updateInfo();
+ }
+
+ int nTimeSteps = 0;
+ double* timeSteps = foamData_->findTimes(nTimeSteps);
+
+ if (!nTimeSteps)
+ {
+ vtkErrorMacro("could not find valid OpenFOAM mesh");
+
+ // delete foamData and flag it as fatal error
+ delete foamData_;
+ foamData_ = NULL;
+ return 0;
+ }
+
+ // set identical time steps for all ports
+ for (int infoI = 0; infoI < nInfo; ++infoI)
+ {
+ outputVector->GetInformationObject(infoI)->Set
+ (
+ vtkStreamingDemandDrivenPipeline::TIME_STEPS(),
+ timeSteps,
+ nTimeSteps
+ );
+ }
+
+ if (nTimeSteps)
+ {
+ double timeRange[2];
+ timeRange[0] = timeSteps[0];
+ timeRange[1] = timeSteps[nTimeSteps-1];
+
+ if (Foam::vtkPV4Foam::debug > 1)
+ {
+ cout<<"nTimeSteps " << nTimeSteps << "\n"
+ <<"timeRange " << timeRange[0] << " to " << timeRange[1]
+ << "\n";
+
+ for (int timeI = 0; timeI < nTimeSteps; ++timeI)
+ {
+ cout<< "step[" << timeI << "] = " << timeSteps[timeI] << "\n";
+ }
+ }
+
+ for (int infoI = 0; infoI < nInfo; ++infoI)
+ {
+ outputVector->GetInformationObject(infoI)->Set
+ (
+ vtkStreamingDemandDrivenPipeline::TIME_RANGE(),
+ timeRange,
+ 2
+ );
+ }
+ }
+
+ delete timeSteps;
+
+ return 1;
+}
+
+
+// Set the output info
+int vtkPV4FoamReader::RequestData
+(
+ vtkInformation* vtkNotUsed(request),
+ vtkInformationVector** vtkNotUsed(inputVector),
+ vtkInformationVector* outputVector
+)
+{
+ vtkDebugMacro(<<"RequestData");
+
+ if (!FileName)
+ {
+ vtkErrorMacro("FileName has to be specified!");
+ return 0;
+ }
+
+ // catch previous error
+ if (!foamData_)
+ {
+ vtkErrorMacro("Reader failed - perhaps no mesh?");
+ return 0;
+ }
+
+ int nInfo = outputVector->GetNumberOfInformationObjects();
+
+ if (Foam::vtkPV4Foam::debug)
+ {
+ cout<<"RequestData with " << nInfo << " item(s)\n";
+ for (int infoI = 0; infoI < nInfo; ++infoI)
+ {
+ outputVector->GetInformationObject(infoI)->Print(cout);
+ }
+ }
+
+ // Get the requested time step.
+ // We only support requests for a single time step
+
+ int nRequestTime = 0;
+ double requestTime[nInfo];
+
+ // taking port0 as the lead for other outputs would be nice, but fails when
+ // a filter is added - we need to check everything
+ // but since PREVIOUS_UPDATE_TIME_STEPS() is protected, relay the logic
+ // to the vtkPV4Foam::setTime() method
+ for (int infoI = 0; infoI < nInfo; ++infoI)
+ {
+ vtkInformation *outInfo = outputVector->GetInformationObject(infoI);
+
+ if
+ (
+ outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP())
+ && outInfo->Length(vtkStreamingDemandDrivenPipeline::TIME_STEPS()) >= 1
+ )
+ {
+ requestTime[nRequestTime++] = outInfo->Get
+ (
+ vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()
+ );
+ }
+ }
+
+ if (nRequestTime)
+ {
+ foamData_->setTime(nRequestTime, requestTime);
+ }
+
+
+ vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::SafeDownCast
+ (
+ outputVector->GetInformationObject(0)->Get
+ (
+ vtkMultiBlockDataSet::DATA_OBJECT()
+ )
+ );
+
+ if (Foam::vtkPV4Foam::debug)
+ {
+ cout<< "update output with "
+ << output->GetNumberOfBlocks() << " blocks\n";
+ }
+
+
+#ifdef EXPERIMENTAL_TIME_CACHING
+ bool needsUpdate = false;
+
+ if (!output0_)
+ {
+ output0_ = vtkMultiBlockDataSet::New();
+ needsUpdate = true;
+ }
+
+ // This experimental bit of code seems to work for the geometry,
+ // but trashes the fields and still triggers the GeometryFilter
+ if (needsUpdate)
+ {
+ foamData_->Update(output);
+ output0_->ShallowCopy(output);
+ }
+ else
+ {
+ output->ShallowCopy(output0_);
+ }
+
+ if (Foam::vtkPV4Foam::debug)
+ {
+ if (needsUpdate)
+ {
+ cout<< "full UPDATE ---------\n";
+ }
+ else
+ {
+ cout<< "cached UPDATE ---------\n";
+ }
+
+ cout<< "UPDATED output: ";
+ output->Print(cout);
+
+ cout<< "UPDATED output0_: ";
+ output0_->Print(cout);
+ }
+
+#else
+
+#ifdef VTKPV4FOAM_DUALPORT
+ foamData_->Update
+ (
+ output,
+ vtkMultiBlockDataSet::SafeDownCast
+ (
+ outputVector->GetInformationObject(1)->Get
+ (
+ vtkMultiBlockDataSet::DATA_OBJECT()
+ )
+ );
+ );
+#else
+ foamData_->Update(output, output);
+#endif
+
+ if (ShowPatchNames)
+ {
+ addPatchNamesToView();
+ }
+ else
+ {
+ removePatchNamesFromView();
+ }
+
+#endif
+
+ // Do any cleanup on the Foam side
+ foamData_->CleanUp();
+
+ return 1;
+}
+
+
+void vtkPV4FoamReader::addPatchNamesToView()
+{
+ pqApplicationCore* appCore = pqApplicationCore::instance();
+
+ // Server manager model for querying items in the server manager
+ pqServerManagerModel* smModel = appCore->getServerManagerModel();
+
+ // Get all the pqRenderView instances
+ QList renderViews = smModel->findItems();
+
+ for (int viewI=0; viewIaddPatchNames
+ (
+ renderViews[viewI]->getRenderViewProxy()->GetRenderer()
+ );
+ }
+}
+
+
+void vtkPV4FoamReader::removePatchNamesFromView()
+{
+ pqApplicationCore* appCore = pqApplicationCore::instance();
+
+ // Server manager model for querying items in the server manager
+ pqServerManagerModel* smModel = appCore->getServerManagerModel();
+
+ // Get all the pqRenderView instances
+ QList renderViews = smModel->findItems();
+
+ for (int viewI=0; viewIremovePatchNames
+ (
+ renderViews[viewI]->getRenderViewProxy()->GetRenderer()
+ );
+ }
+}
+
+
+void vtkPV4FoamReader::PrintSelf(ostream& os, vtkIndent indent)
+{
+ vtkDebugMacro(<<"PrintSelf");
+
+ this->Superclass::PrintSelf(os,indent);
+ os<< indent << "File name: "
+ << (this->FileName ? this->FileName : "(none)") << "\n";
+
+ foamData_->PrintSelf(os, indent);
+
+ os<< indent << "Time step range: "
+ << this->TimeStepRange[0] << " - " << this->TimeStepRange[1]
+ << "\n";
+ os<< indent << "Time step: " << this->GetTimeStep() << endl;
+}
+
+
+int vtkPV4FoamReader::GetTimeStep()
+{
+ return foamData_ ? foamData_->timeIndex() : -1;
+}
+
+
+// ----------------------------------------------------------------------
+// Parts selection list control
+
+vtkDataArraySelection* vtkPV4FoamReader::GetPartSelection()
+{
+ vtkDebugMacro(<<"GetPartSelection");
+ return PartSelection;
+}
+
+
+int vtkPV4FoamReader::GetNumberOfPartArrays()
+{
+ vtkDebugMacro(<<"GetNumberOfPartArrays");
+ return PartSelection->GetNumberOfArrays();
+}
+
+
+const char* vtkPV4FoamReader::GetPartArrayName(int index)
+{
+ vtkDebugMacro(<<"GetPartArrayName");
+ return PartSelection->GetArrayName(index);
+}
+
+
+int vtkPV4FoamReader::GetPartArrayStatus(const char* name)
+{
+ vtkDebugMacro(<<"GetPartArrayStatus");
+ return PartSelection->ArrayIsEnabled(name);
+}
+
+
+void vtkPV4FoamReader::SetPartArrayStatus(const char* name, int status)
+{
+ vtkDebugMacro(<<"SetPartArrayStatus");
+ if (status)
+ {
+ PartSelection->EnableArray(name);
+ }
+ else
+ {
+ PartSelection->DisableArray(name);
+ }
+}
+
+
+// ----------------------------------------------------------------------
+// volField selection list control
+
+vtkDataArraySelection* vtkPV4FoamReader::GetVolFieldSelection()
+{
+ vtkDebugMacro(<<"GetVolFieldSelection");
+ return VolFieldSelection;
+}
+
+
+int vtkPV4FoamReader::GetNumberOfVolFieldArrays()
+{
+ vtkDebugMacro(<<"GetNumberOfVolFieldArrays");
+ return VolFieldSelection->GetNumberOfArrays();
+}
+
+
+const char* vtkPV4FoamReader::GetVolFieldArrayName(int index)
+{
+ vtkDebugMacro(<<"GetVolFieldArrayName");
+ return VolFieldSelection->GetArrayName(index);
+}
+
+
+int vtkPV4FoamReader::GetVolFieldArrayStatus(const char* name)
+{
+ vtkDebugMacro(<<"GetVolFieldArrayStatus");
+ return VolFieldSelection->ArrayIsEnabled(name);
+}
+
+
+void vtkPV4FoamReader::SetVolFieldArrayStatus(const char* name, int status)
+{
+ vtkDebugMacro(<<"SetVolFieldArrayStatus");
+ if (status)
+ {
+ VolFieldSelection->EnableArray(name);
+ }
+ else
+ {
+ VolFieldSelection->DisableArray(name);
+ }
+}
+
+
+// ----------------------------------------------------------------------
+// pointField selection list control
+
+vtkDataArraySelection* vtkPV4FoamReader::GetPointFieldSelection()
+{
+ vtkDebugMacro(<<"GetPointFieldSelection");
+ return PointFieldSelection;
+}
+
+
+int vtkPV4FoamReader::GetNumberOfPointFieldArrays()
+{
+ vtkDebugMacro(<<"GetNumberOfPointFieldArrays");
+ return PointFieldSelection->GetNumberOfArrays();
+}
+
+
+const char* vtkPV4FoamReader::GetPointFieldArrayName(int index)
+{
+ vtkDebugMacro(<<"GetPointFieldArrayName");
+ return PointFieldSelection->GetArrayName(index);
+}
+
+
+int vtkPV4FoamReader::GetPointFieldArrayStatus(const char* name)
+{
+ vtkDebugMacro(<<"GetPointFieldArrayStatus");
+ return PointFieldSelection->ArrayIsEnabled(name);
+}
+
+
+void vtkPV4FoamReader::SetPointFieldArrayStatus(const char* name, int status)
+{
+ vtkDebugMacro(<<"SetPointFieldArrayStatus");
+ if (status)
+ {
+ PointFieldSelection->EnableArray(name);
+ }
+ else
+ {
+ PointFieldSelection->DisableArray(name);
+ }
+}
+
+
+// ----------------------------------------------------------------------
+// lagrangianField selection list control
+
+vtkDataArraySelection* vtkPV4FoamReader::GetLagrangianFieldSelection()
+{
+ vtkDebugMacro(<<"GetLagrangianFieldSelection");
+ return LagrangianFieldSelection;
+}
+
+
+int vtkPV4FoamReader::GetNumberOfLagrangianFieldArrays()
+{
+ vtkDebugMacro(<<"GetNumberOfLagrangianFieldArrays");
+ return LagrangianFieldSelection->GetNumberOfArrays();
+}
+
+
+const char* vtkPV4FoamReader::GetLagrangianFieldArrayName(int index)
+{
+ vtkDebugMacro(<<"GetLagrangianFieldArrayName");
+ return LagrangianFieldSelection->GetArrayName(index);
+}
+
+
+int vtkPV4FoamReader::GetLagrangianFieldArrayStatus(const char* name)
+{
+ vtkDebugMacro(<<"GetLagrangianFieldArrayStatus");
+ return LagrangianFieldSelection->ArrayIsEnabled(name);
+}
+
+
+void vtkPV4FoamReader::SetLagrangianFieldArrayStatus
+(
+ const char* name,
+ int status
+)
+{
+ vtkDebugMacro(<<"SetLagrangianFieldArrayStatus");
+ if (status)
+ {
+ LagrangianFieldSelection->EnableArray(name);
+ }
+ else
+ {
+ LagrangianFieldSelection->DisableArray(name);
+ }
+}
+
+
+// ----------------------------------------------------------------------
+
+void vtkPV4FoamReader::SelectionModifiedCallback
+(
+ vtkObject*,
+ unsigned long,
+ void* clientdata,
+ void*
+)
+{
+ static_cast(clientdata)->SelectionModified();
+}
+
+
+void vtkPV4FoamReader::SelectionModified()
+{
+ vtkDebugMacro(<<"SelectionModified");
+ Modified();
+}
+
+
+int vtkPV4FoamReader::FillOutputPortInformation
+(
+ int port,
+ vtkInformation* info
+)
+{
+ if (port == 0)
+ {
+ return this->Superclass::FillOutputPortInformation(port, info);
+ }
+ info->Set(vtkDataObject::DATA_TYPE_NAME(), "vtkMultiBlockDataSet");
+ return 1;
+}
+
+
+// ************************************************************************* //
diff --git a/applications/utilities/postProcessing/graphics/PV4FoamReader/PV4FoamReader/vtkPV4FoamReader.h b/applications/utilities/postProcessing/graphics/PV4FoamReader/PV4FoamReader/vtkPV4FoamReader.h
new file mode 100644
index 000000000..6dc4a2478
--- /dev/null
+++ b/applications/utilities/postProcessing/graphics/PV4FoamReader/PV4FoamReader/vtkPV4FoamReader.h
@@ -0,0 +1,212 @@
+/*=========================================================================
+
+ Program: Visualization Toolkit
+ Module: $RCSfile: vtkPV4FoamReader.h,v $
+
+ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
+ All rights reserved.
+ See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notice for more information.
+
+=========================================================================*/
+// .NAME vtkPV4FoamReader - reads a dataset in OpenFOAM format
+// .SECTION Description
+// vtkPV4FoamReader creates an multiblock dataset.
+// It uses the OpenFOAM infrastructure (fvMesh, etc) to
+// handle mesh and field data.
+
+#ifndef __vtkPV4FoamReader_h
+#define __vtkPV4FoamReader_h
+
+// Foam forward declarations
+namespace Foam
+{
+ class vtkPV4Foam;
+}
+
+// VTK includes
+#include "vtkMultiBlockDataSetAlgorithm.h"
+#include "vtkIOGeometryModule.h"
+
+// VTK forward declarations
+class vtkDataArraySelection;
+class vtkCallbackCommand;
+
+
+class VTKIOGEOMETRY_EXPORT vtkPV4FoamReader
+:
+ public vtkMultiBlockDataSetAlgorithm
+{
+public:
+ vtkTypeRevisionMacro(vtkPV4FoamReader,vtkMultiBlockDataSetAlgorithm);
+ void PrintSelf(ostream&, vtkIndent);
+
+ static vtkPV4FoamReader* New();
+
+ // Description:
+ // Get the current timestep and the timestep range.
+ vtkGetVector2Macro(TimeStepRange, int);
+
+ // Description:
+ // Set/Get the filename.
+ vtkSetStringMacro(FileName);
+ vtkGetStringMacro(FileName);
+
+ // Description:
+ // GUI update control
+ vtkSetMacro(UpdateGUI, int);
+ vtkGetMacro(UpdateGUI, int);
+
+ // Description:
+ // FOAM mesh caching control
+ vtkSetMacro(CacheMesh, int);
+ vtkGetMacro(CacheMesh, int);
+
+ // Description:
+ // FOAM extrapolate internal values onto the patches
+ vtkSetMacro(ExtrapolatePatches, int);
+ vtkGetMacro(ExtrapolatePatches, int);
+
+ // FOAM read sets control
+ vtkSetMacro(IncludeSets, int);
+ vtkGetMacro(IncludeSets, int);
+
+ // Description:
+ // FOAM read zones control
+ vtkSetMacro(IncludeZones, int);
+ vtkGetMacro(IncludeZones, int);
+
+ // Description:
+ // FOAM display patch names control
+ vtkSetMacro(ShowPatchNames, int);
+ vtkGetMacro(ShowPatchNames, int);
+
+ // Description:
+ // Get the current timestep
+ int GetTimeStep();
+
+ // Description:
+ // Parts selection list control
+ vtkDataArraySelection* GetPartSelection();
+ int GetNumberOfPartArrays();
+ int GetPartArrayStatus(const char* name);
+ void SetPartArrayStatus(const char* name, int status);
+ const char* GetPartArrayName(int index);
+
+ // Description:
+ // volField selection list control
+ vtkDataArraySelection* GetVolFieldSelection();
+ int GetNumberOfVolFieldArrays();
+ int GetVolFieldArrayStatus(const char* name);
+ void SetVolFieldArrayStatus(const char* name, int status);
+ const char* GetVolFieldArrayName(int index);
+
+ // Description:
+ // pointField selection list control
+ vtkDataArraySelection* GetPointFieldSelection();
+ int GetNumberOfPointFieldArrays();
+ int GetPointFieldArrayStatus(const char* name);
+ void SetPointFieldArrayStatus(const char* name, int status);
+ const char* GetPointFieldArrayName(int index);
+
+ // Description:
+ // lagrangianField selection list control
+ vtkDataArraySelection* GetLagrangianFieldSelection();
+ int GetNumberOfLagrangianFieldArrays();
+ int GetLagrangianFieldArrayStatus(const char* name);
+ void SetLagrangianFieldArrayStatus(const char* name, int status);
+ const char* GetLagrangianFieldArrayName(int index);
+
+ // Description:
+ // Callback registered with the SelectionObserver
+ // for all the selection lists
+ static void SelectionModifiedCallback
+ (
+ vtkObject* caller,
+ unsigned long eid,
+ void* clientdata,
+ void* calldata
+ );
+
+ void SelectionModified();
+
+
+protected:
+
+ //- Construct null
+ vtkPV4FoamReader();
+
+ //- Destructor
+ ~vtkPV4FoamReader();
+
+ //- Return information about mesh, times, etc without loading anything
+ virtual int RequestInformation
+ (
+ vtkInformation*,
+ vtkInformationVector**,
+ vtkInformationVector*
+ );
+
+ //- Get the mesh/fields for a particular time
+ //- Destructor
+ virtual int RequestData
+ (
+ vtkInformation*,
+ vtkInformationVector**,
+ vtkInformationVector*
+ );
+
+ //- Fill in additional port information
+ virtual int FillOutputPortInformation(int, vtkInformation*);
+
+ // The observer to modify this object when array selections are modified
+ vtkCallbackCommand* SelectionObserver;
+
+ char* FileName;
+
+private:
+
+ //- Disallow default bitwise copy construct
+ vtkPV4FoamReader(const vtkPV4FoamReader&);
+
+ //- Disallow default bitwise assignment
+ void operator=(const vtkPV4FoamReader&);
+
+ //- Add patch names to the view
+ void addPatchNamesToView();
+
+ //- Remove patch names from the view
+ void removePatchNamesFromView();
+
+ int TimeStepRange[2];
+ int CacheMesh;
+
+ int ExtrapolatePatches;
+ int IncludeSets;
+ int IncludeZones;
+ int ShowPatchNames;
+
+ //- Dummy variable/switch for invoke a reader update
+ int UpdateGUI;
+
+ vtkDataArraySelection* PartSelection;
+ vtkDataArraySelection* VolFieldSelection;
+ vtkDataArraySelection* PointFieldSelection;
+ vtkDataArraySelection* LagrangianFieldSelection;
+
+ //- Cached data for output port0 (experimental!)
+ vtkMultiBlockDataSet* output0_;
+
+ //BTX
+ Foam::vtkPV4Foam* foamData_;
+ //ETX
+};
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/applications/utilities/postProcessing/graphics/PV4FoamReader/vtkPV4Foam/Make/files b/applications/utilities/postProcessing/graphics/PV4FoamReader/vtkPV4Foam/Make/files
new file mode 100644
index 000000000..424748f2e
--- /dev/null
+++ b/applications/utilities/postProcessing/graphics/PV4FoamReader/vtkPV4Foam/Make/files
@@ -0,0 +1,12 @@
+vtkPV4Foam.C
+vtkPV4FoamFields.C
+vtkPV4FoamMesh.C
+vtkPV4FoamMeshLagrangian.C
+vtkPV4FoamMeshPatch.C
+vtkPV4FoamMeshSet.C
+vtkPV4FoamMeshVolume.C
+vtkPV4FoamMeshZone.C
+vtkPV4FoamUpdateInfo.C
+vtkPV4FoamUtilities.C
+
+LIB = $(FOAM_LIBBIN)/libvtkPV4Foam
diff --git a/applications/utilities/postProcessing/graphics/PV4FoamReader/vtkPV4Foam/Make/options b/applications/utilities/postProcessing/graphics/PV4FoamReader/vtkPV4Foam/Make/options
new file mode 100644
index 000000000..879a02de4
--- /dev/null
+++ b/applications/utilities/postProcessing/graphics/PV4FoamReader/vtkPV4Foam/Make/options
@@ -0,0 +1,12 @@
+EXE_INC = \
+ -I$(LIB_SRC)/finiteVolume/lnInclude \
+ -I$(LIB_SRC)/lagrangian/basic/lnInclude \
+ -I$(LIB_SRC)/meshTools/lnInclude \
+ -I$(PARAVIEW_INCLUDE_DIR) \
+ -I../PV4FoamReader
+
+LIB_LIBS = \
+ -lfiniteVolume \
+ -llagrangian \
+ -lmeshTools \
+ $(GLIBS)
diff --git a/applications/utilities/postProcessing/graphics/PV4FoamReader/vtkPV4Foam/vtkDataArrayTemplateImplicit.txx b/applications/utilities/postProcessing/graphics/PV4FoamReader/vtkPV4Foam/vtkDataArrayTemplateImplicit.txx
new file mode 100644
index 000000000..e69de29bb
diff --git a/applications/utilities/postProcessing/graphics/PV4FoamReader/vtkPV4Foam/vtkOpenFOAMTupleRemap.H b/applications/utilities/postProcessing/graphics/PV4FoamReader/vtkPV4Foam/vtkOpenFOAMTupleRemap.H
new file mode 100644
index 000000000..6d6612476
--- /dev/null
+++ b/applications/utilities/postProcessing/graphics/PV4FoamReader/vtkPV4Foam/vtkOpenFOAMTupleRemap.H
@@ -0,0 +1,72 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright held by original author
+ \\/ M anipulation |
+-------------------------------------------------------------------------------
+License
+ This file is part of OpenFOAM.
+
+ OpenFOAM is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2 of the License, or (at your
+ option) any later version.
+
+ OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with OpenFOAM; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+InClass
+ vtkPV4Foam
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef vtkOpenFOAMTupleRemap_H
+#define vtkOpenFOAMTupleRemap_H
+
+// OpenFOAM includes
+#include "StaticAssert.H"
+#include "Swap.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+template
+inline void vtkOpenFOAMTupleRemap(float vec[]);
+
+
+// a symmTensor specialization to remap OpenFOAM -> ParaView naming order
+// Qt/Core/pqScalarBarRepresentation.cxx defines this order
+// { "XX", "YY", "ZZ", "XY", "YZ", "XZ" }
+// in pqScalarBarRepresentation::getDefaultComponentLabel()
+// whereas OpenFOAM uses this order
+// { XX, XY, XZ, YY, YZ, ZZ }
+//
+// for extra safety, assert that symmTensor indeed has 6 components
+StaticAssert(Foam::symmTensor::nComponents == 6);
+
+
+// Template specialization for symmTensor
+template<>
+inline void vtkOpenFOAMTupleRemap(float vec[])
+{
+ Foam::Swap(vec[1], vec[3]); // swap XY <-> YY
+ Foam::Swap(vec[2], vec[5]); // swap XZ <-> ZZ
+}
+
+
+template
+inline void vtkOpenFOAMTupleRemap(float vec[])
+{}
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/applications/utilities/postProcessing/graphics/PV4FoamReader/vtkPV4Foam/vtkPV4Foam.C b/applications/utilities/postProcessing/graphics/PV4FoamReader/vtkPV4Foam/vtkPV4Foam.C
new file mode 100644
index 000000000..7b8b4c3b3
--- /dev/null
+++ b/applications/utilities/postProcessing/graphics/PV4FoamReader/vtkPV4Foam/vtkPV4Foam.C
@@ -0,0 +1,821 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright held by original author
+ \\/ M anipulation |
+-------------------------------------------------------------------------------
+License
+ This file is part of OpenFOAM.
+
+ OpenFOAM is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2 of the License, or (at your
+ option) any later version.
+
+ OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with OpenFOAM; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+\*---------------------------------------------------------------------------*/
+
+#include "vtkPV4Foam.H"
+#include "vtkPV4FoamReader.h"
+
+// Foam includes
+#include "fvMesh.H"
+#include "Time.H"
+#include "patchZones.H"
+
+// VTK includes
+#include "vtkDataArraySelection.h"
+#include "vtkMultiBlockDataSet.h"
+#include "vtkRenderer.h"
+#include "vtkTextActor.h"
+#include "vtkTextProperty.h"
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+defineTypeNameAndDebug(Foam::vtkPV4Foam, 0);
+
+// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
+
+#include "vtkPV4FoamAddToSelection.H"
+#include "vtkPV4FoamUpdateInfoFields.H"
+
+void Foam::vtkPV4Foam::resetCounters()
+{
+ // Reset mesh part ids and sizes
+ partInfoVolume_.reset();
+ partInfoPatches_.reset();
+ partInfoLagrangian_.reset();
+ partInfoCellZones_.reset();
+ partInfoFaceZones_.reset();
+ partInfoPointZones_.reset();
+ partInfoCellSets_.reset();
+ partInfoFaceSets_.reset();
+ partInfoPointSets_.reset();
+}
+
+
+void Foam::vtkPV4Foam::reduceMemory()
+{
+ forAll(regionPolyDecomp_, i)
+ {
+ regionPolyDecomp_[i].clear();
+ }
+
+ forAll(zonePolyDecomp_, i)
+ {
+ zonePolyDecomp_[i].clear();
+ }
+
+ forAll(csetPolyDecomp_, i)
+ {
+ csetPolyDecomp_[i].clear();
+ }
+
+ if (!reader_->GetCacheMesh())
+ {
+ delete meshPtr_;
+ meshPtr_ = NULL;
+ }
+}
+
+
+
+
+int Foam::vtkPV4Foam::setTime(int nRequest, const double requestTimes[])
+{
+ if (debug)
+ {
+ Info<< " Foam::vtkPV4Foam::setTime(";
+ for (int requestI = 0; requestI < nRequest; ++requestI)
+ {
+ if (requestI)
+ {
+ Info<< ", ";
+ }
+
+ Info<< requestTimes[requestI];
+ }
+ Info << ") - previousIndex = " << timeIndex_ << endl;
+ }
+
+ Time& runTime = dbPtr_();
+
+ // Get times list
+ instantList Times = runTime.times();
+
+ int nearestIndex = timeIndex_;
+ for (int requestI = 0; requestI < nRequest; ++requestI)
+ {
+ int index = Time::findClosestTimeIndex(Times, requestTimes[requestI]);
+ if (index >= 0 && index != timeIndex_)
+ {
+ nearestIndex = index;
+ break;
+ }
+ }
+
+ if (nearestIndex < 0)
+ {
+ nearestIndex = 0;
+ }
+
+
+ // see what has changed
+ if (timeIndex_ != nearestIndex)
+ {
+ timeIndex_ = nearestIndex;
+ runTime.setTime(Times[nearestIndex], nearestIndex);
+
+ // the fields change each time
+ fieldsChanged_ = true;
+
+ if (meshPtr_)
+ {
+ if (meshPtr_->readUpdate() != polyMesh::UNCHANGED)
+ {
+ meshChanged_ = true;
+ }
+ }
+ else
+ {
+ meshChanged_ = true;
+ }
+
+ reader_->UpdateProgress(0.05);
+
+ // this seems to be needed for catching Lagrangian fields
+ updateInfo();
+ }
+
+ if (debug)
+ {
+ Info<< " Foam::vtkPV4Foam::setTime() - selectedTime="
+ << Times[nearestIndex].name() << " index=" << timeIndex_
+ << "/" << Times.size()
+ << " meshChanged=" << Switch(meshChanged_)
+ << " fieldsChanged=" << Switch(fieldsChanged_) << endl;
+ }
+
+ return nearestIndex;
+}
+
+
+void Foam::vtkPV4Foam::updateMeshPartsStatus()
+{
+ if (debug)
+ {
+ Info<< " Foam::vtkPV4Foam::updateMeshPartsStatus" << endl;
+ }
+
+ vtkDataArraySelection* selection = reader_->GetPartSelection();
+ label nElem = selection->GetNumberOfArrays();
+
+ if (partStatus_.size() != nElem)
+ {
+ partStatus_.setSize(nElem);
+ partStatus_ = false;
+ meshChanged_ = true;
+ }
+
+ // this needs fixing if we wish to re-use the datasets
+ partDataset_.setSize(nElem);
+ partDataset_ = -1;
+
+ // Read the selected mesh parts (zones, patches ...) and add to list
+ forAll(partStatus_, partId)
+ {
+ const int setting = selection->GetArraySetting(partId);
+
+ if (partStatus_[partId] != setting)
+ {
+ partStatus_[partId] = setting;
+ meshChanged_ = true;
+ }
+
+ if (debug)
+ {
+ Info<< " part[" << partId << "] = "
+ << partStatus_[partId]
+ << " : " << selection->GetArrayName(partId) << endl;
+ }
+ }
+ if (debug)
+ {
+ Info<< " Foam::vtkPV4Foam::updateMeshPartsStatus" << endl;
+ }
+}
+
+// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
+
+Foam::vtkPV4Foam::vtkPV4Foam
+(
+ const char* const FileName,
+ vtkPV4FoamReader* reader
+)
+:
+ reader_(reader),
+ dbPtr_(NULL),
+ meshPtr_(NULL),
+ meshRegion_(polyMesh::defaultRegion),
+ meshDir_(polyMesh::meshSubDir),
+ timeIndex_(-1),
+ meshChanged_(true),
+ fieldsChanged_(true),
+ partInfoVolume_("unzoned"),
+ partInfoPatches_("patches"),
+ partInfoLagrangian_("lagrangian"),
+ partInfoCellZones_("cellZone"),
+ partInfoFaceZones_("faceZone"),
+ partInfoPointZones_("pointZone"),
+ partInfoCellSets_("cellSet"),
+ partInfoFaceSets_("faceSet"),
+ partInfoPointSets_("pointSet")
+{
+ if (debug)
+ {
+ Info<< "Foam::vtkPV4Foam::vtkPV4Foam - " << FileName << endl;
+ printMemory();
+ }
+
+ // avoid argList and get rootPath/caseName directly from the file
+ fileName fullCasePath(fileName(FileName).path());
+
+ if (!isDir(fullCasePath))
+ {
+ return;
+ }
+ if (fullCasePath == ".")
+ {
+ fullCasePath = cwd();
+ }
+
+ // Set the case as an environment variable - some BCs might use this
+ if (fullCasePath.name().find("processor", 0) == 0)
+ {
+ const fileName globalCase = fullCasePath.path();
+
+ setEnv("FOAM_CASE", globalCase, true);
+ setEnv("FOAM_CASENAME", globalCase.name(), true);
+ }
+ else
+ {
+ setEnv("FOAM_CASE", fullCasePath, true);
+ setEnv("FOAM_CASENAME", fullCasePath.name(), true);
+ }
+
+ // look for 'case{region}.OpenFOAM'
+ // could be stringent and insist the prefix match the directory name...
+ // Note: cannot use fileName::name() due to the embedded '{}'
+ string caseName(fileName(FileName).lessExt());
+ string::size_type beg = caseName.find_last_of("/{");
+ string::size_type end = caseName.find('}', beg);
+
+ if
+ (
+ beg != string::npos && caseName[beg] == '{'
+ && end != string::npos && end == caseName.size()-1
+ )
+ {
+ meshRegion_ = caseName.substr(beg+1, end-beg-1);
+
+ // some safety
+ if (!meshRegion_.size())
+ {
+ meshRegion_ = polyMesh::defaultRegion;
+ }
+
+ if (meshRegion_ != polyMesh::defaultRegion)
+ {
+ meshDir_ = meshRegion_/polyMesh::meshSubDir;
+ }
+ }
+
+ if (debug)
+ {
+ Info<< "fullCasePath=" << fullCasePath << nl
+ << "FOAM_CASE=" << getEnv("FOAM_CASE") << nl
+ << "FOAM_CASENAME=" << getEnv("FOAM_CASENAME") << nl
+ << "region=" << meshRegion_ << endl;
+ }
+
+ // Create time object
+ dbPtr_.reset
+ (
+ new Time
+ (
+ Time::controlDictName,
+ fileName(fullCasePath.path()),
+ fileName(fullCasePath.name())
+ )
+ );
+
+ dbPtr_().functionObjects().off();
+
+ updateInfo();
+}
+
+
+// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
+
+Foam::vtkPV4Foam::~vtkPV4Foam()
+{
+ if (debug)
+ {
+ Info<< " Foam::vtkPV4Foam::~vtkPV4Foam" << endl;
+ }
+
+ delete meshPtr_;
+}
+
+
+// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
+
+void Foam::vtkPV4Foam::updateInfo()
+{
+ if (debug)
+ {
+ Info<< " Foam::vtkPV4Foam::updateInfo"
+ << " [meshPtr=" << (meshPtr_ ? "set" : "NULL") << "] timeIndex="
+ << timeIndex_ << endl;
+ }
+
+ resetCounters();
+
+ vtkDataArraySelection* partSelection = reader_->GetPartSelection();
+
+ // enable 'internalMesh' on the first call
+ // or preserve the enabled selections
+ stringList enabledEntries;
+ if (!partSelection->GetNumberOfArrays() && !meshPtr_)
+ {
+ enabledEntries.setSize(1);
+ enabledEntries[0] = "internalMesh";
+ }
+ else
+ {
+ enabledEntries = getSelectedArrayEntries(partSelection);
+ }
+
+ // Clear current mesh parts list
+ partSelection->RemoveAllArrays();
+
+ // Update mesh parts list - add Lagrangian at the bottom
+ updateInfoInternalMesh();
+ updateInfoPatches();
+ updateInfoSets();
+ updateInfoZones();
+ updateInfoLagrangian();
+
+ // restore the enabled selections
+ setSelectedArrayEntries(partSelection, enabledEntries);
+
+ if (meshChanged_)
+ {
+ fieldsChanged_ = true;
+ }
+
+ // Update volume, point and lagrangian fields
+ updateInfoFields
+ (
+ reader_->GetVolFieldSelection()
+ );
+ updateInfoFields
+ (
+ reader_->GetPointFieldSelection()
+ );
+ updateInfoLagrangianFields();
+
+ if (debug)
+ {
+ Info<< " Foam::vtkPV4Foam::updateInfo" << endl;
+ }
+
+}
+
+
+void Foam::vtkPV4Foam::updateFoamMesh()
+{
+ if (debug)
+ {
+ Info<< " Foam::vtkPV4Foam::updateFoamMesh" << endl;
+ printMemory();
+ }
+
+ if (!reader_->GetCacheMesh())
+ {
+ delete meshPtr_;
+ meshPtr_ = NULL;
+ }
+
+ // Check to see if the FOAM mesh has been created
+ if (!meshPtr_)
+ {
+ if (debug)
+ {
+ Info<< "Creating Foam mesh for region " << meshRegion_
+ << " at time=" << dbPtr_().timeName()
+ << endl;
+
+ }
+
+ meshPtr_ = new fvMesh
+ (
+ IOobject
+ (
+ meshRegion_,
+ dbPtr_().timeName(),
+ dbPtr_(),
+ IOobject::MUST_READ
+ )
+ );
+
+ meshChanged_ = true;
+ }
+ else
+ {
+ if (debug)
+ {
+ Info<< "Using existing Foam mesh" << endl;
+ }
+ }
+
+ if (debug)
+ {
+ Info<< " Foam::vtkPV4Foam::updateFoamMesh" << endl;
+ printMemory();
+ }
+}
+
+
+void Foam::vtkPV4Foam::Update
+(
+ vtkMultiBlockDataSet* output,
+ vtkMultiBlockDataSet* lagrangianOutput
+)
+{
+ if (debug)
+ {
+ cout<< " Foam::vtkPV4Foam::Update - output with "
+ << output->GetNumberOfBlocks() << " and "
+ << lagrangianOutput->GetNumberOfBlocks() << " blocks\n";
+ output->Print(cout);
+ lagrangianOutput->Print(cout);
+ printMemory();
+ }
+ reader_->UpdateProgress(0.1);
+
+ // Set up mesh parts selection(s)
+ updateMeshPartsStatus();
+
+ reader_->UpdateProgress(0.15);
+
+ // Update the Foam mesh
+ updateFoamMesh();
+ reader_->UpdateProgress(0.4);
+
+ // Convert meshes - start port0 at block=0
+ int blockNo = 0;
+
+ convertMeshVolume(output, blockNo);
+ convertMeshPatches(output, blockNo);
+ reader_->UpdateProgress(0.6);
+
+ if (reader_->GetIncludeZones())
+ {
+ convertMeshCellZones(output, blockNo);
+ convertMeshFaceZones(output, blockNo);
+ convertMeshPointZones(output, blockNo);
+ reader_->UpdateProgress(0.65);
+ }
+
+ if (reader_->GetIncludeSets())
+ {
+ convertMeshCellSets(output, blockNo);
+ convertMeshFaceSets(output, blockNo);
+ convertMeshPointSets(output, blockNo);
+ reader_->UpdateProgress(0.7);
+ }
+
+#ifdef VTKPV4FOAM_DUALPORT
+ // restart port1 at block=0
+ blockNo = 0;
+#endif
+ convertMeshLagrangian(lagrangianOutput, blockNo);
+
+ reader_->UpdateProgress(0.8);
+
+ // Update fields
+ convertVolFields(output);
+ convertPointFields(output);
+ convertLagrangianFields(lagrangianOutput);
+ reader_->UpdateProgress(0.95);
+
+ meshChanged_ = fieldsChanged_ = false;
+}
+
+
+void Foam::vtkPV4Foam::CleanUp()
+{
+ // reclaim some memory
+ reduceMemory();
+ reader_->UpdateProgress(1.0);
+}
+
+
+double* Foam::vtkPV4Foam::findTimes(int& nTimeSteps)
+{
+ int nTimes = 0;
+ double* tsteps = NULL;
+
+ if (dbPtr_.valid())
+ {
+ Time& runTime = dbPtr_();
+ instantList timeLst = runTime.times();
+
+ // find the first time for which this mesh appears to exist
+ label timeI = 0;
+ for (; timeI < timeLst.size(); ++timeI)
+ {
+ const word& timeName = timeLst[timeI].name();
+
+ if
+ (
+ isFile(runTime.path()/timeName/meshDir_/"points")
+ && IOobject("points", timeName, meshDir_, runTime).headerOk()
+ )
+ {
+ break;
+ }
+ }
+
+ nTimes = timeLst.size() - timeI;
+
+ // always skip "constant" time if possible
+ if (timeI == 0 && nTimes > 1)
+ {
+ timeI = 1;
+ --nTimes;
+ }
+
+ if (nTimes)
+ {
+ tsteps = new double[nTimes];
+ for (label stepI = 0; stepI < nTimes; ++stepI, ++timeI)
+ {
+ tsteps[stepI] = timeLst[timeI].value();
+ }
+ }
+ }
+ else
+ {
+ if (debug)
+ {
+ cout<< "no valid dbPtr:\n";
+ }
+ }
+
+ // vector length returned via the parameter
+ nTimeSteps = nTimes;
+
+ return tsteps;
+}
+
+
+void Foam::vtkPV4Foam::addPatchNames(vtkRenderer* renderer)
+{
+ // Remove any patch names previously added to the renderer
+ removePatchNames(renderer);
+
+ // get the display patches, strip off any suffix
+ wordHashSet selectedPatches = getSelected
+ (
+ reader_->GetPartSelection(),
+ partInfoPatches_
+ );
+
+ if (!selectedPatches.size())
+ {
+ return;
+ }
+
+ if (debug)
+ {
+ Info<< " Foam::vtkPV4Foam::addPatchNames" << nl
+ <<"... add patches: " << selectedPatches << endl;
+ }
+
+ const polyBoundaryMesh& pbMesh = meshPtr_->boundaryMesh();
+
+ // Find the total number of zones
+ // Each zone will take the patch name
+ // Number of zones per patch ... zero zones should be skipped
+ labelList nZones(pbMesh.size(), 0);
+
+ // Per global zone number the average face centre position
+ DynamicList zoneCentre(pbMesh.size());
+
+ if (debug)
+ {
+ Info<< "... determining patch zones" << endl;
+ }
+
+ // Loop through all patches to determine zones, and centre of each zone
+ forAll(pbMesh, patchI)
+ {
+ const polyPatch& pp = pbMesh[patchI];
+
+ // Only include the patch if it is selected
+ if (!selectedPatches.found(pp.name()))
+ {
+ continue;
+ }
+
+ const labelListList& edgeFaces = pp.edgeFaces();
+ const vectorField& n = pp.faceNormals();
+
+ boolList featEdge(pp.nEdges(), false);
+
+ forAll(edgeFaces, edgeI)
+ {
+ const labelList& eFaces = edgeFaces[edgeI];
+
+ if (eFaces.size() == 1)
+ {
+ // Note: could also do ones with > 2 faces but this gives
+ // too many zones for baffles
+ featEdge[edgeI] = true;
+ }
+ else if (mag(n[eFaces[0]] & n[eFaces[1]]) < 0.5)
+ {
+ featEdge[edgeI] = true;
+ }
+ }
+
+ // Do topological analysis of patch, find disconnected regions
+ patchZones pZones(pp, featEdge);
+
+ nZones[patchI] = pZones.nZones();
+
+ labelList zoneNFaces(pZones.nZones(), 0);
+
+ // Save start of information for current patch
+ label patchStart = zoneCentre.size();
+
+ // Create storage for additional zone centres
+ forAll(zoneNFaces, zoneI)
+ {
+ zoneCentre.append(vector::zero);
+ }
+
+ // Do averaging per individual zone
+ forAll(pp, faceI)
+ {
+ label zoneI = pZones[faceI];
+ zoneCentre[patchStart+zoneI] += pp[faceI].centre(pp.points());
+ zoneNFaces[zoneI]++;
+ }
+
+ for (label i=0; i= MAXPATCHZONES)
+ {
+ increment = nZones[patchI]/MAXPATCHZONES;
+ }
+
+ for (label i = 0; i < nDisplayZones; i++)
+ {
+ if (debug)
+ {
+ Info<< "patch name = " << pp.name() << nl
+ << "anchor = " << zoneCentre[globalZoneI] << nl
+ << "globalZoneI = " << globalZoneI << endl;
+ }
+
+ vtkTextActor* txt = vtkTextActor::New();
+
+ txt->SetInput(pp.name().c_str());
+
+ // Set text properties
+ vtkTextProperty* tprop = txt->GetTextProperty();
+ tprop->SetFontFamilyToArial();
+ tprop->BoldOff();
+ tprop->ShadowOff();
+ tprop->SetLineSpacing(1.0);
+ tprop->SetFontSize(12);
+ tprop->SetColor(1.0, 0.0, 0.0);
+ tprop->SetJustificationToCentered();
+
+ // Set text to use 3-D world co-ordinates
+ txt->GetPositionCoordinate()->SetCoordinateSystemToWorld();
+
+ txt->GetPositionCoordinate()->SetValue
+ (
+ zoneCentre[globalZoneI].x(),
+ zoneCentre[globalZoneI].y(),
+ zoneCentre[globalZoneI].z()
+ );
+
+ // Add text to each renderer
+ renderer->AddViewProp(txt);
+
+ // Maintain a list of text labels added so that they can be
+ // removed later
+ patchTextActorsPtrs_[displayZoneI] = txt;
+
+ globalZoneI += increment;
+ displayZoneI++;
+ }
+ }
+
+ // Resize the patch names list to the actual number of patch names added
+ patchTextActorsPtrs_.setSize(displayZoneI);
+
+ if (debug)
+ {
+ Info<< " Foam::vtkPV4Foam::addPatchNames" << endl;
+ }
+}
+
+
+void Foam::vtkPV4Foam::removePatchNames(vtkRenderer* renderer)
+{
+ forAll(patchTextActorsPtrs_, patchI)
+ {
+ renderer->RemoveViewProp(patchTextActorsPtrs_[patchI]);
+ patchTextActorsPtrs_[patchI]->Delete();
+ }
+ patchTextActorsPtrs_.clear();
+}
+
+
+void Foam::vtkPV4Foam::PrintSelf(ostream& os, vtkIndent indent) const
+{
+ os << indent << "Number of nodes: "
+ << (meshPtr_ ? meshPtr_->nPoints() : 0) << "\n";
+
+ os << indent << "Number of cells: "
+ << (meshPtr_ ? meshPtr_->nCells() : 0) << "\n";
+
+ os << indent << "Number of available time steps: "
+ << (dbPtr_.valid() ? dbPtr_().times().size() : 0) << endl;
+
+ os << indent << "mesh region: " << meshRegion_ << "\n";
+}
+
+// ************************************************************************* //
diff --git a/applications/utilities/postProcessing/graphics/PV4FoamReader/vtkPV4Foam/vtkPV4Foam.H b/applications/utilities/postProcessing/graphics/PV4FoamReader/vtkPV4Foam/vtkPV4Foam.H
new file mode 100644
index 000000000..d17049e49
--- /dev/null
+++ b/applications/utilities/postProcessing/graphics/PV4FoamReader/vtkPV4Foam/vtkPV4Foam.H
@@ -0,0 +1,758 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright held by original author
+ \\/ M anipulation |
+-------------------------------------------------------------------------------
+License
+ This file is part of OpenFOAM.
+
+ OpenFOAM is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2 of the License, or (at your
+ option) any later version.
+
+ OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with OpenFOAM; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Class
+ Foam::vtkPV4Foam
+
+Description
+ Provides a reader interface for OpenFOAM to VTK interaction.
+
+SourceFiles
+ vtkPV4Foam.C
+ vtkPV4Foam.H
+ vtkPV4FoamI.H
+ vtkPV4FoamFields.C
+ vtkPV4FoamMesh.C
+ vtkPV4FoamMeshLagrangian.C
+ vtkPV4FoamMeshPatch.C
+ vtkPV4FoamMeshSet.C
+ vtkPV4FoamMeshVolume.C
+ vtkPV4FoamMeshZone.C
+ vtkPV4FoamFaceField.H
+ vtkPV4FoamLagrangianFields.H
+ vtkPV4FoamPatchField.H
+ vtkPV4FoamPointFields.H
+ vtkPV4FoamPoints.H
+ vtkPV4FoamUpdateInfo.C
+ vtkPV4FoamUpdateInfoFields.H
+ vtkPV4FoamUtilities.C
+ vtkPV4FoamVolFields.H
+ vtkPV4FoamAddToSelection.H
+
+ // Needed by VTK:
+ vtkDataArrayTemplateImplicit.txx
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef vtkPV4Foam_H
+#define vtkPV4Foam_H
+
+// do not include legacy strstream headers
+#ifndef VTK_EXCLUDE_STRSTREAM_HEADERS
+# define VTK_EXCLUDE_STRSTREAM_HEADERS
+#endif
+
+#include "className.H"
+#include "fileName.H"
+#include "stringList.H"
+#include "wordList.H"
+#include "primitivePatch.H"
+#include "PrimitivePatchInterpolation.H"
+#include "volPointInterpolation.H"
+
+#undef VTKPV4FOAM_DUALPORT
+
+// * * * * * * * * * * * * * Forward Declarations * * * * * * * * * * * * * //
+
+class vtkDataArraySelection;
+class vtkDataSet;
+class vtkPoints;
+class vtkPV4FoamReader;
+class vtkRenderer;
+class vtkTextActor;
+class vtkMultiBlockDataSet;
+class vtkPolyData;
+class vtkUnstructuredGrid;
+class vtkIndent;
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+// Foam class forward declarations
+class argList;
+class Time;
+class fvMesh;
+class IOobjectList;
+class polyPatch;
+class faceSet;
+class pointSet;
+
+template class IOField;
+template class List;
+
+/*---------------------------------------------------------------------------*\
+ Class vtkPV4Foam Declaration
+\*---------------------------------------------------------------------------*/
+
+class vtkPV4Foam
+{
+ // Private classes
+
+ //- Bookkeeping for GUI checklists and the multi-block organization
+ class partInfo
+ {
+ const char *name_;
+ int block_;
+ int start_;
+ int size_;
+
+ public:
+
+ partInfo(const char *name, const int blockNo=0)
+ :
+ name_(name),
+ block_(blockNo),
+ start_(-1),
+ size_(0)
+ {}
+
+ //- Return the block holding these datasets
+ int block() const
+ {
+ return block_;
+ }
+
+ //- Assign block number, return previous value
+ int block(int blockNo)
+ {
+ int prev = block_;
+ block_ = blockNo;
+ return prev;
+ }
+
+ const char* name() const
+ {
+ return name_;
+ }
+
+ int start() const
+ {
+ return start_;
+ }
+
+ int end() const
+ {
+ return start_ + size_;
+ }
+
+ int size() const
+ {
+ return size_;
+ }
+
+ bool empty() const
+ {
+ return !size_;
+ }
+
+ void reset()
+ {
+ start_ = -1;
+ size_ = 0;
+ }
+
+ //- Assign new start and reset the size
+ void operator=(const int i)
+ {
+ start_ = i;
+ size_ = 0;
+ }
+
+ //- Increment the size
+ void operator+=(const int n)
+ {
+ size_ += n;
+ }
+ };
+
+ //- bookkeeping for polyhedral cell decomposition
+ // hide in extra pointMap (cellSet/cellZone) for now
+ class polyDecomp
+ {
+ labelList superCells_;
+ labelList addPointCellLabels_;
+ labelList pointMap_;
+
+ public:
+
+ polyDecomp()
+ {}
+
+ //- Label of original cell for decomposed cells
+ labelList& superCells()
+ {
+ return superCells_;
+ }
+
+ //- Label of original cell for decomposed cells
+ const labelList& superCells() const
+ {
+ return superCells_;
+ }
+
+ //- Cell-centre labels for additional points of decomposed cells
+ labelList& addPointCellLabels()
+ {
+ return addPointCellLabels_;
+ }
+
+ //- Cell-centre labels for additional points of decomposed cells
+ const labelList& addPointCellLabels() const
+ {
+ return addPointCellLabels_;
+ }
+
+ //- Point labels for subsetted meshes
+ labelList& pointMap()
+ {
+ return pointMap_;
+ }
+
+ //- Point labels for subsetted meshes
+ const labelList& pointMap() const
+ {
+ return pointMap_;
+ }
+
+
+ //- Clear
+ void clear()
+ {
+ superCells_.clear();
+ addPointCellLabels_.clear();
+ pointMap_.clear();
+ }
+ };
+
+
+ // Private Data
+
+ //- Access to the controlling vtkPV4FoamReader
+ vtkPV4FoamReader* reader_;
+
+ //- Foam time control
+ autoPtr