DEFEATURE: drop reader module support for paraview 3.x (issue #295)

- Cannot test if these older reader modules actually build,
  owning largely to build issues since with paraview 3.14 (Feb 2012)
  and paraview 3.98 (Dec 2012) themselves.
This commit is contained in:
Mark Olesen
2016-11-11 13:30:30 +01:00
parent 7aeaf61cda
commit 8e30111b44
57 changed files with 2 additions and 11287 deletions

View File

@ -1,9 +0,0 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
set -x
wclean libso vtkPV3Readers
PV3blockMeshReader/Allwclean
PV3FoamReader/Allwclean
#------------------------------------------------------------------------------

View File

@ -1,68 +0,0 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
# Optional unit: continue-on-error
export WM_CONTINUE_ON_ERROR=true
# Parse arguments for library compilation
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
#
# There are several prerequisites for building a plugin
#
#set -x
canBuildPlugin()
{
[ -d "$ParaView_DIR" -a -r "$ParaView_DIR" ] || {
echo
echo "WARNING: cannot build ParaView plugin(s) without paraview directory"
echo " ParaView_DIR=$ParaView_DIR"
echo
return 1
}
[ -n "$PV_PLUGIN_PATH" ] || {
echo
echo "${PWD##*/} : invalid PV_PLUGIN_PATH for building ParaView plugin(s)"
echo " PV_PLUGIN_PATH=${PV_PLUGIN_PATH:-unset}"
echo
return 1
}
type cmake > /dev/null 2>&1 || {
echo
echo "WARNING: cannot build ParaView plugin(s) without cmake"
echo
return 1
}
return 0 # success
}
# -----------------------------------------------------------------------------
# major version as per paraview include directory:
# Eg, "PREFIX/include/paraview-3.4" -> "3.4"
major="${ParaView_INCLUDE_DIR##*-}"
case "$major" in
3.[0-9]*)
if canBuildPlugin
then
(
wmake $targetType vtkPV3Readers
PV3blockMeshReader/Allwmake $targetType $*
PV3FoamReader/Allwmake $targetType $*
)
fi
;;
*)
echo
echo "NOTE: skipping build of ParaView V3 plugin(s)"
echo " include directory was for paraview major version '${major:-none}'"
echo
;;
esac
#------------------------------------------------------------------------------

View File

@ -1,11 +0,0 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
set -x
# deal with client/server vs combined plugins
rm -f $FOAM_LIBBIN/libPV3FoamReader* 2>/dev/null
rm -rf PV3FoamReader/Make
wclean libso vtkPV3Foam
#------------------------------------------------------------------------------

View File

@ -1,24 +0,0 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
# Parse arguments for library compilation
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
set -x
if [ -d "$ParaView_DIR" -a -r "$ParaView_DIR" ]
then
wmake $targetType vtkPV3Foam
if [ "$targetType" != "objects" ]
then
(
cd PV3FoamReader
mkdir -p Make/$WM_OPTIONS > /dev/null 2>&1
cd Make/$WM_OPTIONS
cmake ../..
make
)
fi
fi
#------------------------------------------------------------------------------

View File

@ -1,86 +0,0 @@
# create a plugin that adds a reader to the ParaView GUI
# it is added in the file dialog when doing opens/saves.
# The qrc file is processed by Qt's resource compiler (rcc)
# the qrc file must have a resource prefix of "/ParaViewResources"
# and ParaView will read anything contained under that prefix
# the pqReader.xml file contains xml defining readers with their
# file extensions and descriptions.
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
FIND_PACKAGE(ParaView REQUIRED)
INCLUDE(${PARAVIEW_USE_FILE})
LINK_DIRECTORIES(
$ENV{FOAM_LIBBIN}
$ENV{FOAM_EXT_LIBBIN}
)
INCLUDE_DIRECTORIES(
$ENV{WM_PROJECT_DIR}/src/OpenFOAM/lnInclude
$ENV{WM_PROJECT_DIR}/src/OSspecific/$ENV{WM_OSTYPE}/lnInclude
$ENV{WM_PROJECT_DIR}/src/finiteVolume/lnInclude
${PROJECT_SOURCE_DIR}/../vtkPV3Foam
)
ADD_DEFINITIONS(
-DWM_$ENV{WM_PRECISION_OPTION}
-DWM_LABEL_SIZE=$ENV{WM_LABEL_SIZE}
)
# Set output library destination to plugin directory
SET(
LIBRARY_OUTPUT_PATH $ENV{PV_PLUGIN_PATH}
CACHE INTERNAL
"Single output directory for building all libraries."
)
#
# Defined combined plugin
#
# Extend the auto-generated panel
QT4_WRAP_CPP(MOC_SRCS pqPV3FoamReaderPanel.h)
ADD_PARAVIEW_OBJECT_PANEL(IFACES IFACE_SRCS
CLASS_NAME pqPV3FoamReaderPanel
XML_NAME PV3FoamReader # name of SourceProxy in *SM.xml
XML_GROUP sources
)
ADD_PARAVIEW_PLUGIN(
PV3FoamReader_SM "1.0"
SERVER_MANAGER_XML PV3FoamReader_SM.xml
SERVER_MANAGER_SOURCES vtkPV3FoamReader.cxx
GUI_INTERFACES ${IFACES}
GUI_SOURCES pqPV3FoamReaderPanel.cxx
${MOC_SRCS} ${UI_SRCS} ${IFACE_SRCS}
GUI_RESOURCE_FILES PV3FoamReader.xml
)
# #
# # Define the server-side portion of the reader plugin
# #
# ADD_PARAVIEW_PLUGIN(
# PV3FoamReader_SM "1.0"
# SERVER_MANAGER_XML PV3FoamReader_SM.xml
# SERVER_MANAGER_SOURCES vtkPV3FoamReader.cxx
# )
# #
# # Define the client-side portion of the reader plugin
# #
# ADD_PARAVIEW_PLUGIN(
# PV3FoamReader "1.0"
# GUI_RESOURCES PV3FoamReader.qrc
# )
#
TARGET_LINK_LIBRARIES(
PV3FoamReader_SM
OpenFOAM
finiteVolume
vtkPV3Foam
)
#-----------------------------------------------------------------------------

View File

@ -1,5 +0,0 @@
<RCC>
<qresource prefix="/ParaViewResources" >
<file>PV3FoamReader.xml</file>
</qresource>
</RCC>

View File

@ -1,6 +0,0 @@
<ParaViewReaders>
<Reader name="PV3FoamReader"
extensions="OpenFOAM"
file_description="OpenFOAM Reader">
</Reader>
</ParaViewReaders>

View File

@ -1,306 +0,0 @@
<ServerManagerConfiguration>
<ProxyGroup name="sources">
<SourceProxy
name="PV3FoamReader"
class="vtkPV3FoamReader">
<!-- File name - compulsory -->
<StringVectorProperty
name="FileName"
command="SetFileName"
number_of_elements="1"
animateable="0">
<FileListDomain name="files"/>
<Documentation>
Specifies the filename for the OpenFOAM Reader.
</Documentation>
</StringVectorProperty>
<!-- Send discrete time info to the animation panel -->
<DoubleVectorProperty
name="TimestepValues"
repeatable="1"
information_only="1">
<TimeStepsInformationHelper/>
<Documentation>
Available timestep values.
</Documentation>
</DoubleVectorProperty>
<!-- Cache Mesh check-box -->
<IntVectorProperty
name="UiCacheMesh"
command="SetCacheMesh"
number_of_elements="1"
is_internal="1"
default_values="1"
animateable="0">
<BooleanDomain name="bool"/>
<Documentation>
Cache the fvMesh in memory.
</Documentation>
</IntVectorProperty>
<!-- Refresh button -->
<IntVectorProperty
name="UiRefresh"
command="SetRefresh"
number_of_elements="1"
is_internal="0"
default_values="0"
animateable="0">
<BooleanDomain name="bool"/>
<Documentation>
Rescan for updated timesteps/fields.
</Documentation>
</IntVectorProperty>
<!-- Skip Zero Time check-box -->
<IntVectorProperty
name="UiZeroTime"
command="SetSkipZeroTime"
number_of_elements="1"
is_internal="1"
default_values="0"
animateable="0">
<BooleanDomain name="bool"/>
<Documentation>
Skip including the 0/ time directory
</Documentation>
</IntVectorProperty>
<!-- Interpolate Fields check-box -->
<IntVectorProperty
name="UiInterpolateVolFields"
command="SetInterpolateVolFields"
number_of_elements="1"
is_internal="1"
default_values="1"
animateable="0">
<BooleanDomain name="bool"/>
<Documentation>
Interpolate volume fields into point fields
</Documentation>
</IntVectorProperty>
<!-- Extrapolate Patches check-box -->
<IntVectorProperty
name="UiExtrapolatePatches"
command="SetExtrapolatePatches"
number_of_elements="1"
is_internal="1"
default_values="0"
animateable="0">
<BooleanDomain name="bool"/>
<Documentation>
Extrapolate internalField to non-constraint patches
</Documentation>
</IntVectorProperty>
<!-- Use VTK Polyhedron check-box -->
<IntVectorProperty
name="UseVTKPolyhedron"
command="SetUseVTKPolyhedron"
number_of_elements="1"
default_values="0"
animateable="0">
<BooleanDomain name="bool"/>
<Documentation>
Use vtkPolyhedron instead of decomposing polyhedra.
</Documentation>
</IntVectorProperty>
<!-- Include Sets check-box -->
<IntVectorProperty
name="UiIncludeSets"
command="SetIncludeSets"
number_of_elements="1"
is_internal="1"
default_values="0"
animateable="0">
<Documentation>
Search the polyMesh/sets/ directory
</Documentation>
<BooleanDomain name="bool"/>
</IntVectorProperty>
<!-- Include Zones check-box -->
<IntVectorProperty
name="UiIncludeZones"
command="SetIncludeZones"
number_of_elements="1"
is_internal="1"
default_values="0"
animateable="0">
<Documentation>
ZoneMesh information is used to find {cell,face,point}Zones.
The polyMesh/ directory is only checked on startup.
</Documentation>
<BooleanDomain name="bool"/>
</IntVectorProperty>
<!-- Show Patch Names check-box -->
<IntVectorProperty
name="UiShowPatchNames"
command="SetShowPatchNames"
number_of_elements="1"
default_values="0"
is_internal="1"
animateable="0">
<BooleanDomain name="bool"/>
<Documentation>
Show patch names in render window
</Documentation>
</IntVectorProperty>
<!-- Show Groups Only check-box -->
<IntVectorProperty
name="UiShowGroupsOnly"
command="SetShowGroupsOnly"
number_of_elements="1"
default_values="0"
is_internal="1"
animateable="0">
<BooleanDomain name="bool"/>
<Documentation>
Show groups only
</Documentation>
</IntVectorProperty>
<!-- Force GUI update check box -->
<IntVectorProperty
name="UpdateGUI"
command="SetUpdateGUI"
number_of_elements="1"
default_values="0"
animateable="0">
<BooleanDomain name="bool"/>
<Documentation>
A simple way to cause a reader GUI modification.
</Documentation>
</IntVectorProperty>
<!--
| Selections
-->
<!-- Available Parts (volume, patches, lagrangian) array -->
<StringVectorProperty
name="PartArrayStatus"
information_only="1">
<ArraySelectionInformationHelper attribute_name="Part"/>
</StringVectorProperty>
<StringVectorProperty
name="PartStatus"
label="Mesh Parts"
command="SetPartArrayStatus"
number_of_elements="0"
repeat_command="1"
number_of_elements_per_command="2"
element_types="2 0"
information_property="PartArrayStatus"
animateable="0">
<ArraySelectionDomain name="array_list">
<RequiredProperties>
<Property name="PartArrayStatus" function="ArrayList"/>
</RequiredProperties>
</ArraySelectionDomain>
<Documentation>
This property contains a list of the mesh parts
(patches, groups, sets, zones).
</Documentation>
</StringVectorProperty>
<!-- Available volFields array -->
<StringVectorProperty
name="VolFieldArrayStatus"
information_only="1">
<ArraySelectionInformationHelper attribute_name="VolField"/>
</StringVectorProperty>
<StringVectorProperty
name="VolFieldStatus"
label="Volume Fields"
command="SetVolFieldArrayStatus"
number_of_elements="0"
repeat_command="1"
number_of_elements_per_command="2"
element_types="2 0"
information_property="VolFieldArrayStatus"
animateable="0">
<ArraySelectionDomain name="array_list">
<RequiredProperties>
<Property name="VolFieldArrayStatus" function="ArrayList"/>
</RequiredProperties>
</ArraySelectionDomain>
<Documentation>
This property contains a list of the volume fields
</Documentation>
</StringVectorProperty>
<!-- Available Lagrangian fields array -->
<StringVectorProperty
name="LagrangianFieldArrayStatus"
information_only="1">
<ArraySelectionInformationHelper attribute_name="LagrangianField"/>
</StringVectorProperty>
<StringVectorProperty
name="LagrangianFieldStatus"
label="Lagrangian Fields"
command="SetLagrangianFieldArrayStatus"
number_of_elements="0"
repeat_command="1"
number_of_elements_per_command="2"
element_types="2 0"
information_property="LagrangianFieldArrayStatus"
animateable="0">
<ArraySelectionDomain name="array_list">
<RequiredProperties>
<Property name="LagrangianFieldArrayStatus" function="ArrayList"/>
</RequiredProperties>
</ArraySelectionDomain>
<Documentation>
This property contains a list of the lagrangian fields
</Documentation>
</StringVectorProperty>
<!-- Available pointFields array -->
<StringVectorProperty
name="PointFieldArrayStatus"
information_only="1">
<ArraySelectionInformationHelper attribute_name="PointField"/>
</StringVectorProperty>
<StringVectorProperty
name="PointFieldStatus"
label="Point Fields"
command="SetPointFieldArrayStatus"
number_of_elements="0"
repeat_command="1"
number_of_elements_per_command="2"
element_types="2 0"
information_property="PointFieldArrayStatus"
animateable="0">
<ArraySelectionDomain name="array_list">
<RequiredProperties>
<Property name="PointFieldArrayStatus" function="ArrayList"/>
</RequiredProperties>
</ArraySelectionDomain>
<Documentation>
This property contains a list of the point fields
</Documentation>
</StringVectorProperty>
<Hints>
<Property name="FileName" show="0"/>
<Property name="UiCacheMesh" show="0"/>
<Property name="UiZeroTime" show="0"/>
<Property name="UiRefresh" show="0"/>
<Property name="UiShowPatchNames" show="0"/>
<Property name="UiShowGroupsOnly" show="0"/>
<Property name="UiIncludeSets" show="0"/>
<Property name="UiIncludeZones" show="0"/>
</Hints>
</SourceProxy>
</ProxyGroup>
</ServerManagerConfiguration>

View File

@ -1,464 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "pqPV3FoamReaderPanel.h"
// QT
#include <QGridLayout>
#include <QCheckBox>
#include <QLabel>
#include <QLayout>
#include <QString>
#include <QPushButton>
#include <QtDebug>
// Paraview <-> QT UI
#include "pqAnimationScene.h"
#include "pqApplicationCore.h"
#include "pqPipelineRepresentation.h"
#include "pqServerManagerModel.h"
#include "pqView.h"
// Paraview Server Manager
#include "vtkSMDoubleVectorProperty.h"
#include "vtkSMIntVectorProperty.h"
#include "vtkSMProperty.h"
#include "vtkSMSourceProxy.h"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
pqPV3FoamReaderPanel::pqPV3FoamReaderPanel
(
pqProxy *proxy,
QWidget *p
)
:
pqAutoGeneratedObjectPanel(proxy, p)
{
// create first sublayout (at top of the panel)
QGridLayout* form = new QGridLayout();
this->PanelLayout->addLayout(form, 0, 0, 1, -1);
// ROW 0
// ~~~~~
vtkSMProperty* prop = 0;
// refresh button for updating times/fields
if ((prop = this->proxy()->GetProperty("UiRefresh")) != 0)
{
prop->SetImmediateUpdate(1);
QPushButton *refresh = new QPushButton("Refresh Times");
refresh->setToolTip("Rescan for updated times/fields.");
form->addWidget(refresh, 0, 0, Qt::AlignLeft);
QObject::connect
(
refresh,
SIGNAL(clicked()),
this,
SLOT(RefreshPressed())
);
}
// checkbox for skip zeroTime
if ((prop = this->proxy()->GetProperty("UiZeroTime")) != 0)
{
// immediate update on the Server Manager side
prop->SetImmediateUpdate(true);
ZeroTime_ = new QCheckBox("Skip Zero Time");
ZeroTime_->setChecked
(
vtkSMIntVectorProperty::SafeDownCast(prop)->GetElement(0)
);
ZeroTime_->setToolTip
(
"Skip including the 0/ time directory."
);
form->addWidget(ZeroTime_, 0, 1, Qt::AlignLeft);
connect
(
ZeroTime_,
SIGNAL(stateChanged(int)),
this,
SLOT(ZeroTimeToggled())
);
}
// ROW 1
// ~~~~~
QFrame* hline1 = new QFrame(this);
hline1->setFrameStyle(QFrame::HLine | QFrame::Sunken);
form->addWidget(hline1, 1, 0, 1, 3);
// ROW 2
// ~~~~~
// checkbox for caching mesh
if ((prop = this->proxy()->GetProperty("UiCacheMesh")) != 0)
{
// immediate update on the Server Manager side
prop->SetImmediateUpdate(true);
CacheMesh_ = new QCheckBox("Cache Mesh");
CacheMesh_->setChecked
(
vtkSMIntVectorProperty::SafeDownCast(prop)->GetElement(0)
);
CacheMesh_->setToolTip
(
"Cache the fvMesh in memory."
);
form->addWidget(CacheMesh_, 2, 0, Qt::AlignLeft);
connect
(
CacheMesh_,
SIGNAL(stateChanged(int)),
this,
SLOT(CacheMeshToggled())
);
}
// cell 2,1 empty
// ROW 3
// ~~~~~
// checkbox for include sets
if ((prop = this->proxy()->GetProperty("UiIncludeSets")) != 0)
{
// immediate update on the Server Manager side
prop->SetImmediateUpdate(true);
IncludeSets_ = new QCheckBox("Include Sets");
IncludeSets_->setChecked
(
vtkSMIntVectorProperty::SafeDownCast(prop)->GetElement(0)
);
IncludeSets_->setToolTip
(
"Search the polyMesh/sets/ directory."
);
// row/col 1,0
form->addWidget(IncludeSets_, 3, 0, Qt::AlignLeft);
connect
(
IncludeSets_,
SIGNAL(stateChanged(int)),
this,
SLOT(IncludeSetsToggled())
);
}
// checkbox for Groups Only
if ((prop = this->proxy()->GetProperty("UiShowGroupsOnly")) != 0)
{
// immediate update on the Server Manager side
prop->SetImmediateUpdate(true);
ShowGroupsOnly_ = new QCheckBox("Groups Only");
ShowGroupsOnly_->setChecked
(
vtkSMIntVectorProperty::SafeDownCast(prop)->GetElement(0)
);
ShowGroupsOnly_->setToolTip
(
"Show patchGroups only."
);
// row/col 2, 2
form->addWidget(ShowGroupsOnly_, 3, 1, Qt::AlignLeft);
connect
(
ShowGroupsOnly_,
SIGNAL(stateChanged(int)),
this,
SLOT(ShowGroupsOnlyToggled())
);
}
// ROW 4
// ~~~~~
// checkbox for include zones
if ((prop = this->proxy()->GetProperty("UiIncludeZones")) != 0)
{
// immediate update on the Server Manager side
prop->SetImmediateUpdate(true);
IncludeZones_ = new QCheckBox("Include Zones");
IncludeZones_->setChecked
(
vtkSMIntVectorProperty::SafeDownCast(prop)->GetElement(0)
);
IncludeZones_->setToolTip
(
"ZoneMesh information is used to find {cell,face,point}Zones. "
"The polyMesh/ directory is only checked on startup."
);
// row/col 1,1
form->addWidget(IncludeZones_, 4, 0, Qt::AlignLeft);
connect
(
IncludeZones_,
SIGNAL(stateChanged(int)),
this,
SLOT(IncludeZonesToggled())
);
}
// checkbox for patch names
if ((prop = this->proxy()->GetProperty("UiShowPatchNames")) != 0)
{
// immediate update on the Server Manager side
prop->SetImmediateUpdate(true);
ShowPatchNames_ = new QCheckBox("Patch Names");
ShowPatchNames_->setChecked
(
vtkSMIntVectorProperty::SafeDownCast(prop)->GetElement(0)
);
ShowPatchNames_->setToolTip
(
"Show patch names in render window."
);
// row/col 0,1
form->addWidget(ShowPatchNames_, 4, 1, Qt::AlignLeft);
connect
(
ShowPatchNames_,
SIGNAL(stateChanged(int)),
this,
SLOT(ShowPatchNamesToggled())
);
}
// ROW 5
// ~~~~~
QFrame* hline2 = new QFrame(this);
hline2->setFrameStyle(QFrame::HLine | QFrame::Sunken);
form->addWidget(hline2, 5, 0, 1, 3);
// ROW 6
// ~~~~~
// checkbox for vol field interpolation
if ((prop = this->proxy()->GetProperty("UiInterpolateVolFields")) != 0)
{
// immediate update on the Server Manager side
prop->SetImmediateUpdate(true);
InterpolateVolFields_ = new QCheckBox("Interpolate volFields");
InterpolateVolFields_->setChecked
(
vtkSMIntVectorProperty::SafeDownCast(prop)->GetElement(0)
);
InterpolateVolFields_->setToolTip
(
"Interpolate volFields into pointFields"
);
// row/col 1,1
form->addWidget(InterpolateVolFields_, 6, 0, Qt::AlignLeft);
connect
(
InterpolateVolFields_,
SIGNAL(stateChanged(int)),
this,
SLOT(InterpolateVolFieldsToggled())
);
}
// checkbox for extrapolate patches
if ((prop = this->proxy()->GetProperty("UiExtrapolatePatches")) != 0)
{
// immediate update on the Server Manager side
prop->SetImmediateUpdate(true);
ExtrapolatePatches_ = new QCheckBox("Extrapolate Patches");
ExtrapolatePatches_->setChecked
(
vtkSMIntVectorProperty::SafeDownCast(prop)->GetElement(0)
);
ExtrapolatePatches_->setToolTip
(
"Extrapolate internalField to non-constraint patches"
);
// row/col 1,1
form->addWidget(ExtrapolatePatches_, 6, 1, Qt::AlignLeft);
connect
(
ExtrapolatePatches_,
SIGNAL(stateChanged(int)),
this,
SLOT(ExtrapolatePatchesToggled())
);
}
// ROW 7
// ~~~~~
QFrame* hline3 = new QFrame(this);
hline3->setFrameStyle(QFrame::HLine | QFrame::Sunken);
form->addWidget(hline3, 7, 0, 1, 3);
}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void pqPV3FoamReaderPanel::CacheMeshToggled()
{
vtkSMIntVectorProperty::SafeDownCast
(
this->proxy()->GetProperty("UiCacheMesh")
)->SetElement(0, CacheMesh_->isChecked());
}
void pqPV3FoamReaderPanel::RefreshPressed()
{
// update everything
vtkSMIntVectorProperty::SafeDownCast
(
this->proxy()->GetProperty("UiRefresh")
)->Modified();
vtkSMSourceProxy::SafeDownCast(this->proxy())->UpdatePipeline();
// render all views
pqApplicationCore::instance()->render();
}
void pqPV3FoamReaderPanel::ZeroTimeToggled()
{
vtkSMIntVectorProperty::SafeDownCast
(
this->proxy()->GetProperty("UiZeroTime")
)->SetElement(0, ZeroTime_->isChecked());
this->setModified();
}
void pqPV3FoamReaderPanel::ShowPatchNamesToggled()
{
vtkSMIntVectorProperty::SafeDownCast
(
this->proxy()->GetProperty("UiShowPatchNames")
)->SetElement(0, ShowPatchNames_->isChecked());
// update the active view
if (this->view())
{
this->view()->render();
}
// OR: update all views
// pqApplicationCore::instance()->render();
}
void pqPV3FoamReaderPanel::ShowGroupsOnlyToggled()
{
vtkSMProperty* prop;
vtkSMIntVectorProperty::SafeDownCast
(
this->proxy()->GetProperty("UiShowGroupsOnly")
)->SetElement(0, ShowGroupsOnly_->isChecked());
if ((prop = this->proxy()->GetProperty("PartArrayStatus")) != 0)
{
this->proxy()->UpdatePropertyInformation(prop);
}
}
void pqPV3FoamReaderPanel::IncludeSetsToggled()
{
vtkSMProperty* prop;
vtkSMIntVectorProperty::SafeDownCast
(
this->proxy()->GetProperty("UiIncludeSets")
)->SetElement(0, IncludeSets_->isChecked());
if ((prop = this->proxy()->GetProperty("PartArrayStatus")) != 0)
{
this->proxy()->UpdatePropertyInformation(prop);
}
}
void pqPV3FoamReaderPanel::IncludeZonesToggled()
{
vtkSMProperty* prop;
vtkSMIntVectorProperty::SafeDownCast
(
this->proxy()->GetProperty("UiIncludeZones")
)->SetElement(0, IncludeZones_->isChecked());
if ((prop = this->proxy()->GetProperty("PartArrayStatus")) != 0)
{
this->proxy()->UpdatePropertyInformation(prop);
}
}
void pqPV3FoamReaderPanel::ExtrapolatePatchesToggled()
{
vtkSMIntVectorProperty::SafeDownCast
(
this->proxy()->GetProperty("UiExtrapolatePatches")
)->SetElement(0, ExtrapolatePatches_->isChecked());
this->setModified();
}
void pqPV3FoamReaderPanel::InterpolateVolFieldsToggled()
{
vtkSMIntVectorProperty::SafeDownCast
(
this->proxy()->GetProperty("UiInterpolateVolFields")
)->SetElement(0, InterpolateVolFields_->isChecked());
this->setModified();
}
// ************************************************************************* //

View File

