diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/Allwmake b/applications/utilities/postProcessing/graphics/PVFoamReader/Allwmake
new file mode 100755
index 0000000000..b1106aa608
--- /dev/null
+++ b/applications/utilities/postProcessing/graphics/PVFoamReader/Allwmake
@@ -0,0 +1,21 @@
+#!/bin/sh
+cd ${0%/*} || exit 1 # run from this directory
+set -x
+
+if [ -d "$ParaView_DIR" -a -r "$ParaView_DIR" ]
+then
+ case "$ParaView_VERSION" in
+ 2*)
+ wmake libso vtkFoam
+ (
+ cd PVFoamReader
+ mkdir -p Make/$WM_OPTIONS > /dev/null 2>&1
+ cd Make/$WM_OPTIONS
+ cmake ../..
+ make
+ )
+ ;;
+ esac
+fi
+
+# ----------------------------------------------------------------- end-of-file
diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/CMakeLists.txt b/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/CMakeLists.txt
new file mode 100644
index 0000000000..1c88efbbff
--- /dev/null
+++ b/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/CMakeLists.txt
@@ -0,0 +1,79 @@
+# Set the project/library name here. Classes should be declared as
+# "class VTK_FoamReader_EXPORT vtkFoo", where PVFoamReader is the name of the
+# project set here.
+PROJECT(PVFoamReader)
+
+# Set your list of sources here. Do not change the name of the
+# PVFoamReader_SRCS variable.
+SET(PVFoamReader_SRCS
+ vtkFoamReader.cxx
+ vtkFoamData.cxx
+)
+
+# List the kits from VTK that are needed by this project. Do not
+# change the name of the PVFoamReader_LIBS variable.
+SET(PVFoamReader_LIBS
+ vtkGraphics
+)
+
+INCLUDE_DIRECTORIES(
+ $ENV{WM_PROJECT_DIR}/src/OpenFOAM/lnInclude
+ $ENV{WM_PROJECT_DIR}/src/finiteVolume/lnInclude
+ $ENV{ParaView_INST_DIR}/include
+ ../vtkFoam/lnInclude
+)
+ADD_DEFINITIONS(-DWM_$ENV{WM_PRECISION_OPTION})
+
+#-----------------------------------------------------------------------------
+# Most users should not need to change anything below this line.
+
+# Need to include class headers and the configuration header.
+INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR})
+INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR})
+
+# Import ParaView build settings.
+FIND_PACKAGE(ParaView)
+IF(NOT ParaView_FOUND)
+ MESSAGE(FATAL_ERROR "ParaView is required. Set ParaView_DIR.")
+ENDIF(NOT ParaView_FOUND)
+IF(NOT PARAVIEW_BUILD_SHARED_LIBS)
+ MESSAGE(FATAL_ERROR "ParaView must be built with BUILD_SHARED_LIBS ON.")
+ENDIF(NOT PARAVIEW_BUILD_SHARED_LIBS)
+INCLUDE(${PARAVIEW_USE_FILE})
+
+# Configure output directories.
+SET (LIBRARY_OUTPUT_PATH $ENV{FOAM_LIBBIN} CACHE INTERNAL
+ "Single output directory for building all libraries.")
+SET (EXECUTABLE_OUTPUT_PATH $ENV{FOAM_APPBIN} CACHE INTERNAL
+ "Single output directory for building all executables.")
+
+# Create the configuration header.
+CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/PVFoamReaderConfigure.h.in
+ ${PROJECT_BINARY_DIR}/vtk${PROJECT_NAME}Configure.h
+ @ONLY IMMEDIATE)
+
+# Must be defined before ADD_LIBRARY for cmake version 2.3.4-20060317
+LINK_DIRECTORIES($ENV{FOAM_LIBBIN})
+LINK_DIRECTORIES($ENV{FOAM_USER_LIBBIN})
+
+# Create vtk client/server wrappers for the classes.
+VTK_WRAP_ClientServer(${PROJECT_NAME} PVFoamReaderCS_SRCS "${PVFoamReader_SRCS}")
+
+# Build the package as a plugin for ParaView.
+ADD_LIBRARY(${PROJECT_NAME} MODULE ${PVFoamReader_SRCS} ${PVFoamReaderCS_SRCS})
+LINK_DIRECTORIES($ENV{ParaView_INST_DIR}/lib)
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} vtkClientServer)
+FOREACH(c ${PVFoamReader_LIBS})
+ TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${c}CS)
+ENDFOREACH(c)
+
+# Place the package configuration file into the build tree.
+CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/PVFoamReader.xml.in
+ ${PROJECT_BINARY_DIR}/../${PROJECT_NAME}.xml @ONLY IMMEDIATE)
+
+# Place the package configuration file into the build tree.
+CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/PVFoamReader.pvsm.in
+ ${PROJECT_BINARY_DIR}/../${PROJECT_NAME}.pvsm @ONLY IMMEDIATE)
+
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} OpenFOAM finiteVolume vtkFoam)
+#-----------------------------------------------------------------------------
diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/Make/PVFoamReader.pvsm b/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/Make/PVFoamReader.pvsm
new file mode 100644
index 0000000000..e3a097219e
--- /dev/null
+++ b/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/Make/PVFoamReader.pvsm
@@ -0,0 +1,154 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/Make/PVFoamReader.xml b/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/Make/PVFoamReader.xml
new file mode 100644
index 0000000000..91e00b78d6
--- /dev/null
+++ b/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/Make/PVFoamReader.xml
@@ -0,0 +1,71 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ParaView Foam reader module
+
+
+
+
diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/PVFoamReader.pvsm.in b/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/PVFoamReader.pvsm.in
new file mode 100644
index 0000000000..e3a097219e
--- /dev/null
+++ b/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/PVFoamReader.pvsm.in
@@ -0,0 +1,154 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/PVFoamReader.xml.in b/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/PVFoamReader.xml.in
new file mode 100644
index 0000000000..5eb2a4a8e8
--- /dev/null
+++ b/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/PVFoamReader.xml.in
@@ -0,0 +1,71 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ParaView Foam reader module
+
+
+
+
diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/PVFoamReaderConfigure.h.in b/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/PVFoamReaderConfigure.h.in
new file mode 100644
index 0000000000..aae4a079a2
--- /dev/null
+++ b/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/PVFoamReaderConfigure.h.in
@@ -0,0 +1,18 @@
+/*=========================================================================
+This source has no copyright. It is intended to be copied by users
+wishing to create their own ParaView plugin classes locally.
+=========================================================================*/
+#ifndef __vtk@PROJECT_NAME@_h
+#define __vtk@PROJECT_NAME@_h
+
+#if defined(_WIN32)
+# if defined(@PROJECT_NAME@_EXPORTS)
+# define VTK_@PROJECT_NAME@_EXPORT __declspec(dllexport)
+# else
+# define VTK_@PROJECT_NAME@_EXPORT __declspec(dllimport)
+# endif
+#else
+# define VTK_@PROJECT_NAME@_EXPORT
+#endif
+
+#endif
diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/vtkFoamData.cxx b/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/vtkFoamData.cxx
new file mode 100644
index 0000000000..4f89b6e25d
--- /dev/null
+++ b/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/vtkFoamData.cxx
@@ -0,0 +1,49 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
+ \\/ 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
+
+Description
+
+\*---------------------------------------------------------------------------*/
+
+#include
+
+#include "vtkFoamData.h"
+#include "vtkObjectFactory.h"
+
+vtkCxxRevisionMacro(vtkFoamData, "$Revision: 1.20 $");
+vtkStandardNewMacro(vtkFoamData);
+
+// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
+
+vtkFoamData::vtkFoamData()
+{}
+
+
+// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
+
+vtkFoamData::~vtkFoamData()
+{}
+
+
+// ************************************************************************* //
diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/vtkFoamData.h b/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/vtkFoamData.h
new file mode 100644
index 0000000000..ebb0a7ad81
--- /dev/null
+++ b/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/vtkFoamData.h
@@ -0,0 +1,70 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
+ \\/ 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
+ vtkFoamData
+
+Description
+
+SourceFiles
+ vtkFoamData.cxx
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef vtkFoamData_h
+#define vtkFoamData_h
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#include "vtkDataSetSource.h"
+
+/*---------------------------------------------------------------------------*\
+ Class vtkFoamData Declaration
+\*---------------------------------------------------------------------------*/
+
+class VTK_IO_EXPORT vtkFoamData
+:
+ public vtkDataSetSource
+{
+
+public:
+
+ static vtkFoamData *New();
+ vtkTypeRevisionMacro(vtkFoamData,vtkDataSetSource);
+
+ vtkFoamData();
+ ~vtkFoamData();
+
+ void SetNthOutput(int num, vtkDataObject *output)
+ {
+ vtkDataSetSource::SetNthOutput(num, output);
+ }
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/vtkFoamReader.cxx b/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/vtkFoamReader.cxx
new file mode 100644
index 0000000000..d977104ce2
--- /dev/null
+++ b/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/vtkFoamReader.cxx
@@ -0,0 +1,411 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
+ \\/ 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
+
+Description
+
+\*---------------------------------------------------------------------------*/
+
+#include
+
+#include "vtkFoamReader.h"
+
+#include "vtkCallbackCommand.h"
+#include "vtkDataArraySelection.h"
+#include "vtkDataArrayCollection.h"
+#include "vtkObjectFactory.h"
+#include "vtkDataSet.h"
+#include "vtkErrorCode.h"
+#include "vtkUnstructuredGrid.h"
+
+#include "vtkFoam.H"
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+vtkCxxRevisionMacro(vtkFoamReader, "$Revision: 1.20 $");
+vtkStandardNewMacro(vtkFoamReader);
+
+// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
+
+vtkFoamReader::vtkFoamReader()
+{
+ StoredOutputs = NULL;
+
+ FileName = NULL;
+ foamData_ = NULL;
+
+ CacheMesh = 0;
+
+ UpdateGUI = 1;
+ UpdateGUIOld = 1;
+ TimeStep = 0;
+ TimeStepRange[0] = 0;
+ TimeStepRange[1] = 0;
+
+ TimeStepLimits[0] = 2;
+ TimeStepLimits[1] = 5;
+
+ TimeSelection = vtkDataArraySelection::New();
+ RegionSelection = vtkDataArraySelection::New();
+ VolFieldSelection = vtkDataArraySelection::New();
+ PointFieldSelection = vtkDataArraySelection::New();
+
+ // Setup the selection callback to modify this object when an array
+ // selection is changed.
+ SelectionObserver = vtkCallbackCommand::New();
+ SelectionObserver->SetCallback(&vtkFoamReader::SelectionModifiedCallback);
+ SelectionObserver->SetClientData(this);
+
+ TimeSelection->AddObserver
+ (
+ vtkCommand::ModifiedEvent,
+ this->SelectionObserver
+ );
+ RegionSelection->AddObserver
+ (
+ vtkCommand::ModifiedEvent,
+ this->SelectionObserver
+ );
+ VolFieldSelection->AddObserver
+ (
+ vtkCommand::ModifiedEvent,
+ this->SelectionObserver
+ );
+ PointFieldSelection->AddObserver
+ (
+ vtkCommand::ModifiedEvent,
+ this->SelectionObserver
+ );
+
+ // This is needed by ParaView 2.?.?
+ this->SetNumberOfOutputPorts(0);
+}
+
+
+// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
+
+vtkFoamReader::~vtkFoamReader()
+{
+ if (foamData_)
+ {
+ delete foamData_;
+ }
+
+ if (StoredOutputs)
+ {
+ StoredOutputs->Delete();
+ }
+
+ if (FileName)
+ {
+ delete [] FileName;
+ }
+
+ TimeSelection->RemoveObserver(this->SelectionObserver);
+ RegionSelection->RemoveObserver(this->SelectionObserver);
+ VolFieldSelection->RemoveObserver(this->SelectionObserver);
+ PointFieldSelection->RemoveObserver(this->SelectionObserver);
+ SelectionObserver->Delete();
+
+ TimeSelection->Delete();
+ RegionSelection->Delete();
+ VolFieldSelection->Delete();
+ PointFieldSelection->Delete();
+}
+
+
+// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
+
+void vtkFoamReader::ExecuteInformation()
+{
+ if (!foamData_)
+ {
+ vtkDebugMacro( << "Reading Foam case" << FileName);
+ foamData_ = new Foam::vtkFoam(FileName, this);
+ }
+ else
+ {
+ foamData_->UpdateInformation();
+ }
+
+ vtkDebugMacro( << "end of ExecuteInformation\n");
+}
+
+
+void vtkFoamReader::Execute()
+{
+ if (!StoredOutputs)
+ {
+ foamData_->Update();
+
+ StoredOutputs = vtkFoamData::New();
+
+ for (int i = 0; i < GetNumberOfOutputs(); i++)
+ {
+ vtkDataObject* tmp = GetOutput(i);
+ vtkDataObject* output = tmp->NewInstance();
+ output->ShallowCopy(tmp);
+ StoredOutputs->SetNthOutput(i, output);
+ output->Delete();
+ }
+ }
+ else
+ {
+ for (int i = 0; i < GetNumberOfOutputs(); i++)
+ {
+ vtkDataObject* output = GetOutput(i);
+ int tempExtent[6];
+ output->GetUpdateExtent(tempExtent);
+ output->ShallowCopy(StoredOutputs->GetOutput(i));
+ output->SetUpdateExtent(tempExtent);
+ }
+
+ if (UpdateGUIOld == GetUpdateGUI())
+ {
+ foamData_->Update();
+
+ for (int i = 0; i < GetNumberOfOutputs(); i++)
+ {
+ vtkDataObject* tmp = GetOutput(i);
+ vtkDataObject* output = tmp->NewInstance();
+ output->ShallowCopy(tmp);
+ StoredOutputs->SetNthOutput(i, output);
+ output->Delete();
+ }
+ }
+ }
+
+ UpdateGUIOld = GetUpdateGUI();
+}
+
+
+void vtkFoamReader::SetFileName(const char *name)
+{
+ if (name && !FileName || (FileName && !strcmp(FileName,name)))
+ {
+ if (!FileName)
+ {
+ FileName = new char[strlen(name) + 1];
+ strcpy(FileName, name);
+ }
+ }
+ else
+ {
+ vtkErrorMacro("Changing case is not currently supported.\nPlease delete reader and create a new one for the new case.");
+ return;
+ }
+
+ /*
+ if ( FileName && name && (!strcmp(FileName,name)))
+ {
+ return;
+ }
+
+ if (!name && !FileName)
+ {
+ return;
+ }
+
+ if (FileName)
+ {
+ delete [] FileName;
+ }
+
+ FileName = new char[strlen(name) + 1];
+ strcpy(FileName, name);
+
+ if (foamData_)
+ {
+ delete foamData_;
+ foamData_ = NULL;
+
+ if (StoredOutputs)
+ {
+ StoredOutputs->Delete();
+ StoredOutputs = NULL;
+ }
+ }
+
+ Modified();
+ */
+}
+
+
+void vtkFoamReader::PrintSelf(ostream& os, vtkIndent indent)
+{
+ Superclass::PrintSelf(os,indent);
+
+ os << indent << "File Name: "
+ << (FileName ? FileName : "(none)") << "\n";
+}
+
+
+vtkDataArraySelection* vtkFoamReader::GetTimeSelection()
+{
+ return TimeSelection;
+}
+
+int vtkFoamReader::GetNumberOfTimeArrays()
+{
+ return TimeSelection->GetNumberOfArrays();
+}
+
+const char* vtkFoamReader::GetTimeArrayName(int index)
+{
+ return TimeSelection->GetArrayName(index);
+}
+
+int vtkFoamReader::GetTimeArrayStatus(const char* name)
+{
+ return TimeSelection->ArrayIsEnabled(name);
+}
+
+void vtkFoamReader::SetTimeArrayStatus(const char* name, int status)
+{
+ if(status)
+ {
+ TimeSelection->EnableArray(name);
+ }
+ else
+ {
+ TimeSelection->DisableArray(name);
+ }
+}
+
+vtkDataArraySelection* vtkFoamReader::GetRegionSelection()
+{
+ return RegionSelection;
+}
+
+int vtkFoamReader::GetNumberOfRegionArrays()
+{
+ return RegionSelection->GetNumberOfArrays();
+}
+
+const char* vtkFoamReader::GetRegionArrayName(int index)
+{
+ return RegionSelection->GetArrayName(index);
+}
+
+int vtkFoamReader::GetRegionArrayStatus(const char* name)
+{
+ return RegionSelection->ArrayIsEnabled(name);
+}
+
+void vtkFoamReader::SetRegionArrayStatus(const char* name, int status)
+{
+ if(status)
+ {
+ RegionSelection->EnableArray(name);
+ }
+ else
+ {
+ RegionSelection->DisableArray(name);
+ }
+}
+
+
+vtkDataArraySelection* vtkFoamReader::GetVolFieldSelection()
+{
+ return VolFieldSelection;
+}
+
+int vtkFoamReader::GetNumberOfVolFieldArrays()
+{
+ return VolFieldSelection->GetNumberOfArrays();
+}
+
+const char* vtkFoamReader::GetVolFieldArrayName(int index)
+{
+ return VolFieldSelection->GetArrayName(index);
+}
+
+int vtkFoamReader::GetVolFieldArrayStatus(const char* name)
+{
+ return VolFieldSelection->ArrayIsEnabled(name);
+}
+
+void vtkFoamReader::SetVolFieldArrayStatus(const char* name, int status)
+{
+ if(status)
+ {
+ VolFieldSelection->EnableArray(name);
+ }
+ else
+ {
+ VolFieldSelection->DisableArray(name);
+ }
+}
+
+
+vtkDataArraySelection* vtkFoamReader::GetPointFieldSelection()
+{
+ return PointFieldSelection;
+}
+
+int vtkFoamReader::GetNumberOfPointFieldArrays()
+{
+ return PointFieldSelection->GetNumberOfArrays();
+}
+
+const char* vtkFoamReader::GetPointFieldArrayName(int index)
+{
+ return PointFieldSelection->GetArrayName(index);
+}
+
+int vtkFoamReader::GetPointFieldArrayStatus(const char* name)
+{
+ return PointFieldSelection->ArrayIsEnabled(name);
+}
+
+void vtkFoamReader::SetPointFieldArrayStatus(const char* name, int status)
+{
+ if(status)
+ {
+ PointFieldSelection->EnableArray(name);
+ }
+ else
+ {
+ PointFieldSelection->DisableArray(name);
+ }
+}
+
+
+void vtkFoamReader::SelectionModifiedCallback
+(
+ vtkObject*,
+ unsigned long,
+ void* clientdata,
+ void*
+)
+{
+ static_cast(clientdata)->SelectionModified();
+}
+
+void vtkFoamReader::SelectionModified()
+{
+ Modified();
+}
+
+
+// ************************************************************************* //
diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/vtkFoamReader.h b/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/vtkFoamReader.h
new file mode 100644
index 0000000000..023c064086
--- /dev/null
+++ b/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/vtkFoamReader.h
@@ -0,0 +1,200 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
+ \\/ 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
+ vtkFoamReader
+
+Description
+
+SourceFiles
+ vtkFoamReader.cxx
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef vtkFoamReader_h
+#define vtkFoamReader_h
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#include "vtkDataSetSource.h"
+#include "vtkFoamData.h"
+
+// * * * * * * * * * * * * * Forward Declarations * * * * * * * * * * * * * //
+
+namespace Foam
+{
+ class vtkFoam;
+}
+
+class vtkPoints;
+class vtkDataArraySelection;
+class vtkDataArrayCollection;
+class vtkCallbackCommand;
+
+/*---------------------------------------------------------------------------*\
+ Class vtkFoamReader Declaration
+\*---------------------------------------------------------------------------*/
+
+class VTK_IO_EXPORT vtkFoamReader
+:
+ public vtkDataSetSource
+{
+
+public:
+
+ //- Standard VTK class creation function
+ static vtkFoamReader *New();
+
+ //- Standard VTK class type and revision declaration macro
+ vtkTypeRevisionMacro(vtkFoamReader,vtkDataSetSource);
+
+ //- Standard VTK class print function
+ void PrintSelf(ostream& os, vtkIndent indent);
+
+ // File name of FOAM datafile to read
+ void SetFileName(const char *);
+ //vtkSetStringMacro(FileName);
+ vtkGetStringMacro(FileName);
+
+ // GUI update control
+ vtkSetMacro(UpdateGUI, int);
+ vtkGetMacro(UpdateGUI, int);
+
+ // FOAM mesh caching control
+ vtkSetMacro(CacheMesh, int);
+ vtkGetMacro(CacheMesh, int);
+
+ // Time-step slider control
+ vtkSetMacro(TimeStep, int);
+ vtkGetMacro(TimeStep, int);
+ vtkSetVector2Macro(TimeStepRange, int);
+ vtkGetVector2Macro(TimeStepRange, int);
+
+ // Control of the upper and lower limits on the number of times
+ // displayed in the selection list
+ vtkSetVector2Macro(TimeStepLimits, int);
+ vtkGetVector2Macro(TimeStepLimits, int);
+
+ // Time selection list control
+ vtkDataArraySelection* GetTimeSelection();
+ int GetNumberOfTimeArrays();
+ const char* GetTimeArrayName(int index);
+ int GetTimeArrayStatus(const char* name);
+ void SetTimeArrayStatus(const char* name, int status);
+
+ // Region selection list control
+ vtkDataArraySelection* GetRegionSelection();
+ int GetNumberOfRegionArrays();
+ const char* GetRegionArrayName(int index);
+ int GetRegionArrayStatus(const char* name);
+ void SetRegionArrayStatus(const char* name, int status);
+
+ // volField selection list control
+ vtkDataArraySelection* GetVolFieldSelection();
+ int GetNumberOfVolFieldArrays();
+ const char* GetVolFieldArrayName(int index);
+ int GetVolFieldArrayStatus(const char* name);
+ void SetVolFieldArrayStatus(const char* name, int status);
+
+ // pointField selection list control
+ vtkDataArraySelection* GetPointFieldSelection();
+ int GetNumberOfPointFieldArrays();
+ const char* GetPointFieldArrayName(int index);
+ int GetPointFieldArrayStatus(const char* name);
+ void SetPointFieldArrayStatus(const char* name, int status);
+
+ // SetNthOutput provided so that vtkFoam can access it
+ void SetNthOutput(int num, vtkDataObject *output)
+ {
+ vtkDataSetSource::SetNthOutput(num, output);
+ }
+
+ // Standard VTK ExecuteInformation function overriding the base-class.
+ // Called by ParaView before GUI is displayed.
+ virtual void ExecuteInformation();
+
+ // 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:
+
+ vtkFoamReader();
+ ~vtkFoamReader();
+
+ // Standard VTK execute function overriding the base-class.
+ // Called by ParaView when Accept is pressed.
+ void Execute();
+
+ // Cache for the outputs. These are stored before the end of Execute()
+ // and re-instated at the beginning because the Outputs would disappear
+ // otherwise.
+ vtkFoamData* StoredOutputs;
+
+ // FOAM file name (*.foam)
+ char *FileName;
+
+ //BTX
+ Foam::vtkFoam* foamData_;
+ //ETX
+
+ int CacheMesh;
+
+ int UpdateGUI;
+ int UpdateGUIOld;
+ int TimeStep;
+ int TimeStepRange[2];
+
+ int TimeStepLimits[2];
+
+ vtkDataArraySelection* TimeSelection;
+ vtkDataArraySelection* RegionSelection;
+ vtkDataArraySelection* VolFieldSelection;
+ vtkDataArraySelection* PointFieldSelection;
+
+ // The observer to modify this object when the array selections are modified
+ vtkCallbackCommand* SelectionObserver;
+
+
+private:
+
+ vtkFoamReader(const vtkFoamReader&); // Not implemented.
+ void operator=(const vtkFoamReader&); // Not implemented.
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/vtkPVFoamSelectTimeSet.cxx b/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/vtkPVFoamSelectTimeSet.cxx
new file mode 100644
index 0000000000..fd948578da
--- /dev/null
+++ b/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/vtkPVFoamSelectTimeSet.cxx
@@ -0,0 +1,531 @@
+/*=========================================================================
+
+ Program: ParaView
+ Module: $RCSfile: vtkPVFoamSelectTimeSet.cxx,v $
+
+ Copyright (c) Kitware, Inc.
+ All rights reserved.
+ See Copyright.txt or http://www.paraview.org/HTML/Copyright.html 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 "vtkPVFoamSelectTimeSet.h"
+
+#include "vtkDataArrayCollection.h"
+#include "vtkFloatArray.h"
+#include "vtkKWFrame.h"
+#include "vtkKWLabel.h"
+#include "vtkKWLabeledFrame.h"
+#include "vtkKWMenu.h"
+#include "vtkObjectFactory.h"
+#include "vtkPVAnimationInterfaceEntry.h"
+#include "vtkPVApplication.h"
+#include "vtkPVProcessModule.h"
+#include "vtkPVScalarListWidgetProperty.h"
+#include "vtkPVSource.h"
+#include "vtkPVXMLElement.h"
+
+#include
+
+//-----------------------------------------------------------------------------
+vtkStandardNewMacro(vtkPVFoamSelectTimeSet);
+vtkCxxRevisionMacro(vtkPVFoamSelectTimeSet, "$Revision: 1.39 $");
+
+//-----------------------------------------------------------------------------
+int vtkDataArrayCollectionCommand(ClientData cd, Tcl_Interp *interp,
+ int argc, char *argv[]);
+
+//-----------------------------------------------------------------------------
+vtkPVFoamSelectTimeSet::vtkPVFoamSelectTimeSet()
+{
+ this->LabeledFrame = vtkKWLabeledFrame::New();
+ this->LabeledFrame->SetParent(this);
+
+ this->TimeLabel = vtkKWLabel::New();
+ this->TimeLabel->SetParent(this->LabeledFrame->GetFrame());
+
+ this->TreeFrame = vtkKWWidget::New();
+ this->TreeFrame->SetParent(this->LabeledFrame->GetFrame());
+
+ this->Tree = vtkKWWidget::New();
+ this->Tree->SetParent(this->TreeFrame);
+
+ this->TimeValue = 0.0;
+
+ this->FrameLabel = 0;
+
+ this->TimeSets = vtkDataArrayCollection::New();
+
+ this->Property = 0;
+
+ this->SetCommand = 0;
+ this->ServerSideID.ID = 0;
+}
+
+//-----------------------------------------------------------------------------
+vtkPVFoamSelectTimeSet::~vtkPVFoamSelectTimeSet()
+{
+ this->LabeledFrame->Delete();
+ this->Tree->Delete();
+ this->TreeFrame->Delete();
+ this->TimeLabel->Delete();
+ this->SetFrameLabel(0);
+ this->TimeSets->Delete();
+ this->SetSetCommand(0);
+ if(this->ServerSideID.ID)
+ {
+ vtkPVProcessModule* pm = this->GetPVApplication()->GetProcessModule();
+ pm->DeleteStreamObject(this->ServerSideID);
+ pm->SendStream(vtkProcessModule::DATA_SERVER);
+ }
+}
+
+//-----------------------------------------------------------------------------
+void vtkPVFoamSelectTimeSet::SetLabel(const char* label)
+{
+ this->SetFrameLabel(label);
+ if (this->GetApplication())
+ {
+ this->LabeledFrame->SetLabel(label);
+ }
+}
+
+//-----------------------------------------------------------------------------
+const char* vtkPVFoamSelectTimeSet::GetLabel()
+{
+ return this->GetFrameLabel();
+}
+
+//-----------------------------------------------------------------------------
+void vtkPVFoamSelectTimeSet::Create(vtkKWApplication *pvApp)
+{
+ // Call the superclass to create the widget and set the appropriate flags
+
+ if (!this->vtkKWWidget::Create(pvApp, "frame", "-bd 2 -relief flat"))
+ {
+ vtkErrorMacro("Failed creating widget " << this->GetClassName());
+ return;
+ }
+
+ // For getting the widget in a script.
+ if ((this->TraceNameState == vtkPVWidget::Uninitialized ||
+ this->TraceNameState == vtkPVWidget::Default) )
+ {
+ this->SetTraceName("FoamSelectTimeSet");
+ this->SetTraceNameState(vtkPVWidget::SelfInitialized);
+ }
+
+ this->LabeledFrame->Create(this->GetApplication(), 0);
+ if (this->FrameLabel)
+ {
+ this->LabeledFrame->SetLabel(this->FrameLabel);
+ }
+ this->TimeLabel->Create(this->GetApplication(), "");
+
+ char label[32];
+ sprintf(label, "Time value: %12.5e", 0.0);
+ this->TimeLabel->SetLabel(label);
+ this->Script("pack %s", this->TimeLabel->GetWidgetName());
+
+ this->TreeFrame->Create(this->GetApplication(), "ScrolledWindow",
+ "-relief sunken -bd 2");
+
+ this->Tree->Create(this->GetApplication(), "Tree",
+ "-background white -bd 0 -width 15 -padx 2 "
+ "-redraw 1 -relief flat -selectbackground red");
+ this->Script("%s bindText {%s SetTimeValueCallback}",
+ this->Tree->GetWidgetName(), this->GetTclName());
+ this->Script("%s setwidget %s", this->TreeFrame->GetWidgetName(),
+ this->Tree->GetWidgetName());
+
+ this->Script("pack %s -expand t -fill x", this->TreeFrame->GetWidgetName());
+
+ this->Script("pack %s -side top -expand t -fill x",
+ this->LabeledFrame->GetWidgetName());
+
+}
+
+//-----------------------------------------------------------------------------
+void vtkPVFoamSelectTimeSet::SetTimeValue(float time)
+{
+ if (this->TimeValue != time ||
+ !this->TimeLabel->GetLabel() ||
+ !strcmp(this->TimeLabel->GetLabel(), "No timesets available."))
+ {
+ this->TimeValue = time;
+
+ char label[32];
+ sprintf(label, "Time value: %12.5e", time);
+ this->TimeLabel->SetLabel(label);
+ this->Modified();
+ }
+}
+
+//-----------------------------------------------------------------------------
+void vtkPVFoamSelectTimeSet::SetTimeValueCallback(const char* item)
+{
+ if (this->TimeSets->GetNumberOfItems() == 0)
+ {
+ return;
+ }
+
+ if ( strncmp(item, "timeset", strlen("timeset")) == 0 )
+ {
+ this->Script("if [%s itemcget %s -open] "
+ "{%s closetree %s} else {%s opentree %s}",
+ this->Tree->GetWidgetName(), item,
+ this->Tree->GetWidgetName(), item,
+ this->Tree->GetWidgetName(), item);
+ return;
+ }
+
+ this->Script("%s selection set %s", this->Tree->GetWidgetName(),
+ item);
+ this->Script("%s itemcget %s -data", this->Tree->GetWidgetName(),
+ item);
+ const char* result = this->GetApplication()->GetMainInterp()->result;
+ if (result[0] == '\0')
+ {
+ return;
+ }
+
+ int index[2];
+ sscanf(result, "%d %d", &(index[0]), &(index[1]));
+
+ this->SetTimeSetsFromReader();
+ this->SetTimeValue(this->TimeSets->GetItem(index[0])->GetTuple1(index[1]));
+ this->ModifiedCallback();
+}
+
+//-----------------------------------------------------------------------------
+void vtkPVFoamSelectTimeSet::AddRootNode(const char* name, const char* text)
+{
+ if (!this->GetApplication())
+ {
+ return;
+ }
+ this->Script("%s insert end root %s -text {%s}", this->Tree->GetWidgetName(),
+ name, text);
+}
+
+//-----------------------------------------------------------------------------
+void vtkPVFoamSelectTimeSet::AddChildNode(const char* parent, const char* name,
+ const char* text, const char* data)
+{
+ if (!this->GetApplication())
+ {
+ return;
+ }
+ this->Script("%s insert end %s %s -text {%s} -data %s",
+ this->Tree->GetWidgetName(), parent, name, text, data);
+}
+
+
+//-----------------------------------------------------------------------------
+void vtkPVFoamSelectTimeSet::SaveInBatchScript(ofstream *file)
+{
+ *file << " [$pvTemp" << this->PVSource->GetVTKSourceID(0)
+ << " GetProperty " << this->SetCommand << "] SetElements1 "
+ << this->Property->GetScalar(0) << endl;
+}
+
+//-----------------------------------------------------------------------------
+void vtkPVFoamSelectTimeSet::AcceptInternal(vtkClientServerID sourceID)
+{
+ if (this->ModifiedFlag)
+ {
+ this->Script("%s selection get", this->Tree->GetWidgetName());
+ this->AddTraceEntry("$kw(%s) SetTimeValueCallback {%s}",
+ this->GetTclName(),
+ this->GetApplication()->GetMainInterp()->result);
+ }
+
+ this->Property->SetVTKSourceID(sourceID);
+ this->Property->SetScalars(1, &this->TimeValue);
+ this->Property->AcceptInternal();
+
+ this->ModifiedFlag = 0;
+}
+
+//---------------------------------------------------------------------------
+void vtkPVFoamSelectTimeSet::Trace(ofstream *file)
+{
+ if ( ! this->InitializeTrace(file))
+ {
+ return;
+ }
+
+ this->Script("%s selection get", this->Tree->GetWidgetName());
+ *file << "$kw(" << this->GetTclName() << ") SetTimeValueCallback {"
+ << this->GetApplication()->GetMainInterp()->result << "}" << endl;
+}
+
+
+//-----------------------------------------------------------------------------
+void vtkPVFoamSelectTimeSet::ResetInternal()
+{
+ if ( ! this->ModifiedFlag)
+ {
+ return;
+ }
+
+ // Command to update the UI.
+ if (!this->Tree)
+ {
+ return;
+ }
+
+ this->Script("%s delete [%s nodes root]", this->Tree->GetWidgetName(),
+ this->Tree->GetWidgetName());
+
+ this->SetTimeSetsFromReader();
+
+ int timeSetId=0;
+ char timeSetName[32];
+ char timeSetText[32];
+
+ char timeValueName[32];
+ char timeValueText[32];
+ char indices[32];
+
+ float actualTimeValue = this->Property->GetScalar(0);
+ int matchFound = 0;
+
+ this->ModifiedFlag = 0;
+
+ if (this->TimeSets->GetNumberOfItems() == 0)
+ {
+ this->Script("pack forget %s", this->TreeFrame->GetWidgetName());
+ this->TimeLabel->SetLabel("No timesets available.");
+ return;
+ }
+ else
+ {
+ this->SetTimeValue(actualTimeValue);
+ this->Script("pack %s -expand t -fill x", this->TreeFrame->GetWidgetName());
+ }
+
+ this->TimeSets->InitTraversal();
+ vtkDataArray* da;
+ while( (da=this->TimeSets->GetNextItem()) )
+ {
+ timeSetId++;
+ sprintf(timeSetName,"timeset%d", timeSetId);
+ sprintf(timeSetText,"Time Set %d", timeSetId);
+ this->AddRootNode(timeSetName, timeSetText);
+
+ vtkIdType tuple;
+ for(tuple=0; tupleGetNumberOfTuples(); tuple++)
+ {
+ float timeValue = da->GetTuple1(tuple);
+ sprintf(timeValueName, "time%d_%-12.5e", timeSetId, timeValue);
+ sprintf(timeValueText, "%-12.5e", timeValue);
+ ostrstream str;
+ str << "{" << timeSetId-1 << " " << tuple << "}" << ends;
+ sprintf(indices, "%s", str.str());
+ str.rdbuf()->freeze(0);
+ this->AddChildNode(timeSetName, timeValueName, timeValueText, indices);
+ if (actualTimeValue == timeValue && !matchFound)
+ {
+ matchFound=1;
+ this->Script("%s selection set %s", this->Tree->GetWidgetName(),
+ timeValueName);
+ }
+ }
+ if (timeSetId == 1)
+ {
+ this->Script("%s opentree %s", this->Tree->GetWidgetName(),
+ timeSetName);
+ }
+ }
+
+ this->SetTimeValue(actualTimeValue);
+}
+
+//-----------------------------------------------------------------------------
+void vtkPVFoamSelectTimeSet::AddAnimationScriptsToMenu(vtkKWMenu *menu,
+ vtkPVAnimationInterfaceEntry *ai)
+{
+ char methodAndArgs[500];
+
+ sprintf(methodAndArgs, "AnimationMenuCallback %s", ai->GetTclName());
+ // I do not under stand why the trace name is used for the
+ // menu entry, but Berk must know.
+ menu->AddCommand(this->GetTraceName(), this, methodAndArgs, 0, "");
+}
+
+
+//-----------------------------------------------------------------------------
+// What a pain. I need this method for tracing.
+// Maybe the animation should call PVwidget methods and not vtk object methods.
+void vtkPVFoamSelectTimeSet::AnimationMenuCallback(vtkPVAnimationInterfaceEntry *ai)
+{
+ if (ai->InitializeTrace(NULL))
+ {
+ this->AddTraceEntry("$kw(%s) AnimationMenuCallback $kw(%s)",
+ this->GetTclName(), ai->GetTclName());
+ }
+
+ // I do not under stand why the trace name is used for the
+ // menu entry, but Berk must know.
+ ai->SetLabelAndScript(this->GetTraceName(), NULL, this->GetTraceName());
+ ai->SetCurrentProperty(this->Property);
+ ai->Update();
+}
+
+
+
+//-----------------------------------------------------------------------------
+vtkPVFoamSelectTimeSet* vtkPVFoamSelectTimeSet::ClonePrototype(vtkPVSource* pvSource,
+ vtkArrayMap* map)
+{
+ vtkPVWidget* clone = this->ClonePrototypeInternal(pvSource, map);
+ return vtkPVFoamSelectTimeSet::SafeDownCast(clone);
+}
+
+//-----------------------------------------------------------------------------
+void vtkPVFoamSelectTimeSet::CopyProperties(vtkPVWidget* clone,
+ vtkPVSource* pvSource,
+ vtkArrayMap* map)
+{
+ this->Superclass::CopyProperties(clone, pvSource, map);
+ vtkPVFoamSelectTimeSet* pvts = vtkPVFoamSelectTimeSet::SafeDownCast(clone);
+ if (pvts)
+ {
+ pvts->SetLabel(this->FrameLabel);
+ pvts->SetSetCommand(this->SetCommand);
+ }
+ else
+ {
+ vtkErrorMacro(
+ "Internal error. Could not downcast clone to PVFoamSelectTimeSet.");
+ }
+}
+
+//-----------------------------------------------------------------------------
+int vtkPVFoamSelectTimeSet::ReadXMLAttributes(vtkPVXMLElement* element,
+ vtkPVXMLPackageParser* parser)
+{
+ if(!this->Superclass::ReadXMLAttributes(element, parser)) { return 0; }
+
+ // Setup the Label.
+ const char* label = element->GetAttribute("label");
+ if(label)
+ {
+ this->SetLabel(label);
+ }
+
+ this->SetSetCommand(element->GetAttribute("set_command"));
+
+ return 1;
+}
+
+//-----------------------------------------------------------------------------
+void vtkPVFoamSelectTimeSet::SetTimeSetsFromReader()
+{
+ vtkPVProcessModule* pm = this->GetPVApplication()->GetProcessModule();
+ this->TimeSets->RemoveAllItems();
+
+ // Create the server-side helper if necessary.
+ if(!this->ServerSideID.ID)
+ {
+ this->ServerSideID = pm->NewStreamObject("vtkPVFoamServerSelectTimeSet");
+ pm->SendStream(vtkProcessModule::DATA_SERVER);
+ }
+
+ // Get the time sets from the reader on the server.
+ // Reader -> VTKSourceID (0). We assume that there is 1 VTKSource.
+ pm->GetStream() << vtkClientServerStream::Invoke
+ << this->ServerSideID << "GetTimeSets"
+ << this->PVSource->GetVTKSourceID(0)
+ << vtkClientServerStream::End;
+ pm->SendStream(vtkProcessModule::DATA_SERVER_ROOT);
+ vtkClientServerStream timeSets;
+ if(!pm->GetLastServerResult().GetArgument(0, 0, &timeSets))
+ {
+ vtkErrorMacro("Error getting time sets from server.");
+ return;
+ }
+
+ // There is one time set per message.
+ for(int m=0; m < timeSets.GetNumberOfMessages(); ++m)
+ {
+ // Each argument in the message is a time set entry.
+ vtkFloatArray* timeSet = vtkFloatArray::New();
+ int n = timeSets.GetNumberOfArguments(m);
+ timeSet->SetNumberOfTuples(n);
+ for(int i=0; i < n; ++i)
+ {
+ float value;
+ if(!timeSets.GetArgument(m, i, &value))
+ {
+ vtkErrorMacro("Error reading time set value.");
+ timeSet->Delete();
+ return;
+ }
+ timeSet->SetTuple1(i, value);
+ }
+ this->TimeSets->AddItem(timeSet);
+ timeSet->Delete();
+ }
+
+ if (this->Property->GetNumberOfScalars() == 0 &&
+ this->TimeSets->GetNumberOfItems() > 0)
+ {
+ vtkFloatArray *ts =
+ vtkFloatArray::SafeDownCast(this->TimeSets->GetItem(0));
+ this->Property->SetScalars(1, ts->GetPointer(0));
+ }
+}
+
+//----------------------------------------------------------------------------
+void vtkPVFoamSelectTimeSet::SaveInBatchScriptForPart(ofstream *file,
+ vtkClientServerID sourceID)
+{
+ if (sourceID.ID == 0)
+ {
+ vtkErrorMacro(<< this->GetClassName()
+ << " must not have SaveInBatchScript method.");
+ return;
+ }
+
+ *file << "\t" << "pvTemp" << sourceID
+ << " SetTimeValue " << this->GetTimeValue()
+ << endl;;
+}
+
+//-----------------------------------------------------------------------------
+void vtkPVFoamSelectTimeSet::SetProperty(vtkPVWidgetProperty *prop)
+{
+ this->Property = vtkPVScalarListWidgetProperty::SafeDownCast(prop);
+ if (this->Property)
+ {
+ int numScalars = 1;
+ this->Property->SetVTKCommands(1, &this->SetCommand, &numScalars);
+ }
+}
+
+//-----------------------------------------------------------------------------
+vtkPVWidgetProperty* vtkPVFoamSelectTimeSet::GetProperty()
+{
+ return this->Property;
+}
+
+//-----------------------------------------------------------------------------
+vtkPVWidgetProperty* vtkPVFoamSelectTimeSet::CreateAppropriateProperty()
+{
+ return vtkPVScalarListWidgetProperty::New();
+}
+
+//-----------------------------------------------------------------------------
+void vtkPVFoamSelectTimeSet::PrintSelf(ostream& os, vtkIndent indent)
+{
+ this->Superclass::PrintSelf(os, indent);
+ os << indent << "TimeValue: " << this->TimeValue << endl;
+ os << indent << "LabeledFrame: " << this->LabeledFrame << endl;
+ os << indent << "SetCommand: "
+ << (this->SetCommand ? this->SetCommand : "(none)") << endl;
+}
diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/vtkPVFoamSelectTimeSet.h b/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/vtkPVFoamSelectTimeSet.h
new file mode 100644
index 0000000000..70ab8cc97f
--- /dev/null
+++ b/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/vtkPVFoamSelectTimeSet.h
@@ -0,0 +1,164 @@
+/*=========================================================================
+
+ Program: ParaView
+ Module: $RCSfile: vtkPVFoamSelectTimeSet.h,v $
+
+ Copyright (c) Kitware, Inc.
+ All rights reserved.
+ See Copyright.txt or http://www.paraview.org/HTML/Copyright.html 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 vtkPVFoamSelectTimeSet - Special time selection widget used by PVFoamReaderModule
+// .SECTION Description
+// This is a PVWidget specially designed to be used with PVFoamReaderModule.
+// It provides support for multiple sets. The time value selected by
+// the user is passed to the Foam reader with a SetTimeValue() call.
+
+#ifndef __vtkPVFoamSelectTimeSet_h
+#define __vtkPVFoamSelectTimeSet_h
+
+#include "vtkPVWidget.h"
+
+class vtkKWLabel;
+class vtkKWMenu;
+class vtkKWLabeledFrame;
+class vtkDataArrayCollection;
+class vtkPVScalarListWidgetProperty;
+
+class VTK_EXPORT vtkPVFoamSelectTimeSet : public vtkPVWidget
+{
+public:
+ static vtkPVFoamSelectTimeSet* New();
+ vtkTypeRevisionMacro(vtkPVFoamSelectTimeSet, vtkPVWidget);
+ void PrintSelf(ostream& os, vtkIndent indent);
+
+ virtual void Create(vtkKWApplication *pvApp);
+
+ //BTX
+ // Description:
+ // Called when accept button is pushed.
+ // Sets objects variable to the widgets value.
+ // Adds a trace entry. Side effect is to turn modified flag off.
+ virtual void AcceptInternal(vtkClientServerID);
+ //ETX
+
+ // Description:
+ // Called when the reset button is pushed.
+ // Sets widget's value to the object-variable's value.
+ // Side effect is to turn the modified flag off.
+ virtual void ResetInternal();
+
+ // Description:
+ // Adds a script to the menu of the animation interface.
+ virtual void AddAnimationScriptsToMenu(vtkKWMenu *menu,
+ vtkPVAnimationInterfaceEntry *ai);
+
+ // Description:
+ // Called whenthe animation method menu item is selected.
+ // Needed for proper tracing.
+ // It would be nice if the menu and cascade menus would trace
+ // invokation of items (?relying of enumeration of menu items or label?)
+ void AnimationMenuCallback(vtkPVAnimationInterfaceEntry *ai);
+
+ // Description:
+ // This is the labeled frame around the timeset tree.
+ vtkGetObjectMacro(LabeledFrame, vtkKWLabeledFrame);
+
+ // Description:
+ // Label displayed on the labeled frame.
+ void SetLabel(const char* label);
+ const char* GetLabel();
+
+ // Description:
+ // Updates the time value label and the time ivar.
+ void SetTimeValue(float time);
+ vtkGetMacro(TimeValue, float);
+
+ // Description:
+ // Calls this->SetTimeValue () and Reader->SetTimeValue()
+ // with currently selected time value.
+ void SetTimeValueCallback(const char* item);
+
+//BTX
+ // Description:
+ // Creates and returns a copy of this widget. It will create
+ // a new instance of the same type as the current object
+ // using NewInstance() and then copy some necessary state
+ // parameters.
+ vtkPVFoamSelectTimeSet* ClonePrototype(vtkPVSource* pvSource,
+ vtkArrayMap* map);
+//ETX
+
+ // Description:
+ // This serves a dual purpose. For tracing and for saving state.
+ virtual void Trace(ofstream *file);
+
+ // Description:
+ // Set/get the property to use with this widget.
+ virtual void SetProperty(vtkPVWidgetProperty *prop);
+ virtual vtkPVWidgetProperty* GetProperty();
+
+ // Description:
+ // Create the right property for use with this widget.
+ virtual vtkPVWidgetProperty* CreateAppropriateProperty();
+
+ // Description:
+ // Set/get the command to pass the value to VTK.
+ vtkSetStringMacro(SetCommand);
+ vtkGetStringMacro(SetCommand);
+
+ // Description:
+ // Save this widget to a file.
+ virtual void SaveInBatchScript(ofstream *file);
+
+protected:
+ vtkPVFoamSelectTimeSet();
+ ~vtkPVFoamSelectTimeSet();
+
+ vtkPVFoamSelectTimeSet(const vtkPVFoamSelectTimeSet&); // Not implemented
+ void operator=(const vtkPVFoamSelectTimeSet&); // Not implemented
+
+ vtkPVScalarListWidgetProperty *Property;
+
+ char *SetCommand;
+
+ vtkSetStringMacro(FrameLabel);
+ vtkGetStringMacro(FrameLabel);
+
+ vtkKWWidget* Tree;
+ vtkKWWidget* TreeFrame;
+ vtkKWLabel* TimeLabel;
+ vtkKWLabeledFrame* LabeledFrame;
+
+ void AddRootNode(const char* name, const char* text);
+ void AddChildNode(const char* parent, const char* name,
+ const char* text, const char* data);
+
+ float TimeValue;
+ char* FrameLabel;
+
+ vtkDataArrayCollection* TimeSets;
+ vtkClientServerID ServerSideID;
+
+ // Fill the TimeSets collection with that from the actual reader.
+ void SetTimeSetsFromReader();
+
+//BTX
+ virtual void CopyProperties(vtkPVWidget* clone, vtkPVSource* pvSource,
+ vtkArrayMap* map);
+//ETX
+
+ int ReadXMLAttributes(vtkPVXMLElement* element,
+ vtkPVXMLPackageParser* parser);
+
+ // Description:
+ // An interface for saving a widget into a script.
+ virtual void SaveInBatchScriptForPart(ofstream *file, vtkClientServerID);
+
+};
+
+#endif
diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/vtkPVFoamServerSelectTimeSet.cxx b/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/vtkPVFoamServerSelectTimeSet.cxx
new file mode 100644
index 0000000000..acfce9bab2
--- /dev/null
+++ b/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/vtkPVFoamServerSelectTimeSet.cxx
@@ -0,0 +1,85 @@
+/*=========================================================================
+
+ Program: ParaView
+ Module: $RCSfile: vtkPVFoamServerSelectTimeSet.cxx,v $
+
+ Copyright (c) Kitware, Inc.
+ All rights reserved.
+ See Copyright.txt or http://www.paraview.org/HTML/Copyright.html 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 "vtkPVFoamServerSelectTimeSet.h"
+
+#include "vtkClientServerInterpreter.h"
+#include "vtkObjectFactory.h"
+#include "vtkPVProcessModule.h"
+#include "vtkFoamReader.h"
+#include "vtkDataArrayCollection.h"
+#include "vtkDataArrayCollectionIterator.h"
+#include "vtkClientServerStream.h"
+
+#include
+
+//----------------------------------------------------------------------------
+vtkStandardNewMacro(vtkPVFoamServerSelectTimeSet);
+vtkCxxRevisionMacro(vtkPVFoamServerSelectTimeSet, "$Revision: 1.4 $");
+
+//----------------------------------------------------------------------------
+class vtkPVFoamServerSelectTimeSetInternals
+{
+public:
+ vtkClientServerStream Result;
+};
+
+//----------------------------------------------------------------------------
+vtkPVFoamServerSelectTimeSet::vtkPVFoamServerSelectTimeSet()
+{
+ this->Internal = new vtkPVFoamServerSelectTimeSetInternals;
+}
+
+//----------------------------------------------------------------------------
+vtkPVFoamServerSelectTimeSet::~vtkPVFoamServerSelectTimeSet()
+{
+ delete this->Internal;
+}
+
+//----------------------------------------------------------------------------
+void vtkPVFoamServerSelectTimeSet::PrintSelf(ostream& os, vtkIndent indent)
+{
+ this->Superclass::PrintSelf(os,indent);
+}
+
+//----------------------------------------------------------------------------
+const vtkClientServerStream&
+vtkPVFoamServerSelectTimeSet::GetTimeSets(vtkFoamReader* reader)
+{
+ // Reset the stream for a new list of time sets.
+ this->Internal->Result.Reset();
+
+ // Get the time sets from the reader.
+ vtkDataArrayCollection* timeSets = reader->GetTimeSets();
+
+ // Iterate through the time sets.
+ vtkDataArrayCollectionIterator* iter = vtkDataArrayCollectionIterator::New();
+ iter->SetCollection(timeSets);
+ for(iter->GoToFirstItem(); !iter->IsDoneWithTraversal();
+ iter->GoToNextItem())
+ {
+ // Each time set is stored in one message.
+ this->Internal->Result << vtkClientServerStream::Reply;
+ vtkDataArray* da = iter->GetDataArray();
+ for(int i=0; i < da->GetNumberOfTuples(); ++i)
+ {
+ this->Internal->Result << da->GetTuple1(i);
+ }
+ this->Internal->Result << vtkClientServerStream::End;
+ }
+ iter->Delete();
+
+ // Return the stream.
+ return this->Internal->Result;
+}
diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/vtkPVFoamServerSelectTimeSet.h b/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/vtkPVFoamServerSelectTimeSet.h
new file mode 100644
index 0000000000..99f755c9f3
--- /dev/null
+++ b/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/vtkPVFoamServerSelectTimeSet.h
@@ -0,0 +1,49 @@
+/*=========================================================================
+
+ Program: ParaView
+ Module: $RCSfile: vtkPVFoamServerSelectTimeSet.h,v $
+
+ Copyright (c) Kitware, Inc.
+ All rights reserved.
+ See Copyright.txt or http://www.paraview.org/HTML/Copyright.html 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 vtkPVFoamServerSelectTimeSet - Server-side helper for vtkPVFoamSelectTimeSet.
+// .SECTION Description
+
+#ifndef __vtkPVFoamServerSelectTimeSet_h
+#define __vtkPVFoamServerSelectTimeSet_h
+
+#include "vtkPVServerObject.h"
+
+class vtkClientServerStream;
+class vtkPVFoamServerSelectTimeSetInternals;
+class vtkFoamReader;
+
+class VTK_EXPORT vtkPVFoamServerSelectTimeSet : public vtkPVServerObject
+{
+public:
+ static vtkPVFoamServerSelectTimeSet* New();
+ vtkTypeRevisionMacro(vtkPVFoamServerSelectTimeSet, vtkPVServerObject);
+ void PrintSelf(ostream& os, vtkIndent indent);
+
+ // Description:
+ // Get a list the time sets provided by the given reader.
+ const vtkClientServerStream& GetTimeSets(vtkFoamReader*);
+
+protected:
+ vtkPVFoamServerSelectTimeSet();
+ ~vtkPVFoamServerSelectTimeSet();
+
+ // Internal implementation details.
+ vtkPVFoamServerSelectTimeSetInternals* Internal;
+private:
+ vtkPVFoamServerSelectTimeSet(const vtkPVFoamServerSelectTimeSet&); // Not implemented
+ void operator=(const vtkPVFoamServerSelectTimeSet&); // Not implemented
+};
+
+#endif
diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/Make/files b/applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/Make/files
new file mode 100644
index 0000000000..f5a5526caa
--- /dev/null
+++ b/applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/Make/files
@@ -0,0 +1,5 @@
+vtkFoam.C
+vtkFoamAddInternalMesh.C
+vtkFoamAddPatch.C
+
+LIB = $(FOAM_LIBBIN)/libvtkFoam
diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/Make/options b/applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/Make/options
new file mode 100644
index 0000000000..670c68424b
--- /dev/null
+++ b/applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/Make/options
@@ -0,0 +1,8 @@
+EXE_INC = \
+ -I$(LIB_SRC)/finiteVolume/lnInclude \
+ -I$(ParaView_INST_DIR)/include \
+ -I../PVFoamReader
+
+LIB_LIBS = \
+ -lfiniteVolume \
+ $(GLIBS)
diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/vtkDataArrayTemplateImplicit.txx b/applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/vtkDataArrayTemplateImplicit.txx
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/vtkFoam.C b/applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/vtkFoam.C
new file mode 100644
index 0000000000..6a1830b5d1
--- /dev/null
+++ b/applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/vtkFoam.C
@@ -0,0 +1,665 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
+ \\/ 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 "vtkFoam.H"
+
+#include "argList.H"
+#include "Time.H"
+#include "polyBoundaryMeshEntries.H"
+#include "IOobjectList.H"
+#include "wordList.H"
+#include "fvMesh.H"
+#include "volFields.H"
+#include "pointMesh.H"
+#include "volPointInterpolation.H"
+
+#include "vtkFoamReader.h"
+#include "vtkDataArraySelection.h"
+#include "vtkUnstructuredGrid.h"
+#include "vtkPointData.h"
+#include "vtkCellData.h"
+#include "vtkFloatArray.h"
+#include "vtkCharArray.h"
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+defineTypeNameAndDebug(Foam::vtkFoam, 0);
+
+// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
+
+#include "vtkFoamConvertFields.H"
+
+void Foam::vtkFoam::SetName
+(
+ vtkUnstructuredGrid* vtkMesh,
+ const char* name
+)
+{
+ vtkCharArray* nmArray = vtkCharArray::New();
+ nmArray->SetName("Name");
+ size_t len = strlen(name);
+ nmArray->SetNumberOfTuples(static_cast(len)+1);
+ char* copy = nmArray->GetPointer(0);
+ memcpy(copy, name, len);
+ copy[len] = '\0';
+ vtkMesh->GetFieldData()->AddArray(nmArray);
+ nmArray->Delete();
+}
+
+
+Foam::string Foam::vtkFoam::padTimeString(const string& ts)
+{
+ return ts + string(" ", max(label(12 - ts.size()), 0));
+}
+
+
+// Pad the patch name string in order to account for dynamic changes
+// in patch names during topological changes
+Foam::string Foam::vtkFoam::padPatchString(const string& ps)
+{
+ label n = max(label(50 - ps.size()), 0);
+ return ps + string(" ", n);
+}
+
+
+void Foam::vtkFoam::setSelectedTime
+(
+ Time& runTime,
+ vtkFoamReader* reader
+)
+{
+ // Get times list
+ instantList Times = runTime.times();
+ int timeIndex = min(max(reader->GetTimeStep() + 1, 0), Times.size()-1);
+
+ // If this is the first call timeIndex will be 0 ("constant")
+ // so reset to the first time step if one exists and deselect every
+ // element of the selection array
+ if (timeIndex == 0)
+ {
+ timeIndex = min(1, Times.size()-1);
+ reader->GetTimeSelection()->DisableAllArrays();
+ }
+
+ label selectedTimeIndex = -1;
+ label nSelectedTimes = reader->GetTimeSelection()->GetNumberOfArrays();
+
+ for (label i=nSelectedTimes-1; i>=0; i--)
+ {
+ if(reader->GetTimeSelection()->GetArraySetting(i))
+ {
+ word timeName = string::validate
+ (
+ reader->GetTimeSelection()->GetArrayName(i)
+ );
+
+ forAll(Times, j)
+ {
+ if (Times[j].name() == timeName)
+ {
+ selectedTimeIndex = j;
+ break;
+ }
+ }
+ break;
+ }
+ }
+
+ if (selectedTimeIndex != -1)
+ {
+ timeIndex = min(selectedTimeIndex, Times.size()-1);
+ }
+
+ if (debug)
+ {
+ Info<< "Selecting time " << Times[timeIndex].name() << endl;
+ }
+
+ runTime.setTime(Times[timeIndex], timeIndex);
+
+ Times = runTime.times();
+
+ reader->SetTimeStepRange(0, max(Times.size()-2, 0));
+
+ // reset the time steps ...
+ reader->GetTimeSelection()->RemoveAllArrays();
+
+ int* TimeStepLimits = reader->GetTimeStepLimits();
+ label maxStartTimes = min(Times.size(), TimeStepLimits[0]);
+ label maxNTimes = min(Times.size() - maxStartTimes, TimeStepLimits[1]);
+
+ for (label i=0; iGetTimeSelection()
+ ->AddArray(padTimeString(Times[i].name()).c_str());
+ }
+
+ if (Times.size() > TimeStepLimits[0] + TimeStepLimits[1])
+ {
+ reader->GetTimeSelection()->AddArray(padTimeString("...").c_str());
+ }
+
+ for (label i=Times.size() - maxNTimes; iGetTimeSelection()
+ ->AddArray(padTimeString(Times[i].name()).c_str());
+ }
+
+ // Disable all the time selections (which are all selected by default) ...
+ reader->GetTimeSelection()->DisableAllArrays();
+
+ // But maintain the selections made previously
+ if (selectedTimeIndex != -1 && selectedTimeIndex < Times.size())
+ {
+ reader->GetTimeSelection()->EnableArray
+ (padTimeString(Times[selectedTimeIndex].name()).c_str());
+ }
+}
+
+
+void Foam::vtkFoam::updateSelectedRegions()
+{
+ if (debug)
+ {
+ Info<< "Foam::vtkFoam::updateSelectedRegions()" << endl;
+ }
+
+ label nRegions = reader_->GetRegionSelection()->GetNumberOfArrays();
+
+ selectedRegions_.setSize(nRegions);
+
+ // Read the selected patches and add to the region list
+ for (int i=0; iGetRegionSelection()->GetArraySetting(i);
+ }
+}
+
+
+void Foam::vtkFoam::convertMesh()
+{
+ if (debug)
+ {
+ Info<< "Foam::vtkFoam::convertMesh()" << endl;
+ }
+
+ const fvMesh& mesh = *meshPtr_;
+
+ // Read the internal mesh as region 0 if selected
+ if (reader_->GetRegionSelection()->GetArraySetting(0))
+ {
+ selectedRegions_[0] = true;
+ addInternalMesh
+ (
+ mesh,
+ vtkUnstructuredGrid::SafeDownCast(reader_->GetOutput(0))
+ );
+ }
+ else
+ {
+ selectedRegions_[0] = false;
+
+ vtkUnstructuredGrid *vtkMesh =
+ vtkUnstructuredGrid::SafeDownCast(reader_->GetOutput(0));
+
+ vtkMesh->Initialize();
+ SetName(vtkMesh, "(Internal Mesh)");
+ }
+
+
+ // Read the selected patches and add to the region list
+
+ polyBoundaryMeshEntries patchEntries
+ (
+ IOobject
+ (
+ "boundary",
+ dbPtr_().findInstance(polyMesh::meshSubDir, "boundary"),
+ polyMesh::meshSubDir,
+ dbPtr_(),
+ IOobject::MUST_READ,
+ IOobject::NO_WRITE,
+ false
+ )
+ );
+
+ label regioni = 0;
+ label regioniLast = 0;
+
+ // Read in the number Outputs (patch regions) currently being used
+ label currNOutputs = reader_->GetNumberOfOutputs();
+
+ // Cycle through all the patches in the boundary file for the relevant
+ // time step
+ forAll(patchEntries, entryi)
+ {
+ // Number of faces in the current patch (Used to detect dummy patches
+ // of size zero)
+ label nFaces(readLabel(patchEntries[entryi].dict().lookup("nFaces")));
+
+ // Check to see if the patch is currently a part of the displayed list
+ if
+ (
+ reader_->GetRegionSelection()->ArrayExists
+ (
+ padPatchString(patchEntries[entryi].keyword()).c_str()
+ )
+ )
+ {
+ if (!nFaces)
+ {
+ // Remove patch if it is only a dummy patch in the current
+ // time step with zero faces
+ reader_->GetRegionSelection()->RemoveArrayByName
+ (
+ padPatchString(patchEntries[entryi].keyword()).c_str()
+ );
+ }
+ else
+ {
+ // A patch already existent in the list and which
+ // continues to exist found
+ regioni++;
+ }
+ }
+ else
+ {
+ // A new patch so far not yet included into the list has been found
+ if (nFaces)
+ {
+ regioni++;
+
+ // Add a new entry to the list of regions
+ reader_->GetRegionSelection()->AddArray
+ (
+ padPatchString(patchEntries[entryi].keyword()).c_str()
+ );
+
+ // AddArray automatically enables a new array... disable
+ // it manually
+ reader_->GetRegionSelection()->DisableArray
+ (
+ padPatchString(patchEntries[entryi].keyword()).c_str()
+ );
+ }
+ }
+
+ // Avoid Initialization of the same Output twice
+ if (regioni != regioniLast)
+ {
+ // Only setup an Output if it has not been setup before
+ if(regioni >= currNOutputs)
+ {
+ vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::New();
+ reader_->SetNthOutput(regioni,ugrid);
+ ugrid->Delete();
+ }
+ // Initialize -> Delete memory used, and reset to zero state
+ reader_->GetOutput(regioni)->Initialize();
+ regioniLast = regioni;
+ }
+ }
+
+ // Initialize (reset to zero and free) any outputs which are not used
+ // anymore
+ if (regioni < currNOutputs)
+ {
+ for(label i = (regioni+1); i < currNOutputs;i++)
+ {
+ reader_->GetOutput(i)->Initialize();
+ }
+ }
+
+ selectedRegions_.setSize(regioni + 1);
+
+ regioni = 0;
+
+ const polyBoundaryMesh& patches = mesh.boundaryMesh();
+
+ forAll (patches, patchi)
+ {
+ if (patches[patchi].size())
+ {
+ regioni++;
+
+ if (reader_->GetRegionSelection()->GetArraySetting(regioni))
+ {
+ selectedRegions_[regioni] = true;
+ addPatch
+ (
+ patches[patchi],
+ vtkUnstructuredGrid::SafeDownCast
+ (
+ reader_->GetOutput(regioni)
+ )
+ );
+ }
+ else
+ {
+ selectedRegions_[regioni] = false;
+
+ vtkUnstructuredGrid *vtkMesh =
+ vtkUnstructuredGrid::SafeDownCast
+ (
+ reader_->GetOutput(regioni)
+ );
+
+ vtkMesh->Initialize();
+ SetName
+ (
+ vtkMesh,
+ ('(' + padPatchString(patches[patchi].name()) + ')').c_str()
+ );
+ }
+ }
+ }
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
+
+Foam::vtkFoam::vtkFoam(const char* const FileName, vtkFoamReader* reader)
+:
+ reader_(reader),
+ argsPtr_(NULL),
+ dbPtr_(NULL),
+ meshPtr_(NULL)
+{
+ fileName fullCasePath(fileName(FileName).path());
+
+ if (!isDir(fullCasePath))
+ {
+ return;
+ }
+
+ char* argvStrings[3];
+ argvStrings[0] = new char[9];
+ strcpy(argvStrings[0], "/vtkFoam");
+ argvStrings[1] = new char[6];
+ strcpy(argvStrings[1], "-case");
+ argvStrings[2] = new char[fullCasePath.size()+1];
+ strcpy(argvStrings[2], fullCasePath.c_str());
+
+ int argc = 3;
+ char** argv = &argvStrings[0];
+ argsPtr_.reset(new argList(argc, argv));
+
+ for(int i = 0; i < argc; i++)
+ {
+ delete[] argvStrings[i];
+ }
+
+ dbPtr_.reset
+ (
+ new Time
+ (
+ Time::controlDictName,
+ argsPtr_().rootPath(),
+ argsPtr_().caseName()
+ )
+ );
+ dbPtr_().functionObjects().off();
+ setSelectedTime(dbPtr_(), reader_);
+
+ if (debug)
+ {
+ Info<< "vtkFoam::ExecuteInformation: Initialising outputs" << endl;
+ }
+
+ reader_->GetRegionSelection()->AddArray("Internal Mesh");
+
+ vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::New();
+ reader_->SetNthOutput(0, ugrid);
+ ugrid->Delete();
+ reader_->GetOutput(0)->Initialize();
+
+ polyBoundaryMeshEntries patchEntries
+ (
+ IOobject
+ (
+ "boundary",
+ dbPtr_().findInstance(polyMesh::meshSubDir, "boundary"),
+ polyMesh::meshSubDir,
+ dbPtr_(),
+ IOobject::MUST_READ,
+ IOobject::NO_WRITE,
+ false
+ )
+ );
+
+ label regioni = 0;
+ forAll(patchEntries, entryi)
+ {
+ label nFaces(readLabel(patchEntries[entryi].dict().lookup("nFaces")));
+
+ if (nFaces)
+ {
+ regioni++;
+
+ reader_->GetRegionSelection()->AddArray
+ (
+ padPatchString(patchEntries[entryi].keyword()).c_str()
+ );
+
+ vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::New();
+ reader_->SetNthOutput(regioni, ugrid);
+ ugrid->Delete();
+ reader_->GetOutput(regioni)->Initialize();
+ }
+ }
+
+ selectedRegions_.setSize(regioni + 1);
+ selectedRegions_ = true;
+
+ UpdateInformation();
+}
+
+
+// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
+
+Foam::vtkFoam::~vtkFoam()
+{
+ // Do NOT delete meshPtr_ since still referenced somehow.
+}
+
+
+// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
+
+#include "vtkFoamAddFields.H"
+
+void Foam::vtkFoam::UpdateInformation()
+{
+ if (debug)
+ {
+ Info<< "TimeStep = " << reader_->GetTimeStep() << endl;
+ }
+
+ setSelectedTime(dbPtr_(), reader_);
+
+ // Search for list of objects for this time
+ IOobjectList objects(dbPtr_(), dbPtr_().timeName());
+
+ addFields(reader_->GetVolFieldSelection(), objects);
+ addFields(reader_->GetVolFieldSelection(), objects);
+ addFields(reader_->GetVolFieldSelection(), objects);
+ addFields(reader_->GetVolFieldSelection(), objects);
+ addFields(reader_->GetVolFieldSelection(), objects);
+
+ addFields(reader_->GetPointFieldSelection(), objects);
+ addFields(reader_->GetPointFieldSelection(), objects);
+ addFields(reader_->GetPointFieldSelection(), objects);
+ addFields(reader_->GetPointFieldSelection(), objects);
+ addFields(reader_->GetPointFieldSelection(), objects);
+}
+
+
+void Foam::vtkFoam::Update()
+{
+ if
+ (
+ !reader_->GetCacheMesh()
+ || reader_->GetTimeSelection()->GetArraySetting(0)
+ )
+ {
+ meshPtr_= NULL;
+ }
+
+ // Clear the current set of selected fields
+
+ for (label i=0; iGetNumberOfOutputs(); i++)
+ {
+ vtkUnstructuredGrid *vtkMesh =
+ vtkUnstructuredGrid::SafeDownCast(reader_->GetOutput(i));
+
+ vtkCellData* cellData = vtkMesh->GetCellData();
+ int numberOfCellArrays = cellData->GetNumberOfArrays();
+
+ wordList cellFieldNames(numberOfCellArrays);
+ for (int j=0; jGetArrayName(j);
+ }
+
+ for (int j=0; jRemoveArray(cellFieldNames[j].c_str());
+ }
+
+ vtkPointData* pointData = vtkMesh->GetPointData();
+ int numberOfPointArrays = pointData->GetNumberOfArrays();
+
+ wordList pointFieldNames(numberOfPointArrays);
+ for (int j=0; jGetArrayName(j);
+ }
+
+ for (int j=0; jRemoveArray(pointFieldNames[j].c_str());
+ }
+ }
+
+ // Check to see if the mesh has been created
+
+ if (!meshPtr_)
+ {
+ if (debug)
+ {
+ Info<< "Reading Mesh" << endl;
+ }
+ meshPtr_ =
+ new fvMesh
+ (
+ IOobject
+ (
+ fvMesh::defaultRegion,
+ dbPtr_().timeName(),
+ dbPtr_()
+ )
+ );
+ convertMesh();
+ }
+ else
+ {
+ boolList oldSelectedRegions = selectedRegions_;
+ updateSelectedRegions();
+ if
+ (
+ meshPtr_->readUpdate() != fvMesh::UNCHANGED
+ || oldSelectedRegions != selectedRegions_
+ )
+ {
+ convertMesh();
+ }
+ }
+
+ if (debug)
+ {
+ Info<< "converting fields" << endl;
+ }
+
+ const fvMesh& mesh = *meshPtr_;
+
+ // Construct interpolation on the raw mesh
+ Foam::pointMesh pMesh(mesh);
+
+ Foam::volPointInterpolation pInterp(mesh, pMesh);
+
+ // Search for list of objects for this time
+ Foam::IOobjectList objects(mesh, dbPtr_().timeName());
+
+ convertVolFields
+ (
+ mesh, pInterp, objects, reader_->GetVolFieldSelection()
+ );
+ convertVolFields
+ (
+ mesh, pInterp, objects, reader_->GetVolFieldSelection()
+ );
+ convertVolFields
+ (
+ mesh, pInterp, objects, reader_->GetVolFieldSelection()
+ );
+ convertVolFields
+ (
+ mesh, pInterp, objects, reader_->GetVolFieldSelection()
+ );
+ convertVolFields
+ (
+ mesh, pInterp, objects, reader_->GetVolFieldSelection()
+ );
+
+ convertPointFields
+ (
+ mesh, objects, reader_->GetPointFieldSelection()
+ );
+ convertPointFields
+ (
+ mesh, objects, reader_->GetPointFieldSelection()
+ );
+ convertPointFields
+ (
+ mesh, objects, reader_->GetPointFieldSelection()
+ );
+ convertPointFields
+ (
+ mesh, objects, reader_->GetPointFieldSelection()
+ );
+ convertPointFields
+ (
+ mesh, objects, reader_->GetPointFieldSelection()
+ );
+
+ if (debug)
+ {
+ Info<< "done" << endl;
+ }
+}
+
+
+// ************************************************************************* //
diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/vtkFoam.H b/applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/vtkFoam.H
new file mode 100644
index 0000000000..baca6a3863
--- /dev/null
+++ b/applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/vtkFoam.H
@@ -0,0 +1,256 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
+ \\/ 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::vtkFoam
+
+Description
+
+SourceFiles
+ vtkFoam.C
+ vtkFoamInsertNextPoint.H
+ vtkFoamAddFields.H
+ vtkFoamAddInternalMesh.H
+ vtkFoamConvertFields.H
+ vtkFoamConvertVolField.H
+ vtkFoamConvertPatchFaceField.H
+ vtkFoamConvertPointField.H
+ vtkFoamConvertPatchPointField.H
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef vtkFoam_H
+#define vtkFoam_H
+
+#include "className.H"
+#include "fileName.H"
+#include "volPointInterpolation.H"
+
+// * * * * * * * * * * * * * Forward Declarations * * * * * * * * * * * * * //
+
+// VTK class forward declarations
+class vtkFoamReader;
+class vtkUnstructuredGrid;
+class vtkPoints;
+class vtkDataArraySelection;
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+// Foam class forward declarations
+class argList;
+class Time;
+class fvMesh;
+class IOobjectList;
+class polyPatch;
+
+
+/*---------------------------------------------------------------------------*\
+ Class vtkFoam Declaration
+\*---------------------------------------------------------------------------*/
+
+class vtkFoam
+{
+ // Private data
+
+ //- Access to the controlling vtkFoamReader
+ vtkFoamReader *reader_;
+
+ autoPtr argsPtr_;
+ autoPtr