ENH: refactor paraview readers code to avoid duplication

- as originally intended years ago, but never actually done.

- use 'foamPvCore' instead of 'vtkPVReaders' to avoid potential name
  collisions with any 'vtk*' files and since we may reuse these
  functions in other foam-paraview modules (not just readers).

STYLE: use same font size/colour for patch-names as for point-numbers

BUG: repair issue with single time-step

- paraview time-selector returns '0' as the requested time if there is
  only one time step. However, if we have skipped the 0/ directory,
  this single time step is likely a non-zero value.
This commit is contained in:
Mark Olesen
2017-01-12 06:40:58 +01:00
parent 7a90f5e6fb
commit ecb80a2ee8
44 changed files with 1933 additions and 3468 deletions

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory cd ${0%/*} || exit 1 # Run from this directory
wclean libso vtkPVReaders wclean libso foamPv
PVblockMeshReader/Allwclean PVblockMeshReader/Allwclean
PVFoamReader/Allwclean PVFoamReader/Allwclean

View File

@ -97,7 +97,7 @@ case "$major" in
if canBuildPlugin if canBuildPlugin
then then
( (
wmakeLibPv vtkPVReaders wmakeLibPv foamPv
PVblockMeshReader/Allwmake $targetType $* PVblockMeshReader/Allwmake $targetType $*
PVFoamReader/Allwmake $targetType $* PVFoamReader/Allwmake $targetType $*

View File

@ -15,6 +15,7 @@ include_directories(
$ENV{WM_PROJECT_DIR}/src/OSspecific/$ENV{WM_OSTYPE}/lnInclude $ENV{WM_PROJECT_DIR}/src/OSspecific/$ENV{WM_OSTYPE}/lnInclude
$ENV{WM_PROJECT_DIR}/src/finiteVolume/lnInclude $ENV{WM_PROJECT_DIR}/src/finiteVolume/lnInclude
${PROJECT_SOURCE_DIR}/../vtkPVFoam ${PROJECT_SOURCE_DIR}/../vtkPVFoam
${PROJECT_SOURCE_DIR}/../../foamPv/lnInclude
) )
add_definitions( add_definitions(
@ -63,6 +64,7 @@ target_link_libraries(
PVFoamReader_SM PVFoamReader_SM
LINK_PUBLIC LINK_PUBLIC
vtkPVFoam-pv${PARAVIEW_VERSION_MAJOR}.${PARAVIEW_VERSION_MINOR} vtkPVFoam-pv${PARAVIEW_VERSION_MAJOR}.${PARAVIEW_VERSION_MINOR}
foamPv-pv${PARAVIEW_VERSION_MAJOR}.${PARAVIEW_VERSION_MINOR}
finiteVolume finiteVolume
OpenFOAM OpenFOAM
) )

View File

@ -273,6 +273,17 @@
<Documentation>The list of point fields.</Documentation> <Documentation>The list of point fields.</Documentation>
</StringVectorProperty> </StringVectorProperty>
<!-- Print button -->
<Property animateable="0"
name="PrintInfo"
command="PrintInfo"
panel_widget="command_button"
panel_visibility="advanced">
<Documentation>
Print basic information to stdout
</Documentation>
</Property>
<Hints> <Hints>
<ReaderFactory <ReaderFactory
extensions="OpenFOAM" extensions="OpenFOAM"

View File

@ -33,6 +33,7 @@ License
#include "vtkDataArraySelection.h" #include "vtkDataArraySelection.h"
#include "vtkInformation.h" #include "vtkInformation.h"
#include "vtkInformationVector.h" #include "vtkInformationVector.h"
#include "vtkInformationDoubleVectorKey.h"
#include "vtkMultiBlockDataSet.h" #include "vtkMultiBlockDataSet.h"
#include "vtkObjectFactory.h" #include "vtkObjectFactory.h"
#include "vtkSMRenderViewProxy.h" #include "vtkSMRenderViewProxy.h"
@ -42,6 +43,9 @@ License
// OpenFOAM includes // OpenFOAM includes
#include "vtkPVFoam.H" #include "vtkPVFoam.H"
// STL includes
#include <vector>
#undef EXPERIMENTAL_TIME_CACHING #undef EXPERIMENTAL_TIME_CACHING
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -58,10 +62,9 @@ vtkPVFoamReader::vtkPVFoamReader()
SetNumberOfInputPorts(0); SetNumberOfInputPorts(0);
FileName = nullptr; FileName = nullptr;
foamData_ = nullptr; backend_ = nullptr;
output0_ = nullptr;
output0_ = nullptr;
#ifdef VTKPVFOAM_DUALPORT #ifdef VTKPVFOAM_DUALPORT
// Add second output for the Lagrangian // Add second output for the Lagrangian
@ -133,11 +136,11 @@ vtkPVFoamReader::~vtkPVFoamReader()
{ {
vtkDebugMacro(<<"Deconstructor"); vtkDebugMacro(<<"Deconstructor");
if (foamData_) if (backend_)
{ {
// remove patch names // remove patch names
updatePatchNamesView(false); updatePatchNamesView(false);
delete foamData_; delete backend_;
} }
if (FileName) if (FileName)
@ -188,7 +191,7 @@ int vtkPVFoamReader::RequestInformation
return 0; return 0;
} }
int nInfo = outputVector->GetNumberOfInformationObjects(); const int nInfo = outputVector->GetNumberOfInformationObjects();
if (Foam::vtkPVFoam::debug) if (Foam::vtkPVFoam::debug)
{ {
@ -199,60 +202,70 @@ int vtkPVFoamReader::RequestInformation
} }
} }
if (!foamData_) if (!backend_)
{ {
foamData_ = new Foam::vtkPVFoam(FileName, this); backend_ = new Foam::vtkPVFoam(FileName, this);
} }
else else
{ {
foamData_->updateInfo(); backend_->updateInfo();
} }
int nTimeSteps = 0; std::vector<double> times = backend_->findTimes(this->SkipZeroTime);
double* timeSteps = foamData_->findTimes(nTimeSteps);
if (!nTimeSteps) if (times.empty())
{ {
vtkErrorMacro("could not find valid OpenFOAM mesh"); vtkErrorMacro("could not find valid OpenFOAM mesh");
// delete foamData and flag it as fatal error // delete foamData and flag it as fatal error
delete foamData_; delete backend_;
foamData_ = nullptr; backend_ = nullptr;
return 0; return 0;
} }
// set identical time steps for all ports // set identical time steps for all ports
for (int infoI = 0; infoI < nInfo; ++infoI) for (int infoI = 0; infoI < nInfo; ++infoI)
{ {
outputVector->GetInformationObject(infoI)->Set vtkInformation *outInfo = outputVector->GetInformationObject(infoI);
outInfo->Set
( (
vtkStreamingDemandDrivenPipeline::TIME_STEPS(), vtkStreamingDemandDrivenPipeline::TIME_STEPS(),
timeSteps, times.data(),
nTimeSteps static_cast<int>(times.size())
); );
// Something like this may be useful:
// outInfo->Set
// (
// vtkStreamingDemandDrivenPipeline::TIME_DEPENDENT_INFORMATION(),
// 1
// );
} }
if (nTimeSteps) if (times.size())
{ {
double timeRange[2]; double timeRange[2]{ times.front(), times.back() };
timeRange[0] = timeSteps[0];
timeRange[1] = timeSteps[nTimeSteps-1];
if (Foam::vtkPVFoam::debug > 1) if (Foam::vtkPVFoam::debug > 1)
{ {
cout<<"nTimeSteps " << nTimeSteps << "\n" cout
<<"timeRange " << timeRange[0] << " to " << timeRange[1] <<"nInfo " << nInfo << "\n"
<< "\n"; <<"time-range " << times.front() << ':' << times.back() << "\n"
<<"times " << times.size() << "(";
for (int timeI = 0; timeI < nTimeSteps; ++timeI) for (const double& val : times)
{ {
cout<< "step[" << timeI << "] = " << timeSteps[timeI] << "\n"; cout<< ' ' << val;
} }
cout << " )" << std::endl;
} }
for (int infoI = 0; infoI < nInfo; ++infoI) for (int infoI = 0; infoI < nInfo; ++infoI)
{ {
outputVector->GetInformationObject(infoI)->Set vtkInformation *outInfo = outputVector->GetInformationObject(infoI);
outInfo->Set
( (
vtkStreamingDemandDrivenPipeline::TIME_RANGE(), vtkStreamingDemandDrivenPipeline::TIME_RANGE(),
timeRange, timeRange,
@ -261,8 +274,6 @@ int vtkPVFoamReader::RequestInformation
} }
} }
delete timeSteps;
return 1; return 1;
} }
@ -282,15 +293,14 @@ int vtkPVFoamReader::RequestData
vtkErrorMacro("FileName has to be specified!"); vtkErrorMacro("FileName has to be specified!");
return 0; return 0;
} }
if (!backend_)
// catch previous error
if (!foamData_)
{ {
// catch some previous error
vtkErrorMacro("Reader failed - perhaps no mesh?"); vtkErrorMacro("Reader failed - perhaps no mesh?");
return 0; return 0;
} }
int nInfo = outputVector->GetNumberOfInformationObjects(); const int nInfo = outputVector->GetNumberOfInformationObjects();
if (Foam::vtkPVFoam::debug) if (Foam::vtkPVFoam::debug)
{ {
@ -315,23 +325,31 @@ int vtkPVFoamReader::RequestData
{ {
vtkInformation *outInfo = outputVector->GetInformationObject(infoI); vtkInformation *outInfo = outputVector->GetInformationObject(infoI);
int nsteps = outInfo->Length(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
if if
( (
outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()) outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP())
&& outInfo->Length(vtkStreamingDemandDrivenPipeline::TIME_STEPS()) > 0 && nsteps > 0
) )
{ {
requestTime[nRequestTime++] = requestTime[nRequestTime] =
outInfo->Get (
( 1 == nsteps
vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP() // Only one time-step available, UPDATE_TIME_STEP is unreliable
); ? outInfo->Get(vtkStreamingDemandDrivenPipeline::TIME_STEPS(), 0)
: outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP())
);
// outInfo->Set(vtkDataObject::DATA_TIME_STEP(), requestTime[nRequestTime]);
// this->SetTimeValue(requestedTimeValue);
++nRequestTime;
} }
} }
if (nRequestTime) if (nRequestTime)
{ {
foamData_->setTime(nRequestTime, requestTime); backend_->setTime(nRequestTime, requestTime);
} }
vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::SafeDownCast vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::SafeDownCast
@ -362,7 +380,7 @@ int vtkPVFoamReader::RequestData
// but trashes the fields and still triggers the GeometryFilter // but trashes the fields and still triggers the GeometryFilter
if (needsUpdate) if (needsUpdate)
{ {
foamData_->Update(output); backend_->Update(output);
output0_->ShallowCopy(output); output0_->ShallowCopy(output);
} }
else else
@ -391,7 +409,7 @@ int vtkPVFoamReader::RequestData
#else #else
#ifdef VTKPVFOAM_DUALPORT #ifdef VTKPVFOAM_DUALPORT
foamData_->Update backend_->Update
( (
output, output,
vtkMultiBlockDataSet::SafeDownCast vtkMultiBlockDataSet::SafeDownCast
@ -403,7 +421,7 @@ int vtkPVFoamReader::RequestData
); );
); );
#else #else
foamData_->Update(output, output); backend_->Update(output, output);
#endif #endif
updatePatchNamesView(ShowPatchNames); updatePatchNamesView(ShowPatchNames);
@ -411,12 +429,27 @@ int vtkPVFoamReader::RequestData
#endif #endif
// Do any cleanup on the OpenFOAM side // Do any cleanup on the OpenFOAM side
foamData_->CleanUp(); backend_->CleanUp();
return 1; return 1;
} }
void vtkPVFoamReader::PrintInfo()
{
if (backend_)
{
backend_->printInfo();
}
else
{
cout
<<"OpenFOAM reader not initialized\n"
<< std::flush;
}
}
void vtkPVFoamReader::SetRefresh(bool val) void vtkPVFoamReader::SetRefresh(bool val)
{ {
Modified(); Modified();
@ -428,9 +461,9 @@ void vtkPVFoamReader::SetIncludeSets(bool val)
if (IncludeSets != val) if (IncludeSets != val)
{ {
IncludeSets = val; IncludeSets = val;
if (foamData_) if (backend_)
{ {
foamData_->updateInfo(); backend_->updateInfo();
} }
} }
} }
@ -441,9 +474,9 @@ void vtkPVFoamReader::SetIncludeZones(bool val)
if (IncludeZones != val) if (IncludeZones != val)
{ {
IncludeZones = val; IncludeZones = val;
if (foamData_) if (backend_)
{ {
foamData_->updateInfo(); backend_->updateInfo();
} }
} }
} }
@ -464,9 +497,9 @@ void vtkPVFoamReader::SetShowGroupsOnly(bool val)
if (ShowGroupsOnly != val) if (ShowGroupsOnly != val)
{ {
ShowGroupsOnly = val; ShowGroupsOnly = val;
if (foamData_) if (backend_)
{ {
foamData_->updateInfo(); backend_->updateInfo();
} }
} }
} }
@ -485,7 +518,7 @@ void vtkPVFoamReader::updatePatchNamesView(const bool show)
// Server manager model for querying items in the server manager // Server manager model for querying items in the server manager
pqServerManagerModel* smModel = appCore->getServerManagerModel(); pqServerManagerModel* smModel = appCore->getServerManagerModel();
if (!smModel || !foamData_) if (!smModel || !backend_)
{ {
return; return;
} }
@ -495,7 +528,7 @@ void vtkPVFoamReader::updatePatchNamesView(const bool show)
for (int viewI=0; viewI < renderViews.size(); ++viewI) for (int viewI=0; viewI < renderViews.size(); ++viewI)
{ {
foamData_->renderPatchNames backend_->renderPatchNames
( (
renderViews[viewI]->getRenderViewProxy()->GetRenderer(), renderViews[viewI]->getRenderViewProxy()->GetRenderer(),
show show
@ -514,7 +547,7 @@ void vtkPVFoamReader::PrintSelf(ostream& os, vtkIndent indent)
os << indent << "File name: " os << indent << "File name: "
<< (this->FileName ? this->FileName : "(none)") << "\n"; << (this->FileName ? this->FileName : "(none)") << "\n";
foamData_->PrintSelf(os, indent); backend_->PrintSelf(os, indent);
os << indent << "Time step range: " os << indent << "Time step range: "
<< this->TimeStepRange[0] << " - " << this->TimeStepRange[1] << "\n" << this->TimeStepRange[0] << " - " << this->TimeStepRange[1] << "\n"
@ -524,7 +557,7 @@ void vtkPVFoamReader::PrintSelf(ostream& os, vtkIndent indent)
int vtkPVFoamReader::GetTimeStep() int vtkPVFoamReader::GetTimeStep()
{ {
return foamData_ ? foamData_->timeIndex() : -1; return backend_ ? backend_->timeIndex() : -1;
} }
@ -533,32 +566,24 @@ int vtkPVFoamReader::GetTimeStep()
vtkDataArraySelection* vtkPVFoamReader::GetPartSelection() vtkDataArraySelection* vtkPVFoamReader::GetPartSelection()
{ {
vtkDebugMacro(<<"GetPartSelection");
return PartSelection; return PartSelection;
} }
int vtkPVFoamReader::GetNumberOfPartArrays() int vtkPVFoamReader::GetNumberOfPartArrays()
{ {
vtkDebugMacro(<<"GetNumberOfPartArrays");
return PartSelection->GetNumberOfArrays(); return PartSelection->GetNumberOfArrays();
} }
const char* vtkPVFoamReader::GetPartArrayName(int index) const char* vtkPVFoamReader::GetPartArrayName(int index)
{ {
vtkDebugMacro(<<"GetPartArrayName");
return PartSelection->GetArrayName(index); return PartSelection->GetArrayName(index);
} }
int vtkPVFoamReader::GetPartArrayStatus(const char* name) int vtkPVFoamReader::GetPartArrayStatus(const char* name)
{ {
vtkDebugMacro(<<"GetPartArrayStatus");
return PartSelection->ArrayIsEnabled(name); return PartSelection->ArrayIsEnabled(name);
} }
void vtkPVFoamReader::SetPartArrayStatus(const char* name, int status) void vtkPVFoamReader::SetPartArrayStatus(const char* name, int status)
{ {
vtkDebugMacro("Set mesh part \"" << name << "\" status to: " << status); vtkDebugMacro("Set mesh part \"" << name << "\" status to: " << status);
@ -579,35 +604,26 @@ void vtkPVFoamReader::SetPartArrayStatus(const char* name, int status)
vtkDataArraySelection* vtkPVFoamReader::GetVolFieldSelection() vtkDataArraySelection* vtkPVFoamReader::GetVolFieldSelection()
{ {
vtkDebugMacro(<<"GetVolFieldSelection");
return VolFieldSelection; return VolFieldSelection;
} }
int vtkPVFoamReader::GetNumberOfVolFieldArrays() int vtkPVFoamReader::GetNumberOfVolFieldArrays()
{ {
vtkDebugMacro(<<"GetNumberOfVolFieldArrays");
return VolFieldSelection->GetNumberOfArrays(); return VolFieldSelection->GetNumberOfArrays();
} }
const char* vtkPVFoamReader::GetVolFieldArrayName(int index) const char* vtkPVFoamReader::GetVolFieldArrayName(int index)
{ {
vtkDebugMacro(<<"GetVolFieldArrayName");
return VolFieldSelection->GetArrayName(index); return VolFieldSelection->GetArrayName(index);
} }
int vtkPVFoamReader::GetVolFieldArrayStatus(const char* name) int vtkPVFoamReader::GetVolFieldArrayStatus(const char* name)
{ {
vtkDebugMacro(<<"GetVolFieldArrayStatus");
return VolFieldSelection->ArrayIsEnabled(name); return VolFieldSelection->ArrayIsEnabled(name);
} }
void vtkPVFoamReader::SetVolFieldArrayStatus(const char* name, int status) void vtkPVFoamReader::SetVolFieldArrayStatus(const char* name, int status)
{ {
vtkDebugMacro(<<"SetVolFieldArrayStatus");
if (status) if (status)
{ {
VolFieldSelection->EnableArray(name); VolFieldSelection->EnableArray(name);
@ -624,35 +640,26 @@ void vtkPVFoamReader::SetVolFieldArrayStatus(const char* name, int status)
vtkDataArraySelection* vtkPVFoamReader::GetPointFieldSelection() vtkDataArraySelection* vtkPVFoamReader::GetPointFieldSelection()
{ {
vtkDebugMacro(<<"GetPointFieldSelection");
return PointFieldSelection; return PointFieldSelection;
} }
int vtkPVFoamReader::GetNumberOfPointFieldArrays() int vtkPVFoamReader::GetNumberOfPointFieldArrays()
{ {
vtkDebugMacro(<<"GetNumberOfPointFieldArrays");
return PointFieldSelection->GetNumberOfArrays(); return PointFieldSelection->GetNumberOfArrays();
} }
const char* vtkPVFoamReader::GetPointFieldArrayName(int index) const char* vtkPVFoamReader::GetPointFieldArrayName(int index)
{ {
vtkDebugMacro(<<"GetPointFieldArrayName");
return PointFieldSelection->GetArrayName(index); return PointFieldSelection->GetArrayName(index);
} }
int vtkPVFoamReader::GetPointFieldArrayStatus(const char* name) int vtkPVFoamReader::GetPointFieldArrayStatus(const char* name)
{ {
vtkDebugMacro(<<"GetPointFieldArrayStatus");
return PointFieldSelection->ArrayIsEnabled(name); return PointFieldSelection->ArrayIsEnabled(name);
} }
void vtkPVFoamReader::SetPointFieldArrayStatus(const char* name, int status) void vtkPVFoamReader::SetPointFieldArrayStatus(const char* name, int status)
{ {
vtkDebugMacro(<<"SetPointFieldArrayStatus");
if (status) if (status)
{ {
PointFieldSelection->EnableArray(name); PointFieldSelection->EnableArray(name);
@ -669,39 +676,30 @@ void vtkPVFoamReader::SetPointFieldArrayStatus(const char* name, int status)
vtkDataArraySelection* vtkPVFoamReader::GetLagrangianFieldSelection() vtkDataArraySelection* vtkPVFoamReader::GetLagrangianFieldSelection()
{ {
vtkDebugMacro(<<"GetLagrangianFieldSelection");
return LagrangianFieldSelection; return LagrangianFieldSelection;
} }
int vtkPVFoamReader::GetNumberOfLagrangianFieldArrays() int vtkPVFoamReader::GetNumberOfLagrangianFieldArrays()
{ {
vtkDebugMacro(<<"GetNumberOfLagrangianFieldArrays");
return LagrangianFieldSelection->GetNumberOfArrays(); return LagrangianFieldSelection->GetNumberOfArrays();
} }
const char* vtkPVFoamReader::GetLagrangianFieldArrayName(int index) const char* vtkPVFoamReader::GetLagrangianFieldArrayName(int index)
{ {
vtkDebugMacro(<<"GetLagrangianFieldArrayName");
return LagrangianFieldSelection->GetArrayName(index); return LagrangianFieldSelection->GetArrayName(index);
} }
int vtkPVFoamReader::GetLagrangianFieldArrayStatus(const char* name) int vtkPVFoamReader::GetLagrangianFieldArrayStatus(const char* name)
{ {
vtkDebugMacro(<<"GetLagrangianFieldArrayStatus");
return LagrangianFieldSelection->ArrayIsEnabled(name); return LagrangianFieldSelection->ArrayIsEnabled(name);
} }
void vtkPVFoamReader::SetLagrangianFieldArrayStatus void vtkPVFoamReader::SetLagrangianFieldArrayStatus
( (
const char* name, const char* name,
int status int status
) )
{ {
vtkDebugMacro(<<"SetLagrangianFieldArrayStatus");
if (status) if (status)
{ {
LagrangianFieldSelection->EnableArray(name); LagrangianFieldSelection->EnableArray(name);

View File

@ -77,6 +77,10 @@ public:
vtkSetStringMacro(FileName); vtkSetStringMacro(FileName);
vtkGetStringMacro(FileName); vtkGetStringMacro(FileName);
// Description:
// Print some case information
virtual void PrintInfo();
// Description: // Description:
// OpenFOAM mesh caching control // OpenFOAM mesh caching control
vtkSetMacro(CacheMesh, bool); vtkSetMacro(CacheMesh, bool);
@ -250,7 +254,8 @@ private:
//- Cached data for output port0 (experimental!) //- Cached data for output port0 (experimental!)
vtkMultiBlockDataSet* output0_; vtkMultiBlockDataSet* output0_;
Foam::vtkPVFoam* foamData_; //- Backend portion of the reader
Foam::vtkPVFoam* backend_;
}; };
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,10 +2,7 @@ vtkPVFoam.C
vtkPVFoamFields.C vtkPVFoamFields.C
vtkPVFoamMesh.C vtkPVFoamMesh.C
vtkPVFoamMeshLagrangian.C vtkPVFoamMeshLagrangian.C
vtkPVFoamMeshSet.C
vtkPVFoamMeshVolume.C vtkPVFoamMeshVolume.C
vtkPVFoamMeshZone.C
vtkPVFoamUpdateInfo.C vtkPVFoamUpdateInfo.C
vtkPVFoamUtils.C
LIB = $(FOAM_LIBBIN)/libvtkPVFoam-pv${ParaView_MAJOR} LIB = $(FOAM_LIBBIN)/libvtkPVFoam-pv${ParaView_MAJOR}

View File

@ -10,7 +10,7 @@ EXE_INC = \
-I$(LIB_SRC)/conversion/lnInclude \ -I$(LIB_SRC)/conversion/lnInclude \
-I$(ParaView_INCLUDE_DIR) \ -I$(ParaView_INCLUDE_DIR) \
-I$(ParaView_INCLUDE_DIR)/vtkkwiml \ -I$(ParaView_INCLUDE_DIR)/vtkkwiml \
-I../../vtkPVReaders/lnInclude \ -I../../foamPv/lnInclude \
-I../PVFoamReader -I../PVFoamReader
LIB_LIBS = \ LIB_LIBS = \
@ -18,5 +18,5 @@ LIB_LIBS = \
-lconversion \ -lconversion \
-lgenericPatchFields \ -lgenericPatchFields \
-llagrangian \ -llagrangian \
-L$(FOAM_LIBBIN) -lvtkPVReaders-pv${ParaView_MAJOR} \ -L$(FOAM_LIBBIN) -lfoamPv-pv${ParaView_MAJOR} \
$(GLIBS) $(GLIBS)

View File

@ -1,79 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
InClass
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
// ************************************************************************* //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -42,15 +42,11 @@ License
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(vtkPVFoam, 0); defineTypeNameAndDebug(vtkPVFoam, 0);
} }
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
#include "vtkPVFoamAddToSelection.H"
#include "vtkPVFoamUpdateInfoFields.H"
void Foam::vtkPVFoam::resetCounters() void Foam::vtkPVFoam::resetCounters()
{ {
// Reset array range information (ids and sizes) // Reset array range information (ids and sizes)
@ -116,14 +112,10 @@ int Foam::vtkPVFoam::setTime(int nRequest, const double requestTimes[])
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPVFoam::setTime("; Info<< "<beg> setTime(";
for (int requestI = 0; requestI < nRequest; ++requestI) for (int requestI = 0; requestI < nRequest; ++requestI)
{ {
if (requestI) if (requestI) Info<< ", ";
{
Info<< ", ";
}
Info<< requestTimes[requestI]; Info<< requestTimes[requestI];
} }
Info<< ") - previousIndex = " << timeIndex_ Info<< ") - previousIndex = " << timeIndex_
@ -160,7 +152,7 @@ int Foam::vtkPVFoam::setTime(int nRequest, const double requestTimes[])
if (debug) if (debug)
{ {
Info<< "<end> Foam::vtkPVFoam::setTime() - selectedTime=" Info<< "<end> setTime() - selectedTime="
<< Times[nearestIndex].name() << " index=" << timeIndex_ << Times[nearestIndex].name() << " index=" << timeIndex_
<< "/" << Times.size() << "/" << Times.size()
<< " meshChanged=" << Switch(meshChanged_) << " meshChanged=" << Switch(meshChanged_)
@ -175,7 +167,7 @@ void Foam::vtkPVFoam::updateMeshPartsStatus()
{ {
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPVFoam::updateMeshPartsStatus" << endl; Info<< "<beg> updateMeshPartsStatus" << endl;
} }
vtkDataArraySelection* selection = reader_->GetPartSelection(); vtkDataArraySelection* selection = reader_->GetPartSelection();
@ -203,7 +195,7 @@ void Foam::vtkPVFoam::updateMeshPartsStatus()
meshChanged_ = true; meshChanged_ = true;
} }
if (debug) if (debug > 1)
{ {
Info<< " part[" << partId << "] = " Info<< " part[" << partId << "] = "
<< partStatus_[partId] << partStatus_[partId]
@ -212,11 +204,17 @@ void Foam::vtkPVFoam::updateMeshPartsStatus()
} }
if (debug) if (debug)
{ {
Info<< "<end> Foam::vtkPVFoam::updateMeshPartsStatus" << endl; Info<< "<end> updateMeshPartsStatus" << endl;
} }
} }
Foam::word Foam::vtkPVFoam::getPartName(const int partId)
{
return getFirstWord(reader_->GetPartArrayName(partId));
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::vtkPVFoam::vtkPVFoam Foam::vtkPVFoam::vtkPVFoam
@ -245,7 +243,7 @@ Foam::vtkPVFoam::vtkPVFoam
{ {
if (debug) if (debug)
{ {
Info<< "Foam::vtkPVFoam::vtkPVFoam - " << FileName << endl; Info<< "vtkPVFoam - " << FileName << endl;
printMemory(); printMemory();
} }
@ -333,7 +331,7 @@ Foam::vtkPVFoam::~vtkPVFoam()
{ {
if (debug) if (debug)
{ {
Info<< "<end> Foam::vtkPVFoam::~vtkPVFoam" << endl; Info<< "~vtkPVFoam" << endl;
} }
delete meshPtr_; delete meshPtr_;
@ -346,7 +344,7 @@ void Foam::vtkPVFoam::updateInfo()
{ {
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPVFoam::updateInfo" Info<< "<beg> updateInfo"
<< " [meshPtr=" << (meshPtr_ ? "set" : "nullptr") << "] timeIndex=" << " [meshPtr=" << (meshPtr_ ? "set" : "nullptr") << "] timeIndex="
<< timeIndex_ << endl; << timeIndex_ << endl;
} }
@ -363,16 +361,15 @@ void Foam::vtkPVFoam::updateInfo()
// time of the vtkDataArraySelection, but the qt/paraview proxy // time of the vtkDataArraySelection, but the qt/paraview proxy
// layer doesn't care about that anyhow. // layer doesn't care about that anyhow.
// enable 'internalMesh' on the first call
// or preserve the enabled selections
stringList enabledEntries; stringList enabledEntries;
if (!partSelection->GetNumberOfArrays() && !meshPtr_) if (!partSelection->GetNumberOfArrays() && !meshPtr_)
{ {
enabledEntries.setSize(1); // enable 'internalMesh' on the first call
enabledEntries[0] = "internalMesh"; enabledEntries = { "internalMesh" };
} }
else else
{ {
// preserve the enabled selections
enabledEntries = getSelectedArrayEntries(partSelection); enabledEntries = getSelectedArrayEntries(partSelection);
} }
@ -395,23 +392,12 @@ void Foam::vtkPVFoam::updateInfo()
} }
// Update volume, point and lagrangian fields // Update volume, point and lagrangian fields
updateInfoFields<fvPatchField, volMesh> updateInfoFields();
(
reader_->GetVolFieldSelection()
);
updateInfoFields<pointPatchField, pointMesh>
(
reader_->GetPointFieldSelection()
);
updateInfoLagrangianFields();
if (debug) if (debug)
{ {
// just for debug info Info<< "<end> updateInfo" << endl;
getSelectedArrayEntries(partSelection);
Info<< "<end> Foam::vtkPVFoam::updateInfo" << endl;
} }
} }
@ -419,7 +405,7 @@ void Foam::vtkPVFoam::updateFoamMesh()
{ {
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPVFoam::updateFoamMesh" << endl; Info<< "<beg> updateFoamMesh" << endl;
printMemory(); printMemory();
} }
@ -463,7 +449,7 @@ void Foam::vtkPVFoam::updateFoamMesh()
if (debug) if (debug)
{ {
Info<< "<end> Foam::vtkPVFoam::updateFoamMesh" << endl; Info<< "<end> updateFoamMesh" << endl;
printMemory(); printMemory();
} }
} }
@ -532,7 +518,7 @@ void Foam::vtkPVFoam::Update
convertLagrangianFields(lagrangianOutput); convertLagrangianFields(lagrangianOutput);
if (debug) if (debug)
{ {
Info<< "done reader part" << endl; Info<< "done reader part" << nl << endl;
} }
reader_->UpdateProgress(0.95); reader_->UpdateProgress(0.95);
@ -548,68 +534,58 @@ void Foam::vtkPVFoam::CleanUp()
} }
double* Foam::vtkPVFoam::findTimes(int& nTimeSteps) std::vector<double> Foam::vtkPVFoam::findTimes(const bool skipZero) const
{ {
int nTimes = 0; std::vector<double> times;
double* tsteps = nullptr;
if (dbPtr_.valid()) if (dbPtr_.valid())
{ {
Time& runTime = dbPtr_(); const Time& runTime = dbPtr_();
instantList timeLst = runTime.times(); instantList timeLst = runTime.times();
// find the first time for which this mesh appears to exist // find the first time for which this mesh appears to exist
label timeI = 0; label begIndex = timeLst.size();
for (; timeI < timeLst.size(); ++timeI) forAll(timeLst, timeI)
{ {
const word& timeName = timeLst[timeI].name();
if if
( (
isFile(runTime.path()/timeName/meshDir_/"points") IOobject
&& IOobject
( (
"points", "points",
timeName, timeLst[timeI].name(),
meshDir_, meshDir_,
runTime runTime
).typeHeaderOk<pointIOField>(true) ).typeHeaderOk<pointIOField>(false, false)
) )
{ {
begIndex = timeI;
break; break;
} }
} }
nTimes = timeLst.size() - timeI; label nTimes = timeLst.size() - begIndex;
// skip "constant" time whenever possible // skip "constant" time whenever possible
if (timeI == 0 && nTimes > 1) if (begIndex == 0 && nTimes > 1)
{ {
if (timeLst[timeI].name() == runTime.constant()) if (timeLst[begIndex].name() == runTime.constant())
{ {
++timeI; ++begIndex;
--nTimes; --nTimes;
} }
} }
// skip "0/" time if requested and possible // skip "0/" time if requested and possible
if (nTimes > 1 && reader_->GetSkipZeroTime()) if (skipZero && nTimes > 1 && timeLst[begIndex].name() == "0")
{ {
if (mag(timeLst[timeI].value()) < SMALL) ++begIndex;
{ --nTimes;
++timeI;
--nTimes;
}
} }
if (nTimes) times.reserve(nTimes);
while (nTimes-- > 0)
{ {
tsteps = new double[nTimes]; times.push_back(timeLst[begIndex++].value());
for (label stepI = 0; stepI < nTimes; ++stepI, ++timeI)
{
tsteps[stepI] = timeLst[timeI].value();
}
} }
} }
else else
@ -620,10 +596,7 @@ double* Foam::vtkPVFoam::findTimes(int& nTimeSteps)
} }
} }
// vector length returned via the parameter return times;
nTimeSteps = nTimes;
return tsteps;
} }
@ -650,7 +623,7 @@ void Foam::vtkPVFoam::renderPatchNames
if (show) if (show)
{ {
// get the display patches, strip off any suffix // get the display patches, strip off any suffix
wordHashSet selectedPatches = getSelected hashedWordList selectedPatches = getSelected
( (
reader_->GetPartSelection(), reader_->GetPartSelection(),
arrayRangePatches_ arrayRangePatches_
@ -793,8 +766,8 @@ void Foam::vtkPVFoam::renderPatchNames
tprop->BoldOff(); tprop->BoldOff();
tprop->ShadowOff(); tprop->ShadowOff();
tprop->SetLineSpacing(1.0); tprop->SetLineSpacing(1.0);
tprop->SetFontSize(12); tprop->SetFontSize(14);
tprop->SetColor(1.0, 0.0, 0.0); tprop->SetColor(1.0, 0.0, 1.0);
tprop->SetJustificationToCentered(); tprop->SetJustificationToCentered();
// Set text to use 3-D world co-ordinates // Set text to use 3-D world co-ordinates
@ -840,4 +813,24 @@ void Foam::vtkPVFoam::PrintSelf(ostream& os, vtkIndent indent) const
} }
void Foam::vtkPVFoam::printInfo() const
{
std::cout
<< "Region: " << meshRegion_ << "\n"
<< "nPoints: " << (meshPtr_ ? meshPtr_->nPoints() : 0) << "\n"
<< "nCells: " << (meshPtr_ ? meshPtr_->nCells() : 0) << "\n"
<< "nTimes: "
<< (dbPtr_.valid() ? dbPtr_().times().size() : 0) << "\n";
std::vector<double> times = this->findTimes(reader_->GetSkipZeroTime());
std::cout<<" " << times.size() << "(";
for (const double& val : times)
{
std::cout<< ' ' << val;
}
std::cout << " )" << std::endl;
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -29,24 +29,15 @@ Description
SourceFiles SourceFiles
vtkPVFoam.C vtkPVFoam.C
vtkPVFoam.H
vtkPVFoamFields.C vtkPVFoamFields.C
vtkPVFoamMesh.C vtkPVFoamMesh.C
vtkPVFoamMeshLagrangian.C vtkPVFoamMeshLagrangian.C
vtkPVFoamTemplates.C
vtkPVFoamMeshSet.C
vtkPVFoamMeshVolume.C vtkPVFoamMeshVolume.C
vtkPVFoamMeshZone.C vtkPVFoamTemplates.C
vtkPVFoamFaceField.H
vtkPVFoamLagrangianFields.H
vtkPVFoamPatchField.H
vtkPVFoamPointFields.H
vtkPVFoamPoints.H
vtkPVFoamUpdateInfo.C vtkPVFoamUpdateInfo.C
vtkPVFoamUpdateInfoFields.H
vtkPVFoamUtils.C vtkPVFoamUtils.C
vtkPVFoamVolFields.H vtkPVFoamFieldTemplates.C
vtkPVFoamAddToSelection.H vtkPVFoamUpdateTemplates.C
// Needed by VTK: // Needed by VTK:
vtkDataArrayTemplateImplicit.txx vtkDataArrayTemplateImplicit.txx
@ -63,6 +54,7 @@ SourceFiles
#include "primitivePatch.H" #include "primitivePatch.H"
#include "PrimitivePatchInterpolation.H" #include "PrimitivePatchInterpolation.H"
#include "volPointInterpolation.H" #include "volPointInterpolation.H"
#include "foamPvCore.H"
#undef VTKPVFOAM_DUALPORT #undef VTKPVFOAM_DUALPORT
@ -70,6 +62,7 @@ SourceFiles
class vtkDataArraySelection; class vtkDataArraySelection;
class vtkDataSet; class vtkDataSet;
class vtkFloatArray;
class vtkPoints; class vtkPoints;
class vtkPVFoamReader; class vtkPVFoamReader;
class vtkRenderer; class vtkRenderer;
@ -90,10 +83,9 @@ class Time;
class fvMesh; class fvMesh;
class IOobjectList; class IOobjectList;
class polyPatch; class polyPatch;
class faceSet;
class pointSet;
template<class Type> class IOField; template<class Type> class IOField;
template<class Type> class Field;
template<class Type> class List; template<class Type> class List;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
@ -101,84 +93,15 @@ template<class Type> class List;
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class vtkPVFoam class vtkPVFoam
:
private foamPvCore
{ {
// Convenience typedefs
typedef PrimitivePatchInterpolation<primitivePatch> patchInterpolator;
// Private classes // 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 //- Bookkeeping for polyhedral cell decomposition
// hide in extra pointMap (cellSet/cellZone) for now // hide in extra pointMap (cellSet/cellZone) for now
class polyDecomp class polyDecomp
@ -297,372 +220,258 @@ class vtkPVFoam
//- List of patch names for rendering to window //- List of patch names for rendering to window
List<vtkTextActor*> patchTextActorsPtrs_; List<vtkTextActor*> patchTextActorsPtrs_;
// Private Member Functions // 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 //- Reset data counters
void resetCounters(); void resetCounters();
// Update information helper functions // Update information helper functions
//- Update the mesh parts selected in the GUI //- Update the mesh parts selected in the GUI
void updateMeshPartsStatus(); void updateMeshPartsStatus();
//- Internal mesh info //- Internal mesh info
void updateInfoInternalMesh(vtkDataArraySelection*); void updateInfoInternalMesh(vtkDataArraySelection*);
//- Lagrangian info //- Lagrangian info
void updateInfoLagrangian(vtkDataArraySelection*); void updateInfoLagrangian(vtkDataArraySelection*);
//- Patch info //- Patch info
void updateInfoPatches(vtkDataArraySelection*, stringList&); void updateInfoPatches(vtkDataArraySelection*, stringList&);
//- Set info //- Set info
void updateInfoSets(vtkDataArraySelection*); void updateInfoSets(vtkDataArraySelection*);
//- Zone info //- Zone info
void updateInfoZones(vtkDataArraySelection*); void updateInfoZones(vtkDataArraySelection*);
//- Get non-empty zone names for zoneType from file //- Get non-empty zone names for zoneType from file
wordList getZoneNames(const word& zoneType) const; wordList getZoneNames(const word& zoneType) const;
//- Get non-empty zone names from mesh info //- Get names of on non-empty zones from the mesh info
template<class ZoneType> template<class ZoneType>
wordList getZoneNames static 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();
// 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 ZoneMesh<ZoneType, polyMesh>& zmesh
const IOobjectList&, );
const string& suffix=string::null
//- Field (volume, point, lagrangian) info
void updateInfoFields();
//- Field info
template<template<class> class patchType, class meshType>
void updateInfoFields
(
vtkDataArraySelection* select
);
//- Lagrangian field info
void updateInfoLagrangianFields(vtkDataArraySelection* select);
// Update helper functions
//- OpenFOAM mesh
void updateFoamMesh();
//- Reduce memory footprint after conversion
void reduceMemory();
// Mesh conversion functions
//- Convert volume mesh
void convertMeshVolume(vtkMultiBlockDataSet* output, int& blockNo);
//- Convert Lagrangian points
void convertMeshLagrangian(vtkMultiBlockDataSet* output, int& blockNo);
//- Convert mesh patches
void convertMeshPatches(vtkMultiBlockDataSet* output, int& blockNo);
//- Convert cell zones
void convertMeshCellZones(vtkMultiBlockDataSet* output, int& blockNo);
//- Convert face zones
void convertMeshFaceZones(vtkMultiBlockDataSet* output, int& blockNo);
//- Convert point zones
void convertMeshPointZones(vtkMultiBlockDataSet* output, int& blockNo);
//- Convert cell sets
void convertMeshCellSets(vtkMultiBlockDataSet* output, int& blockNo);
//- Convert face sets
void convertMeshFaceSets(vtkMultiBlockDataSet* output, int& blockNo);
//- Convert point sets
void convertMeshPointSets(vtkMultiBlockDataSet* output, int& blockNo);
// Add mesh functions
//- Volume meshes as vtkUnstructuredGrid
vtkUnstructuredGrid* volumeVTKMesh
(
const fvMesh& mesh,
polyDecomp& decompInfo
);
//- Lagrangian positions as vtkPolyData
vtkPolyData* lagrangianVTKMesh
(
const polyMesh& mesh,
const word& cloudName
);
//- Patches (mesh or primitive) as vtkPolyData
template<class PatchType>
vtkPolyData* patchVTKMesh
(
const word& name,
const PatchType& p
); );
// Convert OpenFOAM fields // Field conversion functions
//- Volume field - all types //- Convert Field to VTK field
template<class Type> template<class Type>
void convertVolField vtkFloatArray* convertFieldToVTK
( (
const PtrList<PrimitivePatchInterpolation<primitivePatch>>&, const word& name,
const GeometricField<Type, fvPatchField, volMesh>&, const Field<Type>& fld
const bool interpFields, );
vtkMultiBlockDataSet* output
);
//- Volume fields - all types //- Face set/zone field
template<class Type> template<class Type>
void convertVolFields vtkFloatArray* convertFaceFieldToVTK
( (
const fvMesh&, const GeometricField<Type, fvPatchField, volMesh>& fld,
const PtrList<PrimitivePatchInterpolation<primitivePatch>>&, const labelUList& faceLabels
const IOobjectList&, );
const bool interpFields,
vtkMultiBlockDataSet* output
);
//- Volume internal fields (DimensionedField)- all types //- Volume field
template<class Type> template<class Type>
void convertDimFields vtkFloatArray* convertVolFieldToVTK
( (
const fvMesh&, const GeometricField<Type, fvPatchField, volMesh>& fld,
const PtrList<PrimitivePatchInterpolation<primitivePatch>>&, const polyDecomp& decompInfo
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 //- Convert volume fields
void convertVolFields(vtkMultiBlockDataSet* output);
//- Only keep what is listed in hashSet //- Convert point fields
static void pruneObjectList void convertPointFields(vtkMultiBlockDataSet* output);
(
IOobjectList&,
const wordHashSet&
);
//- Retrieve the current selections //- Convert Lagrangian fields
static wordHashSet getSelected(vtkDataArraySelection*); void convertLagrangianFields(vtkMultiBlockDataSet* output);
//- Retrieve a sub-list of the current selections
static wordHashSet getSelected
(
vtkDataArraySelection*,
const arrayRange&
);
//- Retrieve the current selections // Convert OpenFOAM fields
static stringList getSelectedArrayEntries(vtkDataArraySelection*);
//- Retrieve a sub-list of the current selections //- Volume field - all types
static stringList getSelectedArrayEntries template<class Type>
( void convertVolField
vtkDataArraySelection*, (
const arrayRange& const PtrList<patchInterpolator>& patchInterpList,
); const GeometricField<Type, fvPatchField, volMesh>& fld,
vtkMultiBlockDataSet* output
);
//- Set selection(s) //- Volume fields - all types
static void setSelectedArrayEntries template<class Type>
( void convertVolFields
vtkDataArraySelection*, (
const stringList& const fvMesh& mesh,
); const PtrList<patchInterpolator>& patchInterpList,
const IOobjectList& objects,
vtkMultiBlockDataSet* output
);
//- Get the first word from the mesh parts selection //- Volume internal fields (DimensionedField)- all types
word getPartName(const int); template<class Type>
void convertDimFields
(
const fvMesh& mesh,
const PtrList<patchInterpolator>& patchInterpList,
const IOobjectList& objects,
vtkMultiBlockDataSet* output
);
//- Volume field - all selected parts
template<class Type>
void convertVolFieldBlock
(
const GeometricField<Type, fvPatchField, volMesh>& fld,
autoPtr<GeometricField<Type, pointPatchField, pointMesh>>& ptfPtr,
vtkMultiBlockDataSet* output,
const arrayRange& range,
const List<polyDecomp>& decompLst
);
//- Lagrangian fields - all types
template<class Type>
void convertLagrangianFields
(
const IOobjectList& objects,
vtkMultiBlockDataSet* output,
const label datasetNo
);
//- Point fields - all types
template<class Type>
void convertPointFields
(
const pointMesh& pMesh,
const IOobjectList& objects,
vtkMultiBlockDataSet* output
);
//- Point field - all selected parts
template<class Type>
void convertPointFieldBlock
(
const GeometricField<Type, pointPatchField, pointMesh>& pfld,
vtkMultiBlockDataSet* output,
const arrayRange& range,
const List<polyDecomp>& decompLst
);
//- Point field
template<class Type>
void convertPointField
(
vtkUnstructuredGrid* vtkmesh,
const GeometricField<Type, pointPatchField, pointMesh>& pfld,
const GeometricField<Type, fvPatchField, volMesh>& vfld,
const polyDecomp& decomp
);
// GUI selection helper functions
//- Only retain specified fields
static void pruneObjectList
(
IOobjectList& objects,
const hashedWordList& retain
);
//- Get the first word from the reader 'parts' selection
word getPartName(const int partId);
// Constructors
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
vtkPVFoam(const vtkPVFoam&); vtkPVFoam(const vtkPVFoam&) = delete;
//- Disallow default bitwise assignment //- Disallow default bitwise assignment
void operator=(const vtkPVFoam&); void operator=(const vtkPVFoam&) = delete;
public: public:
@ -700,9 +509,9 @@ public:
//- Clean any storage //- Clean any storage
void CleanUp(); void CleanUp();
//- Allocate and return a list of selected times //- Return a list of selected times.
// returns the count via the parameter // Use STL container since these values are used by the plugin
double* findTimes(int& nTimeSteps); std::vector<double> findTimes(const bool skipZero = false) const;
//- Add/remove patch names to/from the view //- Add/remove patch names to/from the view
void renderPatchNames(vtkRenderer*, const bool show); void renderPatchNames(vtkRenderer*, const bool show);
@ -725,9 +534,7 @@ public:
//- Debug information //- Debug information
void PrintSelf(ostream&, vtkIndent) const; void PrintSelf(ostream&, vtkIndent) const;
//- Simple memory used debugging information void printInfo() const;
static void printMemory();
}; };

View File

@ -1,117 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
InClass
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
// ************************************************************************* //

View File

@ -0,0 +1,909 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 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 vtkPVFoamFieldTemplates_C
#define vtkPVFoamFieldTemplates_C
// OpenFOAM includes
#include "emptyFvPatchField.H"
#include "wallPolyPatch.H"
#include "faceSet.H"
#include "volPointInterpolation.H"
#include "zeroGradientFvPatchField.H"
#include "interpolatePointToCell.H"
#include "foamPvFields.H"
// vtk includes
#include "vtkFloatArray.h"
#include "vtkCellData.h"
#include "vtkPointData.h"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//
// volume-fields
//
template<class Type>
void Foam::vtkPVFoam::convertVolField
(
const PtrList<patchInterpolator>& patchInterpList,
const GeometricField<Type, fvPatchField, volMesh>& fld,
vtkMultiBlockDataSet* output
)
{
const fvMesh& mesh = fld.mesh();
const polyBoundaryMesh& patches = mesh.boundaryMesh();
const bool interpField = !patchInterpList.empty();
const bool extrapPatch = reader_->GetExtrapolatePatches();
// Interpolated field (demand driven)
autoPtr<GeometricField<Type, pointPatchField, pointMesh>> ptfPtr;
if (interpField)
{
if (debug)
{
Info<< "convertVolField interpolating:" << fld.name() << endl;
}
ptfPtr.reset
(
volPointInterpolation::New(mesh).interpolate(fld).ptr()
);
}
// Convert activated internalMesh regions
convertVolFieldBlock
(
fld,
ptfPtr,
output,
arrayRangeVolume_,
regionPolyDecomp_
);
// Convert activated cellZones
convertVolFieldBlock
(
fld,
ptfPtr,
output,
arrayRangeCellZones_,
zonePolyDecomp_
);
// Convert activated cellSets
convertVolFieldBlock
(
fld,
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] || patchId < 0)
{
continue;
}
vtkPolyData* vtkmesh = getDataFromBlock<vtkPolyData>
(
output, arrayRangePatches_, datasetNo
);
if (!vtkmesh)
{
continue;
}
const fvPatchField<Type>& ptf = fld.boundaryField()[patchId];
if
(
isType<emptyFvPatchField<Type>>(ptf)
||
(
extrapPatch
&& !polyPatch::constraintType(patches[patchId].type())
)
)
{
fvPatch p(ptf.patch().patch(), mesh.boundary());
tmp<Field<Type>> tpptf
(
fvPatchField<Type>(p, fld).patchInternalField()
);
vtkFloatArray* cdata = convertFieldToVTK(fld.name(), tpptf());
vtkmesh->GetCellData()->AddArray(cdata);
cdata->Delete();
if (patchId < patchInterpList.size())
{
vtkFloatArray* pdata = convertFieldToVTK
(
fld.name(),
patchInterpList[patchId].faceToPointInterpolate(tpptf)()
);
vtkmesh->GetPointData()->AddArray(pdata);
pdata->Delete();
}
}
else
{
vtkFloatArray* cdata = convertFieldToVTK(fld.name(), ptf);
vtkmesh->GetCellData()->AddArray(cdata);
cdata->Delete();
if (patchId < patchInterpList.size())
{
vtkFloatArray* pdata = convertFieldToVTK
(
fld.name(),
patchInterpList[patchId].faceToPointInterpolate(ptf)()
);
vtkmesh->GetPointData()->AddArray(pdata);
pdata->Delete();
}
}
}
//
// 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;
}
vtkPolyData* vtkmesh = getDataFromBlock<vtkPolyData>
(
output, arrayRangeFaceZones_, datasetNo
);
if (vtkmesh)
{
vtkFloatArray* cdata = convertFaceFieldToVTK
(
fld,
zMesh[zoneId]
);
vtkmesh->GetCellData()->AddArray(cdata);
cdata->Delete();
}
// 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])
{
continue;
}
vtkPolyData* vtkmesh = getDataFromBlock<vtkPolyData>
(
output, arrayRangeFaceSets_, datasetNo
);
if (!vtkmesh)
{
continue;
}
const faceSet fSet(mesh, selectName);
vtkFloatArray* cdata = convertFaceFieldToVTK
(
fld,
fSet.sortedToc()
);
vtkmesh->GetCellData()->AddArray(cdata);
cdata->Delete();
// TODO: points
}
}
template<class Type>
void Foam::vtkPVFoam::convertVolFields
(
const fvMesh& mesh,
const PtrList<patchInterpolator>& patchInterpList,
const IOobjectList& objects,
vtkMultiBlockDataSet* output
)
{
forAllConstIter(IOobjectList, objects, iter)
{
// restrict to GeometricField<Type, ...>
if
(
iter()->headerClassName()
!= GeometricField<Type, fvPatchField, volMesh>::typeName
)
{
continue;
}
// Load field
GeometricField<Type, fvPatchField, volMesh> fld
(
*iter(),
mesh
);
// Convert
convertVolField(patchInterpList, fld, output);
}
}
template<class Type>
void Foam::vtkPVFoam::convertDimFields
(
const fvMesh& mesh,
const PtrList<patchInterpolator>& patchInterpList,
const IOobjectList& objects,
vtkMultiBlockDataSet* output
)
{
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
forAllConstIter(IOobjectList, objects, iter)
{
// restrict to DimensionedField<Type, ...>
if
(
iter()->headerClassName()
!= DimensionedField<Type, volMesh>::typeName
)
{
continue;
}
// Load field
DimensionedField<Type, volMesh> dimFld(*iter(), mesh);
// Construct volField with zero-gradient patch fields
IOobject io(dimFld);
io.readOpt() = IOobject::NO_READ;
PtrList<fvPatchField<Type>> patchFields(mesh.boundary().size());
forAll(patchFields, patchI)
{
patchFields.set
(
patchI,
fvPatchField<Type>::New
(
zeroGradientFvPatchField<Type>::typeName,
mesh.boundary()[patchI],
dimFld
)
);
}
VolFieldType volFld
(
io,
dimFld.mesh(),
dimFld.dimensions(),
dimFld,
patchFields
);
volFld.correctBoundaryConditions();
convertVolField(patchInterpList, volFld, output);
}
}
template<class Type>
void Foam::vtkPVFoam::convertVolFieldBlock
(
const GeometricField<Type, fvPatchField, volMesh>& fld,
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 (!partStatus_[partId])
{
continue;
}
vtkUnstructuredGrid* vtkmesh =
getDataFromBlock<vtkUnstructuredGrid>(output, range, datasetNo);
if (!vtkmesh)
{
continue;
}
vtkFloatArray* cdata = convertVolFieldToVTK
(
fld,
decompLst[datasetNo]
);
vtkmesh->GetCellData()->AddArray(cdata);
cdata->Delete();
if (ptfPtr.valid())
{
convertPointField(vtkmesh, ptfPtr(), fld, decompLst[datasetNo]);
}
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//
// point-fields
//
template<class Type>
void Foam::vtkPVFoam::convertPointFields
(
const pointMesh& pMesh,
const IOobjectList& objects,
vtkMultiBlockDataSet* output
)
{
const polyMesh& mesh = pMesh.mesh();
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<< "convertPointFields : " << fieldName << endl;
}
GeometricField<Type, pointPatchField, pointMesh> pfld(*iter(), pMesh);
// Convert activated internalMesh regions
convertPointFieldBlock
(
pfld,
output,
arrayRangeVolume_,
regionPolyDecomp_
);
// Convert activated cellZones
convertPointFieldBlock
(
pfld,
output,
arrayRangeCellZones_,
zonePolyDecomp_
);
// Convert activated cellSets
convertPointFieldBlock
(
pfld,
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] || patchId < 0)
{
continue;
}
vtkPolyData* vtkmesh = getDataFromBlock<vtkPolyData>
(
output, arrayRangePatches_, datasetNo
);
if (vtkmesh)
{
vtkFloatArray* pdata = convertFieldToVTK
(
fieldName,
pfld.boundaryField()[patchId].patchInternalField()()
);
vtkmesh->GetPointData()->AddArray(pdata);
pdata->Delete();
}
}
//
// 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] || zoneId < 0)
{
continue;
}
vtkPolyData* vtkmesh = getDataFromBlock<vtkPolyData>
(
output, arrayRangeFaceZones_, datasetNo
);
if (vtkmesh)
{
// Extract the field on the zone
Field<Type> znfld
(
pfld.primitiveField(),
mesh.faceZones()[zoneId]().meshPoints()
);
vtkFloatArray* pdata = convertFieldToVTK(fieldName, znfld);
vtkmesh->GetPointData()->AddArray(pdata);
pdata->Delete();
}
}
}
}
template<class Type>
void Foam::vtkPVFoam::convertPointFieldBlock
(
const GeometricField<Type, pointPatchField, pointMesh>& pfld,
vtkMultiBlockDataSet* output,
const arrayRange& range,
const List<polyDecomp>& decompLst
)
{
for (int partId = range.start(); partId < range.end(); ++partId)
{
const label datasetNo = partDataset_[partId];
if (!partStatus_[partId])
{
continue;
}
vtkUnstructuredGrid* vtkmesh = getDataFromBlock<vtkUnstructuredGrid>
(
output, range, datasetNo
);
if (vtkmesh)
{
convertPointField
(
vtkmesh,
pfld,
GeometricField<Type, fvPatchField, volMesh>::null(),
decompLst[datasetNo]
);
}
}
}
template<class Type>
void Foam::vtkPVFoam::convertPointField
(
vtkUnstructuredGrid* vtkmesh,
const GeometricField<Type, pointPatchField, pointMesh>& pfld,
const GeometricField<Type, fvPatchField, volMesh>& vfld,
const polyDecomp& decomp
)
{
if (!vtkmesh)
{
return;
}
const label nComp = pTraits<Type>::nComponents;
const labelUList& addPointCellLabels = decomp.addPointCellLabels();
const labelUList& pointMap = decomp.pointMap();
// use a pointMap or address directly into mesh
const label nPoints = (pointMap.size() ? pointMap.size() : pfld.size());
vtkFloatArray* fldData = vtkFloatArray::New();
fldData->SetNumberOfTuples(nPoints + addPointCellLabels.size());
fldData->SetNumberOfComponents(nComp);
fldData->Allocate(nComp*(nPoints + addPointCellLabels.size()));
// Note: using the name of the original volField
// not the name generated by the interpolation "volPointInterpolate(<name>)"
if (&vfld != &GeometricField<Type, fvPatchField, volMesh>::null())
{
fldData->SetName(vfld.name().c_str());
}
else
{
fldData->SetName(pfld.name().c_str());
}
if (debug)
{
Info<< "convert Point field: "
<< pfld.name()
<< " size=" << (nPoints + addPointCellLabels.size())
<< " (" << nPoints << " + " << addPointCellLabels.size()
<< ") nComp=" << nComp << endl;
}
float vec[nComp];
if (pointMap.size())
{
forAll(pointMap, i)
{
const Type& t = pfld[pointMap[i]];
for (direction d=0; d<nComp; ++d)
{
vec[d] = component(t, d);
}
foamPvFields::remapTuple<Type>(vec);
fldData->InsertTuple(i, vec);
}
}
else
{
forAll(pfld, i)
{
const Type& t = pfld[i];
for (direction d=0; d<nComp; ++d)
{
vec[d] = component(t, d);
}
foamPvFields::remapTuple<Type>(vec);
fldData->InsertTuple(i, vec);
}
}
// continue insertion from here
label i = nPoints;
if (&vfld != &GeometricField<Type, fvPatchField, volMesh>::null())
{
forAll(addPointCellLabels, apI)
{
const Type& t = vfld[addPointCellLabels[apI]];
for (direction d=0; d<nComp; ++d)
{
vec[d] = component(t, d);
}
foamPvFields::remapTuple<Type>(vec);
fldData->InsertTuple(i++, vec);
}
}
else
{
forAll(addPointCellLabels, apI)
{
Type t = interpolatePointToCell(pfld, addPointCellLabels[apI]);
for (direction d=0; d<nComp; ++d)
{
vec[d] = component(t, d);
}
foamPvFields::remapTuple<Type>(vec);
fldData->InsertTuple(i++, vec);
}
}
vtkmesh->GetPointData()->AddArray(fldData);
fldData->Delete();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//
// lagrangian-fields
//
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)
{
vtkPolyData* vtkmesh =
getDataFromBlock<vtkPolyData>(output, range, datasetNo);
if (vtkmesh)
{
IOField<Type> fld(*iter());
vtkFloatArray* fldData = convertFieldToVTK(fld.name(), fld);
vtkmesh->GetPointData()->AddArray(fldData);
fldData->Delete();
}
}
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//
// low-level conversions
//
template<class Type>
vtkFloatArray* Foam::vtkPVFoam::convertFieldToVTK
(
const word& name,
const Field<Type>& fld
)
{
if (debug)
{
Info<< "convert Field<" << pTraits<Type>::typeName << "> "
<< name
<< " size=" << fld.size()
<< " nComp=" << label(pTraits<Type>::nComponents) << endl;
}
const label nComp = pTraits<Type>::nComponents;
vtkFloatArray* fldData = vtkFloatArray::New();
fldData->SetNumberOfTuples(fld.size());
fldData->SetNumberOfComponents(nComp);
fldData->Allocate(nComp*fld.size());
fldData->SetName(name.c_str());
float vec[nComp];
forAll(fld, i)
{
const Type& t = fld[i];
for (direction d=0; d<nComp; ++d)
{
vec[d] = component(t, d);
}
foamPvFields::remapTuple<Type>(vec);
fldData->InsertTuple(i, vec);
}
return fldData;
}
template<class Type>
vtkFloatArray* Foam::vtkPVFoam::convertFaceFieldToVTK
(
const GeometricField<Type, fvPatchField, volMesh>& fld,
const labelUList& faceLabels
)
{
if (debug)
{
Info<< "convert face field: "
<< fld.name()
<< " size=" << faceLabels.size()
<< " nComp=" << label(pTraits<Type>::nComponents) << endl;
}
const fvMesh& mesh = fld.mesh();
const label nComp = pTraits<Type>::nComponents;
const label nInternalFaces = mesh.nInternalFaces();
const labelList& faceOwner = mesh.faceOwner();
const labelList& faceNeigh = mesh.faceNeighbour();
vtkFloatArray* fldData = vtkFloatArray::New();
fldData->SetNumberOfTuples(faceLabels.size());
fldData->SetNumberOfComponents(nComp);
fldData->Allocate(nComp*faceLabels.size());
fldData->SetName(fld.name().c_str());
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*(fld[faceOwner[faceNo]] + fld[faceNeigh[faceNo]]);
for (direction d=0; d<nComp; ++d)
{
vec[d] = component(t, d);
}
}
else
{
const Type& t = fld[faceOwner[faceNo]];
for (direction d=0; d<nComp; ++d)
{
vec[d] = component(t, d);
}
}
foamPvFields::remapTuple<Type>(vec);
fldData->InsertTuple(facei, vec);
}
return fldData;
}
template<class Type>
vtkFloatArray* Foam::vtkPVFoam::convertVolFieldToVTK
(
const GeometricField<Type, fvPatchField, volMesh>& fld,
const polyDecomp& decompInfo
)
{
const label nComp = pTraits<Type>::nComponents;
const labelList& superCells = decompInfo.superCells();
vtkFloatArray* fldData = vtkFloatArray::New();
fldData->SetNumberOfTuples(superCells.size());
fldData->SetNumberOfComponents(nComp);
fldData->Allocate(nComp*superCells.size());
fldData->SetName(fld.name().c_str());
if (debug)
{
Info<< "convert volField: "
<< fld.name()
<< " size=" << superCells.size()
<< " (" << fld.size() << " + "
<< (superCells.size() - fld.size())
<< ") nComp=" << nComp << endl;
}
float vec[nComp];
forAll(superCells, i)
{
const Type& t = fld[superCells[i]];
for (direction d=0; d<nComp; ++d)
{
vec[d] = component(t, d);
}
foamPvFields::remapTuple<Type>(vec);
fldData->InsertTuple(i, vec);
}
return fldData;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -26,6 +26,7 @@ License
#include "vtkPVFoam.H" #include "vtkPVFoam.H"
// OpenFOAM includes // OpenFOAM includes
#include "Cloud.H"
#include "IOobjectList.H" #include "IOobjectList.H"
#include "vtkPVFoamReader.h" #include "vtkPVFoamReader.h"
@ -34,29 +35,26 @@ License
#include "vtkPolyData.h" #include "vtkPolyData.h"
#include "vtkUnstructuredGrid.h" #include "vtkUnstructuredGrid.h"
// Templates (only needed here)
#include "vtkPVFoamFieldTemplates.C"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
#include "vtkPVFoamVolFields.H"
#include "vtkPVFoamPointFields.H"
#include "vtkPVFoamLagrangianFields.H"
void Foam::vtkPVFoam::pruneObjectList void Foam::vtkPVFoam::pruneObjectList
( (
IOobjectList& objects, IOobjectList& objects,
const wordHashSet& selected const hashedWordList& retain
) )
{ {
// hash all the selected field names if (retain.empty())
if (selected.empty())
{ {
objects.clear(); objects.clear();
} }
// only keep selected fields // only retain specified fields
forAllIter(IOobjectList, objects, iter) forAllIter(IOobjectList, objects, iter)
{ {
if (!selected.found(iter()->name())) if (!retain.found(iter()->name()))
{ {
objects.erase(iter); objects.erase(iter);
} }
@ -71,7 +69,8 @@ void Foam::vtkPVFoam::convertVolFields
{ {
const fvMesh& mesh = *meshPtr_; const fvMesh& mesh = *meshPtr_;
wordHashSet selectedFields = getSelected const bool interpFields = reader_->GetInterpolateVolFields();
hashedWordList selectedFields = getSelected
( (
reader_->GetVolFieldSelection() reader_->GetVolFieldSelection()
); );
@ -93,80 +92,50 @@ void Foam::vtkPVFoam::convertVolFields
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPVFoam::convertVolFields" << nl Info<< "<beg> convert volume fields" << endl;
<< "converting OpenFOAM volume fields" << endl;
forAllConstIter(IOobjectList, objects, iter) forAllConstIter(IOobjectList, objects, iter)
{ {
Info<< " " << iter()->name() Info<< " " << iter()->name()
<< " == " << iter()->objectPath() << nl; << " == " << iter()->objectPath() << endl;
} }
printMemory(); printMemory();
} }
PtrList<PrimitivePatchInterpolation<primitivePatch>> PtrList<patchInterpolator> interpLst;
ppInterpList(mesh.boundaryMesh().size());
forAll(ppInterpList, i) if (interpFields)
{ {
ppInterpList.set interpLst.setSize(mesh.boundaryMesh().size());
(
i, forAll(interpLst, i)
new PrimitivePatchInterpolation<primitivePatch> {
interpLst.set
( (
mesh.boundaryMesh()[i] i,
) new PrimitivePatchInterpolation<primitivePatch>
); (
mesh.boundaryMesh()[i]
)
);
}
} }
convertVolFields<scalar>(mesh, interpLst, objects, output);
convertVolFields<vector>(mesh, interpLst, objects, output);
convertVolFields<sphericalTensor>(mesh, interpLst, objects, output);
convertVolFields<symmTensor>(mesh, interpLst, objects, output);
convertVolFields<tensor>(mesh, interpLst, objects, output);
bool interpFields = reader_->GetInterpolateVolFields(); convertDimFields<scalar>(mesh, interpLst, objects, output);
convertDimFields<vector>(mesh, interpLst, objects, output);
convertVolFields<scalar> convertDimFields<sphericalTensor>(mesh, interpLst, objects, output);
( convertDimFields<symmTensor>(mesh, interpLst, objects, output);
mesh, ppInterpList, objects, interpFields, output convertDimFields<tensor>(mesh, interpLst, objects, 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
);
convertDimFields<scalar>
(
mesh, ppInterpList, objects, interpFields, output
);
convertDimFields<vector>
(
mesh, ppInterpList, objects, interpFields, output
);
convertDimFields<sphericalTensor>
(
mesh, ppInterpList, objects, interpFields, output
);
convertDimFields<symmTensor>
(
mesh, ppInterpList, objects, interpFields, output
);
convertDimFields<tensor>
(
mesh, ppInterpList, objects, interpFields, output
);
if (debug) if (debug)
{ {
Info<< "<end> Foam::vtkPVFoam::convertVolFields" << endl; Info<< "<end> convert volume fields" << endl;
printMemory(); printMemory();
} }
} }
@ -179,7 +148,7 @@ void Foam::vtkPVFoam::convertPointFields
{ {
const fvMesh& mesh = *meshPtr_; const fvMesh& mesh = *meshPtr_;
wordHashSet selectedFields = getSelected hashedWordList selectedFields = getSelected
( (
reader_->GetPointFieldSelection() reader_->GetPointFieldSelection()
); );
@ -205,12 +174,11 @@ void Foam::vtkPVFoam::convertPointFields
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPVFoam::convertPointFields" << nl Info<< "<beg> convert volume -> point fields" << endl;
<< "converting OpenFOAM volume fields -> point fields" << endl;
forAllConstIter(IOobjectList, objects, iter) forAllConstIter(IOobjectList, objects, iter)
{ {
Info<< " " << iter()->name() Info<< " " << iter()->name()
<< " == " << iter()->objectPath() << nl; << " == " << iter()->objectPath() << endl;
} }
printMemory(); printMemory();
} }
@ -218,31 +186,15 @@ void Foam::vtkPVFoam::convertPointFields
// Construct interpolation on the raw mesh // Construct interpolation on the raw mesh
const pointMesh& pMesh = pointMesh::New(mesh); const pointMesh& pMesh = pointMesh::New(mesh);
convertPointFields<scalar>(pMesh, objects, output);
convertPointFields<scalar> convertPointFields<vector>(pMesh, objects, output);
( convertPointFields<sphericalTensor>(pMesh, objects, output);
mesh, pMesh, objects, output convertPointFields<symmTensor>(pMesh, objects, output);
); convertPointFields<tensor>(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) if (debug)
{ {
Info<< "<end> Foam::vtkPVFoam::convertPointFields" << endl; Info<< "<end> convert volume -> point fields" << endl;
printMemory(); printMemory();
} }
} }
@ -256,7 +208,7 @@ void Foam::vtkPVFoam::convertLagrangianFields
arrayRange& range = arrayRangeLagrangian_; arrayRange& range = arrayRangeLagrangian_;
const fvMesh& mesh = *meshPtr_; const fvMesh& mesh = *meshPtr_;
wordHashSet selectedFields = getSelected hashedWordList selectedFields = getSelected
( (
reader_->GetLagrangianFieldSelection() reader_->GetLagrangianFieldSelection()
); );
@ -268,7 +220,7 @@ void Foam::vtkPVFoam::convertLagrangianFields
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPVFoam::convertLagrangianFields" << endl; Info<< "<beg> convert Lagrangian fields" << endl;
printMemory(); printMemory();
} }
@ -282,7 +234,6 @@ void Foam::vtkPVFoam::convertLagrangianFields
continue; continue;
} }
// Get the Lagrangian fields for this time and this cloud // Get the Lagrangian fields for this time and this cloud
// but only keep selected fields // but only keep selected fields
// the region name is already in the mesh db // the region name is already in the mesh db
@ -301,43 +252,25 @@ void Foam::vtkPVFoam::convertLagrangianFields
if (debug) if (debug)
{ {
Info<< "converting OpenFOAM lagrangian fields" << nl; Info<< "converting OpenFOAM lagrangian fields" << endl;
forAllConstIter(IOobjectList, objects, iter) forAllConstIter(IOobjectList, objects, iter)
{ {
Info<< " " << iter()->name() Info<< " " << iter()->name()
<< " == " << iter()->objectPath() << nl; << " == " << iter()->objectPath() << endl;
} }
} }
convertLagrangianFields<label> convertLagrangianFields<label>(objects, output, datasetNo);
( convertLagrangianFields<scalar>(objects, output, datasetNo);
objects, output, datasetNo convertLagrangianFields<vector>(objects, output, datasetNo);
); convertLagrangianFields<sphericalTensor>(objects, output, datasetNo);
convertLagrangianFields<scalar> convertLagrangianFields<symmTensor>(objects, output, datasetNo);
( convertLagrangianFields<tensor>(objects, output, datasetNo);
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) if (debug)
{ {
Info<< "<end> Foam::vtkPVFoam::convertLagrangianFields" << endl; Info<< "<end> convert Lagrangian fields" << endl;
printMemory(); printMemory();
} }
} }

View File

@ -1,113 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
InClass
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
// ************************************************************************* //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -57,7 +57,7 @@ void Foam::vtkPVFoam::convertMeshVolume
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPVFoam::convertMeshVolume" << endl; Info<< "<beg> convertMeshVolume" << endl;
printMemory(); printMemory();
} }
@ -80,7 +80,7 @@ void Foam::vtkPVFoam::convertMeshVolume
if (vtkmesh) if (vtkmesh)
{ {
AddToBlock(output, vtkmesh, range, datasetNo, partName); addToBlock(output, vtkmesh, range, datasetNo, partName);
vtkmesh->Delete(); vtkmesh->Delete();
partDataset_[partId] = datasetNo++; partDataset_[partId] = datasetNo++;
@ -95,7 +95,7 @@ void Foam::vtkPVFoam::convertMeshVolume
if (debug) if (debug)
{ {
Info<< "<end> Foam::vtkPVFoam::convertMeshVolume" << endl; Info<< "<end> convertMeshVolume" << endl;
printMemory(); printMemory();
} }
} }
@ -114,7 +114,7 @@ void Foam::vtkPVFoam::convertMeshLagrangian
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPVFoam::convertMeshLagrangian" << endl; Info<< "<beg> convertMeshLagrangian" << endl;
printMemory(); printMemory();
} }
@ -131,7 +131,7 @@ void Foam::vtkPVFoam::convertMeshLagrangian
if (vtkmesh) if (vtkmesh)
{ {
AddToBlock(output, vtkmesh, range, datasetNo, cloudName); addToBlock(output, vtkmesh, range, datasetNo, cloudName);
vtkmesh->Delete(); vtkmesh->Delete();
partDataset_[partId] = datasetNo++; partDataset_[partId] = datasetNo++;
@ -146,7 +146,7 @@ void Foam::vtkPVFoam::convertMeshLagrangian
if (debug) if (debug)
{ {
Info<< "<end> Foam::vtkPVFoam::convertMeshLagrangian" << endl; Info<< "<end> convertMeshLagrangian" << endl;
printMemory(); printMemory();
} }
} }
@ -166,7 +166,7 @@ void Foam::vtkPVFoam::convertMeshPatches
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPVFoam::convertMeshPatches" << endl; Info<< "<beg> convertMeshPatches" << endl;
printMemory(); printMemory();
} }
@ -201,26 +201,33 @@ void Foam::vtkPVFoam::convertMeshPatches
{ {
sz += patches[iter.key()].size(); sz += patches[iter.key()].size();
} }
labelList meshFaceLabels(sz); labelList faceLabels(sz);
sz = 0; sz = 0;
forAllConstIter(labelHashSet, patchIds, iter) forAllConstIter(labelHashSet, patchIds, iter)
{ {
const polyPatch& pp = patches[iter.key()]; const polyPatch& pp = patches[iter.key()];
forAll(pp, i) forAll(pp, i)
{ {
meshFaceLabels[sz++] = pp.start()+i; faceLabels[sz++] = pp.start()+i;
} }
} }
UIndirectList<face> fcs(mesh.faces(), meshFaceLabels);
uindirectPrimitivePatch pp(fcs, mesh.points()); uindirectPrimitivePatch pp
(
UIndirectList<face>
(
mesh.faces(),
faceLabels
),
mesh.points()
);
vtkmesh = patchVTKMesh(patchName, pp); vtkmesh = patchVTKMesh(patchName, pp);
} }
if (vtkmesh) if (vtkmesh)
{ {
AddToBlock(output, vtkmesh, range, datasetNo, patchName); addToBlock(output, vtkmesh, range, datasetNo, patchName);
vtkmesh->Delete(); vtkmesh->Delete();
partDataset_[partId] = datasetNo++; partDataset_[partId] = datasetNo++;
@ -235,7 +242,7 @@ void Foam::vtkPVFoam::convertMeshPatches
if (debug) if (debug)
{ {
Info<< "<end> Foam::vtkPVFoam::convertMeshPatches" << endl; Info<< "<end> convertMeshPatches" << endl;
printMemory(); printMemory();
} }
} }
@ -262,7 +269,7 @@ void Foam::vtkPVFoam::convertMeshCellZones
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPVFoam::convertMeshCellZones" << endl; Info<< "<beg> convertMeshCellZones" << endl;
printMemory(); printMemory();
} }
@ -309,7 +316,7 @@ void Foam::vtkPVFoam::convertMeshCellZones
// copy pointMap as well, otherwise pointFields fail // copy pointMap as well, otherwise pointFields fail
zonePolyDecomp_[datasetNo].pointMap() = subsetter.pointMap(); zonePolyDecomp_[datasetNo].pointMap() = subsetter.pointMap();
AddToBlock(output, vtkmesh, range, datasetNo, zoneName); addToBlock(output, vtkmesh, range, datasetNo, zoneName);
vtkmesh->Delete(); vtkmesh->Delete();
partDataset_[partId] = datasetNo++; partDataset_[partId] = datasetNo++;
@ -324,7 +331,7 @@ void Foam::vtkPVFoam::convertMeshCellZones
if (debug) if (debug)
{ {
Info<< "<end> Foam::vtkPVFoam::convertMeshCellZones" << endl; Info<< "<end> convertMeshCellZones" << endl;
printMemory(); printMemory();
} }
} }
@ -346,7 +353,7 @@ void Foam::vtkPVFoam::convertMeshCellSets
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPVFoam::convertMeshCellSets" << endl; Info<< "<beg> convertMeshCellSets" << endl;
printMemory(); printMemory();
} }
@ -391,7 +398,7 @@ void Foam::vtkPVFoam::convertMeshCellSets
// copy pointMap as well, otherwise pointFields fail // copy pointMap as well, otherwise pointFields fail
csetPolyDecomp_[datasetNo].pointMap() = subsetter.pointMap(); csetPolyDecomp_[datasetNo].pointMap() = subsetter.pointMap();
AddToBlock(output, vtkmesh, range, datasetNo, partName); addToBlock(output, vtkmesh, range, datasetNo, partName);
vtkmesh->Delete(); vtkmesh->Delete();
partDataset_[partId] = datasetNo++; partDataset_[partId] = datasetNo++;
@ -406,7 +413,7 @@ void Foam::vtkPVFoam::convertMeshCellSets
if (debug) if (debug)
{ {
Info<< "<end> Foam::vtkPVFoam::convertMeshCellSets" << endl; Info<< "<end> convertMeshCellSets" << endl;
printMemory(); printMemory();
} }
} }
@ -430,7 +437,7 @@ void Foam::vtkPVFoam::convertMeshFaceZones
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPVFoam::convertMeshFaceZones" << endl; Info<< "<beg> convertMeshFaceZones" << endl;
printMemory(); printMemory();
} }
@ -455,7 +462,7 @@ void Foam::vtkPVFoam::convertMeshFaceZones
if (vtkmesh) if (vtkmesh)
{ {
AddToBlock(output, vtkmesh, range, datasetNo, zoneName); addToBlock(output, vtkmesh, range, datasetNo, zoneName);
vtkmesh->Delete(); vtkmesh->Delete();
partDataset_[partId] = datasetNo++; partDataset_[partId] = datasetNo++;
@ -470,7 +477,7 @@ void Foam::vtkPVFoam::convertMeshFaceZones
if (debug) if (debug)
{ {
Info<< "<end> Foam::vtkPVFoam::convertMeshFaceZones" << endl; Info<< "<end> convertMeshFaceZones" << endl;
printMemory(); printMemory();
} }
} }
@ -489,7 +496,7 @@ void Foam::vtkPVFoam::convertMeshFaceSets
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPVFoam::convertMeshFaceSets" << endl; Info<< "<beg> convertMeshFaceSets" << endl;
printMemory(); printMemory();
} }
@ -507,12 +514,26 @@ void Foam::vtkPVFoam::convertMeshFaceSets
Info<< "Creating VTK mesh for faceSet=" << partName << endl; Info<< "Creating VTK mesh for faceSet=" << partName << endl;
} }
const faceSet fSet(mesh, partName); // faces in sorted order for more reliability
uindirectPrimitivePatch p
(
UIndirectList<face>
(
mesh.faces(),
faceSet(mesh, partName).sortedToc()
),
mesh.points()
);
vtkPolyData* vtkmesh = faceSetVTKMesh(mesh, fSet); if (p.empty())
{
continue;
}
vtkPolyData* vtkmesh = patchVTKMesh("faceSet:" + partName, p);
if (vtkmesh) if (vtkmesh)
{ {
AddToBlock(output, vtkmesh, range, datasetNo, partName); addToBlock(output, vtkmesh, range, datasetNo, partName);
vtkmesh->Delete(); vtkmesh->Delete();
partDataset_[partId] = datasetNo++; partDataset_[partId] = datasetNo++;
@ -527,7 +548,7 @@ void Foam::vtkPVFoam::convertMeshFaceSets
if (debug) if (debug)
{ {
Info<< "<end> Foam::vtkPVFoam::convertMeshFaceSets" << endl; Info<< "<end> convertMeshFaceSets" << endl;
printMemory(); printMemory();
} }
} }
@ -546,7 +567,7 @@ void Foam::vtkPVFoam::convertMeshPointZones
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPVFoam::convertMeshPointZones" << endl; Info<< "<beg> convertMeshPointZones" << endl;
printMemory(); printMemory();
} }
@ -563,10 +584,24 @@ void Foam::vtkPVFoam::convertMeshPointZones
continue; continue;
} }
vtkPolyData* vtkmesh = pointZoneVTKMesh(mesh, zMesh[zoneId]); const labelUList& pointLabels = zMesh[zoneId];
vtkPoints* vtkpoints = vtkPoints::New();
vtkpoints->Allocate(pointLabels.size());
const pointField& meshPoints = mesh.points();
forAll(pointLabels, pointi)
{
vtkpoints->InsertNextPoint(meshPoints[pointLabels[pointi]].v_);
}
vtkPolyData* vtkmesh = vtkPolyData::New();
vtkmesh->SetPoints(vtkpoints);
vtkpoints->Delete();
if (vtkmesh) if (vtkmesh)
{ {
AddToBlock(output, vtkmesh, range, datasetNo, zoneName); addToBlock(output, vtkmesh, range, datasetNo, zoneName);
vtkmesh->Delete(); vtkmesh->Delete();
partDataset_[partId] = datasetNo++; partDataset_[partId] = datasetNo++;
@ -582,7 +617,7 @@ void Foam::vtkPVFoam::convertMeshPointZones
if (debug) if (debug)
{ {
Info<< "<end> Foam::vtkPVFoam::convertMeshPointZones" << endl; Info<< "<end> convertMeshPointZones" << endl;
printMemory(); printMemory();
} }
} }
@ -602,7 +637,7 @@ void Foam::vtkPVFoam::convertMeshPointSets
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPVFoam::convertMeshPointSets" << endl; Info<< "<beg> convertMeshPointSets" << endl;
printMemory(); printMemory();
} }
@ -622,10 +657,22 @@ void Foam::vtkPVFoam::convertMeshPointSets
const pointSet pSet(mesh, partName); const pointSet pSet(mesh, partName);
vtkPolyData* vtkmesh = pointSetVTKMesh(mesh, pSet); vtkPoints* vtkpoints = vtkPoints::New();
vtkpoints->Allocate(pSet.size());
const pointField& meshPoints = mesh.points();
forAllConstIter(pointSet, pSet, iter)
{
vtkpoints->InsertNextPoint(meshPoints[iter.key()].v_);
}
vtkPolyData* vtkmesh = vtkPolyData::New();
vtkmesh->SetPoints(vtkpoints);
vtkpoints->Delete();
if (vtkmesh) if (vtkmesh)
{ {
AddToBlock(output, vtkmesh, range, datasetNo, partName); addToBlock(output, vtkmesh, range, datasetNo, partName);
vtkmesh->Delete(); vtkmesh->Delete();
partDataset_[partId] = datasetNo++; partDataset_[partId] = datasetNo++;
@ -640,7 +687,7 @@ void Foam::vtkPVFoam::convertMeshPointSets
if (debug) if (debug)
{ {
Info<< "<end> Foam::vtkPVFoam::convertMeshPointSets" << endl; Info<< "<end> convertMeshPointSets" << endl;
printMemory(); printMemory();
} }
} }

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -30,7 +30,6 @@ License
#include "fvMesh.H" #include "fvMesh.H"
#include "IOobjectList.H" #include "IOobjectList.H"
#include "passiveParticle.H" #include "passiveParticle.H"
#include "vtkOpenFOAMPoints.H"
// VTK includes // VTK includes
#include "vtkCellArray.h" #include "vtkCellArray.h"
@ -41,7 +40,7 @@ License
vtkPolyData* Foam::vtkPVFoam::lagrangianVTKMesh vtkPolyData* Foam::vtkPVFoam::lagrangianVTKMesh
( (
const fvMesh& mesh, const polyMesh& mesh,
const word& cloudName const word& cloudName
) )
{ {
@ -49,7 +48,7 @@ vtkPolyData* Foam::vtkPVFoam::lagrangianVTKMesh
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPVFoam::lagrangianVTKMesh - timePath " Info<< "<beg> lagrangianVTKMesh - timePath "
<< mesh.time().timePath()/cloud::prefix/cloudName << endl; << mesh.time().timePath()/cloud::prefix/cloudName << endl;
printMemory(); printMemory();
} }
@ -83,7 +82,7 @@ vtkPolyData* Foam::vtkPVFoam::lagrangianVTKMesh
vtkIdType particleId = 0; vtkIdType particleId = 0;
forAllConstIter(Cloud<passiveParticle>, parcels, iter) forAllConstIter(Cloud<passiveParticle>, parcels, iter)
{ {
vtkInsertNextOpenFOAMPoint(vtkpoints, iter().position()); vtkpoints->InsertNextPoint(iter().position().v_);
vtkcells->InsertNextCell(1, &particleId); vtkcells->InsertNextCell(1, &particleId);
particleId++; particleId++;
@ -98,7 +97,7 @@ vtkPolyData* Foam::vtkPVFoam::lagrangianVTKMesh
if (debug) if (debug)
{ {
Info<< "<end> Foam::vtkPVFoam::lagrangianVTKMesh" << endl; Info<< "<end> lagrangianVTKMesh" << endl;
printMemory(); printMemory();
} }

View File

@ -1,148 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "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;
}
// ************************************************************************* //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -29,8 +29,6 @@ License
// OpenFOAM includes // OpenFOAM includes
#include "fvMesh.H" #include "fvMesh.H"
#include "cellModeller.H" #include "cellModeller.H"
#include "vtkOpenFOAMPoints.H"
#include "Swap.H"
// VTK includes // VTK includes
#include "vtkCellArray.h" #include "vtkCellArray.h"
@ -56,7 +54,7 @@ vtkUnstructuredGrid* Foam::vtkPVFoam::volumeVTKMesh
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPVFoam::volumeVTKMesh" << endl; Info<< "<beg> volumeVTKMesh" << endl;
printMemory(); printMemory();
} }
@ -78,11 +76,6 @@ vtkUnstructuredGrid* Foam::vtkPVFoam::volumeVTKMesh
// and cells // and cells
if (!reader_->GetUseVTKPolyhedron()) if (!reader_->GetUseVTKPolyhedron())
{ {
if (debug)
{
Info<< "... scanning for polyhedra" << endl;
}
forAll(cellShapes, celli) forAll(cellShapes, celli)
{ {
const cellModel& model = cellShapes[celli].model(); const cellModel& model = cellShapes[celli].model();
@ -123,21 +116,8 @@ vtkUnstructuredGrid* Foam::vtkPVFoam::volumeVTKMesh
// Set size of additional cells mapping array // Set size of additional cells mapping array
// (from added cell to original cell) // (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); superCells.setSize(mesh.nCells() + nAddCells);
if (debug)
{
Info<< "... converting points" << endl;
}
// Convert OpenFOAM mesh vertices to VTK // Convert OpenFOAM mesh vertices to VTK
vtkPoints* vtkpoints = vtkPoints::New(); vtkPoints* vtkpoints = vtkPoints::New();
vtkpoints->Allocate(mesh.nPoints() + nAddPoints); vtkpoints->Allocate(mesh.nPoints() + nAddPoints);
@ -146,13 +126,7 @@ vtkUnstructuredGrid* Foam::vtkPVFoam::volumeVTKMesh
forAll(points, i) forAll(points, i)
{ {
vtkInsertNextOpenFOAMPoint(vtkpoints, points[i]); vtkpoints->InsertNextPoint(points[i].v_);
}
if (debug)
{
Info<< "... converting cells" << endl;
} }
vtkmesh->Allocate(mesh.nCells() + nAddCells); vtkmesh->Allocate(mesh.nCells() + nAddCells);
@ -329,7 +303,7 @@ vtkUnstructuredGrid* Foam::vtkPVFoam::volumeVTKMesh
// The new vertex from the cell-centre // The new vertex from the cell-centre
const label newVertexLabel = mesh.nPoints() + addPointi; const label newVertexLabel = mesh.nPoints() + addPointi;
vtkInsertNextOpenFOAMPoint(vtkpoints, mesh.C()[celli]); vtkpoints->InsertNextPoint(mesh.C()[celli].v_);
// Whether to insert cell in place of original or not. // Whether to insert cell in place of original or not.
bool substituteCell = true; bool substituteCell = true;
@ -441,7 +415,10 @@ vtkUnstructuredGrid* Foam::vtkPVFoam::volumeVTKMesh
if (debug) if (debug)
{ {
Info<< "<end> Foam::vtkPVFoam::volumeVTKMesh" << endl; Info<<"nCells=" << mesh.nCells() <<" nPoints=" << mesh.nPoints()
<<" nAddCells=" << nAddCells <<" nAddPoints=" << nAddPoints
<< nl
<< "<end> volumeVTKMesh" << endl;
printMemory(); printMemory();
} }

View File

@ -1,75 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "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;
}
// ************************************************************************* //

View File

@ -1,129 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
InClass
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
// ************************************************************************* //

View File

@ -1,331 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
InClass
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.primitiveField(),
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
// ************************************************************************* //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -28,7 +28,6 @@ License
// OpenFOAM includes // OpenFOAM includes
#include "polyPatch.H" #include "polyPatch.H"
#include "primitivePatch.H" #include "primitivePatch.H"
#include "vtkOpenFOAMPoints.H"
// VTK includes // VTK includes
#include "vtkCellArray.h" #include "vtkCellArray.h"
@ -48,7 +47,7 @@ vtkPolyData* Foam::vtkPVFoam::patchVTKMesh
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPVFoam::patchVTKMesh - " << name << endl; Info<< "<beg> patchVTKMesh - " << name << endl;
printMemory(); printMemory();
} }
@ -59,13 +58,12 @@ vtkPolyData* Foam::vtkPVFoam::patchVTKMesh
vtkpoints->Allocate(points.size()); vtkpoints->Allocate(points.size());
forAll(points, i) forAll(points, i)
{ {
vtkInsertNextOpenFOAMPoint(vtkpoints, points[i]); vtkpoints->InsertNextPoint(points[i].v_);
} }
vtkmesh->SetPoints(vtkpoints); vtkmesh->SetPoints(vtkpoints);
vtkpoints->Delete(); vtkpoints->Delete();
// Add faces as polygons // Add faces as polygons
const faceList& faces = p.localFaces(); const faceList& faces = p.localFaces();
@ -88,7 +86,7 @@ vtkPolyData* Foam::vtkPVFoam::patchVTKMesh
if (debug) if (debug)
{ {
Info<< "<end> Foam::vtkPVFoam::patchVTKMesh - " << name << endl; Info<< "<end> patchVTKMesh - " << name << endl;
printMemory(); printMemory();
} }

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -36,13 +36,12 @@ License
#include "Cloud.H" #include "Cloud.H"
#include "vtkPVFoamReader.h" #include "vtkPVFoamReader.h"
// local headers
#include "vtkPVFoamAddToSelection.H"
#include "vtkPVFoamUpdateInfoFields.H"
// VTK includes // VTK includes
#include "vtkDataArraySelection.h" #include "vtkDataArraySelection.h"
// Templates (only needed here)
#include "vtkPVFoamUpdateTemplates.C"
// * * * * * * * * * * * * * * * Private Classes * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Private Classes * * * * * * * * * * * * * * //
@ -85,14 +84,14 @@ template<class ZoneType>
Foam::wordList Foam::vtkPVFoam::getZoneNames Foam::wordList Foam::vtkPVFoam::getZoneNames
( (
const ZoneMesh<ZoneType, polyMesh>& zmesh const ZoneMesh<ZoneType, polyMesh>& zmesh
) const )
{ {
wordList names(zmesh.size()); wordList names(zmesh.size());
label nZone = 0; label nZone = 0;
forAll(zmesh, zoneI) forAll(zmesh, zoneI)
{ {
if (zmesh[zoneI].size()) if (!zmesh[zoneI].empty())
{ {
names[nZone++] = zmesh[zoneI].name(); names[nZone++] = zmesh[zoneI].name();
} }
@ -124,7 +123,7 @@ Foam::wordList Foam::vtkPVFoam::getZoneNames(const word& zoneType) const
false false
); );
if (ioObj.typeHeaderOk<cellZoneMesh>(false)) if (ioObj.typeHeaderOk<cellZoneMesh>(false, false))
{ {
zonesEntries zones(ioObj); zonesEntries zones(ioObj);
@ -146,7 +145,7 @@ void Foam::vtkPVFoam::updateInfoInternalMesh
{ {
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPVFoam::updateInfoInternalMesh" << endl; Info<< "<beg> updateInfoInternalMesh" << endl;
} }
// Determine mesh parts (internalMesh, patches...) // Determine mesh parts (internalMesh, patches...)
@ -160,10 +159,7 @@ void Foam::vtkPVFoam::updateInfoInternalMesh
if (debug) if (debug)
{ {
// just for debug info Info<< "<end> updateInfoInternalMesh" << endl;
getSelectedArrayEntries(arraySelection);
Info<< "<end> Foam::vtkPVFoam::updateInfoInternalMesh" << endl;
} }
} }
@ -175,7 +171,7 @@ void Foam::vtkPVFoam::updateInfoLagrangian
{ {
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPVFoam::updateInfoLagrangian" << nl Info<< "<beg> updateInfoLagrangian" << nl
<< " " << dbPtr_->timePath()/cloud::prefix << endl; << " " << dbPtr_->timePath()/cloud::prefix << endl;
} }
@ -211,10 +207,7 @@ void Foam::vtkPVFoam::updateInfoLagrangian
if (debug) if (debug)
{ {
// just for debug info Info<< "<end> updateInfoLagrangian" << endl;
getSelectedArrayEntries(arraySelection);
Info<< "<end> Foam::vtkPVFoam::updateInfoLagrangian" << endl;
} }
} }
@ -227,8 +220,8 @@ void Foam::vtkPVFoam::updateInfoPatches
{ {
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPVFoam::updateInfoPatches" Info<< "<beg> updateInfoPatches"
<< " [meshPtr=" << (meshPtr_ ? "set" : "nullptr") << "]" << endl; << " [meshPtr=" << (meshPtr_ ? "set" : "null") << "]" << endl;
} }
@ -333,7 +326,7 @@ void Foam::vtkPVFoam::updateInfoPatches
); );
// this should only ever fail if the mesh region doesn't exist // this should only ever fail if the mesh region doesn't exist
if (ioObj.typeHeaderOk<polyBoundaryMesh>(true)) if (ioObj.typeHeaderOk<polyBoundaryMesh>(true, false))
{ {
polyBoundaryMeshEntries patchEntries(ioObj); polyBoundaryMeshEntries patchEntries(ioObj);
@ -377,7 +370,7 @@ void Foam::vtkPVFoam::updateInfoPatches
} }
else else
{ {
groups.insert(groupNames[groupI], labelList(1, patchi)); groups.insert(groupNames[groupI], labelList{patchi});
} }
} }
} }
@ -455,10 +448,7 @@ void Foam::vtkPVFoam::updateInfoPatches
if (debug) if (debug)
{ {
// just for debug info Info<< "<end> updateInfoPatches" << endl;
getSelectedArrayEntries(arraySelection);
Info<< "<end> Foam::vtkPVFoam::updateInfoPatches" << endl;
} }
} }
@ -475,8 +465,8 @@ void Foam::vtkPVFoam::updateInfoZones
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPVFoam::updateInfoZones" Info<< "<beg> updateInfoZones"
<< " [meshPtr=" << (meshPtr_ ? "set" : "nullptr") << "]" << endl; << " [meshPtr=" << (meshPtr_ ? "set" : "null") << "]" << endl;
} }
wordList namesLst; wordList namesLst;
@ -551,10 +541,7 @@ void Foam::vtkPVFoam::updateInfoZones
if (debug) if (debug)
{ {
// just for debug info Info<< "<end> updateInfoZones" << endl;
getSelectedArrayEntries(arraySelection);
Info<< "<end> Foam::vtkPVFoam::updateInfoZones" << endl;
} }
} }
@ -571,7 +558,7 @@ void Foam::vtkPVFoam::updateInfoSets
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPVFoam::updateInfoSets" << endl; Info<< "<beg> updateInfoSets" << endl;
} }
// Add names of sets. Search for last time directory with a sets // Add names of sets. Search for last time directory with a sets
@ -596,7 +583,7 @@ void Foam::vtkPVFoam::updateInfoSets
if (debug) if (debug)
{ {
Info<< " Foam::vtkPVFoam::updateInfoSets read " Info<< " updateInfoSets read "
<< objects.names() << " from " << setsInstance << endl; << objects.names() << " from " << setsInstance << endl;
} }
@ -627,28 +614,41 @@ void Foam::vtkPVFoam::updateInfoSets
if (debug) if (debug)
{ {
// just for debug info Info<< "<end> updateInfoSets" << endl;
getSelectedArrayEntries(arraySelection);
Info<< "<end> Foam::vtkPVFoam::updateInfoSets" << endl;
} }
} }
void Foam::vtkPVFoam::updateInfoLagrangianFields() void Foam::vtkPVFoam::updateInfoFields()
{
updateInfoFields<fvPatchField, volMesh>
(
reader_->GetVolFieldSelection()
);
updateInfoFields<pointPatchField, pointMesh>
(
reader_->GetPointFieldSelection()
);
updateInfoLagrangianFields
(
reader_->GetLagrangianFieldSelection()
);
}
void Foam::vtkPVFoam::updateInfoLagrangianFields
(
vtkDataArraySelection* select
)
{ {
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPVFoam::updateInfoLagrangianFields" Info<< "<beg> updateInfoLagrangianFields" << endl;
<< endl;
} }
vtkDataArraySelection* fieldSelection =
reader_->GetLagrangianFieldSelection();
// preserve the enabled selections // preserve the enabled selections
stringList enabledEntries = getSelectedArrayEntries(fieldSelection); stringList enabledEntries = getSelectedArrayEntries(select);
fieldSelection->RemoveAllArrays(); select->RemoveAllArrays();
// TODO - currently only get fields from ONE cloud // TODO - currently only get fields from ONE cloud
// have to decide if the second set of fields get mixed in // have to decide if the second set of fields get mixed in
@ -678,44 +678,37 @@ void Foam::vtkPVFoam::updateInfoLagrangianFields()
lagrangianPrefix/cloudName lagrangianPrefix/cloudName
); );
addToSelection<IOField<label>> addToSelection<IOField<label>>(select, objects);
( addToSelection<IOField<scalar>>(select, objects);
fieldSelection, addToSelection<IOField<vector>>(select, objects);
objects addToSelection<IOField<sphericalTensor>>(select, objects);
); addToSelection<IOField<symmTensor>>(select, objects);
addToSelection<IOField<scalar>> addToSelection<IOField<tensor>>(select, objects);
(
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 // restore the enabled selections
setSelectedArrayEntries(fieldSelection, enabledEntries); setSelectedArrayEntries(select, enabledEntries);
if (debug > 1)
{
boolList status;
const label nElem = getSelected(status, select);
forAll(status, i)
{
Info<< " lagrangian[" << i << "] = "
<< status[i]
<< " : " << select->GetArrayName(i) << nl;
}
if (!nElem)
{
Info<< " lagrangian[none]" << nl;
}
}
if (debug) if (debug)
{ {
Info<< "<end> Foam::vtkPVFoam::updateInfoLagrangianFields - " Info<< "<end> updateInfoLagrangianFields - "
<< "lagrangian objects.size() = " << objects.size() << endl; << "lagrangian objects.size() = " << objects.size() << endl;
} }
} }

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -26,8 +26,8 @@ InClass
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef vtkPVFoamUpdateInfoFields_H #ifndef vtkPVFoamUpdateTemplates_C
#define vtkPVFoamUpdateInfoFields_H #define vtkPVFoamUpdateTemplates_C
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -39,19 +39,17 @@ void Foam::vtkPVFoam::updateInfoFields
{ {
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPVFoam::updateInfoFields <" Info<< "<beg> updateInfoFields <"
<< meshType::Mesh::typeName << meshType::Mesh::typeName
<< "> [meshPtr=" << (meshPtr_ ? "set" : "nullptr") << "]" << "> [meshPtr=" << (meshPtr_ ? "set" : "null") << "]"
<< endl; << endl;
} }
stringList enabledEntries; stringList enabledEntries;
// enable 'p' and 'U' on the first call if (!select->GetNumberOfArrays() && !meshPtr_)
if (select->GetNumberOfArrays() == 0 && !meshPtr_)
{ {
enabledEntries.setSize(2); // enable 'p' and 'U' only on the first call
enabledEntries[0] = "p"; enabledEntries = { "p", "U" };
enabledEntries[1] = "U";
} }
else else
{ {
@ -72,7 +70,7 @@ void Foam::vtkPVFoam::updateInfoFields
// Search for list of objects for this time and mesh region // Search for list of objects for this time and mesh region
IOobjectList objects(dbPtr_(), dbPtr_().timeName(), regionPrefix); IOobjectList objects(dbPtr_(), dbPtr_().timeName(), regionPrefix);
//- Add volume fields to GUI // Add volume fields to GUI
addToSelection<GeometricField<scalar, patchType, meshType>> addToSelection<GeometricField<scalar, patchType, meshType>>
( (
select, select,
@ -93,13 +91,14 @@ void Foam::vtkPVFoam::updateInfoFields
select, select,
objects objects
); );
addToSelection<GeometricField<tensor, patchType, meshType>> addToSelection<GeometricField<tensor, patchType, meshType>>
( (
select, select,
objects objects
); );
//- Add dimensioned fields to GUI // Add dimensioned fields to GUI
addToSelection<DimensionedField<scalar, meshType>> addToSelection<DimensionedField<scalar, meshType>>
( (
select, select,
@ -132,7 +131,7 @@ void Foam::vtkPVFoam::updateInfoFields
if (debug) if (debug)
{ {
Info<< "<end> Foam::vtkPVFoam::updateInfoFields" << endl; Info<< "<end> updateInfoFields" << endl;
} }
} }

View File

@ -1,340 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
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";
}
}
// ************************************************************************* //

View File

@ -1,456 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
InClass
vtkPVFoam
\*---------------------------------------------------------------------------*/
#ifndef vtkPVFoamVolFields_H
#define vtkPVFoamVolFields_H
// OpenFOAM includes
#include "emptyFvPatchField.H"
#include "wallPolyPatch.H"
#include "faceSet.H"
#include "volPointInterpolation.H"
#include "zeroGradientFvPatchField.H"
#include "vtkPVFoamFaceField.H"
#include "vtkPVFoamPatchField.H"
#include "vtkOpenFOAMTupleRemap.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
void Foam::vtkPVFoam::convertVolField
(
const PtrList<PrimitivePatchInterpolation<primitivePatch>>& ppInterpList,
const GeometricField<Type, fvPatchField, volMesh>& tf,
const bool interpFields,
vtkMultiBlockDataSet* output
)
{
const fvMesh& mesh = tf.mesh();
const polyBoundaryMesh& patches = mesh.boundaryMesh();
// Interpolated field (demand driven)
autoPtr<GeometricField<Type, pointPatchField, pointMesh>> ptfPtr;
if (interpFields)
{
if (debug)
{
Info<< "convertVolFieldBlock interpolating:" << tf.name()
<< endl;
}
ptfPtr.reset
(
volPointInterpolation::New(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(), 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::convertVolFields
(
const fvMesh& mesh,
const PtrList<PrimitivePatchInterpolation<primitivePatch>>& ppInterpList,
const IOobjectList& objects,
const bool interpFields,
vtkMultiBlockDataSet* output
)
{
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
);
// Convert
convertVolField(ppInterpList, tf, interpFields, output);
}
}
template<class Type>
void Foam::vtkPVFoam::convertDimFields
(
const fvMesh& mesh,
const PtrList<PrimitivePatchInterpolation<primitivePatch>>& ppInterpList,
const IOobjectList& objects,
const bool interpFields,
vtkMultiBlockDataSet* output
)
{
forAllConstIter(IOobjectList, objects, iter)
{
// restrict to DimensionedField<Type, ...>
if
(
iter()->headerClassName()
!= DimensionedField<Type, volMesh>::typeName
)
{
continue;
}
// Load field
DimensionedField<Type, volMesh> dimFld(*iter(), mesh);
// Construct volField with zero-gradient patch fields
IOobject io(dimFld);
io.readOpt() = IOobject::NO_READ;
PtrList<fvPatchField<Type>> patchFields(mesh.boundary().size());
forAll(patchFields, patchI)
{
patchFields.set
(
patchI,
fvPatchField<Type>::New
(
zeroGradientFvPatchField<scalar>::typeName,
mesh.boundary()[patchI],
dimFld
)
);
}
GeometricField<Type, fvPatchField, volMesh> volFld
(
io,
dimFld.mesh(),
dimFld.dimensions(),
dimFld,
patchFields
);
volFld.correctBoundaryConditions();
convertVolField(ppInterpList, volFld, interpFields, output);
}
}
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
// ************************************************************************* //

View File

@ -15,6 +15,7 @@ include_directories(
$ENV{WM_PROJECT_DIR}/src/OSspecific/$ENV{WM_OSTYPE}/lnInclude $ENV{WM_PROJECT_DIR}/src/OSspecific/$ENV{WM_OSTYPE}/lnInclude
$ENV{WM_PROJECT_DIR}/src/meshing/blockMesh/lnInclude $ENV{WM_PROJECT_DIR}/src/meshing/blockMesh/lnInclude
${PROJECT_SOURCE_DIR}/../vtkPVblockMesh ${PROJECT_SOURCE_DIR}/../vtkPVblockMesh
${PROJECT_SOURCE_DIR}/../../foamPv/lnInclude
) )
add_definitions( add_definitions(
@ -63,6 +64,7 @@ target_link_libraries(
PVblockMeshReader_SM PVblockMeshReader_SM
LINK_PUBLIC LINK_PUBLIC
vtkPVblockMesh-pv${PARAVIEW_VERSION_MAJOR}.${PARAVIEW_VERSION_MINOR} vtkPVblockMesh-pv${PARAVIEW_VERSION_MAJOR}.${PARAVIEW_VERSION_MINOR}
foamPv-pv${PARAVIEW_VERSION_MAJOR}.${PARAVIEW_VERSION_MINOR}
blockMesh blockMesh
OpenFOAM OpenFOAM
) )

View File

@ -56,8 +56,8 @@ vtkPVblockMeshReader::vtkPVblockMeshReader()
SetNumberOfInputPorts(0); SetNumberOfInputPorts(0);
FileName = nullptr; FileName = nullptr;
foamData_ = nullptr; backend_ = nullptr;
ShowPointNumbers = true; ShowPointNumbers = true;
@ -73,7 +73,6 @@ vtkPVblockMeshReader::vtkPVblockMeshReader()
); );
SelectionObserver->SetClientData(this); SelectionObserver->SetClientData(this);
BlockSelection->AddObserver BlockSelection->AddObserver
( (
vtkCommand::ModifiedEvent, vtkCommand::ModifiedEvent,
@ -94,11 +93,11 @@ vtkPVblockMeshReader::~vtkPVblockMeshReader()
{ {
vtkDebugMacro(<<"Destructor"); vtkDebugMacro(<<"Destructor");
if (foamData_) if (backend_)
{ {
// Remove point numbers // Remove point numbers
updatePointNumbersView(false); updatePointNumbersView(false);
delete foamData_; delete backend_;
} }
if (FileName) if (FileName)
@ -147,13 +146,13 @@ int vtkPVblockMeshReader::RequestInformation
} }
} }
if (!foamData_) if (!backend_)
{ {
foamData_ = new Foam::vtkPVblockMesh(FileName, this); backend_ = new Foam::vtkPVblockMesh(FileName, this);
} }
else else
{ {
foamData_->updateInfo(); backend_->updateInfo();
} }
return 1; return 1;
@ -176,7 +175,7 @@ int vtkPVblockMeshReader::RequestData
} }
// Catch previous error // Catch previous error
if (!foamData_) if (!backend_)
{ {
vtkErrorMacro("Reader failed - perhaps no mesh?"); vtkErrorMacro("Reader failed - perhaps no mesh?");
return 0; return 0;
@ -207,12 +206,11 @@ int vtkPVblockMeshReader::RequestData
<< output->GetNumberOfBlocks() << " blocks\n"; << output->GetNumberOfBlocks() << " blocks\n";
} }
backend_->Update(output);
foamData_->Update(output);
updatePointNumbersView(ShowPointNumbers); updatePointNumbersView(ShowPointNumbers);
// Do any cleanup on the OpenFOAM side // Do any cleanup on the OpenFOAM side
foamData_->CleanUp(); backend_->CleanUp();
return 1; return 1;
} }
@ -221,11 +219,11 @@ int vtkPVblockMeshReader::RequestData
void vtkPVblockMeshReader::SetRefresh(bool val) void vtkPVblockMeshReader::SetRefresh(bool val)
{ {
// Delete the current blockMesh to force re-read and update // Delete the current blockMesh to force re-read and update
if (foamData_) if (backend_)
{ {
updatePointNumbersView(false); updatePointNumbersView(false);
delete foamData_; delete backend_;
foamData_ = 0; backend_ = nullptr;
} }
Modified(); Modified();
@ -254,7 +252,7 @@ void vtkPVblockMeshReader::updatePointNumbersView(const bool show)
// Server manager model for querying items in the server manager // Server manager model for querying items in the server manager
pqServerManagerModel* smModel = appCore->getServerManagerModel(); pqServerManagerModel* smModel = appCore->getServerManagerModel();
if (!smModel || !foamData_) if (!smModel || !backend_)
{ {
return; return;
} }
@ -264,7 +262,7 @@ void vtkPVblockMeshReader::updatePointNumbersView(const bool show)
QList<pqRenderView*> renderViews = smModel->findItems<pqRenderView*>(); QList<pqRenderView*> renderViews = smModel->findItems<pqRenderView*>();
for (int viewI=0; viewI<renderViews.size(); ++viewI) for (int viewI=0; viewI<renderViews.size(); ++viewI)
{ {
foamData_->renderPointNumbers backend_->renderPointNumbers
( (
renderViews[viewI]->getRenderViewProxy()->GetRenderer(), renderViews[viewI]->getRenderViewProxy()->GetRenderer(),
show show
@ -283,7 +281,7 @@ void vtkPVblockMeshReader::PrintSelf(ostream& os, vtkIndent indent)
os << indent << "File name: " os << indent << "File name: "
<< (this->FileName ? this->FileName : "(none)") << "\n"; << (this->FileName ? this->FileName : "(none)") << "\n";
foamData_->PrintSelf(os, indent); backend_->PrintSelf(os, indent);
} }

View File

@ -114,7 +114,7 @@ protected:
vtkPVblockMeshReader(); vtkPVblockMeshReader();
//- Destructor //- Destructor
~vtkPVblockMeshReader(); virtual ~vtkPVblockMeshReader();
//- Return information about mesh, times, etc without loading anything //- Return information about mesh, times, etc without loading anything
virtual int RequestInformation virtual int RequestInformation
@ -160,7 +160,8 @@ private:
vtkDataArraySelection* CurvedEdgesSelection; vtkDataArraySelection* CurvedEdgesSelection;
Foam::vtkPVblockMesh* foamData_; //- Backend portion of the reader
Foam::vtkPVblockMesh* backend_;
}; };
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -1,5 +1,4 @@
vtkPVblockMesh.C vtkPVblockMesh.C
vtkPVblockMeshConvert.C vtkPVblockMeshConvert.C
vtkPVblockMeshUtils.C
LIB = $(FOAM_LIBBIN)/libvtkPVblockMesh-pv${ParaView_MAJOR} LIB = $(FOAM_LIBBIN)/libvtkPVblockMesh-pv${ParaView_MAJOR}

View File

@ -7,12 +7,12 @@ EXE_INC = \
-I$(LIB_SRC)/mesh/blockMesh/lnInclude \ -I$(LIB_SRC)/mesh/blockMesh/lnInclude \
-I$(ParaView_INCLUDE_DIR) \ -I$(ParaView_INCLUDE_DIR) \
-I$(ParaView_INCLUDE_DIR)/vtkkwiml \ -I$(ParaView_INCLUDE_DIR)/vtkkwiml \
-I../../vtkPVReaders/lnInclude \ -I../../foamPv/lnInclude \
-I../PVblockMeshReader -I../PVblockMeshReader
LIB_LIBS = \ LIB_LIBS = \
-lmeshTools \ -lmeshTools \
-lfileFormats \ -lfileFormats \
-lblockMesh \ -lblockMesh \
-L$(FOAM_LIBBIN) -lvtkPVReaders-pv${ParaView_MAJOR} \ -L$(FOAM_LIBBIN) -lfoamPv-pv${ParaView_MAJOR} \
$(GLIBS) $(GLIBS)

View File

@ -1,65 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
InClass
vtkPVblockMesh
\*---------------------------------------------------------------------------*/
#ifndef vtkOpenFOAMPoints_H
#define vtkOpenFOAMPoints_H
// VTK includes
#include "vtkPoints.h"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
inline void vtkInsertNextOpenFOAMPoint
(
vtkPoints *points,
const Foam::point& p
)
{
points->InsertNextPoint(p.x(), p.y(), p.z());
}
inline void vtkInsertNextOpenFOAMPoint
(
vtkPoints *points,
const Foam::point& p,
const Foam::scalar scaleFactor
)
{
points->InsertNextPoint
(
p.x()*scaleFactor,
p.y()*scaleFactor,
p.z()*scaleFactor
);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -67,8 +67,8 @@ void Foam::vtkPVblockMesh::updateInfoBlocks
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPVblockMesh::updateInfoBlocks" Info<< "<beg> updateInfoBlocks"
<< " [meshPtr=" << (meshPtr_ ? "set" : "nullptr") << "]" << endl; << " [meshPtr=" << (meshPtr_ ? "set" : "null") << "]" << endl;
} }
range.reset(arraySelection->GetNumberOfArrays()); range.reset(arraySelection->GetNumberOfArrays());
@ -99,10 +99,7 @@ void Foam::vtkPVblockMesh::updateInfoBlocks
if (debug) if (debug)
{ {
// just for debug info Info<< "<end> updateInfoBlocks" << endl;
getSelectedArrayEntries(arraySelection);
Info<< "<end> Foam::vtkPVblockMesh::updateInfoBlocks" << endl;
} }
} }
@ -116,8 +113,8 @@ void Foam::vtkPVblockMesh::updateInfoEdges
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPVblockMesh::updateInfoEdges" Info<< "<beg> updateInfoEdges"
<< " [meshPtr=" << (meshPtr_ ? "set" : "nullptr") << "]" << endl; << " [meshPtr=" << (meshPtr_ ? "set" : "null") << "]" << endl;
} }
range.reset(arraySelection->GetNumberOfArrays()); range.reset(arraySelection->GetNumberOfArrays());
@ -141,10 +138,7 @@ void Foam::vtkPVblockMesh::updateInfoEdges
if (debug) if (debug)
{ {
// just for debug info Info<< "<end> updateInfoEdges" << endl;
getSelectedArrayEntries(arraySelection);
Info<< "<end> Foam::vtkPVblockMesh::updateInfoEdges" << endl;
} }
} }
@ -168,8 +162,7 @@ Foam::vtkPVblockMesh::vtkPVblockMesh
{ {
if (debug) if (debug)
{ {
Info<< "Foam::vtkPVblockMesh::vtkPVblockMesh - " Info<< "vtkPVblockMesh - " << FileName << endl;
<< FileName << endl;
} }
// avoid argList and get rootPath/caseName directly from the file // avoid argList and get rootPath/caseName directly from the file
@ -255,7 +248,7 @@ Foam::vtkPVblockMesh::~vtkPVblockMesh()
{ {
if (debug) if (debug)
{ {
Info<< "<end> Foam::vtkPVblockMesh::~vtkPVblockMesh" << endl; Info<< "~vtkPVblockMesh" << endl;
} }
// Hmm. pointNumberTextActors are not getting removed // Hmm. pointNumberTextActors are not getting removed
@ -276,8 +269,8 @@ void Foam::vtkPVblockMesh::updateInfo()
{ {
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPVblockMesh::updateInfo" Info<< "<beg> updateInfo"
<< " [meshPtr=" << (meshPtr_ ? "set" : "nullptr") << "] " << endl; << " [meshPtr=" << (meshPtr_ ? "set" : "null") << "] " << endl;
} }
resetCounters(); resetCounters();
@ -285,8 +278,7 @@ void Foam::vtkPVblockMesh::updateInfo()
vtkDataArraySelection* blockSelection = reader_->GetBlockSelection(); vtkDataArraySelection* blockSelection = reader_->GetBlockSelection();
vtkDataArraySelection* edgeSelection = reader_->GetCurvedEdgesSelection(); vtkDataArraySelection* edgeSelection = reader_->GetCurvedEdgesSelection();
// enable 'internalMesh' on the first call // preserve the enabled selections if possible
// or preserve the enabled selections
stringList enabledParts; stringList enabledParts;
stringList enabledEdges; stringList enabledEdges;
const bool firstTime = (!blockSelection->GetNumberOfArrays() && !meshPtr_); const bool firstTime = (!blockSelection->GetNumberOfArrays() && !meshPtr_);
@ -313,12 +305,12 @@ void Foam::vtkPVblockMesh::updateInfo()
if (!firstTime) if (!firstTime)
{ {
setSelectedArrayEntries(blockSelection, enabledParts); setSelectedArrayEntries(blockSelection, enabledParts);
setSelectedArrayEntries(edgeSelection, enabledEdges); setSelectedArrayEntries(edgeSelection, enabledEdges);
} }
if (debug) if (debug)
{ {
Info<< "<end> Foam::vtkPVblockMesh::updateInfo" << endl; Info<< "<end> updateInfo" << endl;
} }
} }
@ -327,7 +319,7 @@ void Foam::vtkPVblockMesh::updateFoamMesh()
{ {
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPVblockMesh::updateFoamMesh" << endl; Info<< "<beg> updateFoamMesh" << endl;
} }
// Check to see if the OpenFOAM mesh has been created // Check to see if the OpenFOAM mesh has been created
@ -377,7 +369,7 @@ void Foam::vtkPVblockMesh::updateFoamMesh()
if (debug) if (debug)
{ {
Info<< "<end> Foam::vtkPVblockMesh::updateFoamMesh" << endl; Info<< "<end> updateFoamMesh" << endl;
} }
} }
@ -390,10 +382,10 @@ void Foam::vtkPVblockMesh::Update
reader_->UpdateProgress(0.1); reader_->UpdateProgress(0.1);
// Set up mesh parts selection(s) // Set up mesh parts selection(s)
updateBoolListStatus(blockStatus_, reader_->GetBlockSelection()); getSelected(blockStatus_, reader_->GetBlockSelection());
// Set up curved edges selection(s) // Set up curved edges selection(s)
updateBoolListStatus(edgeStatus_, reader_->GetCurvedEdgesSelection()); getSelected(edgeStatus_, reader_->GetCurvedEdgesSelection());
reader_->UpdateProgress(0.2); reader_->UpdateProgress(0.2);