@ -1,120 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
Class
pqPV3FoamReaderPanel
Description
GUI modifications for the ParaView reader panel
A custom panel for the PV3FoamReader.
SourceFiles
pqPV3FoamReaderPanel.cxx
\*---------------------------------------------------------------------------*/
#ifndef pqPV3FoamReaderPanel_h
#define pqPV3FoamReaderPanel_h
#include "pqAutoGeneratedObjectPanel.h"
// Forward declaration of QT classes
class QCheckBox;
class QLineEdit;
class QTimer;
class QToolButton;
// Forward declaration of ParaView classes
class vtkSMSourceProxy;
/*---------------------------------------------------------------------------*\
Class pqPV3FoamReaderPanel Declaration
\*---------------------------------------------------------------------------*/
class pqPV3FoamReaderPanel
:
public pqAutoGeneratedObjectPanel
{
// Private data
Q_OBJECT;
typedef pqAutoGeneratedObjectPanel Superclass;
//- ZeroTime checkbox
QCheckBox* ZeroTime_;
//- CacheMesh checkbox
QCheckBox* CacheMesh_;
//- Show Patch Names checkbox
QCheckBox* ShowPatchNames_;
//- Show Groups Only checkbox
QCheckBox* ShowGroupsOnly_;
//- IncludeSets checkbox
QCheckBox* IncludeSets_;
//- IncludeZones checkbox
QCheckBox* IncludeZones_;
//- InterpolateVolFields checkbox
QCheckBox* InterpolateVolFields_;
//- ExtrapolatePatches checkbox
QCheckBox* ExtrapolatePatches_;
protected slots:
void CacheMeshToggled();
void ZeroTimeToggled();
void RefreshPressed();
void ShowPatchNamesToggled();
void ShowGroupsOnlyToggled();
void IncludeSetsToggled();
void IncludeZonesToggled();
void InterpolateVolFieldsToggled();
void ExtrapolatePatchesToggled();
public:
// Constructors
//- Construct from components
pqPV3FoamReaderPanel(pqProxy*, QWidget*);
//- Destructor
// virtual ~pqPV3FoamReaderPanel();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,757 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "vtkPV3FoamReader.h"
#include "pqApplicationCore.h"
#include "pqRenderView.h"
#include "pqServerManagerModel.h"
// VTK includes
#include "vtkCallbackCommand.h"
#include "vtkDataArraySelection.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkMultiBlockDataSet.h"
#include "vtkObjectFactory.h"
#include "vtkSMRenderViewProxy.h"
#include "vtkStreamingDemandDrivenPipeline.h"
#include "vtkStringArray.h"
// OpenFOAM includes
#include "vtkPV3Foam.H"
#undef EXPERIMENTAL_TIME_CACHING
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
vtkStandardNewMacro(vtkPV3FoamReader);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
vtkPV3FoamReader::vtkPV3FoamReader()
{
Debug = 0;
vtkDebugMacro(<<"Constructor");
SetNumberOfInputPorts(0);
FileName = nullptr;
foamData_ = nullptr;
output0_ = nullptr;
#ifdef VTKPV3FOAM_DUALPORT
// Add second output for the Lagrangian
this->SetNumberOfOutputPorts(2);
vtkMultiBlockDataSet *lagrangian = vtkMultiBlockDataSet::New();
lagrangian->ReleaseData();
this->GetExecutive()->SetOutputData(1, lagrangian);
lagrangian->Delete();
#endif
TimeStepRange[0] = 0;
TimeStepRange[1] = 0;
CacheMesh = 1;
Refresh = 0;
SkipZeroTime = 0;
ExtrapolatePatches = 0;
UseVTKPolyhedron = 0;
IncludeSets = 0;
IncludeZones = 0;
ShowPatchNames = 0;
ShowGroupsOnly = 0;
InterpolateVolFields = 1;
UpdateGUI = 0;
PartSelection = vtkDataArraySelection::New();
VolFieldSelection = vtkDataArraySelection::New();
PointFieldSelection = vtkDataArraySelection::New();
LagrangianFieldSelection = vtkDataArraySelection::New();
// Setup the selection callback to modify this object when an array
// selection is changed.
SelectionObserver = vtkCallbackCommand::New();
SelectionObserver->SetCallback
(
&vtkPV3FoamReader::SelectionModifiedCallback
);
SelectionObserver->SetClientData(this);
PartSelection->AddObserver
(
vtkCommand::ModifiedEvent,
this->SelectionObserver
);
VolFieldSelection->AddObserver
(
vtkCommand::ModifiedEvent,
this->SelectionObserver
);
PointFieldSelection->AddObserver
(
vtkCommand::ModifiedEvent,
this->SelectionObserver
);
LagrangianFieldSelection->AddObserver
(
vtkCommand::ModifiedEvent,
this->SelectionObserver
);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
vtkPV3FoamReader::~vtkPV3FoamReader()
{
vtkDebugMacro(<<"Deconstructor");
if (foamData_)
{
// remove patch names
updatePatchNamesView(false);
delete foamData_;
}
if (FileName)
{
delete [] FileName;
}
if (output0_)
{
output0_->Delete();
}
PartSelection->RemoveObserver(this->SelectionObserver);
VolFieldSelection->RemoveObserver(this->SelectionObserver);
PointFieldSelection->RemoveObserver(this->SelectionObserver);
LagrangianFieldSelection->RemoveObserver(this->SelectionObserver);
SelectionObserver->Delete();
PartSelection->Delete();
VolFieldSelection->Delete();
PointFieldSelection->Delete();
LagrangianFieldSelection->Delete();
}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
// Do everything except set the output info
int vtkPV3FoamReader::RequestInformation
(
vtkInformation* vtkNotUsed(request),
vtkInformationVector** vtkNotUsed(inputVector),
vtkInformationVector* outputVector
)
{
vtkDebugMacro(<<"RequestInformation");
if (Foam::vtkPV3Foam::debug)
{
cout<<"REQUEST_INFORMATION\n";
}
if (!FileName)
{
vtkErrorMacro("FileName has to be specified!");
return 0;
}
int nInfo = outputVector->GetNumberOfInformationObjects();
if (Foam::vtkPV3Foam::debug)
{
cout<<"RequestInformation with " << nInfo << " item(s)\n";
for (int infoI = 0; infoI < nInfo; ++infoI)
{
outputVector->GetInformationObject(infoI)->Print(cout);
}
}
if (!foamData_)
{
foamData_ = new Foam::vtkPV3Foam(FileName, this);
}
else
{
foamData_->updateInfo();
}
int nTimeSteps = 0;
double* timeSteps = foamData_->findTimes(nTimeSteps);
if (!nTimeSteps)
{
vtkErrorMacro("could not find valid OpenFOAM mesh");
// delete foamData and flag it as fatal error
delete foamData_;
foamData_ = nullptr;
return 0;
}
// set identical time steps for all ports
for (int infoI = 0; infoI < nInfo; ++infoI)
{
outputVector->GetInformationObject(infoI)->Set
(
vtkStreamingDemandDrivenPipeline::TIME_STEPS(),
timeSteps,
nTimeSteps
);
}
if (nTimeSteps)
{
double timeRange[2];
timeRange[0] = timeSteps[0];
timeRange[1] = timeSteps[nTimeSteps-1];
if (Foam::vtkPV3Foam::debug > 1)
{
cout<<"nTimeSteps " << nTimeSteps << "\n"
<<"timeRange " << timeRange[0] << " to " << timeRange[1]
<< "\n";
for (int timeI = 0; timeI < nTimeSteps; ++timeI)
{
cout<< "step[" << timeI << "] = " << timeSteps[timeI] << "\n";
}
}
for (int infoI = 0; infoI < nInfo; ++infoI)
{
outputVector->GetInformationObject(infoI)->Set
(
vtkStreamingDemandDrivenPipeline::TIME_RANGE(),
timeRange,
2
);
}
}
delete timeSteps;
return 1;
}
// Set the output info
int vtkPV3FoamReader::RequestData
(
vtkInformation* vtkNotUsed(request),
vtkInformationVector** vtkNotUsed(inputVector),
vtkInformationVector* outputVector
)
{
vtkDebugMacro(<<"RequestData");
if (!FileName)
{
vtkErrorMacro("FileName has to be specified!");
return 0;
}
// catch previous error
if (!foamData_)
{
vtkErrorMacro("Reader failed - perhaps no mesh?");
return 0;
}
int nInfo = outputVector->GetNumberOfInformationObjects();
if (Foam::vtkPV3Foam::debug)
{
cout<<"RequestData with " << nInfo << " item(s)\n";
for (int infoI = 0; infoI < nInfo; ++infoI)
{
outputVector->GetInformationObject(infoI)->Print(cout);
}
}
// Get the requested time step.
// We only support requests for a single time step
int nRequestTime = 0;
double requestTime[nInfo];
// taking port0 as the lead for other outputs would be nice, but fails when
// a filter is added - we need to check everything
// but since PREVIOUS_UPDATE_TIME_STEPS() is protected, relay the logic
// to the vtkPV3Foam::setTime() method
for (int infoI = 0; infoI < nInfo; ++infoI)
{
vtkInformation *outInfo = outputVector->GetInformationObject(infoI);
if
(
outInfo->Has
(
vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS()
)
&& outInfo->Length
(
vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS()
) >= 1
)
{
requestTime[nRequestTime++] = outInfo->Get
(
vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS()
)[0];
}
}
if (nRequestTime)
{
foamData_->setTime(nRequestTime, requestTime);
}
vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::SafeDownCast
(
outputVector->GetInformationObject(0)->Get
(
vtkMultiBlockDataSet::DATA_OBJECT()
)
);
if (Foam::vtkPV3Foam::debug)
{
cout<< "update output with "
<< output->GetNumberOfBlocks() << " blocks\n";
}
#ifdef EXPERIMENTAL_TIME_CACHING
bool needsUpdate = false;
if (!output0_)
{
output0_ = vtkMultiBlockDataSet::New();
needsUpdate = true;
}
// This experimental bit of code seems to work for the geometry,
// but trashes the fields and still triggers the GeometryFilter
if (needsUpdate)
{
foamData_->Update(output);
output0_->ShallowCopy(output);
}
else
{
output->ShallowCopy(output0_);
}
if (Foam::vtkPV3Foam::debug)
{
if (needsUpdate)
{
cout<< "full UPDATE ---------\n";
}
else
{
cout<< "cached UPDATE ---------\n";
}
cout<< "UPDATED output: ";
output->Print(cout);
cout<< "UPDATED output0_: ";
output0_->Print(cout);
}
#else
#ifdef VTKPV3FOAM_DUALPORT
foamData_->Update
(
output,
vtkMultiBlockDataSet::SafeDownCast
(
outputVector->GetInformationObject(1)->Get
(
vtkMultiBlockDataSet::DATA_OBJECT()
)
);
);
#else
foamData_->Update(output, output);
#endif
updatePatchNamesView(ShowPatchNames);
#endif
// Do any cleanup on the OpenFOAM side
foamData_->CleanUp();
return 1;
}
void vtkPV3FoamReader::SetRefresh(int val)
{
Modified();
}
void vtkPV3FoamReader::SetIncludeSets(int val)
{
if (IncludeSets != val)
{
IncludeSets = val;
if (foamData_)
{
foamData_->updateInfo();
}
}
}
void vtkPV3FoamReader::SetIncludeZones(int val)
{
if (IncludeZones != val)
{
IncludeZones = val;
if (foamData_)
{
foamData_->updateInfo();
}
}
}
void vtkPV3FoamReader::SetShowPatchNames(int val)
{
if (ShowPatchNames != val)
{
ShowPatchNames = val;
updatePatchNamesView(ShowPatchNames);
}
}
void vtkPV3FoamReader::SetShowGroupsOnly(int val)
{
if (ShowGroupsOnly != val)
{
ShowGroupsOnly = val;
if (foamData_)
{
foamData_->updateInfo();
}
}
}
void vtkPV3FoamReader::updatePatchNamesView(const bool show)
{
pqApplicationCore* appCore = pqApplicationCore::instance();
// need to check this, since our destructor calls this
if (!appCore)
{
return;
}
// Server manager model for querying items in the server manager
pqServerManagerModel* smModel = appCore->getServerManagerModel();
if (!smModel || !foamData_)
{
return;
}
// Get all the pqRenderView instances
QList<pqRenderView*> renderViews = smModel->findItems<pqRenderView*>();
for (int viewI=0; viewI < renderViews.size(); ++viewI)
{
foamData_->renderPatchNames
(
renderViews[viewI]->getRenderViewProxy()->GetRenderer(),
show
);
}
// use refresh here?
}
void vtkPV3FoamReader::PrintSelf(ostream& os, vtkIndent indent)
{
vtkDebugMacro(<<"PrintSelf");
this->Superclass::PrintSelf(os,indent);
os << indent << "File name: "
<< (this->FileName ? this->FileName : "(none)") << "\n";
foamData_->PrintSelf(os, indent);
os << indent << "Time step range: "
<< this->TimeStepRange[0] << " - " << this->TimeStepRange[1] << "\n"
<< indent << "Time step: " << this->GetTimeStep() << endl;
}
int vtkPV3FoamReader::GetTimeStep()
{
return foamData_ ? foamData_->timeIndex() : -1;
}
// ----------------------------------------------------------------------
// Parts selection list control
vtkDataArraySelection* vtkPV3FoamReader::GetPartSelection()
{
vtkDebugMacro(<<"GetPartSelection");
return PartSelection;
}
int vtkPV3FoamReader::GetNumberOfPartArrays()
{
vtkDebugMacro(<<"GetNumberOfPartArrays");
return PartSelection->GetNumberOfArrays();
}
const char* vtkPV3FoamReader::GetPartArrayName(int index)
{
vtkDebugMacro(<<"GetPartArrayName");
return PartSelection->GetArrayName(index);
}
int vtkPV3FoamReader::GetPartArrayStatus(const char* name)
{
vtkDebugMacro(<<"GetPartArrayStatus");
return PartSelection->ArrayIsEnabled(name);
}
void vtkPV3FoamReader::SetPartArrayStatus(const char* name, int status)
{
vtkDebugMacro("Set mesh part \"" << name << "\" status to: " << status);
if (status)
{
PartSelection->EnableArray(name);
}
else
{
PartSelection->DisableArray(name);
}
}
// ----------------------------------------------------------------------
// volField selection list control
vtkDataArraySelection* vtkPV3FoamReader::GetVolFieldSelection()
{
vtkDebugMacro(<<"GetVolFieldSelection");
return VolFieldSelection;
}
int vtkPV3FoamReader::GetNumberOfVolFieldArrays()
{
vtkDebugMacro(<<"GetNumberOfVolFieldArrays");
return VolFieldSelection->GetNumberOfArrays();
}
const char* vtkPV3FoamReader::GetVolFieldArrayName(int index)
{
vtkDebugMacro(<<"GetVolFieldArrayName");
return VolFieldSelection->GetArrayName(index);
}
int vtkPV3FoamReader::GetVolFieldArrayStatus(const char* name)
{
vtkDebugMacro(<<"GetVolFieldArrayStatus");
return VolFieldSelection->ArrayIsEnabled(name);
}
void vtkPV3FoamReader::SetVolFieldArrayStatus(const char* name, int status)
{
vtkDebugMacro(<<"SetVolFieldArrayStatus");
if (status)
{
VolFieldSelection->EnableArray(name);
}
else
{
VolFieldSelection->DisableArray(name);
}
}
// ----------------------------------------------------------------------
// pointField selection list control
vtkDataArraySelection* vtkPV3FoamReader::GetPointFieldSelection()
{
vtkDebugMacro(<<"GetPointFieldSelection");
return PointFieldSelection;
}
int vtkPV3FoamReader::GetNumberOfPointFieldArrays()
{
vtkDebugMacro(<<"GetNumberOfPointFieldArrays");
return PointFieldSelection->GetNumberOfArrays();
}
const char* vtkPV3FoamReader::GetPointFieldArrayName(int index)
{
vtkDebugMacro(<<"GetPointFieldArrayName");
return PointFieldSelection->GetArrayName(index);
}
int vtkPV3FoamReader::GetPointFieldArrayStatus(const char* name)
{
vtkDebugMacro(<<"GetPointFieldArrayStatus");
return PointFieldSelection->ArrayIsEnabled(name);
}
void vtkPV3FoamReader::SetPointFieldArrayStatus(const char* name, int status)
{
vtkDebugMacro(<<"SetPointFieldArrayStatus");
if (status)
{
PointFieldSelection->EnableArray(name);
}
else
{
PointFieldSelection->DisableArray(name);
}
}
// ----------------------------------------------------------------------
// lagrangianField selection list control
vtkDataArraySelection* vtkPV3FoamReader::GetLagrangianFieldSelection()
{
vtkDebugMacro(<<"GetLagrangianFieldSelection");
return LagrangianFieldSelection;
}
int vtkPV3FoamReader::GetNumberOfLagrangianFieldArrays()
{
vtkDebugMacro(<<"GetNumberOfLagrangianFieldArrays");
return LagrangianFieldSelection->GetNumberOfArrays();
}
const char* vtkPV3FoamReader::GetLagrangianFieldArrayName(int index)
{
vtkDebugMacro(<<"GetLagrangianFieldArrayName");
return LagrangianFieldSelection->GetArrayName(index);
}
int vtkPV3FoamReader::GetLagrangianFieldArrayStatus(const char* name)
{
vtkDebugMacro(<<"GetLagrangianFieldArrayStatus");
return LagrangianFieldSelection->ArrayIsEnabled(name);
}
void vtkPV3FoamReader::SetLagrangianFieldArrayStatus
(
const char* name,
int status
)
{
vtkDebugMacro(<<"SetLagrangianFieldArrayStatus");
if (status)
{
LagrangianFieldSelection->EnableArray(name);
}
else
{
LagrangianFieldSelection->DisableArray(name);
}
}
// ----------------------------------------------------------------------
void vtkPV3FoamReader::SelectionModifiedCallback
(
vtkObject*,
unsigned long,
void* clientdata,
void*
)
{
static_cast<vtkPV3FoamReader*>(clientdata)->SelectionModified();
}
void vtkPV3FoamReader::SelectionModified()
{
vtkDebugMacro(<<"SelectionModified");
Modified();
}
int vtkPV3FoamReader::FillOutputPortInformation
(
int port,
vtkInformation* info
)
{
if (port == 0)
{
return this->Superclass::FillOutputPortInformation(port, info);
}
info->Set(vtkDataObject::DATA_TYPE_NAME(), "vtkMultiBlockDataSet");
return 1;
}
// ************************************************************************* //

View File

@ -1,262 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
Class
vtkPV3FoamReader
Description
reads a dataset in OpenFOAM format
vtkPV3blockMeshReader creates an multiblock dataset.
It uses the OpenFOAM infrastructure (fvMesh, etc) to handle mesh and
field data.
SourceFiles
vtkPV3blockMeshReader.cxx
\*---------------------------------------------------------------------------*/
#ifndef vtkPV3FoamReader_h
#define vtkPV3FoamReader_h
// VTK includes
#include "vtkMultiBlockDataSetAlgorithm.h"
// * * * * * * * * * * * * * Forward Declarations * * * * * * * * * * * * * //
// VTK forward declarations
class vtkDataArraySelection;
class vtkCallbackCommand;
// OpenFOAM forward declarations
namespace Foam
{
class vtkPV3Foam;
}
/*---------------------------------------------------------------------------*\
Class vtkPV3FoamReader Declaration
\*---------------------------------------------------------------------------*/
class VTK_IO_EXPORT vtkPV3FoamReader
:
public vtkMultiBlockDataSetAlgorithm
{
public:
vtkTypeMacro(vtkPV3FoamReader, vtkMultiBlockDataSetAlgorithm);
void PrintSelf(ostream&, vtkIndent);
static vtkPV3FoamReader* New();
// Description:
// Get the current timestep and the timestep range.
vtkGetVector2Macro(TimeStepRange, int);
// Description:
// Set/Get the filename.
vtkSetStringMacro(FileName);
vtkGetStringMacro(FileName);
// Description:
// OpenFOAM mesh caching control
vtkSetMacro(CacheMesh, int);
vtkGetMacro(CacheMesh, int);
// Description:
// OpenFOAM refresh times/fields
virtual void SetRefresh(int);
// Description:
// OpenFOAM skip/include the 0/ time directory
vtkSetMacro(SkipZeroTime, int);
vtkGetMacro(SkipZeroTime, int);
// Description:
// GUI update control
vtkSetMacro(UpdateGUI, int);
vtkGetMacro(UpdateGUI, int);
// Description:
// OpenFOAM extrapolate internal values onto the patches
vtkSetMacro(ExtrapolatePatches, int);
vtkGetMacro(ExtrapolatePatches, int);
// Description:
// OpenFOAM use vtkPolyhedron instead of decomposing polyhedra
vtkSetMacro(UseVTKPolyhedron, int);
vtkGetMacro(UseVTKPolyhedron, int);
// Description:
// OpenFOAM read sets control
virtual void SetIncludeSets(int);
vtkGetMacro(IncludeSets, int);
// Description:
// OpenFOAM read zones control
virtual void SetIncludeZones(int);
vtkGetMacro(IncludeZones, int);
// Description:
// OpenFOAM display patch names control
virtual void SetShowPatchNames(int);
vtkGetMacro(ShowPatchNames, int);
// Description:
// OpenFOAM display patchGroups
virtual void SetShowGroupsOnly(int);
vtkGetMacro(ShowGroupsOnly, int);
// Description:
// OpenFOAM volField interpolation
vtkSetMacro(InterpolateVolFields, int);
vtkGetMacro(InterpolateVolFields, int);
// Description:
// Get the current timestep
int GetTimeStep();
// Description:
// Parts selection list control
virtual vtkDataArraySelection* GetPartSelection();
int GetNumberOfPartArrays();
int GetPartArrayStatus(const char* name);
void SetPartArrayStatus(const char* name, int status);
const char* GetPartArrayName(int index);
// Description:
// volField selection list control
virtual vtkDataArraySelection* GetVolFieldSelection();
int GetNumberOfVolFieldArrays();
int GetVolFieldArrayStatus(const char* name);
void SetVolFieldArrayStatus(const char* name, int status);
const char* GetVolFieldArrayName(int index);
// Description:
// pointField selection list control
virtual vtkDataArraySelection* GetPointFieldSelection();
int GetNumberOfPointFieldArrays();
int GetPointFieldArrayStatus(const char* name);
void SetPointFieldArrayStatus(const char* name, int status);
const char* GetPointFieldArrayName(int index);
// Description:
// lagrangianField selection list control
virtual vtkDataArraySelection* GetLagrangianFieldSelection();
int GetNumberOfLagrangianFieldArrays();
int GetLagrangianFieldArrayStatus(const char* name);
void SetLagrangianFieldArrayStatus(const char* name, int status);
const char* GetLagrangianFieldArrayName(int index);
// Description:
// Callback registered with the SelectionObserver
// for all the selection lists
static void SelectionModifiedCallback
(
vtkObject* caller,
unsigned long eid,
void* clientdata,
void* calldata
);
void SelectionModified();
protected:
//- Construct null
vtkPV3FoamReader();
//- Destructor
~vtkPV3FoamReader();
//- Return information about mesh, times, etc without loading anything
virtual int RequestInformation
(
vtkInformation*,
vtkInformationVector**,
vtkInformationVector*
);
//- Get the mesh/fields for a particular time
virtual int RequestData
(
vtkInformation*,
vtkInformationVector**,
vtkInformationVector*
);
//- Fill in additional port information
virtual int FillOutputPortInformation(int, vtkInformation*);
//- The observer to modify this object when array selections are modified
vtkCallbackCommand* SelectionObserver;
//- The file name for this case
char* FileName;
private:
//- Disallow default bitwise copy construct
vtkPV3FoamReader(const vtkPV3FoamReader&);
//- Disallow default bitwise assignment
void operator=(const vtkPV3FoamReader&);
//- Add/remove patch names to/from the view
void updatePatchNamesView(const bool show);
int TimeStepRange[2];
int Refresh;
int CacheMesh;
int SkipZeroTime;
int ExtrapolatePatches;
int UseVTKPolyhedron;
int IncludeSets;
int IncludeZones;
int ShowPatchNames;
int ShowGroupsOnly;
int InterpolateVolFields;
//- Dummy variable/switch to invoke a reader update
int UpdateGUI;
vtkDataArraySelection* PartSelection;
vtkDataArraySelection* VolFieldSelection;
vtkDataArraySelection* PointFieldSelection;
vtkDataArraySelection* LagrangianFieldSelection;
//- Cached data for output port0 (experimental!)
vtkMultiBlockDataSet* output0_;
//BTX
Foam::vtkPV3Foam* foamData_;
//ETX
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,11 +0,0 @@
vtkPV3Foam.C
vtkPV3FoamFields.C
vtkPV3FoamMesh.C
vtkPV3FoamMeshLagrangian.C
vtkPV3FoamMeshSet.C
vtkPV3FoamMeshVolume.C
vtkPV3FoamMeshZone.C
vtkPV3FoamUpdateInfo.C
vtkPV3FoamUtils.C
LIB = $(FOAM_LIBBIN)/libvtkPV3Foam

View File

@ -1,21 +0,0 @@
/* Note: enable vtkPolyhedron when available */
EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I../../vtkPV3Readers/lnInclude \
-I../PV3FoamReader \
-I$(ParaView_INCLUDE_DIR) \
$(shell \
test -f $(ParaView_INCLUDE_DIR)/vtkPolyhedron.h && \
echo "-DHAS_VTK_POLYHEDRON" || echo "-UHAS_VTK_POLYHEDRON" \
)
LIB_LIBS = \
-lmeshTools \
-lfiniteVolume \
-lgenericPatchFields \
-llagrangian \
-L$(FOAM_LIBBIN) -lvtkPV3Readers \
$(GLIBS)

View File

@ -1,79 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
InClass
vtkPV3Foam
\*---------------------------------------------------------------------------*/
#ifndef vtkOpenFOAMPoints_H
#define vtkOpenFOAMPoints_H
// VTK includes
#include "vtkPoints.h"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
inline void vtkInsertNextOpenFOAMPoint
(
vtkPoints *points,
const Foam::point& p
)
{
points->InsertNextPoint(p.x(), p.y(), p.z());
}
#if 0
// this should be faster, but didn't get it working ...
inline void vtkSetOpenFOAMPoint
(
vtkPoints *points,
const Foam::label id,
const Foam::point& p
)
{
points->SetPoint(id, p.x(), p.y(), p.z());
}
// Convert OpenFOAM mesh vertices to VTK
inline vtkPoints* vtkSetOpenFOAMPoints(const Foam::pointField& points)
{
vtkPoints *vtkpoints = vtkPoints::New();
vtkpoints->SetNumberOfPoints(points.size());
forAll(points, i)
{
const Foam::point& p = points[i];
vtkpoints->SetPoint(i, p.x(), p.y(), p.z());
}
return vtkpoints;
}
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,59 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
InClass
vtkPV3Foam
\*---------------------------------------------------------------------------*/
#ifndef vtkOpenFOAMTupleRemap_H
#define vtkOpenFOAMTupleRemap_H
// OpenFOAM includes
#include "Swap.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
inline void vtkOpenFOAMTupleRemap(float vec[]);
// Template specialization for symmTensor
template<>
inline void vtkOpenFOAMTupleRemap<Foam::symmTensor>(float vec[])
{
Foam::Swap(vec[1], vec[3]); // swap XY <-> YY
Foam::Swap(vec[2], vec[5]); // swap XZ <-> ZZ
}
template<class Type>
inline void vtkOpenFOAMTupleRemap(float vec[])
{}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,839 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "vtkPV3Foam.H"
#include "vtkPV3FoamReader.h"
// OpenFOAM includes
#include "fvMesh.H"
#include "Time.H"
#include "patchZones.H"
// VTK includes
#include "vtkDataArraySelection.h"
#include "vtkMultiBlockDataSet.h"
#include "vtkRenderer.h"
#include "vtkTextActor.h"
#include "vtkTextProperty.h"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(vtkPV3Foam, 0);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
#include "vtkPV3FoamAddToSelection.H"
#include "vtkPV3FoamUpdateInfoFields.H"
void Foam::vtkPV3Foam::resetCounters()
{
// Reset array range information (ids and sizes)
arrayRangeVolume_.reset();
arrayRangePatches_.reset();
arrayRangeLagrangian_.reset();
arrayRangeCellZones_.reset();
arrayRangeFaceZones_.reset();
arrayRangePointZones_.reset();
arrayRangeCellSets_.reset();
arrayRangeFaceSets_.reset();
arrayRangePointSets_.reset();
}
void Foam::vtkPV3Foam::reduceMemory()
{
forAll(regionPolyDecomp_, i)
{
regionPolyDecomp_[i].clear();
}
forAll(zonePolyDecomp_, i)
{
zonePolyDecomp_[i].clear();
}
forAll(csetPolyDecomp_, i)
{
csetPolyDecomp_[i].clear();
}
if (!reader_->GetCacheMesh())
{
delete meshPtr_;
meshPtr_ = nullptr;
}
}
int Foam::vtkPV3Foam::setTime(int nRequest, const double requestTimes[])
{
Time& runTime = dbPtr_();
// Get times list
instantList Times = runTime.times();
int nearestIndex = timeIndex_;
for (int requestI = 0; requestI < nRequest; ++requestI)
{
int index = Time::findClosestTimeIndex(Times, requestTimes[requestI]);
if (index >= 0 && index != timeIndex_)
{
nearestIndex = index;
break;
}
}
if (nearestIndex < 0)
{
nearestIndex = 0;
}
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::setTime(";
for (int requestI = 0; requestI < nRequest; ++requestI)
{
if (requestI)
{
Info<< ", ";
}
Info<< requestTimes[requestI];
}
Info<< ") - previousIndex = " << timeIndex_
<< ", nearestIndex = " << nearestIndex << endl;
}
// see what has changed
if (timeIndex_ != nearestIndex)
{
timeIndex_ = nearestIndex;
runTime.setTime(Times[nearestIndex], nearestIndex);
// the fields change each time
fieldsChanged_ = true;
if (meshPtr_)
{
if (meshPtr_->readUpdate() != polyMesh::UNCHANGED)
{
meshChanged_ = true;
}
}
else
{
meshChanged_ = true;
}
reader_->UpdateProgress(0.05);
// this seems to be needed for catching Lagrangian fields
updateInfo();
}
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::setTime() - selectedTime="
<< Times[nearestIndex].name() << " index=" << timeIndex_
<< "/" << Times.size()
<< " meshChanged=" << Switch(meshChanged_)
<< " fieldsChanged=" << Switch(fieldsChanged_) << endl;
}
return nearestIndex;
}
void Foam::vtkPV3Foam::updateMeshPartsStatus()
{
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::updateMeshPartsStatus" << endl;
}
vtkDataArraySelection* selection = reader_->GetPartSelection();
label nElem = selection->GetNumberOfArrays();
if (partStatus_.size() != nElem)
{
partStatus_.setSize(nElem);
partStatus_ = false;
meshChanged_ = true;
}
// this needs fixing if we wish to re-use the datasets
partDataset_.setSize(nElem);
partDataset_ = -1;
// Read the selected mesh parts (zones, patches ...) and add to list
forAll(partStatus_, partId)
{
const int setting = selection->GetArraySetting(partId);
if (partStatus_[partId] != setting)
{
partStatus_[partId] = setting;
meshChanged_ = true;
}
if (debug)
{
Info<< " part[" << partId << "] = "
<< partStatus_[partId]
<< " : " << selection->GetArrayName(partId) << endl;
}
}
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::updateMeshPartsStatus" << endl;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::vtkPV3Foam::vtkPV3Foam
(
const char* const FileName,
vtkPV3FoamReader* reader
)
:
reader_(reader),
dbPtr_(nullptr),
meshPtr_(nullptr),
meshRegion_(polyMesh::defaultRegion),
meshDir_(polyMesh::meshSubDir),
timeIndex_(-1),
meshChanged_(true),
fieldsChanged_(true),
arrayRangeVolume_("unzoned"),
arrayRangePatches_("patches"),
arrayRangeLagrangian_("lagrangian"),
arrayRangeCellZones_("cellZone"),
arrayRangeFaceZones_("faceZone"),
arrayRangePointZones_("pointZone"),
arrayRangeCellSets_("cellSet"),
arrayRangeFaceSets_("faceSet"),
arrayRangePointSets_("pointSet")
{
if (debug)
{
Info<< "Foam::vtkPV3Foam::vtkPV3Foam - " << FileName << endl;
printMemory();
}
// avoid argList and get rootPath/caseName directly from the file
fileName fullCasePath(fileName(FileName).path());
if (!isDir(fullCasePath))
{
return;
}
if (fullCasePath == ".")
{
fullCasePath = cwd();
}
// Set the case as an environment variable - some BCs might use this
if (fullCasePath.name().find("processor", 0) == 0)
{
const fileName globalCase = fullCasePath.path();
setEnv("FOAM_CASE", globalCase, true);
setEnv("FOAM_CASENAME", globalCase.name(), true);
}
else
{
setEnv("FOAM_CASE", fullCasePath, true);
setEnv("FOAM_CASENAME", fullCasePath.name(), true);
}
// look for 'case{region}.OpenFOAM'
// could be stringent and insist the prefix match the directory name...
// Note: cannot use fileName::name() due to the embedded '{}'
string caseName(fileName(FileName).lessExt());
string::size_type beg = caseName.find_last_of("/{");
string::size_type end = caseName.find('}', beg);
if
(
beg != string::npos && caseName[beg] == '{'
&& end != string::npos && end == caseName.size()-1
)
{
meshRegion_ = caseName.substr(beg+1, end-beg-1);
// some safety
if (meshRegion_.empty())
{
meshRegion_ = polyMesh::defaultRegion;
}
if (meshRegion_ != polyMesh::defaultRegion)
{
meshDir_ = meshRegion_/polyMesh::meshSubDir;
}
}
if (debug)
{
Info<< "fullCasePath=" << fullCasePath << nl
<< "FOAM_CASE=" << getEnv("FOAM_CASE") << nl
<< "FOAM_CASENAME=" << getEnv("FOAM_CASENAME") << nl
<< "region=" << meshRegion_ << endl;
}
// Create time object
dbPtr_.reset
(
new Time
(
Time::controlDictName,
fileName(fullCasePath.path()),
fileName(fullCasePath.name())
)
);
dbPtr_().functionObjects().off();
updateInfo();
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::vtkPV3Foam::~vtkPV3Foam()
{
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::~vtkPV3Foam" << endl;
}
delete meshPtr_;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::vtkPV3Foam::updateInfo()
{
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::updateInfo"
<< " [meshPtr=" << (meshPtr_ ? "set" : "nullptr") << "] timeIndex="
<< timeIndex_ << endl;
}
resetCounters();
vtkDataArraySelection* partSelection = reader_->GetPartSelection();
// there are two ways to ensure we have the correct list of parts:
// 1. remove everything and then set particular entries 'on'
// 2. build a 'char **' list and call SetArraysWithDefault()
//
// Nr. 2 has the potential advantage of not touching the modification
// time of the vtkDataArraySelection, but the qt/paraview proxy
// layer doesn't care about that anyhow.
// enable 'internalMesh' on the first call
// or preserve the enabled selections
stringList enabledEntries;
if (!partSelection->GetNumberOfArrays() && !meshPtr_)
{
enabledEntries.setSize(1);
enabledEntries[0] = "internalMesh";
}
else
{
enabledEntries = getSelectedArrayEntries(partSelection);
}
// Clear current mesh parts list
partSelection->RemoveAllArrays();
// Update mesh parts list - add Lagrangian at the bottom
updateInfoInternalMesh(partSelection);
updateInfoPatches(partSelection, enabledEntries);
updateInfoSets(partSelection);
updateInfoZones(partSelection);
updateInfoLagrangian(partSelection);
// restore the enabled selections
setSelectedArrayEntries(partSelection, enabledEntries);
if (meshChanged_)
{
fieldsChanged_ = true;
}
// Update volume, point and lagrangian fields
updateInfoFields<fvPatchField, volMesh>
(
reader_->GetVolFieldSelection()
);
updateInfoFields<pointPatchField, pointMesh>
(
reader_->GetPointFieldSelection()
);
updateInfoLagrangianFields();
if (debug)
{
// just for debug info
getSelectedArrayEntries(partSelection);
Info<< "<end> Foam::vtkPV3Foam::updateInfo" << endl;
}
}
void Foam::vtkPV3Foam::updateFoamMesh()
{
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::updateFoamMesh" << endl;
printMemory();
}
if (!reader_->GetCacheMesh())
{
delete meshPtr_;
meshPtr_ = nullptr;
}
// Check to see if the OpenFOAM mesh has been created
if (!meshPtr_)
{
if (debug)
{
Info<< "Creating OpenFOAM mesh for region " << meshRegion_
<< " at time=" << dbPtr_().timeName()
<< endl;
}
meshPtr_ = new fvMesh
(
IOobject
(
meshRegion_,
dbPtr_().timeName(),
dbPtr_(),
IOobject::MUST_READ
)
);
meshChanged_ = true;
}
else
{
if (debug)
{
Info<< "Using existing OpenFOAM mesh" << endl;
}
}
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::updateFoamMesh" << endl;
printMemory();
}
}
void Foam::vtkPV3Foam::Update
(
vtkMultiBlockDataSet* output,
vtkMultiBlockDataSet* lagrangianOutput
)
{
if (debug)
{
cout<< "<beg> Foam::vtkPV3Foam::Update - output with "
<< output->GetNumberOfBlocks() << " and "
<< lagrangianOutput->GetNumberOfBlocks() << " blocks\n";
output->Print(cout);
lagrangianOutput->Print(cout);
printMemory();
}
reader_->UpdateProgress(0.1);
// Set up mesh parts selection(s)
updateMeshPartsStatus();
reader_->UpdateProgress(0.15);
// Update the OpenFOAM mesh
updateFoamMesh();
reader_->UpdateProgress(0.4);
// Convert meshes - start port0 at block=0
int blockNo = 0;
convertMeshVolume(output, blockNo);
convertMeshPatches(output, blockNo);
reader_->UpdateProgress(0.6);
if (reader_->GetIncludeZones())
{
convertMeshCellZones(output, blockNo);
convertMeshFaceZones(output, blockNo);
convertMeshPointZones(output, blockNo);
reader_->UpdateProgress(0.65);
}
if (reader_->GetIncludeSets())
{
convertMeshCellSets(output, blockNo);
convertMeshFaceSets(output, blockNo);
convertMeshPointSets(output, blockNo);
reader_->UpdateProgress(0.7);
}
#ifdef VTKPV3FOAM_DUALPORT
// restart port1 at block=0
blockNo = 0;
#endif
convertMeshLagrangian(lagrangianOutput, blockNo);
reader_->UpdateProgress(0.8);
// Update fields
convertVolFields(output);
convertPointFields(output);
convertLagrangianFields(lagrangianOutput);
if (debug)
{
Info<< "done reader part" << endl;
}
reader_->UpdateProgress(0.95);
meshChanged_ = fieldsChanged_ = false;
}
void Foam::vtkPV3Foam::CleanUp()
{
// reclaim some memory
reduceMemory();
reader_->UpdateProgress(1.0);
}
double* Foam::vtkPV3Foam::findTimes(int& nTimeSteps)
{
int nTimes = 0;
double* tsteps = nullptr;
if (dbPtr_.valid())
{
Time& runTime = dbPtr_();
instantList timeLst = runTime.times();
// find the first time for which this mesh appears to exist
label timeI = 0;
for (; timeI < timeLst.size(); ++timeI)
{
const word& timeName = timeLst[timeI].name();
if
(
isFile(runTime.path()/timeName/meshDir_/"points")
&& IOobject
(
"points",
timeName,
meshDir_,
runTime
).typeHeaderOk<pointIOField>(true)
)
{
break;
}
}
nTimes = timeLst.size() - timeI;
// skip "constant" time whenever possible
if (timeI == 0 && nTimes > 1)
{
if (timeLst[timeI].name() == runTime.constant())
{
++timeI;
--nTimes;
}
}
// skip "0/" time if requested and possible
if (nTimes > 1 && reader_->GetSkipZeroTime())
{
if (mag(timeLst[timeI].value()) < SMALL)
{
++timeI;
--nTimes;
}
}
if (nTimes)
{
tsteps = new double[nTimes];
for (label stepI = 0; stepI < nTimes; ++stepI, ++timeI)
{
tsteps[stepI] = timeLst[timeI].value();
}
}
}
else
{
if (debug)
{
cout<< "no valid dbPtr:\n";
}
}
// vector length returned via the parameter
nTimeSteps = nTimes;
return tsteps;
}
void Foam::vtkPV3Foam::renderPatchNames(vtkRenderer* renderer, const bool show)
{
if (!meshPtr_)
{
return;
}
// always remove old actors first
forAll(patchTextActorsPtrs_, patchi)
{
renderer->RemoveViewProp(patchTextActorsPtrs_[patchi]);
patchTextActorsPtrs_[patchi]->Delete();
}
patchTextActorsPtrs_.clear();
if (show)
{
// get the display patches, strip off any suffix
wordHashSet selectedPatches = getSelected
(
reader_->GetPartSelection(),
arrayRangePatches_
);
if (selectedPatches.empty())
{
return;
}
const polyBoundaryMesh& pbMesh = meshPtr_->boundaryMesh();
// Find the total number of zones
// Each zone will take the patch name
// Number of zones per patch ... zero zones should be skipped
labelList nZones(pbMesh.size(), 0);
// Per global zone number the average face centre position
List<DynamicList<point>> zoneCentre(pbMesh.size());
// Loop through all patches to determine zones, and centre of each zone
forAll(pbMesh, patchi)
{
const polyPatch& pp = pbMesh[patchi];
// Only include the patch if it is selected
if (!selectedPatches.found(pp.name()))
{
continue;
}
const labelListList& edgeFaces = pp.edgeFaces();
const vectorField& n = pp.faceNormals();
boolList featEdge(pp.nEdges(), false);
forAll(edgeFaces, edgeI)
{
const labelList& eFaces = edgeFaces[edgeI];
if (eFaces.size() == 1)
{
// Note: could also do ones with > 2 faces but this gives
// too many zones for baffles
featEdge[edgeI] = true;
}
else if (mag(n[eFaces[0]] & n[eFaces[1]]) < 0.5)
{
featEdge[edgeI] = true;
}
}
// Do topological analysis of patch, find disconnected regions
patchZones pZones(pp, featEdge);
nZones[patchi] = pZones.nZones();
labelList zoneNFaces(pZones.nZones(), 0);
// Create storage for additional zone centres
forAll(zoneNFaces, zoneI)
{
zoneCentre[patchi].append(Zero);
}
// Do averaging per individual zone
forAll(pp, facei)
{
label zoneI = pZones[facei];
zoneCentre[patchi][zoneI] += pp[facei].centre(pp.points());
zoneNFaces[zoneI]++;
}
forAll(zoneCentre[patchi], zoneI)
{
zoneCentre[patchi][zoneI] /= zoneNFaces[zoneI];
}
}
// Count number of zones we're actually going to display.
// This is truncated to a max per patch
const label MAXPATCHZONES = 20;
label displayZoneI = 0;
forAll(pbMesh, patchi)
{
displayZoneI += min(MAXPATCHZONES, nZones[patchi]);
}
if (debug)
{
Info<< "displayed zone centres = " << displayZoneI << nl
<< "zones per patch = " << nZones << endl;
}
// Set the size of the patch labels to max number of zones
patchTextActorsPtrs_.setSize(displayZoneI);
if (debug)
{
Info<< "constructing patch labels" << endl;
}
// Actor index
displayZoneI = 0;
forAll(pbMesh, patchi)
{
const polyPatch& pp = pbMesh[patchi];
label globalZoneI = 0;
// Only selected patches will have a non-zero number of zones
label nDisplayZones = min(MAXPATCHZONES, nZones[patchi]);
label increment = 1;
if (nZones[patchi] >= MAXPATCHZONES)
{
increment = nZones[patchi]/MAXPATCHZONES;
}
for (label i = 0; i < nDisplayZones; i++)
{
if (debug)
{
Info<< "patch name = " << pp.name() << nl
<< "anchor = " << zoneCentre[patchi][globalZoneI] << nl
<< "globalZoneI = " << globalZoneI << endl;
}
vtkTextActor* txt = vtkTextActor::New();
txt->SetInput(pp.name().c_str());
// Set text properties
vtkTextProperty* tprop = txt->GetTextProperty();
tprop->SetFontFamilyToArial();
tprop->BoldOff();
tprop->ShadowOff();
tprop->SetLineSpacing(1.0);
tprop->SetFontSize(12);
tprop->SetColor(1.0, 0.0, 0.0);
tprop->SetJustificationToCentered();
// Set text to use 3-D world co-ordinates
txt->GetPositionCoordinate()->SetCoordinateSystemToWorld();
txt->GetPositionCoordinate()->SetValue
(
zoneCentre[patchi][globalZoneI].x(),
zoneCentre[patchi][globalZoneI].y(),
zoneCentre[patchi][globalZoneI].z()
);
// Add text to each renderer
renderer->AddViewProp(txt);
// Maintain a list of text labels added so that they can be
// removed later
patchTextActorsPtrs_[displayZoneI] = txt;
globalZoneI += increment;
displayZoneI++;
}
}
// Resize the patch names list to the actual number of patch names added
patchTextActorsPtrs_.setSize(displayZoneI);
}
}
void Foam::vtkPV3Foam::PrintSelf(ostream& os, vtkIndent indent) const
{
os << indent << "Number of nodes: "
<< (meshPtr_ ? meshPtr_->nPoints() : 0) << "\n";
os << indent << "Number of cells: "
<< (meshPtr_ ? meshPtr_->nCells() : 0) << "\n";
os << indent << "Number of available time steps: "
<< (dbPtr_.valid() ? dbPtr_().times().size() : 0) << "\n";
os << indent << "mesh region: " << meshRegion_ << "\n";
}
// ************************************************************************* //

