mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Renamed PV4Readers -> PVReaders to avoid confusion when compiling the reader for ParaView-5
This commit is contained in:
@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
cd ${0%/*} || exit 1 # Run from this directory
|
||||
set -x
|
||||
|
||||
# deal with client/server vs combined plugins
|
||||
rm -f $FOAM_LIBBIN/libPVFoamReader* 2>/dev/null
|
||||
|
||||
rm -rf PVFoamReader/Make
|
||||
wclean libso vtkPVFoam
|
||||
|
||||
# ----------------------------------------------------------------- end-of-file
|
||||
@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
cd ${0%/*} || exit 1 # Run from this directory
|
||||
set -x
|
||||
|
||||
if [ -d "$ParaView_DIR" -a -r "$ParaView_DIR" ]
|
||||
then
|
||||
wmake libso vtkPVFoam
|
||||
(
|
||||
cd PVFoamReader
|
||||
mkdir -p Make/$WM_OPTIONS > /dev/null 2>&1
|
||||
cd Make/$WM_OPTIONS
|
||||
cmake ../..
|
||||
make
|
||||
)
|
||||
fi
|
||||
|
||||
# ----------------------------------------------------------------- end-of-file
|
||||
@ -0,0 +1,83 @@
|
||||
# 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.8)
|
||||
|
||||
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}/../vtkPVFoam
|
||||
)
|
||||
|
||||
ADD_DEFINITIONS(
|
||||
-std=c++0x
|
||||
-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 pqPVFoamReaderPanel.h)
|
||||
|
||||
ADD_PARAVIEW_OBJECT_PANEL(IFACES IFACE_SRCS
|
||||
CLASS_NAME pqPVFoamReaderPanel
|
||||
XML_NAME PVFoamReader # name of SourceProxy in *SM.xml
|
||||
XML_GROUP sources
|
||||
)
|
||||
|
||||
IF("${PARAVIEW_VERSION_MINOR}" EQUAL 0)
|
||||
ADD_PARAVIEW_PLUGIN(
|
||||
PVFoamReader_SM "1.0"
|
||||
SERVER_MANAGER_XML PVFoamReader_SM.xml
|
||||
SERVER_MANAGER_SOURCES vtkPVFoamReader.cxx
|
||||
GUI_INTERFACES ${IFACES}
|
||||
GUI_SOURCES pqPVFoamReaderPanel.cxx
|
||||
${MOC_SRCS} ${UI_SRCS} ${IFACE_SRCS}
|
||||
GUI_RESOURCE_FILES PVFoamReader.xml
|
||||
)
|
||||
ELSE("${PARAVIEW_VERSION_MINOR}" EQUAL 0)
|
||||
ADD_PARAVIEW_PLUGIN(
|
||||
PVFoamReader_SM "1.0"
|
||||
SERVER_MANAGER_XML PVFoamReader_SM.xml
|
||||
SERVER_MANAGER_SOURCES vtkPVFoamReader.cxx
|
||||
GUI_INTERFACES ${IFACES}
|
||||
GUI_SOURCES pqPVFoamReaderPanel.cxx
|
||||
${MOC_SRCS} ${UI_SRCS} ${IFACE_SRCS}
|
||||
)
|
||||
ENDIF("${PARAVIEW_VERSION_MINOR}" EQUAL 0)
|
||||
|
||||
TARGET_LINK_LIBRARIES(
|
||||
PVFoamReader_SM
|
||||
LINK_PUBLIC
|
||||
OpenFOAM
|
||||
finiteVolume
|
||||
vtkPVFoam
|
||||
)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
@ -0,0 +1,5 @@
|
||||
<RCC>
|
||||
<qresource prefix="/ParaViewResources" >
|
||||
<file>PVFoamReader.xml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
@ -0,0 +1,6 @@
|
||||
<ParaViewReaders>
|
||||
<Reader name="PVFoamReader"
|
||||
extensions="OpenFOAM"
|
||||
file_description="OpenFOAM Reader">
|
||||
</Reader>
|
||||
</ParaViewReaders>
|
||||
@ -0,0 +1,309 @@
|
||||
<ServerManagerConfiguration>
|
||||
<ProxyGroup name="sources">
|
||||
<SourceProxy
|
||||
name="PVFoamReader"
|
||||
class="vtkPVFoamReader">
|
||||
|
||||
<!-- 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"
|
||||
is_internal="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"/>
|
||||
<ReaderFactory extensions="OpenFOAM"
|
||||
file_description="OpenFOAM"/>
|
||||
</Hints>
|
||||
|
||||
|
||||
</SourceProxy>
|
||||
</ProxyGroup>
|
||||
</ServerManagerConfiguration>
|
||||
@ -0,0 +1,485 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "pqPVFoamReaderPanel.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 * * * * * * * * * * * * * * //
|
||||
|
||||
pqPVFoamReaderPanel::pqPVFoamReaderPanel
|
||||
(
|
||||
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);
|
||||
|
||||
// update GUI button
|
||||
if ((prop = this->proxy()->GetProperty("UpdateGUI")) != 0)
|
||||
{
|
||||
prop->SetImmediateUpdate(1);
|
||||
QPushButton* updateGUI = new QPushButton("Update GUI");
|
||||
updateGUI->setToolTip("Update GUI");
|
||||
|
||||
form->addWidget(updateGUI, 8, 0, Qt::AlignLeft);
|
||||
QObject::connect
|
||||
(
|
||||
updateGUI,
|
||||
SIGNAL(clicked()),
|
||||
this,
|
||||
SLOT(setModified())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
void pqPVFoamReaderPanel::CacheMeshToggled()
|
||||
{
|
||||
vtkSMIntVectorProperty::SafeDownCast
|
||||
(
|
||||
this->proxy()->GetProperty("UiCacheMesh")
|
||||
)->SetElement(0, CacheMesh_->isChecked());
|
||||
}
|
||||
|
||||
|
||||
void pqPVFoamReaderPanel::RefreshPressed()
|
||||
{
|
||||
// update everything
|
||||
vtkSMIntVectorProperty::SafeDownCast
|
||||
(
|
||||
this->proxy()->GetProperty("UiRefresh")
|
||||
)->Modified();
|
||||
|
||||
vtkSMSourceProxy::SafeDownCast(this->proxy())->UpdatePipeline();
|
||||
|
||||
// render all views
|
||||
pqApplicationCore::instance()->render();
|
||||
}
|
||||
|
||||
|
||||
void pqPVFoamReaderPanel::ZeroTimeToggled()
|
||||
{
|
||||
vtkSMIntVectorProperty::SafeDownCast
|
||||
(
|
||||
this->proxy()->GetProperty("UiZeroTime")
|
||||
)->SetElement(0, ZeroTime_->isChecked());
|
||||
|
||||
this->setModified();
|
||||
}
|
||||
|
||||
|
||||
void pqPVFoamReaderPanel::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 pqPVFoamReaderPanel::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 pqPVFoamReaderPanel::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 pqPVFoamReaderPanel::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 pqPVFoamReaderPanel::ExtrapolatePatchesToggled()
|
||||
{
|
||||
vtkSMProperty* prop;
|
||||
|
||||
vtkSMIntVectorProperty::SafeDownCast
|
||||
(
|
||||
this->proxy()->GetProperty("UiExtrapolatePatches")
|
||||
)->SetElement(0, ExtrapolatePatches_->isChecked());
|
||||
|
||||
this->setModified();
|
||||
}
|
||||
|
||||
|
||||
void pqPVFoamReaderPanel::InterpolateVolFieldsToggled()
|
||||
{
|
||||
vtkSMProperty* prop;
|
||||
|
||||
vtkSMIntVectorProperty::SafeDownCast
|
||||
(
|
||||
this->proxy()->GetProperty("UiInterpolateVolFields")
|
||||
)->SetElement(0, InterpolateVolFields_->isChecked());
|
||||
|
||||
this->setModified();
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,120 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
pqPVFoamReaderPanel
|
||||
|
||||
Description
|
||||
GUI modifications for the ParaView reader panel
|
||||
|
||||
A custom panel for the PVFoamReader.
|
||||
|
||||
SourceFiles
|
||||
pqPVFoamReaderPanel.cxx
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
#ifndef pqPVFoamReaderPanel_h
|
||||
#define pqPVFoamReaderPanel_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 pqPVFoamReaderPanel Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class pqPVFoamReaderPanel
|
||||
:
|
||||
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
|
||||
pqPVFoamReaderPanel(pqProxy*, QWidget*);
|
||||
|
||||
|
||||
//- Destructor
|
||||
// virtual ~pqPVFoamReaderPanel();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,752 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "vtkPVFoamReader.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 "vtkPVFoam.H"
|
||||
|
||||
#undef EXPERIMENTAL_TIME_CACHING
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
vtkStandardNewMacro(vtkPVFoamReader);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
vtkPVFoamReader::vtkPVFoamReader()
|
||||
{
|
||||
Debug = 0;
|
||||
vtkDebugMacro(<<"Constructor");
|
||||
|
||||
SetNumberOfInputPorts(0);
|
||||
|
||||
FileName = NULL;
|
||||
foamData_ = NULL;
|
||||
|
||||
output0_ = NULL;
|
||||
|
||||
#ifdef VTKPVFOAM_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
|
||||
(
|
||||
&vtkPVFoamReader::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 * * * * * * * * * * * * * * * //
|
||||
|
||||
vtkPVFoamReader::~vtkPVFoamReader()
|
||||
{
|
||||
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 vtkPVFoamReader::RequestInformation
|
||||
(
|
||||
vtkInformation* vtkNotUsed(request),
|
||||
vtkInformationVector** vtkNotUsed(inputVector),
|
||||
vtkInformationVector* outputVector
|
||||
)
|
||||
{
|
||||
vtkDebugMacro(<<"RequestInformation");
|
||||
|
||||
if (Foam::vtkPVFoam::debug)
|
||||
{
|
||||
cout<<"REQUEST_INFORMATION\n";
|
||||
}
|
||||
|
||||
if (!FileName)
|
||||
{
|
||||
vtkErrorMacro("FileName has to be specified!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nInfo = outputVector->GetNumberOfInformationObjects();
|
||||
|
||||
if (Foam::vtkPVFoam::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::vtkPVFoam(FileName, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
foamData_->updateInfo();
|
||||
}
|
||||
|
||||
int nTimeSteps = 0;
|
||||
double* timeSteps = foamData_->findTimes(nTimeSteps);
|
||||
|
||||
if (!nTimeSteps)
|
||||
{
|
||||
vtkErrorMacro("could not find valid OpenFOAM mesh");
|
||||
|
||||
// delete foamData and flag it as fatal error
|
||||
delete foamData_;
|
||||
foamData_ = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// set identical time steps for all ports
|
||||
for (int infoI = 0; infoI < nInfo; ++infoI)
|
||||
{
|
||||
outputVector->GetInformationObject(infoI)->Set
|
||||
(
|
||||
vtkStreamingDemandDrivenPipeline::TIME_STEPS(),
|
||||
timeSteps,
|
||||
nTimeSteps
|
||||
);
|
||||
}
|
||||
|
||||
if (nTimeSteps)
|
||||
{
|
||||
double timeRange[2];
|
||||
timeRange[0] = timeSteps[0];
|
||||
timeRange[1] = timeSteps[nTimeSteps-1];
|
||||
|
||||
if (Foam::vtkPVFoam::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 vtkPVFoamReader::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::vtkPVFoam::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 vtkPVFoam::setTime() method
|
||||
for (int infoI = 0; infoI < nInfo; ++infoI)
|
||||
{
|
||||
vtkInformation *outInfo = outputVector->GetInformationObject(infoI);
|
||||
|
||||
if
|
||||
(
|
||||
outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP())
|
||||
&& outInfo->Length(vtkStreamingDemandDrivenPipeline::TIME_STEPS()) > 0
|
||||
)
|
||||
{
|
||||
requestTime[nRequestTime++] =
|
||||
outInfo->Get
|
||||
(
|
||||
vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (nRequestTime)
|
||||
{
|
||||
foamData_->setTime(nRequestTime, requestTime);
|
||||
}
|
||||
|
||||
vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::SafeDownCast
|
||||
(
|
||||
outputVector->GetInformationObject(0)->Get
|
||||
(
|
||||
vtkMultiBlockDataSet::DATA_OBJECT()
|
||||
)
|
||||
);
|
||||
|
||||
if (Foam::vtkPVFoam::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::vtkPVFoam::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 VTKPVFOAM_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 vtkPVFoamReader::SetRefresh(int val)
|
||||
{
|
||||
Modified();
|
||||
}
|
||||
|
||||
|
||||
void vtkPVFoamReader::SetIncludeSets(int val)
|
||||
{
|
||||
if (IncludeSets != val)
|
||||
{
|
||||
IncludeSets = val;
|
||||
if (foamData_)
|
||||
{
|
||||
foamData_->updateInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void vtkPVFoamReader::SetIncludeZones(int val)
|
||||
{
|
||||
if (IncludeZones != val)
|
||||
{
|
||||
IncludeZones = val;
|
||||
if (foamData_)
|
||||
{
|
||||
foamData_->updateInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void vtkPVFoamReader::SetShowPatchNames(int val)
|
||||
{
|
||||
if (ShowPatchNames != val)
|
||||
{
|
||||
ShowPatchNames = val;
|
||||
updatePatchNamesView(ShowPatchNames);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void vtkPVFoamReader::SetShowGroupsOnly(int val)
|
||||
{
|
||||
if (ShowGroupsOnly != val)
|
||||
{
|
||||
ShowGroupsOnly = val;
|
||||
if (foamData_)
|
||||
{
|
||||
foamData_->updateInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void vtkPVFoamReader::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 vtkPVFoamReader::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 vtkPVFoamReader::GetTimeStep()
|
||||
{
|
||||
return foamData_ ? foamData_->timeIndex() : -1;
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Parts selection list control
|
||||
|
||||
vtkDataArraySelection* vtkPVFoamReader::GetPartSelection()
|
||||
{
|
||||
vtkDebugMacro(<<"GetPartSelection");
|
||||
return PartSelection;
|
||||
}
|
||||
|
||||
|
||||
int vtkPVFoamReader::GetNumberOfPartArrays()
|
||||
{
|
||||
vtkDebugMacro(<<"GetNumberOfPartArrays");
|
||||
return PartSelection->GetNumberOfArrays();
|
||||
}
|
||||
|
||||
|
||||
const char* vtkPVFoamReader::GetPartArrayName(int index)
|
||||
{
|
||||
vtkDebugMacro(<<"GetPartArrayName");
|
||||
return PartSelection->GetArrayName(index);
|
||||
}
|
||||
|
||||
|
||||
int vtkPVFoamReader::GetPartArrayStatus(const char* name)
|
||||
{
|
||||
vtkDebugMacro(<<"GetPartArrayStatus");
|
||||
return PartSelection->ArrayIsEnabled(name);
|
||||
}
|
||||
|
||||
|
||||
void vtkPVFoamReader::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* vtkPVFoamReader::GetVolFieldSelection()
|
||||
{
|
||||
vtkDebugMacro(<<"GetVolFieldSelection");
|
||||
return VolFieldSelection;
|
||||
}
|
||||
|
||||
|
||||
int vtkPVFoamReader::GetNumberOfVolFieldArrays()
|
||||
{
|
||||
vtkDebugMacro(<<"GetNumberOfVolFieldArrays");
|
||||
return VolFieldSelection->GetNumberOfArrays();
|
||||
}
|
||||
|
||||
|
||||
const char* vtkPVFoamReader::GetVolFieldArrayName(int index)
|
||||
{
|
||||
vtkDebugMacro(<<"GetVolFieldArrayName");
|
||||
return VolFieldSelection->GetArrayName(index);
|
||||
}
|
||||
|
||||
|
||||
int vtkPVFoamReader::GetVolFieldArrayStatus(const char* name)
|
||||
{
|
||||
vtkDebugMacro(<<"GetVolFieldArrayStatus");
|
||||
return VolFieldSelection->ArrayIsEnabled(name);
|
||||
}
|
||||
|
||||
|
||||
void vtkPVFoamReader::SetVolFieldArrayStatus(const char* name, int status)
|
||||
{
|
||||
vtkDebugMacro(<<"SetVolFieldArrayStatus");
|
||||
if (status)
|
||||
{
|
||||
VolFieldSelection->EnableArray(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
VolFieldSelection->DisableArray(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// pointField selection list control
|
||||
|
||||
vtkDataArraySelection* vtkPVFoamReader::GetPointFieldSelection()
|
||||
{
|
||||
vtkDebugMacro(<<"GetPointFieldSelection");
|
||||
return PointFieldSelection;
|
||||
}
|
||||
|
||||
|
||||
int vtkPVFoamReader::GetNumberOfPointFieldArrays()
|
||||
{
|
||||
vtkDebugMacro(<<"GetNumberOfPointFieldArrays");
|
||||
return PointFieldSelection->GetNumberOfArrays();
|
||||
}
|
||||
|
||||
|
||||
const char* vtkPVFoamReader::GetPointFieldArrayName(int index)
|
||||
{
|
||||
vtkDebugMacro(<<"GetPointFieldArrayName");
|
||||
return PointFieldSelection->GetArrayName(index);
|
||||
}
|
||||
|
||||
|
||||
int vtkPVFoamReader::GetPointFieldArrayStatus(const char* name)
|
||||
{
|
||||
vtkDebugMacro(<<"GetPointFieldArrayStatus");
|
||||
return PointFieldSelection->ArrayIsEnabled(name);
|
||||
}
|
||||
|
||||
|
||||
void vtkPVFoamReader::SetPointFieldArrayStatus(const char* name, int status)
|
||||
{
|
||||
vtkDebugMacro(<<"SetPointFieldArrayStatus");
|
||||
if (status)
|
||||
{
|
||||
PointFieldSelection->EnableArray(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
PointFieldSelection->DisableArray(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// lagrangianField selection list control
|
||||
|
||||
vtkDataArraySelection* vtkPVFoamReader::GetLagrangianFieldSelection()
|
||||
{
|
||||
vtkDebugMacro(<<"GetLagrangianFieldSelection");
|
||||
return LagrangianFieldSelection;
|
||||
}
|
||||
|
||||
|
||||
int vtkPVFoamReader::GetNumberOfLagrangianFieldArrays()
|
||||
{
|
||||
vtkDebugMacro(<<"GetNumberOfLagrangianFieldArrays");
|
||||
return LagrangianFieldSelection->GetNumberOfArrays();
|
||||
}
|
||||
|
||||
|
||||
const char* vtkPVFoamReader::GetLagrangianFieldArrayName(int index)
|
||||
{
|
||||
vtkDebugMacro(<<"GetLagrangianFieldArrayName");
|
||||
return LagrangianFieldSelection->GetArrayName(index);
|
||||
}
|
||||
|
||||
|
||||
int vtkPVFoamReader::GetLagrangianFieldArrayStatus(const char* name)
|
||||
{
|
||||
vtkDebugMacro(<<"GetLagrangianFieldArrayStatus");
|
||||
return LagrangianFieldSelection->ArrayIsEnabled(name);
|
||||
}
|
||||
|
||||
|
||||
void vtkPVFoamReader::SetLagrangianFieldArrayStatus
|
||||
(
|
||||
const char* name,
|
||||
int status
|
||||
)
|
||||
{
|
||||
vtkDebugMacro(<<"SetLagrangianFieldArrayStatus");
|
||||
if (status)
|
||||
{
|
||||
LagrangianFieldSelection->EnableArray(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
LagrangianFieldSelection->DisableArray(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void vtkPVFoamReader::SelectionModifiedCallback
|
||||
(
|
||||
vtkObject*,
|
||||
unsigned long,
|
||||
void* clientdata,
|
||||
void*
|
||||
)
|
||||
{
|
||||
static_cast<vtkPVFoamReader*>(clientdata)->SelectionModified();
|
||||
}
|
||||
|
||||
|
||||
void vtkPVFoamReader::SelectionModified()
|
||||
{
|
||||
vtkDebugMacro(<<"SelectionModified");
|
||||
Modified();
|
||||
}
|
||||
|
||||
|
||||
int vtkPVFoamReader::FillOutputPortInformation
|
||||
(
|
||||
int port,
|
||||
vtkInformation* info
|
||||
)
|
||||
{
|
||||
if (port == 0)
|
||||
{
|
||||
return this->Superclass::FillOutputPortInformation(port, info);
|
||||
}
|
||||
info->Set(vtkDataObject::DATA_TYPE_NAME(), "vtkMultiBlockDataSet");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,262 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
vtkPVFoamReader
|
||||
|
||||
Description
|
||||
reads a dataset in OpenFOAM format
|
||||
|
||||
vtkPVblockMeshReader creates an multiblock dataset.
|
||||
It uses the OpenFOAM infrastructure (fvMesh, etc) to handle mesh and
|
||||
field data.
|
||||
|
||||
SourceFiles
|
||||
vtkPVblockMeshReader.cxx
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
#ifndef vtkPVFoamReader_h
|
||||
#define vtkPVFoamReader_h
|
||||
|
||||
// VTK includes
|
||||
#include "vtkMultiBlockDataSetAlgorithm.h"
|
||||
|
||||
// * * * * * * * * * * * * * Forward Declarations * * * * * * * * * * * * * //
|
||||
|
||||
// VTK forward declarations
|
||||
class vtkDataArraySelection;
|
||||
class vtkCallbackCommand;
|
||||
|
||||
// OpenFOAM forward declarations
|
||||
namespace Foam
|
||||
{
|
||||
class vtkPVFoam;
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class vtkPVFoamReader Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class vtkPVFoamReader
|
||||
:
|
||||
public vtkMultiBlockDataSetAlgorithm
|
||||
{
|
||||
public:
|
||||
vtkTypeMacro(vtkPVFoamReader, vtkMultiBlockDataSetAlgorithm);
|
||||
void PrintSelf(ostream&, vtkIndent);
|
||||
|
||||
static vtkPVFoamReader* 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
|
||||
vtkPVFoamReader();
|
||||
|
||||
//- Destructor
|
||||
~vtkPVFoamReader();
|
||||
|
||||
//- 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
|
||||
vtkPVFoamReader(const vtkPVFoamReader&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const vtkPVFoamReader&);
|
||||
|
||||
//- 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::vtkPVFoam* foamData_;
|
||||
//ETX
|
||||
};
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,11 @@
|
||||
vtkPVFoam.C
|
||||
vtkPVFoamFields.C
|
||||
vtkPVFoamMesh.C
|
||||
vtkPVFoamMeshLagrangian.C
|
||||
vtkPVFoamMeshSet.C
|
||||
vtkPVFoamMeshVolume.C
|
||||
vtkPVFoamMeshZone.C
|
||||
vtkPVFoamUpdateInfo.C
|
||||
vtkPVFoamUtils.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libvtkPVFoam
|
||||
@ -0,0 +1,22 @@
|
||||
/* Note: enable vtkPolyhedron when available */
|
||||
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
|
||||
-I../../vtkPVReaders/lnInclude \
|
||||
-I../PVFoamReader \
|
||||
-I$(ParaView_INCLUDE_DIR) \
|
||||
-I$(ParaView_INCLUDE_DIR)/vtkkwiml \
|
||||
$(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) -lvtkPVReaders \
|
||||
$(GLIBS)
|
||||
@ -0,0 +1,79 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
vtkPVFoam
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,71 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
vtkPVFoam
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkOpenFOAMTupleRemap_H
|
||||
#define vtkOpenFOAMTupleRemap_H
|
||||
|
||||
// OpenFOAM includes
|
||||
#include "StaticAssert.H"
|
||||
#include "Swap.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
inline void vtkOpenFOAMTupleRemap(float vec[]);
|
||||
|
||||
|
||||
// a symmTensor specialization to remap OpenFOAM -> ParaView naming order
|
||||
// Qt/Core/pqScalarBarRepresentation.cxx defines this order
|
||||
// { "XX", "YY", "ZZ", "XY", "YZ", "XZ" }
|
||||
// in pqScalarBarRepresentation::getDefaultComponentLabel()
|
||||
// whereas OpenFOAM uses this order
|
||||
// { XX, XY, XZ, YY, YZ, ZZ }
|
||||
//
|
||||
// for extra safety, assert that symmTensor indeed has 6 components
|
||||
StaticAssert(Foam::symmTensor::nComponents == 6);
|
||||
|
||||
|
||||
// Template specialization for symmTensor
|
||||
template<>
|
||||
inline void vtkOpenFOAMTupleRemap<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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,837 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "vtkPVFoam.H"
|
||||
#include "vtkPVFoamReader.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(vtkPVFoam, 0);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
#include "vtkPVFoamAddToSelection.H"
|
||||
#include "vtkPVFoamUpdateInfoFields.H"
|
||||
|
||||
void Foam::vtkPVFoam::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::vtkPVFoam::reduceMemory()
|
||||
{
|
||||
forAll(regionPolyDecomp_, i)
|
||||
{
|
||||
regionPolyDecomp_[i].clear();
|
||||
}
|
||||
|
||||
forAll(zonePolyDecomp_, i)
|
||||
{
|
||||
zonePolyDecomp_[i].clear();
|
||||
}
|
||||
|
||||
forAll(csetPolyDecomp_, i)
|
||||
{
|
||||
csetPolyDecomp_[i].clear();
|
||||
}
|
||||
|
||||
if (!reader_->GetCacheMesh())
|
||||
{
|
||||
delete meshPtr_;
|
||||
meshPtr_ = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int Foam::vtkPVFoam::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::vtkPVFoam::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::vtkPVFoam::setTime() - selectedTime="
|
||||
<< Times[nearestIndex].name() << " index=" << timeIndex_
|
||||
<< "/" << Times.size()
|
||||
<< " meshChanged=" << Switch(meshChanged_)
|
||||
<< " fieldsChanged=" << Switch(fieldsChanged_) << endl;
|
||||
}
|
||||
|
||||
return nearestIndex;
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPVFoam::updateMeshPartsStatus()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::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::vtkPVFoam::updateMeshPartsStatus" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::vtkPVFoam::vtkPVFoam
|
||||
(
|
||||
const char* const FileName,
|
||||
vtkPVFoamReader* reader
|
||||
)
|
||||
:
|
||||
reader_(reader),
|
||||
dbPtr_(NULL),
|
||||
meshPtr_(NULL),
|
||||
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::vtkPVFoam::vtkPVFoam - " << 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::vtkPVFoam::~vtkPVFoam()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::~vtkPVFoam" << endl;
|
||||
}
|
||||
|
||||
delete meshPtr_;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::vtkPVFoam::updateInfo()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::updateInfo"
|
||||
<< " [meshPtr=" << (meshPtr_ ? "set" : "NULL") << "] 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::vtkPVFoam::updateInfo" << endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPVFoam::updateFoamMesh()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::updateFoamMesh" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
if (!reader_->GetCacheMesh())
|
||||
{
|
||||
delete meshPtr_;
|
||||
meshPtr_ = NULL;
|
||||
}
|
||||
|
||||
// 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::vtkPVFoam::updateFoamMesh" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPVFoam::Update
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
vtkMultiBlockDataSet* lagrangianOutput
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
cout<< "<beg> Foam::vtkPVFoam::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 VTKPVFOAM_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::vtkPVFoam::CleanUp()
|
||||
{
|
||||
// reclaim some memory
|
||||
reduceMemory();
|
||||
reader_->UpdateProgress(1.0);
|
||||
}
|
||||
|
||||
|
||||
double* Foam::vtkPVFoam::findTimes(int& nTimeSteps)
|
||||
{
|
||||
int nTimes = 0;
|
||||
double* tsteps = NULL;
|
||||
|
||||
if (dbPtr_.valid())
|
||||
{
|
||||
Time& runTime = dbPtr_();
|
||||
instantList timeLst = runTime.times();
|
||||
|
||||
// find the first time for which this mesh appears to exist
|
||||
label timeI = 0;
|
||||
for (; timeI < timeLst.size(); ++timeI)
|
||||
{
|
||||
const word& timeName = timeLst[timeI].name();
|
||||
|
||||
if
|
||||
(
|
||||
isFile(runTime.path()/timeName/meshDir_/"points")
|
||||
&& IOobject("points", timeName, meshDir_, runTime).headerOk()
|
||||
)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
nTimes = timeLst.size() - timeI;
|
||||
|
||||
// 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::vtkPVFoam::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(vector::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::vtkPVFoam::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";
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,741 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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::vtkPVFoam
|
||||
|
||||
Description
|
||||
Provides a reader interface for OpenFOAM to VTK interaction.
|
||||
|
||||
SourceFiles
|
||||
vtkPVFoam.C
|
||||
vtkPVFoam.H
|
||||
vtkPVFoamFields.C
|
||||
vtkPVFoamMesh.C
|
||||
vtkPVFoamMeshLagrangian.C
|
||||
vtkPVFoamTemplates.C
|
||||
vtkPVFoamMeshSet.C
|
||||
vtkPVFoamMeshVolume.C
|
||||
vtkPVFoamMeshZone.C
|
||||
vtkPVFoamFaceField.H
|
||||
vtkPVFoamLagrangianFields.H
|
||||
vtkPVFoamPatchField.H
|
||||
vtkPVFoamPointFields.H
|
||||
vtkPVFoamPoints.H
|
||||
vtkPVFoamUpdateInfo.C
|
||||
vtkPVFoamUpdateInfoFields.H
|
||||
vtkPVFoamUtils.C
|
||||
vtkPVFoamVolFields.H
|
||||
vtkPVFoamAddToSelection.H
|
||||
|
||||
// Needed by VTK:
|
||||
vtkDataArrayTemplateImplicit.txx
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkPVFoam_H
|
||||
#define vtkPVFoam_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 VTKPVFOAM_DUALPORT
|
||||
|
||||
// * * * * * * * * * * * * * Forward Declarations * * * * * * * * * * * * * //
|
||||
|
||||
class vtkDataArraySelection;
|
||||
class vtkDataSet;
|
||||
class vtkPoints;
|
||||
class vtkPVFoamReader;
|
||||
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 vtkPVFoam Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class vtkPVFoam
|
||||
{
|
||||
// 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 vtkPVFoamReader
|
||||
vtkPVFoamReader* 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
|
||||
vtkPVFoam(const vtkPVFoam&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const vtkPVFoam&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Static data members
|
||||
|
||||
ClassName("vtkPVFoam");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
vtkPVFoam
|
||||
(
|
||||
const char* const FileName,
|
||||
vtkPVFoamReader* reader
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
~vtkPVFoam();
|
||||
|
||||
|
||||
// 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 "vtkPVFoamTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,74 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkPVFoamAddToSelection_H
|
||||
#define vtkPVFoamAddToSelection_H
|
||||
|
||||
// OpenFOAM includes
|
||||
#include "IOobjectList.H"
|
||||
#include "SortableList.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkDataArraySelection.h"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::label Foam::vtkPVFoam::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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,117 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
vtkPVFoam
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkPVFoamFaceField_H
|
||||
#define vtkPVFoamFaceField_H
|
||||
|
||||
// VTK includes
|
||||
#include "vtkCellData.h"
|
||||
#include "vtkFloatArray.h"
|
||||
#include "vtkMultiBlockDataSet.h"
|
||||
#include "vtkPolyData.h"
|
||||
|
||||
#include "vtkOpenFOAMTupleRemap.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtkPVFoam::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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,325 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "vtkPVFoam.H"
|
||||
|
||||
// OpenFOAM includes
|
||||
#include "IOobjectList.H"
|
||||
#include "vtkPVFoamReader.h"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkDataArraySelection.h"
|
||||
#include "vtkPolyData.h"
|
||||
#include "vtkUnstructuredGrid.h"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
#include "vtkPVFoamVolFields.H"
|
||||
#include "vtkPVFoamPointFields.H"
|
||||
#include "vtkPVFoamLagrangianFields.H"
|
||||
|
||||
|
||||
void Foam::vtkPVFoam::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::vtkPVFoam::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::vtkPVFoam::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::vtkPVFoam::convertVolFields" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPVFoam::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::vtkPVFoam::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::vtkPVFoam::convertPointFields" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPVFoam::convertLagrangianFields
|
||||
(
|
||||
vtkMultiBlockDataSet* output
|
||||
)
|
||||
{
|
||||
arrayRange& range = arrayRangeLagrangian_;
|
||||
const fvMesh& mesh = *meshPtr_;
|
||||
|
||||
wordHashSet selectedFields = getSelected
|
||||
(
|
||||
reader_->GetLagrangianFieldSelection()
|
||||
);
|
||||
|
||||
if (selectedFields.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::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::vtkPVFoam::convertLagrangianFields" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,113 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
vtkPVFoam
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkPVFoamLagrangianFields_H
|
||||
#define vtkPVFoamLagrangianFields_H
|
||||
|
||||
#include "Cloud.H"
|
||||
|
||||
#include "vtkOpenFOAMTupleRemap.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtkPVFoam::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::vtkPVFoam::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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,649 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "vtkPVFoam.H"
|
||||
|
||||
// OpenFOAM includes
|
||||
#include "cellSet.H"
|
||||
#include "faceSet.H"
|
||||
#include "pointSet.H"
|
||||
#include "fvMeshSubset.H"
|
||||
#include "vtkPVFoamReader.h"
|
||||
#include "uindirectPrimitivePatch.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkDataArraySelection.h"
|
||||
#include "vtkMultiBlockDataSet.h"
|
||||
#include "vtkPolyData.h"
|
||||
#include "vtkUnstructuredGrid.h"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::vtkPVFoam::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::vtkPVFoam::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::vtkPVFoam::convertMeshVolume" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPVFoam::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::vtkPVFoam::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::vtkPVFoam::convertMeshLagrangian" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPVFoam::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::vtkPVFoam::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 = NULL;
|
||||
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::vtkPVFoam::convertMeshPatches" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPVFoam::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::vtkPVFoam::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::vtkPVFoam::convertMeshCellZones" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPVFoam::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::vtkPVFoam::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::vtkPVFoam::convertMeshCellSets" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPVFoam::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::vtkPVFoam::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::vtkPVFoam::convertMeshFaceZones" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPVFoam::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::vtkPVFoam::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::vtkPVFoam::convertMeshFaceSets" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPVFoam::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::vtkPVFoam::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::vtkPVFoam::convertMeshPointZones" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Foam::vtkPVFoam::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::vtkPVFoam::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::vtkPVFoam::convertMeshPointSets" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,109 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "vtkPVFoam.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::vtkPVFoam::lagrangianVTKMesh
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const word& cloudName
|
||||
)
|
||||
{
|
||||
vtkPolyData* vtkmesh = NULL;
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::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::vtkPVFoam::lagrangianVTKMesh" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
return vtkmesh;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,148 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "vtkPVFoam.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::vtkPVFoam::faceSetVTKMesh
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const faceSet& fSet
|
||||
)
|
||||
{
|
||||
vtkPolyData* vtkmesh = vtkPolyData::New();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::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::vtkPVFoam::faceSetVTKMesh" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
return vtkmesh;
|
||||
}
|
||||
|
||||
|
||||
vtkPolyData* Foam::vtkPVFoam::pointSetVTKMesh
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const pointSet& pSet
|
||||
)
|
||||
{
|
||||
vtkPolyData* vtkmesh = vtkPolyData::New();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::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::vtkPVFoam::pointSetVTKMesh" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
return vtkmesh;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,480 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "vtkPVFoam.H"
|
||||
#include "vtkPVFoamReader.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::vtkPVFoam::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::vtkPVFoam::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)
|
||||
{
|
||||
// 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::vtkPVFoam::volumeVTKMesh" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
return vtkmesh;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,75 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "vtkPVFoam.H"
|
||||
|
||||
// OpenFOAM includes
|
||||
#include "vtkOpenFOAMPoints.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkPoints.h"
|
||||
#include "vtkPolyData.h"
|
||||
#include "vtkCellArray.h"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
vtkPolyData* Foam::vtkPVFoam::pointZoneVTKMesh
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const labelList& pointLabels
|
||||
)
|
||||
{
|
||||
vtkPolyData* vtkmesh = vtkPolyData::New();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::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::vtkPVFoam::pointZoneVTKMesh" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
return vtkmesh;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,129 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
vtkPVFoam
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkPVFoamPatchField_H
|
||||
#define vtkPVFoamPatchField_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::vtkPVFoam::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::vtkPVFoam::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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,331 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
vtkPVFoam
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkPVFoamPointFields_H
|
||||
#define vtkPVFoamPointFields_H
|
||||
|
||||
// OpenFOAM includes
|
||||
#include "interpolatePointToCell.H"
|
||||
|
||||
#include "vtkOpenFOAMTupleRemap.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtkPVFoam::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::vtkPVFoam::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.internalField(),
|
||||
mesh.faceZones()[zoneId]().meshPoints()
|
||||
);
|
||||
|
||||
convertPatchPointField
|
||||
(
|
||||
fieldName,
|
||||
fld,
|
||||
output,
|
||||
arrayRangeFaceZones_,
|
||||
datasetNo
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtkPVFoam::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::vtkPVFoam::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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,99 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "vtkPVFoam.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::vtkPVFoam::patchVTKMesh
|
||||
(
|
||||
const word& name,
|
||||
const PatchType& p
|
||||
)
|
||||
{
|
||||
vtkPolyData* vtkmesh = vtkPolyData::New();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::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::vtkPVFoam::patchVTKMesh - " << name << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
return vtkmesh;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,724 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "vtkPVFoam.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 "vtkPVFoamReader.h"
|
||||
|
||||
// local headers
|
||||
#include "vtkPVFoamAddToSelection.H"
|
||||
#include "vtkPVFoamUpdateInfoFields.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::vtkPVFoam::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::vtkPVFoam::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.headerOk())
|
||||
{
|
||||
zonesEntries zones(ioObj);
|
||||
|
||||
names.setSize(zones.size());
|
||||
forAll(zones, zoneI)
|
||||
{
|
||||
names[zoneI] = zones[zoneI].keyword();
|
||||
}
|
||||
}
|
||||
|
||||
return names;
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPVFoam::updateInfoInternalMesh
|
||||
(
|
||||
vtkDataArraySelection* arraySelection
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::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::vtkPVFoam::updateInfoInternalMesh" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPVFoam::updateInfoLagrangian
|
||||
(
|
||||
vtkDataArraySelection* arraySelection
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::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::vtkPVFoam::updateInfoLagrangian" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPVFoam::updateInfoPatches
|
||||
(
|
||||
vtkDataArraySelection* arraySelection,
|
||||
stringList& enabledEntries
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::updateInfoPatches"
|
||||
<< " [meshPtr=" << (meshPtr_ ? "set" : "NULL") << "]" << 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.headerOk())
|
||||
{
|
||||
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::vtkPVFoam::updateInfoPatches" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPVFoam::updateInfoZones
|
||||
(
|
||||
vtkDataArraySelection* arraySelection
|
||||
)
|
||||
{
|
||||
if (!reader_->GetIncludeZones())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::updateInfoZones"
|
||||
<< " [meshPtr=" << (meshPtr_ ? "set" : "NULL") << "]" << 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::vtkPVFoam::updateInfoZones" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPVFoam::updateInfoSets
|
||||
(
|
||||
vtkDataArraySelection* arraySelection
|
||||
)
|
||||
{
|
||||
if (!reader_->GetIncludeSets())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::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::vtkPVFoam::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::vtkPVFoam::updateInfoSets" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPVFoam::updateInfoLagrangianFields()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::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::vtkPVFoam::updateInfoLagrangianFields - "
|
||||
<< "lagrangian objects.size() = " << objects.size() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,115 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
vtkPVFoam
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkPVFoamUpdateInfoFields_H
|
||||
#define vtkPVFoamUpdateInfoFields_H
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<template<class> class patchType, class meshType>
|
||||
void Foam::vtkPVFoam::updateInfoFields
|
||||
(
|
||||
vtkDataArraySelection* select
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::updateInfoFields <"
|
||||
<< meshType::Mesh::typeName
|
||||
<< "> [meshPtr=" << (meshPtr_ ? "set" : "NULL") << "]"
|
||||
<< 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::vtkPVFoam::updateInfoFields" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,340 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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/>.
|
||||
|
||||
Description
|
||||
Misc helper methods and utilities
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "vtkPVFoam.H"
|
||||
#include "vtkPVFoamReader.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::vtkPVFoam::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::vtkPVFoam::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::vtkPVFoam::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::vtkPVFoam::getPartName(const int partId)
|
||||
{
|
||||
return getFirstWord(reader_->GetPartArrayName(partId));
|
||||
}
|
||||
|
||||
|
||||
Foam::wordHashSet Foam::vtkPVFoam::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::vtkPVFoam::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::vtkPVFoam::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::vtkPVFoam::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::vtkPVFoam::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::vtkPVFoam::printMemory()
|
||||
{
|
||||
memInfo mem;
|
||||
|
||||
if (mem.valid())
|
||||
{
|
||||
Info<< "mem peak/size/rss: " << mem << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,380 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
vtkPVFoam
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkPVFoamVolFields_H
|
||||
#define vtkPVFoamVolFields_H
|
||||
|
||||
// OpenFOAM includes
|
||||
#include "emptyFvPatchField.H"
|
||||
#include "wallPolyPatch.H"
|
||||
#include "faceSet.H"
|
||||
#include "volPointInterpolation.H"
|
||||
|
||||
#include "vtkPVFoamFaceField.H"
|
||||
#include "vtkPVFoamPatchField.H"
|
||||
|
||||
#include "vtkOpenFOAMTupleRemap.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtkPVFoam::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::vtkPVFoam::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::vtkPVFoam::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
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user