mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Revert "drop support for paraview 2.x reader"
- this was not agreed.
This reverts commit 41b196ffeb.
This commit is contained in:
21
applications/utilities/postProcessing/graphics/PVFoamReader/Allwmake
Executable file
21
applications/utilities/postProcessing/graphics/PVFoamReader/Allwmake
Executable file
@ -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
|
||||||
@ -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)
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
@ -0,0 +1,154 @@
|
|||||||
|
<ServerManagerConfiguration>
|
||||||
|
<ProxyGroup name="sources">
|
||||||
|
<SourceProxy
|
||||||
|
|
||||||
|
name="FoamReader"
|
||||||
|
class="vtkFoamReader">
|
||||||
|
|
||||||
|
<StringVectorProperty
|
||||||
|
name="FileName"
|
||||||
|
command="SetFileName"
|
||||||
|
number_of_elements="1">
|
||||||
|
<StringListDomain name="files"/>
|
||||||
|
</StringVectorProperty>
|
||||||
|
|
||||||
|
<IntVectorProperty
|
||||||
|
name="UpdateGUI"
|
||||||
|
command="SetUpdateGUI"
|
||||||
|
number_of_elements="1"
|
||||||
|
default_values="0">
|
||||||
|
<BooleanDomain name="bool"/>
|
||||||
|
</IntVectorProperty>
|
||||||
|
|
||||||
|
<IntVectorProperty
|
||||||
|
name="CacheMesh"
|
||||||
|
command="SetCacheMesh"
|
||||||
|
number_of_elements="1"
|
||||||
|
default_values="1">
|
||||||
|
<BooleanDomain name="bool"/>
|
||||||
|
</IntVectorProperty>
|
||||||
|
|
||||||
|
<IntVectorProperty
|
||||||
|
name="TimeStepRangeInfo"
|
||||||
|
command="GetTimeStepRange"
|
||||||
|
information_only="1">
|
||||||
|
<SimpleIntInformationHelper/>
|
||||||
|
</IntVectorProperty>
|
||||||
|
<IntVectorProperty
|
||||||
|
name="TimeStep"
|
||||||
|
command="SetTimeStep"
|
||||||
|
number_of_elements="1"
|
||||||
|
animateable="1"
|
||||||
|
default_values="0">
|
||||||
|
<IntRangeDomain name="range">
|
||||||
|
<RequiredProperties>
|
||||||
|
<Property name="TimeStepRangeInfo" function="Range"/>
|
||||||
|
</RequiredProperties>
|
||||||
|
</IntRangeDomain>
|
||||||
|
</IntVectorProperty>
|
||||||
|
|
||||||
|
<IntVectorProperty
|
||||||
|
name="TimeStepLimitsInfo"
|
||||||
|
command="GetTimeStepLimits"
|
||||||
|
information_only="1">
|
||||||
|
<SimpleIntInformationHelper/>
|
||||||
|
</IntVectorProperty>
|
||||||
|
<IntVectorProperty
|
||||||
|
name="TimeStepLimits"
|
||||||
|
command="SetTimeStepLimits"
|
||||||
|
number_of_elements="2"
|
||||||
|
default_values="2 5" >
|
||||||
|
<IntRangeDomain name="range">
|
||||||
|
<RequiredProperties>
|
||||||
|
<Property name="TimeStepLimitsInfo" function="Range"/>
|
||||||
|
</RequiredProperties>
|
||||||
|
</IntRangeDomain>
|
||||||
|
</IntVectorProperty>
|
||||||
|
|
||||||
|
<StringVectorProperty
|
||||||
|
name="TimeArrayInfo"
|
||||||
|
information_only="1">
|
||||||
|
<ArraySelectionInformationHelper attribute_name="Time"/>
|
||||||
|
</StringVectorProperty>
|
||||||
|
<StringVectorProperty
|
||||||
|
name="TimeStatus"
|
||||||
|
command="SetTimeArrayStatus"
|
||||||
|
number_of_elements="0"
|
||||||
|
repeat_command="1"
|
||||||
|
number_of_elements_per_command="2"
|
||||||
|
element_types="2 0"
|
||||||
|
information_property="TimeArrayInfo">
|
||||||
|
<ArraySelectionDomain name="array_list">
|
||||||
|
<RequiredProperties>
|
||||||
|
<Property name="TimeArrayInfo"
|
||||||
|
function="ArrayList"/>
|
||||||
|
</RequiredProperties>
|
||||||
|
</ArraySelectionDomain>
|
||||||
|
</StringVectorProperty>
|
||||||
|
|
||||||
|
<StringVectorProperty
|
||||||
|
name="RegionArrayInfo"
|
||||||
|
information_only="1">
|
||||||
|
<ArraySelectionInformationHelper attribute_name="Region"/>
|
||||||
|
</StringVectorProperty>
|
||||||
|
<StringVectorProperty
|
||||||
|
name="RegionStatus"
|
||||||
|
command="SetRegionArrayStatus"
|
||||||
|
number_of_elements="0"
|
||||||
|
repeat_command="1"
|
||||||
|
number_of_elements_per_command="2"
|
||||||
|
element_types="2 0"
|
||||||
|
information_property="RegionArrayInfo">
|
||||||
|
<ArraySelectionDomain name="array_list">
|
||||||
|
<RequiredProperties>
|
||||||
|
<Property name="RegionArrayInfo"
|
||||||
|
function="ArrayList"/>
|
||||||
|
</RequiredProperties>
|
||||||
|
</ArraySelectionDomain>
|
||||||
|
</StringVectorProperty>
|
||||||
|
|
||||||
|
<StringVectorProperty
|
||||||
|
name="VolFieldArrayInfo"
|
||||||
|
information_only="1">
|
||||||
|
<ArraySelectionInformationHelper attribute_name="VolField"/>
|
||||||
|
</StringVectorProperty>
|
||||||
|
<StringVectorProperty
|
||||||
|
name="VolFieldStatus"
|
||||||
|
command="SetVolFieldArrayStatus"
|
||||||
|
number_of_elements="0"
|
||||||
|
repeat_command="1"
|
||||||
|
number_of_elements_per_command="2"
|
||||||
|
element_types="2 0"
|
||||||
|
information_property="VolFieldArrayInfo">
|
||||||
|
<ArraySelectionDomain name="array_list">
|
||||||
|
<RequiredProperties>
|
||||||
|
<Property name="VolFieldArrayInfo"
|
||||||
|
function="ArrayList"/>
|
||||||
|
</RequiredProperties>
|
||||||
|
</ArraySelectionDomain>
|
||||||
|
</StringVectorProperty>
|
||||||
|
|
||||||
|
<StringVectorProperty
|
||||||
|
name="PointFieldArrayInfo"
|
||||||
|
information_only="1">
|
||||||
|
<ArraySelectionInformationHelper attribute_name="PointField"/>
|
||||||
|
</StringVectorProperty>
|
||||||
|
<StringVectorProperty
|
||||||
|
name="PointFieldStatus"
|
||||||
|
command="SetPointFieldArrayStatus"
|
||||||
|
number_of_elements="0"
|
||||||
|
repeat_command="1"
|
||||||
|
number_of_elements_per_command="2"
|
||||||
|
element_types="2 0"
|
||||||
|
information_property="PointFieldArrayInfo">
|
||||||
|
<ArraySelectionDomain name="array_list">
|
||||||
|
<RequiredProperties>
|
||||||
|
<Property name="PointFieldArrayInfo"
|
||||||
|
function="ArrayList"/>
|
||||||
|
</RequiredProperties>
|
||||||
|
</ArraySelectionDomain>
|
||||||
|
</StringVectorProperty>
|
||||||
|
|
||||||
|
</SourceProxy>
|
||||||
|
</ProxyGroup>
|
||||||
|
</ServerManagerConfiguration>
|
||||||
@ -0,0 +1,71 @@
|
|||||||
|
<ModuleInterfaces>
|
||||||
|
<Library name="PVFoamReader"/>
|
||||||
|
<ServerManagerFile name="PVFoamReader.pvsm"/>
|
||||||
|
|
||||||
|
<Module name="FoamReader"
|
||||||
|
class="vtkPVAdvancedReaderModule"
|
||||||
|
root_name="Foam"
|
||||||
|
output="vtkDataSet"
|
||||||
|
module_type="Reader"
|
||||||
|
extensions=".foam"
|
||||||
|
file_description="Foam case">
|
||||||
|
|
||||||
|
<Source class="vtkFoamReader"/>
|
||||||
|
|
||||||
|
<LabeledToggle
|
||||||
|
label="Update GUI"
|
||||||
|
trace_name="UpdateGUI"
|
||||||
|
property="UpdateGUI"
|
||||||
|
help="To update GUI without execution toggle this Accept and Reset."/>
|
||||||
|
|
||||||
|
<LabeledToggle
|
||||||
|
label="Cache Mesh"
|
||||||
|
trace_name="CacheMesh"
|
||||||
|
property="CacheMesh"
|
||||||
|
help="Cache the FOAM mesh between GUI selection changes."/>
|
||||||
|
|
||||||
|
<Scale
|
||||||
|
property="TimeStep"
|
||||||
|
trace_name="TimeStep"
|
||||||
|
label="Time step"
|
||||||
|
display_entry="0"
|
||||||
|
display_value="1"
|
||||||
|
entry_and_label_on_top="0"
|
||||||
|
help="Select a time step."
|
||||||
|
keeps_timesteps="1"
|
||||||
|
range_source="TimeStepRange"/>
|
||||||
|
|
||||||
|
<VectorEntry
|
||||||
|
property="TimeStepLimits"
|
||||||
|
type="int"
|
||||||
|
trace_name="TimeStepLimits"
|
||||||
|
length="2"
|
||||||
|
label="Lower and Upper Times"
|
||||||
|
help="Maximum lower and upper number of time steps displayed in the selection list."/>
|
||||||
|
|
||||||
|
<ArraySelection
|
||||||
|
label_text="Time"
|
||||||
|
property="TimeStatus"
|
||||||
|
trace_name="TimeArrays"/>
|
||||||
|
|
||||||
|
<ArraySelection
|
||||||
|
label_text="Region"
|
||||||
|
property="RegionStatus"
|
||||||
|
trace_name="RegionArrays"/>
|
||||||
|
|
||||||
|
<ArraySelection
|
||||||
|
label_text="Vol Field"
|
||||||
|
property="VolFieldStatus"
|
||||||
|
trace_name="CellArrays"/>
|
||||||
|
|
||||||
|
<ArraySelection
|
||||||
|
label_text="Point Field"
|
||||||
|
property="PointFieldStatus"
|
||||||
|
trace_name="PointArrays"/>
|
||||||
|
|
||||||
|
<Documentation>
|
||||||
|
ParaView Foam reader module
|
||||||
|
</Documentation>
|
||||||
|
</Module>
|
||||||
|
|
||||||
|
</ModuleInterfaces>
|
||||||
@ -0,0 +1,154 @@
|
|||||||
|
<ServerManagerConfiguration>
|
||||||
|
<ProxyGroup name="sources">
|
||||||
|
<SourceProxy
|
||||||
|
|
||||||
|
name="FoamReader"
|
||||||
|
class="vtkFoamReader">
|
||||||
|
|
||||||
|
<StringVectorProperty
|
||||||
|
name="FileName"
|
||||||
|
command="SetFileName"
|
||||||
|
number_of_elements="1">
|
||||||
|
<StringListDomain name="files"/>
|
||||||
|
</StringVectorProperty>
|
||||||
|
|
||||||
|
<IntVectorProperty
|
||||||
|
name="UpdateGUI"
|
||||||
|
command="SetUpdateGUI"
|
||||||
|
number_of_elements="1"
|
||||||
|
default_values="0">
|
||||||
|
<BooleanDomain name="bool"/>
|
||||||
|
</IntVectorProperty>
|
||||||
|
|
||||||
|
<IntVectorProperty
|
||||||
|
name="CacheMesh"
|
||||||
|
command="SetCacheMesh"
|
||||||
|
number_of_elements="1"
|
||||||
|
default_values="1">
|
||||||
|
<BooleanDomain name="bool"/>
|
||||||
|
</IntVectorProperty>
|
||||||
|
|
||||||
|
<IntVectorProperty
|
||||||
|
name="TimeStepRangeInfo"
|
||||||
|
command="GetTimeStepRange"
|
||||||
|
information_only="1">
|
||||||
|
<SimpleIntInformationHelper/>
|
||||||
|
</IntVectorProperty>
|
||||||
|
<IntVectorProperty
|
||||||
|
name="TimeStep"
|
||||||
|
command="SetTimeStep"
|
||||||
|
number_of_elements="1"
|
||||||
|
animateable="1"
|
||||||
|
default_values="0">
|
||||||
|
<IntRangeDomain name="range">
|
||||||
|
<RequiredProperties>
|
||||||
|
<Property name="TimeStepRangeInfo" function="Range"/>
|
||||||
|
</RequiredProperties>
|
||||||
|
</IntRangeDomain>
|
||||||
|
</IntVectorProperty>
|
||||||
|
|
||||||
|
<IntVectorProperty
|
||||||
|
name="TimeStepLimitsInfo"
|
||||||
|
command="GetTimeStepLimits"
|
||||||
|
information_only="1">
|
||||||
|
<SimpleIntInformationHelper/>
|
||||||
|
</IntVectorProperty>
|
||||||
|
<IntVectorProperty
|
||||||
|
name="TimeStepLimits"
|
||||||
|
command="SetTimeStepLimits"
|
||||||
|
number_of_elements="2"
|
||||||
|
default_values="2 5" >
|
||||||
|
<IntRangeDomain name="range">
|
||||||
|
<RequiredProperties>
|
||||||
|
<Property name="TimeStepLimitsInfo" function="Range"/>
|
||||||
|
</RequiredProperties>
|
||||||
|
</IntRangeDomain>
|
||||||
|
</IntVectorProperty>
|
||||||
|
|
||||||
|
<StringVectorProperty
|
||||||
|
name="TimeArrayInfo"
|
||||||
|
information_only="1">
|
||||||
|
<ArraySelectionInformationHelper attribute_name="Time"/>
|
||||||
|
</StringVectorProperty>
|
||||||
|
<StringVectorProperty
|
||||||
|
name="TimeStatus"
|
||||||
|
command="SetTimeArrayStatus"
|
||||||
|
number_of_elements="0"
|
||||||
|
repeat_command="1"
|
||||||
|
number_of_elements_per_command="2"
|
||||||
|
element_types="2 0"
|
||||||
|
information_property="TimeArrayInfo">
|
||||||
|
<ArraySelectionDomain name="array_list">
|
||||||
|
<RequiredProperties>
|
||||||
|
<Property name="TimeArrayInfo"
|
||||||
|
function="ArrayList"/>
|
||||||
|
</RequiredProperties>
|
||||||
|
</ArraySelectionDomain>
|
||||||
|
</StringVectorProperty>
|
||||||
|
|
||||||
|
<StringVectorProperty
|
||||||
|
name="RegionArrayInfo"
|
||||||
|
information_only="1">
|
||||||
|
<ArraySelectionInformationHelper attribute_name="Region"/>
|
||||||
|
</StringVectorProperty>
|
||||||
|
<StringVectorProperty
|
||||||
|
name="RegionStatus"
|
||||||
|
command="SetRegionArrayStatus"
|
||||||
|
number_of_elements="0"
|
||||||
|
repeat_command="1"
|
||||||
|
number_of_elements_per_command="2"
|
||||||
|
element_types="2 0"
|
||||||
|
information_property="RegionArrayInfo">
|
||||||
|
<ArraySelectionDomain name="array_list">
|
||||||
|
<RequiredProperties>
|
||||||
|
<Property name="RegionArrayInfo"
|
||||||
|
function="ArrayList"/>
|
||||||
|
</RequiredProperties>
|
||||||
|
</ArraySelectionDomain>
|
||||||
|
</StringVectorProperty>
|
||||||
|
|
||||||
|
<StringVectorProperty
|
||||||
|
name="VolFieldArrayInfo"
|
||||||
|
information_only="1">
|
||||||
|
<ArraySelectionInformationHelper attribute_name="VolField"/>
|
||||||
|
</StringVectorProperty>
|
||||||
|
<StringVectorProperty
|
||||||
|
name="VolFieldStatus"
|
||||||
|
command="SetVolFieldArrayStatus"
|
||||||
|
number_of_elements="0"
|
||||||
|
repeat_command="1"
|
||||||
|
number_of_elements_per_command="2"
|
||||||
|
element_types="2 0"
|
||||||
|
information_property="VolFieldArrayInfo">
|
||||||
|
<ArraySelectionDomain name="array_list">
|
||||||
|
<RequiredProperties>
|
||||||
|
<Property name="VolFieldArrayInfo"
|
||||||
|
function="ArrayList"/>
|
||||||
|
</RequiredProperties>
|
||||||
|
</ArraySelectionDomain>
|
||||||
|
</StringVectorProperty>
|
||||||
|
|
||||||
|
<StringVectorProperty
|
||||||
|
name="PointFieldArrayInfo"
|
||||||
|
information_only="1">
|
||||||
|
<ArraySelectionInformationHelper attribute_name="PointField"/>
|
||||||
|
</StringVectorProperty>
|
||||||
|
<StringVectorProperty
|
||||||
|
name="PointFieldStatus"
|
||||||
|
command="SetPointFieldArrayStatus"
|
||||||
|
number_of_elements="0"
|
||||||
|
repeat_command="1"
|
||||||
|
number_of_elements_per_command="2"
|
||||||
|
element_types="2 0"
|
||||||
|
information_property="PointFieldArrayInfo">
|
||||||
|
<ArraySelectionDomain name="array_list">
|
||||||
|
<RequiredProperties>
|
||||||
|
<Property name="PointFieldArrayInfo"
|
||||||
|
function="ArrayList"/>
|
||||||
|
</RequiredProperties>
|
||||||
|
</ArraySelectionDomain>
|
||||||
|
</StringVectorProperty>
|
||||||
|
|
||||||
|
</SourceProxy>
|
||||||
|
</ProxyGroup>
|
||||||
|
</ServerManagerConfiguration>
|
||||||
@ -0,0 +1,71 @@
|
|||||||
|
<ModuleInterfaces>
|
||||||
|
<Library name="@PROJECT_NAME@"/>
|
||||||
|
<ServerManagerFile name="@PROJECT_NAME@.pvsm"/>
|
||||||
|
|
||||||
|
<Module name="FoamReader"
|
||||||
|
class="vtkPVAdvancedReaderModule"
|
||||||
|
root_name="Foam"
|
||||||
|
output="vtkDataSet"
|
||||||
|
module_type="Reader"
|
||||||
|
extensions=".foam"
|
||||||
|
file_description="Foam case">
|
||||||
|
|
||||||
|
<Source class="vtkFoamReader"/>
|
||||||
|
|
||||||
|
<LabeledToggle
|
||||||
|
label="Update GUI"
|
||||||
|
trace_name="UpdateGUI"
|
||||||
|
property="UpdateGUI"
|
||||||
|
help="To update GUI without execution toggle this Accept and Reset."/>
|
||||||
|
|
||||||
|
<LabeledToggle
|
||||||
|
label="Cache Mesh"
|
||||||
|
trace_name="CacheMesh"
|
||||||
|
property="CacheMesh"
|
||||||
|
help="Cache the FOAM mesh between GUI selection changes."/>
|
||||||
|
|
||||||
|
<Scale
|
||||||
|
property="TimeStep"
|
||||||
|
trace_name="TimeStep"
|
||||||
|
label="Time step"
|
||||||
|
display_entry="0"
|
||||||
|
display_value="1"
|
||||||
|
entry_and_label_on_top="0"
|
||||||
|
help="Select a time step."
|
||||||
|
keeps_timesteps="1"
|
||||||
|
range_source="TimeStepRange"/>
|
||||||
|
|
||||||
|
<VectorEntry
|
||||||
|
property="TimeStepLimits"
|
||||||
|
type="int"
|
||||||
|
trace_name="TimeStepLimits"
|
||||||
|
length="2"
|
||||||
|
label="Lower and Upper Times"
|
||||||
|
help="Maximum lower and upper number of time steps displayed in the selection list."/>
|
||||||
|
|
||||||
|
<ArraySelection
|
||||||
|
label_text="Time"
|
||||||
|
property="TimeStatus"
|
||||||
|
trace_name="TimeArrays"/>
|
||||||
|
|
||||||
|
<ArraySelection
|
||||||
|
label_text="Region"
|
||||||
|
property="RegionStatus"
|
||||||
|
trace_name="RegionArrays"/>
|
||||||
|
|
||||||
|
<ArraySelection
|
||||||
|
label_text="Vol Field"
|
||||||
|
property="VolFieldStatus"
|
||||||
|
trace_name="CellArrays"/>
|
||||||
|
|
||||||
|
<ArraySelection
|
||||||
|
label_text="Point Field"
|
||||||
|
property="PointFieldStatus"
|
||||||
|
trace_name="PointArrays"/>
|
||||||
|
|
||||||
|
<Documentation>
|
||||||
|
ParaView Foam reader module
|
||||||
|
</Documentation>
|
||||||
|
</Module>
|
||||||
|
|
||||||
|
</ModuleInterfaces>
|
||||||
@ -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
|
||||||
@ -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 <ctype.h>
|
||||||
|
|
||||||
|
#include "vtkFoamData.h"
|
||||||
|
#include "vtkObjectFactory.h"
|
||||||
|
|
||||||
|
vtkCxxRevisionMacro(vtkFoamData, "$Revision: 1.20 $");
|
||||||
|
vtkStandardNewMacro(vtkFoamData);
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
vtkFoamData::vtkFoamData()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
vtkFoamData::~vtkFoamData()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -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
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -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 <ctype.h>
|
||||||
|
|
||||||
|
#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<vtkFoamReader*>(clientdata)->SelectionModified();
|
||||||
|
}
|
||||||
|
|
||||||
|
void vtkFoamReader::SelectionModified()
|
||||||
|
{
|
||||||
|
Modified();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -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
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -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 <vtkstd/string>
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
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 <ButtonPress-1> {%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; tuple<da->GetNumberOfTuples(); 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<vtkPVWidget*, vtkPVWidget*>* map)
|
||||||
|
{
|
||||||
|
vtkPVWidget* clone = this->ClonePrototypeInternal(pvSource, map);
|
||||||
|
return vtkPVFoamSelectTimeSet::SafeDownCast(clone);
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void vtkPVFoamSelectTimeSet::CopyProperties(vtkPVWidget* clone,
|
||||||
|
vtkPVSource* pvSource,
|
||||||
|
vtkArrayMap<vtkPVWidget*, vtkPVWidget*>* 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;
|
||||||
|
}
|
||||||
@ -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<vtkPVWidget*, vtkPVWidget*>* 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<vtkPVWidget*, vtkPVWidget*>* 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
|
||||||
@ -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 <vtkstd/string>
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
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;
|
||||||
|
}
|
||||||
@ -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
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
vtkFoam.C
|
||||||
|
vtkFoamAddInternalMesh.C
|
||||||
|
vtkFoamAddPatch.C
|
||||||
|
|
||||||
|
LIB = $(FOAM_LIBBIN)/libvtkFoam
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
EXE_INC = \
|
||||||
|
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||||
|
-I$(ParaView_INST_DIR)/include \
|
||||||
|
-I../PVFoamReader
|
||||||
|
|
||||||
|
LIB_LIBS = \
|
||||||
|
-lfiniteVolume \
|
||||||
|
$(GLIBS)
|
||||||
@ -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<vtkIdType>(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<word>
|
||||||
|
(
|
||||||
|
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; i<maxStartTimes; i++)
|
||||||
|
{
|
||||||
|
reader->GetTimeSelection()
|
||||||
|
->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; i<Times.size(); i++)
|
||||||
|
{
|
||||||
|
reader->GetTimeSelection()
|
||||||
|
->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; i<nRegions; i++)
|
||||||
|
{
|
||||||
|
selectedRegions_[i] =
|
||||||
|
reader_->GetRegionSelection()->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<volScalarField>(reader_->GetVolFieldSelection(), objects);
|
||||||
|
addFields<volVectorField>(reader_->GetVolFieldSelection(), objects);
|
||||||
|
addFields<volSphericalTensorField>(reader_->GetVolFieldSelection(), objects);
|
||||||
|
addFields<volSymmTensorField>(reader_->GetVolFieldSelection(), objects);
|
||||||
|
addFields<volTensorField>(reader_->GetVolFieldSelection(), objects);
|
||||||
|
|
||||||
|
addFields<pointScalarField>(reader_->GetPointFieldSelection(), objects);
|
||||||
|
addFields<pointVectorField>(reader_->GetPointFieldSelection(), objects);
|
||||||
|
addFields<pointSphericalTensorField>(reader_->GetPointFieldSelection(), objects);
|
||||||
|
addFields<pointSymmTensorField>(reader_->GetPointFieldSelection(), objects);
|
||||||
|
addFields<pointTensorField>(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; i<reader_->GetNumberOfOutputs(); i++)
|
||||||
|
{
|
||||||
|
vtkUnstructuredGrid *vtkMesh =
|
||||||
|
vtkUnstructuredGrid::SafeDownCast(reader_->GetOutput(i));
|
||||||
|
|
||||||
|
vtkCellData* cellData = vtkMesh->GetCellData();
|
||||||
|
int numberOfCellArrays = cellData->GetNumberOfArrays();
|
||||||
|
|
||||||
|
wordList cellFieldNames(numberOfCellArrays);
|
||||||
|
for (int j=0; j<numberOfCellArrays; j++)
|
||||||
|
{
|
||||||
|
cellFieldNames[j] = cellData->GetArrayName(j);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int j=0; j<numberOfCellArrays; j++)
|
||||||
|
{
|
||||||
|
cellData->RemoveArray(cellFieldNames[j].c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
vtkPointData* pointData = vtkMesh->GetPointData();
|
||||||
|
int numberOfPointArrays = pointData->GetNumberOfArrays();
|
||||||
|
|
||||||
|
wordList pointFieldNames(numberOfPointArrays);
|
||||||
|
for (int j=0; j<numberOfPointArrays; j++)
|
||||||
|
{
|
||||||
|
pointFieldNames[j] = pointData->GetArrayName(j);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int j=0; j<numberOfPointArrays; j++)
|
||||||
|
{
|
||||||
|
pointData->RemoveArray(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<Foam::scalar>
|
||||||
|
(
|
||||||
|
mesh, pInterp, objects, reader_->GetVolFieldSelection()
|
||||||
|
);
|
||||||
|
convertVolFields<Foam::vector>
|
||||||
|
(
|
||||||
|
mesh, pInterp, objects, reader_->GetVolFieldSelection()
|
||||||
|
);
|
||||||
|
convertVolFields<Foam::sphericalTensor>
|
||||||
|
(
|
||||||
|
mesh, pInterp, objects, reader_->GetVolFieldSelection()
|
||||||
|
);
|
||||||
|
convertVolFields<Foam::symmTensor>
|
||||||
|
(
|
||||||
|
mesh, pInterp, objects, reader_->GetVolFieldSelection()
|
||||||
|
);
|
||||||
|
convertVolFields<Foam::tensor>
|
||||||
|
(
|
||||||
|
mesh, pInterp, objects, reader_->GetVolFieldSelection()
|
||||||
|
);
|
||||||
|
|
||||||
|
convertPointFields<Foam::scalar>
|
||||||
|
(
|
||||||
|
mesh, objects, reader_->GetPointFieldSelection()
|
||||||
|
);
|
||||||
|
convertPointFields<Foam::vector>
|
||||||
|
(
|
||||||
|
mesh, objects, reader_->GetPointFieldSelection()
|
||||||
|
);
|
||||||
|
convertPointFields<Foam::sphericalTensor>
|
||||||
|
(
|
||||||
|
mesh, objects, reader_->GetPointFieldSelection()
|
||||||
|
);
|
||||||
|
convertPointFields<Foam::symmTensor>
|
||||||
|
(
|
||||||
|
mesh, objects, reader_->GetPointFieldSelection()
|
||||||
|
);
|
||||||
|
convertPointFields<Foam::tensor>
|
||||||
|
(
|
||||||
|
mesh, objects, reader_->GetPointFieldSelection()
|
||||||
|
);
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Info<< "done" << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -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<argList> argsPtr_;
|
||||||
|
autoPtr<Time> dbPtr_;
|
||||||
|
fvMesh* meshPtr_;
|
||||||
|
|
||||||
|
//- Selected regions, [0] = internal mesh, [1-nPatches] = patches
|
||||||
|
boolList selectedRegions_;
|
||||||
|
|
||||||
|
//- Lables of cell-centres used as additional points when decomposing
|
||||||
|
// polyhedra
|
||||||
|
labelList addPointCellLabels_;
|
||||||
|
|
||||||
|
//- Label of original cell the decomposed cells are split from
|
||||||
|
labelList superCells_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Pad-out the time name to avoid bug in the GUI redraw
|
||||||
|
static string padTimeString(const string&);
|
||||||
|
|
||||||
|
//- Pad-out the patch name
|
||||||
|
static string padPatchString(const string&);
|
||||||
|
|
||||||
|
//- Find and set the selected time from all the methods of selection
|
||||||
|
static void setSelectedTime
|
||||||
|
(
|
||||||
|
Time& runTime,
|
||||||
|
vtkFoamReader* reader
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Update the selected regions
|
||||||
|
void updateSelectedRegions();
|
||||||
|
|
||||||
|
//- Convert the mesh according to the list of selected regions
|
||||||
|
void convertMesh();
|
||||||
|
|
||||||
|
//- Add the internal mesh to the set of Outputs if selected
|
||||||
|
void addInternalMesh(const fvMesh&, vtkUnstructuredGrid*);
|
||||||
|
|
||||||
|
//- Add the internal patch to the set of Outputs if selected
|
||||||
|
void addPatch(const polyPatch&, vtkUnstructuredGrid*);
|
||||||
|
|
||||||
|
//- Add the fields in th selested time directory to the selection lists
|
||||||
|
template<class GeoField>
|
||||||
|
void addFields
|
||||||
|
(
|
||||||
|
vtkDataArraySelection *fieldSelection,
|
||||||
|
const IOobjectList& objects
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Convert the selected volFields
|
||||||
|
template<class Type>
|
||||||
|
void convertVolFields
|
||||||
|
(
|
||||||
|
const fvMesh& mesh,
|
||||||
|
const volPointInterpolation& pInterp,
|
||||||
|
const IOobjectList& objects,
|
||||||
|
vtkDataArraySelection *fieldSelection
|
||||||
|
);
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void convertVolField
|
||||||
|
(
|
||||||
|
const GeometricField<Type, fvPatchField, volMesh>& tf
|
||||||
|
);
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void convertPatchFaceField
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const Field<Type>& tf,
|
||||||
|
const label regioni
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Convert the selected pointFields
|
||||||
|
template<class Type>
|
||||||
|
void convertPointFields
|
||||||
|
(
|
||||||
|
const fvMesh& mesh,
|
||||||
|
const IOobjectList& objects,
|
||||||
|
vtkDataArraySelection *fieldSelection
|
||||||
|
);
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void convertPointField
|
||||||
|
(
|
||||||
|
const GeometricField<Type, pointPatchField, pointMesh>& ptf,
|
||||||
|
const GeometricField<Type, fvPatchField, volMesh>& tf
|
||||||
|
);
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void convertPatchPointField
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const Field<Type>& tf,
|
||||||
|
const label regioni
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Set the name of the Output vtkUnstructuredGrid
|
||||||
|
void SetName(vtkUnstructuredGrid *vtkMesh, const char* name);
|
||||||
|
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
vtkFoam(const vtkFoam&);
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const vtkFoam&);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Static data members
|
||||||
|
|
||||||
|
ClassName("vtkFoam");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
vtkFoam(const char* const FileName, vtkFoamReader* reader);
|
||||||
|
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
|
||||||
|
~vtkFoam();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
void UpdateInformation();
|
||||||
|
void Update();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Template Specialisations * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<>
|
||||||
|
void vtkFoam::convertVolField
|
||||||
|
(
|
||||||
|
const GeometricField<scalar, fvPatchField, volMesh>& sf
|
||||||
|
);
|
||||||
|
|
||||||
|
template<>
|
||||||
|
void vtkFoam::convertPatchFaceField
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const Field<scalar>& sf,
|
||||||
|
const label regioni
|
||||||
|
);
|
||||||
|
|
||||||
|
template<>
|
||||||
|
void vtkFoam::convertPointField
|
||||||
|
(
|
||||||
|
const GeometricField<scalar, pointPatchField, pointMesh>& psf,
|
||||||
|
const GeometricField<scalar, fvPatchField, volMesh>& sf
|
||||||
|
);
|
||||||
|
|
||||||
|
template<>
|
||||||
|
void vtkFoam::convertPatchPointField
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const Field<scalar>& sf,
|
||||||
|
const label regioni
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,60 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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
|
||||||
|
|
||||||
|
InClass
|
||||||
|
Foam::vtkFoam
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef vtkFoamAddFields_H
|
||||||
|
#define vtkFoamAddFields_H
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class GeoField>
|
||||||
|
void Foam::vtkFoam::addFields
|
||||||
|
(
|
||||||
|
vtkDataArraySelection *fieldSelection,
|
||||||
|
const IOobjectList& objects
|
||||||
|
)
|
||||||
|
{
|
||||||
|
IOobjectList fieldObjects(objects.lookupClass(GeoField::typeName));
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
IOobjectList::iterator iter = fieldObjects.begin();
|
||||||
|
iter != fieldObjects.end();
|
||||||
|
++iter
|
||||||
|
)
|
||||||
|
{
|
||||||
|
fieldSelection->AddArray(iter()->name().c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,299 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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 "vtkFoam.H"
|
||||||
|
#include "fvMesh.H"
|
||||||
|
#include "cellModeller.H"
|
||||||
|
|
||||||
|
#include "vtkUnstructuredGrid.h"
|
||||||
|
#include "vtkCellArray.h"
|
||||||
|
|
||||||
|
#include "vtkFoamInsertNextPoint.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::vtkFoam::addInternalMesh
|
||||||
|
(
|
||||||
|
const fvMesh& mesh,
|
||||||
|
vtkUnstructuredGrid* vtkMesh
|
||||||
|
)
|
||||||
|
{
|
||||||
|
SetName(vtkMesh, "Internal Mesh");
|
||||||
|
|
||||||
|
// Number of additional points needed by the decomposition of polyhedra
|
||||||
|
label nAddPoints = 0;
|
||||||
|
|
||||||
|
// Number of additional cells generated by the decomposition of polyhedra
|
||||||
|
label nAddCells = 0;
|
||||||
|
|
||||||
|
const cellModel& tet = *(cellModeller::lookup("tet"));
|
||||||
|
const cellModel& pyr = *(cellModeller::lookup("pyr"));
|
||||||
|
const cellModel& prism = *(cellModeller::lookup("prism"));
|
||||||
|
const cellModel& wedge = *(cellModeller::lookup("wedge"));
|
||||||
|
const cellModel& tetWedge = *(cellModeller::lookup("tetWedge"));
|
||||||
|
const cellModel& hex = *(cellModeller::lookup("hex"));
|
||||||
|
|
||||||
|
// Scan for cells which need to be decomposed and count additional points
|
||||||
|
// and cells
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Info<< "building cell-shapes" << endl;
|
||||||
|
}
|
||||||
|
const cellShapeList& cellShapes = mesh.cellShapes();
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Info<< "scanning" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
forAll(cellShapes, cellI)
|
||||||
|
{
|
||||||
|
const cellModel& model = cellShapes[cellI].model();
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
model != hex
|
||||||
|
&& model != wedge
|
||||||
|
&& model != prism
|
||||||
|
&& model != pyr
|
||||||
|
&& model != tet
|
||||||
|
&& model != tetWedge
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const cell& cFaces = mesh.cells()[cellI];
|
||||||
|
|
||||||
|
forAll(cFaces, cFaceI)
|
||||||
|
{
|
||||||
|
const face& f = mesh.faces()[cFaces[cFaceI]];
|
||||||
|
|
||||||
|
label nFacePoints = f.size();
|
||||||
|
|
||||||
|
label nQuads = (nFacePoints - 2)/2;
|
||||||
|
label nTris = (nFacePoints - 2)%2;
|
||||||
|
nAddCells += nQuads + nTris;
|
||||||
|
}
|
||||||
|
|
||||||
|
nAddCells--;
|
||||||
|
nAddPoints++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set size of additional point addressing array
|
||||||
|
// (from added point to original cell)
|
||||||
|
addPointCellLabels_.setSize(nAddPoints);
|
||||||
|
|
||||||
|
// Set size of additional cells mapping array
|
||||||
|
// (from added cell to original cell)
|
||||||
|
superCells_.setSize(mesh.nCells() + nAddCells);
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Info<< "converting points" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert Foam mesh vertices to VTK
|
||||||
|
vtkPoints *vtkpoints = vtkPoints::New();
|
||||||
|
vtkpoints->Allocate(mesh.nPoints() + nAddPoints);
|
||||||
|
|
||||||
|
const Foam::pointField& points = mesh.points();
|
||||||
|
|
||||||
|
forAll(points, i)
|
||||||
|
{
|
||||||
|
vtkFoamInsertNextPoint(vtkpoints, points[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Info<< "converting cells" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
vtkMesh->Allocate(mesh.nCells() + nAddCells);
|
||||||
|
|
||||||
|
// Set counters for additional points and additional cells
|
||||||
|
label api = 0, aci = 0;
|
||||||
|
|
||||||
|
forAll(cellShapes, celli)
|
||||||
|
{
|
||||||
|
const cellShape& cellShape = cellShapes[celli];
|
||||||
|
const cellModel& cellModel = cellShape.model();
|
||||||
|
|
||||||
|
superCells_[aci++] = celli;
|
||||||
|
|
||||||
|
if (cellModel == tet)
|
||||||
|
{
|
||||||
|
vtkMesh->InsertNextCell
|
||||||
|
(
|
||||||
|
VTK_TETRA,
|
||||||
|
4,
|
||||||
|
const_cast<int*>(cellShape.begin())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (cellModel == pyr)
|
||||||
|
{
|
||||||
|
vtkMesh->InsertNextCell
|
||||||
|
(
|
||||||
|
VTK_PYRAMID,
|
||||||
|
5,
|
||||||
|
const_cast<int*>(cellShape.begin())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (cellModel == prism)
|
||||||
|
{
|
||||||
|
vtkMesh->InsertNextCell
|
||||||
|
(
|
||||||
|
VTK_WEDGE,
|
||||||
|
6,
|
||||||
|
const_cast<int*>(cellShape.begin())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (cellModel == tetWedge)
|
||||||
|
{
|
||||||
|
// Treat as squeezed prism
|
||||||
|
|
||||||
|
int vtkVerts[6];
|
||||||
|
vtkVerts[0] = cellShape[0];
|
||||||
|
vtkVerts[1] = cellShape[2];
|
||||||
|
vtkVerts[2] = cellShape[1];
|
||||||
|
vtkVerts[3] = cellShape[3];
|
||||||
|
vtkVerts[4] = cellShape[4];
|
||||||
|
vtkVerts[5] = cellShape[4];
|
||||||
|
|
||||||
|
vtkMesh->InsertNextCell(VTK_WEDGE, 6, vtkVerts);
|
||||||
|
}
|
||||||
|
else if (cellModel == wedge)
|
||||||
|
{
|
||||||
|
// Treat as squeezed hex
|
||||||
|
|
||||||
|
int vtkVerts[8];
|
||||||
|
vtkVerts[0] = cellShape[0];
|
||||||
|
vtkVerts[1] = cellShape[1];
|
||||||
|
vtkVerts[2] = cellShape[2];
|
||||||
|
vtkVerts[3] = cellShape[2];
|
||||||
|
vtkVerts[4] = cellShape[3];
|
||||||
|
vtkVerts[5] = cellShape[4];
|
||||||
|
vtkVerts[6] = cellShape[5];
|
||||||
|
vtkVerts[7] = cellShape[6];
|
||||||
|
|
||||||
|
vtkMesh->InsertNextCell(VTK_HEXAHEDRON, 8, vtkVerts);
|
||||||
|
}
|
||||||
|
else if (cellModel == hex)
|
||||||
|
{
|
||||||
|
vtkMesh->InsertNextCell
|
||||||
|
(
|
||||||
|
VTK_HEXAHEDRON,
|
||||||
|
8,
|
||||||
|
const_cast<int*>(cellShape.begin())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Polyhedral cell. Decompose into tets + prisms.
|
||||||
|
|
||||||
|
// Mapping from additional point to cell
|
||||||
|
addPointCellLabels_[api] = celli;
|
||||||
|
|
||||||
|
// Insert the new vertex from the cell-centre
|
||||||
|
label newVertexLabel = mesh.nPoints() + api;
|
||||||
|
vtkFoamInsertNextPoint(vtkpoints, mesh.C()[celli]);
|
||||||
|
|
||||||
|
// Whether to insert cell in place of original or not.
|
||||||
|
bool substituteCell = true;
|
||||||
|
|
||||||
|
const labelList& cFaces = mesh.cells()[celli];
|
||||||
|
|
||||||
|
forAll(cFaces, cFaceI)
|
||||||
|
{
|
||||||
|
const face& f = mesh.faces()[cFaces[cFaceI]];
|
||||||
|
|
||||||
|
label nFacePoints = f.size();
|
||||||
|
|
||||||
|
label nQuads = (nFacePoints - 2)/2;
|
||||||
|
label nTris = (nFacePoints - 2)%2;
|
||||||
|
|
||||||
|
label qpi = 0;
|
||||||
|
|
||||||
|
for (label quadi=0; quadi<nQuads; quadi++)
|
||||||
|
{
|
||||||
|
label thisCellI = -1;
|
||||||
|
|
||||||
|
if (substituteCell)
|
||||||
|
{
|
||||||
|
thisCellI = celli;
|
||||||
|
substituteCell = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
thisCellI = mesh.nCells() + aci;
|
||||||
|
superCells_[aci++] = celli;
|
||||||
|
}
|
||||||
|
|
||||||
|
int addVtkVerts[5];
|
||||||
|
addVtkVerts[0] = f[0];
|
||||||
|
addVtkVerts[1] = f[qpi + 1];
|
||||||
|
addVtkVerts[2] = f[qpi + 2];
|
||||||
|
addVtkVerts[3] = f[qpi + 3];
|
||||||
|
addVtkVerts[4] = newVertexLabel;
|
||||||
|
vtkMesh->InsertNextCell(VTK_PYRAMID, 5, addVtkVerts);
|
||||||
|
|
||||||
|
qpi += 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nTris)
|
||||||
|
{
|
||||||
|
label thisCellI = -1;
|
||||||
|
|
||||||
|
if (substituteCell)
|
||||||
|
{
|
||||||
|
thisCellI = celli;
|
||||||
|
substituteCell = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
thisCellI = mesh.nCells() + aci;
|
||||||
|
superCells_[aci++] = celli;
|
||||||
|
}
|
||||||
|
|
||||||
|
int addVtkVerts[4];
|
||||||
|
addVtkVerts[0] = f[0];
|
||||||
|
addVtkVerts[1] = f[qpi + 1];
|
||||||
|
addVtkVerts[2] = f[qpi + 2];
|
||||||
|
addVtkVerts[3] = newVertexLabel;
|
||||||
|
vtkMesh->InsertNextCell(VTK_TETRA, 4, addVtkVerts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
api++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vtkMesh->SetPoints(vtkpoints);
|
||||||
|
vtkpoints->Delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,115 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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 "vtkFoam.H"
|
||||||
|
#include "polyPatch.H"
|
||||||
|
|
||||||
|
#include "vtkUnstructuredGrid.h"
|
||||||
|
#include "vtkCellArray.h"
|
||||||
|
|
||||||
|
#include "vtkFoamInsertNextPoint.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::vtkFoam::addPatch
|
||||||
|
(
|
||||||
|
const polyPatch& p,
|
||||||
|
vtkUnstructuredGrid *vtkPatch
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Info<< "Adding patch " << p.name() << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetName(vtkPatch, p.name().c_str());
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Info<< "converting points" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Foam::pointField& points = p.localPoints();
|
||||||
|
|
||||||
|
// Convert Foam mesh vertices to VTK
|
||||||
|
vtkPoints *vtkpoints = vtkPoints::New();
|
||||||
|
vtkpoints->Allocate(points.size());
|
||||||
|
|
||||||
|
forAll(points, i)
|
||||||
|
{
|
||||||
|
vtkFoamInsertNextPoint(vtkpoints, points[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Info<< "converting faces" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
const faceList& faces = p.localFaces();
|
||||||
|
|
||||||
|
vtkPatch->Allocate(faces.size());
|
||||||
|
|
||||||
|
forAll(faces, facei)
|
||||||
|
{
|
||||||
|
const face& f = faces[facei];
|
||||||
|
|
||||||
|
if (f.size() == 3)
|
||||||
|
{
|
||||||
|
vtkPatch->InsertNextCell
|
||||||
|
(
|
||||||
|
VTK_TRIANGLE,
|
||||||
|
3,
|
||||||
|
const_cast<int*>(f.begin())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (f.size() == 4)
|
||||||
|
{
|
||||||
|
vtkPatch->InsertNextCell
|
||||||
|
(
|
||||||
|
VTK_QUAD,
|
||||||
|
4,
|
||||||
|
const_cast<int*>(f.begin())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vtkPatch->InsertNextCell
|
||||||
|
(
|
||||||
|
VTK_POLYGON,
|
||||||
|
f.size(),
|
||||||
|
const_cast<int*>(f.begin())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vtkPatch->SetPoints(vtkpoints);
|
||||||
|
vtkpoints->Delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,235 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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
|
||||||
|
|
||||||
|
InClass
|
||||||
|
Foam::vtkFoam
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef vtkFoamConvertFields_H
|
||||||
|
#define vtkFoamConvertFields_H
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#include "vtkFoamConvertVolField.H"
|
||||||
|
#include "vtkFoamConvertPointField.H"
|
||||||
|
|
||||||
|
#include "vtkFoamConvertPatchFaceField.H"
|
||||||
|
#include "vtkFoamConvertPatchPointField.H"
|
||||||
|
|
||||||
|
#include "emptyFvPatchField.H"
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::vtkFoam::convertVolFields
|
||||||
|
(
|
||||||
|
const fvMesh& mesh,
|
||||||
|
const volPointInterpolation& pInterp,
|
||||||
|
const IOobjectList& objects,
|
||||||
|
vtkDataArraySelection *fieldSelection
|
||||||
|
)
|
||||||
|
{
|
||||||
|
IOobjectList fieldObjects
|
||||||
|
(
|
||||||
|
objects.lookupClass
|
||||||
|
(
|
||||||
|
GeometricField<Type, fvPatchField, volMesh>::typeName
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
label nSelectedFields = fieldSelection->GetNumberOfArrays();
|
||||||
|
|
||||||
|
for (label i=0; i<nSelectedFields; i++)
|
||||||
|
{
|
||||||
|
if(fieldSelection->GetArraySetting(i))
|
||||||
|
{
|
||||||
|
word fieldName = fieldSelection->GetArrayName(i);
|
||||||
|
|
||||||
|
if (fieldObjects.found(fieldName))
|
||||||
|
{
|
||||||
|
GeometricField<Type, fvPatchField, volMesh> tf
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
fieldName,
|
||||||
|
mesh.time().timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::MUST_READ
|
||||||
|
),
|
||||||
|
mesh
|
||||||
|
);
|
||||||
|
|
||||||
|
tmp<GeometricField<Type, pointPatchField, pointMesh> > tptf
|
||||||
|
(
|
||||||
|
pInterp.interpolate(tf)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (selectedRegions_[0])
|
||||||
|
{
|
||||||
|
convertVolField(tf);
|
||||||
|
convertPointField(tptf(), tf);
|
||||||
|
}
|
||||||
|
|
||||||
|
label regioni = 0;
|
||||||
|
forAll (mesh.boundaryMesh(), patchi)
|
||||||
|
{
|
||||||
|
if (mesh.boundaryMesh()[patchi].size())
|
||||||
|
{
|
||||||
|
regioni++;
|
||||||
|
|
||||||
|
if (selectedRegions_[regioni])
|
||||||
|
{
|
||||||
|
const fvPatchField<Type>& ptf
|
||||||
|
(
|
||||||
|
tf.boundaryField()[patchi]
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!isType<emptyFvPatchField<Type> >(ptf))
|
||||||
|
{
|
||||||
|
convertPatchFaceField
|
||||||
|
(
|
||||||
|
tf.name(),
|
||||||
|
ptf,
|
||||||
|
regioni
|
||||||
|
);
|
||||||
|
|
||||||
|
convertPatchPointField
|
||||||
|
(
|
||||||
|
tptf().name(),
|
||||||
|
tptf().boundaryField()[patchi]
|
||||||
|
.patchInternalField()(),
|
||||||
|
regioni
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fvPatch p
|
||||||
|
(
|
||||||
|
ptf.patch().patch(),
|
||||||
|
tf.mesh().boundary()
|
||||||
|
);
|
||||||
|
|
||||||
|
convertPatchFaceField
|
||||||
|
(
|
||||||
|
tf.name(),
|
||||||
|
fvPatchField<Type>(p, tf)
|
||||||
|
.patchInternalField()(),
|
||||||
|
regioni
|
||||||
|
);
|
||||||
|
|
||||||
|
convertPatchPointField
|
||||||
|
(
|
||||||
|
tptf().name(),
|
||||||
|
tptf().boundaryField()[patchi]
|
||||||
|
.patchInternalField()(),
|
||||||
|
regioni
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::vtkFoam::convertPointFields
|
||||||
|
(
|
||||||
|
const fvMesh& mesh,
|
||||||
|
const IOobjectList& objects,
|
||||||
|
vtkDataArraySelection *fieldSelection
|
||||||
|
)
|
||||||
|
{
|
||||||
|
IOobjectList fieldObjects
|
||||||
|
(
|
||||||
|
objects.lookupClass
|
||||||
|
(
|
||||||
|
GeometricField<Type, pointPatchField, pointMesh>::typeName
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
label nSelectedFields = fieldSelection->GetNumberOfArrays();
|
||||||
|
|
||||||
|
for (label i=0; i<nSelectedFields; i++)
|
||||||
|
{
|
||||||
|
if(fieldSelection->GetArraySetting(i))
|
||||||
|
{
|
||||||
|
word fieldName = fieldSelection->GetArrayName(i);
|
||||||
|
|
||||||
|
if (fieldObjects.found(fieldName))
|
||||||
|
{
|
||||||
|
pointMesh pMesh(mesh);
|
||||||
|
|
||||||
|
GeometricField<Type, pointPatchField, pointMesh> ptf
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
fieldName,
|
||||||
|
mesh.time().timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::MUST_READ
|
||||||
|
),
|
||||||
|
pMesh
|
||||||
|
);
|
||||||
|
|
||||||
|
if (selectedRegions_[0])
|
||||||
|
{
|
||||||
|
convertPointField
|
||||||
|
(
|
||||||
|
ptf,
|
||||||
|
GeometricField<Type, fvPatchField, volMesh>::null()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
label regioni = 0;
|
||||||
|
forAll (mesh.boundaryMesh(), patchi)
|
||||||
|
{
|
||||||
|
if (mesh.boundaryMesh()[patchi].size())
|
||||||
|
{
|
||||||
|
regioni++;
|
||||||
|
|
||||||
|
if (selectedRegions_[regioni])
|
||||||
|
{
|
||||||
|
convertPatchPointField
|
||||||
|
(
|
||||||
|
ptf.name(),
|
||||||
|
ptf.boundaryField()[patchi]
|
||||||
|
.patchInternalField()(),
|
||||||
|
regioni
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,106 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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
|
||||||
|
|
||||||
|
InClass
|
||||||
|
Foam::vtkFoam
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef vtkFoamConvertPatchFaceField_H
|
||||||
|
#define vtkFoamConvertPatchFaceField_H
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::vtkFoam::convertPatchFaceField
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const Field<Type>& ptf,
|
||||||
|
const label regioni
|
||||||
|
)
|
||||||
|
{
|
||||||
|
vtkUnstructuredGrid *vtkMesh =
|
||||||
|
vtkUnstructuredGrid::SafeDownCast(reader_->GetOutput(regioni));
|
||||||
|
|
||||||
|
vtkFloatArray *cellTypes = vtkFloatArray::New();
|
||||||
|
cellTypes->SetNumberOfTuples(ptf.size());
|
||||||
|
cellTypes->SetNumberOfComponents(Type::nComponents);
|
||||||
|
cellTypes->Allocate(Type::nComponents*ptf.size());
|
||||||
|
cellTypes->SetName(name.c_str());
|
||||||
|
|
||||||
|
float vec[Type::nComponents];
|
||||||
|
|
||||||
|
forAll(ptf, i)
|
||||||
|
{
|
||||||
|
const Type& t = ptf[i];
|
||||||
|
for (direction d=0; d<Type::nComponents; d++)
|
||||||
|
{
|
||||||
|
vec[d] = t[d];
|
||||||
|
}
|
||||||
|
|
||||||
|
cellTypes->InsertTuple(i, vec);
|
||||||
|
}
|
||||||
|
|
||||||
|
vtkMesh->GetCellData()->AddArray(cellTypes);
|
||||||
|
cellTypes->Delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<>
|
||||||
|
void Foam::vtkFoam::convertPatchFaceField
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const Field<scalar>& psf,
|
||||||
|
const label regioni
|
||||||
|
)
|
||||||
|
{
|
||||||
|
vtkUnstructuredGrid *vtkMesh =
|
||||||
|
vtkUnstructuredGrid::SafeDownCast(reader_->GetOutput(regioni));
|
||||||
|
|
||||||
|
vtkFloatArray *cellScalars = vtkFloatArray::New();
|
||||||
|
cellScalars->SetNumberOfTuples(psf.size());
|
||||||
|
cellScalars->SetNumberOfComponents(1);
|
||||||
|
cellScalars->Allocate(psf.size());
|
||||||
|
cellScalars->SetName(name.c_str());
|
||||||
|
|
||||||
|
forAll(psf, i)
|
||||||
|
{
|
||||||
|
cellScalars->InsertComponent(i, 0, psf[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
vtkMesh->GetCellData()->AddArray(cellScalars);
|
||||||
|
if (!vtkMesh->GetCellData()->GetScalars())
|
||||||
|
{
|
||||||
|
vtkMesh->GetCellData()->SetScalars(cellScalars);
|
||||||
|
}
|
||||||
|
|
||||||
|
cellScalars->Delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,105 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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
|
||||||
|
|
||||||
|
InClass
|
||||||
|
Foam::vtkFoam
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef vtkFoamConvertPatchPointField_H
|
||||||
|
#define vtkFoamConvertPatchPointField_H
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::vtkFoam::convertPatchPointField
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const Field<Type>& pptf,
|
||||||
|
const label regioni
|
||||||
|
)
|
||||||
|
{
|
||||||
|
vtkUnstructuredGrid *vtkMesh =
|
||||||
|
vtkUnstructuredGrid::SafeDownCast(reader_->GetOutput(regioni));
|
||||||
|
|
||||||
|
vtkFloatArray *pointTypes = vtkFloatArray::New();
|
||||||
|
pointTypes->SetNumberOfTuples(pptf.size());
|
||||||
|
pointTypes->SetNumberOfComponents(Type::nComponents);
|
||||||
|
pointTypes->Allocate(Type::nComponents*pptf.size());
|
||||||
|
pointTypes->SetName(name.c_str());
|
||||||
|
|
||||||
|
float vec[Type::nComponents];
|
||||||
|
|
||||||
|
forAll(pptf, i)
|
||||||
|
{
|
||||||
|
for (direction d=0; d<Type::nComponents; d++)
|
||||||
|
{
|
||||||
|
vec[d] = pptf[i][d];
|
||||||
|
}
|
||||||
|
|
||||||
|
pointTypes->InsertTuple(i, vec);
|
||||||
|
}
|
||||||
|
|
||||||
|
vtkMesh->GetPointData()->AddArray(pointTypes);
|
||||||
|
pointTypes->Delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<>
|
||||||
|
void Foam::vtkFoam::convertPatchPointField
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const Field<scalar>& ppsf,
|
||||||
|
const label regioni
|
||||||
|
)
|
||||||
|
{
|
||||||
|
vtkUnstructuredGrid *vtkMesh =
|
||||||
|
vtkUnstructuredGrid::SafeDownCast(reader_->GetOutput(regioni));
|
||||||
|
|
||||||
|
vtkFloatArray *pointScalars = vtkFloatArray::New();
|
||||||
|
pointScalars->SetNumberOfTuples(ppsf.size());
|
||||||
|
pointScalars->SetNumberOfComponents(1);
|
||||||
|
pointScalars->Allocate(ppsf.size());
|
||||||
|
pointScalars->SetName(name.c_str());
|
||||||
|
|
||||||
|
for (int i=0; i<ppsf.size(); i++)
|
||||||
|
{
|
||||||
|
pointScalars->InsertComponent(i, 0, ppsf[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
vtkMesh->GetPointData()->AddArray(pointScalars);
|
||||||
|
if (!vtkMesh->GetPointData()->GetScalars())
|
||||||
|
{
|
||||||
|
vtkMesh->GetPointData()->SetScalars(pointScalars);
|
||||||
|
}
|
||||||
|
|
||||||
|
pointScalars->Delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,163 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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
|
||||||
|
|
||||||
|
InClass
|
||||||
|
Foam::vtkFoam
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef vtkFoamConvertPointField_H
|
||||||
|
#define vtkFoamConvertPointField_H
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#include "interpolatePointToCell.H"
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::vtkFoam::convertPointField
|
||||||
|
(
|
||||||
|
const GeometricField<Type, pointPatchField, pointMesh>& ptf,
|
||||||
|
const GeometricField<Type, fvPatchField, volMesh>& tf
|
||||||
|
)
|
||||||
|
{
|
||||||
|
vtkUnstructuredGrid *vtkMesh =
|
||||||
|
vtkUnstructuredGrid::SafeDownCast(reader_->GetOutput(0));
|
||||||
|
|
||||||
|
vtkFloatArray *pointTypes = vtkFloatArray::New();
|
||||||
|
pointTypes->SetNumberOfTuples(ptf.size() + addPointCellLabels_.size());
|
||||||
|
pointTypes->SetNumberOfComponents(Type::nComponents);
|
||||||
|
pointTypes->Allocate(Type::nComponents*ptf.size());
|
||||||
|
pointTypes->SetName(ptf.name().c_str());
|
||||||
|
|
||||||
|
float vec[Type::nComponents];
|
||||||
|
|
||||||
|
forAll(ptf, i)
|
||||||
|
{
|
||||||
|
for (direction d=0; d<Type::nComponents; d++)
|
||||||
|
{
|
||||||
|
vec[d] = ptf[i][d];
|
||||||
|
}
|
||||||
|
|
||||||
|
pointTypes->InsertTuple(i, vec);
|
||||||
|
}
|
||||||
|
|
||||||
|
label i = ptf.size();
|
||||||
|
|
||||||
|
if (&tf != &GeometricField<Type, fvPatchField, volMesh>::null())
|
||||||
|
{
|
||||||
|
forAll(addPointCellLabels_, api)
|
||||||
|
{
|
||||||
|
Type t = tf[addPointCellLabels_[api]];
|
||||||
|
|
||||||
|
for (direction d=0; d<Type::nComponents; d++)
|
||||||
|
{
|
||||||
|
vec[d] = t[d];
|
||||||
|
}
|
||||||
|
|
||||||
|
pointTypes->InsertTuple(i++, vec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
forAll(addPointCellLabels_, api)
|
||||||
|
{
|
||||||
|
Type t = interpolatePointToCell(ptf, addPointCellLabels_[api]);
|
||||||
|
|
||||||
|
for (direction d=0; d<Type::nComponents; d++)
|
||||||
|
{
|
||||||
|
vec[d] = t[d];
|
||||||
|
}
|
||||||
|
|
||||||
|
pointTypes->InsertTuple(i++, vec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vtkMesh->GetPointData()->AddArray(pointTypes);
|
||||||
|
pointTypes->Delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<>
|
||||||
|
void Foam::vtkFoam::convertPointField
|
||||||
|
(
|
||||||
|
const GeometricField<scalar, pointPatchField, pointMesh>& psf,
|
||||||
|
const GeometricField<scalar, fvPatchField, volMesh>& sf
|
||||||
|
)
|
||||||
|
{
|
||||||
|
vtkUnstructuredGrid *vtkMesh =
|
||||||
|
vtkUnstructuredGrid::SafeDownCast(reader_->GetOutput(0));
|
||||||
|
|
||||||
|
vtkFloatArray *pointScalars = vtkFloatArray::New();
|
||||||
|
pointScalars->SetNumberOfTuples(psf.size() + addPointCellLabels_.size());
|
||||||
|
pointScalars->SetNumberOfComponents(1);
|
||||||
|
pointScalars->Allocate(psf.size());
|
||||||
|
pointScalars->SetName(psf.name().c_str());
|
||||||
|
|
||||||
|
for (int i=0; i<psf.size(); i++)
|
||||||
|
{
|
||||||
|
pointScalars->InsertComponent(i, 0, psf[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
label i = psf.size();
|
||||||
|
|
||||||
|
if (&sf != &GeometricField<scalar, fvPatchField, volMesh>::null())
|
||||||
|
{
|
||||||
|
forAll(addPointCellLabels_, api)
|
||||||
|
{
|
||||||
|
pointScalars->InsertComponent
|
||||||
|
(
|
||||||
|
i++,
|
||||||
|
0,
|
||||||
|
sf[addPointCellLabels_[api]]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
forAll(addPointCellLabels_, api)
|
||||||
|
{
|
||||||
|
pointScalars->InsertComponent
|
||||||
|
(
|
||||||
|
i++,
|
||||||
|
0,
|
||||||
|
interpolatePointToCell(psf, addPointCellLabels_[api])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vtkMesh->GetPointData()->AddArray(pointScalars);
|
||||||
|
if (!vtkMesh->GetPointData()->GetScalars())
|
||||||
|
{
|
||||||
|
vtkMesh->GetPointData()->SetScalars(pointScalars);
|
||||||
|
}
|
||||||
|
|
||||||
|
pointScalars->Delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,102 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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
|
||||||
|
|
||||||
|
InClass
|
||||||
|
Foam::vtkFoam
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef vtkFoamConvertVolField_H
|
||||||
|
#define vtkFoamConvertVolField_H
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::vtkFoam::convertVolField
|
||||||
|
(
|
||||||
|
const GeometricField<Type, fvPatchField, volMesh>& tf
|
||||||
|
)
|
||||||
|
{
|
||||||
|
vtkUnstructuredGrid *vtkMesh =
|
||||||
|
vtkUnstructuredGrid::SafeDownCast(reader_->GetOutput(0));
|
||||||
|
|
||||||
|
vtkFloatArray *cellTypes = vtkFloatArray::New();
|
||||||
|
cellTypes->SetNumberOfTuples(superCells_.size());
|
||||||
|
cellTypes->SetNumberOfComponents(Type::nComponents);
|
||||||
|
cellTypes->Allocate(Type::nComponents*tf.size());
|
||||||
|
cellTypes->SetName(tf.name().c_str());
|
||||||
|
|
||||||
|
float vec[Type::nComponents];
|
||||||
|
|
||||||
|
forAll(superCells_, sci)
|
||||||
|
{
|
||||||
|
const Type& t = tf[superCells_[sci]];
|
||||||
|
for (direction d=0; d<Type::nComponents; d++)
|
||||||
|
{
|
||||||
|
vec[d] = t[d];
|
||||||
|
}
|
||||||
|
|
||||||
|
cellTypes->InsertTuple(sci, vec);
|
||||||
|
}
|
||||||
|
|
||||||
|
vtkMesh->GetCellData()->AddArray(cellTypes);
|
||||||
|
cellTypes->Delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<>
|
||||||
|
void Foam::vtkFoam::convertVolField
|
||||||
|
(
|
||||||
|
const GeometricField<scalar, fvPatchField, volMesh>& sf
|
||||||
|
)
|
||||||
|
{
|
||||||
|
vtkUnstructuredGrid *vtkMesh =
|
||||||
|
vtkUnstructuredGrid::SafeDownCast(reader_->GetOutput(0));
|
||||||
|
|
||||||
|
vtkFloatArray *cellScalars = vtkFloatArray::New();
|
||||||
|
cellScalars->SetNumberOfTuples(superCells_.size());
|
||||||
|
cellScalars->SetNumberOfComponents(1);
|
||||||
|
cellScalars->Allocate(sf.size());
|
||||||
|
cellScalars->SetName(sf.name().c_str());
|
||||||
|
|
||||||
|
forAll(superCells_, sci)
|
||||||
|
{
|
||||||
|
cellScalars->InsertComponent(sci, 0, sf[superCells_[sci]]);
|
||||||
|
}
|
||||||
|
|
||||||
|
vtkMesh->GetCellData()->AddArray(cellScalars);
|
||||||
|
if (!vtkMesh->GetCellData()->GetScalars())
|
||||||
|
{
|
||||||
|
vtkMesh->GetCellData()->SetScalars(cellScalars);
|
||||||
|
}
|
||||||
|
|
||||||
|
cellScalars->Delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -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
|
||||||
|
|
||||||
|
InClass
|
||||||
|
Foam::vtkFoam
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef vtkFoamInsertNextPoint_H
|
||||||
|
#define vtkFoamInsertNextPoint_H
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
inline void vtkFoamInsertNextPoint
|
||||||
|
(
|
||||||
|
vtkPoints *points,
|
||||||
|
const Foam::point& p
|
||||||
|
)
|
||||||
|
{
|
||||||
|
points->InsertNextPoint(p.x(), p.y(), p.z());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
34
bin/paraFoam
34
bin/paraFoam
@ -62,10 +62,10 @@ do
|
|||||||
;;
|
;;
|
||||||
-region)
|
-region)
|
||||||
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
||||||
regionName="$2"
|
regionName=$2
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
-t | -touch)
|
-touch)
|
||||||
touchOnly=true
|
touchOnly=true
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
@ -89,7 +89,7 @@ fi
|
|||||||
if [ -n "$touchOnly" ]
|
if [ -n "$touchOnly" ]
|
||||||
then
|
then
|
||||||
touch "$caseFile"
|
touch "$caseFile"
|
||||||
echo "created '$caseFile'" 1>&2
|
echo "created '$caseFile'"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -99,7 +99,6 @@ case "$caseName" in
|
|||||||
*) parentDir="." ;;
|
*) parentDir="." ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
# check existence of essential files
|
# check existence of essential files
|
||||||
for check in system/controlDict $fvControls/fvSchemes $fvControls/fvSolution
|
for check in system/controlDict $fvControls/fvSchemes $fvControls/fvSolution
|
||||||
do
|
do
|
||||||
@ -107,13 +106,28 @@ do
|
|||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
# only create/remove caseFile if it didn't already exist
|
case "$ParaView_VERSION" in
|
||||||
[ -e $caseFile ] || {
|
2*)
|
||||||
trap "rm -f $caseFile 2>/dev/null; exit 0" EXIT TERM INT
|
trap "rm -f paraFoam.pvs $caseFile 2>/dev/null; exit 0" EXIT TERM INT
|
||||||
touch "$caseFile"
|
touch "$caseFile"
|
||||||
echo "created temporary '$caseFile'" 1>&2
|
|
||||||
}
|
|
||||||
|
|
||||||
paraview --data="$caseFile"
|
# since we are now in the cwd, %CASE% is '$PWD/$caseFile'
|
||||||
|
sed -e s@%CASE%@$PWD/$caseFile@g \
|
||||||
|
$WM_PROJECT_DIR/bin/tools/paraFoam.pvs > paraFoam.pvs
|
||||||
|
|
||||||
|
paraview paraFoam.pvs
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
# only create/remove caseFile if it didn't already exist
|
||||||
|
[ -e $caseFile ] || {
|
||||||
|
trap "rm -f $caseFile 2>/dev/null; exit 0" EXIT TERM INT
|
||||||
|
touch "$caseFile"
|
||||||
|
echo "created temporary '$caseFile'"
|
||||||
|
}
|
||||||
|
|
||||||
|
paraview --data="$caseFile"
|
||||||
|
;;
|
||||||
|
|
||||||
|
esac
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|||||||
12
bin/tools/paraFoam.pvs
Normal file
12
bin/tools/paraFoam.pvs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# ParaView State Version 2.2
|
||||||
|
|
||||||
|
set kw(vtkTemp2) [$Application GetMainWindow]
|
||||||
|
set kw(vtkTemp29) [$kw(vtkTemp2) GetMainView]
|
||||||
|
set kw(vtkTemp980) [$kw(vtkTemp2) GetAnimationManager]
|
||||||
|
[$kw(vtkTemp2) GetRotateCameraButton] SetState 1
|
||||||
|
$kw(vtkTemp2) ChangeInteractorStyle 1
|
||||||
|
set kw(vtkTemp840) [$kw(vtkTemp2) InitializeReadCustom "FoamReader" "%CASE%"]
|
||||||
|
$kw(vtkTemp2) ReadFileInformation $kw(vtkTemp840) "%CASE%"
|
||||||
|
$kw(vtkTemp2) FinalizeRead $kw(vtkTemp840) "%CASE%"
|
||||||
|
set kw(vtkTemp868) [$kw(vtkTemp840) GetPVWidget {Filename}]
|
||||||
|
$kw(vtkTemp868) SetValue "%CASE%"
|
||||||
67
etc/apps/paraview/bashrc
Normal file
67
etc/apps/paraview/bashrc
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
#----------------------------------*-sh-*--------------------------------------
|
||||||
|
# ========= |
|
||||||
|
# \\ / 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
|
||||||
|
#
|
||||||
|
# Script
|
||||||
|
# paraview/bashrc
|
||||||
|
#
|
||||||
|
# Description
|
||||||
|
# Setup file for paraview-2.x
|
||||||
|
# Sourced from OpenFOAM-*/etc/bashrc
|
||||||
|
#
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# determine the cmake to be used
|
||||||
|
unset CMAKE_HOME
|
||||||
|
for cmake in cmake-2.6.4 cmake-2.6.2 cmake-2.4.6
|
||||||
|
do
|
||||||
|
cmake=$WM_THIRD_PARTY_DIR/$cmake/platforms/$WM_ARCH
|
||||||
|
if [ -r $cmake ]
|
||||||
|
then
|
||||||
|
export CMAKE_HOME=$cmake
|
||||||
|
export PATH=$CMAKE_HOME/bin:$PATH
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
paraviewMajor=paraview-2.4
|
||||||
|
export ParaView_VERSION=2.4.4
|
||||||
|
|
||||||
|
export ParaView_INST_DIR=$WM_THIRD_PARTY_DIR/ParaView$ParaView_VERSION
|
||||||
|
export ParaView_DIR=$ParaView_INST_DIR/lib/$paraviewMajor
|
||||||
|
|
||||||
|
if [ -r $ParaView_INST_DIR ]
|
||||||
|
then
|
||||||
|
export PV_INTERFACE_PATH=$FOAM_UTILITIES/postProcessing/graphics/PVFoamReader/PVFoamReader/Make
|
||||||
|
|
||||||
|
export PATH=$ParaView_INST_DIR/bin:$PATH
|
||||||
|
export LD_LIBRARY_PATH=${ParaView_INST_DIR}/lib:${ParaView_INST_DIR}/lib/vtk:${LD_LIBRARY_PATH}
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -r $ParaView_DIR ]
|
||||||
|
then
|
||||||
|
export VTK_DIR=$ParaView_DIR/VTK
|
||||||
|
fi
|
||||||
|
|
||||||
|
unset cmake paraviewMajor
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
63
etc/apps/paraview/cshrc
Normal file
63
etc/apps/paraview/cshrc
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
#----------------------------------*-sh-*--------------------------------------
|
||||||
|
# ========= |
|
||||||
|
# \\ / 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
|
||||||
|
#
|
||||||
|
# Script
|
||||||
|
# paraview/cshrc
|
||||||
|
#
|
||||||
|
# Description
|
||||||
|
# Setup file for paraview-2.x
|
||||||
|
# Sourced from OpenFOAM-*/etc/cshrc
|
||||||
|
#
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# determine the cmake to be used
|
||||||
|
unsetenv CMAKE_HOME
|
||||||
|
foreach cmake ( cmake-2.6.4 cmake-2.6.2 cmake-2.4.6 )
|
||||||
|
set cmake=$WM_THIRD_PARTY_DIR/$cmake/platforms/$WM_ARCH
|
||||||
|
if ( -r $cmake ) then
|
||||||
|
setenv CMAKE_HOME $cmake
|
||||||
|
set path=($CMAKE_HOME/bin $path)
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
end
|
||||||
|
|
||||||
|
set paraviewMajor=paraview-2.4
|
||||||
|
setenv ParaView_VERSION 2.4.4
|
||||||
|
|
||||||
|
setenv ParaView_INST_DIR $WM_THIRD_PARTY_DIR/ParaView$ParaView_VERSION
|
||||||
|
setenv ParaView_DIR $ParaView_INST_DIR/lib/$paraviewMajor
|
||||||
|
|
||||||
|
if ( -r $ParaView_INST_DIR ) then
|
||||||
|
setenv PV_INTERFACE_PATH $FOAM_UTILITIES/postProcessing/graphics/PVFoamReader/PVFoamReader/Make
|
||||||
|
|
||||||
|
set path=($ParaView_INST_DIR/bin $path)
|
||||||
|
setenv LD_LIBRARY_PATH ${ParaView_INST_DIR}/lib:${ParaView_INST_DIR}/lib/vtk:${LD_LIBRARY_PATH}
|
||||||
|
endif
|
||||||
|
|
||||||
|
if ( -r $ParaView_DIR ) then
|
||||||
|
setenv VTK_DIR $ParaView_DIR/VTK
|
||||||
|
endif
|
||||||
|
|
||||||
|
unset cmake paraviewMajor
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
Reference in New Issue
Block a user