View File

@ -1,741 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
Class
Foam::vtkPV3Foam
Description
Provides a reader interface for OpenFOAM to VTK interaction.
SourceFiles
vtkPV3Foam.C
vtkPV3Foam.H
vtkPV3FoamFields.C
vtkPV3FoamMesh.C
vtkPV3FoamMeshLagrangian.C
vtkPV3FoamTemplates.C
vtkPV3FoamMeshSet.C
vtkPV3FoamMeshVolume.C
vtkPV3FoamMeshZone.C
vtkPV3FoamFaceField.H
vtkPV3FoamLagrangianFields.H
vtkPV3FoamPatchField.H
vtkPV3FoamPointFields.H
vtkPV3FoamPoints.H
vtkPV3FoamUpdateInfo.C
vtkPV3FoamUpdateInfoFields.H
vtkPV3FoamUtils.C
vtkPV3FoamVolFields.H
vtkPV3FoamAddToSelection.H
// Needed by VTK:
vtkDataArrayTemplateImplicit.txx
\*---------------------------------------------------------------------------*/
#ifndef vtkPV3Foam_H
#define vtkPV3Foam_H
// do not include legacy strstream headers
#ifndef VTK_EXCLUDE_STRSTREAM_HEADERS
# define VTK_EXCLUDE_STRSTREAM_HEADERS
#endif
#include "className.H"
#include "fileName.H"
#include "stringList.H"
#include "wordList.H"
#include "primitivePatch.H"
#include "PrimitivePatchInterpolation.H"
#include "volPointInterpolation.H"
#undef VTKPV3FOAM_DUALPORT
// * * * * * * * * * * * * * Forward Declarations * * * * * * * * * * * * * //
class vtkDataArraySelection;
class vtkDataSet;
class vtkPoints;
class vtkPV3FoamReader;
class vtkRenderer;
class vtkTextActor;
class vtkMultiBlockDataSet;
class vtkPolyData;
class vtkUnstructuredGrid;
class vtkIndent;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// OpenFOAM class forward declarations
class argList;
class Time;
class fvMesh;
class IOobjectList;
class polyPatch;
class faceSet;
class pointSet;
template<class Type> class IOField;
template<class Type> class List;
/*---------------------------------------------------------------------------*\
Class vtkPV3Foam Declaration
\*---------------------------------------------------------------------------*/
class vtkPV3Foam
{
// Private classes
//- Bookkeeping for GUI checklists and the multi-block organization
class arrayRange
{
const char *name_;
int block_;
int start_;
int size_;
public:
arrayRange(const char *name, const int blockNo=0)
:
name_(name),
block_(blockNo),
start_(0),
size_(0)
{}
//- Return the block holding these datasets
int block() const
{
return block_;
}
//- Assign block number, return previous value
int block(int blockNo)
{
int prev = block_;
block_ = blockNo;
return prev;
}
//- Return block name
const char* name() const
{
return name_;
}
//- Return array start index
int start() const
{
return start_;
}
//- Return array end index
int end() const
{
return start_ + size_;
}
//- Return sublist size
int size() const
{
return size_;
}
bool empty() const
{
return !size_;
}
//- Reset the size to zero and optionally assign a new start
void reset(const int startAt = 0)
{
start_ = startAt;
size_ = 0;
}
//- Increment the size
void operator+=(const int n)
{
size_ += n;
}
};
//- Bookkeeping for polyhedral cell decomposition
// hide in extra pointMap (cellSet/cellZone) for now
class polyDecomp
{
labelList superCells_;
labelList addPointCellLabels_;
labelList pointMap_;
public:
polyDecomp()
{}
//- Label of original cell for decomposed cells
labelList& superCells()
{
return superCells_;
}
//- Label of original cell for decomposed cells
const labelList& superCells() const
{
return superCells_;
}
//- Cell-centre labels for additional points of decomposed cells
labelList& addPointCellLabels()
{
return addPointCellLabels_;
}
//- Cell-centre labels for additional points of decomposed cells
const labelList& addPointCellLabels() const
{
return addPointCellLabels_;
}
//- Point labels for subsetted meshes
labelList& pointMap()
{
return pointMap_;
}
//- Point labels for subsetted meshes
const labelList& pointMap() const
{
return pointMap_;
}
//- Clear
void clear()
{
superCells_.clear();
addPointCellLabels_.clear();
pointMap_.clear();
}
};
// Private Data
//- Access to the controlling vtkPV3FoamReader
vtkPV3FoamReader* reader_;
//- OpenFOAM time control
autoPtr<Time> dbPtr_;
//- OpenFOAM mesh
fvMesh* meshPtr_;
//- The mesh region
word meshRegion_;
//- The mesh directory for the region
fileName meshDir_;
//- The time index
int timeIndex_;
//- Track changes in mesh geometry
bool meshChanged_;
//- Track changes in fields
bool fieldsChanged_;
//- Selected geometrical parts (internalMesh, patches, ...)
boolList partStatus_;
//- Datasets corresponding to selected geometrical pieces
// a negative number indicates that no vtkmesh exists for this piece
labelList partDataset_;
//- First instance and size of various mesh parts
// used to index into partStatus_ and partDataset_
arrayRange arrayRangeVolume_;
arrayRange arrayRangePatches_;
arrayRange arrayRangeLagrangian_;
arrayRange arrayRangeCellZones_;
arrayRange arrayRangeFaceZones_;
arrayRange arrayRangePointZones_;
arrayRange arrayRangeCellSets_;
arrayRange arrayRangeFaceSets_;
arrayRange arrayRangePointSets_;
//- Decomposed cells information (mesh regions)
// TODO: regions
List<polyDecomp> regionPolyDecomp_;
//- Decomposed cells information (cellZone meshes)
List<polyDecomp> zonePolyDecomp_;
//- Decomposed cells information (cellSet meshes)
List<polyDecomp> csetPolyDecomp_;
//- List of patch names for rendering to window
List<vtkTextActor*> patchTextActorsPtrs_;
// Private Member Functions
// Convenience method use to convert the readers from VTK 5
// multiblock API to the current composite data infrastructure
static void AddToBlock
(
vtkMultiBlockDataSet* output,
vtkDataSet* dataset,
const arrayRange&,
const label datasetNo,
const std::string& datasetName
);
// Convenience method use to convert the readers from VTK 5
// multiblock API to the current composite data infrastructure
static vtkDataSet* GetDataSetFromBlock
(
vtkMultiBlockDataSet* output,
const arrayRange&,
const label datasetNo
);
// Convenience method use to convert the readers from VTK 5
// multiblock API to the current composite data infrastructure
static label GetNumberOfDataSets
(
vtkMultiBlockDataSet* output,
const arrayRange&
);
//- Reset data counters
void resetCounters();
// Update information helper functions
//- Update the mesh parts selected in the GUI
void updateMeshPartsStatus();
//- Internal mesh info
void updateInfoInternalMesh(vtkDataArraySelection*);
//- Lagrangian info
void updateInfoLagrangian(vtkDataArraySelection*);
//- Patch info
void updateInfoPatches(vtkDataArraySelection*, stringList&);
//- Set info
void updateInfoSets(vtkDataArraySelection*);
//- Zone info
void updateInfoZones(vtkDataArraySelection*);
//- Get non-empty zone names for zoneType from file
wordList getZoneNames(const word& zoneType) const;
//- Get non-empty zone names from mesh info
template<class ZoneType>
wordList getZoneNames
(
const ZoneMesh<ZoneType, polyMesh>&
) const;
//- Add objects of Type to paraview array selection
template<class Type>
label addToSelection
(
vtkDataArraySelection*,
const IOobjectList&,
const string& suffix=string::null
);
//- Field info
template<template<class> class patchType, class meshType>
void updateInfoFields(vtkDataArraySelection*);
//- Lagrangian field info
void updateInfoLagrangianFields();
// Update helper functions
//- OpenFOAM mesh
void updateFoamMesh();
//- Reduce memory footprint after conversion
void reduceMemory();
//- Volume fields
void updateVolFields(vtkMultiBlockDataSet*);
//- Point fields
void updatePointFields(vtkMultiBlockDataSet*);
//- Lagrangian fields
void updateLagrangianFields(vtkMultiBlockDataSet*);
// Mesh conversion functions
//- Volume mesh
void convertMeshVolume(vtkMultiBlockDataSet*, int& blockNo);
//- Lagrangian mesh
void convertMeshLagrangian(vtkMultiBlockDataSet*, int& blockNo);
//- Patch meshes
void convertMeshPatches(vtkMultiBlockDataSet*, int& blockNo);
//- Cell zone meshes
void convertMeshCellZones(vtkMultiBlockDataSet*, int& blockNo);
//- Face zone meshes
void convertMeshFaceZones(vtkMultiBlockDataSet*, int& blockNo);
//- Point zone meshes
void convertMeshPointZones(vtkMultiBlockDataSet*, int& blockNo);
//- Cell set meshes
void convertMeshCellSets(vtkMultiBlockDataSet*, int& blockNo);
//- Face set meshes
void convertMeshFaceSets(vtkMultiBlockDataSet*, int& blockNo);
//- Point set meshes
void convertMeshPointSets(vtkMultiBlockDataSet*, int& blockNo);
// Add mesh functions
//- Add internal mesh/cell set meshes
vtkUnstructuredGrid* volumeVTKMesh(const fvMesh&, polyDecomp&);
//- Add Lagrangian mesh
vtkPolyData* lagrangianVTKMesh
(
const fvMesh&,
const word& cloudName
);
//- Add patch mesh
template<class PatchType>
vtkPolyData* patchVTKMesh(const word& name, const PatchType&);
//- Add point zone
vtkPolyData* pointZoneVTKMesh
(
const fvMesh&,
const labelList& pointLabels
);
//- Add face set mesh
vtkPolyData* faceSetVTKMesh
(
const fvMesh&,
const faceSet&
);
//- Add point mesh
vtkPolyData* pointSetVTKMesh
(
const fvMesh&,
const pointSet&
);
// Field conversion functions
//- Convert volume fields
void convertVolFields(vtkMultiBlockDataSet*);
//- Convert point fields
void convertPointFields(vtkMultiBlockDataSet*);
//- Convert Lagrangian fields
void convertLagrangianFields(vtkMultiBlockDataSet*);
//- Add the fields in the selected time directory to the selection
// lists
template<class GeoField>
label addObjectsToSelection
(
vtkDataArraySelection*,
const IOobjectList&,
const string& suffix=string::null
);
// Convert OpenFOAM fields
//- Volume fields - all types
template<class Type>
void convertVolFields
(
const fvMesh&,
const PtrList<PrimitivePatchInterpolation<primitivePatch>>&,
const IOobjectList&,
const bool interpFields,
vtkMultiBlockDataSet* output
);
//- Volume field - all selected parts
template<class Type>
void convertVolFieldBlock
(
const GeometricField<Type, fvPatchField, volMesh>&,
autoPtr<GeometricField<Type, pointPatchField, pointMesh>>&,
vtkMultiBlockDataSet* output,
const arrayRange&,
const List<polyDecomp>& decompLst
);
//- Volume field
template<class Type>
void convertVolField
(
const GeometricField<Type, fvPatchField, volMesh>&,
vtkMultiBlockDataSet* output,
const arrayRange&,
const label datasetNo,
const polyDecomp&
);
//- Patch field
template<class Type>
void convertPatchField
(
const word& name,
const Field<Type>&,
vtkMultiBlockDataSet* output,
const arrayRange&,
const label datasetNo
);
//- Face set/zone field
template<class Type>
void convertFaceField
(
const GeometricField<Type, fvPatchField, volMesh>&,
vtkMultiBlockDataSet* output,
const arrayRange&,
const label datasetNo,
const fvMesh&,
const labelList& faceLabels
);
//- Lagrangian fields - all types
template<class Type>
void convertLagrangianFields
(
const IOobjectList&,
vtkMultiBlockDataSet* output,
const label datasetNo
);
//- Lagrangian field
template<class Type>
void convertLagrangianField
(
const IOField<Type>&,
vtkMultiBlockDataSet* output,
const arrayRange&,
const label datasetNo
);
//- Point fields - all types
template<class Type>
void convertPointFields
(
const fvMesh&,
const pointMesh&,
const IOobjectList&,
vtkMultiBlockDataSet* output
);
//- Point field - all selected parts
template<class Type>
void convertPointFieldBlock
(
const GeometricField<Type, pointPatchField, pointMesh>&,
vtkMultiBlockDataSet* output,
const arrayRange&,
const List<polyDecomp>&
);
//- Point fields
template<class Type>
void convertPointField
(
const GeometricField<Type, pointPatchField, pointMesh>&,
const GeometricField<Type, fvPatchField, volMesh>&,
vtkMultiBlockDataSet* output,
const arrayRange&,
const label datasetNo,
const polyDecomp&
);
//- Patch point field
template<class Type>
void convertPatchPointField
(
const word& name,
const Field<Type>&,
vtkMultiBlockDataSet* output,
const arrayRange&,
const label datasetNo
);
// GUI selection helper functions
//- Only keep what is listed in hashSet
static void pruneObjectList
(
IOobjectList&,
const wordHashSet&
);
//- Retrieve the current selections
static wordHashSet getSelected(vtkDataArraySelection*);
//- Retrieve a sub-list of the current selections
static wordHashSet getSelected
(
vtkDataArraySelection*,
const arrayRange&
);
//- Retrieve the current selections
static stringList getSelectedArrayEntries(vtkDataArraySelection*);
//- Retrieve a sub-list of the current selections
static stringList getSelectedArrayEntries
(
vtkDataArraySelection*,
const arrayRange&
);
//- Set selection(s)
static void setSelectedArrayEntries
(
vtkDataArraySelection*,
const stringList&
);
//- Get the first word from the mesh parts selection
word getPartName(const int);
//- Disallow default bitwise copy construct
vtkPV3Foam(const vtkPV3Foam&);
//- Disallow default bitwise assignment
void operator=(const vtkPV3Foam&);
public:
//- Static data members
ClassName("vtkPV3Foam");
// Constructors
//- Construct from components
vtkPV3Foam
(
const char* const FileName,
vtkPV3FoamReader* reader
);
//- Destructor
~vtkPV3Foam();
// Member Functions
//- Update
void updateInfo();
void Update
(
vtkMultiBlockDataSet* output,
vtkMultiBlockDataSet* lagrangianOutput
);
//- Clean any storage
void CleanUp();
//- Allocate and return a list of selected times
// returns the count via the parameter
double* findTimes(int& nTimeSteps);
//- Add/remove patch names to/from the view
void renderPatchNames(vtkRenderer*, const bool show);
//- Set the runTime to the first plausible request time,
// returns the timeIndex
// sets to "constant" on error
int setTime(int count, const double requestTimes[]);
//- The current time index
int timeIndex() const
{
return timeIndex_;
}
// Access
//- Debug information
void PrintSelf(ostream&, vtkIndent) const;
//- Simple memory used debugging information
static void printMemory();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "vtkPV3FoamTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,74 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#ifndef vtkPV3FoamAddToSelection_H
#define vtkPV3FoamAddToSelection_H
// OpenFOAM includes
#include "IOobjectList.H"
#include "SortableList.H"
// VTK includes
#include "vtkDataArraySelection.h"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
Foam::label Foam::vtkPV3Foam::addToSelection
(
vtkDataArraySelection *select,
const IOobjectList& objectLst,
const string& suffix
)
{
SortableList<word> names(objectLst.names(Type::typeName));
forAll(names, nameI)
{
if (suffix.size())
{
select->AddArray
(
(names[nameI] + suffix).c_str()
);
}
else
{
select->AddArray
(
(names[nameI]).c_str()
);
}
}
return names.size();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,117 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
InClass
vtkPV3Foam
\*---------------------------------------------------------------------------*/
#ifndef vtkPV3FoamFaceField_H
#define vtkPV3FoamFaceField_H
// VTK includes
#include "vtkCellData.h"
#include "vtkFloatArray.h"
#include "vtkMultiBlockDataSet.h"
#include "vtkPolyData.h"
#include "vtkOpenFOAMTupleRemap.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
void Foam::vtkPV3Foam::convertFaceField
(
const GeometricField<Type, fvPatchField, volMesh>& tf,
vtkMultiBlockDataSet* output,
const arrayRange& range,
const label datasetNo,
const fvMesh& mesh,
const labelList& faceLabels
)
{
const label nComp = pTraits<Type>::nComponents;
const label nInternalFaces = mesh.nInternalFaces();
const labelList& faceOwner = mesh.faceOwner();
const labelList& faceNeigh = mesh.faceNeighbour();
vtkFloatArray* cellData = vtkFloatArray::New();
cellData->SetNumberOfTuples(faceLabels.size());
cellData->SetNumberOfComponents(nComp);
cellData->Allocate(nComp*faceLabels.size());
cellData->SetName(tf.name().c_str());
if (debug)
{
Info<< "convert convertFaceField: "
<< tf.name()
<< " size = " << tf.size()
<< " nComp=" << nComp
<< " nTuples = " << faceLabels.size() << endl;
}
float vec[nComp];
// for interior faces: average owner/neighbour
// for boundary faces: owner
forAll(faceLabels, facei)
{
const label faceNo = faceLabels[facei];
if (faceNo < nInternalFaces)
{
Type t = 0.5*(tf[faceOwner[faceNo]] + tf[faceNeigh[faceNo]]);
for (direction d=0; d<nComp; ++d)
{
vec[d] = component(t, d);
}
}
else
{
const Type& t = tf[faceOwner[faceNo]];
for (direction d=0; d<nComp; ++d)
{
vec[d] = component(t, d);
}
}
vtkOpenFOAMTupleRemap<Type>(vec);
cellData->InsertTuple(facei, vec);
}
vtkPolyData::SafeDownCast
(
GetDataSetFromBlock(output, range, datasetNo)
) ->GetCellData()
->AddArray(cellData);
cellData->Delete();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,325 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "vtkPV3Foam.H"
// OpenFOAM includes
#include "IOobjectList.H"
#include "vtkPV3FoamReader.h"
// VTK includes
#include "vtkDataArraySelection.h"
#include "vtkPolyData.h"
#include "vtkUnstructuredGrid.h"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
#include "vtkPV3FoamVolFields.H"
#include "vtkPV3FoamPointFields.H"
#include "vtkPV3FoamLagrangianFields.H"
void Foam::vtkPV3Foam::pruneObjectList
(
IOobjectList& objects,
const wordHashSet& selected
)
{
// hash all the selected field names
if (selected.empty())
{
objects.clear();
}
// only keep selected fields
forAllIter(IOobjectList, objects, iter)
{
if (!selected.found(iter()->name()))
{
objects.erase(iter);
}
}
}
void Foam::vtkPV3Foam::convertVolFields
(
vtkMultiBlockDataSet* output
)
{
const fvMesh& mesh = *meshPtr_;
wordHashSet selectedFields = getSelected
(
reader_->GetVolFieldSelection()
);
if (selectedFields.empty())
{
return;
}
// Get objects (fields) for this time - only keep selected fields
// the region name is already in the mesh db
IOobjectList objects(mesh, dbPtr_().timeName());
pruneObjectList(objects, selectedFields);
if (objects.empty())
{
return;
}
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::convertVolFields" << nl
<< "converting OpenFOAM volume fields" << endl;
forAllConstIter(IOobjectList, objects, iter)
{
Info<< " " << iter()->name()
<< " == " << iter()->objectPath() << nl;
}
printMemory();
}
PtrList<PrimitivePatchInterpolation<primitivePatch>>
ppInterpList(mesh.boundaryMesh().size());
forAll(ppInterpList, i)
{
ppInterpList.set
(
i,
new PrimitivePatchInterpolation<primitivePatch>
(
mesh.boundaryMesh()[i]
)
);
}
bool interpFields = reader_->GetInterpolateVolFields();
convertVolFields<scalar>
(
mesh, ppInterpList, objects, interpFields, output
);
convertVolFields<vector>
(
mesh, ppInterpList, objects, interpFields, output
);
convertVolFields<sphericalTensor>
(
mesh, ppInterpList, objects, interpFields, output
);
convertVolFields<symmTensor>
(
mesh, ppInterpList, objects, interpFields, output
);
convertVolFields<tensor>
(
mesh, ppInterpList, objects, interpFields, output
);
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::convertVolFields" << endl;
printMemory();
}
}
void Foam::vtkPV3Foam::convertPointFields
(
vtkMultiBlockDataSet* output
)
{
const fvMesh& mesh = *meshPtr_;
wordHashSet selectedFields = getSelected
(
reader_->GetPointFieldSelection()
);
if (selectedFields.empty())
{
if (debug)
{
Info<< "no point fields selected" << endl;
}
return;
}
// Get objects (fields) for this time - only keep selected fields
// the region name is already in the mesh db
IOobjectList objects(mesh, dbPtr_().timeName());
pruneObjectList(objects, selectedFields);
if (objects.empty())
{
return;
}
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::convertPointFields" << nl
<< "converting OpenFOAM volume fields -> point fields" << endl;
forAllConstIter(IOobjectList, objects, iter)
{
Info<< " " << iter()->name()
<< " == " << iter()->objectPath() << nl;
}
printMemory();
}
// Construct interpolation on the raw mesh
const pointMesh& pMesh = pointMesh::New(mesh);
convertPointFields<scalar>
(
mesh, pMesh, objects, output
);
convertPointFields<vector>
(
mesh, pMesh, objects, output
);
convertPointFields<sphericalTensor>
(
mesh, pMesh, objects, output
);
convertPointFields<symmTensor>
(
mesh, pMesh, objects, output
);
convertPointFields<tensor>
(
mesh, pMesh, objects, output
);
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::convertPointFields" << endl;
printMemory();
}
}
void Foam::vtkPV3Foam::convertLagrangianFields
(
vtkMultiBlockDataSet* output
)
{
arrayRange& range = arrayRangeLagrangian_;
const fvMesh& mesh = *meshPtr_;
wordHashSet selectedFields = getSelected
(
reader_->GetLagrangianFieldSelection()
);
if (selectedFields.empty())
{
return;
}
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::convertLagrangianFields" << endl;
printMemory();
}
for (int partId = range.start(); partId < range.end(); ++partId)
{
const word cloudName = getPartName(partId);
const label datasetNo = partDataset_[partId];
if (!partStatus_[partId] || datasetNo < 0)
{
continue;
}
// Get the Lagrangian fields for this time and this cloud
// but only keep selected fields
// the region name is already in the mesh db
IOobjectList objects
(
mesh,
dbPtr_().timeName(),
cloud::prefix/cloudName
);
pruneObjectList(objects, selectedFields);
if (objects.empty())
{
continue;
}
if (debug)
{
Info<< "converting OpenFOAM lagrangian fields" << nl;
forAllConstIter(IOobjectList, objects, iter)
{
Info<< " " << iter()->name()
<< " == " << iter()->objectPath() << nl;
}
}
convertLagrangianFields<label>
(
objects, output, datasetNo
);
convertLagrangianFields<scalar>
(
objects, output, datasetNo
);
convertLagrangianFields<vector>
(
objects, output, datasetNo
);
convertLagrangianFields<sphericalTensor>
(
objects, output, datasetNo
);
convertLagrangianFields<symmTensor>
(
objects, output, datasetNo
);
convertLagrangianFields<tensor>
(
objects, output, datasetNo
);
}
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::convertLagrangianFields" << endl;
printMemory();
}
}
// ************************************************************************* //

