mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
cd ${0%/*} || exit 1 # Run from this directory
|
||||
|
||||
wclean libso vtkPVReaders
|
||||
wclean libso foamPv
|
||||
PVblockMeshReader/Allwclean
|
||||
PVFoamReader/Allwclean
|
||||
|
||||
|
||||
@ -97,7 +97,7 @@ case "$major" in
|
||||
if canBuildPlugin
|
||||
then
|
||||
(
|
||||
wmakeLibPv vtkPVReaders
|
||||
wmakeLibPv foamPv
|
||||
PVblockMeshReader/Allwmake $targetType $*
|
||||
PVFoamReader/Allwmake $targetType $*
|
||||
|
||||
|
||||
@ -15,6 +15,7 @@ include_directories(
|
||||
$ENV{WM_PROJECT_DIR}/src/OSspecific/$ENV{WM_OSTYPE}/lnInclude
|
||||
$ENV{WM_PROJECT_DIR}/src/finiteVolume/lnInclude
|
||||
${PROJECT_SOURCE_DIR}/../vtkPVFoam
|
||||
${PROJECT_SOURCE_DIR}/../../foamPv/lnInclude
|
||||
)
|
||||
|
||||
add_definitions(
|
||||
@ -63,6 +64,7 @@ target_link_libraries(
|
||||
PVFoamReader_SM
|
||||
LINK_PUBLIC
|
||||
vtkPVFoam-pv${PARAVIEW_VERSION_MAJOR}.${PARAVIEW_VERSION_MINOR}
|
||||
foamPv-pv${PARAVIEW_VERSION_MAJOR}.${PARAVIEW_VERSION_MINOR}
|
||||
finiteVolume
|
||||
OpenFOAM
|
||||
)
|
||||
|
||||
@ -273,6 +273,17 @@
|
||||
<Documentation>The list of point fields.</Documentation>
|
||||
</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>
|
||||
<ReaderFactory
|
||||
extensions="OpenFOAM"
|
||||
|
||||
@ -33,6 +33,7 @@ License
|
||||
#include "vtkDataArraySelection.h"
|
||||
#include "vtkInformation.h"
|
||||
#include "vtkInformationVector.h"
|
||||
#include "vtkInformationDoubleVectorKey.h"
|
||||
#include "vtkMultiBlockDataSet.h"
|
||||
#include "vtkObjectFactory.h"
|
||||
#include "vtkSMRenderViewProxy.h"
|
||||
@ -42,6 +43,9 @@ License
|
||||
// OpenFOAM includes
|
||||
#include "vtkPVFoam.H"
|
||||
|
||||
// STL includes
|
||||
#include <vector>
|
||||
|
||||
#undef EXPERIMENTAL_TIME_CACHING
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
@ -58,10 +62,9 @@ vtkPVFoamReader::vtkPVFoamReader()
|
||||
|
||||
SetNumberOfInputPorts(0);
|
||||
|
||||
FileName = nullptr;
|
||||
foamData_ = nullptr;
|
||||
|
||||
output0_ = nullptr;
|
||||
FileName = nullptr;
|
||||
backend_ = nullptr;
|
||||
output0_ = nullptr;
|
||||
|
||||
#ifdef VTKPVFOAM_DUALPORT
|
||||
// Add second output for the Lagrangian
|
||||
@ -133,11 +136,11 @@ vtkPVFoamReader::~vtkPVFoamReader()
|
||||
{
|
||||
vtkDebugMacro(<<"Deconstructor");
|
||||
|
||||
if (foamData_)
|
||||
if (backend_)
|
||||
{
|
||||
// remove patch names
|
||||
updatePatchNamesView(false);
|
||||
delete foamData_;
|
||||
delete backend_;
|
||||
}
|
||||
|
||||
if (FileName)
|
||||
@ -188,7 +191,7 @@ int vtkPVFoamReader::RequestInformation
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nInfo = outputVector->GetNumberOfInformationObjects();
|
||||
const int nInfo = outputVector->GetNumberOfInformationObjects();
|
||||
|
||||
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
|
||||
{
|
||||
foamData_->updateInfo();
|
||||
backend_->updateInfo();
|
||||
}
|
||||
|
||||
int nTimeSteps = 0;
|
||||
double* timeSteps = foamData_->findTimes(nTimeSteps);
|
||||
std::vector<double> times = backend_->findTimes(this->SkipZeroTime);
|
||||
|
||||
if (!nTimeSteps)
|
||||
if (times.empty())
|
||||
{
|
||||
vtkErrorMacro("could not find valid OpenFOAM mesh");
|
||||
|
||||
// delete foamData and flag it as fatal error
|
||||
delete foamData_;
|
||||
foamData_ = nullptr;
|
||||
delete backend_;
|
||||
backend_ = nullptr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// set identical time steps for all ports
|
||||
for (int infoI = 0; infoI < nInfo; ++infoI)
|
||||
{
|
||||
outputVector->GetInformationObject(infoI)->Set
|
||||
vtkInformation *outInfo = outputVector->GetInformationObject(infoI);
|
||||
|
||||
outInfo->Set
|
||||
(
|
||||
vtkStreamingDemandDrivenPipeline::TIME_STEPS(),
|
||||
timeSteps,
|
||||
nTimeSteps
|
||||
times.data(),
|
||||
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];
|
||||
timeRange[0] = timeSteps[0];
|
||||
timeRange[1] = timeSteps[nTimeSteps-1];
|
||||
double timeRange[2]{ times.front(), times.back() };
|
||||
|
||||
if (Foam::vtkPVFoam::debug > 1)
|
||||
{
|
||||
cout<<"nTimeSteps " << nTimeSteps << "\n"
|
||||
<<"timeRange " << timeRange[0] << " to " << timeRange[1]
|
||||
<< "\n";
|
||||
cout
|
||||
<<"nInfo " << nInfo << "\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)
|
||||
{
|
||||
outputVector->GetInformationObject(infoI)->Set
|
||||
vtkInformation *outInfo = outputVector->GetInformationObject(infoI);
|
||||
|
||||
outInfo->Set
|
||||
(
|
||||
vtkStreamingDemandDrivenPipeline::TIME_RANGE(),
|
||||
timeRange,
|
||||
@ -261,8 +274,6 @@ int vtkPVFoamReader::RequestInformation
|
||||
}
|
||||
}
|
||||
|
||||
delete timeSteps;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -282,15 +293,14 @@ int vtkPVFoamReader::RequestData
|
||||
vtkErrorMacro("FileName has to be specified!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// catch previous error
|
||||
if (!foamData_)
|
||||
if (!backend_)
|
||||
{
|
||||
// catch some previous error
|
||||
vtkErrorMacro("Reader failed - perhaps no mesh?");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nInfo = outputVector->GetNumberOfInformationObjects();
|
||||
const int nInfo = outputVector->GetNumberOfInformationObjects();
|
||||
|
||||
if (Foam::vtkPVFoam::debug)
|
||||
{
|
||||
@ -315,23 +325,31 @@ int vtkPVFoamReader::RequestData
|
||||
{
|
||||
vtkInformation *outInfo = outputVector->GetInformationObject(infoI);
|
||||
|
||||
int nsteps = outInfo->Length(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
|
||||
|
||||
if
|
||||
(
|
||||
outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP())
|
||||
&& outInfo->Length(vtkStreamingDemandDrivenPipeline::TIME_STEPS()) > 0
|
||||
&& nsteps > 0
|
||||
)
|
||||
{
|
||||
requestTime[nRequestTime++] =
|
||||
outInfo->Get
|
||||
(
|
||||
vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()
|
||||
);
|
||||
requestTime[nRequestTime] =
|
||||
(
|
||||
1 == nsteps
|
||||
// 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)
|
||||
{
|
||||
foamData_->setTime(nRequestTime, requestTime);
|
||||
backend_->setTime(nRequestTime, requestTime);
|
||||
}
|
||||
|
||||
vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::SafeDownCast
|
||||
@ -362,7 +380,7 @@ int vtkPVFoamReader::RequestData
|
||||
// but trashes the fields and still triggers the GeometryFilter
|
||||
if (needsUpdate)
|
||||
{
|
||||
foamData_->Update(output);
|
||||
backend_->Update(output);
|
||||
output0_->ShallowCopy(output);
|
||||
}
|
||||
else
|
||||
@ -391,7 +409,7 @@ int vtkPVFoamReader::RequestData
|
||||
#else
|
||||
|
||||
#ifdef VTKPVFOAM_DUALPORT
|
||||
foamData_->Update
|
||||
backend_->Update
|
||||
(
|
||||
output,
|
||||
vtkMultiBlockDataSet::SafeDownCast
|
||||
@ -403,7 +421,7 @@ int vtkPVFoamReader::RequestData
|
||||
);
|
||||
);
|
||||
#else
|
||||
foamData_->Update(output, output);
|
||||
backend_->Update(output, output);
|
||||
#endif
|
||||
|
||||
updatePatchNamesView(ShowPatchNames);
|
||||
@ -411,12 +429,27 @@ int vtkPVFoamReader::RequestData
|
||||
#endif
|
||||
|
||||
// Do any cleanup on the OpenFOAM side
|
||||
foamData_->CleanUp();
|
||||
backend_->CleanUp();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void vtkPVFoamReader::PrintInfo()
|
||||
{
|
||||
if (backend_)
|
||||
{
|
||||
backend_->printInfo();
|
||||
}
|
||||
else
|
||||
{
|
||||
cout
|
||||
<<"OpenFOAM reader not initialized\n"
|
||||
<< std::flush;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void vtkPVFoamReader::SetRefresh(bool val)
|
||||
{
|
||||
Modified();
|
||||
@ -428,9 +461,9 @@ void vtkPVFoamReader::SetIncludeSets(bool val)
|
||||
if (IncludeSets != val)
|
||||
{
|
||||
IncludeSets = val;
|
||||
if (foamData_)
|
||||
if (backend_)
|
||||
{
|
||||
foamData_->updateInfo();
|
||||
backend_->updateInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -441,9 +474,9 @@ void vtkPVFoamReader::SetIncludeZones(bool val)
|
||||
if (IncludeZones != val)
|
||||
{
|
||||
IncludeZones = val;
|
||||
if (foamData_)
|
||||
if (backend_)
|
||||
{
|
||||
foamData_->updateInfo();
|
||||
backend_->updateInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -464,9 +497,9 @@ void vtkPVFoamReader::SetShowGroupsOnly(bool val)
|
||||
if (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
|
||||
pqServerManagerModel* smModel = appCore->getServerManagerModel();
|
||||
|
||||
if (!smModel || !foamData_)
|
||||
if (!smModel || !backend_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -495,7 +528,7 @@ void vtkPVFoamReader::updatePatchNamesView(const bool show)
|
||||
|
||||
for (int viewI=0; viewI < renderViews.size(); ++viewI)
|
||||
{
|
||||
foamData_->renderPatchNames
|
||||
backend_->renderPatchNames
|
||||
(
|
||||
renderViews[viewI]->getRenderViewProxy()->GetRenderer(),
|
||||
show
|
||||
@ -514,7 +547,7 @@ void vtkPVFoamReader::PrintSelf(ostream& os, vtkIndent indent)
|
||||
os << indent << "File name: "
|
||||
<< (this->FileName ? this->FileName : "(none)") << "\n";
|
||||
|
||||
foamData_->PrintSelf(os, indent);
|
||||
backend_->PrintSelf(os, indent);
|
||||
|
||||
os << indent << "Time step range: "
|
||||
<< this->TimeStepRange[0] << " - " << this->TimeStepRange[1] << "\n"
|
||||
@ -524,7 +557,7 @@ void vtkPVFoamReader::PrintSelf(ostream& os, vtkIndent indent)
|
||||
|
||||
int vtkPVFoamReader::GetTimeStep()
|
||||
{
|
||||
return foamData_ ? foamData_->timeIndex() : -1;
|
||||
return backend_ ? backend_->timeIndex() : -1;
|
||||
}
|
||||
|
||||
|
||||
@ -533,32 +566,24 @@ int vtkPVFoamReader::GetTimeStep()
|
||||
|
||||
vtkDataArraySelection* vtkPVFoamReader::GetPartSelection()
|
||||
{
|
||||
vtkDebugMacro(<<"GetPartSelection");
|
||||
return PartSelection;
|
||||
}
|
||||
|
||||
|
||||
int vtkPVFoamReader::GetNumberOfPartArrays()
|
||||
{
|
||||
vtkDebugMacro(<<"GetNumberOfPartArrays");
|
||||
return PartSelection->GetNumberOfArrays();
|
||||
}
|
||||
|
||||
|
||||
const char* vtkPVFoamReader::GetPartArrayName(int index)
|
||||
{
|
||||
vtkDebugMacro(<<"GetPartArrayName");
|
||||
return PartSelection->GetArrayName(index);
|
||||
}
|
||||
|
||||
|
||||
int vtkPVFoamReader::GetPartArrayStatus(const char* name)
|
||||
{
|
||||
vtkDebugMacro(<<"GetPartArrayStatus");
|
||||
return PartSelection->ArrayIsEnabled(name);
|
||||
}
|
||||
|
||||
|
||||
void vtkPVFoamReader::SetPartArrayStatus(const char* name, int status)
|
||||
{
|
||||
vtkDebugMacro("Set mesh part \"" << name << "\" status to: " << status);
|
||||
@ -579,35 +604,26 @@ void vtkPVFoamReader::SetPartArrayStatus(const char* name, int status)
|
||||
|
||||
vtkDataArraySelection* vtkPVFoamReader::GetVolFieldSelection()
|
||||
{
|
||||
vtkDebugMacro(<<"GetVolFieldSelection");
|
||||
return VolFieldSelection;
|
||||
}
|
||||
|
||||
|
||||
int vtkPVFoamReader::GetNumberOfVolFieldArrays()
|
||||
{
|
||||
vtkDebugMacro(<<"GetNumberOfVolFieldArrays");
|
||||
return VolFieldSelection->GetNumberOfArrays();
|
||||
}
|
||||
|
||||
|
||||
const char* vtkPVFoamReader::GetVolFieldArrayName(int index)
|
||||
{
|
||||
vtkDebugMacro(<<"GetVolFieldArrayName");
|
||||
return VolFieldSelection->GetArrayName(index);
|
||||
}
|
||||
|
||||
|
||||
int vtkPVFoamReader::GetVolFieldArrayStatus(const char* name)
|
||||
{
|
||||
vtkDebugMacro(<<"GetVolFieldArrayStatus");
|
||||
return VolFieldSelection->ArrayIsEnabled(name);
|
||||
}
|
||||
|
||||
|
||||
void vtkPVFoamReader::SetVolFieldArrayStatus(const char* name, int status)
|
||||
{
|
||||
vtkDebugMacro(<<"SetVolFieldArrayStatus");
|
||||
if (status)
|
||||
{
|
||||
VolFieldSelection->EnableArray(name);
|
||||
@ -624,35 +640,26 @@ void vtkPVFoamReader::SetVolFieldArrayStatus(const char* name, int status)
|
||||
|
||||
vtkDataArraySelection* vtkPVFoamReader::GetPointFieldSelection()
|
||||
{
|
||||
vtkDebugMacro(<<"GetPointFieldSelection");
|
||||
return PointFieldSelection;
|
||||
}
|
||||
|
||||
|
||||
int vtkPVFoamReader::GetNumberOfPointFieldArrays()
|
||||
{
|
||||
vtkDebugMacro(<<"GetNumberOfPointFieldArrays");
|
||||
return PointFieldSelection->GetNumberOfArrays();
|
||||
}
|
||||
|
||||
|
||||
const char* vtkPVFoamReader::GetPointFieldArrayName(int index)
|
||||
{
|
||||
vtkDebugMacro(<<"GetPointFieldArrayName");
|
||||
return PointFieldSelection->GetArrayName(index);
|
||||
}
|
||||
|
||||
|
||||
int vtkPVFoamReader::GetPointFieldArrayStatus(const char* name)
|
||||
{
|
||||
vtkDebugMacro(<<"GetPointFieldArrayStatus");
|
||||
return PointFieldSelection->ArrayIsEnabled(name);
|
||||
}
|
||||
|
||||
|
||||
void vtkPVFoamReader::SetPointFieldArrayStatus(const char* name, int status)
|
||||
{
|
||||
vtkDebugMacro(<<"SetPointFieldArrayStatus");
|
||||
if (status)
|
||||
{
|
||||
PointFieldSelection->EnableArray(name);
|
||||
@ -669,39 +676,30 @@ void vtkPVFoamReader::SetPointFieldArrayStatus(const char* name, int status)
|
||||
|
||||
vtkDataArraySelection* vtkPVFoamReader::GetLagrangianFieldSelection()
|
||||
{
|
||||
vtkDebugMacro(<<"GetLagrangianFieldSelection");
|
||||
return LagrangianFieldSelection;
|
||||
}
|
||||
|
||||
|
||||
int vtkPVFoamReader::GetNumberOfLagrangianFieldArrays()
|
||||
{
|
||||
vtkDebugMacro(<<"GetNumberOfLagrangianFieldArrays");
|
||||
return LagrangianFieldSelection->GetNumberOfArrays();
|
||||
}
|
||||
|
||||
|
||||
const char* vtkPVFoamReader::GetLagrangianFieldArrayName(int index)
|
||||
{
|
||||
vtkDebugMacro(<<"GetLagrangianFieldArrayName");
|
||||
return LagrangianFieldSelection->GetArrayName(index);
|
||||
}
|
||||
|
||||
|
||||
int vtkPVFoamReader::GetLagrangianFieldArrayStatus(const char* name)
|
||||
{
|
||||
vtkDebugMacro(<<"GetLagrangianFieldArrayStatus");
|
||||
return LagrangianFieldSelection->ArrayIsEnabled(name);
|
||||
}
|
||||
|
||||
|
||||
void vtkPVFoamReader::SetLagrangianFieldArrayStatus
|
||||
(
|
||||
const char* name,
|
||||
int status
|
||||
)
|
||||
{
|
||||
vtkDebugMacro(<<"SetLagrangianFieldArrayStatus");
|
||||
if (status)
|
||||
{
|
||||
LagrangianFieldSelection->EnableArray(name);
|
||||
|
||||
@ -77,6 +77,10 @@ public:
|
||||
vtkSetStringMacro(FileName);
|
||||
vtkGetStringMacro(FileName);
|
||||
|
||||
// Description:
|
||||
// Print some case information
|
||||
virtual void PrintInfo();
|
||||
|
||||
// Description:
|
||||
// OpenFOAM mesh caching control
|
||||
vtkSetMacro(CacheMesh, bool);
|
||||
@ -250,7 +254,8 @@ private:
|
||||
//- Cached data for output port0 (experimental!)
|
||||
vtkMultiBlockDataSet* output0_;
|
||||
|
||||
Foam::vtkPVFoam* foamData_;
|
||||
//- Backend portion of the reader
|
||||
Foam::vtkPVFoam* backend_;
|
||||
};
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -2,10 +2,7 @@ vtkPVFoam.C
|
||||
vtkPVFoamFields.C
|
||||
vtkPVFoamMesh.C
|
||||
vtkPVFoamMeshLagrangian.C
|
||||
vtkPVFoamMeshSet.C
|
||||
vtkPVFoamMeshVolume.C
|
||||
vtkPVFoamMeshZone.C
|
||||
vtkPVFoamUpdateInfo.C
|
||||
vtkPVFoamUtils.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libvtkPVFoam-pv${ParaView_MAJOR}
|
||||
|
||||
@ -10,7 +10,7 @@ EXE_INC = \
|
||||
-I$(LIB_SRC)/conversion/lnInclude \
|
||||
-I$(ParaView_INCLUDE_DIR) \
|
||||
-I$(ParaView_INCLUDE_DIR)/vtkkwiml \
|
||||
-I../../vtkPVReaders/lnInclude \
|
||||
-I../../foamPv/lnInclude \
|
||||
-I../PVFoamReader
|
||||
|
||||
LIB_LIBS = \
|
||||
@ -18,5 +18,5 @@ LIB_LIBS = \
|
||||
-lconversion \
|
||||
-lgenericPatchFields \
|
||||
-llagrangian \
|
||||
-L$(FOAM_LIBBIN) -lvtkPVReaders-pv${ParaView_MAJOR} \
|
||||
-L$(FOAM_LIBBIN) -lfoamPv-pv${ParaView_MAJOR} \
|
||||
$(GLIBS)
|
||||
|
||||
@ -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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -42,15 +42,11 @@ License
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(vtkPVFoam, 0);
|
||||
defineTypeNameAndDebug(vtkPVFoam, 0);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
#include "vtkPVFoamAddToSelection.H"
|
||||
#include "vtkPVFoamUpdateInfoFields.H"
|
||||
|
||||
void Foam::vtkPVFoam::resetCounters()
|
||||
{
|
||||
// Reset array range information (ids and sizes)
|
||||
@ -116,14 +112,10 @@ int Foam::vtkPVFoam::setTime(int nRequest, const double requestTimes[])
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::setTime(";
|
||||
Info<< "<beg> setTime(";
|
||||
for (int requestI = 0; requestI < nRequest; ++requestI)
|
||||
{
|
||||
if (requestI)
|
||||
{
|
||||
Info<< ", ";
|
||||
}
|
||||
|
||||
if (requestI) Info<< ", ";
|
||||
Info<< requestTimes[requestI];
|
||||
}
|
||||
Info<< ") - previousIndex = " << timeIndex_
|
||||
@ -160,7 +152,7 @@ int Foam::vtkPVFoam::setTime(int nRequest, const double requestTimes[])
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::setTime() - selectedTime="
|
||||
Info<< "<end> setTime() - selectedTime="
|
||||
<< Times[nearestIndex].name() << " index=" << timeIndex_
|
||||
<< "/" << Times.size()
|
||||
<< " meshChanged=" << Switch(meshChanged_)
|
||||
@ -175,7 +167,7 @@ void Foam::vtkPVFoam::updateMeshPartsStatus()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::updateMeshPartsStatus" << endl;
|
||||
Info<< "<beg> updateMeshPartsStatus" << endl;
|
||||
}
|
||||
|
||||
vtkDataArraySelection* selection = reader_->GetPartSelection();
|
||||
@ -203,7 +195,7 @@ void Foam::vtkPVFoam::updateMeshPartsStatus()
|
||||
meshChanged_ = true;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
if (debug > 1)
|
||||
{
|
||||
Info<< " part[" << partId << "] = "
|
||||
<< partStatus_[partId]
|
||||
@ -212,11 +204,17 @@ void Foam::vtkPVFoam::updateMeshPartsStatus()
|
||||
}
|
||||
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 * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::vtkPVFoam::vtkPVFoam
|
||||
@ -245,7 +243,7 @@ Foam::vtkPVFoam::vtkPVFoam
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Foam::vtkPVFoam::vtkPVFoam - " << FileName << endl;
|
||||
Info<< "vtkPVFoam - " << FileName << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
@ -333,7 +331,7 @@ Foam::vtkPVFoam::~vtkPVFoam()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::~vtkPVFoam" << endl;
|
||||
Info<< "~vtkPVFoam" << endl;
|
||||
}
|
||||
|
||||
delete meshPtr_;
|
||||
@ -346,7 +344,7 @@ void Foam::vtkPVFoam::updateInfo()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::updateInfo"
|
||||
Info<< "<beg> updateInfo"
|
||||
<< " [meshPtr=" << (meshPtr_ ? "set" : "nullptr") << "] timeIndex="
|
||||
<< timeIndex_ << endl;
|
||||
}
|
||||
@ -363,16 +361,15 @@ void Foam::vtkPVFoam::updateInfo()
|
||||
// time of the vtkDataArraySelection, but the qt/paraview proxy
|
||||
// layer doesn't care about that anyhow.
|
||||
|
||||
// enable 'internalMesh' on the first call
|
||||
// or preserve the enabled selections
|
||||
stringList enabledEntries;
|
||||
if (!partSelection->GetNumberOfArrays() && !meshPtr_)
|
||||
{
|
||||
enabledEntries.setSize(1);
|
||||
enabledEntries[0] = "internalMesh";
|
||||
// enable 'internalMesh' on the first call
|
||||
enabledEntries = { "internalMesh" };
|
||||
}
|
||||
else
|
||||
{
|
||||
// preserve the enabled selections
|
||||
enabledEntries = getSelectedArrayEntries(partSelection);
|
||||
}
|
||||
|
||||
@ -395,23 +392,12 @@ void Foam::vtkPVFoam::updateInfo()
|
||||
}
|
||||
|
||||
// Update volume, point and lagrangian fields
|
||||
updateInfoFields<fvPatchField, volMesh>
|
||||
(
|
||||
reader_->GetVolFieldSelection()
|
||||
);
|
||||
updateInfoFields<pointPatchField, pointMesh>
|
||||
(
|
||||
reader_->GetPointFieldSelection()
|
||||
);
|
||||
updateInfoLagrangianFields();
|
||||
updateInfoFields();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
// just for debug info
|
||||
getSelectedArrayEntries(partSelection);
|
||||
Info<< "<end> Foam::vtkPVFoam::updateInfo" << endl;
|
||||
Info<< "<end> updateInfo" << endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -419,7 +405,7 @@ void Foam::vtkPVFoam::updateFoamMesh()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::updateFoamMesh" << endl;
|
||||
Info<< "<beg> updateFoamMesh" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
@ -463,7 +449,7 @@ void Foam::vtkPVFoam::updateFoamMesh()
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::updateFoamMesh" << endl;
|
||||
Info<< "<end> updateFoamMesh" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
@ -532,7 +518,7 @@ void Foam::vtkPVFoam::Update
|
||||
convertLagrangianFields(lagrangianOutput);
|
||||
if (debug)
|
||||
{
|
||||
Info<< "done reader part" << endl;
|
||||
Info<< "done reader part" << nl << endl;
|
||||
}
|
||||
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;
|
||||
double* tsteps = nullptr;
|
||||
std::vector<double> times;
|
||||
|
||||
if (dbPtr_.valid())
|
||||
{
|
||||
Time& runTime = dbPtr_();
|
||||
const Time& runTime = dbPtr_();
|
||||
instantList timeLst = runTime.times();
|
||||
|
||||
// find the first time for which this mesh appears to exist
|
||||
label timeI = 0;
|
||||
for (; timeI < timeLst.size(); ++timeI)
|
||||
label begIndex = timeLst.size();
|
||||
forAll(timeLst, timeI)
|
||||
{
|
||||
const word& timeName = timeLst[timeI].name();
|
||||
|
||||
if
|
||||
(
|
||||
isFile(runTime.path()/timeName/meshDir_/"points")
|
||||
&& IOobject
|
||||
IOobject
|
||||
(
|
||||
"points",
|
||||
timeName,
|
||||
timeLst[timeI].name(),
|
||||
meshDir_,
|
||||
runTime
|
||||
).typeHeaderOk<pointIOField>(true)
|
||||
).typeHeaderOk<pointIOField>(false, false)
|
||||
)
|
||||
{
|
||||
begIndex = timeI;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
nTimes = timeLst.size() - timeI;
|
||||
label nTimes = timeLst.size() - begIndex;
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 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)
|
||||
{
|
||||
++timeI;
|
||||
--nTimes;
|
||||
}
|
||||
++begIndex;
|
||||
--nTimes;
|
||||
}
|
||||
|
||||
if (nTimes)
|
||||
times.reserve(nTimes);
|
||||
while (nTimes-- > 0)
|
||||
{
|
||||
tsteps = new double[nTimes];
|
||||
for (label stepI = 0; stepI < nTimes; ++stepI, ++timeI)
|
||||
{
|
||||
tsteps[stepI] = timeLst[timeI].value();
|
||||
}
|
||||
times.push_back(timeLst[begIndex++].value());
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -620,10 +596,7 @@ double* Foam::vtkPVFoam::findTimes(int& nTimeSteps)
|
||||
}
|
||||
}
|
||||
|
||||
// vector length returned via the parameter
|
||||
nTimeSteps = nTimes;
|
||||
|
||||
return tsteps;
|
||||
return times;
|
||||
}
|
||||
|
||||
|
||||
@ -650,7 +623,7 @@ void Foam::vtkPVFoam::renderPatchNames
|
||||
if (show)
|
||||
{
|
||||
// get the display patches, strip off any suffix
|
||||
wordHashSet selectedPatches = getSelected
|
||||
hashedWordList selectedPatches = getSelected
|
||||
(
|
||||
reader_->GetPartSelection(),
|
||||
arrayRangePatches_
|
||||
@ -793,8 +766,8 @@ void Foam::vtkPVFoam::renderPatchNames
|
||||
tprop->BoldOff();
|
||||
tprop->ShadowOff();
|
||||
tprop->SetLineSpacing(1.0);
|
||||
tprop->SetFontSize(12);
|
||||
tprop->SetColor(1.0, 0.0, 0.0);
|
||||
tprop->SetFontSize(14);
|
||||
tprop->SetColor(1.0, 0.0, 1.0);
|
||||
tprop->SetJustificationToCentered();
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -29,24 +29,15 @@ Description
|
||||
|
||||
SourceFiles
|
||||
vtkPVFoam.C
|
||||
vtkPVFoam.H
|
||||
vtkPVFoamFields.C
|
||||
vtkPVFoamMesh.C
|
||||
vtkPVFoamMeshLagrangian.C
|
||||
vtkPVFoamTemplates.C
|
||||
vtkPVFoamMeshSet.C
|
||||
vtkPVFoamMeshVolume.C
|
||||
vtkPVFoamMeshZone.C
|
||||
vtkPVFoamFaceField.H
|
||||
vtkPVFoamLagrangianFields.H
|
||||
vtkPVFoamPatchField.H
|
||||
vtkPVFoamPointFields.H
|
||||
vtkPVFoamPoints.H
|
||||
vtkPVFoamTemplates.C
|
||||
vtkPVFoamUpdateInfo.C
|
||||
vtkPVFoamUpdateInfoFields.H
|
||||
vtkPVFoamUtils.C
|
||||
vtkPVFoamVolFields.H
|
||||
vtkPVFoamAddToSelection.H
|
||||
vtkPVFoamFieldTemplates.C
|
||||
vtkPVFoamUpdateTemplates.C
|
||||
|
||||
// Needed by VTK:
|
||||
vtkDataArrayTemplateImplicit.txx
|
||||
@ -63,6 +54,7 @@ SourceFiles
|
||||
#include "primitivePatch.H"
|
||||
#include "PrimitivePatchInterpolation.H"
|
||||
#include "volPointInterpolation.H"
|
||||
#include "foamPvCore.H"
|
||||
|
||||
#undef VTKPVFOAM_DUALPORT
|
||||
|
||||
@ -70,6 +62,7 @@ SourceFiles
|
||||
|
||||
class vtkDataArraySelection;
|
||||
class vtkDataSet;
|
||||
class vtkFloatArray;
|
||||
class vtkPoints;
|
||||
class vtkPVFoamReader;
|
||||
class vtkRenderer;
|
||||
@ -90,10 +83,9 @@ class Time;
|
||||
class fvMesh;
|
||||
class IOobjectList;
|
||||
class polyPatch;
|
||||
class faceSet;
|
||||
class pointSet;
|
||||
|
||||
template<class Type> class IOField;
|
||||
template<class Type> class Field;
|
||||
template<class Type> class List;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
@ -101,84 +93,15 @@ template<class Type> class List;
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class vtkPVFoam
|
||||
:
|
||||
private foamPvCore
|
||||
{
|
||||
// Convenience typedefs
|
||||
typedef PrimitivePatchInterpolation<primitivePatch> patchInterpolator;
|
||||
|
||||
|
||||
// Private classes
|
||||
|
||||
//- Bookkeeping for GUI checklists and the multi-block organization
|
||||
class arrayRange
|
||||
{
|
||||
const char *name_;
|
||||
int block_;
|
||||
int start_;
|
||||
int size_;
|
||||
|
||||
public:
|
||||
|
||||
arrayRange(const char *name, const int blockNo=0)
|
||||
:
|
||||
name_(name),
|
||||
block_(blockNo),
|
||||
start_(0),
|
||||
size_(0)
|
||||
{}
|
||||
|
||||
//- Return the block holding these datasets
|
||||
int block() const
|
||||
{
|
||||
return block_;
|
||||
}
|
||||
|
||||
//- Assign block number, return previous value
|
||||
int block(int blockNo)
|
||||
{
|
||||
int prev = block_;
|
||||
block_ = blockNo;
|
||||
return prev;
|
||||
}
|
||||
|
||||
//- Return block name
|
||||
const char* name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- Return array start index
|
||||
int start() const
|
||||
{
|
||||
return start_;
|
||||
}
|
||||
|
||||
//- Return array end index
|
||||
int end() const
|
||||
{
|
||||
return start_ + size_;
|
||||
}
|
||||
|
||||
//- Return sublist size
|
||||
int size() const
|
||||
{
|
||||
return size_;
|
||||
}
|
||||
|
||||
bool empty() const
|
||||
{
|
||||
return !size_;
|
||||
}
|
||||
|
||||
//- Reset the size to zero and optionally assign a new start
|
||||
void reset(const int startAt = 0)
|
||||
{
|
||||
start_ = startAt;
|
||||
size_ = 0;
|
||||
}
|
||||
|
||||
//- Increment the size
|
||||
void operator+=(const int n)
|
||||
{
|
||||
size_ += n;
|
||||
}
|
||||
};
|
||||
|
||||
//- Bookkeeping for polyhedral cell decomposition
|
||||
// hide in extra pointMap (cellSet/cellZone) for now
|
||||
class polyDecomp
|
||||
@ -297,372 +220,258 @@ class vtkPVFoam
|
||||
//- List of patch names for rendering to window
|
||||
List<vtkTextActor*> patchTextActorsPtrs_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
// Convenience method use to convert the readers from VTK 5
|
||||
// multiblock API to the current composite data infrastructure
|
||||
static void AddToBlock
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
vtkDataSet* dataset,
|
||||
const arrayRange&,
|
||||
const label datasetNo,
|
||||
const std::string& datasetName
|
||||
);
|
||||
|
||||
// Convenience method use to convert the readers from VTK 5
|
||||
// multiblock API to the current composite data infrastructure
|
||||
static vtkDataSet* GetDataSetFromBlock
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
const arrayRange&,
|
||||
const label datasetNo
|
||||
);
|
||||
|
||||
// Convenience method use to convert the readers from VTK 5
|
||||
// multiblock API to the current composite data infrastructure
|
||||
static label GetNumberOfDataSets
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
const arrayRange&
|
||||
);
|
||||
|
||||
//- Reset data counters
|
||||
void resetCounters();
|
||||
|
||||
// Update information helper functions
|
||||
// Update information helper functions
|
||||
|
||||
//- Update the mesh parts selected in the GUI
|
||||
void updateMeshPartsStatus();
|
||||
//- Update the mesh parts selected in the GUI
|
||||
void updateMeshPartsStatus();
|
||||
|
||||
//- Internal mesh info
|
||||
void updateInfoInternalMesh(vtkDataArraySelection*);
|
||||
//- Internal mesh info
|
||||
void updateInfoInternalMesh(vtkDataArraySelection*);
|
||||
|
||||
//- Lagrangian info
|
||||
void updateInfoLagrangian(vtkDataArraySelection*);
|
||||
//- Lagrangian info
|
||||
void updateInfoLagrangian(vtkDataArraySelection*);
|
||||
|
||||
//- Patch info
|
||||
void updateInfoPatches(vtkDataArraySelection*, stringList&);
|
||||
//- Patch info
|
||||
void updateInfoPatches(vtkDataArraySelection*, stringList&);
|
||||
|
||||
//- Set info
|
||||
void updateInfoSets(vtkDataArraySelection*);
|
||||
//- Set info
|
||||
void updateInfoSets(vtkDataArraySelection*);
|
||||
|
||||
//- Zone info
|
||||
void updateInfoZones(vtkDataArraySelection*);
|
||||
//- Zone info
|
||||
void updateInfoZones(vtkDataArraySelection*);
|
||||
|
||||
//- Get non-empty zone names for zoneType from file
|
||||
wordList getZoneNames(const word& zoneType) const;
|
||||
//- Get non-empty zone names for zoneType from file
|
||||
wordList getZoneNames(const word& zoneType) const;
|
||||
|
||||
//- Get non-empty zone names from mesh info
|
||||
template<class ZoneType>
|
||||
wordList getZoneNames
|
||||
(
|
||||
const ZoneMesh<ZoneType, polyMesh>&
|
||||
) const;
|
||||
|
||||
//- Add objects of Type to paraview array selection
|
||||
template<class Type>
|
||||
label addToSelection
|
||||
(
|
||||
vtkDataArraySelection*,
|
||||
const IOobjectList&,
|
||||
const string& suffix=string::null
|
||||
);
|
||||
|
||||
//- Field info
|
||||
template<template<class> class patchType, class meshType>
|
||||
void updateInfoFields(vtkDataArraySelection*);
|
||||
|
||||
//- Lagrangian field info
|
||||
void updateInfoLagrangianFields();
|
||||
|
||||
|
||||
// Update helper functions
|
||||
|
||||
//- OpenFOAM mesh
|
||||
void updateFoamMesh();
|
||||
|
||||
//- Reduce memory footprint after conversion
|
||||
void reduceMemory();
|
||||
|
||||
|
||||
// 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
|
||||
//- Get names of on non-empty zones from the mesh info
|
||||
template<class ZoneType>
|
||||
static wordList getZoneNames
|
||||
(
|
||||
vtkDataArraySelection*,
|
||||
const IOobjectList&,
|
||||
const string& suffix=string::null
|
||||
const ZoneMesh<ZoneType, polyMesh>& zmesh
|
||||
);
|
||||
|
||||
//- 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
|
||||
template<class Type>
|
||||
void convertVolField
|
||||
(
|
||||
const PtrList<PrimitivePatchInterpolation<primitivePatch>>&,
|
||||
const GeometricField<Type, fvPatchField, volMesh>&,
|
||||
const bool interpFields,
|
||||
vtkMultiBlockDataSet* output
|
||||
);
|
||||
//- Convert Field to VTK field
|
||||
template<class Type>
|
||||
vtkFloatArray* convertFieldToVTK
|
||||
(
|
||||
const word& name,
|
||||
const Field<Type>& fld
|
||||
);
|
||||
|
||||
//- Volume fields - all types
|
||||
template<class Type>
|
||||
void convertVolFields
|
||||
(
|
||||
const fvMesh&,
|
||||
const PtrList<PrimitivePatchInterpolation<primitivePatch>>&,
|
||||
const IOobjectList&,
|
||||
const bool interpFields,
|
||||
vtkMultiBlockDataSet* output
|
||||
);
|
||||
//- Face set/zone field
|
||||
template<class Type>
|
||||
vtkFloatArray* convertFaceFieldToVTK
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& fld,
|
||||
const labelUList& faceLabels
|
||||
);
|
||||
|
||||
//- Volume internal fields (DimensionedField)- all types
|
||||
template<class Type>
|
||||
void convertDimFields
|
||||
(
|
||||
const fvMesh&,
|
||||
const PtrList<PrimitivePatchInterpolation<primitivePatch>>&,
|
||||
const IOobjectList&,
|
||||
const bool interpFields,
|
||||
vtkMultiBlockDataSet* output
|
||||
);
|
||||
|
||||
//- Volume field - all selected parts
|
||||
template<class Type>
|
||||
void convertVolFieldBlock
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>&,
|
||||
autoPtr<GeometricField<Type, pointPatchField, pointMesh>>&,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const arrayRange&,
|
||||
const List<polyDecomp>& decompLst
|
||||
);
|
||||
|
||||
//- Volume field
|
||||
template<class Type>
|
||||
void convertVolField
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>&,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const arrayRange&,
|
||||
const label datasetNo,
|
||||
const polyDecomp&
|
||||
);
|
||||
|
||||
//- Patch field
|
||||
template<class Type>
|
||||
void convertPatchField
|
||||
(
|
||||
const word& name,
|
||||
const Field<Type>&,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const arrayRange&,
|
||||
const label datasetNo
|
||||
);
|
||||
|
||||
//- Face set/zone field
|
||||
template<class Type>
|
||||
void convertFaceField
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>&,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const arrayRange&,
|
||||
const label datasetNo,
|
||||
const fvMesh&,
|
||||
const labelList& faceLabels
|
||||
);
|
||||
|
||||
//- Lagrangian fields - all types
|
||||
template<class Type>
|
||||
void convertLagrangianFields
|
||||
(
|
||||
const IOobjectList&,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const label datasetNo
|
||||
);
|
||||
|
||||
//- Lagrangian field
|
||||
template<class Type>
|
||||
void convertLagrangianField
|
||||
(
|
||||
const IOField<Type>&,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const arrayRange&,
|
||||
const label datasetNo
|
||||
);
|
||||
|
||||
//- Point fields - all types
|
||||
template<class Type>
|
||||
void convertPointFields
|
||||
(
|
||||
const fvMesh&,
|
||||
const pointMesh&,
|
||||
const IOobjectList&,
|
||||
vtkMultiBlockDataSet* output
|
||||
);
|
||||
|
||||
//- Point field - all selected parts
|
||||
template<class Type>
|
||||
void convertPointFieldBlock
|
||||
(
|
||||
const GeometricField<Type, pointPatchField, pointMesh>&,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const arrayRange&,
|
||||
const List<polyDecomp>&
|
||||
);
|
||||
|
||||
//- Point fields
|
||||
template<class Type>
|
||||
void convertPointField
|
||||
(
|
||||
const GeometricField<Type, pointPatchField, pointMesh>&,
|
||||
const GeometricField<Type, fvPatchField, volMesh>&,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const arrayRange&,
|
||||
const label datasetNo,
|
||||
const polyDecomp&
|
||||
);
|
||||
|
||||
//- Patch point field
|
||||
template<class Type>
|
||||
void convertPatchPointField
|
||||
(
|
||||
const word& name,
|
||||
const Field<Type>&,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const arrayRange&,
|
||||
const label datasetNo
|
||||
);
|
||||
//- Volume field
|
||||
template<class Type>
|
||||
vtkFloatArray* convertVolFieldToVTK
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& fld,
|
||||
const polyDecomp& decompInfo
|
||||
);
|
||||
|
||||
|
||||
// GUI selection helper functions
|
||||
//- Convert volume fields
|
||||
void convertVolFields(vtkMultiBlockDataSet* output);
|
||||
|
||||
//- Only keep what is listed in hashSet
|
||||
static void pruneObjectList
|
||||
(
|
||||
IOobjectList&,
|
||||
const wordHashSet&
|
||||
);
|
||||
//- Convert point fields
|
||||
void convertPointFields(vtkMultiBlockDataSet* output);
|
||||
|
||||
//- Retrieve the current selections
|
||||
static wordHashSet getSelected(vtkDataArraySelection*);
|
||||
//- Convert Lagrangian fields
|
||||
void convertLagrangianFields(vtkMultiBlockDataSet* output);
|
||||
|
||||
//- Retrieve a sub-list of the current selections
|
||||
static wordHashSet getSelected
|
||||
(
|
||||
vtkDataArraySelection*,
|
||||
const arrayRange&
|
||||
);
|
||||
|
||||
//- Retrieve the current selections
|
||||
static stringList getSelectedArrayEntries(vtkDataArraySelection*);
|
||||
// Convert OpenFOAM fields
|
||||
|
||||
//- Retrieve a sub-list of the current selections
|
||||
static stringList getSelectedArrayEntries
|
||||
(
|
||||
vtkDataArraySelection*,
|
||||
const arrayRange&
|
||||
);
|
||||
//- Volume field - all types
|
||||
template<class Type>
|
||||
void convertVolField
|
||||
(
|
||||
const PtrList<patchInterpolator>& patchInterpList,
|
||||
const GeometricField<Type, fvPatchField, volMesh>& fld,
|
||||
vtkMultiBlockDataSet* output
|
||||
);
|
||||
|
||||
//- Set selection(s)
|
||||
static void setSelectedArrayEntries
|
||||
(
|
||||
vtkDataArraySelection*,
|
||||
const stringList&
|
||||
);
|
||||
//- Volume fields - all types
|
||||
template<class Type>
|
||||
void convertVolFields
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const PtrList<patchInterpolator>& patchInterpList,
|
||||
const IOobjectList& objects,
|
||||
vtkMultiBlockDataSet* output
|
||||
);
|
||||
|
||||
//- Get the first word from the mesh parts selection
|
||||
word getPartName(const int);
|
||||
//- Volume internal fields (DimensionedField)- all types
|
||||
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
|
||||
vtkPVFoam(const vtkPVFoam&);
|
||||
vtkPVFoam(const vtkPVFoam&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const vtkPVFoam&);
|
||||
void operator=(const vtkPVFoam&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
@ -700,9 +509,9 @@ public:
|
||||
//- Clean any storage
|
||||
void CleanUp();
|
||||
|
||||
//- Allocate and return a list of selected times
|
||||
// returns the count via the parameter
|
||||
double* findTimes(int& nTimeSteps);
|
||||
//- Return a list of selected times.
|
||||
// Use STL container since these values are used by the plugin
|
||||
std::vector<double> findTimes(const bool skipZero = false) const;
|
||||
|
||||
//- Add/remove patch names to/from the view
|
||||
void renderPatchNames(vtkRenderer*, const bool show);
|
||||
@ -725,9 +534,7 @@ public:
|
||||
//- Debug information
|
||||
void PrintSelf(ostream&, vtkIndent) const;
|
||||
|
||||
//- Simple memory used debugging information
|
||||
static void printMemory();
|
||||
|
||||
void printInfo() const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -26,6 +26,7 @@ License
|
||||
#include "vtkPVFoam.H"
|
||||
|
||||
// OpenFOAM includes
|
||||
#include "Cloud.H"
|
||||
#include "IOobjectList.H"
|
||||
#include "vtkPVFoamReader.h"
|
||||
|
||||
@ -34,29 +35,26 @@ License
|
||||
#include "vtkPolyData.h"
|
||||
#include "vtkUnstructuredGrid.h"
|
||||
|
||||
// Templates (only needed here)
|
||||
#include "vtkPVFoamFieldTemplates.C"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
#include "vtkPVFoamVolFields.H"
|
||||
#include "vtkPVFoamPointFields.H"
|
||||
#include "vtkPVFoamLagrangianFields.H"
|
||||
|
||||
|
||||
void Foam::vtkPVFoam::pruneObjectList
|
||||
(
|
||||
IOobjectList& objects,
|
||||
const wordHashSet& selected
|
||||
const hashedWordList& retain
|
||||
)
|
||||
{
|
||||
// hash all the selected field names
|
||||
if (selected.empty())
|
||||
if (retain.empty())
|
||||
{
|
||||
objects.clear();
|
||||
}
|
||||
|
||||
// only keep selected fields
|
||||
// only retain specified fields
|
||||
forAllIter(IOobjectList, objects, iter)
|
||||
{
|
||||
if (!selected.found(iter()->name()))
|
||||
if (!retain.found(iter()->name()))
|
||||
{
|
||||
objects.erase(iter);
|
||||
}
|
||||
@ -71,7 +69,8 @@ void Foam::vtkPVFoam::convertVolFields
|
||||
{
|
||||
const fvMesh& mesh = *meshPtr_;
|
||||
|
||||
wordHashSet selectedFields = getSelected
|
||||
const bool interpFields = reader_->GetInterpolateVolFields();
|
||||
hashedWordList selectedFields = getSelected
|
||||
(
|
||||
reader_->GetVolFieldSelection()
|
||||
);
|
||||
@ -93,80 +92,50 @@ void Foam::vtkPVFoam::convertVolFields
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::convertVolFields" << nl
|
||||
<< "converting OpenFOAM volume fields" << endl;
|
||||
Info<< "<beg> convert volume fields" << endl;
|
||||
forAllConstIter(IOobjectList, objects, iter)
|
||||
{
|
||||
Info<< " " << iter()->name()
|
||||
<< " == " << iter()->objectPath() << nl;
|
||||
<< " == " << iter()->objectPath() << endl;
|
||||
}
|
||||
printMemory();
|
||||
}
|
||||
|
||||
|
||||
PtrList<PrimitivePatchInterpolation<primitivePatch>>
|
||||
ppInterpList(mesh.boundaryMesh().size());
|
||||
PtrList<patchInterpolator> interpLst;
|
||||
|
||||
forAll(ppInterpList, i)
|
||||
if (interpFields)
|
||||
{
|
||||
ppInterpList.set
|
||||
(
|
||||
i,
|
||||
new PrimitivePatchInterpolation<primitivePatch>
|
||||
interpLst.setSize(mesh.boundaryMesh().size());
|
||||
|
||||
forAll(interpLst, i)
|
||||
{
|
||||
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();
|
||||
|
||||
convertVolFields<scalar>
|
||||
(
|
||||
mesh, ppInterpList, objects, interpFields, output
|
||||
);
|
||||
convertVolFields<vector>
|
||||
(
|
||||
mesh, ppInterpList, objects, interpFields, output
|
||||
);
|
||||
convertVolFields<sphericalTensor>
|
||||
(
|
||||
mesh, ppInterpList, objects, interpFields, output
|
||||
);
|
||||
convertVolFields<symmTensor>
|
||||
(
|
||||
mesh, ppInterpList, objects, interpFields, output
|
||||
);
|
||||
convertVolFields<tensor>
|
||||
(
|
||||
mesh, ppInterpList, objects, interpFields, output
|
||||
);
|
||||
|
||||
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
|
||||
);
|
||||
convertDimFields<scalar>(mesh, interpLst, objects, output);
|
||||
convertDimFields<vector>(mesh, interpLst, objects, output);
|
||||
convertDimFields<sphericalTensor>(mesh, interpLst, objects, output);
|
||||
convertDimFields<symmTensor>(mesh, interpLst, objects, output);
|
||||
convertDimFields<tensor>(mesh, interpLst, objects, output);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::convertVolFields" << endl;
|
||||
Info<< "<end> convert volume fields" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
@ -179,7 +148,7 @@ void Foam::vtkPVFoam::convertPointFields
|
||||
{
|
||||
const fvMesh& mesh = *meshPtr_;
|
||||
|
||||
wordHashSet selectedFields = getSelected
|
||||
hashedWordList selectedFields = getSelected
|
||||
(
|
||||
reader_->GetPointFieldSelection()
|
||||
);
|
||||
@ -205,12 +174,11 @@ void Foam::vtkPVFoam::convertPointFields
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::convertPointFields" << nl
|
||||
<< "converting OpenFOAM volume fields -> point fields" << endl;
|
||||
Info<< "<beg> convert volume -> point fields" << endl;
|
||||
forAllConstIter(IOobjectList, objects, iter)
|
||||
{
|
||||
Info<< " " << iter()->name()
|
||||
<< " == " << iter()->objectPath() << nl;
|
||||
<< " == " << iter()->objectPath() << endl;
|
||||
}
|
||||
printMemory();
|
||||
}
|
||||
@ -218,31 +186,15 @@ void Foam::vtkPVFoam::convertPointFields
|
||||
// Construct interpolation on the raw mesh
|
||||
const pointMesh& pMesh = pointMesh::New(mesh);
|
||||
|
||||
|
||||
convertPointFields<scalar>
|
||||
(
|
||||
mesh, pMesh, objects, output
|
||||
);
|
||||
convertPointFields<vector>
|
||||
(
|
||||
mesh, pMesh, objects, output
|
||||
);
|
||||
convertPointFields<sphericalTensor>
|
||||
(
|
||||
mesh, pMesh, objects, output
|
||||
);
|
||||
convertPointFields<symmTensor>
|
||||
(
|
||||
mesh, pMesh, objects, output
|
||||
);
|
||||
convertPointFields<tensor>
|
||||
(
|
||||
mesh, pMesh, objects, output
|
||||
);
|
||||
convertPointFields<scalar>(pMesh, objects, output);
|
||||
convertPointFields<vector>(pMesh, objects, output);
|
||||
convertPointFields<sphericalTensor>(pMesh, objects, output);
|
||||
convertPointFields<symmTensor>(pMesh, objects, output);
|
||||
convertPointFields<tensor>(pMesh, objects, output);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::convertPointFields" << endl;
|
||||
Info<< "<end> convert volume -> point fields" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
@ -256,7 +208,7 @@ void Foam::vtkPVFoam::convertLagrangianFields
|
||||
arrayRange& range = arrayRangeLagrangian_;
|
||||
const fvMesh& mesh = *meshPtr_;
|
||||
|
||||
wordHashSet selectedFields = getSelected
|
||||
hashedWordList selectedFields = getSelected
|
||||
(
|
||||
reader_->GetLagrangianFieldSelection()
|
||||
);
|
||||
@ -268,7 +220,7 @@ void Foam::vtkPVFoam::convertLagrangianFields
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::convertLagrangianFields" << endl;
|
||||
Info<< "<beg> convert Lagrangian fields" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
@ -282,7 +234,6 @@ void Foam::vtkPVFoam::convertLagrangianFields
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// Get the Lagrangian fields for this time and this cloud
|
||||
// but only keep selected fields
|
||||
// the region name is already in the mesh db
|
||||
@ -301,43 +252,25 @@ void Foam::vtkPVFoam::convertLagrangianFields
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "converting OpenFOAM lagrangian fields" << nl;
|
||||
Info<< "converting OpenFOAM lagrangian fields" << endl;
|
||||
forAllConstIter(IOobjectList, objects, iter)
|
||||
{
|
||||
Info<< " " << iter()->name()
|
||||
<< " == " << iter()->objectPath() << nl;
|
||||
<< " == " << iter()->objectPath() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
convertLagrangianFields<label>
|
||||
(
|
||||
objects, output, datasetNo
|
||||
);
|
||||
convertLagrangianFields<scalar>
|
||||
(
|
||||
objects, output, datasetNo
|
||||
);
|
||||
convertLagrangianFields<vector>
|
||||
(
|
||||
objects, output, datasetNo
|
||||
);
|
||||
convertLagrangianFields<sphericalTensor>
|
||||
(
|
||||
objects, output, datasetNo
|
||||
);
|
||||
convertLagrangianFields<symmTensor>
|
||||
(
|
||||
objects, output, datasetNo
|
||||
);
|
||||
convertLagrangianFields<tensor>
|
||||
(
|
||||
objects, output, datasetNo
|
||||
);
|
||||
convertLagrangianFields<label>(objects, output, datasetNo);
|
||||
convertLagrangianFields<scalar>(objects, output, datasetNo);
|
||||
convertLagrangianFields<vector>(objects, output, datasetNo);
|
||||
convertLagrangianFields<sphericalTensor>(objects, output, datasetNo);
|
||||
convertLagrangianFields<symmTensor>(objects, output, datasetNo);
|
||||
convertLagrangianFields<tensor>(objects, output, datasetNo);
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::convertLagrangianFields" << endl;
|
||||
Info<< "<end> convert Lagrangian fields" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -57,7 +57,7 @@ void Foam::vtkPVFoam::convertMeshVolume
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::convertMeshVolume" << endl;
|
||||
Info<< "<beg> convertMeshVolume" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ void Foam::vtkPVFoam::convertMeshVolume
|
||||
|
||||
if (vtkmesh)
|
||||
{
|
||||
AddToBlock(output, vtkmesh, range, datasetNo, partName);
|
||||
addToBlock(output, vtkmesh, range, datasetNo, partName);
|
||||
vtkmesh->Delete();
|
||||
|
||||
partDataset_[partId] = datasetNo++;
|
||||
@ -95,7 +95,7 @@ void Foam::vtkPVFoam::convertMeshVolume
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::convertMeshVolume" << endl;
|
||||
Info<< "<end> convertMeshVolume" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
@ -114,7 +114,7 @@ void Foam::vtkPVFoam::convertMeshLagrangian
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::convertMeshLagrangian" << endl;
|
||||
Info<< "<beg> convertMeshLagrangian" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
@ -131,7 +131,7 @@ void Foam::vtkPVFoam::convertMeshLagrangian
|
||||
|
||||
if (vtkmesh)
|
||||
{
|
||||
AddToBlock(output, vtkmesh, range, datasetNo, cloudName);
|
||||
addToBlock(output, vtkmesh, range, datasetNo, cloudName);
|
||||
vtkmesh->Delete();
|
||||
|
||||
partDataset_[partId] = datasetNo++;
|
||||
@ -146,7 +146,7 @@ void Foam::vtkPVFoam::convertMeshLagrangian
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::convertMeshLagrangian" << endl;
|
||||
Info<< "<end> convertMeshLagrangian" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
@ -166,7 +166,7 @@ void Foam::vtkPVFoam::convertMeshPatches
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::convertMeshPatches" << endl;
|
||||
Info<< "<beg> convertMeshPatches" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
@ -201,26 +201,33 @@ void Foam::vtkPVFoam::convertMeshPatches
|
||||
{
|
||||
sz += patches[iter.key()].size();
|
||||
}
|
||||
labelList meshFaceLabels(sz);
|
||||
labelList faceLabels(sz);
|
||||
sz = 0;
|
||||
forAllConstIter(labelHashSet, patchIds, iter)
|
||||
{
|
||||
const polyPatch& pp = patches[iter.key()];
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
if (vtkmesh)
|
||||
{
|
||||
AddToBlock(output, vtkmesh, range, datasetNo, patchName);
|
||||
addToBlock(output, vtkmesh, range, datasetNo, patchName);
|
||||
vtkmesh->Delete();
|
||||
|
||||
partDataset_[partId] = datasetNo++;
|
||||
@ -235,7 +242,7 @@ void Foam::vtkPVFoam::convertMeshPatches
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::convertMeshPatches" << endl;
|
||||
Info<< "<end> convertMeshPatches" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
@ -262,7 +269,7 @@ void Foam::vtkPVFoam::convertMeshCellZones
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::convertMeshCellZones" << endl;
|
||||
Info<< "<beg> convertMeshCellZones" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
@ -309,7 +316,7 @@ void Foam::vtkPVFoam::convertMeshCellZones
|
||||
// copy pointMap as well, otherwise pointFields fail
|
||||
zonePolyDecomp_[datasetNo].pointMap() = subsetter.pointMap();
|
||||
|
||||
AddToBlock(output, vtkmesh, range, datasetNo, zoneName);
|
||||
addToBlock(output, vtkmesh, range, datasetNo, zoneName);
|
||||
vtkmesh->Delete();
|
||||
|
||||
partDataset_[partId] = datasetNo++;
|
||||
@ -324,7 +331,7 @@ void Foam::vtkPVFoam::convertMeshCellZones
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::convertMeshCellZones" << endl;
|
||||
Info<< "<end> convertMeshCellZones" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
@ -346,7 +353,7 @@ void Foam::vtkPVFoam::convertMeshCellSets
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::convertMeshCellSets" << endl;
|
||||
Info<< "<beg> convertMeshCellSets" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
@ -391,7 +398,7 @@ void Foam::vtkPVFoam::convertMeshCellSets
|
||||
// copy pointMap as well, otherwise pointFields fail
|
||||
csetPolyDecomp_[datasetNo].pointMap() = subsetter.pointMap();
|
||||
|
||||
AddToBlock(output, vtkmesh, range, datasetNo, partName);
|
||||
addToBlock(output, vtkmesh, range, datasetNo, partName);
|
||||
vtkmesh->Delete();
|
||||
|
||||
partDataset_[partId] = datasetNo++;
|
||||
@ -406,7 +413,7 @@ void Foam::vtkPVFoam::convertMeshCellSets
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::convertMeshCellSets" << endl;
|
||||
Info<< "<end> convertMeshCellSets" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
@ -430,7 +437,7 @@ void Foam::vtkPVFoam::convertMeshFaceZones
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::convertMeshFaceZones" << endl;
|
||||
Info<< "<beg> convertMeshFaceZones" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
@ -455,7 +462,7 @@ void Foam::vtkPVFoam::convertMeshFaceZones
|
||||
|
||||
if (vtkmesh)
|
||||
{
|
||||
AddToBlock(output, vtkmesh, range, datasetNo, zoneName);
|
||||
addToBlock(output, vtkmesh, range, datasetNo, zoneName);
|
||||
vtkmesh->Delete();
|
||||
|
||||
partDataset_[partId] = datasetNo++;
|
||||
@ -470,7 +477,7 @@ void Foam::vtkPVFoam::convertMeshFaceZones
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::convertMeshFaceZones" << endl;
|
||||
Info<< "<end> convertMeshFaceZones" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
@ -489,7 +496,7 @@ void Foam::vtkPVFoam::convertMeshFaceSets
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::convertMeshFaceSets" << endl;
|
||||
Info<< "<beg> convertMeshFaceSets" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
@ -507,12 +514,26 @@ void Foam::vtkPVFoam::convertMeshFaceSets
|
||||
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)
|
||||
{
|
||||
AddToBlock(output, vtkmesh, range, datasetNo, partName);
|
||||
addToBlock(output, vtkmesh, range, datasetNo, partName);
|
||||
vtkmesh->Delete();
|
||||
|
||||
partDataset_[partId] = datasetNo++;
|
||||
@ -527,7 +548,7 @@ void Foam::vtkPVFoam::convertMeshFaceSets
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::convertMeshFaceSets" << endl;
|
||||
Info<< "<end> convertMeshFaceSets" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
@ -546,7 +567,7 @@ void Foam::vtkPVFoam::convertMeshPointZones
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::convertMeshPointZones" << endl;
|
||||
Info<< "<beg> convertMeshPointZones" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
@ -563,10 +584,24 @@ void Foam::vtkPVFoam::convertMeshPointZones
|
||||
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)
|
||||
{
|
||||
AddToBlock(output, vtkmesh, range, datasetNo, zoneName);
|
||||
addToBlock(output, vtkmesh, range, datasetNo, zoneName);
|
||||
vtkmesh->Delete();
|
||||
|
||||
partDataset_[partId] = datasetNo++;
|
||||
@ -582,7 +617,7 @@ void Foam::vtkPVFoam::convertMeshPointZones
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::convertMeshPointZones" << endl;
|
||||
Info<< "<end> convertMeshPointZones" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
@ -602,7 +637,7 @@ void Foam::vtkPVFoam::convertMeshPointSets
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::convertMeshPointSets" << endl;
|
||||
Info<< "<beg> convertMeshPointSets" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
@ -622,10 +657,22 @@ void Foam::vtkPVFoam::convertMeshPointSets
|
||||
|
||||
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)
|
||||
{
|
||||
AddToBlock(output, vtkmesh, range, datasetNo, partName);
|
||||
addToBlock(output, vtkmesh, range, datasetNo, partName);
|
||||
vtkmesh->Delete();
|
||||
|
||||
partDataset_[partId] = datasetNo++;
|
||||
@ -640,7 +687,7 @@ void Foam::vtkPVFoam::convertMeshPointSets
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::convertMeshPointSets" << endl;
|
||||
Info<< "<end> convertMeshPointSets" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -30,7 +30,6 @@ License
|
||||
#include "fvMesh.H"
|
||||
#include "IOobjectList.H"
|
||||
#include "passiveParticle.H"
|
||||
#include "vtkOpenFOAMPoints.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkCellArray.h"
|
||||
@ -41,7 +40,7 @@ License
|
||||
|
||||
vtkPolyData* Foam::vtkPVFoam::lagrangianVTKMesh
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const polyMesh& mesh,
|
||||
const word& cloudName
|
||||
)
|
||||
{
|
||||
@ -49,7 +48,7 @@ vtkPolyData* Foam::vtkPVFoam::lagrangianVTKMesh
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::lagrangianVTKMesh - timePath "
|
||||
Info<< "<beg> lagrangianVTKMesh - timePath "
|
||||
<< mesh.time().timePath()/cloud::prefix/cloudName << endl;
|
||||
printMemory();
|
||||
}
|
||||
@ -83,7 +82,7 @@ vtkPolyData* Foam::vtkPVFoam::lagrangianVTKMesh
|
||||
vtkIdType particleId = 0;
|
||||
forAllConstIter(Cloud<passiveParticle>, parcels, iter)
|
||||
{
|
||||
vtkInsertNextOpenFOAMPoint(vtkpoints, iter().position());
|
||||
vtkpoints->InsertNextPoint(iter().position().v_);
|
||||
|
||||
vtkcells->InsertNextCell(1, &particleId);
|
||||
particleId++;
|
||||
@ -98,7 +97,7 @@ vtkPolyData* Foam::vtkPVFoam::lagrangianVTKMesh
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::lagrangianVTKMesh" << endl;
|
||||
Info<< "<end> lagrangianVTKMesh" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -29,8 +29,6 @@ License
|
||||
// OpenFOAM includes
|
||||
#include "fvMesh.H"
|
||||
#include "cellModeller.H"
|
||||
#include "vtkOpenFOAMPoints.H"
|
||||
#include "Swap.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkCellArray.h"
|
||||
@ -56,7 +54,7 @@ vtkUnstructuredGrid* Foam::vtkPVFoam::volumeVTKMesh
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::volumeVTKMesh" << endl;
|
||||
Info<< "<beg> volumeVTKMesh" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
@ -78,11 +76,6 @@ vtkUnstructuredGrid* Foam::vtkPVFoam::volumeVTKMesh
|
||||
// and cells
|
||||
if (!reader_->GetUseVTKPolyhedron())
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "... scanning for polyhedra" << endl;
|
||||
}
|
||||
|
||||
forAll(cellShapes, celli)
|
||||
{
|
||||
const cellModel& model = cellShapes[celli].model();
|
||||
@ -123,21 +116,8 @@ vtkUnstructuredGrid* Foam::vtkPVFoam::volumeVTKMesh
|
||||
// Set size of additional cells mapping array
|
||||
// (from added cell to original cell)
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<<" mesh nCells = " << mesh.nCells() << nl
|
||||
<<" nPoints = " << mesh.nPoints() << nl
|
||||
<<" nAddCells = " << nAddCells << nl
|
||||
<<" nAddPoints = " << nAddPoints << endl;
|
||||
}
|
||||
|
||||
superCells.setSize(mesh.nCells() + nAddCells);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "... converting points" << endl;
|
||||
}
|
||||
|
||||
// Convert OpenFOAM mesh vertices to VTK
|
||||
vtkPoints* vtkpoints = vtkPoints::New();
|
||||
vtkpoints->Allocate(mesh.nPoints() + nAddPoints);
|
||||
@ -146,13 +126,7 @@ vtkUnstructuredGrid* Foam::vtkPVFoam::volumeVTKMesh
|
||||
|
||||
forAll(points, i)
|
||||
{
|
||||
vtkInsertNextOpenFOAMPoint(vtkpoints, points[i]);
|
||||
}
|
||||
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "... converting cells" << endl;
|
||||
vtkpoints->InsertNextPoint(points[i].v_);
|
||||
}
|
||||
|
||||
vtkmesh->Allocate(mesh.nCells() + nAddCells);
|
||||
@ -329,7 +303,7 @@ vtkUnstructuredGrid* Foam::vtkPVFoam::volumeVTKMesh
|
||||
|
||||
// The new vertex from the cell-centre
|
||||
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.
|
||||
bool substituteCell = true;
|
||||
@ -441,7 +415,10 @@ vtkUnstructuredGrid* Foam::vtkPVFoam::volumeVTKMesh
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::volumeVTKMesh" << endl;
|
||||
Info<<"nCells=" << mesh.nCells() <<" nPoints=" << mesh.nPoints()
|
||||
<<" nAddCells=" << nAddCells <<" nAddPoints=" << nAddPoints
|
||||
<< nl
|
||||
<< "<end> volumeVTKMesh" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -28,7 +28,6 @@ License
|
||||
// OpenFOAM includes
|
||||
#include "polyPatch.H"
|
||||
#include "primitivePatch.H"
|
||||
#include "vtkOpenFOAMPoints.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkCellArray.h"
|
||||
@ -48,7 +47,7 @@ vtkPolyData* Foam::vtkPVFoam::patchVTKMesh
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::patchVTKMesh - " << name << endl;
|
||||
Info<< "<beg> patchVTKMesh - " << name << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
@ -59,13 +58,12 @@ vtkPolyData* Foam::vtkPVFoam::patchVTKMesh
|
||||
vtkpoints->Allocate(points.size());
|
||||
forAll(points, i)
|
||||
{
|
||||
vtkInsertNextOpenFOAMPoint(vtkpoints, points[i]);
|
||||
vtkpoints->InsertNextPoint(points[i].v_);
|
||||
}
|
||||
|
||||
vtkmesh->SetPoints(vtkpoints);
|
||||
vtkpoints->Delete();
|
||||
|
||||
|
||||
// Add faces as polygons
|
||||
const faceList& faces = p.localFaces();
|
||||
|
||||
@ -88,7 +86,7 @@ vtkPolyData* Foam::vtkPVFoam::patchVTKMesh
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::patchVTKMesh - " << name << endl;
|
||||
Info<< "<end> patchVTKMesh - " << name << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -36,13 +36,12 @@ License
|
||||
#include "Cloud.H"
|
||||
#include "vtkPVFoamReader.h"
|
||||
|
||||
// local headers
|
||||
#include "vtkPVFoamAddToSelection.H"
|
||||
#include "vtkPVFoamUpdateInfoFields.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkDataArraySelection.h"
|
||||
|
||||
// Templates (only needed here)
|
||||
#include "vtkPVFoamUpdateTemplates.C"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Private Classes * * * * * * * * * * * * * * //
|
||||
|
||||
@ -85,14 +84,14 @@ template<class ZoneType>
|
||||
Foam::wordList Foam::vtkPVFoam::getZoneNames
|
||||
(
|
||||
const ZoneMesh<ZoneType, polyMesh>& zmesh
|
||||
) const
|
||||
)
|
||||
{
|
||||
wordList names(zmesh.size());
|
||||
label nZone = 0;
|
||||
|
||||
forAll(zmesh, zoneI)
|
||||
{
|
||||
if (zmesh[zoneI].size())
|
||||
if (!zmesh[zoneI].empty())
|
||||
{
|
||||
names[nZone++] = zmesh[zoneI].name();
|
||||
}
|
||||
@ -124,7 +123,7 @@ Foam::wordList Foam::vtkPVFoam::getZoneNames(const word& zoneType) const
|
||||
false
|
||||
);
|
||||
|
||||
if (ioObj.typeHeaderOk<cellZoneMesh>(false))
|
||||
if (ioObj.typeHeaderOk<cellZoneMesh>(false, false))
|
||||
{
|
||||
zonesEntries zones(ioObj);
|
||||
|
||||
@ -146,7 +145,7 @@ void Foam::vtkPVFoam::updateInfoInternalMesh
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::updateInfoInternalMesh" << endl;
|
||||
Info<< "<beg> updateInfoInternalMesh" << endl;
|
||||
}
|
||||
|
||||
// Determine mesh parts (internalMesh, patches...)
|
||||
@ -160,10 +159,7 @@ void Foam::vtkPVFoam::updateInfoInternalMesh
|
||||
|
||||
if (debug)
|
||||
{
|
||||
// just for debug info
|
||||
getSelectedArrayEntries(arraySelection);
|
||||
|
||||
Info<< "<end> Foam::vtkPVFoam::updateInfoInternalMesh" << endl;
|
||||
Info<< "<end> updateInfoInternalMesh" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -175,7 +171,7 @@ void Foam::vtkPVFoam::updateInfoLagrangian
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::updateInfoLagrangian" << nl
|
||||
Info<< "<beg> updateInfoLagrangian" << nl
|
||||
<< " " << dbPtr_->timePath()/cloud::prefix << endl;
|
||||
}
|
||||
|
||||
@ -211,10 +207,7 @@ void Foam::vtkPVFoam::updateInfoLagrangian
|
||||
|
||||
if (debug)
|
||||
{
|
||||
// just for debug info
|
||||
getSelectedArrayEntries(arraySelection);
|
||||
|
||||
Info<< "<end> Foam::vtkPVFoam::updateInfoLagrangian" << endl;
|
||||
Info<< "<end> updateInfoLagrangian" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -227,8 +220,8 @@ void Foam::vtkPVFoam::updateInfoPatches
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::updateInfoPatches"
|
||||
<< " [meshPtr=" << (meshPtr_ ? "set" : "nullptr") << "]" << endl;
|
||||
Info<< "<beg> updateInfoPatches"
|
||||
<< " [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
|
||||
if (ioObj.typeHeaderOk<polyBoundaryMesh>(true))
|
||||
if (ioObj.typeHeaderOk<polyBoundaryMesh>(true, false))
|
||||
{
|
||||
polyBoundaryMeshEntries patchEntries(ioObj);
|
||||
|
||||
@ -377,7 +370,7 @@ void Foam::vtkPVFoam::updateInfoPatches
|
||||
}
|
||||
else
|
||||
{
|
||||
groups.insert(groupNames[groupI], labelList(1, patchi));
|
||||
groups.insert(groupNames[groupI], labelList{patchi});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -455,10 +448,7 @@ void Foam::vtkPVFoam::updateInfoPatches
|
||||
|
||||
if (debug)
|
||||
{
|
||||
// just for debug info
|
||||
getSelectedArrayEntries(arraySelection);
|
||||
|
||||
Info<< "<end> Foam::vtkPVFoam::updateInfoPatches" << endl;
|
||||
Info<< "<end> updateInfoPatches" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -475,8 +465,8 @@ void Foam::vtkPVFoam::updateInfoZones
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::updateInfoZones"
|
||||
<< " [meshPtr=" << (meshPtr_ ? "set" : "nullptr") << "]" << endl;
|
||||
Info<< "<beg> updateInfoZones"
|
||||
<< " [meshPtr=" << (meshPtr_ ? "set" : "null") << "]" << endl;
|
||||
}
|
||||
|
||||
wordList namesLst;
|
||||
@ -551,10 +541,7 @@ void Foam::vtkPVFoam::updateInfoZones
|
||||
|
||||
if (debug)
|
||||
{
|
||||
// just for debug info
|
||||
getSelectedArrayEntries(arraySelection);
|
||||
|
||||
Info<< "<end> Foam::vtkPVFoam::updateInfoZones" << endl;
|
||||
Info<< "<end> updateInfoZones" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -571,7 +558,7 @@ void Foam::vtkPVFoam::updateInfoSets
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::updateInfoSets" << endl;
|
||||
Info<< "<beg> updateInfoSets" << endl;
|
||||
}
|
||||
|
||||
// Add names of sets. Search for last time directory with a sets
|
||||
@ -596,7 +583,7 @@ void Foam::vtkPVFoam::updateInfoSets
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< " Foam::vtkPVFoam::updateInfoSets read "
|
||||
Info<< " updateInfoSets read "
|
||||
<< objects.names() << " from " << setsInstance << endl;
|
||||
}
|
||||
|
||||
@ -627,28 +614,41 @@ void Foam::vtkPVFoam::updateInfoSets
|
||||
|
||||
if (debug)
|
||||
{
|
||||
// just for debug info
|
||||
getSelectedArrayEntries(arraySelection);
|
||||
|
||||
Info<< "<end> Foam::vtkPVFoam::updateInfoSets" << endl;
|
||||
Info<< "<end> 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)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::updateInfoLagrangianFields"
|
||||
<< endl;
|
||||
Info<< "<beg> updateInfoLagrangianFields" << endl;
|
||||
}
|
||||
|
||||
vtkDataArraySelection* fieldSelection =
|
||||
reader_->GetLagrangianFieldSelection();
|
||||
|
||||
// preserve the enabled selections
|
||||
stringList enabledEntries = getSelectedArrayEntries(fieldSelection);
|
||||
fieldSelection->RemoveAllArrays();
|
||||
stringList enabledEntries = getSelectedArrayEntries(select);
|
||||
select->RemoveAllArrays();
|
||||
|
||||
// TODO - currently only get fields from ONE cloud
|
||||
// have to decide if the second set of fields get mixed in
|
||||
@ -678,44 +678,37 @@ void Foam::vtkPVFoam::updateInfoLagrangianFields()
|
||||
lagrangianPrefix/cloudName
|
||||
);
|
||||
|
||||
addToSelection<IOField<label>>
|
||||
(
|
||||
fieldSelection,
|
||||
objects
|
||||
);
|
||||
addToSelection<IOField<scalar>>
|
||||
(
|
||||
fieldSelection,
|
||||
objects
|
||||
);
|
||||
addToSelection<IOField<vector>>
|
||||
(
|
||||
fieldSelection,
|
||||
objects
|
||||
);
|
||||
addToSelection<IOField<sphericalTensor>>
|
||||
(
|
||||
fieldSelection,
|
||||
|
||||
objects
|
||||
);
|
||||
addToSelection<IOField<symmTensor>>
|
||||
(
|
||||
fieldSelection,
|
||||
objects
|
||||
);
|
||||
addToSelection<IOField<tensor>>
|
||||
(
|
||||
fieldSelection,
|
||||
objects
|
||||
);
|
||||
addToSelection<IOField<label>>(select, objects);
|
||||
addToSelection<IOField<scalar>>(select, objects);
|
||||
addToSelection<IOField<vector>>(select, objects);
|
||||
addToSelection<IOField<sphericalTensor>>(select, objects);
|
||||
addToSelection<IOField<symmTensor>>(select, objects);
|
||||
addToSelection<IOField<tensor>>(select, objects);
|
||||
|
||||
// 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)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::updateInfoLagrangianFields - "
|
||||
Info<< "<end> updateInfoLagrangianFields - "
|
||||
<< "lagrangian objects.size() = " << objects.size() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -26,8 +26,8 @@ InClass
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkPVFoamUpdateInfoFields_H
|
||||
#define vtkPVFoamUpdateInfoFields_H
|
||||
#ifndef vtkPVFoamUpdateTemplates_C
|
||||
#define vtkPVFoamUpdateTemplates_C
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -39,19 +39,17 @@ void Foam::vtkPVFoam::updateInfoFields
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::updateInfoFields <"
|
||||
Info<< "<beg> updateInfoFields <"
|
||||
<< meshType::Mesh::typeName
|
||||
<< "> [meshPtr=" << (meshPtr_ ? "set" : "nullptr") << "]"
|
||||
<< "> [meshPtr=" << (meshPtr_ ? "set" : "null") << "]"
|
||||
<< endl;
|
||||
}
|
||||
|
||||
stringList enabledEntries;
|
||||
// enable 'p' and 'U' on the first call
|
||||
if (select->GetNumberOfArrays() == 0 && !meshPtr_)
|
||||
if (!select->GetNumberOfArrays() && !meshPtr_)
|
||||
{
|
||||
enabledEntries.setSize(2);
|
||||
enabledEntries[0] = "p";
|
||||
enabledEntries[1] = "U";
|
||||
// enable 'p' and 'U' only on the first call
|
||||
enabledEntries = { "p", "U" };
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -72,7 +70,7 @@ void Foam::vtkPVFoam::updateInfoFields
|
||||
// Search for list of objects for this time and mesh region
|
||||
IOobjectList objects(dbPtr_(), dbPtr_().timeName(), regionPrefix);
|
||||
|
||||
//- Add volume fields to GUI
|
||||
// Add volume fields to GUI
|
||||
addToSelection<GeometricField<scalar, patchType, meshType>>
|
||||
(
|
||||
select,
|
||||
@ -93,13 +91,14 @@ void Foam::vtkPVFoam::updateInfoFields
|
||||
select,
|
||||
objects
|
||||
);
|
||||
|
||||
addToSelection<GeometricField<tensor, patchType, meshType>>
|
||||
(
|
||||
select,
|
||||
objects
|
||||
);
|
||||
|
||||
//- Add dimensioned fields to GUI
|
||||
// Add dimensioned fields to GUI
|
||||
addToSelection<DimensionedField<scalar, meshType>>
|
||||
(
|
||||
select,
|
||||
@ -132,7 +131,7 @@ void Foam::vtkPVFoam::updateInfoFields
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::updateInfoFields" << endl;
|
||||
Info<< "<end> updateInfoFields" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -15,6 +15,7 @@ include_directories(
|
||||
$ENV{WM_PROJECT_DIR}/src/OSspecific/$ENV{WM_OSTYPE}/lnInclude
|
||||
$ENV{WM_PROJECT_DIR}/src/meshing/blockMesh/lnInclude
|
||||
${PROJECT_SOURCE_DIR}/../vtkPVblockMesh
|
||||
${PROJECT_SOURCE_DIR}/../../foamPv/lnInclude
|
||||
)
|
||||
|
||||
add_definitions(
|
||||
@ -63,6 +64,7 @@ target_link_libraries(
|
||||
PVblockMeshReader_SM
|
||||
LINK_PUBLIC
|
||||
vtkPVblockMesh-pv${PARAVIEW_VERSION_MAJOR}.${PARAVIEW_VERSION_MINOR}
|
||||
foamPv-pv${PARAVIEW_VERSION_MAJOR}.${PARAVIEW_VERSION_MINOR}
|
||||
blockMesh
|
||||
OpenFOAM
|
||||
)
|
||||
|
||||
@ -56,8 +56,8 @@ vtkPVblockMeshReader::vtkPVblockMeshReader()
|
||||
|
||||
SetNumberOfInputPorts(0);
|
||||
|
||||
FileName = nullptr;
|
||||
foamData_ = nullptr;
|
||||
FileName = nullptr;
|
||||
backend_ = nullptr;
|
||||
|
||||
ShowPointNumbers = true;
|
||||
|
||||
@ -73,7 +73,6 @@ vtkPVblockMeshReader::vtkPVblockMeshReader()
|
||||
);
|
||||
SelectionObserver->SetClientData(this);
|
||||
|
||||
|
||||
BlockSelection->AddObserver
|
||||
(
|
||||
vtkCommand::ModifiedEvent,
|
||||
@ -94,11 +93,11 @@ vtkPVblockMeshReader::~vtkPVblockMeshReader()
|
||||
{
|
||||
vtkDebugMacro(<<"Destructor");
|
||||
|
||||
if (foamData_)
|
||||
if (backend_)
|
||||
{
|
||||
// Remove point numbers
|
||||
updatePointNumbersView(false);
|
||||
delete foamData_;
|
||||
delete backend_;
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
foamData_->updateInfo();
|
||||
backend_->updateInfo();
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -176,7 +175,7 @@ int vtkPVblockMeshReader::RequestData
|
||||
}
|
||||
|
||||
// Catch previous error
|
||||
if (!foamData_)
|
||||
if (!backend_)
|
||||
{
|
||||
vtkErrorMacro("Reader failed - perhaps no mesh?");
|
||||
return 0;
|
||||
@ -207,12 +206,11 @@ int vtkPVblockMeshReader::RequestData
|
||||
<< output->GetNumberOfBlocks() << " blocks\n";
|
||||
}
|
||||
|
||||
|
||||
foamData_->Update(output);
|
||||
backend_->Update(output);
|
||||
updatePointNumbersView(ShowPointNumbers);
|
||||
|
||||
// Do any cleanup on the OpenFOAM side
|
||||
foamData_->CleanUp();
|
||||
backend_->CleanUp();
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -221,11 +219,11 @@ int vtkPVblockMeshReader::RequestData
|
||||
void vtkPVblockMeshReader::SetRefresh(bool val)
|
||||
{
|
||||
// Delete the current blockMesh to force re-read and update
|
||||
if (foamData_)
|
||||
if (backend_)
|
||||
{
|
||||
updatePointNumbersView(false);
|
||||
delete foamData_;
|
||||
foamData_ = 0;
|
||||
delete backend_;
|
||||
backend_ = nullptr;
|
||||
}
|
||||
|
||||
Modified();
|
||||
@ -254,7 +252,7 @@ void vtkPVblockMeshReader::updatePointNumbersView(const bool show)
|
||||
|
||||
// Server manager model for querying items in the server manager
|
||||
pqServerManagerModel* smModel = appCore->getServerManagerModel();
|
||||
if (!smModel || !foamData_)
|
||||
if (!smModel || !backend_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -264,7 +262,7 @@ void vtkPVblockMeshReader::updatePointNumbersView(const bool show)
|
||||
QList<pqRenderView*> renderViews = smModel->findItems<pqRenderView*>();
|
||||
for (int viewI=0; viewI<renderViews.size(); ++viewI)
|
||||
{
|
||||
foamData_->renderPointNumbers
|
||||
backend_->renderPointNumbers
|
||||
(
|
||||
renderViews[viewI]->getRenderViewProxy()->GetRenderer(),
|
||||
show
|
||||
@ -283,7 +281,7 @@ void vtkPVblockMeshReader::PrintSelf(ostream& os, vtkIndent indent)
|
||||
os << indent << "File name: "
|
||||
<< (this->FileName ? this->FileName : "(none)") << "\n";
|
||||
|
||||
foamData_->PrintSelf(os, indent);
|
||||
backend_->PrintSelf(os, indent);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -114,7 +114,7 @@ protected:
|
||||
vtkPVblockMeshReader();
|
||||
|
||||
//- Destructor
|
||||
~vtkPVblockMeshReader();
|
||||
virtual ~vtkPVblockMeshReader();
|
||||
|
||||
//- Return information about mesh, times, etc without loading anything
|
||||
virtual int RequestInformation
|
||||
@ -160,7 +160,8 @@ private:
|
||||
|
||||
vtkDataArraySelection* CurvedEdgesSelection;
|
||||
|
||||
Foam::vtkPVblockMesh* foamData_;
|
||||
//- Backend portion of the reader
|
||||
Foam::vtkPVblockMesh* backend_;
|
||||
};
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
vtkPVblockMesh.C
|
||||
vtkPVblockMeshConvert.C
|
||||
vtkPVblockMeshUtils.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libvtkPVblockMesh-pv${ParaView_MAJOR}
|
||||
|
||||
@ -7,12 +7,12 @@ EXE_INC = \
|
||||
-I$(LIB_SRC)/mesh/blockMesh/lnInclude \
|
||||
-I$(ParaView_INCLUDE_DIR) \
|
||||
-I$(ParaView_INCLUDE_DIR)/vtkkwiml \
|
||||
-I../../vtkPVReaders/lnInclude \
|
||||
-I../../foamPv/lnInclude \
|
||||
-I../PVblockMeshReader
|
||||
|
||||
LIB_LIBS = \
|
||||
-lmeshTools \
|
||||
-lfileFormats \
|
||||
-lblockMesh \
|
||||
-L$(FOAM_LIBBIN) -lvtkPVReaders-pv${ParaView_MAJOR} \
|
||||
-L$(FOAM_LIBBIN) -lfoamPv-pv${ParaView_MAJOR} \
|
||||
$(GLIBS)
|
||||
|
||||
@ -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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -67,8 +67,8 @@ void Foam::vtkPVblockMesh::updateInfoBlocks
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVblockMesh::updateInfoBlocks"
|
||||
<< " [meshPtr=" << (meshPtr_ ? "set" : "nullptr") << "]" << endl;
|
||||
Info<< "<beg> updateInfoBlocks"
|
||||
<< " [meshPtr=" << (meshPtr_ ? "set" : "null") << "]" << endl;
|
||||
}
|
||||
|
||||
range.reset(arraySelection->GetNumberOfArrays());
|
||||
@ -99,10 +99,7 @@ void Foam::vtkPVblockMesh::updateInfoBlocks
|
||||
|
||||
if (debug)
|
||||
{
|
||||
// just for debug info
|
||||
getSelectedArrayEntries(arraySelection);
|
||||
|
||||
Info<< "<end> Foam::vtkPVblockMesh::updateInfoBlocks" << endl;
|
||||
Info<< "<end> updateInfoBlocks" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -116,8 +113,8 @@ void Foam::vtkPVblockMesh::updateInfoEdges
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVblockMesh::updateInfoEdges"
|
||||
<< " [meshPtr=" << (meshPtr_ ? "set" : "nullptr") << "]" << endl;
|
||||
Info<< "<beg> updateInfoEdges"
|
||||
<< " [meshPtr=" << (meshPtr_ ? "set" : "null") << "]" << endl;
|
||||
}
|
||||
|
||||
range.reset(arraySelection->GetNumberOfArrays());
|
||||
@ -141,10 +138,7 @@ void Foam::vtkPVblockMesh::updateInfoEdges
|
||||
|
||||
if (debug)
|
||||
{
|
||||
// just for debug info
|
||||
getSelectedArrayEntries(arraySelection);
|
||||
|
||||
Info<< "<end> Foam::vtkPVblockMesh::updateInfoEdges" << endl;
|
||||
Info<< "<end> updateInfoEdges" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -168,8 +162,7 @@ Foam::vtkPVblockMesh::vtkPVblockMesh
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Foam::vtkPVblockMesh::vtkPVblockMesh - "
|
||||
<< FileName << endl;
|
||||
Info<< "vtkPVblockMesh - " << FileName << endl;
|
||||
}
|
||||
|
||||
// avoid argList and get rootPath/caseName directly from the file
|
||||
@ -255,7 +248,7 @@ Foam::vtkPVblockMesh::~vtkPVblockMesh()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVblockMesh::~vtkPVblockMesh" << endl;
|
||||
Info<< "~vtkPVblockMesh" << endl;
|
||||
}
|
||||
|
||||
// Hmm. pointNumberTextActors are not getting removed
|
||||
@ -276,8 +269,8 @@ void Foam::vtkPVblockMesh::updateInfo()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVblockMesh::updateInfo"
|
||||
<< " [meshPtr=" << (meshPtr_ ? "set" : "nullptr") << "] " << endl;
|
||||
Info<< "<beg> updateInfo"
|
||||
<< " [meshPtr=" << (meshPtr_ ? "set" : "null") << "] " << endl;
|
||||
}
|
||||
|
||||
resetCounters();
|
||||
@ -285,8 +278,7 @@ void Foam::vtkPVblockMesh::updateInfo()
|
||||
vtkDataArraySelection* blockSelection = reader_->GetBlockSelection();
|
||||
vtkDataArraySelection* edgeSelection = reader_->GetCurvedEdgesSelection();
|
||||
|
||||
// enable 'internalMesh' on the first call
|
||||
// or preserve the enabled selections
|
||||
// preserve the enabled selections if possible
|
||||
stringList enabledParts;
|
||||
stringList enabledEdges;
|
||||
const bool firstTime = (!blockSelection->GetNumberOfArrays() && !meshPtr_);
|
||||
@ -313,12 +305,12 @@ void Foam::vtkPVblockMesh::updateInfo()
|
||||
if (!firstTime)
|
||||
{
|
||||
setSelectedArrayEntries(blockSelection, enabledParts);
|
||||
setSelectedArrayEntries(edgeSelection, enabledEdges);
|
||||
setSelectedArrayEntries(edgeSelection, enabledEdges);
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVblockMesh::updateInfo" << endl;
|
||||
Info<< "<end> updateInfo" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -327,7 +319,7 @@ void Foam::vtkPVblockMesh::updateFoamMesh()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVblockMesh::updateFoamMesh" << endl;
|
||||
Info<< "<beg> updateFoamMesh" << endl;
|
||||
}
|
||||
|
||||
// Check to see if the OpenFOAM mesh has been created
|
||||
@ -377,7 +369,7 @@ void Foam::vtkPVblockMesh::updateFoamMesh()
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVblockMesh::updateFoamMesh" << endl;
|
||||
Info<< "<end> updateFoamMesh" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -390,10 +382,10 @@ void Foam::vtkPVblockMesh::Update
|
||||
reader_->UpdateProgress(0.1);
|
||||
|
||||
// Set up mesh parts selection(s)
|
||||
updateBoolListStatus(blockStatus_, reader_->GetBlockSelection());
|
||||
getSelected(blockStatus_, reader_->GetBlockSelection());
|
||||
|
||||
// Set up curved edges selection(s)
|
||||
updateBoolListStatus(edgeStatus_, reader_->GetCurvedEdgesSelection());
|
||||
getSelected(edgeStatus_, reader_->GetCurvedEdgesSelection());
|
||||
|
||||
reader_->UpdateProgress(0.2);
|
||||
|
||||
|
||||
@ -41,10 +41,7 @@ SourceFiles
|
||||
#ifndef vtkPVblockMesh_H
|
||||
#define vtkPVblockMesh_H
|
||||
|
||||
#include "className.H"
|
||||
#include "fileName.H"
|
||||
#include "stringList.H"
|
||||
#include "wordList.H"
|
||||
#include "foamPvCore.H"
|
||||
|
||||
// * * * * * * * * * * * * * Forward Declarations * * * * * * * * * * * * * //
|
||||
|
||||
@ -76,85 +73,9 @@ template<class Type> class List;
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
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
|
||||
|
||||
//- Access to the controlling vtkPVblockMeshReader
|
||||
@ -194,24 +115,6 @@ class vtkPVblockMesh
|
||||
|
||||
// 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
|
||||
void resetCounters();
|
||||
|
||||
@ -240,36 +143,6 @@ class vtkPVblockMesh
|
||||
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
|
||||
vtkPVblockMesh(const vtkPVblockMesh&) = delete;
|
||||
|
||||
|
||||
@ -30,8 +30,6 @@ License
|
||||
#include "blockMesh.H"
|
||||
#include "Time.H"
|
||||
|
||||
#include "vtkOpenFOAMPoints.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkCellArray.h"
|
||||
#include "vtkDataArraySelection.h"
|
||||
@ -41,6 +39,26 @@ License
|
||||
#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 * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::vtkPVblockMesh::convertMeshBlocks
|
||||
@ -59,7 +77,7 @@ void Foam::vtkPVblockMesh::convertMeshBlocks
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVblockMesh::convertMeshBlocks" << endl;
|
||||
Info<< "<beg> convertMeshBlocks" << endl;
|
||||
}
|
||||
|
||||
int blockI = 0;
|
||||
@ -79,19 +97,16 @@ void Foam::vtkPVblockMesh::convertMeshBlocks
|
||||
|
||||
const blockDescriptor& blockDef = blkMesh[blockI];
|
||||
|
||||
vtkUnstructuredGrid* vtkmesh = vtkUnstructuredGrid::New();
|
||||
|
||||
// Convert OpenFOAM mesh vertices to VTK
|
||||
vtkPoints *vtkpoints = vtkPoints::New();
|
||||
vtkpoints->Allocate( blockDef.nPoints() );
|
||||
vtkpoints->Allocate(blockDef.nPoints());
|
||||
const labelList& blockLabels = blockDef.blockShape();
|
||||
|
||||
vtkmesh->Allocate(1);
|
||||
vtkIdType nodeIds[8];
|
||||
|
||||
forAll(blockLabels, ptI)
|
||||
{
|
||||
vtkInsertNextOpenFOAMPoint
|
||||
insertNextPoint
|
||||
(
|
||||
vtkpoints,
|
||||
blockPoints[blockLabels[ptI]],
|
||||
@ -101,6 +116,8 @@ void Foam::vtkPVblockMesh::convertMeshBlocks
|
||||
nodeIds[ptI] = ptI;
|
||||
}
|
||||
|
||||
vtkUnstructuredGrid* vtkmesh = vtkUnstructuredGrid::New();
|
||||
vtkmesh->Allocate(1);
|
||||
vtkmesh->InsertNextCell
|
||||
(
|
||||
VTK_HEXAHEDRON,
|
||||
@ -111,7 +128,7 @@ void Foam::vtkPVblockMesh::convertMeshBlocks
|
||||
vtkmesh->SetPoints(vtkpoints);
|
||||
vtkpoints->Delete();
|
||||
|
||||
AddToBlock
|
||||
addToBlock
|
||||
(
|
||||
output, vtkmesh, range, datasetNo,
|
||||
selection->GetArrayName(partId)
|
||||
@ -130,7 +147,7 @@ void Foam::vtkPVblockMesh::convertMeshBlocks
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVblockMesh::convertMeshBlocks" << endl;
|
||||
Info<< "<end> convertMeshBlocks" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -201,7 +218,7 @@ void Foam::vtkPVblockMesh::convertMeshEdges
|
||||
vtkIdType pointIds[edgePoints.size()];
|
||||
forAll(edgePoints, ptI)
|
||||
{
|
||||
vtkInsertNextOpenFOAMPoint
|
||||
insertNextPoint
|
||||
(
|
||||
vtkpoints,
|
||||
edgePoints[ptI],
|
||||
@ -220,7 +237,7 @@ void Foam::vtkPVblockMesh::convertMeshEdges
|
||||
vtkmesh->SetPoints(vtkpoints);
|
||||
vtkpoints->Delete();
|
||||
|
||||
AddToBlock
|
||||
addToBlock
|
||||
(
|
||||
output, vtkmesh, range, datasetNo,
|
||||
selection->GetArrayName(partId)
|
||||
@ -242,7 +259,7 @@ void Foam::vtkPVblockMesh::convertMeshEdges
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVblockMesh::convertMeshEdges" << endl;
|
||||
Info<< "<end> convertMeshEdges" << endl;
|
||||
}
|
||||
|
||||
}
|
||||
@ -263,7 +280,7 @@ void Foam::vtkPVblockMesh::convertMeshCorners
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVblockMesh::convertMeshCorners" << endl;
|
||||
Info<< "<beg> convertMeshCorners" << endl;
|
||||
}
|
||||
|
||||
if (true) // or some flag or other condition
|
||||
@ -278,7 +295,7 @@ void Foam::vtkPVblockMesh::convertMeshCorners
|
||||
vtkIdType pointId = 0;
|
||||
forAll(blockPoints, ptI)
|
||||
{
|
||||
vtkInsertNextOpenFOAMPoint
|
||||
insertNextPoint
|
||||
(
|
||||
vtkpoints,
|
||||
blockPoints[ptI],
|
||||
@ -295,7 +312,7 @@ void Foam::vtkPVblockMesh::convertMeshCorners
|
||||
vtkmesh->SetVerts(vtkcells);
|
||||
vtkcells->Delete();
|
||||
|
||||
AddToBlock(output, vtkmesh, range, datasetNo, range.name());
|
||||
addToBlock(output, vtkmesh, range, datasetNo, range.name());
|
||||
vtkmesh->Delete();
|
||||
|
||||
datasetNo++;
|
||||
@ -309,7 +326,7 @@ void Foam::vtkPVblockMesh::convertMeshCorners
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVblockMesh::convertMeshCorners" << endl;
|
||||
Info<< "<end> convertMeshCorners" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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 * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,3 @@
|
||||
foamPvCore.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libfoamPv-pv${ParaView_MAJOR}
|
||||
@ -2,6 +2,7 @@ sinclude $(GENERAL_RULES)/paraview
|
||||
|
||||
EXE_INC = \
|
||||
${c++LESSWARN} \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(ParaView_INCLUDE_DIR) \
|
||||
-I$(ParaView_INCLUDE_DIR)/vtkkwiml
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -21,17 +21,13 @@ License
|
||||
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 "vtkPVReaders.H"
|
||||
#include "foamPvCore.H"
|
||||
|
||||
// OpenFOAM includes
|
||||
#include "IFstream.H"
|
||||
#include "memInfo.H"
|
||||
#include "DynamicList.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkDataArraySelection.h"
|
||||
#include "vtkDataSet.h"
|
||||
#include "vtkMultiBlockDataSet.h"
|
||||
@ -41,57 +37,28 @@ Description
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(vtkPVReaders, 0);
|
||||
defineTypeNameAndDebug(foamPvCore, 0);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
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
|
||||
void Foam::foamPvCore::addToBlock
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
vtkDataSet* dataset,
|
||||
const partInfo& selector,
|
||||
const arrayRange& selector,
|
||||
const label datasetNo,
|
||||
const std::string& datasetName
|
||||
)
|
||||
{
|
||||
const int blockNo = selector.block();
|
||||
|
||||
vtkDataObject* blockDO = output->GetBlock(blockNo);
|
||||
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO);
|
||||
vtkDataObject* dataObj = output->GetBlock(blockNo);
|
||||
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(dataObj);
|
||||
|
||||
if (!block)
|
||||
{
|
||||
if (blockDO)
|
||||
if (dataObj)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Block already has a vtkDataSet assigned to it"
|
||||
@ -114,7 +81,7 @@ void Foam::vtkPVReaders::AddToBlock
|
||||
|
||||
block->SetBlock(datasetNo, dataset);
|
||||
|
||||
// name the block when assigning dataset 0
|
||||
// name the output block when assigning dataset 0
|
||||
if (datasetNo == 0)
|
||||
{
|
||||
output->GetMetaData(blockNo)->Set
|
||||
@ -135,38 +102,19 @@ void Foam::vtkPVReaders::AddToBlock
|
||||
}
|
||||
|
||||
|
||||
vtkDataSet* Foam::vtkPVReaders::GetDataSetFromBlock
|
||||
int Foam::foamPvCore::getNumberOfDataSets
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
const partInfo& selector,
|
||||
const label datasetNo
|
||||
const arrayRange& selector
|
||||
)
|
||||
{
|
||||
const int blockNo = selector.block();
|
||||
|
||||
vtkDataObject* blockDO = output->GetBlock(blockNo);
|
||||
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO);
|
||||
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast
|
||||
(
|
||||
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)
|
||||
{
|
||||
return block->GetNumberOfBlocks();
|
||||
@ -176,54 +124,76 @@ Foam::label Foam::vtkPVReaders::GetNumberOfDataSets
|
||||
}
|
||||
|
||||
|
||||
// Foam::word Foam::vtkPVReaders::getPartName(int partId)
|
||||
// {
|
||||
// return getFirstWord(reader_->GetPartArrayName(partId));
|
||||
// }
|
||||
int Foam::foamPvCore::getSelected
|
||||
(
|
||||
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
|
||||
)
|
||||
{
|
||||
int nElem = select->GetNumberOfArrays();
|
||||
wordHashSet selections(2*nElem);
|
||||
const int n = select->GetNumberOfArrays();
|
||||
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,
|
||||
const partInfo& selector
|
||||
const arrayRange& selector
|
||||
)
|
||||
{
|
||||
int nElem = select->GetNumberOfArrays();
|
||||
wordHashSet selections(2*nElem);
|
||||
const int n = select->GetNumberOfArrays();
|
||||
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
|
||||
)
|
||||
@ -240,14 +210,13 @@ Foam::stringList Foam::vtkPVReaders::getSelectedArrayEntries
|
||||
}
|
||||
selections.setSize(nElem);
|
||||
|
||||
|
||||
if (debug)
|
||||
if (debug > 1)
|
||||
{
|
||||
label nElem = select->GetNumberOfArrays();
|
||||
const int n = select->GetNumberOfArrays();
|
||||
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(";
|
||||
|
||||
@ -262,31 +231,30 @@ Foam::stringList Foam::vtkPVReaders::getSelectedArrayEntries
|
||||
}
|
||||
|
||||
|
||||
Foam::stringList Foam::vtkPVReaders::getSelectedArrayEntries
|
||||
Foam::stringList Foam::foamPvCore::getSelectedArrayEntries
|
||||
(
|
||||
vtkDataArraySelection* select,
|
||||
const partInfo& selector
|
||||
const arrayRange& selector
|
||||
)
|
||||
{
|
||||
stringList selections(selector.size());
|
||||
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);
|
||||
|
||||
|
||||
if (debug)
|
||||
if (debug > 1)
|
||||
{
|
||||
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(";
|
||||
|
||||
@ -301,19 +269,19 @@ Foam::stringList Foam::vtkPVReaders::getSelectedArrayEntries
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPVReaders::setSelectedArrayEntries
|
||||
void Foam::foamPvCore::setSelectedArrayEntries
|
||||
(
|
||||
vtkDataArraySelection* select,
|
||||
const stringList& selections
|
||||
)
|
||||
{
|
||||
const int nElem = select->GetNumberOfArrays();
|
||||
const int n = select->GetNumberOfArrays();
|
||||
select->DisableAllArrays();
|
||||
|
||||
// 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)
|
||||
{
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -21,39 +21,33 @@ License
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Namespace
|
||||
Foam::vtkPVReaders
|
||||
|
||||
Description
|
||||
A collection of helper functions when building a reader interface in
|
||||
ParaView3.
|
||||
Helpers for OpenFOAM reader interfaces in ParaView.
|
||||
|
||||
SourceFiles
|
||||
vtkPVReaders.C
|
||||
foamPvCore.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkPVReaders_H
|
||||
#define vtkPVReaders_H
|
||||
#ifndef foamPvCore_H
|
||||
#define foamPvCore_H
|
||||
|
||||
#include "className.H"
|
||||
#include "fileName.H"
|
||||
#include "stringList.H"
|
||||
#include "boolList.H"
|
||||
#include "pointList.H"
|
||||
#include "wordList.H"
|
||||
#include "HashSet.H"
|
||||
#include "Hash.H"
|
||||
#include "hashedWordList.H"
|
||||
|
||||
#include "vtkPoints.h"
|
||||
|
||||
// * * * * * * * * * * * * * Forward Declarations * * * * * * * * * * * * * //
|
||||
|
||||
class vtkDataArraySelection;
|
||||
class vtkDataSet;
|
||||
class vtkPoints;
|
||||
class vtkPVFoamReader;
|
||||
class vtkRenderer;
|
||||
class vtkTextActor;
|
||||
class vtkMultiBlockDataSet;
|
||||
class vtkPolyData;
|
||||
class vtkUnstructuredGrid;
|
||||
class vtkIndent;
|
||||
|
||||
|
||||
@ -61,13 +55,20 @@ class vtkIndent;
|
||||
|
||||
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 partInfo
|
||||
class IOobjectList;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class foamPvCore Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class foamPvCore
|
||||
{
|
||||
public:
|
||||
|
||||
//- Bookkeeping for GUI checklists and multi-block organization
|
||||
// Works like a SubList selection.
|
||||
class arrayRange
|
||||
{
|
||||
const char *name_;
|
||||
int block_;
|
||||
@ -76,11 +77,12 @@ namespace vtkPVReaders
|
||||
|
||||
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),
|
||||
block_(blockNo),
|
||||
start_(-1),
|
||||
start_(0),
|
||||
size_(0)
|
||||
{}
|
||||
|
||||
@ -98,42 +100,47 @@ namespace vtkPVReaders
|
||||
return prev;
|
||||
}
|
||||
|
||||
//- Return the name
|
||||
const char* name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- The array start index
|
||||
int start() const
|
||||
{
|
||||
return start_;
|
||||
}
|
||||
|
||||
//- The array end index
|
||||
int end() const
|
||||
{
|
||||
return start_ + size_;
|
||||
}
|
||||
|
||||
//- The sub-list size
|
||||
int size() const
|
||||
{
|
||||
return size_;
|
||||
}
|
||||
|
||||
//- True if the sub-list is empty
|
||||
bool empty() const
|
||||
{
|
||||
return !size_;
|
||||
}
|
||||
|
||||
void reset()
|
||||
//- Reset the size to zero and optionally assign a new start
|
||||
void reset(const int startAt = 0)
|
||||
{
|
||||
start_ = -1;
|
||||
size_ = 0;
|
||||
start_ = startAt;
|
||||
size_ = 0;
|
||||
}
|
||||
|
||||
//- Assign new start and reset the size
|
||||
void operator=(const int i)
|
||||
{
|
||||
start_ = i;
|
||||
size_ = 0;
|
||||
reset(i);
|
||||
}
|
||||
|
||||
//- Increment the size
|
||||
@ -141,81 +148,132 @@ namespace vtkPVReaders
|
||||
{
|
||||
size_ += n;
|
||||
}
|
||||
};
|
||||
|
||||
}; // End class arrayRange
|
||||
|
||||
|
||||
//- Convenience method use to convert the readers from VTK 5
|
||||
// multiblock API to the current composite data infrastructure
|
||||
void AddToBlock
|
||||
private:
|
||||
|
||||
// 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,
|
||||
vtkDataSet* dataset,
|
||||
const partInfo& selector,
|
||||
const arrayRange& selector,
|
||||
const label datasetNo,
|
||||
const std::string& datasetName
|
||||
);
|
||||
|
||||
|
||||
//- Convenience method use to convert the readers from VTK 5
|
||||
// multiblock API to the current composite data infrastructure
|
||||
vtkDataSet* GetDataSetFromBlock
|
||||
//- Convenience method for the VTK multiblock API
|
||||
// Always returns a nullptr if datasetNo is negative
|
||||
template<class Type=vtkDataSet>
|
||||
static Type* getDataFromBlock
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
const partInfo& selector,
|
||||
const arrayRange& selector,
|
||||
const label datasetNo
|
||||
);
|
||||
|
||||
//- Convenience method use to convert the readers from VTK 5
|
||||
// multiblock API to the current composite data infrastructure
|
||||
// ununsed at the moment
|
||||
label GetNumberOfDataSets
|
||||
//- Convenience method for the VTK multiblock API
|
||||
static int getNumberOfDataSets
|
||||
(
|
||||
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
|
||||
wordHashSet getSelected
|
||||
static hashedWordList getSelected
|
||||
(
|
||||
vtkDataArraySelection* select
|
||||
);
|
||||
|
||||
|
||||
//- Retrieve a sub-list of the current selections
|
||||
wordHashSet getSelected
|
||||
static hashedWordList getSelected
|
||||
(
|
||||
vtkDataArraySelection*,
|
||||
const partInfo&
|
||||
vtkDataArraySelection* select,
|
||||
const arrayRange& selector
|
||||
);
|
||||
|
||||
|
||||
//- Retrieve the current selections
|
||||
stringList getSelectedArrayEntries(vtkDataArraySelection*);
|
||||
static stringList getSelectedArrayEntries
|
||||
(
|
||||
vtkDataArraySelection* select
|
||||
);
|
||||
|
||||
//- Retrieve a sub-list of the current selections
|
||||
stringList getSelectedArrayEntries
|
||||
static stringList getSelectedArrayEntries
|
||||
(
|
||||
vtkDataArraySelection* select,
|
||||
const partInfo& selector
|
||||
const arrayRange& selector
|
||||
);
|
||||
|
||||
|
||||
//- Set selection(s)
|
||||
void setSelectedArrayEntries
|
||||
static void setSelectedArrayEntries
|
||||
(
|
||||
vtkDataArraySelection*,
|
||||
const stringList&
|
||||
vtkDataArraySelection* select,
|
||||
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
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "foamPvCoreTemplates.C"
|
||||
#endif
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -23,43 +23,57 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkPVFoamAddToSelection_H
|
||||
#define vtkPVFoamAddToSelection_H
|
||||
|
||||
// OpenFOAM includes
|
||||
#include "IOobjectList.H"
|
||||
#include "SortableList.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkDataArraySelection.h"
|
||||
#include "vtkMultiBlockDataSet.h"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
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,
|
||||
const IOobjectList& objectLst,
|
||||
const IOobjectList& objects,
|
||||
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
|
||||
(
|
||||
(names[nameI] + suffix).c_str()
|
||||
);
|
||||
select->AddArray(names[i].c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
select->AddArray
|
||||
(
|
||||
(names[nameI]).c_str()
|
||||
);
|
||||
select->AddArray((names[i] + suffix).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,8 +81,4 @@ Foam::label Foam::vtkPVFoam::addToSelection
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -21,36 +21,57 @@ License
|
||||
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
|
||||
Description
|
||||
Helpers for OpenFOAM reader interfaces in ParaView.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkOpenFOAMTupleRemap_H
|
||||
#define vtkOpenFOAMTupleRemap_H
|
||||
#ifndef foamPvFields_H
|
||||
#define foamPvFields_H
|
||||
|
||||
// OpenFOAM includes
|
||||
#include "Swap.H"
|
||||
#include "volFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
inline void vtkOpenFOAMTupleRemap(float vec[]);
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
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<>
|
||||
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[2], vec[5]); // swap XZ <-> ZZ
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
inline void vtkOpenFOAMTupleRemap(float vec[])
|
||||
{}
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
vtkPVReaders.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libvtkPVReaders-pv${ParaView_MAJOR}
|
||||
Reference in New Issue
Block a user