View File

@ -41,10 +41,7 @@ SourceFiles
#ifndef vtkPVblockMesh_H #ifndef vtkPVblockMesh_H
#define vtkPVblockMesh_H #define vtkPVblockMesh_H
#include "className.H" #include "foamPvCore.H"
#include "fileName.H"
#include "stringList.H"
#include "wordList.H"
// * * * * * * * * * * * * * Forward Declarations * * * * * * * * * * * * * // // * * * * * * * * * * * * * Forward Declarations * * * * * * * * * * * * * //
@ -76,85 +73,9 @@ template<class Type> class List;
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class vtkPVblockMesh class vtkPVblockMesh
:
private foamPvCore
{ {
// Private classes
//- Bookkeeping for GUI checklists and the multi-block organization
class arrayRange
{
const char *name_;
int block_;
int start_;
int size_;
public:
arrayRange(const char *name, const int blockNo=0)
:
name_(name),
block_(blockNo),
start_(0),
size_(0)
{}
//- Return the block holding these datasets
int block() const
{
return block_;
}
//- Assign block number, return previous value
int block(int blockNo)
{
int prev = block_;
block_ = blockNo;
return prev;
}
//- Return block name
const char* name() const
{
return name_;
}
//- Return array start index
int start() const
{
return start_;
}
//- Return array end index
int end() const
{
return start_ + size_;
}
//- Return sublist size
int size() const
{
return size_;
}
bool empty() const
{
return !size_;
}
//- Reset the size to zero and optionally assign a new start
void reset(const int startAt = 0)
{
start_ = startAt;
size_ = 0;
}
//- Increment the size
void operator+=(const int n)
{
size_ += n;
}
};
// Private Data // Private Data
//- Access to the controlling vtkPVblockMeshReader //- Access to the controlling vtkPVblockMeshReader
@ -194,24 +115,6 @@ class vtkPVblockMesh
// Private Member Functions // 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
);
//- Update boolList from GUI selection
static void updateBoolListStatus
(
boolList&,
vtkDataArraySelection*
);
//- Reset data counters //- Reset data counters
void resetCounters(); void resetCounters();
@ -240,36 +143,6 @@ class vtkPVblockMesh
void convertMeshCorners(vtkMultiBlockDataSet*, int& blockNo); void convertMeshCorners(vtkMultiBlockDataSet*, int& blockNo);
// GUI selection helper functions
//- Retrieve the current selections
static wordHashSet getSelected(vtkDataArraySelection*);
//- Retrieve a sub-list of the current selections
static wordHashSet getSelected
(
vtkDataArraySelection*,
const arrayRange&
);
//- Retrieve the current selections
static stringList getSelectedArrayEntries(vtkDataArraySelection*);
//- Retrieve a sub-list of the current selections
static stringList getSelectedArrayEntries
(
vtkDataArraySelection*,
const arrayRange&
);
//- Set selection(s)
static void setSelectedArrayEntries
(
vtkDataArraySelection*,
const stringList&
);
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
vtkPVblockMesh(const vtkPVblockMesh&) = delete; vtkPVblockMesh(const vtkPVblockMesh&) = delete;

View File

@ -30,8 +30,6 @@ License
#include "blockMesh.H" #include "blockMesh.H"
#include "Time.H" #include "Time.H"
#include "vtkOpenFOAMPoints.H"
// VTK includes // VTK includes
#include "vtkCellArray.h" #include "vtkCellArray.h"
#include "vtkDataArraySelection.h" #include "vtkDataArraySelection.h"
@ -41,6 +39,26 @@ License
#include "vtkUnstructuredGrid.h" #include "vtkUnstructuredGrid.h"
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
//! \cond fileScope
inline static void insertNextPoint
(
vtkPoints *points,
const Foam::point& p,
const Foam::scalar scaleFactor
)
{
points->InsertNextPoint
(
p.x()*scaleFactor,
p.y()*scaleFactor,
p.z()*scaleFactor
);
}
//! \endcond
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::vtkPVblockMesh::convertMeshBlocks void Foam::vtkPVblockMesh::convertMeshBlocks
@ -59,7 +77,7 @@ void Foam::vtkPVblockMesh::convertMeshBlocks
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPVblockMesh::convertMeshBlocks" << endl; Info<< "<beg> convertMeshBlocks" << endl;
} }
int blockI = 0; int blockI = 0;
@ -79,19 +97,16 @@ void Foam::vtkPVblockMesh::convertMeshBlocks
const blockDescriptor& blockDef = blkMesh[blockI]; const blockDescriptor& blockDef = blkMesh[blockI];
vtkUnstructuredGrid* vtkmesh = vtkUnstructuredGrid::New();
// Convert OpenFOAM mesh vertices to VTK // Convert OpenFOAM mesh vertices to VTK
vtkPoints *vtkpoints = vtkPoints::New(); vtkPoints *vtkpoints = vtkPoints::New();
vtkpoints->Allocate( blockDef.nPoints() ); vtkpoints->Allocate(blockDef.nPoints());
const labelList& blockLabels = blockDef.blockShape(); const labelList& blockLabels = blockDef.blockShape();
vtkmesh->Allocate(1);
vtkIdType nodeIds[8]; vtkIdType nodeIds[8];
forAll(blockLabels, ptI) forAll(blockLabels, ptI)
{ {
vtkInsertNextOpenFOAMPoint insertNextPoint
( (
vtkpoints, vtkpoints,
blockPoints[blockLabels[ptI]], blockPoints[blockLabels[ptI]],
@ -101,6 +116,8 @@ void Foam::vtkPVblockMesh::convertMeshBlocks
nodeIds[ptI] = ptI; nodeIds[ptI] = ptI;
} }
vtkUnstructuredGrid* vtkmesh = vtkUnstructuredGrid::New();
vtkmesh->Allocate(1);
vtkmesh->InsertNextCell vtkmesh->InsertNextCell
( (
VTK_HEXAHEDRON, VTK_HEXAHEDRON,
@ -111,7 +128,7 @@ void Foam::vtkPVblockMesh::convertMeshBlocks
vtkmesh->SetPoints(vtkpoints); vtkmesh->SetPoints(vtkpoints);
vtkpoints->Delete(); vtkpoints->Delete();
AddToBlock addToBlock
( (
output, vtkmesh, range, datasetNo, output, vtkmesh, range, datasetNo,
selection->GetArrayName(partId) selection->GetArrayName(partId)
@ -130,7 +147,7 @@ void Foam::vtkPVblockMesh::convertMeshBlocks
if (debug) if (debug)
{ {
Info<< "<end> Foam::vtkPVblockMesh::convertMeshBlocks" << endl; Info<< "<end> convertMeshBlocks" << endl;
} }
} }
@ -201,7 +218,7 @@ void Foam::vtkPVblockMesh::convertMeshEdges
vtkIdType pointIds[edgePoints.size()]; vtkIdType pointIds[edgePoints.size()];
forAll(edgePoints, ptI) forAll(edgePoints, ptI)
{ {
vtkInsertNextOpenFOAMPoint insertNextPoint
( (
vtkpoints, vtkpoints,
edgePoints[ptI], edgePoints[ptI],
@ -220,7 +237,7 @@ void Foam::vtkPVblockMesh::convertMeshEdges
vtkmesh->SetPoints(vtkpoints); vtkmesh->SetPoints(vtkpoints);
vtkpoints->Delete(); vtkpoints->Delete();
AddToBlock addToBlock
( (
output, vtkmesh, range, datasetNo, output, vtkmesh, range, datasetNo,
selection->GetArrayName(partId) selection->GetArrayName(partId)
@ -242,7 +259,7 @@ void Foam::vtkPVblockMesh::convertMeshEdges
if (debug) if (debug)
{ {
Info<< "<end> Foam::vtkPVblockMesh::convertMeshEdges" << endl; Info<< "<end> convertMeshEdges" << endl;
} }
} }
@ -263,7 +280,7 @@ void Foam::vtkPVblockMesh::convertMeshCorners
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPVblockMesh::convertMeshCorners" << endl; Info<< "<beg> convertMeshCorners" << endl;
} }
if (true) // or some flag or other condition if (true) // or some flag or other condition
@ -278,7 +295,7 @@ void Foam::vtkPVblockMesh::convertMeshCorners
vtkIdType pointId = 0; vtkIdType pointId = 0;
forAll(blockPoints, ptI) forAll(blockPoints, ptI)
{ {
vtkInsertNextOpenFOAMPoint insertNextPoint
( (
vtkpoints, vtkpoints,
blockPoints[ptI], blockPoints[ptI],
@ -295,7 +312,7 @@ void Foam::vtkPVblockMesh::convertMeshCorners
vtkmesh->SetVerts(vtkcells); vtkmesh->SetVerts(vtkcells);
vtkcells->Delete(); vtkcells->Delete();
AddToBlock(output, vtkmesh, range, datasetNo, range.name()); addToBlock(output, vtkmesh, range, datasetNo, range.name());
vtkmesh->Delete(); vtkmesh->Delete();
datasetNo++; datasetNo++;
@ -309,7 +326,7 @@ void Foam::vtkPVblockMesh::convertMeshCorners
if (debug) if (debug)
{ {
Info<< "<end> Foam::vtkPVblockMesh::convertMeshCorners" << endl; Info<< "<end> convertMeshCorners" << endl;
} }
} }

View File

@ -1,316 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
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 "vtkPVblockMesh.H"
#include "vtkPVblockMeshReader.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::vtkPVblockMesh::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()
);
}
}
Foam::wordHashSet Foam::vtkPVblockMesh::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::vtkPVblockMesh::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::vtkPVblockMesh::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::vtkPVblockMesh::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::vtkPVblockMesh::setSelectedArrayEntries
(
vtkDataArraySelection* select,
const stringList& selections
)
{
const int nElem = select->GetNumberOfArrays();
select->DisableAllArrays();
// Loop through entries, setting values from selectedEntries
for (int elemI=0; elemI < nElem; ++elemI)
{
string arrayName(select->GetArrayName(elemI));
forAll(selections, elemI)
{
if (selections[elemI] == arrayName)
{
select->EnableArray(arrayName.c_str());
break;
}
}
}
}
void Foam::vtkPVblockMesh::updateBoolListStatus
(
boolList& status,
vtkDataArraySelection* selection
)
{
if (debug)
{
Info<< "<beg> Foam::vtkPVblockMesh::updateBoolListStatus" << endl;
}
const label nElem = selection->GetNumberOfArrays();
if (status.size() != nElem)
{
status.setSize(nElem);
status = false;
}
forAll(status, elemI)
{
const int setting = selection->GetArraySetting(elemI);
status[elemI] = setting;
if (debug)
{
Info<< " part[" << elemI << "] = "
<< status[elemI]
<< " : " << selection->GetArrayName(elemI) << endl;
}
}
if (debug)
{
Info<< "<end> Foam::vtkPVblockMesh::updateBoolListStatus" << endl;
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// ************************************************************************* //

View File

@ -0,0 +1,3 @@
foamPvCore.C
LIB = $(FOAM_LIBBIN)/libfoamPv-pv${ParaView_MAJOR}

View File

@ -2,6 +2,7 @@ sinclude $(GENERAL_RULES)/paraview
EXE_INC = \ EXE_INC = \
${c++LESSWARN} \ ${c++LESSWARN} \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(ParaView_INCLUDE_DIR) \ -I$(ParaView_INCLUDE_DIR) \
-I$(ParaView_INCLUDE_DIR)/vtkkwiml -I$(ParaView_INCLUDE_DIR)/vtkkwiml

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -21,17 +21,13 @@ License
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
Misc helper methods and utilities
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "vtkPVReaders.H" #include "foamPvCore.H"
// OpenFOAM includes #include "memInfo.H"
#include "IFstream.H" #include "DynamicList.H"
// VTK includes
#include "vtkDataArraySelection.h" #include "vtkDataArraySelection.h"
#include "vtkDataSet.h" #include "vtkDataSet.h"
#include "vtkMultiBlockDataSet.h" #include "vtkMultiBlockDataSet.h"
@ -41,57 +37,28 @@ Description
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(vtkPVReaders, 0); defineTypeNameAndDebug(foamPvCore, 0);
} }
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // void Foam::foamPvCore::addToBlock
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::vtkPVReaders::AddToBlock
( (
vtkMultiBlockDataSet* output, vtkMultiBlockDataSet* output,
vtkDataSet* dataset, vtkDataSet* dataset,
const partInfo& selector, const arrayRange& selector,
const label datasetNo, const label datasetNo,
const std::string& datasetName const std::string& datasetName
) )
{ {
const int blockNo = selector.block(); const int blockNo = selector.block();
vtkDataObject* blockDO = output->GetBlock(blockNo); vtkDataObject* dataObj = output->GetBlock(blockNo);
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO); vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(dataObj);
if (!block) if (!block)
{ {
if (blockDO) if (dataObj)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Block already has a vtkDataSet assigned to it" << "Block already has a vtkDataSet assigned to it"
@ -114,7 +81,7 @@ void Foam::vtkPVReaders::AddToBlock
block->SetBlock(datasetNo, dataset); block->SetBlock(datasetNo, dataset);
// name the block when assigning dataset 0 // name the output block when assigning dataset 0
if (datasetNo == 0) if (datasetNo == 0)
{ {
output->GetMetaData(blockNo)->Set output->GetMetaData(blockNo)->Set
@ -135,38 +102,19 @@ void Foam::vtkPVReaders::AddToBlock
} }
vtkDataSet* Foam::vtkPVReaders::GetDataSetFromBlock int Foam::foamPvCore::getNumberOfDataSets
( (
vtkMultiBlockDataSet* output, vtkMultiBlockDataSet* output,
const partInfo& selector, const arrayRange& selector
const label datasetNo
) )
{ {
const int blockNo = selector.block(); const int blockNo = selector.block();
vtkDataObject* blockDO = output->GetBlock(blockNo); vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO); (
output->GetBlock(blockNo)
);
if (block)
{
return vtkDataSet::SafeDownCast(block->GetBlock(datasetNo));
}
return 0;
}
// ununsed at the moment
Foam::label Foam::vtkPVReaders::GetNumberOfDataSets
(
vtkMultiBlockDataSet* output,
const partInfo& selector
)
{
const int blockNo = selector.block();
vtkDataObject* blockDO = output->GetBlock(blockNo);
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO);
if (block) if (block)
{ {
return block->GetNumberOfBlocks(); return block->GetNumberOfBlocks();
@ -176,54 +124,76 @@ Foam::label Foam::vtkPVReaders::GetNumberOfDataSets
} }
// Foam::word Foam::vtkPVReaders::getPartName(int partId) int Foam::foamPvCore::getSelected
// { (
// return getFirstWord(reader_->GetPartArrayName(partId)); boolList& status,
// } vtkDataArraySelection* selection
)
{
const int n = selection->GetNumberOfArrays();
if (status.size() != n)
{
status.setSize(n);
status = false;
}
int count = 0;
forAll(status, i)
{
const bool setting = selection->GetArraySetting(i);
if (setting)
{
++count;
}
status[i] = setting;
}
return count;
}
Foam::wordHashSet Foam::vtkPVReaders::getSelected Foam::hashedWordList Foam::foamPvCore::getSelected
( (
vtkDataArraySelection* select vtkDataArraySelection* select
) )
{ {
int nElem = select->GetNumberOfArrays(); const int n = select->GetNumberOfArrays();
wordHashSet selections(2*nElem); DynamicList<word> selected(n);
for (int elemI=0; elemI < nElem; ++elemI) for (int i=0; i < n; ++i)
{ {
if (select->GetArraySetting(elemI)) if (select->GetArraySetting(i))
{ {
selections.insert(getFirstWord(select->GetArrayName(elemI))); selected.append(getFirstWord(select->GetArrayName(i)));
} }
} }
return selections; return hashedWordList(selected, true);
} }
Foam::wordHashSet Foam::vtkPVReaders::getSelected Foam::hashedWordList Foam::foamPvCore::getSelected
( (
vtkDataArraySelection* select, vtkDataArraySelection* select,
const partInfo& selector const arrayRange& selector
) )
{ {
int nElem = select->GetNumberOfArrays(); const int n = select->GetNumberOfArrays();
wordHashSet selections(2*nElem); DynamicList<word> selected(n);
for (int elemI = selector.start(); elemI < selector.end(); ++elemI) for (int i = selector.start(); i < selector.end(); ++i)
{ {
if (select->GetArraySetting(elemI)) if (select->GetArraySetting(i))
{ {
selections.insert(getFirstWord(select->GetArrayName(elemI))); selected.append(getFirstWord(select->GetArrayName(i)));
} }
} }
return selections; return hashedWordList(selected, true);
} }
Foam::stringList Foam::vtkPVReaders::getSelectedArrayEntries Foam::stringList Foam::foamPvCore::getSelectedArrayEntries
( (
vtkDataArraySelection* select vtkDataArraySelection* select
) )
@ -240,14 +210,13 @@ Foam::stringList Foam::vtkPVReaders::getSelectedArrayEntries
} }
selections.setSize(nElem); selections.setSize(nElem);
if (debug > 1)
if (debug)
{ {
label nElem = select->GetNumberOfArrays(); const int n = select->GetNumberOfArrays();
Info<< "available("; Info<< "available(";
for (int elemI = 0; elemI < nElem; ++elemI) for (int i=0; i < n; ++i)
{ {
Info<< " \"" << select->GetArrayName(elemI) << "\""; Info<< " \"" << select->GetArrayName(i) << "\"";
} }
Info<< " )\nselected("; Info<< " )\nselected(";
@ -262,31 +231,30 @@ Foam::stringList Foam::vtkPVReaders::getSelectedArrayEntries
} }
Foam::stringList Foam::vtkPVReaders::getSelectedArrayEntries Foam::stringList Foam::foamPvCore::getSelectedArrayEntries
( (
vtkDataArraySelection* select, vtkDataArraySelection* select,
const partInfo& selector const arrayRange& selector
) )
{ {
stringList selections(selector.size()); stringList selections(selector.size());
label nElem = 0; label nElem = 0;
for (int elemI = selector.start(); elemI < selector.end(); ++elemI) for (int i = selector.start(); i < selector.end(); ++i)
{ {
if (select->GetArraySetting(elemI)) if (select->GetArraySetting(i))
{ {
selections[nElem++] = select->GetArrayName(elemI); selections[nElem++] = select->GetArrayName(i);
} }
} }
selections.setSize(nElem); selections.setSize(nElem);
if (debug > 1)
if (debug)
{ {
Info<< "available("; Info<< "available(";
for (int elemI = selector.start(); elemI < selector.end(); ++elemI) for (int i = selector.start(); i < selector.end(); ++i)
{ {
Info<< " \"" << select->GetArrayName(elemI) << "\""; Info<< " \"" << select->GetArrayName(i) << "\"";
} }
Info<< " )\nselected("; Info<< " )\nselected(";
@ -301,19 +269,19 @@ Foam::stringList Foam::vtkPVReaders::getSelectedArrayEntries
} }
void Foam::vtkPVReaders::setSelectedArrayEntries void Foam::foamPvCore::setSelectedArrayEntries
( (
vtkDataArraySelection* select, vtkDataArraySelection* select,
const stringList& selections const stringList& selections
) )
{ {
const int nElem = select->GetNumberOfArrays(); const int n = select->GetNumberOfArrays();
select->DisableAllArrays(); select->DisableAllArrays();
// Loop through entries, setting values from selectedEntries // Loop through entries, setting values from selectedEntries
for (int elemI=0; elemI < nElem; ++elemI) for (int i=0; i < n; ++i)
{ {
string arrayName(select->GetArrayName(elemI)); const string arrayName(select->GetArrayName(i));
forAll(selections, elemI) forAll(selections, elemI)
{ {
@ -327,7 +295,33 @@ void Foam::vtkPVReaders::setSelectedArrayEntries
} }
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // Foam::word Foam::foamPvCore::getFirstWord(const char* str)
{
if (str)
{
label n = 0;
while (str[n] && word::valid(str[n]))
{
++n;
}
// don't need to re-check for invalid chars
return word(str, n, false);
}
else
{
return word::null;
}
}
void Foam::foamPvCore::printMemory()
{
memInfo mem;
if (mem.valid())
{
Info<< "mem peak/size/rss: " << mem << endl;
}
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -21,39 +21,33 @@ License
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Namespace
Foam::vtkPVReaders
Description Description
A collection of helper functions when building a reader interface in Helpers for OpenFOAM reader interfaces in ParaView.
ParaView3.
SourceFiles SourceFiles
vtkPVReaders.C foamPvCore.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef vtkPVReaders_H #ifndef foamPvCore_H
#define vtkPVReaders_H #define foamPvCore_H
#include "className.H" #include "className.H"
#include "fileName.H" #include "fileName.H"
#include "stringList.H" #include "stringList.H"
#include "boolList.H"
#include "pointList.H"
#include "wordList.H" #include "wordList.H"
#include "HashSet.H" #include "Hash.H"
#include "hashedWordList.H"
#include "vtkPoints.h"
// * * * * * * * * * * * * * Forward Declarations * * * * * * * * * * * * * // // * * * * * * * * * * * * * Forward Declarations * * * * * * * * * * * * * //
class vtkDataArraySelection; class vtkDataArraySelection;
class vtkDataSet; class vtkDataSet;
class vtkPoints;
class vtkPVFoamReader;
class vtkRenderer;
class vtkTextActor;
class vtkMultiBlockDataSet; class vtkMultiBlockDataSet;
class vtkPolyData;
class vtkUnstructuredGrid;
class vtkIndent; class vtkIndent;
@ -61,13 +55,20 @@ class vtkIndent;
namespace Foam namespace Foam
{ {
namespace vtkPVReaders
{
//- Declare name of the class and its debug switch
NamespaceName("vtkPVReaders");
//- Bookkeeping for GUI checklists and the multi-block organization class IOobjectList;
class partInfo
/*---------------------------------------------------------------------------*\
Class foamPvCore Declaration
\*---------------------------------------------------------------------------*/
class foamPvCore
{
public:
//- Bookkeeping for GUI checklists and multi-block organization
// Works like a SubList selection.
class arrayRange
{ {
const char *name_; const char *name_;
int block_; int block_;
@ -76,11 +77,12 @@ namespace vtkPVReaders
public: public:
partInfo(const char *name, const int blockNo=0) //- Construct with given name for the specified block
arrayRange(const char *name, const int blockNo=0)
: :
name_(name), name_(name),
block_(blockNo), block_(blockNo),
start_(-1), start_(0),
size_(0) size_(0)
{} {}
@ -98,42 +100,47 @@ namespace vtkPVReaders
return prev; return prev;
} }
//- Return the name
const char* name() const const char* name() const
{ {
return name_; return name_;
} }
//- The array start index
int start() const int start() const
{ {
return start_; return start_;
} }
//- The array end index
int end() const int end() const
{ {
return start_ + size_; return start_ + size_;
} }
//- The sub-list size
int size() const int size() const
{ {
return size_; return size_;
} }
//- True if the sub-list is empty
bool empty() const bool empty() const
{ {
return !size_; return !size_;
} }
void reset() //- Reset the size to zero and optionally assign a new start
void reset(const int startAt = 0)
{ {
start_ = -1; start_ = startAt;
size_ = 0; size_ = 0;
} }
//- Assign new start and reset the size //- Assign new start and reset the size
void operator=(const int i) void operator=(const int i)
{ {
start_ = i; reset(i);
size_ = 0;
} }
//- Increment the size //- Increment the size
@ -141,81 +148,132 @@ namespace vtkPVReaders
{ {
size_ += n; size_ += n;
} }
};
}; // End class arrayRange
//- Convenience method use to convert the readers from VTK 5 private:
// multiblock API to the current composite data infrastructure
void AddToBlock // Private Member Functions
//- Disallow default bitwise copy construct
foamPvCore(const foamPvCore&) = delete;
//- Disallow default bitwise assignment
void operator=(const foamPvCore&) = delete;
public:
//- Static data members
ClassName("foamPvCore");
//- Construct null
foamPvCore()
{}
//- Convenience method for the VTK multiblock API
static void addToBlock
( (
vtkMultiBlockDataSet* output, vtkMultiBlockDataSet* output,
vtkDataSet* dataset, vtkDataSet* dataset,
const partInfo& selector, const arrayRange& selector,
const label datasetNo, const label datasetNo,
const std::string& datasetName const std::string& datasetName
); );
//- Convenience method for the VTK multiblock API
//- Convenience method use to convert the readers from VTK 5 // Always returns a nullptr if datasetNo is negative
// multiblock API to the current composite data infrastructure template<class Type=vtkDataSet>
vtkDataSet* GetDataSetFromBlock static Type* getDataFromBlock
( (
vtkMultiBlockDataSet* output, vtkMultiBlockDataSet* output,
const partInfo& selector, const arrayRange& selector,
const label datasetNo const label datasetNo
); );
//- Convenience method use to convert the readers from VTK 5 //- Convenience method for the VTK multiblock API
// multiblock API to the current composite data infrastructure static int getNumberOfDataSets
// ununsed at the moment
label GetNumberOfDataSets
( (
vtkMultiBlockDataSet* output, vtkMultiBlockDataSet* output,
const partInfo& selector const arrayRange& selector
);
//- Add objects of Type to array selection
template<class Type>
static label addToSelection
(
vtkDataArraySelection* select,
const IOobjectList& objects,
const string& suffix = string::null
); );
//- Retrieve the current selections into a boolList
static int getSelected
(
boolList& lst,
vtkDataArraySelection* select
);
//- Retrieve the current selections as a wordHashSet //- Retrieve the current selections as a wordHashSet
wordHashSet getSelected static hashedWordList getSelected
( (
vtkDataArraySelection* select vtkDataArraySelection* select
); );
//- Retrieve a sub-list of the current selections //- Retrieve a sub-list of the current selections
wordHashSet getSelected static hashedWordList getSelected
( (
vtkDataArraySelection*, vtkDataArraySelection* select,
const partInfo& const arrayRange& selector
); );
//- Retrieve the current selections //- Retrieve the current selections
stringList getSelectedArrayEntries(vtkDataArraySelection*); static stringList getSelectedArrayEntries
(
vtkDataArraySelection* select
);
//- Retrieve a sub-list of the current selections //- Retrieve a sub-list of the current selections
stringList getSelectedArrayEntries static stringList getSelectedArrayEntries
( (
vtkDataArraySelection* select, vtkDataArraySelection* select,
const partInfo& selector const arrayRange& selector
); );
//- Set selection(s) //- Set selection(s)
void setSelectedArrayEntries static void setSelectedArrayEntries
( (
vtkDataArraySelection*, vtkDataArraySelection* select,
const stringList& const stringList& selections
); );
//- Extract up to the first non-word characters
static word getFirstWord(const char* str);
//- Simple memory used debugging information
static void printMemory();
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace vtkPV }; // End class foamPvCore
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "foamPvCoreTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif #endif

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -23,43 +23,57 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef vtkPVFoamAddToSelection_H
#define vtkPVFoamAddToSelection_H
// OpenFOAM includes
#include "IOobjectList.H" #include "IOobjectList.H"
#include "SortableList.H"
// VTK includes
#include "vtkDataArraySelection.h" #include "vtkDataArraySelection.h"
#include "vtkMultiBlockDataSet.h"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type> template<class Type>
Foam::label Foam::vtkPVFoam::addToSelection Type* Foam::foamPvCore::getDataFromBlock
(
vtkMultiBlockDataSet* output,
const arrayRange& selector,
const label datasetNo
)
{
const int blockNo = selector.block();
vtkMultiBlockDataSet* block =
(
datasetNo < 0
? nullptr
: vtkMultiBlockDataSet::SafeDownCast(output->GetBlock(blockNo))
);
if (block)
{
return Type::SafeDownCast(block->GetBlock(datasetNo));
}
return nullptr;
}
template<class Type>
Foam::label Foam::foamPvCore::addToSelection
( (
vtkDataArraySelection *select, vtkDataArraySelection *select,
const IOobjectList& objectLst, const IOobjectList& objects,
const string& suffix const string& suffix
) )
{ {
SortableList<word> names(objectLst.names(Type::typeName)); const wordList names = objects.sortedNames(Type::typeName);
forAll(names, nameI) forAll(names, i)
{ {
if (suffix.size()) if (suffix.empty())
{ {
select->AddArray select->AddArray(names[i].c_str());
(
(names[nameI] + suffix).c_str()
);
} }
else else
{ {
select->AddArray select->AddArray((names[i] + suffix).c_str());
(
(names[nameI]).c_str()
);
} }
} }
@ -67,8 +81,4 @@ Foam::label Foam::vtkPVFoam::addToSelection
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* // // ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -21,36 +21,57 @@ License
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
InClass Description
vtkPVFoam Helpers for OpenFOAM reader interfaces in ParaView.
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef vtkOpenFOAMTupleRemap_H #ifndef foamPvFields_H
#define vtkOpenFOAMTupleRemap_H #define foamPvFields_H
// OpenFOAM includes #include "volFields.H"
#include "Swap.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type> namespace Foam
inline void vtkOpenFOAMTupleRemap(float vec[]); {
/*---------------------------------------------------------------------------*\
Class foamPvFields Declaration
\*---------------------------------------------------------------------------*/
class foamPvFields
{
// Private Member Functions
//- Disallow default bitwise copy construct
foamPvFields(const foamPvFields&) = delete;
//- Disallow default bitwise assignment
void operator=(const foamPvFields&) = delete;
public:
//- Remapping for some data types
template<class Type>
inline static void remapTuple(float vec[])
{}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
}; // End class foamPvFields
// Template specialization for symmTensor // Template specialization for symmTensor
template<> template<>
inline void vtkOpenFOAMTupleRemap<Foam::symmTensor>(float vec[]) inline void Foam::foamPvFields::remapTuple<Foam::symmTensor>(float vec[])
{ {
Foam::Swap(vec[1], vec[3]); // swap XY <-> YY Foam::Swap(vec[1], vec[3]); // swap XY <-> YY
Foam::Swap(vec[2], vec[5]); // swap XZ <-> ZZ Foam::Swap(vec[2], vec[5]); // swap XZ <-> ZZ
} }
template<class Type> } // End namespace Foam
inline void vtkOpenFOAMTupleRemap(float vec[])
{}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -1,3 +0,0 @@
vtkPVReaders.C
LIB = $(FOAM_LIBBIN)/libvtkPVReaders-pv${ParaView_MAJOR}