View File

@ -1,113 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
InClass
vtkPV3Foam
\*---------------------------------------------------------------------------*/
#ifndef vtkPV3FoamLagrangianFields_H
#define vtkPV3FoamLagrangianFields_H
#include "Cloud.H"
#include "vtkOpenFOAMTupleRemap.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
void Foam::vtkPV3Foam::convertLagrangianFields
(
const IOobjectList& objects,
vtkMultiBlockDataSet* output,
const label datasetNo
)
{
const arrayRange& range = arrayRangeLagrangian_;
forAllConstIter(IOobjectList, objects, iter)
{
// restrict to this IOField<Type>
if (iter()->headerClassName() == IOField<Type>::typeName)
{
IOField<Type> tf(*iter());
convertLagrangianField(tf, output, range, datasetNo);
}
}
}
template<class Type>
void Foam::vtkPV3Foam::convertLagrangianField
(
const IOField<Type>& tf,
vtkMultiBlockDataSet* output,
const arrayRange& range,
const label datasetNo
)
{
const label nComp = pTraits<Type>::nComponents;
vtkFloatArray* pointData = vtkFloatArray::New();
pointData->SetNumberOfTuples(tf.size());
pointData->SetNumberOfComponents(nComp);
pointData->Allocate(nComp*tf.size());
pointData->SetName(tf.name().c_str());
if (debug)
{
Info<< "convert LagrangianField: "
<< tf.name()
<< " size = " << tf.size()
<< " nComp=" << nComp
<< " nTuples = " << tf.size() << endl;
}
float vec[nComp];
forAll(tf, i)
{
const Type& t = tf[i];
for (direction d=0; d<nComp; ++d)
{
vec[d] = component(t, d);
}
vtkOpenFOAMTupleRemap<Type>(vec);
pointData->InsertTuple(i, vec);
}
vtkPolyData::SafeDownCast
(
GetDataSetFromBlock(output, range, datasetNo)
) ->GetPointData()
->AddArray(pointData);
pointData->Delete();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,651 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "vtkPV3Foam.H"
// OpenFOAM includes
#include "cellSet.H"
#include "faceSet.H"
#include "pointSet.H"
#include "fvMeshSubset.H"
#include "vtkPV3FoamReader.h"
#include "uindirectPrimitivePatch.H"
// VTK includes
#include "vtkDataArraySelection.h"
#include "vtkMultiBlockDataSet.h"
#include "vtkPolyData.h"
#include "vtkUnstructuredGrid.h"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::vtkPV3Foam::convertMeshVolume
(
vtkMultiBlockDataSet* output,
int& blockNo
)
{
arrayRange& range = arrayRangeVolume_;
range.block(blockNo); // set output block
label datasetNo = 0; // restart at dataset 0
const fvMesh& mesh = *meshPtr_;
// resize for decomposed polyhedra
regionPolyDecomp_.setSize(range.size());
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::convertMeshVolume" << endl;
printMemory();
}
// Convert the internalMesh
// this looks like more than one part, but it isn't
for (int partId = range.start(); partId < range.end(); ++partId)
{
const word partName = "internalMesh";
if (!partStatus_[partId])
{
continue;
}
vtkUnstructuredGrid* vtkmesh = volumeVTKMesh
(
mesh,
regionPolyDecomp_[datasetNo]
);
if (vtkmesh)
{
AddToBlock(output, vtkmesh, range, datasetNo, partName);
vtkmesh->Delete();
partDataset_[partId] = datasetNo++;
}
}
// anything added?
if (datasetNo)
{
++blockNo;
}
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::convertMeshVolume" << endl;
printMemory();
}
}
void Foam::vtkPV3Foam::convertMeshLagrangian
(
vtkMultiBlockDataSet* output,
int& blockNo
)
{
arrayRange& range = arrayRangeLagrangian_;
range.block(blockNo); // set output block
label datasetNo = 0; // restart at dataset 0
const fvMesh& mesh = *meshPtr_;
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::convertMeshLagrangian" << endl;
printMemory();
}
for (int partId = range.start(); partId < range.end(); ++partId)
{
const word cloudName = getPartName(partId);
if (!partStatus_[partId])
{
continue;
}
vtkPolyData* vtkmesh = lagrangianVTKMesh(mesh, cloudName);
if (vtkmesh)
{
AddToBlock(output, vtkmesh, range, datasetNo, cloudName);
vtkmesh->Delete();
partDataset_[partId] = datasetNo++;
}
}
// anything added?
if (datasetNo)
{
++blockNo;
}
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::convertMeshLagrangian" << endl;
printMemory();
}
}
void Foam::vtkPV3Foam::convertMeshPatches
(
vtkMultiBlockDataSet* output,
int& blockNo
)
{
arrayRange& range = arrayRangePatches_;
range.block(blockNo); // set output block
label datasetNo = 0; // restart at dataset 0
const fvMesh& mesh = *meshPtr_;
const polyBoundaryMesh& patches = mesh.boundaryMesh();
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::convertMeshPatches" << endl;
printMemory();
}
for (int partId = range.start(); partId < range.end(); ++partId)
{
if (!partStatus_[partId])
{
continue;
}
const word patchName = getPartName(partId);
labelHashSet patchIds
(
patches.patchSet(List<wordRe>(1, wordRe(patchName)))
);
if (debug)
{
Info<< "Creating VTK mesh for patches [" << patchIds <<"] "
<< patchName << endl;
}
vtkPolyData* vtkmesh = nullptr;
if (patchIds.size() == 1)
{
vtkmesh = patchVTKMesh(patchName, patches[patchIds.begin().key()]);
}
else
{
// Patch group. Collect patch faces.
label sz = 0;
forAllConstIter(labelHashSet, patchIds, iter)
{
sz += patches[iter.key()].size();
}
labelList meshFaceLabels(sz);
sz = 0;
forAllConstIter(labelHashSet, patchIds, iter)
{
const polyPatch& pp = patches[iter.key()];
forAll(pp, i)
{
meshFaceLabels[sz++] = pp.start()+i;
}
}
UIndirectList<face> fcs(mesh.faces(), meshFaceLabels);
uindirectPrimitivePatch pp(fcs, mesh.points());
vtkmesh = patchVTKMesh(patchName, pp);
}
if (vtkmesh)
{
AddToBlock(output, vtkmesh, range, datasetNo, patchName);
vtkmesh->Delete();
partDataset_[partId] = datasetNo++;
}
}
// anything added?
if (datasetNo)
{
++blockNo;
}
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::convertMeshPatches" << endl;
printMemory();
}
}
void Foam::vtkPV3Foam::convertMeshCellZones
(
vtkMultiBlockDataSet* output,
int& blockNo
)
{
arrayRange& range = arrayRangeCellZones_;
range.block(blockNo); // set output block
label datasetNo = 0; // restart at dataset 0
const fvMesh& mesh = *meshPtr_;
// resize for decomposed polyhedra
zonePolyDecomp_.setSize(range.size());
if (range.empty())
{
return;
}
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::convertMeshCellZones" << endl;
printMemory();
}
const cellZoneMesh& zMesh = mesh.cellZones();
for (int partId = range.start(); partId < range.end(); ++partId)
{
const word zoneName = getPartName(partId);
const label zoneId = zMesh.findZoneID(zoneName);
if (!partStatus_[partId] || zoneId < 0)
{
continue;
}
if (debug)
{
Info<< "Creating VTK mesh for cellZone[" << zoneId << "] "
<< zoneName << endl;
}
fvMeshSubset subsetter(mesh);
subsetter.setLargeCellSubset(zMesh[zoneId]);
vtkUnstructuredGrid* vtkmesh = volumeVTKMesh
(
subsetter.subMesh(),
zonePolyDecomp_[datasetNo]
);
if (vtkmesh)
{
// superCells + addPointCellLabels must contain global cell ids
inplaceRenumber
(
subsetter.cellMap(),
zonePolyDecomp_[datasetNo].superCells()
);
inplaceRenumber
(
subsetter.cellMap(),
zonePolyDecomp_[datasetNo].addPointCellLabels()
);
// copy pointMap as well, otherwise pointFields fail
zonePolyDecomp_[datasetNo].pointMap() = subsetter.pointMap();
AddToBlock(output, vtkmesh, range, datasetNo, zoneName);
vtkmesh->Delete();
partDataset_[partId] = datasetNo++;
}
}
// anything added?
if (datasetNo)
{
++blockNo;
}
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::convertMeshCellZones" << endl;
printMemory();
}
}
void Foam::vtkPV3Foam::convertMeshCellSets
(
vtkMultiBlockDataSet* output,
int& blockNo
)
{
arrayRange& range = arrayRangeCellSets_;
range.block(blockNo); // set output block
label datasetNo = 0; // restart at dataset 0
const fvMesh& mesh = *meshPtr_;
// resize for decomposed polyhedra
csetPolyDecomp_.setSize(range.size());
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::convertMeshCellSets" << endl;
printMemory();
}
for (int partId = range.start(); partId < range.end(); ++partId)
{
const word partName = getPartName(partId);
if (!partStatus_[partId])
{
continue;
}
if (debug)
{
Info<< "Creating VTK mesh for cellSet=" << partName << endl;
}
const cellSet cSet(mesh, partName);
fvMeshSubset subsetter(mesh);
subsetter.setLargeCellSubset(cSet);
vtkUnstructuredGrid* vtkmesh = volumeVTKMesh
(
subsetter.subMesh(),
csetPolyDecomp_[datasetNo]
);
if (vtkmesh)
{
// superCells + addPointCellLabels must contain global cell ids
inplaceRenumber
(
subsetter.cellMap(),
csetPolyDecomp_[datasetNo].superCells()
);
inplaceRenumber
(
subsetter.cellMap(),
csetPolyDecomp_[datasetNo].addPointCellLabels()
);
// copy pointMap as well, otherwise pointFields fail
csetPolyDecomp_[datasetNo].pointMap() = subsetter.pointMap();
AddToBlock(output, vtkmesh, range, datasetNo, partName);
vtkmesh->Delete();
partDataset_[partId] = datasetNo++;
}
}
// anything added?
if (datasetNo)
{
++blockNo;
}
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::convertMeshCellSets" << endl;
printMemory();
}
}
void Foam::vtkPV3Foam::convertMeshFaceZones
(
vtkMultiBlockDataSet* output,
int& blockNo
)
{
arrayRange& range = arrayRangeFaceZones_;
range.block(blockNo); // set output block
label datasetNo = 0; // restart at dataset 0
const fvMesh& mesh = *meshPtr_;
if (range.empty())
{
return;
}
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::convertMeshFaceZones" << endl;
printMemory();
}
const faceZoneMesh& zMesh = mesh.faceZones();
for (int partId = range.start(); partId < range.end(); ++partId)
{
const word zoneName = getPartName(partId);
const label zoneId = zMesh.findZoneID(zoneName);
if (!partStatus_[partId] || zoneId < 0)
{
continue;
}
if (debug)
{
Info<< "Creating VTKmesh for faceZone[" << zoneId << "] "
<< zoneName << endl;
}
vtkPolyData* vtkmesh = patchVTKMesh(zoneName, zMesh[zoneId]());
if (vtkmesh)
{
AddToBlock(output, vtkmesh, range, datasetNo, zoneName);
vtkmesh->Delete();
partDataset_[partId] = datasetNo++;
}
}
// anything added?
if (datasetNo)
{
++blockNo;
}
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::convertMeshFaceZones" << endl;
printMemory();
}
}
void Foam::vtkPV3Foam::convertMeshFaceSets
(
vtkMultiBlockDataSet* output,
int& blockNo
)
{
arrayRange& range = arrayRangeFaceSets_;
range.block(blockNo); // set output block
label datasetNo = 0; // restart at dataset 0
const fvMesh& mesh = *meshPtr_;
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::convertMeshFaceSets" << endl;
printMemory();
}
for (int partId = range.start(); partId < range.end(); ++partId)
{
const word partName = getPartName(partId);
if (!partStatus_[partId])
{
continue;
}
if (debug)
{
Info<< "Creating VTK mesh for faceSet=" << partName << endl;
}
const faceSet fSet(mesh, partName);
vtkPolyData* vtkmesh = faceSetVTKMesh(mesh, fSet);
if (vtkmesh)
{
AddToBlock(output, vtkmesh, range, datasetNo, partName);
vtkmesh->Delete();
partDataset_[partId] = datasetNo++;
}
}
// anything added?
if (datasetNo)
{
++blockNo;
}
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::convertMeshFaceSets" << endl;
printMemory();
}
}
void Foam::vtkPV3Foam::convertMeshPointZones
(
vtkMultiBlockDataSet* output,
int& blockNo
)
{
arrayRange& range = arrayRangePointZones_;
range.block(blockNo); // set output block
label datasetNo = 0; // restart at dataset 0
const fvMesh& mesh = *meshPtr_;
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::convertMeshPointZones" << endl;
printMemory();
}
if (range.size())
{
const pointZoneMesh& zMesh = mesh.pointZones();
for (int partId = range.start(); partId < range.end(); ++partId)
{
word zoneName = getPartName(partId);
label zoneId = zMesh.findZoneID(zoneName);
if (!partStatus_[partId] || zoneId < 0)
{
continue;
}
vtkPolyData* vtkmesh = pointZoneVTKMesh(mesh, zMesh[zoneId]);
if (vtkmesh)
{
AddToBlock(output, vtkmesh, range, datasetNo, zoneName);
vtkmesh->Delete();
partDataset_[partId] = datasetNo++;
}
}
}
// anything added?
if (datasetNo)
{
++blockNo;
}
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::convertMeshPointZones" << endl;
printMemory();
}
}
void Foam::vtkPV3Foam::convertMeshPointSets
(
vtkMultiBlockDataSet* output,
int& blockNo
)
{
arrayRange& range = arrayRangePointSets_;
range.block(blockNo); // set output block
label datasetNo = 0; // restart at dataset 0
const fvMesh& mesh = *meshPtr_;
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::convertMeshPointSets" << endl;
printMemory();
}
for (int partId = range.start(); partId < range.end(); ++partId)
{
word partName = getPartName(partId);
if (!partStatus_[partId])
{
continue;
}
if (debug)
{
Info<< "Creating VTK mesh for pointSet=" << partName << endl;
}
const pointSet pSet(mesh, partName);
vtkPolyData* vtkmesh = pointSetVTKMesh(mesh, pSet);
if (vtkmesh)
{
AddToBlock(output, vtkmesh, range, datasetNo, partName);
vtkmesh->Delete();
partDataset_[partId] = datasetNo++;
}
}
// anything added?
if (datasetNo)
{
++blockNo;
}
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::convertMeshPointSets" << endl;
printMemory();
}
}
// ************************************************************************* //

View File

@ -1,109 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "vtkPV3Foam.H"
// OpenFOAM includes
#include "Cloud.H"
#include "fvMesh.H"
#include "IOobjectList.H"
#include "passiveParticle.H"
#include "vtkOpenFOAMPoints.H"
// VTK includes
#include "vtkCellArray.h"
#include "vtkPoints.h"
#include "vtkPolyData.h"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
vtkPolyData* Foam::vtkPV3Foam::lagrangianVTKMesh
(
const fvMesh& mesh,
const word& cloudName
)
{
vtkPolyData* vtkmesh = nullptr;
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::lagrangianVTKMesh - timePath "
<< mesh.time().timePath()/cloud::prefix/cloudName << endl;
printMemory();
}
// the region name is already in the mesh db
IOobjectList sprayObjs
(
mesh,
mesh.time().timeName(),
cloud::prefix/cloudName
);
IOobject* positionsPtr = sprayObjs.lookup(word("positions"));
if (positionsPtr)
{
Cloud<passiveParticle> parcels(mesh, cloudName, false);
if (debug)
{
Info<< "cloud with " << parcels.size() << " parcels" << endl;
}
vtkmesh = vtkPolyData::New();
vtkPoints* vtkpoints = vtkPoints::New();
vtkCellArray* vtkcells = vtkCellArray::New();
vtkpoints->Allocate(parcels.size());
vtkcells->Allocate(parcels.size());
vtkIdType particleId = 0;
forAllConstIter(Cloud<passiveParticle>, parcels, iter)
{
vtkInsertNextOpenFOAMPoint(vtkpoints, iter().position());
vtkcells->InsertNextCell(1, &particleId);
particleId++;
}
vtkmesh->SetPoints(vtkpoints);
vtkpoints->Delete();
vtkmesh->SetVerts(vtkcells);
vtkcells->Delete();
}
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::lagrangianVTKMesh" << endl;
printMemory();
}
return vtkmesh;
}
// ************************************************************************* //

View File

@ -1,148 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "vtkPV3Foam.H"
// OpenFOAM includes
#include "faceSet.H"
#include "pointSet.H"
#include "vtkOpenFOAMPoints.H"
// VTK includes
#include "vtkPoints.h"
#include "vtkPolyData.h"
#include "vtkCellArray.h"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
vtkPolyData* Foam::vtkPV3Foam::faceSetVTKMesh
(
const fvMesh& mesh,
const faceSet& fSet
)
{
vtkPolyData* vtkmesh = vtkPolyData::New();
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::faceSetVTKMesh" << endl;
printMemory();
}
// Construct primitivePatch of faces in fSet.
const faceList& meshFaces = mesh.faces();
faceList patchFaces(fSet.size());
label facei = 0;
forAllConstIter(faceSet, fSet, iter)
{
patchFaces[facei++] = meshFaces[iter.key()];
}
primitiveFacePatch p(patchFaces, mesh.points());
// The balance of this routine should be identical to patchVTKMesh
// Convert OpenFOAM mesh vertices to VTK
const pointField& points = p.localPoints();
vtkPoints* vtkpoints = vtkPoints::New();
vtkpoints->Allocate(points.size());
forAll(points, i)
{
vtkInsertNextOpenFOAMPoint(vtkpoints, points[i]);
}
vtkmesh->SetPoints(vtkpoints);
vtkpoints->Delete();
// Add faces as polygons
const faceList& faces = p.localFaces();
vtkCellArray* vtkcells = vtkCellArray::New();
vtkcells->Allocate(faces.size());
forAll(faces, facei)
{
const face& f = faces[facei];
vtkIdType nodeIds[f.size()];
forAll(f, fp)
{
nodeIds[fp] = f[fp];
}
vtkcells->InsertNextCell(f.size(), nodeIds);
}
vtkmesh->SetPolys(vtkcells);
vtkcells->Delete();
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::faceSetVTKMesh" << endl;
printMemory();
}
return vtkmesh;
}
vtkPolyData* Foam::vtkPV3Foam::pointSetVTKMesh
(
const fvMesh& mesh,
const pointSet& pSet
)
{
vtkPolyData* vtkmesh = vtkPolyData::New();
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::pointSetVTKMesh" << endl;
printMemory();
}
const pointField& meshPoints = mesh.points();
vtkPoints* vtkpoints = vtkPoints::New();
vtkpoints->Allocate(pSet.size());
forAllConstIter(pointSet, pSet, iter)
{
vtkInsertNextOpenFOAMPoint(vtkpoints, meshPoints[iter.key()]);
}
vtkmesh->SetPoints(vtkpoints);
vtkpoints->Delete();
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::pointSetVTKMesh" << endl;
printMemory();
}
return vtkmesh;
}
// ************************************************************************* //

View File

@ -1,480 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "vtkPV3Foam.H"
#include "vtkPV3FoamReader.h"
// OpenFOAM includes
#include "fvMesh.H"
#include "cellModeller.H"
#include "vtkOpenFOAMPoints.H"
#include "Swap.H"
// VTK includes
#include "vtkCellArray.h"
#include "vtkIdTypeArray.h"
#include "vtkUnstructuredGrid.h"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
vtkUnstructuredGrid* Foam::vtkPV3Foam::volumeVTKMesh
(
const fvMesh& mesh,
polyDecomp& decompInfo
)
{
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"));
vtkUnstructuredGrid* vtkmesh = vtkUnstructuredGrid::New();
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::volumeVTKMesh" << endl;
printMemory();
}
const cellShapeList& cellShapes = mesh.cellShapes();
// 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;
// face owner is needed to determine the face orientation
const labelList& owner = mesh.faceOwner();
labelList& superCells = decompInfo.superCells();
labelList& addPointCellLabels = decompInfo.addPointCellLabels();
// Scan for cells which need to be decomposed and count additional points
// and cells
if (!reader_->GetUseVTKPolyhedron())
{
if (debug)
{
Info<< "... scanning for polyhedra" << 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 nQuads = 0;
label nTris = 0;
f.nTrianglesQuads(mesh.points(), nTris, nQuads);
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)
if (debug)
{
Info<<" mesh nCells = " << mesh.nCells() << nl
<<" nPoints = " << mesh.nPoints() << nl
<<" nAddCells = " << nAddCells << nl
<<" nAddPoints = " << nAddPoints << endl;
}
superCells.setSize(mesh.nCells() + nAddCells);
if (debug)
{
Info<< "... converting points" << endl;
}
// Convert OpenFOAM mesh vertices to VTK
vtkPoints* vtkpoints = vtkPoints::New();
vtkpoints->Allocate(mesh.nPoints() + nAddPoints);
const Foam::pointField& points = mesh.points();
forAll(points, i)
{
vtkInsertNextOpenFOAMPoint(vtkpoints, points[i]);
}
if (debug)
{
Info<< "... converting cells" << endl;
}
vtkmesh->Allocate(mesh.nCells() + nAddCells);
// Set counters for additional points and additional cells
label addPointi = 0, addCelli = 0;
// Create storage for points - needed for mapping from OpenFOAM to VTK
// data types - max 'order' = hex = 8 points
vtkIdType nodeIds[8];
// face-stream for a polyhedral cell
// [numFace0Pts, id1, id2, id3, numFace1Pts, id1, id2, id3, ...]
DynamicList<vtkIdType> faceStream(256);
forAll(cellShapes, celli)
{
const cellShape& cellShape = cellShapes[celli];
const cellModel& cellModel = cellShape.model();
superCells[addCelli++] = celli;
if (cellModel == tet)
{
for (int j = 0; j < 4; j++)
{
nodeIds[j] = cellShape[j];
}
vtkmesh->InsertNextCell
(
VTK_TETRA,
4,
nodeIds
);
}
else if (cellModel == pyr)
{
for (int j = 0; j < 5; j++)
{
nodeIds[j] = cellShape[j];
}
vtkmesh->InsertNextCell
(
VTK_PYRAMID,
5,
nodeIds
);
}
else if (cellModel == prism)
{
// VTK has a different node order for VTK_WEDGE
// their triangles point outwards!
nodeIds[0] = cellShape[0];
nodeIds[1] = cellShape[2];
nodeIds[2] = cellShape[1];
nodeIds[3] = cellShape[3];
nodeIds[4] = cellShape[5];
nodeIds[5] = cellShape[4];
vtkmesh->InsertNextCell
(
VTK_WEDGE,
6,
nodeIds
);
}
else if (cellModel == tetWedge && !reader_->GetUseVTKPolyhedron())
{
// Treat as squeezed prism (VTK_WEDGE)
nodeIds[0] = cellShape[0];
nodeIds[1] = cellShape[2];
nodeIds[2] = cellShape[1];
nodeIds[3] = cellShape[3];
nodeIds[4] = cellShape[4];
nodeIds[5] = cellShape[3];
vtkmesh->InsertNextCell
(
VTK_WEDGE,
6,
nodeIds
);
}
else if (cellModel == wedge)
{
// Treat as squeezed hex
nodeIds[0] = cellShape[0];
nodeIds[1] = cellShape[1];
nodeIds[2] = cellShape[2];
nodeIds[3] = cellShape[2];
nodeIds[4] = cellShape[3];
nodeIds[5] = cellShape[4];
nodeIds[6] = cellShape[5];
nodeIds[7] = cellShape[6];
vtkmesh->InsertNextCell
(
VTK_HEXAHEDRON,
8,
nodeIds
);
}
else if (cellModel == hex)
{
for (int j = 0; j < 8; j++)
{
nodeIds[j] = cellShape[j];
}
vtkmesh->InsertNextCell
(
VTK_HEXAHEDRON,
8,
nodeIds
);
}
else if (reader_->GetUseVTKPolyhedron())
{
// Polyhedral cell - use VTK_POLYHEDRON
const labelList& cFaces = mesh.cells()[celli];
#ifdef HAS_VTK_POLYHEDRON
vtkIdType nFaces = cFaces.size();
vtkIdType nLabels = nFaces;
// count size for face stream
forAll(cFaces, cFacei)
{
const face& f = mesh.faces()[cFaces[cFacei]];
nLabels += f.size();
}
// build face-stream
// [numFace0Pts, id1, id2, id3, numFace1Pts, id1, id2, id3, ...]
// point Ids are global
faceStream.clear();
faceStream.reserve(nLabels + nFaces);
forAll(cFaces, cFacei)
{
const face& f = mesh.faces()[cFaces[cFacei]];
const bool isOwner = (owner[cFaces[cFacei]] == celli);
const label nFacePoints = f.size();
// number of labels for this face
faceStream.append(nFacePoints);
if (isOwner)
{
forAll(f, fp)
{
faceStream.append(f[fp]);
}
}
else
{
// fairly immaterial if we reverse the list
// or use face::reverseFace()
forAllReverse(f, fp)
{
faceStream.append(f[fp]);
}
}
}
vtkmesh->InsertNextCell(VTK_POLYHEDRON, nFaces, faceStream.data());
#else
// this is a horrible substitute
// but avoids crashes when there is no vtkPolyhedron support
// establish unique node ids used
HashSet<vtkIdType, Hash<label>> hashUniqId(2*256);
forAll(cFaces, cFacei)
{
const face& f = mesh.faces()[cFaces[cFacei]];
forAll(f, fp)
{
hashUniqId.insert(f[fp]);
}
}
// use face stream to store unique node ids:
faceStream = hashUniqId.sortedToc();
vtkmesh->InsertNextCell
(
VTK_CONVEX_POINT_SET,
vtkIdType(faceStream.size()),
faceStream.data()
);
#endif
}
else
{
// Polyhedral cell. Decompose into tets + prisms.
// Mapping from additional point to cell
addPointCellLabels[addPointi] = celli;
// The new vertex from the cell-centre
const label newVertexLabel = mesh.nPoints() + addPointi;
vtkInsertNextOpenFOAMPoint(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]];
const bool isOwner = (owner[cFaces[cFacei]] == celli);
// Number of triangles and quads in decomposition
label nTris = 0;
label nQuads = 0;
f.nTrianglesQuads(mesh.points(), nTris, nQuads);
// Do actual decomposition into triFcs and quadFcs.
faceList triFcs(nTris);
faceList quadFcs(nQuads);
label trii = 0;
label quadi = 0;
f.trianglesQuads(mesh.points(), trii, quadi, triFcs, quadFcs);
forAll(quadFcs, quadI)
{
if (substituteCell)
{
substituteCell = false;
}
else
{
superCells[addCelli++] = celli;
}
const face& quad = quadFcs[quadI];
// Ensure we have the correct orientation for the
// base of the primitive cell shape.
// If the cell is face owner, the orientation needs to be
// flipped.
// At the moment, VTK doesn't actually seem to care if
// negative cells are defined, but we'll do it anyhow
// (for safety).
if (isOwner)
{
nodeIds[0] = quad[3];
nodeIds[1] = quad[2];
nodeIds[2] = quad[1];
nodeIds[3] = quad[0];
}
else
{
nodeIds[0] = quad[0];
nodeIds[1] = quad[1];
nodeIds[2] = quad[2];
nodeIds[3] = quad[3];
}
nodeIds[4] = newVertexLabel;
vtkmesh->InsertNextCell
(
VTK_PYRAMID,
5,
nodeIds
);
}
forAll(triFcs, triI)
{
if (substituteCell)
{
substituteCell = false;
}
else
{
superCells[addCelli++] = celli;
}
const face& tri = triFcs[triI];
// See note above about the orientation.
if (isOwner)
{
nodeIds[0] = tri[2];
nodeIds[1] = tri[1];
nodeIds[2] = tri[0];
}
else
{
nodeIds[0] = tri[0];
nodeIds[1] = tri[1];
nodeIds[2] = tri[2];
}
nodeIds[3] = newVertexLabel;
vtkmesh->InsertNextCell
(
VTK_TETRA,
4,
nodeIds
);
}
}
addPointi++;
}
}
vtkmesh->SetPoints(vtkpoints);
vtkpoints->Delete();
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::volumeVTKMesh" << endl;
printMemory();
}
return vtkmesh;
}
// ************************************************************************* //

View File

@ -1,75 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "vtkPV3Foam.H"
// OpenFOAM includes
#include "vtkOpenFOAMPoints.H"
// VTK includes
#include "vtkPoints.h"
#include "vtkPolyData.h"
#include "vtkCellArray.h"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
vtkPolyData* Foam::vtkPV3Foam::pointZoneVTKMesh
(
const fvMesh& mesh,
const labelList& pointLabels
)
{
vtkPolyData* vtkmesh = vtkPolyData::New();
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::pointZoneVTKMesh" << endl;
printMemory();
}
const pointField& meshPoints = mesh.points();
vtkPoints* vtkpoints = vtkPoints::New();
vtkpoints->Allocate(pointLabels.size());
forAll(pointLabels, pointi)
{
vtkInsertNextOpenFOAMPoint(vtkpoints, meshPoints[pointLabels[pointi]]);
}
vtkmesh->SetPoints(vtkpoints);
vtkpoints->Delete();
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::pointZoneVTKMesh" << endl;
printMemory();
}
return vtkmesh;
}
// ************************************************************************* //

View File

@ -1,129 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
InClass
vtkPV3Foam
\*---------------------------------------------------------------------------*/
#ifndef vtkPV3FoamPatchField_H
#define vtkPV3FoamPatchField_H
// VTK includes
#include "vtkCellData.h"
#include "vtkFloatArray.h"
#include "vtkMultiBlockDataSet.h"
#include "vtkPointData.h"
#include "vtkPolyData.h"
#include "vtkOpenFOAMTupleRemap.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
void Foam::vtkPV3Foam::convertPatchField
(
const word& name,
const Field<Type>& ptf,
vtkMultiBlockDataSet* output,
const arrayRange& range,
const label datasetNo
)
{
const label nComp = pTraits<Type>::nComponents;
vtkFloatArray* cellData = vtkFloatArray::New();
cellData->SetNumberOfTuples(ptf.size());
cellData->SetNumberOfComponents(nComp);
cellData->Allocate(nComp*ptf.size());
cellData->SetName(name.c_str());
float vec[nComp];
forAll(ptf, i)
{
const Type& t = ptf[i];
for (direction d=0; d<nComp; ++d)
{
vec[d] = component(t, d);
}
vtkOpenFOAMTupleRemap<Type>(vec);
cellData->InsertTuple(i, vec);
}
vtkPolyData::SafeDownCast
(
GetDataSetFromBlock(output, range, datasetNo)
) ->GetCellData()
->AddArray(cellData);
cellData->Delete();
}
// as above, but with PointData()
template<class Type>
void Foam::vtkPV3Foam::convertPatchPointField
(
const word& name,
const Field<Type>& pptf,
vtkMultiBlockDataSet* output,
const arrayRange& range,
const label datasetNo
)
{
const label nComp = pTraits<Type>::nComponents;
vtkFloatArray* pointData = vtkFloatArray::New();
pointData->SetNumberOfTuples(pptf.size());
pointData->SetNumberOfComponents(nComp);
pointData->Allocate(nComp*pptf.size());
pointData->SetName(name.c_str());
float vec[nComp];
forAll(pptf, i)
{
const Type& t = pptf[i];
for (direction d=0; d<nComp; ++d)
{
vec[d] = component(t, d);
}
vtkOpenFOAMTupleRemap<Type>(vec);
pointData->InsertTuple(i, vec);
}
vtkPolyData::SafeDownCast
(
GetDataSetFromBlock(output, range, datasetNo)
) ->GetPointData()
->AddArray(pointData);
pointData->Delete();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,331 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
InClass
vtkPV3Foam
\*---------------------------------------------------------------------------*/
#ifndef vtkPV3FoamPointFields_H
#define vtkPV3FoamPointFields_H
// OpenFOAM includes
#include "interpolatePointToCell.H"
#include "vtkOpenFOAMTupleRemap.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
void Foam::vtkPV3Foam::convertPointFields
(
const fvMesh& mesh,
const pointMesh& pMesh,
const IOobjectList& objects,
vtkMultiBlockDataSet* output
)
{
const polyBoundaryMesh& patches = mesh.boundaryMesh();
forAllConstIter(IOobjectList, objects, iter)
{
const word& fieldName = iter()->name();
// restrict to this GeometricField<Type, ...>
if
(
iter()->headerClassName()
!= GeometricField<Type, pointPatchField, pointMesh>::typeName
)
{
continue;
}
if (debug)
{
Info<< "Foam::vtkPV3Foam::convertPointFields : "
<< fieldName << endl;
}
GeometricField<Type, pointPatchField, pointMesh> ptf
(
*iter(),
pMesh
);
// Convert activated internalMesh regions
convertPointFieldBlock
(
ptf,
output,
arrayRangeVolume_,
regionPolyDecomp_
);
// Convert activated cellZones
convertPointFieldBlock
(
ptf,
output,
arrayRangeCellZones_,
zonePolyDecomp_
);
// Convert activated cellSets
convertPointFieldBlock
(
ptf,
output,
arrayRangeCellSets_,
csetPolyDecomp_
);
//
// Convert patches - if activated
//
for
(
int partId = arrayRangePatches_.start();
partId < arrayRangePatches_.end();
++partId
)
{
const word patchName = getPartName(partId);
const label datasetNo = partDataset_[partId];
const label patchId = patches.findPatchID(patchName);
if (!partStatus_[partId] || datasetNo < 0 || patchId < 0)
{
continue;
}
convertPatchPointField
(
fieldName,
ptf.boundaryField()[patchId].patchInternalField()(),
output,
arrayRangePatches_,
datasetNo
);
}
//
// Convert faceZones - if activated
//
for
(
int partId = arrayRangeFaceZones_.start();
partId < arrayRangeFaceZones_.end();
++partId
)
{
const word zoneName = getPartName(partId);
const label datasetNo = partDataset_[partId];
const label zoneId = mesh.faceZones().findZoneID(zoneName);
if (!partStatus_[partId] || datasetNo < 0 || zoneId < 0)
{
continue;
}
// Extract the field on the zone
Field<Type> fld
(
ptf.primitiveField(),
mesh.faceZones()[zoneId]().meshPoints()
);
convertPatchPointField
(
fieldName,
fld,
output,
arrayRangeFaceZones_,
datasetNo
);
}
}
}
template<class Type>
void Foam::vtkPV3Foam::convertPointFieldBlock
(
const GeometricField<Type, pointPatchField, pointMesh>& ptf,
vtkMultiBlockDataSet* output,
const arrayRange& range,
const List<polyDecomp>& decompLst
)
{
for (int partId = range.start(); partId < range.end(); ++partId)
{
const label datasetNo = partDataset_[partId];
if (datasetNo >= 0 && partStatus_[partId])
{
convertPointField
(
ptf,
GeometricField<Type, fvPatchField, volMesh>::null(),
output,
range,
datasetNo,
decompLst[datasetNo]
);
}
}
}
template<class Type>
void Foam::vtkPV3Foam::convertPointField
(
const GeometricField<Type, pointPatchField, pointMesh>& ptf,
const GeometricField<Type, fvPatchField, volMesh>& tf,
vtkMultiBlockDataSet* output,
const arrayRange& range,
const label datasetNo,
const polyDecomp& decomp
)
{
const label nComp = pTraits<Type>::nComponents;
const labelList& addPointCellLabels = decomp.addPointCellLabels();
const labelList& pointMap = decomp.pointMap();
// use a pointMap or address directly into mesh
label nPoints;
if (pointMap.size())
{
nPoints = pointMap.size();
}
else
{
nPoints = ptf.size();
}
vtkFloatArray* pointData = vtkFloatArray::New();
pointData->SetNumberOfTuples(nPoints + addPointCellLabels.size());
pointData->SetNumberOfComponents(nComp);
pointData->Allocate(nComp*(nPoints + addPointCellLabels.size()));
// Note: using the name of the original volField
// not the name generated by the interpolation "volPointInterpolate(<name>)"
if (&tf != &GeometricField<Type, fvPatchField, volMesh>::null())
{
pointData->SetName(tf.name().c_str());
}
else
{
pointData->SetName(ptf.name().c_str());
}
if (debug)
{
Info<< "convert convertPointField: "
<< ptf.name()
<< " size = " << nPoints
<< " nComp=" << nComp
<< " nTuples = " << (nPoints + addPointCellLabels.size())
<< endl;
}
float vec[nComp];
if (pointMap.size())
{
forAll(pointMap, i)
{
const Type& t = ptf[pointMap[i]];
for (direction d=0; d<nComp; ++d)
{
vec[d] = component(t, d);
}
vtkOpenFOAMTupleRemap<Type>(vec);
pointData->InsertTuple(i, vec);
}
}
else
{
forAll(ptf, i)
{
const Type& t = ptf[i];
for (direction d=0; d<nComp; ++d)
{
vec[d] = component(t, d);
}
vtkOpenFOAMTupleRemap<Type>(vec);
pointData->InsertTuple(i, vec);
}
}
// continue insertion from here
label i = nPoints;
if (&tf != &GeometricField<Type, fvPatchField, volMesh>::null())
{
forAll(addPointCellLabels, apI)
{
const Type& t = tf[addPointCellLabels[apI]];
for (direction d=0; d<nComp; ++d)
{
vec[d] = component(t, d);
}
vtkOpenFOAMTupleRemap<Type>(vec);
pointData->InsertTuple(i++, vec);
}
}
else
{
forAll(addPointCellLabels, apI)
{
Type t = interpolatePointToCell(ptf, addPointCellLabels[apI]);
for (direction d=0; d<nComp; ++d)
{
vec[d] = component(t, d);
}
vtkOpenFOAMTupleRemap<Type>(vec);
pointData->InsertTuple(i++, vec);
}
}
vtkUnstructuredGrid::SafeDownCast
(
GetDataSetFromBlock(output, range, datasetNo)
) ->GetPointData()
->AddArray(pointData);
pointData->Delete();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,99 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "vtkPV3Foam.H"
// OpenFOAM includes
#include "polyPatch.H"
#include "primitivePatch.H"
#include "vtkOpenFOAMPoints.H"
// VTK includes
#include "vtkCellArray.h"
#include "vtkPoints.h"
#include "vtkPolyData.h"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class PatchType>
vtkPolyData* Foam::vtkPV3Foam::patchVTKMesh
(
const word& name,
const PatchType& p
)
{
vtkPolyData* vtkmesh = vtkPolyData::New();
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::patchVTKMesh - " << name << endl;
printMemory();
}
// Convert OpenFOAM mesh vertices to VTK
const Foam::pointField& points = p.localPoints();
vtkPoints* vtkpoints = vtkPoints::New();
vtkpoints->Allocate(points.size());
forAll(points, i)
{
vtkInsertNextOpenFOAMPoint(vtkpoints, points[i]);
}
vtkmesh->SetPoints(vtkpoints);
vtkpoints->Delete();
// Add faces as polygons
const faceList& faces = p.localFaces();
vtkCellArray* vtkcells = vtkCellArray::New();
vtkcells->Allocate(faces.size());
forAll(faces, facei)
{
const face& f = faces[facei];
vtkIdType nodeIds[f.size()];
forAll(f, fp)
{
nodeIds[fp] = f[fp];
}
vtkcells->InsertNextCell(f.size(), nodeIds);
}
vtkmesh->SetPolys(vtkcells);
vtkcells->Delete();
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::patchVTKMesh - " << name << endl;
printMemory();
}
return vtkmesh;
}
// ************************************************************************* //

View File

@ -1,724 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "vtkPV3Foam.H"
// OpenFOAM includes
#include "cellSet.H"
#include "faceSet.H"
#include "pointSet.H"
#include "IOobjectList.H"
#include "IOPtrList.H"
#include "polyBoundaryMeshEntries.H"
#include "entry.H"
#include "Cloud.H"
#include "vtkPV3FoamReader.h"
// local headers
#include "vtkPV3FoamAddToSelection.H"
#include "vtkPV3FoamUpdateInfoFields.H"
// VTK includes
#include "vtkDataArraySelection.h"
// * * * * * * * * * * * * * * * Private Classes * * * * * * * * * * * * * * //
namespace Foam
{
//- A class for reading zone information without requiring a mesh
class zonesEntries
:
public regIOobject,
public PtrList<entry>
{
public:
// Constructors
explicit zonesEntries(const IOobject& io)
:
regIOobject(io),
PtrList<entry>(readStream("regIOobject"))
{
close();
}
// Member functions
bool writeData(Ostream&) const
{
NotImplemented;
return false;
}
};
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class ZoneType>
Foam::wordList Foam::vtkPV3Foam::getZoneNames
(
const ZoneMesh<ZoneType, polyMesh>& zmesh
) const
{
wordList names(zmesh.size());
label nZone = 0;
forAll(zmesh, zoneI)
{
if (zmesh[zoneI].size())
{
names[nZone++] = zmesh[zoneI].name();
}
}
names.setSize(nZone);
return names;
}
Foam::wordList Foam::vtkPV3Foam::getZoneNames(const word& zoneType) const
{
wordList names;
// mesh not loaded - read from file
IOobject ioObj
(
zoneType,
dbPtr_().findInstance
(
meshDir_,
zoneType,
IOobject::READ_IF_PRESENT
),
meshDir_,
dbPtr_(),
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE,
false
);
if (ioObj.typeHeaderOk<cellZoneMesh>(false))
{
zonesEntries zones(ioObj);
names.setSize(zones.size());
forAll(zones, zoneI)
{
names[zoneI] = zones[zoneI].keyword();
}
}
return names;
}
void Foam::vtkPV3Foam::updateInfoInternalMesh
(
vtkDataArraySelection* arraySelection
)
{
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::updateInfoInternalMesh" << endl;
}
// Determine mesh parts (internalMesh, patches...)
//- Add internal mesh as first entry
arrayRangeVolume_.reset(arraySelection->GetNumberOfArrays());
arraySelection->AddArray
(
"internalMesh"
);
arrayRangeVolume_ += 1;
if (debug)
{
// just for debug info
getSelectedArrayEntries(arraySelection);
Info<< "<end> Foam::vtkPV3Foam::updateInfoInternalMesh" << endl;
}
}
void Foam::vtkPV3Foam::updateInfoLagrangian
(
vtkDataArraySelection* arraySelection
)
{
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::updateInfoLagrangian" << nl
<< " " << dbPtr_->timePath()/cloud::prefix << endl;
}
// use the db directly since this might be called without a mesh,
// but the region must get added back in
fileName lagrangianPrefix(cloud::prefix);
if (meshRegion_ != polyMesh::defaultRegion)
{
lagrangianPrefix = meshRegion_/cloud::prefix;
}
// Search for list of lagrangian objects for this time
fileNameList cloudDirs
(
readDir(dbPtr_->timePath()/lagrangianPrefix, fileName::DIRECTORY)
);
arrayRangeLagrangian_.reset(arraySelection->GetNumberOfArrays());
int nClouds = 0;
forAll(cloudDirs, cloudI)
{
// Add cloud to GUI list
arraySelection->AddArray
(
(cloudDirs[cloudI] + " - lagrangian").c_str()
);
++nClouds;
}
arrayRangeLagrangian_ += nClouds;
if (debug)
{
// just for debug info
getSelectedArrayEntries(arraySelection);
Info<< "<end> Foam::vtkPV3Foam::updateInfoLagrangian" << endl;
}
}
void Foam::vtkPV3Foam::updateInfoPatches
(
vtkDataArraySelection* arraySelection,
stringList& enabledEntries
)
{
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::updateInfoPatches"
<< " [meshPtr=" << (meshPtr_ ? "set" : "nullptr") << "]" << endl;
}
HashSet<string> enabledEntriesSet(enabledEntries);
arrayRangePatches_.reset(arraySelection->GetNumberOfArrays());
int nPatches = 0;
if (meshPtr_)
{
const polyBoundaryMesh& patches = meshPtr_->boundaryMesh();
const HashTable<labelList, word>& groups = patches.groupPatchIDs();
const wordList allPatchNames = patches.names();
// Add patch groups
// ~~~~~~~~~~~~~~~~
for
(
HashTable<labelList, word>::const_iterator iter = groups.begin();
iter != groups.end();
++iter
)
{
const word& groupName = iter.key();
const labelList& patchIDs = iter();
label nFaces = 0;
forAll(patchIDs, i)
{
nFaces += patches[patchIDs[i]].size();
}
// Valid patch if nFace > 0 - add patch to GUI list
if (nFaces)
{
string vtkGrpName = groupName + " - group";
arraySelection->AddArray(vtkGrpName.c_str());
++nPatches;
if (enabledEntriesSet.found(vtkGrpName))
{
if (!reader_->GetShowGroupsOnly())
{
enabledEntriesSet.erase(vtkGrpName);
forAll(patchIDs, i)
{
const polyPatch& pp = patches[patchIDs[i]];
if (pp.size())
{
string vtkPatchName = pp.name() + " - patch";
enabledEntriesSet.insert(vtkPatchName);
}
}
}
}
}
}
// Add patches
// ~~~~~~~~~~~
if (!reader_->GetShowGroupsOnly())
{
forAll(patches, patchi)
{
const polyPatch& pp = patches[patchi];
if (pp.size())
{
// Add patch to GUI list
arraySelection->AddArray
(
(pp.name() + " - patch").c_str()
);
++nPatches;
}
}
}
}
else
{
// mesh not loaded - read from file
// but this could fail if we've supplied a bad region name
IOobject ioObj
(
"boundary",
dbPtr_().findInstance
(
meshDir_,
"boundary",
IOobject::READ_IF_PRESENT
),
meshDir_,
dbPtr_(),
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE,
false
);
// this should only ever fail if the mesh region doesn't exist
if (ioObj.typeHeaderOk<polyBoundaryMesh>(true))
{
polyBoundaryMeshEntries patchEntries(ioObj);
// Read patches and determine sizes
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
wordList names(patchEntries.size());
labelList sizes(patchEntries.size());
forAll(patchEntries, patchi)
{
const dictionary& patchDict = patchEntries[patchi].dict();
sizes[patchi] = readLabel(patchDict.lookup("nFaces"));
names[patchi] = patchEntries[patchi].keyword();
}
// Add (non-zero) patch groups to the list of mesh parts
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HashTable<labelList, word> groups(patchEntries.size());
forAll(patchEntries, patchi)
{
const dictionary& patchDict = patchEntries[patchi].dict();
wordList groupNames;
patchDict.readIfPresent("inGroups", groupNames);
forAll(groupNames, groupI)
{
HashTable<labelList, word>::iterator iter = groups.find
(
groupNames[groupI]
);
if (iter != groups.end())
{
iter().append(patchi);
}
else
{
groups.insert(groupNames[groupI], labelList(1, patchi));
}
}
}
for
(
HashTable<labelList, word>::const_iterator iter =
groups.begin();
iter != groups.end();
++iter
)
{
const word& groupName = iter.key();
const labelList& patchIDs = iter();
label nFaces = 0;
forAll(patchIDs, i)
{
nFaces += sizes[patchIDs[i]];
}
// Valid patch if nFace > 0 - add patch to GUI list
if (nFaces)
{
string vtkGrpName = groupName + " - group";
arraySelection->AddArray(vtkGrpName.c_str());
++nPatches;
if (enabledEntriesSet.found(vtkGrpName))
{
if (!reader_->GetShowGroupsOnly())
{
enabledEntriesSet.erase(vtkGrpName);
forAll(patchIDs, i)
{
if (sizes[patchIDs[i]])
{
string vtkPatchName =
names[patchIDs[i]] + " - patch";
enabledEntriesSet.insert(vtkPatchName);
}
}
}
}
}
}
// Add (non-zero) patches to the list of mesh parts
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if (!reader_->GetShowGroupsOnly())
{
forAll(names, patchi)
{
// Valid patch if nFace > 0 - add patch to GUI list
if (sizes[patchi])
{
arraySelection->AddArray
(
(names[patchi] + " - patch").c_str()
);
++nPatches;
}
}
}
}
}
arrayRangePatches_ += nPatches;
// Update enabled entries in case of group selection
enabledEntries = enabledEntriesSet.toc();
if (debug)
{
// just for debug info
getSelectedArrayEntries(arraySelection);
Info<< "<end> Foam::vtkPV3Foam::updateInfoPatches" << endl;
}
}
void Foam::vtkPV3Foam::updateInfoZones
(
vtkDataArraySelection* arraySelection
)
{
if (!reader_->GetIncludeZones())
{
return;
}
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::updateInfoZones"
<< " [meshPtr=" << (meshPtr_ ? "set" : "nullptr") << "]" << endl;
}
wordList namesLst;
//
// cellZones information
// ~~~~~~~~~~~~~~~~~~~~~
if (meshPtr_)
{
namesLst = getZoneNames(meshPtr_->cellZones());
}
else
{
namesLst = getZoneNames("cellZones");
}
arrayRangeCellZones_.reset(arraySelection->GetNumberOfArrays());
forAll(namesLst, elemI)
{
arraySelection->AddArray
(
(namesLst[elemI] + " - cellZone").c_str()
);
}
arrayRangeCellZones_ += namesLst.size();
//
// faceZones information
// ~~~~~~~~~~~~~~~~~~~~~
if (meshPtr_)
{
namesLst = getZoneNames(meshPtr_->faceZones());
}
else
{
namesLst = getZoneNames("faceZones");
}
arrayRangeFaceZones_.reset(arraySelection->GetNumberOfArrays());
forAll(namesLst, elemI)
{
arraySelection->AddArray
(
(namesLst[elemI] + " - faceZone").c_str()
);
}
arrayRangeFaceZones_ += namesLst.size();
//
// pointZones information
// ~~~~~~~~~~~~~~~~~~~~~~
if (meshPtr_)
{
namesLst = getZoneNames(meshPtr_->pointZones());
}
else
{
namesLst = getZoneNames("pointZones");
}
arrayRangePointZones_.reset(arraySelection->GetNumberOfArrays());
forAll(namesLst, elemI)
{
arraySelection->AddArray
(
(namesLst[elemI] + " - pointZone").c_str()
);
}
arrayRangePointZones_ += namesLst.size();
if (debug)
{
// just for debug info
getSelectedArrayEntries(arraySelection);
Info<< "<end> Foam::vtkPV3Foam::updateInfoZones" << endl;
}
}
void Foam::vtkPV3Foam::updateInfoSets
(
vtkDataArraySelection* arraySelection
)
{
if (!reader_->GetIncludeSets())
{
return;
}
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::updateInfoSets" << endl;
}
// Add names of sets. Search for last time directory with a sets
// subdirectory. Take care not to search beyond the last mesh.
word facesInstance = dbPtr_().findInstance
(
meshDir_,
"faces",
IOobject::READ_IF_PRESENT
);
word setsInstance = dbPtr_().findInstance
(
meshDir_/"sets",
word::null,
IOobject::READ_IF_PRESENT,
facesInstance
);
IOobjectList objects(dbPtr_(), setsInstance, meshDir_/"sets");
if (debug)
{
Info<< " Foam::vtkPV3Foam::updateInfoSets read "
<< objects.names() << " from " << setsInstance << endl;
}
arrayRangeCellSets_.reset(arraySelection->GetNumberOfArrays());
arrayRangeCellSets_ += addToSelection<cellSet>
(
arraySelection,
objects,
" - cellSet"
);
arrayRangeFaceSets_.reset(arraySelection->GetNumberOfArrays());
arrayRangeFaceSets_ += addToSelection<faceSet>
(
arraySelection,
objects,
" - faceSet"
);
arrayRangePointSets_.reset(arraySelection->GetNumberOfArrays());
arrayRangePointSets_ += addToSelection<pointSet>
(
arraySelection,
objects,
" - pointSet"
);
if (debug)
{
// just for debug info
getSelectedArrayEntries(arraySelection);
Info<< "<end> Foam::vtkPV3Foam::updateInfoSets" << endl;
}
}
void Foam::vtkPV3Foam::updateInfoLagrangianFields()
{
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::updateInfoLagrangianFields"
<< endl;
}
vtkDataArraySelection* fieldSelection =
reader_->GetLagrangianFieldSelection();
// preserve the enabled selections
stringList enabledEntries = getSelectedArrayEntries(fieldSelection);
fieldSelection->RemoveAllArrays();
// TODO - currently only get fields from ONE cloud
// have to decide if the second set of fields get mixed in
// or dealt with separately
const arrayRange& range = arrayRangeLagrangian_;
if (range.empty())
{
return;
}
int partId = range.start();
word cloudName = getPartName(partId);
// use the db directly since this might be called without a mesh,
// but the region must get added back in
fileName lagrangianPrefix(cloud::prefix);
if (meshRegion_ != polyMesh::defaultRegion)
{
lagrangianPrefix = meshRegion_/cloud::prefix;
}
IOobjectList objects
(
dbPtr_(),
dbPtr_().timeName(),
lagrangianPrefix/cloudName
);
addToSelection<IOField<label>>
(
fieldSelection,
objects
);
addToSelection<IOField<scalar>>
(
fieldSelection,
objects
);
addToSelection<IOField<vector>>
(
fieldSelection,
objects
);
addToSelection<IOField<sphericalTensor>>
(
fieldSelection,
objects
);
addToSelection<IOField<symmTensor>>
(
fieldSelection,
objects
);
addToSelection<IOField<tensor>>
(
fieldSelection,
objects
);
// restore the enabled selections
setSelectedArrayEntries(fieldSelection, enabledEntries);
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::updateInfoLagrangianFields - "
<< "lagrangian objects.size() = " << objects.size() << endl;
}
}
// ************************************************************************* //

View File

@ -1,115 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
InClass
vtkPV3Foam
\*---------------------------------------------------------------------------*/
#ifndef vtkPV3FoamUpdateInfoFields_H
#define vtkPV3FoamUpdateInfoFields_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<template<class> class patchType, class meshType>
void Foam::vtkPV3Foam::updateInfoFields
(
vtkDataArraySelection* select
)
{
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::updateInfoFields <"
<< meshType::Mesh::typeName
<< "> [meshPtr=" << (meshPtr_ ? "set" : "nullptr") << "]"
<< endl;
}
stringList enabledEntries;
// enable 'p' and 'U' on the first call
if (select->GetNumberOfArrays() == 0 && !meshPtr_)
{
enabledEntries.setSize(2);
enabledEntries[0] = "p";
enabledEntries[1] = "U";
}
else
{
// preserve the enabled selections
enabledEntries = getSelectedArrayEntries(select);
}
select->RemoveAllArrays();
// use the db directly since this might be called without a mesh,
// but the region must get added back in
word regionPrefix;
if (meshRegion_ != polyMesh::defaultRegion)
{
regionPrefix = meshRegion_;
}
// Search for list of objects for this time and mesh region
IOobjectList objects(dbPtr_(), dbPtr_().timeName(), regionPrefix);
//- Add volume fields to GUI
addToSelection<GeometricField<scalar, patchType, meshType>>
(
select,
objects
);
addToSelection<GeometricField<vector, patchType, meshType>>
(
select,
objects
);
addToSelection<GeometricField<sphericalTensor, patchType, meshType>>
(
select,
objects
);
addToSelection<GeometricField<symmTensor, patchType, meshType>>
(
select,
objects
);
addToSelection<GeometricField<tensor, patchType, meshType>>
(
select,
objects
);
// restore the enabled selections
setSelectedArrayEntries(select, enabledEntries);
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::updateInfoFields" << endl;
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,340 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
Description
Misc helper methods and utilities
\*---------------------------------------------------------------------------*/
#include "vtkPV3Foam.H"
#include "vtkPV3FoamReader.h"
// OpenFOAM includes
#include "fvMesh.H"
#include "Time.H"
#include "IFstream.H"
#include "memInfo.H"
// VTK includes
#include "vtkDataArraySelection.h"
#include "vtkDataSet.h"
#include "vtkMultiBlockDataSet.h"
#include "vtkInformation.h"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
//! \cond fileScope
// Extract up to the first non-word characters
inline word getFirstWord(const char* str)
{
if (str)
{
label n = 0;
while (str[n] && word::valid(str[n]))
{
++n;
}
return word(str, n, true);
}
else
{
return word::null;
}
}
//! \endcond
} // End namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::vtkPV3Foam::AddToBlock
(
vtkMultiBlockDataSet* output,
vtkDataSet* dataset,
const arrayRange& range,
const label datasetNo,
const std::string& datasetName
)
{
const int blockNo = range.block();
vtkDataObject* blockDO = output->GetBlock(blockNo);
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO);
if (!block)
{
if (blockDO)
{
FatalErrorInFunction
<< "Block already has a vtkDataSet assigned to it"
<< endl;
return;
}
block = vtkMultiBlockDataSet::New();
output->SetBlock(blockNo, block);
block->Delete();
}
if (debug)
{
Info<< "block[" << blockNo << "] has "
<< block->GetNumberOfBlocks()
<< " datasets prior to adding set " << datasetNo
<< " with name: " << datasetName << endl;
}
block->SetBlock(datasetNo, dataset);
// name the block when assigning dataset 0
if (datasetNo == 0)
{
output->GetMetaData(blockNo)->Set
(
vtkCompositeDataSet::NAME(),
range.name()
);
}
if (datasetName.size())
{
block->GetMetaData(datasetNo)->Set
(
vtkCompositeDataSet::NAME(),
datasetName.c_str()
);
}
}
vtkDataSet* Foam::vtkPV3Foam::GetDataSetFromBlock
(
vtkMultiBlockDataSet* output,
const arrayRange& range,
const label datasetNo
)
{
const int blockNo = range.block();
vtkDataObject* blockDO = output->GetBlock(blockNo);
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO);
if (block)
{
return vtkDataSet::SafeDownCast(block->GetBlock(datasetNo));
}
return 0;
}
// ununsed at the moment
Foam::label Foam::vtkPV3Foam::GetNumberOfDataSets
(
vtkMultiBlockDataSet* output,
const arrayRange& range
)
{
const int blockNo = range.block();
vtkDataObject* blockDO = output->GetBlock(blockNo);
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO);
if (block)
{
return block->GetNumberOfBlocks();
}
return 0;
}
Foam::word Foam::vtkPV3Foam::getPartName(const int partId)
{
return getFirstWord(reader_->GetPartArrayName(partId));
}
Foam::wordHashSet Foam::vtkPV3Foam::getSelected
(
vtkDataArraySelection* select
)
{
int nElem = select->GetNumberOfArrays();
wordHashSet selections(2*nElem);
for (int elemI=0; elemI < nElem; ++elemI)
{
if (select->GetArraySetting(elemI))
{
selections.insert(getFirstWord(select->GetArrayName(elemI)));
}
}
return selections;
}
Foam::wordHashSet Foam::vtkPV3Foam::getSelected
(
vtkDataArraySelection* select,
const arrayRange& range
)
{
int nElem = select->GetNumberOfArrays();
wordHashSet selections(2*nElem);
for (int elemI = range.start(); elemI < range.end(); ++elemI)
{
if (select->GetArraySetting(elemI))
{
selections.insert(getFirstWord(select->GetArrayName(elemI)));
}
}
return selections;
}
Foam::stringList Foam::vtkPV3Foam::getSelectedArrayEntries
(
vtkDataArraySelection* select
)
{
stringList selections(select->GetNumberOfArrays());
label nElem = 0;
forAll(selections, elemI)
{
if (select->GetArraySetting(elemI))
{
selections[nElem++] = select->GetArrayName(elemI);
}
}
selections.setSize(nElem);
if (debug)
{
label nElem = select->GetNumberOfArrays();
Info<< "available(";
for (int elemI = 0; elemI < nElem; ++elemI)
{
Info<< " \"" << select->GetArrayName(elemI) << "\"";
}
Info<< " )\nselected(";
forAll(selections, elemI)
{
Info<< " " << selections[elemI];
}
Info<< " )\n";
}
return selections;
}
Foam::stringList Foam::vtkPV3Foam::getSelectedArrayEntries
(
vtkDataArraySelection* select,
const arrayRange& range
)
{
stringList selections(range.size());
label nElem = 0;
for (int elemI = range.start(); elemI < range.end(); ++elemI)
{
if (select->GetArraySetting(elemI))
{
selections[nElem++] = select->GetArrayName(elemI);
}
}
selections.setSize(nElem);
if (debug)
{
Info<< "available(";
for (int elemI = range.start(); elemI < range.end(); ++elemI)
{
Info<< " \"" << select->GetArrayName(elemI) << "\"";
}
Info<< " )\nselected(";
forAll(selections, elemI)
{
Info<< " " << selections[elemI];
}
Info<< " )\n";
}
return selections;
}
void Foam::vtkPV3Foam::setSelectedArrayEntries
(
vtkDataArraySelection* select,
const stringList& selections
)
{
const int nElem = select->GetNumberOfArrays();
select->DisableAllArrays();
// Loop through entries, setting values from selectedEntries
for (int elemI=0; elemI < nElem; ++elemI)
{
string arrayName(select->GetArrayName(elemI));
forAll(selections, elemI)
{
if (selections[elemI] == arrayName)
{
select->EnableArray(arrayName.c_str());
break;
}
}
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::vtkPV3Foam::printMemory()
{
memInfo mem;
if (mem.valid())
{
Info<< "mem peak/size/rss: " << mem << "\n";
}
}
// ************************************************************************* //

View File

@ -1,380 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
InClass
vtkPV3Foam
\*---------------------------------------------------------------------------*/
#ifndef vtkPV3FoamVolFields_H
#define vtkPV3FoamVolFields_H
// OpenFOAM includes
#include "emptyFvPatchField.H"
#include "wallPolyPatch.H"
#include "faceSet.H"
#include "volPointInterpolation.H"
#include "vtkPV3FoamFaceField.H"
#include "vtkPV3FoamPatchField.H"
#include "vtkOpenFOAMTupleRemap.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
void Foam::vtkPV3Foam::convertVolFields
(
const fvMesh& mesh,
const PtrList<PrimitivePatchInterpolation<primitivePatch>>& ppInterpList,
const IOobjectList& objects,
const bool interpFields,
vtkMultiBlockDataSet* output
)
{
const polyBoundaryMesh& patches = mesh.boundaryMesh();
forAllConstIter(IOobjectList, objects, iter)
{
// restrict to GeometricField<Type, ...>
if
(
iter()->headerClassName()
!= GeometricField<Type, fvPatchField, volMesh>::typeName
)
{
continue;
}
// Load field
GeometricField<Type, fvPatchField, volMesh> tf
(
*iter(),
mesh
);
// Interpolated field (demand driven)
autoPtr<GeometricField<Type, pointPatchField, pointMesh>> ptfPtr;
if (interpFields)
{
if (debug)
{
Info<< "convertVolFieldBlock interpolating:" << tf.name()
<< endl;
}
ptfPtr.reset
(
volPointInterpolation::New(tf.mesh()).interpolate(tf).ptr()
);
}
// Convert activated internalMesh regions
convertVolFieldBlock
(
tf,
ptfPtr,
output,
arrayRangeVolume_,
regionPolyDecomp_
);
// Convert activated cellZones
convertVolFieldBlock
(
tf,
ptfPtr,
output,
arrayRangeCellZones_,
zonePolyDecomp_
);
// Convert activated cellSets
convertVolFieldBlock
(
tf,
ptfPtr,
output,
arrayRangeCellSets_,
csetPolyDecomp_
);
//
// Convert patches - if activated
//
for
(
int partId = arrayRangePatches_.start();
partId < arrayRangePatches_.end();
++partId
)
{
const word patchName = getPartName(partId);
const label datasetNo = partDataset_[partId];
const label patchId = patches.findPatchID(patchName);
if (!partStatus_[partId] || datasetNo < 0 || patchId < 0)
{
continue;
}
const fvPatchField<Type>& ptf = tf.boundaryField()[patchId];
if
(
isType<emptyFvPatchField<Type>>(ptf)
||
(
reader_->GetExtrapolatePatches()
&& !polyPatch::constraintType(patches[patchId].type())
)
)
{
fvPatch p(ptf.patch().patch(), tf.mesh().boundary());
tmp<Field<Type>> tpptf
(
fvPatchField<Type>(p, tf).patchInternalField()
);
convertPatchField
(
tf.name(),
tpptf(),
output,
arrayRangePatches_,
datasetNo
);
if (interpFields)
{
convertPatchPointField
(
tf.name(),
ppInterpList[patchId].faceToPointInterpolate(tpptf)(),
output,
arrayRangePatches_,
datasetNo
);
}
}
else
{
convertPatchField
(
tf.name(),
ptf,
output,
arrayRangePatches_,
datasetNo
);
if (interpFields)
{
convertPatchPointField
(
tf.name(),
ppInterpList[patchId].faceToPointInterpolate(ptf)(),
output,
arrayRangePatches_,
datasetNo
);
}
}
}
//
// Convert face zones - if activated
//
for
(
int partId = arrayRangeFaceZones_.start();
partId < arrayRangeFaceZones_.end();
++partId
)
{
const word zoneName = getPartName(partId);
const label datasetNo = partDataset_[partId];
if (!partStatus_[partId] || datasetNo < 0)
{
continue;
}
const faceZoneMesh& zMesh = mesh.faceZones();
const label zoneId = zMesh.findZoneID(zoneName);
if (zoneId < 0)
{
continue;
}
convertFaceField
(
tf,
output,
arrayRangeFaceZones_,
datasetNo,
mesh,
zMesh[zoneId]
);
// TODO: points
}
//
// Convert face sets - if activated
//
for
(
int partId = arrayRangeFaceSets_.start();
partId < arrayRangeFaceSets_.end();
++partId
)
{
const word selectName = getPartName(partId);
const label datasetNo = partDataset_[partId];
if (!partStatus_[partId] || datasetNo < 0)
{
continue;
}
const faceSet fSet(mesh, selectName);
convertFaceField
(
tf,
output,
arrayRangeFaceSets_,
datasetNo,
mesh,
fSet.toc()
);
// TODO: points
}
}
}
template<class Type>
void Foam::vtkPV3Foam::convertVolFieldBlock
(
const GeometricField<Type, fvPatchField, volMesh>& tf,
autoPtr<GeometricField<Type, pointPatchField, pointMesh>>& ptfPtr,
vtkMultiBlockDataSet* output,
const arrayRange& range,
const List<polyDecomp>& decompLst
)
{
for (int partId = range.start(); partId < range.end(); ++partId)
{
const label datasetNo = partDataset_[partId];
if (datasetNo >= 0 && partStatus_[partId])
{
convertVolField
(
tf,
output,
range,
datasetNo,
decompLst[datasetNo]
);
if (ptfPtr.valid())
{
convertPointField
(
ptfPtr(),
tf,
output,
range,
datasetNo,
decompLst[datasetNo]
);
}
}
}
}
template<class Type>
void Foam::vtkPV3Foam::convertVolField
(
const GeometricField<Type, fvPatchField, volMesh>& tf,
vtkMultiBlockDataSet* output,
const arrayRange& range,
const label datasetNo,
const polyDecomp& decompInfo
)
{
const label nComp = pTraits<Type>::nComponents;
const labelList& superCells = decompInfo.superCells();
vtkFloatArray* celldata = vtkFloatArray::New();
celldata->SetNumberOfTuples(superCells.size());
celldata->SetNumberOfComponents(nComp);
celldata->Allocate(nComp*superCells.size());
celldata->SetName(tf.name().c_str());
if (debug)
{
Info<< "convert volField: "
<< tf.name()
<< " size = " << tf.size()
<< " nComp=" << nComp
<< " nTuples = " << superCells.size() << endl;
}
float vec[nComp];
forAll(superCells, i)
{
const Type& t = tf[superCells[i]];
for (direction d=0; d<nComp; ++d)
{
vec[d] = component(t, d);
}
vtkOpenFOAMTupleRemap<Type>(vec);
celldata->InsertTuple(i, vec);
}
vtkUnstructuredGrid::SafeDownCast
(
GetDataSetFromBlock(output, range, datasetNo)
) ->GetCellData()
->AddArray(celldata);
celldata->Delete();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,11 +0,0 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
set -x
# deal with client/server vs combined plugins
rm -f $FOAM_LIBBIN/libPV3blockMeshReader* 2>/dev/null
rm -rf PV3blockMeshReader/Make
wclean libso vtkPV3blockMesh
#------------------------------------------------------------------------------

View File

@ -1,24 +0,0 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
# Parse arguments for library compilation
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
set -x
if [ -d "$ParaView_DIR" -a -r "$ParaView_DIR" ]
then
wmake $targetType vtkPV3blockMesh
if [ "$targetType" != "objects" ]
then
(
cd PV3blockMeshReader
mkdir -p Make/$WM_OPTIONS > /dev/null 2>&1
cd Make/$WM_OPTIONS
cmake ../..
make
)
fi
fi
#------------------------------------------------------------------------------

View File

@ -1,87 +0,0 @@
# create a plugin that adds a reader to the ParaView GUI
# it is added in the file dialog when doing opens/saves.
# The qrc file is processed by Qt's resource compiler (rcc)
# the qrc file must have a resource prefix of "/ParaViewResources"
# and ParaView will read anything contained under that prefix
# the pqReader.xml file contains xml defining readers with their
# file extensions and descriptions.
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
FIND_PACKAGE(ParaView REQUIRED)
INCLUDE(${PARAVIEW_USE_FILE})
LINK_DIRECTORIES(
$ENV{FOAM_LIBBIN}
$ENV{FOAM_EXT_LIBBIN}
)
INCLUDE_DIRECTORIES(
$ENV{WM_PROJECT_DIR}/src/OpenFOAM/lnInclude
$ENV{WM_PROJECT_DIR}/src/OSspecific/$ENV{WM_OSTYPE}/lnInclude
$ENV{WM_PROJECT_DIR}/src/meshing/blockMesh/lnInclude
${PROJECT_SOURCE_DIR}/../vtkPV3blockMesh
)
ADD_DEFINITIONS(
-DWM_$ENV{WM_PRECISION_OPTION}
-DWM_LABEL_SIZE=$ENV{WM_LABEL_SIZE}
)
# Set output library destination to plugin directory
SET(
LIBRARY_OUTPUT_PATH $ENV{PV_PLUGIN_PATH}
CACHE INTERNAL
"Single output directory for building all libraries."
)
#
# Define combined plugin
#
# Extend the auto-generated panel
QT4_WRAP_CPP(MOC_SRCS pqPV3blockMeshReaderPanel.h)
ADD_PARAVIEW_OBJECT_PANEL(IFACES IFACE_SRCS
CLASS_NAME pqPV3blockMeshReaderPanel
XML_NAME PV3blockMeshReader # name of SourceProxy in *SM.xml
XML_GROUP sources
)
ADD_PARAVIEW_PLUGIN(
PV3blockMeshReader_SM "1.0"
SERVER_MANAGER_XML PV3blockMeshReader_SM.xml
SERVER_MANAGER_SOURCES vtkPV3blockMeshReader.cxx
GUI_INTERFACES ${IFACES}
GUI_SOURCES pqPV3blockMeshReaderPanel.cxx
${MOC_SRCS} ${UI_SRCS} ${IFACE_SRCS}
GUI_RESOURCE_FILES PV3blockMeshReader.xml
)
# #
# # Define the server-side portion of the reader plugin
# #
# ADD_PARAVIEW_PLUGIN(PV3blockMeshReader_SM "1.0"
# SERVER_MANAGER_XML PV3blockMeshReader_SM.xml
# SERVER_MANAGER_SOURCES vtkPV3blockMeshReader.cxx
# )
# #
# # Define the client-side portion of the reader plugin
# #
# ADD_PARAVIEW_PLUGIN(
# PV3blockMeshReader "1.0"
# GUI_RESOURCES PV3blockMeshReader.qrc
# )
# Build the client-side plugin
TARGET_LINK_LIBRARIES(
PV3blockMeshReader_SM
OpenFOAM
blockMesh
vtkPV3blockMesh
)
#-----------------------------------------------------------------------------

View File

@ -1,5 +0,0 @@
<RCC>
<qresource prefix="/ParaViewResources" >
<file>PV3blockMeshReader.xml</file>
</qresource>
</RCC>

View File

@ -1,6 +0,0 @@
<ParaViewReaders>
<Reader name="PV3blockMeshReader"
extensions="blockMesh"
file_description="OpenFOAM blockMesh reader">
</Reader>
</ParaViewReaders>

View File

@ -1,110 +0,0 @@
<ServerManagerConfiguration>
<ProxyGroup name="sources">
<SourceProxy
name="PV3blockMeshReader"
class="vtkPV3blockMeshReader">
<!-- File name - compulsory -->
<StringVectorProperty
name="FileName"
command="SetFileName"
number_of_elements="1"
animateable="0">
<FileListDomain name="files"/>
<Documentation>
Specifies the filename for the OpenFOAM blockMesh Reader.
</Documentation>
</StringVectorProperty>
<!-- Show Point Numbers check-box -->
<IntVectorProperty
name="UiShowPointNumbers"
command="SetShowPointNumbers"
number_of_elements="1"
default_values="1"
is_internal="1"
animateable="0">
<BooleanDomain name="bool"/>
<Documentation>
Show point numbers in render window.
</Documentation>
</IntVectorProperty>
<!-- Update GUI check box -->
<IntVectorProperty
name="UpdateGUI"
command="SetUpdateGUI"
number_of_elements="1"
default_values="0"
animateable="0">
<BooleanDomain name="bool"/>
<Documentation>
A simple way to cause a reader GUI modification.
</Documentation>
</IntVectorProperty>
<!--
| Selections
-->
<!-- Available Blocks array -->
<StringVectorProperty
name="BlockArrayStatus"
information_only="1">
<ArraySelectionInformationHelper attribute_name="Block"/>
</StringVectorProperty>
<StringVectorProperty
name="BlockStatus"
label="Blocks"
command="SetBlockArrayStatus"
number_of_elements="0"
repeat_command="1"
number_of_elements_per_command="2"
element_types="2 0"
information_property="BlockArrayStatus"
animateable="0">
<ArraySelectionDomain name="array_list">
<RequiredProperties>
<Property name="BlockArrayStatus" function="ArrayList"/>
</RequiredProperties>
</ArraySelectionDomain>
<Documentation>
This property contains a list of the blocks
</Documentation>
</StringVectorProperty>
<!-- Available CurvedEdges array -->
<StringVectorProperty
name="CurvedEdgesArrayStatus"
information_only="1">
<ArraySelectionInformationHelper attribute_name="CurvedEdges"/>
</StringVectorProperty>
<StringVectorProperty
name="CurvedEdgesStatus"
label="Curved Edges"
command="SetCurvedEdgesArrayStatus"
number_of_elements="0"
repeat_command="1"
number_of_elements_per_command="2"
element_types="2 0"
information_property="CurvedEdgesArrayStatus"
animateable="0">
<ArraySelectionDomain name="array_list">
<RequiredProperties>
<Property name="CurvedEdgesArrayStatus" function="ArrayList"/>
</RequiredProperties>
</ArraySelectionDomain>
<Documentation>
This property contains a list of the curved edges
</Documentation>
</StringVectorProperty>
<Hints>
<Property name="FileName" show="0"/>
<Property name="UiShowPointNumbers" show="0"/>
</Hints>
</SourceProxy>
</ProxyGroup>
</ServerManagerConfiguration>

View File

@ -1,110 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "pqPV3blockMeshReaderPanel.h"
// QT
#include <QGridLayout>
#include <QCheckBox>
#include <QLabel>
#include <QLayout>
#include <QString>
#include <QPushButton>
#include <QtDebug>
// Paraview <-> QT UI
#include "pqAnimationScene.h"
#include "pqApplicationCore.h"
#include "pqPipelineRepresentation.h"
#include "pqServerManagerModel.h"
#include "pqView.h"
// Paraview Server Manager
#include "vtkSMDoubleVectorProperty.h"
#include "vtkSMIntVectorProperty.h"
#include "vtkSMProperty.h"
#include "vtkSMSourceProxy.h"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
pqPV3blockMeshReaderPanel::pqPV3blockMeshReaderPanel
(
pqProxy *proxy,
QWidget *p
)
:
pqAutoGeneratedObjectPanel(proxy, p)
{
// create first sublayout (at top of the panel)
QGridLayout *form = new QGridLayout();
this->PanelLayout->addLayout(form, 0, 0, 1, -1);
vtkSMProperty* prop = 0;
// checkbox for showing point numbers
if ((prop = this->proxy()->GetProperty("UiShowPointNumbers")) != 0)
{
prop->SetImmediateUpdate(true);
ShowPointNumbers_ = new QCheckBox("Show Point Numbers");
ShowPointNumbers_->setToolTip("Show point numbers in render window.");
ShowPointNumbers_->setChecked
(
vtkSMIntVectorProperty::SafeDownCast(prop)->GetElement(0)
);
form->addWidget(ShowPointNumbers_);
connect
(
ShowPointNumbers_,
SIGNAL(stateChanged(int)),
this,
SLOT(ShowPointNumbersToggled())
);
}
}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void pqPV3blockMeshReaderPanel::ShowPointNumbersToggled()
{
vtkSMIntVectorProperty::SafeDownCast
(
this->proxy()->GetProperty("UiShowPointNumbers")
)->SetElement(0, ShowPointNumbers_->isChecked());
// update the active view
if (this->view())
{
this->view()->render();
}
// OR: update all views
// pqApplicationCore::instance()->render();
}
// ************************************************************************* //

View File

@ -1,90 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
Class
pqPV3blockMeshReaderPanel
Description
GUI modifications for the ParaView reader panel
A custom panel for the PV3blockMeshReader.
SourceFiles
pqPV3blockMeshReaderPanel.cxx
\*---------------------------------------------------------------------------*/
#ifndef pqPV3blockMeshReaderPanel_h
#define pqPV3blockMeshReaderPanel_h
#include "pqAutoGeneratedObjectPanel.h"
// Forward declaration of QT classes
class QCheckBox;
class QLineEdit;
class QTimer;
class QToolButton;
// Forward declaration of ParaView classes
class vtkSMSourceProxy;
/*---------------------------------------------------------------------------*\
Class pqPV3blockMeshReaderPanel Declaration
\*---------------------------------------------------------------------------*/
class pqPV3blockMeshReaderPanel
:
public pqAutoGeneratedObjectPanel
{
// Private data
Q_OBJECT;
typedef pqAutoGeneratedObjectPanel Superclass;
//- Show Point Numbers checkbox
QCheckBox* ShowPointNumbers_;
protected slots:
void ShowPointNumbersToggled();
public:
// Constructors
//- Construct from components
pqPV3blockMeshReaderPanel(pqProxy*, QWidget*);
//- Destructor
// virtual ~pqPV3blockMeshReaderPanel();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,419 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "vtkPV3blockMeshReader.h"
#include "pqApplicationCore.h"
#include "pqRenderView.h"
#include "pqServerManagerModel.h"
// VTK includes
#include "vtkCallbackCommand.h"
#include "vtkDataArraySelection.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkMultiBlockDataSet.h"
#include "vtkObjectFactory.h"
#include "vtkSMRenderViewProxy.h"
#include "vtkStreamingDemandDrivenPipeline.h"
#include "vtkStringArray.h"
// OpenFOAM includes
#include "vtkPV3blockMesh.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
vtkStandardNewMacro(vtkPV3blockMeshReader);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
vtkPV3blockMeshReader::vtkPV3blockMeshReader()
{
Debug = 0;
vtkDebugMacro(<<"Constructor");
SetNumberOfInputPorts(0);
FileName = nullptr;
foamData_ = nullptr;
ShowPointNumbers = 1;
UpdateGUI = 0;
BlockSelection = vtkDataArraySelection::New();
CurvedEdgesSelection = vtkDataArraySelection::New();
// Setup the selection callback to modify this object when an array
// selection is changed.
SelectionObserver = vtkCallbackCommand::New();
SelectionObserver->SetCallback
(
&vtkPV3blockMeshReader::SelectionModifiedCallback
);
SelectionObserver->SetClientData(this);
BlockSelection->AddObserver
(
vtkCommand::ModifiedEvent,
this->SelectionObserver
);
CurvedEdgesSelection->AddObserver
(
vtkCommand::ModifiedEvent,
this->SelectionObserver
);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
vtkPV3blockMeshReader::~vtkPV3blockMeshReader()
{
vtkDebugMacro(<<"Deconstructor");
if (foamData_)
{
// remove point numbers
updatePointNumbersView(false);
delete foamData_;
}
if (FileName)
{
delete [] FileName;
}
BlockSelection->RemoveObserver(this->SelectionObserver);
CurvedEdgesSelection->RemoveObserver(this->SelectionObserver);
SelectionObserver->Delete();
BlockSelection->Delete();
}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
// Do everything except set the output info
int vtkPV3blockMeshReader::RequestInformation
(
vtkInformation* vtkNotUsed(request),
vtkInformationVector** vtkNotUsed(inputVector),
vtkInformationVector* outputVector
)
{
vtkDebugMacro(<<"RequestInformation");
if (Foam::vtkPV3blockMesh::debug)
{
cout<<"REQUEST_INFORMATION\n";
}
if (!FileName)
{
vtkErrorMacro("FileName has to be specified!");
return 0;
}
int nInfo = outputVector->GetNumberOfInformationObjects();
if (Foam::vtkPV3blockMesh::debug)
{
cout<<"RequestInformation with " << nInfo << " item(s)\n";
for (int infoI = 0; infoI < nInfo; ++infoI)
{
outputVector->GetInformationObject(infoI)->Print(cout);
}
}
if (!foamData_)
{
foamData_ = new Foam::vtkPV3blockMesh(FileName, this);
}
else
{
foamData_->updateInfo();
}
// might need some other type of error handling
// {
// vtkErrorMacro("could not find valid OpenFOAM blockMesh");
//
// // delete foamData and flag it as fatal error
// delete foamData_;
// foamData_ = nullptr;
// return 0;
// }
return 1;
}
// Set the output info
int vtkPV3blockMeshReader::RequestData
(
vtkInformation* vtkNotUsed(request),
vtkInformationVector** vtkNotUsed(inputVector),
vtkInformationVector* outputVector
)
{
vtkDebugMacro(<<"RequestData");
if (!FileName)
{
vtkErrorMacro("FileName has to be specified!");
return 0;
}
// catch previous error
if (!foamData_)
{
vtkErrorMacro("Reader failed - perhaps no mesh?");
return 0;
}
int nInfo = outputVector->GetNumberOfInformationObjects();
if (Foam::vtkPV3blockMesh::debug)
{
cout<<"RequestData with " << nInfo << " item(s)\n";
for (int infoI = 0; infoI < nInfo; ++infoI)
{
outputVector->GetInformationObject(infoI)->Print(cout);
}
}
vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::SafeDownCast
(
outputVector->GetInformationObject(0)->Get
(
vtkMultiBlockDataSet::DATA_OBJECT()
)
);
if (Foam::vtkPV3blockMesh::debug)
{
cout<< "update output with "
<< output->GetNumberOfBlocks() << " blocks\n";
}
foamData_->Update(output);
updatePointNumbersView(ShowPointNumbers);
// Do any cleanup on the OpenFOAM side
foamData_->CleanUp();
return 1;
}
void vtkPV3blockMeshReader::SetShowPointNumbers(const int val)
{
if (ShowPointNumbers != val)
{
ShowPointNumbers = val;
updatePointNumbersView(ShowPointNumbers);
}
}
void vtkPV3blockMeshReader::updatePointNumbersView(const bool show)
{
pqApplicationCore* appCore = pqApplicationCore::instance();
// need to check this, since our destructor calls this
if (!appCore)
{
return;
}
// Server manager model for querying items in the server manager
pqServerManagerModel* smModel = appCore->getServerManagerModel();
if (!smModel || !foamData_)
{
return;
}
// Get all the pqRenderView instances
QList<pqRenderView*> renderViews = smModel->findItems<pqRenderView*>();
for (int viewI=0; viewI<renderViews.size(); ++viewI)
{
foamData_->renderPointNumbers
(
renderViews[viewI]->getRenderViewProxy()->GetRenderer(),
show
);
}
// use refresh here?
}
void vtkPV3blockMeshReader::PrintSelf(ostream& os, vtkIndent indent)
{
vtkDebugMacro(<<"PrintSelf");
this->Superclass::PrintSelf(os,indent);
os << indent << "File name: "
<< (this->FileName ? this->FileName : "(none)") << "\n";
foamData_->PrintSelf(os, indent);
}
// ----------------------------------------------------------------------
// Block selection list control
vtkDataArraySelection* vtkPV3blockMeshReader::GetBlockSelection()
{
vtkDebugMacro(<<"GetBlockSelection");
return BlockSelection;
}
int vtkPV3blockMeshReader::GetNumberOfBlockArrays()
{
vtkDebugMacro(<<"GetNumberOfBlockArrays");
return BlockSelection->GetNumberOfArrays();
}
const char* vtkPV3blockMeshReader::GetBlockArrayName(int index)
{
vtkDebugMacro(<<"GetBlockArrayName");
return BlockSelection->GetArrayName(index);
}
int vtkPV3blockMeshReader::GetBlockArrayStatus(const char* name)
{
vtkDebugMacro(<<"GetBlockArrayStatus");
return BlockSelection->ArrayIsEnabled(name);
}
void vtkPV3blockMeshReader::SetBlockArrayStatus
(
const char* name,
int status
)
{
vtkDebugMacro(<<"SetBlockArrayStatus");
if (status)
{
BlockSelection->EnableArray(name);
}
else
{
BlockSelection->DisableArray(name);
}
}
// ----------------------------------------------------------------------
// CurvedEdges selection list control
vtkDataArraySelection* vtkPV3blockMeshReader::GetCurvedEdgesSelection()
{
vtkDebugMacro(<<"GetCurvedEdgesSelection");
return CurvedEdgesSelection;
}
int vtkPV3blockMeshReader::GetNumberOfCurvedEdgesArrays()
{
vtkDebugMacro(<<"GetNumberOfCurvedEdgesArrays");
return CurvedEdgesSelection->GetNumberOfArrays();
}
const char* vtkPV3blockMeshReader::GetCurvedEdgesArrayName(int index)
{
vtkDebugMacro(<<"GetCurvedEdgesArrayName");
return CurvedEdgesSelection->GetArrayName(index);
}
int vtkPV3blockMeshReader::GetCurvedEdgesArrayStatus(const char* name)
{
vtkDebugMacro(<<"GetCurvedEdgesArrayStatus");
return CurvedEdgesSelection->ArrayIsEnabled(name);
}
void vtkPV3blockMeshReader::SetCurvedEdgesArrayStatus
(
const char* name,
int status
)
{
vtkDebugMacro(<<"SetCurvedEdgesArrayStatus");
if (status)
{
CurvedEdgesSelection->EnableArray(name);
}
else
{
CurvedEdgesSelection->DisableArray(name);
}
}
// ----------------------------------------------------------------------
void vtkPV3blockMeshReader::SelectionModifiedCallback
(
vtkObject*,
unsigned long,
void* clientdata,
void*
)
{
static_cast<vtkPV3blockMeshReader*>(clientdata)->Modified();
}
int vtkPV3blockMeshReader::FillOutputPortInformation
(
int port,
vtkInformation* info
)
{
if (port == 0)
{
return this->Superclass::FillOutputPortInformation(port, info);
}
info->Set(vtkDataObject::DATA_TYPE_NAME(), "vtkMultiBlockDataSet");
return 1;
}
// ************************************************************************* //

View File

@ -1,177 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
Class
vtkPV3blockMeshReader
Description
reads a dataset in OpenFOAM bockMesh format
vtkPV3blockMeshReader creates an multiblock dataset.
It uses the OpenFOAM infrastructure (blockMesh).
SourceFiles
vtkPV3blockMeshReader.cxx
\*---------------------------------------------------------------------------*/
#ifndef vtkPV3blockMeshReader_h
#define vtkPV3blockMeshReader_h
// VTK includes
#include "vtkMultiBlockDataSetAlgorithm.h"
// * * * * * * * * * * * * * Forward Declarations * * * * * * * * * * * * * //
// VTK forward declarations
class vtkDataArraySelection;
class vtkCallbackCommand;
namespace Foam
{
class vtkPV3blockMesh;
}
/*---------------------------------------------------------------------------*\
Class vtkPV3blockMeshReader Declaration
\*---------------------------------------------------------------------------*/
class VTK_IO_EXPORT vtkPV3blockMeshReader
:
public vtkMultiBlockDataSetAlgorithm
{
public:
vtkTypeMacro(vtkPV3blockMeshReader, vtkMultiBlockDataSetAlgorithm);
void PrintSelf(ostream&, vtkIndent);
static vtkPV3blockMeshReader* New();
// Description:
// Set/Get the filename.
vtkSetStringMacro(FileName);
vtkGetStringMacro(FileName);
// Description:
// Display corner point labels
virtual void SetShowPointNumbers(int);
vtkGetMacro(ShowPointNumbers, int);
// Description:
// GUI update control
vtkSetMacro(UpdateGUI, int);
vtkGetMacro(UpdateGUI, int);
// Description:
// Blocks selection list control
vtkDataArraySelection* GetBlockSelection();
int GetNumberOfBlockArrays();
int GetBlockArrayStatus(const char*);
void SetBlockArrayStatus(const char*, int status);
const char* GetBlockArrayName(int index);
// Description:
// CurvedEdges selection list control
vtkDataArraySelection* GetCurvedEdgesSelection();
int GetNumberOfCurvedEdgesArrays();
int GetCurvedEdgesArrayStatus(const char*);
void SetCurvedEdgesArrayStatus(const char*, int status);
const char* GetCurvedEdgesArrayName(int index);
// Description:
// Callback registered with the SelectionObserver
// for all the selection lists
static void SelectionModifiedCallback
(
vtkObject* caller,
unsigned long eid,
void* clientdata,
void* calldata
);
protected:
//- Construct null
vtkPV3blockMeshReader();
//- Destructor
~vtkPV3blockMeshReader();
//- Return information about mesh, times, etc without loading anything
virtual int RequestInformation
(
vtkInformation*,
vtkInformationVector**,
vtkInformationVector*
);
//- Get the mesh/fields for a particular time
virtual int RequestData
(
vtkInformation*,
vtkInformationVector**,
vtkInformationVector*
);
//- Fill in additional port information
virtual int FillOutputPortInformation(int, vtkInformation*);
// The observer to modify this object when array selections are modified
vtkCallbackCommand* SelectionObserver;
char* FileName;
private:
//- Disallow default bitwise copy construct
vtkPV3blockMeshReader(const vtkPV3blockMeshReader&);
//- Disallow default bitwise assignment
void operator=(const vtkPV3blockMeshReader&);
//- Add/remove point numbers to/from the view
void updatePointNumbersView(const bool show);
//- Show Point Numbers
int ShowPointNumbers;
//- Dummy variable/switch to invoke a reader update
int UpdateGUI;
vtkDataArraySelection* BlockSelection;
vtkDataArraySelection* CurvedEdgesSelection;
//BTX
Foam::vtkPV3blockMesh* foamData_;
//ETX
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,5 +0,0 @@
vtkPV3blockMesh.C
vtkPV3blockMeshConvert.C
vtkPV3blockMeshUtils.C
LIB = $(FOAM_LIBBIN)/libvtkPV3blockMesh

View File

@ -1,12 +0,0 @@
EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/mesh/blockMesh/lnInclude \
-I$(ParaView_INCLUDE_DIR) \
-I../../vtkPV3Readers/lnInclude \
-I../PV3blockMeshReader
LIB_LIBS = \
-lmeshTools \
-lblockMesh \
-L$(FOAM_LIBBIN) -lvtkPV3Readers \
$(GLIBS)

View File

@ -1,65 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
InClass
vtkPV3blockMesh
\*---------------------------------------------------------------------------*/
#ifndef vtkOpenFOAMPoints_H
#define vtkOpenFOAMPoints_H
// VTK includes
#include "vtkPoints.h"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
inline void vtkInsertNextOpenFOAMPoint
(
vtkPoints *points,
const Foam::point& p
)
{
points->InsertNextPoint(p.x(), p.y(), p.z());
}
inline void vtkInsertNextOpenFOAMPoint
(
vtkPoints *points,
const Foam::point& p,
const Foam::scalar scaleFactor
)
{
points->InsertNextPoint
(
p.x()*scaleFactor,
p.y()*scaleFactor,
p.z()*scaleFactor
);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,488 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "vtkPV3blockMesh.H"
#include "vtkPV3blockMeshReader.h"
// OpenFOAM includes
#include "blockMesh.H"
#include "Time.H"
#include "patchZones.H"
#include "OStringStream.H"
// VTK includes
#include "vtkDataArraySelection.h"
#include "vtkMultiBlockDataSet.h"
#include "vtkRenderer.h"
#include "vtkTextActor.h"
#include "vtkTextProperty.h"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(vtkPV3blockMesh, 0);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::vtkPV3blockMesh::resetCounters()
{
// Reset mesh part ids and sizes
arrayRangeBlocks_.reset();
arrayRangeEdges_.reset();
arrayRangeCorners_.reset();
}
void Foam::vtkPV3blockMesh::updateInfoBlocks
(
vtkDataArraySelection* arraySelection
)
{
if (debug)
{
Info<< "<beg> Foam::vtkPV3blockMesh::updateInfoBlocks"
<< " [meshPtr=" << (meshPtr_ ? "set" : "nullptr") << "]" << endl;
}
arrayRangeBlocks_.reset( arraySelection->GetNumberOfArrays() );
const blockMesh& blkMesh = *meshPtr_;
const int nBlocks = blkMesh.size();
for (int blockI = 0; blockI < nBlocks; ++blockI)
{
const blockDescriptor& blockDef = blkMesh[blockI];
word partName = Foam::name(blockI);
// append the (optional) zone name
if (!blockDef.zoneName().empty())
{
partName += " - " + blockDef.zoneName();
}
// Add blockId and zoneName to GUI list
arraySelection->AddArray(partName.c_str());
}
arrayRangeBlocks_ += nBlocks;
if (debug)
{
// just for debug info
getSelectedArrayEntries(arraySelection);
Info<< "<end> Foam::vtkPV3blockMesh::updateInfoBlocks" << endl;
}
}
void Foam::vtkPV3blockMesh::updateInfoEdges
(
vtkDataArraySelection* arraySelection
)
{
if (debug)
{
Info<< "<beg> Foam::vtkPV3blockMesh::updateInfoEdges"
<< " [meshPtr=" << (meshPtr_ ? "set" : "nullptr") << "]" << endl;
}
arrayRangeEdges_.reset( arraySelection->GetNumberOfArrays() );
const blockMesh& blkMesh = *meshPtr_;
const blockEdgeList& edges = blkMesh.edges();
const int nEdges = edges.size();
forAll(edges, edgeI)
{
OStringStream ostr;
ostr<< edges[edgeI].start() << ":" << edges[edgeI].end() << " - "
<< edges[edgeI].type();
// Add "beg:end - type" to GUI list
arraySelection->AddArray(ostr.str().c_str());
}
arrayRangeEdges_ += nEdges;
if (debug)
{
// just for debug info
getSelectedArrayEntries(arraySelection);
Info<< "<end> Foam::vtkPV3blockMesh::updateInfoEdges" << endl;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::vtkPV3blockMesh::vtkPV3blockMesh
(
const char* const FileName,
vtkPV3blockMeshReader* reader
)
:
reader_(reader),
dbPtr_(nullptr),
meshPtr_(nullptr),
meshRegion_(polyMesh::defaultRegion),
meshDir_(polyMesh::meshSubDir),
arrayRangeBlocks_("block"),
arrayRangeEdges_("edges"),
arrayRangeCorners_("corners")
{
if (debug)
{
Info<< "Foam::vtkPV3blockMesh::vtkPV3blockMesh - "
<< FileName << endl;
}
// avoid argList and get rootPath/caseName directly from the file
fileName fullCasePath(fileName(FileName).path());
if (!isDir(fullCasePath))
{
return;
}
if (fullCasePath == ".")
{
fullCasePath = cwd();
}
// Set the case as an environment variable - some BCs might use this
if (fullCasePath.name().find("processor", 0) == 0)
{
const fileName globalCase = fullCasePath.path();
setEnv("FOAM_CASE", globalCase, true);
setEnv("FOAM_CASENAME", globalCase.name(), true);
}
else
{
setEnv("FOAM_CASE", fullCasePath, true);
setEnv("FOAM_CASENAME", fullCasePath.name(), true);
}
// look for 'case{region}.OpenFOAM'
// could be stringent and insist the prefix match the directory name...
// Note: cannot use fileName::name() due to the embedded '{}'
string caseName(fileName(FileName).lessExt());
string::size_type beg = caseName.find_last_of("/{");
string::size_type end = caseName.find('}', beg);
if
(
beg != string::npos && caseName[beg] == '{'
&& end != string::npos && end == caseName.size()-1
)
{
meshRegion_ = caseName.substr(beg+1, end-beg-1);
// some safety
if (meshRegion_.empty())
{
meshRegion_ = polyMesh::defaultRegion;
}
if (meshRegion_ != polyMesh::defaultRegion)
{
meshDir_ = meshRegion_/polyMesh::meshSubDir;
}
}
if (debug)
{
Info<< "fullCasePath=" << fullCasePath << nl
<< "FOAM_CASE=" << getEnv("FOAM_CASE") << nl
<< "FOAM_CASENAME=" << getEnv("FOAM_CASENAME") << endl;
}
// Create time object
dbPtr_.reset
(
new Time
(
Time::controlDictName,
fileName(fullCasePath.path()),
fileName(fullCasePath.name())
)
);
dbPtr_().functionObjects().off();
updateInfo();
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::vtkPV3blockMesh::~vtkPV3blockMesh()
{
if (debug)
{
Info<< "<end> Foam::vtkPV3blockMesh::~vtkPV3blockMesh" << endl;
}
// Hmm. pointNumberTextActors are not getting removed
//
forAll(pointNumberTextActorsPtrs_, pointi)
{
pointNumberTextActorsPtrs_[pointi]->Delete();
}
pointNumberTextActorsPtrs_.clear();
delete meshPtr_;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::vtkPV3blockMesh::updateInfo()
{
if (debug)
{
Info<< "<beg> Foam::vtkPV3blockMesh::updateInfo"
<< " [meshPtr=" << (meshPtr_ ? "set" : "nullptr") << "] " << endl;
}
resetCounters();
vtkDataArraySelection* blockSelection = reader_->GetBlockSelection();
vtkDataArraySelection* edgeSelection = reader_->GetCurvedEdgesSelection();
// enable 'internalMesh' on the first call
// or preserve the enabled selections
stringList enabledParts;
stringList enabledEdges;
bool firstTime = false;
if (!blockSelection->GetNumberOfArrays() && !meshPtr_)
{
firstTime = true;
}
else
{
enabledParts = getSelectedArrayEntries(blockSelection);
enabledEdges = getSelectedArrayEntries(edgeSelection);
}
// Clear current mesh parts list
blockSelection->RemoveAllArrays();
edgeSelection->RemoveAllArrays();
// need a blockMesh
updateFoamMesh();
// Update mesh parts list
updateInfoBlocks( blockSelection );
// Update curved edges list
updateInfoEdges( edgeSelection );
// restore the enabled selections
if (!firstTime)
{
setSelectedArrayEntries(blockSelection, enabledParts);
setSelectedArrayEntries(edgeSelection, enabledEdges);
}
if (debug)
{
Info<< "<end> Foam::vtkPV3blockMesh::updateInfo" << endl;
}
}
void Foam::vtkPV3blockMesh::updateFoamMesh()
{
if (debug)
{
Info<< "<beg> Foam::vtkPV3blockMesh::updateFoamMesh" << endl;
}
// Check to see if the OpenFOAM mesh has been created
if (!meshPtr_)
{
if (debug)
{
Info<< "Creating blockMesh at time=" << dbPtr_().timeName()
<< endl;
}
// Set path for the blockMeshDict
const word dictName("blockMeshDict");
fileName dictPath(dbPtr_().system()/dictName);
// Check if dictionary is present in the constant directory
if
(
exists
(
dbPtr_().path()/dbPtr_().constant()
/polyMesh::meshSubDir/dictName
)
)
{
dictPath = dbPtr_().constant()/polyMesh::meshSubDir/dictName;
}
IOdictionary meshDict
(
IOobject
(
dictPath,
dbPtr_(),
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE,
false
)
);
meshPtr_ = new blockMesh(meshDict, meshRegion_);
}
if (debug)
{
Info<< "<end> Foam::vtkPV3blockMesh::updateFoamMesh" << endl;
}
}
void Foam::vtkPV3blockMesh::Update
(
vtkMultiBlockDataSet* output
)
{
reader_->UpdateProgress(0.1);
// Set up mesh parts selection(s)
updateBoolListStatus(blockStatus_, reader_->GetBlockSelection());
// Set up curved edges selection(s)
updateBoolListStatus(edgeStatus_, reader_->GetCurvedEdgesSelection());
reader_->UpdateProgress(0.2);
// Update the OpenFOAM mesh
updateFoamMesh();
reader_->UpdateProgress(0.5);
// Convert mesh elemente
int blockNo = 0;
convertMeshCorners(output, blockNo);
convertMeshBlocks(output, blockNo);
convertMeshEdges(output, blockNo);
reader_->UpdateProgress(0.8);
}
void Foam::vtkPV3blockMesh::CleanUp()
{
reader_->UpdateProgress(1.0);
}
void Foam::vtkPV3blockMesh::renderPointNumbers
(
vtkRenderer* renderer,
const bool show
)
{
// always remove old actors first
forAll(pointNumberTextActorsPtrs_, pointi)
{
renderer->RemoveViewProp(pointNumberTextActorsPtrs_[pointi]);
pointNumberTextActorsPtrs_[pointi]->Delete();
}
pointNumberTextActorsPtrs_.clear();
if (show && meshPtr_)
{
const pointField& cornerPts = meshPtr_->vertices();
const scalar scaleFactor = meshPtr_->scaleFactor();
pointNumberTextActorsPtrs_.setSize(cornerPts.size());
forAll(cornerPts, pointi)
{
vtkTextActor* txt = vtkTextActor::New();
txt->SetInput(Foam::name(pointi).c_str());
// Set text properties
vtkTextProperty* tprop = txt->GetTextProperty();
tprop->SetFontFamilyToArial();
tprop->BoldOn();
tprop->ShadowOff();
tprop->SetLineSpacing(1.0);
tprop->SetFontSize(14);
tprop->SetColor(1.0, 0.0, 1.0);
tprop->SetJustificationToCentered();
// Set text to use 3-D world co-ordinates
txt->GetPositionCoordinate()->SetCoordinateSystemToWorld();
txt->GetPositionCoordinate()->SetValue
(
cornerPts[pointi].x()*scaleFactor,
cornerPts[pointi].y()*scaleFactor,
cornerPts[pointi].z()*scaleFactor
);
// Add text to each renderer
renderer->AddViewProp(txt);
// Maintain a list of text labels added so that they can be
// removed later
pointNumberTextActorsPtrs_[pointi] = txt;
}
}
}
void Foam::vtkPV3blockMesh::PrintSelf(ostream& os, vtkIndent indent) const
{
#if 0
os << indent << "Number of nodes: "
<< (meshPtr_ ? meshPtr_->nPoints() : 0) << "\n";
os << indent << "Number of cells: "
<< (meshPtr_ ? meshPtr_->nCells() : 0) << "\n";
os << indent << "Number of available time steps: "
<< (dbPtr_.valid() ? dbPtr_().times().size() : 0) << endl;
#endif
}
// ************************************************************************* //

View File

@ -1,353 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
Class
Foam::vtkPV3blockMesh
Description
Provides a reader interface for OpenFOAM blockMesh to VTK interaction
SourceFiles
vtkPV3blockMesh.C
vtkPV3blockMeshConvert.C
vtkPV3blockMeshUpdate.C
vtkPV3blockMeshUtils.C
// Needed by VTK:
vtkDataArrayTemplateImplicit.txx
\*---------------------------------------------------------------------------*/
#ifndef vtkPV3blockMesh_H
#define vtkPV3blockMesh_H
// do not include legacy strstream headers
#ifndef VTK_EXCLUDE_STRSTREAM_HEADERS
# define VTK_EXCLUDE_STRSTREAM_HEADERS
#endif
#include "className.H"
#include "fileName.H"
#include "stringList.H"
#include "wordList.H"
#include "primitivePatch.H"
// * * * * * * * * * * * * * Forward Declarations * * * * * * * * * * * * * //
class vtkDataArraySelection;
class vtkDataSet;
class vtkPoints;
class vtkPV3blockMeshReader;
class vtkRenderer;
class vtkTextActor;
class vtkMultiBlockDataSet;
class vtkPolyData;
class vtkUnstructuredGrid;
class vtkIndent;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// OpenFOAM class forward declarations
class argList;
class Time;
class blockMesh;
template<class Type> class List;
/*---------------------------------------------------------------------------*\
Class vtkPV3blockMesh Declaration
\*---------------------------------------------------------------------------*/
class vtkPV3blockMesh
{
// Private classes
//- Bookkeeping for GUI checklists and the multi-block organization
class arrayRange
{
const char *name_;
int block_;
int start_;
int size_;
public:
arrayRange(const char *name, const int blockNo=0)
:
name_(name),
block_(blockNo),
start_(0),
size_(0)
{}
//- Return the block holding these datasets
int block() const
{
return block_;
}
//- Assign block number, return previous value
int block(int blockNo)
{
int prev = block_;
block_ = blockNo;
return prev;
}
//- Return block name
const char* name() const
{
return name_;
}
//- Return array start index
int start() const
{
return start_;
}
//- Return array end index
int end() const
{
return start_ + size_;
}
//- Return sublist size
int size() const
{
return size_;
}
bool empty() const
{
return !size_;
}
//- Reset the size to zero and optionally assign a new start
void reset(const int startAt = 0)
{
start_ = startAt;
size_ = 0;
}
//- Increment the size
void operator+=(const int n)
{
size_ += n;
}
};
// Private Data
//- Access to the controlling vtkPV3blockMeshReader
vtkPV3blockMeshReader* reader_;
//- OpenFOAM time control
autoPtr<Time> dbPtr_;
//- OpenFOAM mesh
blockMesh* meshPtr_;
//- The mesh region
word meshRegion_;
//- The mesh directory for the region
fileName meshDir_;
//- Selected geometrical parts
boolList blockStatus_;
//- Selected curved edges
boolList edgeStatus_;
//- First instance and size of bleckMesh blocks
// used to index into blockStatus_
arrayRange arrayRangeBlocks_;
//- First instance and size of CurvedEdges (only partially used)
arrayRange arrayRangeEdges_;
//- First instance and size of block corners (only partially used)
arrayRange arrayRangeCorners_;
//- List of point numbers for rendering to window
List<vtkTextActor*> pointNumberTextActorsPtrs_;
// Private Member Functions
// Convenience method use to convert the readers from VTK 5
// multiblock API to the current composite data infrastructure
static void AddToBlock
(
vtkMultiBlockDataSet* output,
vtkDataSet* dataset,
const arrayRange&,
const label datasetNo,
const std::string& datasetName
);
// Convenience method use to convert the readers from VTK 5
// multiblock API to the current composite data infrastructure
static vtkDataSet* GetDataSetFromBlock
(
vtkMultiBlockDataSet* output,
const arrayRange&,
const label datasetNo
);
// Convenience method use to convert the readers from VTK 5
// multiblock API to the current composite data infrastructure
static label GetNumberOfDataSets
(
vtkMultiBlockDataSet* output,
const arrayRange&
);
//- Update boolList from GUI selection
static void updateBoolListStatus
(
boolList&,
vtkDataArraySelection*
);
//- Reset data counters
void resetCounters();
// Update information helper functions
//- Internal block info
void updateInfoBlocks(vtkDataArraySelection*);
//- Block curved edges info
void updateInfoEdges(vtkDataArraySelection*);
// Update helper functions
//- OpenFOAM mesh
void updateFoamMesh();
// Mesh conversion functions
//- Mesh blocks
void convertMeshBlocks(vtkMultiBlockDataSet*, int& blockNo);
//- Mesh curved edges
void convertMeshEdges(vtkMultiBlockDataSet*, int& blockNo);
//- Mesh corners
void convertMeshCorners(vtkMultiBlockDataSet*, int& blockNo);
// GUI selection helper functions
//- Retrieve the current selections
static wordHashSet getSelected(vtkDataArraySelection*);
//- Retrieve a sub-list of the current selections
static wordHashSet getSelected
(
vtkDataArraySelection*,
const arrayRange&
);
//- Retrieve the current selections
static stringList getSelectedArrayEntries(vtkDataArraySelection*);
//- Retrieve a sub-list of the current selections
static stringList getSelectedArrayEntries
(
vtkDataArraySelection*,
const arrayRange&
);
//- Set selection(s)
static void setSelectedArrayEntries
(
vtkDataArraySelection*,
const stringList&
);
//- Disallow default bitwise copy construct
vtkPV3blockMesh(const vtkPV3blockMesh&);
//- Disallow default bitwise assignment
void operator=(const vtkPV3blockMesh&);
public:
//- Static data members
ClassName("vtkPV3blockMesh");
// Constructors
//- Construct from components
vtkPV3blockMesh
(
const char* const FileName,
vtkPV3blockMeshReader* reader
);
//- Destructor
~vtkPV3blockMesh();
// Member Functions
//- Update
void updateInfo();
void Update(vtkMultiBlockDataSet* output);
//- Clean any storage
void CleanUp();
//- Add/remove point numbers to/from the view
void renderPointNumbers(vtkRenderer*, const bool show);
// Access
//- Debug information
void PrintSelf(ostream&, vtkIndent) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,319 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "vtkPV3blockMesh.H"
#include "vtkPV3blockMeshReader.h"
// OpenFOAM includes
#include "blockMesh.H"
#include "Time.H"
#include "vtkOpenFOAMPoints.H"
// VTK includes
#include "vtkCellArray.h"
#include "vtkDataArraySelection.h"
#include "vtkMultiBlockDataSet.h"
#include "vtkPoints.h"
#include "vtkPolyData.h"
#include "vtkUnstructuredGrid.h"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::vtkPV3blockMesh::convertMeshBlocks
(
vtkMultiBlockDataSet* output,
int& blockNo
)
{
vtkDataArraySelection* selection = reader_->GetBlockSelection();
arrayRange& range = arrayRangeBlocks_;
range.block(blockNo); // set output block
label datasetNo = 0; // restart at dataset 0
const blockMesh& blkMesh = *meshPtr_;
const Foam::pointField& blockPoints = blkMesh.vertices();
if (debug)
{
Info<< "<beg> Foam::vtkPV3blockMesh::convertMeshBlocks" << endl;
}
int blockI = 0;
const scalar scaleFactor = blkMesh.scaleFactor();
for
(
int partId = range.start();
partId < range.end();
++partId, ++blockI
)
{
if (!blockStatus_[partId])
{
continue;
}
const blockDescriptor& blockDef = blkMesh[blockI];
vtkUnstructuredGrid* vtkmesh = vtkUnstructuredGrid::New();
// Convert OpenFOAM mesh vertices to VTK
vtkPoints *vtkpoints = vtkPoints::New();
vtkpoints->Allocate( blockDef.nPoints() );
const labelList& blockLabels = blockDef.blockShape();
vtkmesh->Allocate(1);
vtkIdType nodeIds[8];
forAll(blockLabels, ptI)
{
vtkInsertNextOpenFOAMPoint
(
vtkpoints,
blockPoints[blockLabels[ptI]],
scaleFactor
);
nodeIds[ptI] = ptI;
}
vtkmesh->InsertNextCell
(
VTK_HEXAHEDRON,
8,
nodeIds
);
vtkmesh->SetPoints(vtkpoints);
vtkpoints->Delete();
AddToBlock
(
output, vtkmesh, range, datasetNo,
selection->GetArrayName(partId)
);
vtkmesh->Delete();
datasetNo++;
}
// anything added?
if (datasetNo)
{
++blockNo;
}
if (debug)
{
Info<< "<end> Foam::vtkPV3blockMesh::convertMeshBlocks" << endl;
}
}
void Foam::vtkPV3blockMesh::convertMeshEdges
(
vtkMultiBlockDataSet* output,
int& blockNo
)
{
vtkDataArraySelection* selection = reader_->GetCurvedEdgesSelection();
arrayRange& range = arrayRangeEdges_;
range.block(blockNo); // set output block
label datasetNo = 0; // restart at dataset 0
const blockMesh& blkMesh = *meshPtr_;
const blockEdgeList& edges = blkMesh.edges();
int edgeI = 0;
const scalar scaleFactor = blkMesh.scaleFactor();
for
(
int partId = range.start();
partId < range.end();
++partId, ++edgeI
)
{
if (!edgeStatus_[partId])
{
continue;
}
// search each block
forAll(blkMesh, blockI)
{
const blockDescriptor& blockDef = blkMesh[blockI];
edgeList blkEdges = blockDef.blockShape().edges();
// find the corresponding edge within the block
label foundEdgeI = -1;
forAll(blkEdges, blkEdgeI)
{
if (edges[edgeI].compare(blkEdges[blkEdgeI]))
{
foundEdgeI = blkEdgeI;
break;
}
}
if (foundEdgeI != -1)
{
const List<point>& edgePoints =
blockDef.blockEdgePoints()[foundEdgeI];
vtkPolyData* vtkmesh = vtkPolyData::New();
vtkPoints* vtkpoints = vtkPoints::New();
vtkpoints->Allocate( edgePoints.size() );
vtkmesh->Allocate(1);
vtkIdType pointIds[edgePoints.size()];
forAll(edgePoints, ptI)
{
vtkInsertNextOpenFOAMPoint
(
vtkpoints,
edgePoints[ptI],
scaleFactor
);
pointIds[ptI] = ptI;
}
vtkmesh->InsertNextCell
(
VTK_POLY_LINE,
edgePoints.size(),
pointIds
);
vtkmesh->SetPoints(vtkpoints);
vtkpoints->Delete();
AddToBlock
(
output, vtkmesh, range, datasetNo,
selection->GetArrayName(partId)
);
vtkmesh->Delete();
datasetNo++;
break;
}
}
}
// anything added?
if (datasetNo)
{
++blockNo;
}
if (debug)
{
Info<< "<end> Foam::vtkPV3blockMesh::convertMeshEdges" << endl;
}
}
void Foam::vtkPV3blockMesh::convertMeshCorners
(
vtkMultiBlockDataSet* output,
int& blockNo
)
{
arrayRange& range = arrayRangeCorners_;
range.block(blockNo); // set output block
label datasetNo = 0; // restart at dataset 0
const pointField& blockPoints = meshPtr_->vertices();
const scalar& scaleFactor = meshPtr_->scaleFactor();
if (debug)
{
Info<< "<beg> Foam::vtkPV3blockMesh::convertMeshCorners" << endl;
}
if (true) // or some flag or other condition
{
vtkPolyData* vtkmesh = vtkPolyData::New();
vtkPoints* vtkpoints = vtkPoints::New();
vtkCellArray* vtkcells = vtkCellArray::New();
vtkpoints->Allocate( blockPoints.size() );
vtkcells->Allocate( blockPoints.size() );
vtkIdType pointId = 0;
forAll(blockPoints, ptI)
{
vtkInsertNextOpenFOAMPoint
(
vtkpoints,
blockPoints[ptI],
scaleFactor
);
vtkcells->InsertNextCell(1, &pointId);
pointId++;
}
vtkmesh->SetPoints(vtkpoints);
vtkpoints->Delete();
vtkmesh->SetVerts(vtkcells);
vtkcells->Delete();
AddToBlock
(
output, vtkmesh, range, datasetNo,
arrayRangeCorners_.name()
);
vtkmesh->Delete();
datasetNo++;
}
// anything added?
if (datasetNo)
{
++blockNo;
}
if (debug)
{
Info<< "<end> Foam::vtkPV3blockMesh::convertMeshCorners" << endl;
}
}
// ************************************************************************* //

View File

@ -1,357 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
Description
Misc helper methods and utilities
\*---------------------------------------------------------------------------*/
#include "vtkPV3blockMesh.H"
#include "vtkPV3blockMeshReader.h"
// VTK includes
#include "vtkDataArraySelection.h"
#include "vtkDataSet.h"
#include "vtkMultiBlockDataSet.h"
#include "vtkInformation.h"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
//! \cond fileScope
// Extract up to the first non-word characters
inline word getFirstWord(const char* str)
{
if (str)
{
label n = 0;
while (str[n] && word::valid(str[n]))
{
++n;
}
return word(str, n, true);
}
else
{
return word::null;
}
}
//! \endcond
} // End namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::vtkPV3blockMesh::AddToBlock
(
vtkMultiBlockDataSet* output,
vtkDataSet* dataset,
const arrayRange& range,
const label datasetNo,
const std::string& datasetName
)
{
const int blockNo = range.block();
vtkDataObject* blockDO = output->GetBlock(blockNo);
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO);
if (!block)
{
if (blockDO)
{
FatalErrorInFunction
<< "Block already has a vtkDataSet assigned to it"
<< endl;
return;
}
block = vtkMultiBlockDataSet::New();
output->SetBlock(blockNo, block);
block->Delete();
}
if (debug)
{
Info<< "block[" << blockNo << "] has "
<< block->GetNumberOfBlocks()
<< " datasets prior to adding set " << datasetNo
<< " with name: " << datasetName << endl;
}
block->SetBlock(datasetNo, dataset);
// name the block when assigning dataset 0
if (datasetNo == 0)
{
output->GetMetaData(blockNo)->Set
(
vtkCompositeDataSet::NAME(),
range.name()
);
}
if (datasetName.size())
{
block->GetMetaData(datasetNo)->Set
(
vtkCompositeDataSet::NAME(),
datasetName.c_str()
);
}
}
vtkDataSet* Foam::vtkPV3blockMesh::GetDataSetFromBlock
(
vtkMultiBlockDataSet* output,
const arrayRange& range,
const label datasetNo
)
{
const int blockNo = range.block();
vtkDataObject* blockDO = output->GetBlock(blockNo);
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO);
if (block)
{
return vtkDataSet::SafeDownCast(block->GetBlock(datasetNo));
}
return 0;
}
// ununsed at the moment
Foam::label Foam::vtkPV3blockMesh::GetNumberOfDataSets
(
vtkMultiBlockDataSet* output,
const arrayRange& range
)
{
const int blockNo = range.block();
vtkDataObject* blockDO = output->GetBlock(blockNo);
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO);
if (block)
{
return block->GetNumberOfBlocks();
}
return 0;
}
Foam::wordHashSet Foam::vtkPV3blockMesh::getSelected
(
vtkDataArraySelection* select
)
{
int nElem = select->GetNumberOfArrays();
wordHashSet selections(2*nElem);
for (int elemI=0; elemI < nElem; ++elemI)
{
if (select->GetArraySetting(elemI))
{
selections.insert(getFirstWord(select->GetArrayName(elemI)));
}
}
return selections;
}
Foam::wordHashSet Foam::vtkPV3blockMesh::getSelected
(
vtkDataArraySelection* select,
const arrayRange& range
)
{
int nElem = select->GetNumberOfArrays();
wordHashSet selections(2*nElem);
for (int elemI = range.start(); elemI < range.end(); ++elemI)
{
if (select->GetArraySetting(elemI))
{
selections.insert(getFirstWord(select->GetArrayName(elemI)));
}
}
return selections;
}
Foam::stringList Foam::vtkPV3blockMesh::getSelectedArrayEntries
(
vtkDataArraySelection* select
)
{
stringList selections(select->GetNumberOfArrays());
label nElem = 0;
forAll(selections, elemI)
{
if (select->GetArraySetting(elemI))
{
selections[nElem++] = select->GetArrayName(elemI);
}
}
selections.setSize(nElem);
if (debug)
{
label nElem = select->GetNumberOfArrays();
Info<< "available(";
for (int elemI = 0; elemI < nElem; ++elemI)
{
Info<< " \"" << select->GetArrayName(elemI) << "\"";
}
Info<< " )\nselected(";
forAll(selections, elemI)
{
Info<< " " << selections[elemI];
}
Info<< " )\n";
}
return selections;
}
Foam::stringList Foam::vtkPV3blockMesh::getSelectedArrayEntries
(
vtkDataArraySelection* select,
const arrayRange& range
)
{
stringList selections(range.size());
label nElem = 0;
for (int elemI = range.start(); elemI < range.end(); ++elemI)
{
if (select->GetArraySetting(elemI))
{
selections[nElem++] = select->GetArrayName(elemI);
}
}
selections.setSize(nElem);
if (debug)
{
Info<< "available(";
for (int elemI = range.start(); elemI < range.end(); ++elemI)
{
Info<< " \"" << select->GetArrayName(elemI) << "\"";
}
Info<< " )\nselected(";
forAll(selections, elemI)
{
Info<< " " << selections[elemI];
}
Info<< " )\n";
}
return selections;
}
void Foam::vtkPV3blockMesh::setSelectedArrayEntries
(
vtkDataArraySelection* select,
const stringList& selections
)
{
const int nElem = select->GetNumberOfArrays();
select->DisableAllArrays();
// Loop through entries, setting values from selectedEntries
for (int elemI=0; elemI < nElem; ++elemI)
{
string arrayName(select->GetArrayName(elemI));
forAll(selections, elemI)
{
if (selections[elemI] == arrayName)
{
select->EnableArray(arrayName.c_str());
break;
}
}
}
}
void Foam::vtkPV3blockMesh::updateBoolListStatus
(
boolList& status,
vtkDataArraySelection* selection
)
{
if (debug)
{
Info<< "<beg> Foam::vtkPV3blockMesh::updateBoolListStatus" << endl;
}
const label nElem = selection->GetNumberOfArrays();
if (status.size() != nElem)
{
status.setSize(nElem);
status = false;
}
forAll(status, elemI)
{
const int setting = selection->GetArraySetting(elemI);
status[elemI] = setting;
if (debug)
{
Info<< " part[" << elemI << "] = "
<< status[elemI]
<< " : " << selection->GetArrayName(elemI) << endl;
}
}
if (debug)
{
Info<< "<end> Foam::vtkPV3blockMesh::updateBoolListStatus" << endl;
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// ************************************************************************* //

View File

@ -1,3 +0,0 @@
vtkPV3Readers.C
LIB = $(FOAM_LIBBIN)/libvtkPV3Readers

View File

@ -1,5 +0,0 @@
EXE_INC = \
-I$(ParaView_INCLUDE_DIR)
LIB_LIBS = \
$(GLIBS)

View File

@ -1,333 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
Description
Misc helper methods and utilities
\*---------------------------------------------------------------------------*/
#include "vtkPV3Readers.H"
// OpenFOAM includes
#include "IFstream.H"
// VTK includes
#include "vtkDataArraySelection.h"
#include "vtkDataSet.h"
#include "vtkMultiBlockDataSet.h"
#include "vtkInformation.h"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(vtkPV3Readers, 0);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
//! \cond fileScope
// Extract up to the first non-word characters
inline word getFirstWord(const char* str)
{
if (str)
{
label n = 0;
while (str[n] && word::valid(str[n]))
{
++n;
}
return word(str, n, true);
}
else
{
return word::null;
}
}
//! \endcond
} // End namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::vtkPV3Readers::AddToBlock
(
vtkMultiBlockDataSet* output,
vtkDataSet* dataset,
const partInfo& selector,
const label datasetNo,
const std::string& datasetName
)
{
const int blockNo = selector.block();
vtkDataObject* blockDO = output->GetBlock(blockNo);
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO);
if (!block)
{
if (blockDO)
{
FatalErrorInFunction
<< "Block already has a vtkDataSet assigned to it"
<< endl;
return;
}
block = vtkMultiBlockDataSet::New();
output->SetBlock(blockNo, block);
block->Delete();
}
if (debug)
{
Info<< "block[" << blockNo << "] has "
<< block->GetNumberOfBlocks()
<< " datasets prior to adding set " << datasetNo
<< " with name: " << datasetName << endl;
}
block->SetBlock(datasetNo, dataset);
// name the block when assigning dataset 0
if (datasetNo == 0)
{
output->GetMetaData(blockNo)->Set
(
vtkCompositeDataSet::NAME(),
selector.name()
);
}
if (datasetName.size())
{
block->GetMetaData(datasetNo)->Set
(
vtkCompositeDataSet::NAME(),
datasetName.c_str()
);
}
}
vtkDataSet* Foam::vtkPV3Readers::GetDataSetFromBlock
(
vtkMultiBlockDataSet* output,
const partInfo& selector,
const label datasetNo
)
{
const int blockNo = selector.block();
vtkDataObject* blockDO = output->GetBlock(blockNo);
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO);
if (block)
{
return vtkDataSet::SafeDownCast(block->GetBlock(datasetNo));
}
return 0;
}
// ununsed at the moment
Foam::label Foam::vtkPV3Readers::GetNumberOfDataSets
(
vtkMultiBlockDataSet* output,
const partInfo& selector
)
{
const int blockNo = selector.block();
vtkDataObject* blockDO = output->GetBlock(blockNo);
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO);
if (block)
{
return block->GetNumberOfBlocks();
}
return 0;
}
// Foam::word Foam::vtkPV3Readers::getPartName(int partId)
// {
// return getFirstWord(reader_->GetPartArrayName(partId));
// }
Foam::wordHashSet Foam::vtkPV3Readers::getSelected
(
vtkDataArraySelection* select
)
{
int nElem = select->GetNumberOfArrays();
wordHashSet selections(2*nElem);
for (int elemI=0; elemI < nElem; ++elemI)
{
if (select->GetArraySetting(elemI))
{
selections.insert(getFirstWord(select->GetArrayName(elemI)));
}
}
return selections;
}
Foam::wordHashSet Foam::vtkPV3Readers::getSelected
(
vtkDataArraySelection* select,
const partInfo& selector
)
{
int nElem = select->GetNumberOfArrays();
wordHashSet selections(2*nElem);
for (int elemI = selector.start(); elemI < selector.end(); ++elemI)
{
if (select->GetArraySetting(elemI))
{
selections.insert(getFirstWord(select->GetArrayName(elemI)));
}
}
return selections;
}
Foam::stringList Foam::vtkPV3Readers::getSelectedArrayEntries
(
vtkDataArraySelection* select
)
{
stringList selections(select->GetNumberOfArrays());
label nElem = 0;
forAll(selections, elemI)
{
if (select->GetArraySetting(elemI))
{
selections[nElem++] = select->GetArrayName(elemI);
}
}
selections.setSize(nElem);
if (debug)
{
label nElem = select->GetNumberOfArrays();
Info<< "available(";
for (int elemI = 0; elemI < nElem; ++elemI)
{
Info<< " \"" << select->GetArrayName(elemI) << "\"";
}
Info<< " )\nselected(";
forAll(selections, elemI)
{
Info<< " " << selections[elemI];
}
Info<< " )\n";
}
return selections;
}
Foam::stringList Foam::vtkPV3Readers::getSelectedArrayEntries
(
vtkDataArraySelection* select,
const partInfo& selector
)
{
stringList selections(selector.size());
label nElem = 0;
for (int elemI = selector.start(); elemI < selector.end(); ++elemI)
{
if (select->GetArraySetting(elemI))
{
selections[nElem++] = select->GetArrayName(elemI);
}
}
selections.setSize(nElem);
if (debug)
{
Info<< "available(";
for (int elemI = selector.start(); elemI < selector.end(); ++elemI)
{
Info<< " \"" << select->GetArrayName(elemI) << "\"";
}
Info<< " )\nselected(";
forAll(selections, elemI)
{
Info<< " " << selections[elemI];
}
Info<< " )\n";
}
return selections;
}
void Foam::vtkPV3Readers::setSelectedArrayEntries
(
vtkDataArraySelection* select,
const stringList& selections
)
{
const int nElem = select->GetNumberOfArrays();
select->DisableAllArrays();
// Loop through entries, setting values from selectedEntries
for (int elemI=0; elemI < nElem; ++elemI)
{
string arrayName(select->GetArrayName(elemI));
forAll(selections, elemI)
{
if (selections[elemI] == arrayName)
{
select->EnableArray(arrayName.c_str());
break;
}
}
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// ************************************************************************* //

View File

@ -1,228 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
Namespace
Foam::vtkPV3Readers
Description
A collection of helper functions when building a reader interface in
ParaView3.
SourceFiles
vtkPV3Readers.C
\*---------------------------------------------------------------------------*/
#ifndef vtkPV3Readers_H
#define vtkPV3Readers_H
// do not include legacy strstream headers
#ifndef VTK_EXCLUDE_STRSTREAM_HEADERS
# define VTK_EXCLUDE_STRSTREAM_HEADERS
#endif
#include "className.H"
#include "fileName.H"
#include "stringList.H"
#include "wordList.H"
#include "HashSet.H"
// * * * * * * * * * * * * * Forward Declarations * * * * * * * * * * * * * //
class vtkDataArraySelection;
class vtkDataSet;
class vtkPoints;
class vtkPV3FoamReader;
class vtkRenderer;
class vtkTextActor;
class vtkMultiBlockDataSet;
class vtkPolyData;
class vtkUnstructuredGrid;
class vtkIndent;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace vtkPV3Readers
{
//- Declare name of the class and its debug switch
NamespaceName("vtkPV3Readers");
//- Bookkeeping for GUI checklists and the multi-block organization
class partInfo
{
const char *name_;
int block_;
int start_;
int size_;
public:
partInfo(const char *name, const int blockNo=0)
:
name_(name),
block_(blockNo),
start_(-1),
size_(0)
{}
//- Return the block holding these datasets
int block() const
{
return block_;
}
//- Assign block number, return previous value
int block(int blockNo)
{
int prev = block_;
block_ = blockNo;
return prev;
}
const char* name() const
{
return name_;
}
int start() const
{
return start_;
}
int end() const
{
return start_ + size_;
}
int size() const
{
return size_;
}
bool empty() const
{
return !size_;
}
void reset()
{
start_ = -1;
size_ = 0;
}
//- Assign new start and reset the size
void operator=(const int i)
{
start_ = i;
size_ = 0;
}
//- Increment the size
void operator+=(const int n)
{
size_ += n;
}
};
//- Convenience method use to convert the readers from VTK 5
// multiblock API to the current composite data infrastructure
void AddToBlock
(
vtkMultiBlockDataSet* output,
vtkDataSet* dataset,
const partInfo& selector,
const label datasetNo,
const std::string& datasetName
);
//- Convenience method use to convert the readers from VTK 5
// multiblock API to the current composite data infrastructure
vtkDataSet* GetDataSetFromBlock
(
vtkMultiBlockDataSet* output,
const partInfo& selector,
const label datasetNo
);
//- Convenience method use to convert the readers from VTK 5
// multiblock API to the current composite data infrastructure
// ununsed at the moment
label GetNumberOfDataSets
(
vtkMultiBlockDataSet* output,
const partInfo& selector
);
//- Retrieve the current selections as a wordHashSet
wordHashSet getSelected
(
vtkDataArraySelection* select
);
//- Retrieve a sub-list of the current selections
wordHashSet getSelected
(
vtkDataArraySelection*,
const partInfo&
);
//- Retrieve the current selections
stringList getSelectedArrayEntries(vtkDataArraySelection*);
//- Retrieve a sub-list of the current selections
stringList getSelectedArrayEntries
(
vtkDataArraySelection* select,
const partInfo& selector
);
//- Set selection(s)
void setSelectedArrayEntries
(
vtkDataArraySelection*,
const stringList&
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace vtkPV3
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -39,7 +39,7 @@
#
set foamFile=`$WM_PROJECT_DIR/bin/foamEtcFile -mode o config.csh/paraview`
if ( $status == 0 ) source $foamFile ParaView_VERSION=3.12.0
if ( $status == 0 ) source $foamFile ParaView_VERSION=5.0.1
unset foamFile

View File

@ -39,7 +39,7 @@
#
foamFile=$($WM_PROJECT_DIR/bin/foamEtcFile -mode o config.sh/paraview 2>/dev/null)
[ $? -eq 0 ] && . $foamFile ParaView_VERSION=3.12.0
[ $? -eq 0 ] && . $foamFile ParaView_VERSION=5.0.1
unset foamFile