PV3FoamReader improvements

- various GUI properties are now animateable="0"
    (meaning they no longer show up on the time-line)
  - move reader switches to the bottom of the GUI
  - move Lagrangian fields above pointFields for better visibility
  - basic support for multiple clouds
  - filter fields based on selection before looping over all the geometry bits
  - mesh conversion functions now return VTK mesh types for easier handling
  - faceZones mesh conversion had points/faces allocation reversed
  - updateInfo with every call to setTime() that changes the timeIndex
    This seems to be the only way to notice Lagrangian fields
  - restore displaying patchnames that got forgotten in the last commit
  - misc reorganization
This commit is contained in:
Mark Olesen
2008-08-02 16:05:22 +02:00
parent fa0b034338
commit 775ef2c843
24 changed files with 1660 additions and 1633 deletions

View File

@ -1,7 +1,6 @@
<ServerManagerConfiguration>
<ProxyGroup name="sources">
<SourceProxy
name="PV3FoamReader"
class="vtkPV3FoamReader">
@ -9,19 +8,21 @@
<StringVectorProperty
name="FileName"
command="SetFileName"
number_of_elements="1">
<FileListDomain
name="files"/>
number_of_elements="1"
animateable="0">
<FileListDomain name="files"/>
<Documentation>
Specifies the filename for the OpenFOAM Reader
</Documentation>
</StringVectorProperty>
<!-- Time info sent to animation controls (top of window) -->
<!-- Time info sent to animation controls (top of window) -->
<DoubleVectorProperty
name="TimestepValues"
information_only="1">
<TimeStepsInformationHelper/>
<Documentation>
Available timestep values.
Available timestep values
</Documentation>
</DoubleVectorProperty>
@ -31,159 +32,156 @@
<TimeRangeInformationHelper/>
</DoubleVectorProperty>
<!-- ExtrapolateWalls check box -->
<IntVectorProperty
name="ExtrapolateWalls"
command="SetExtrapolateWalls"
number_of_elements="1"
default_values="0">
<BooleanDomain
name="bool"/>
</IntVectorProperty>
<!-- Include sets check box -->
<IntVectorProperty
name="IncludeSets"
command="SetIncludeSets"
number_of_elements="1"
default_values="0">
<BooleanDomain
name="bool"/>
</IntVectorProperty>
<!-- Include zones check box -->
<IntVectorProperty
name="IncludeZones"
command="SetIncludeZones"
number_of_elements="1"
default_values="0">
<BooleanDomain
name="bool"/>
</IntVectorProperty>
<!-- Show patch names check box -->
<IntVectorProperty
name="ShowPatchNames"
command="SetShowPatchNames"
number_of_elements="1"
default_values="0">
<BooleanDomain name="bool"/>
</IntVectorProperty>
<!-- Available regions array -->
<!-- Available Region array -->
<StringVectorProperty
name="RegionArrayInfo"
information_only="1">
<ArraySelectionInformationHelper
attribute_name="Region"/>
<ArraySelectionInformationHelper attribute_name="Region"/>
</StringVectorProperty>
<StringVectorProperty
name="RegionStatus"
label="Mesh Parts"
command="SetRegionArrayStatus"
number_of_elements="0"
repeat_command="1"
number_of_elements_per_command="2"
element_types="2 0"
information_property="RegionArrayInfo">
<ArraySelectionDomain
name="array_list">
information_property="RegionArrayInfo"
animateable="0">
<ArraySelectionDomain name="array_list">
<RequiredProperties>
<Property name="RegionArrayInfo"
function="ArrayList"/>
<Property name="RegionArrayInfo" function="ArrayList"/>
</RequiredProperties>
</ArraySelectionDomain>
</StringVectorProperty>
<!-- Available volFields array -->
<!-- Available volFields array -->
<StringVectorProperty
name="VolFieldArrayInfo"
information_only="1">
<ArraySelectionInformationHelper
attribute_name="VolField"/>
<ArraySelectionInformationHelper attribute_name="VolField"/>
</StringVectorProperty>
<StringVectorProperty
name="VolFieldStatus"
label="Volume Fields"
command="SetVolFieldArrayStatus"
number_of_elements="0"
repeat_command="1"
number_of_elements_per_command="2"
element_types="2 0"
information_property="VolFieldArrayInfo">
<ArraySelectionDomain
name="array_list">
information_property="VolFieldArrayInfo"
animateable="0">
<ArraySelectionDomain name="array_list">
<RequiredProperties>
<Property name="VolFieldArrayInfo"
function="ArrayList"/>
<Property name="VolFieldArrayInfo" function="ArrayList"/>
</RequiredProperties>
</ArraySelectionDomain>
</StringVectorProperty>
<!-- Available pointFields array -->
<StringVectorProperty
name="PointFieldArrayInfo"
information_only="1">
<ArraySelectionInformationHelper
attribute_name="PointField"/>
</StringVectorProperty>
<StringVectorProperty
name="PointFieldStatus"
command="SetPointFieldArrayStatus"
number_of_elements="0"
repeat_command="1"
number_of_elements_per_command="2"
element_types="2 0"
information_property="PointFieldArrayInfo">
<ArraySelectionDomain
name="array_list">
<RequiredProperties>
<Property name="PointFieldArrayInfo"
function="ArrayList"/>
</RequiredProperties>
</ArraySelectionDomain>
</StringVectorProperty>
<!-- Available Lagrangian fields array -->
<!-- Available Lagrangian fields array -->
<StringVectorProperty
name="LagrangianFieldArrayInfo"
information_only="1">
<ArraySelectionInformationHelper
attribute_name="LagrangianField"/>
<ArraySelectionInformationHelper attribute_name="LagrangianField"/>
</StringVectorProperty>
<StringVectorProperty
name="LagrangianFieldStatus"
label="Lagrangian Fields"
command="SetLagrangianFieldArrayStatus"
number_of_elements="0"
repeat_command="1"
number_of_elements_per_command="2"
element_types="2 0"
information_property="LagrangianFieldArrayInfo">
<ArraySelectionDomain
name="array_list">
information_property="LagrangianFieldArrayInfo"
animateable="0">
<ArraySelectionDomain name="array_list">
<RequiredProperties>
<Property name="LagrangianFieldArrayInfo"
function="ArrayList"/>
<Property name="LagrangianFieldArrayInfo" function="ArrayList"/>
</RequiredProperties>
</ArraySelectionDomain>
</StringVectorProperty>
<!-- Cache mesh check box -->
<!-- Available pointFields array -->
<StringVectorProperty
name="PointFieldArrayInfo"
information_only="1">
<ArraySelectionInformationHelper attribute_name="PointField"/>
</StringVectorProperty>
<StringVectorProperty
name="PointFieldStatus"
label="Point Fields"
command="SetPointFieldArrayStatus"
number_of_elements="0"
repeat_command="1"
number_of_elements_per_command="2"
element_types="2 0"
information_property="PointFieldArrayInfo"
animateable="0">
<ArraySelectionDomain name="array_list">
<RequiredProperties>
<Property name="PointFieldArrayInfo" function="ArrayList"/>
</RequiredProperties>
</ArraySelectionDomain>
</StringVectorProperty>
<!-- Extrapolate Walls check-box -->
<IntVectorProperty
name="ExtrapolateWalls"
command="SetExtrapolateWalls"
number_of_elements="1"
default_values="0"
animateable="0">
<BooleanDomain name="bool"/>
</IntVectorProperty>
<!-- Include Sets check-box -->
<IntVectorProperty
name="IncludeSets"
command="SetIncludeSets"
number_of_elements="1"
default_values="0"
animateable="0">
<BooleanDomain name="bool"/>
</IntVectorProperty>
<!-- Include Zones check-box -->
<IntVectorProperty
name="IncludeZones"
command="SetIncludeZones"
number_of_elements="1"
default_values="0"
animateable="0">
<BooleanDomain name="bool"/>
</IntVectorProperty>
<!-- Show Patch Names check-box -->
<IntVectorProperty
name="ShowPatchNames"
command="SetShowPatchNames"
number_of_elements="1"
default_values="0"
animateable="0">
<BooleanDomain name="bool"/>
</IntVectorProperty>
<!-- Cache Mesh check-box -->
<IntVectorProperty
name="CacheMesh"
command="SetCacheMesh"
number_of_elements="1"
default_values="1">
<BooleanDomain
name="bool"/>
default_values="1"
animateable="0">
<BooleanDomain name="bool"/>
</IntVectorProperty>
<!-- Update GUI check box -->
<!-- Update GUI check box -->
<IntVectorProperty
name="UpdateGUI"
command="SetUpdateGUI"
number_of_elements="1"
default_values="0">
<BooleanDomain
name="bool"/>
default_values="0"
animateable="0">
<BooleanDomain name="bool"/>
</IntVectorProperty>
</SourceProxy>

View File

@ -59,11 +59,10 @@ vtkPV3FoamReader::vtkPV3FoamReader()
this->GetExecutive()->SetOutputData(1, lagrangian);
lagrangian->Delete();
TimeStep = 0;
TimeStepRange[0] = 0;
TimeStepRange[1] = 0;
CacheMesh = 0;
CacheMesh = 1;
ExtrapolateWalls = 0;
IncludeSets = 0;
@ -181,7 +180,7 @@ int vtkPV3FoamReader::RequestInformation
}
else
{
foamData_->UpdateInformation();
foamData_->updateInfo();
}
int nTimeSteps = 0;
@ -349,6 +348,15 @@ int vtkPV3FoamReader::RequestData
foamData_->Update(output, lagrangianOutput);
if (ShowPatchNames)
{
addPatchNamesToView();
}
else
{
removePatchNamesFromView();
}
#endif
return 1;
@ -408,7 +416,13 @@ void vtkPV3FoamReader::PrintSelf(ostream& os, vtkIndent indent)
os<< indent << "Time step range: "
<< this->TimeStepRange[0] << " - " << this->TimeStepRange[1]
<< "\n";
os<< indent << "Time step: " << this->TimeStep << endl;
os<< indent << "Time step: " << this->GetTimeStep() << endl;
}
int vtkPV3FoamReader::GetTimeStep()
{
return foamData_ ? foamData_->timeIndex() : -1;
}
@ -446,7 +460,6 @@ int vtkPV3FoamReader::GetRegionArrayStatus(const char* name)
void vtkPV3FoamReader::SetRegionArrayStatus(const char* name, int status)
{
vtkDebugMacro(<<"SetRegionArrayStatus");
if (status)
{
RegionSelection->EnableArray(name);

View File

@ -21,20 +21,16 @@
#ifndef __vtkPV3FoamReader_h
#define __vtkPV3FoamReader_h
#include "vtkMultiBlockDataSetAlgorithm.h"
// Foam forward declarations
namespace Foam
{
class vtkPV3Foam;
}
// VTK includes
#include "vtkMultiBlockDataSetAlgorithm.h"
// VTK forward declarations
class vtkUnstructuredGrid;
class vtkPoints;
class vtkIntArray;
class vtkFloatArray;
class vtkDoubleArray;
class vtkDataArraySelection;
class vtkCallbackCommand;
@ -44,41 +40,31 @@ class VTK_IO_EXPORT vtkPV3FoamReader
public vtkMultiBlockDataSetAlgorithm
{
public:
vtkTypeRevisionMacro(vtkPV3FoamReader,vtkMultiBlockDataSetAlgorithm);
void PrintSelf(ostream&, vtkIndent);
static vtkPV3FoamReader* New();
vtkTypeRevisionMacro
(
vtkPV3FoamReader,
vtkMultiBlockDataSetAlgorithm
);
void PrintSelf
(
ostream& os,
vtkIndent indent
);
// Description:
// Get the current timestep and the timestep range.
vtkGetVector2Macro(TimeStepRange, int);
// Description:
// Set/Get the filename.
vtkSetStringMacro(FileName);
vtkGetStringMacro(FileName);
// Time control
// Set/Get the timestep and the timestep range
vtkSetMacro(TimeStep, int);
vtkGetMacro(TimeStep, int);
vtkSetVector2Macro(TimeStepRange, int);
vtkGetVector2Macro(TimeStepRange, int);
// Description:
// GUI update control
vtkSetMacro(UpdateGUI, int);
vtkGetMacro(UpdateGUI, int);
// Description:
// FOAM mesh caching control
vtkSetMacro(CacheMesh, int);
vtkGetMacro(CacheMesh, int);
// Description:
// FOAM extrapolate internal values onto the walls
vtkSetMacro(ExtrapolateWalls, int);
vtkGetMacro(ExtrapolateWalls, int);
@ -87,28 +73,37 @@ public:
vtkSetMacro(IncludeSets, int);
vtkGetMacro(IncludeSets, int);
// Description:
// FOAM read zones control
vtkSetMacro(IncludeZones, int);
vtkGetMacro(IncludeZones, int);
// Description:
// FOAM display patch names control
vtkSetMacro(ShowPatchNames, int);
vtkGetMacro(ShowPatchNames, int);
// Description:
// Get the current timestep
int GetTimeStep();
// Description:
// Region selection list control
vtkDataArraySelection* GetRegionSelection();
int GetNumberOfRegionArrays();
const char* GetRegionArrayName(int index);
int GetRegionArrayStatus(const char* name);
void SetRegionArrayStatus(const char* name, int status);
const char* GetRegionArrayName(int index);
// Description:
// volField selection list control
vtkDataArraySelection* GetVolFieldSelection();
int GetNumberOfVolFieldArrays();
const char* GetVolFieldArrayName(int index);
int GetVolFieldArrayStatus(const char* name);
void SetVolFieldArrayStatus(const char* name, int status);
const char* GetVolFieldArrayName(int index);
// Description:
// pointField selection list control
vtkDataArraySelection* GetPointFieldSelection();
int GetNumberOfPointFieldArrays();
@ -116,6 +111,7 @@ public:
void SetPointFieldArrayStatus(const char* name, int status);
const char* GetPointFieldArrayName(int index);
// Description:
// lagrangianField selection list control
vtkDataArraySelection* GetLagrangianFieldSelection();
int GetNumberOfLagrangianFieldArrays();
@ -123,6 +119,7 @@ public:
void SetLagrangianFieldArrayStatus(const char* name, int status);
const char* GetLagrangianFieldArrayName(int index);
// Description:
// Callback registered with the SelectionObserver
// for all the selection lists
static void SelectionModifiedCallback
@ -138,18 +135,13 @@ public:
protected:
//- Construct null
vtkPV3FoamReader();
//- Destructor
~vtkPV3FoamReader();
char* FileName;
virtual int RequestData
(
vtkInformation*,
vtkInformationVector**,
vtkInformationVector*
);
//- Return information about mesh, times, etc without loading anything
virtual int RequestInformation
(
vtkInformation*,
@ -157,16 +149,30 @@ protected:
vtkInformationVector*
);
//- Get the mesh/fields for a particular time
//- Destructor
virtual int RequestData
(
vtkInformation*,
vtkInformationVector**,
vtkInformationVector*
);
//- Fill in additional port information
virtual int FillOutputPortInformation(int, vtkInformation*);
// The observer to modify this object when the array selections
// are modified
// The observer to modify this object when array selections are modified
vtkCallbackCommand* SelectionObserver;
char* FileName;
private:
vtkPV3FoamReader(const vtkPV3FoamReader&); // Not implemented.
void operator=(const vtkPV3FoamReader&); // Not implemented.
//- Disallow default bitwise copy construct
vtkPV3FoamReader(const vtkPV3FoamReader&);
//- Disallow default bitwise assignment
void operator=(const vtkPV3FoamReader&);
//- Add patch names to the view
void addPatchNamesToView();
@ -174,9 +180,7 @@ private:
//- Remove patch names from the view
void removePatchNamesFromView();
int TimeStep;
int TimeStepRange[2];
int CacheMesh;
int ExtrapolateWalls;
@ -184,7 +188,7 @@ private:
int IncludeZones;
int ShowPatchNames;
//- Dummy variable/switch for provoking a reader update
//- Dummy variable/switch for invoke a reader update
int UpdateGUI;
vtkDataArraySelection* RegionSelection;
@ -192,7 +196,7 @@ private:
vtkDataArraySelection* PointFieldSelection;
vtkDataArraySelection* LagrangianFieldSelection;
//- Cached data for output port0
//- Cached data for output port0 (experimental!)
vtkMultiBlockDataSet* output0_;
//BTX

View File

@ -1,11 +1,11 @@
vtkPV3Foam.C
vtkPV3FoamAddVolumeMesh.C
vtkPV3FoamAddLagrangianMesh.C
vtkPV3FoamAddPatchMesh.C
vtkPV3FoamAddZoneMesh.C
vtkPV3FoamAddSetMesh.C
vtkPV3FoamUpdateInformation.C
vtkPV3FoamConvertMesh.C
vtkPV3FoamConvertFields.C
vtkPV3FoamFields.C
vtkPV3FoamMesh.C
vtkPV3FoamMeshLagrangian.C
vtkPV3FoamMeshPatch.C
vtkPV3FoamMeshSet.C
vtkPV3FoamMeshVolume.C
vtkPV3FoamMeshZone.C
vtkPV3FoamUpdateInfo.C
LIB = $(FOAM_LIBBIN)/libvtkPV3Foam

View File

@ -25,13 +25,12 @@ License
\*---------------------------------------------------------------------------*/
#include "vtkPV3Foam.H"
#include "vtkPV3FoamReader.h"
// Foam includes
#include "Time.H"
#include "fvMesh.H"
#include "IOobjectList.H"
#include "Time.H"
#include "patchZones.H"
#include "vtkPV3FoamReader.h"
#include "IFstream.H"
// VTK includes
@ -54,8 +53,7 @@ defineTypeNameAndDebug(Foam::vtkPV3Foam, 0);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
#include "vtkPV3FoamAddToSelection.H"
#include "vtkPV3FoamUpdateInformationFields.H"
#include "vtkPV3FoamUpdateInfoFields.H"
void Foam::vtkPV3Foam::AddToBlock
(
@ -161,19 +159,19 @@ Foam::label Foam::vtkPV3Foam::GetNumberOfDataSets
void Foam::vtkPV3Foam::resetCounters()
{
// Reset region ids and sizes
selectInfoVolume_.reset();
selectInfoPatches_.reset();
selectInfoLagrangian_.reset();
selectInfoCellZones_.reset();
selectInfoFaceZones_.reset();
selectInfoPointZones_.reset();
selectInfoCellSets_.reset();
selectInfoFaceSets_.reset();
selectInfoPointSets_.reset();
regionInfoVolume_.reset();
regionInfoPatches_.reset();
regionInfoLagrangian_.reset();
regionInfoCellZones_.reset();
regionInfoFaceZones_.reset();
regionInfoPointZones_.reset();
regionInfoCellSets_.reset();
regionInfoFaceSets_.reset();
regionInfoPointSets_.reset();
}
bool Foam::vtkPV3Foam::setTime(const double& requestedTime)
int Foam::vtkPV3Foam::setTime(const double& requestedTime)
{
if (debug)
{
@ -186,17 +184,12 @@ bool Foam::vtkPV3Foam::setTime(const double& requestedTime)
// Get times list
instantList Times = runTime.times();
bool found = false;
int nearestIndex = Time::findClosestTimeIndex(Times, requestedTime);
int foundIndex = Time::findClosestTimeIndex(Times, requestedTime);
int nearestIndex = foundIndex;
if (nearestIndex == -1)
if (foundIndex < 0)
{
nearestIndex = 0;
found = false;
}
else
{
found = true;
}
// see what has changed
@ -213,16 +206,17 @@ bool Foam::vtkPV3Foam::setTime(const double& requestedTime)
if (meshPtr_->readUpdate() != polyMesh::UNCHANGED)
{
meshChanged_ = true;
reader_->UpdateProgress(0.05);
// patches, zones etc might have changed
UpdateInformation();
}
}
else
{
meshChanged_ = true;
}
reader_->UpdateProgress(0.05);
// this seems to be needed for catching Lagrangian fields
updateInfo();
}
if (debug)
@ -233,91 +227,109 @@ bool Foam::vtkPV3Foam::setTime(const double& requestedTime)
<< " fieldsChanged=" << fieldsChanged_ << endl;
}
return found;
return foundIndex;
}
void Foam::vtkPV3Foam::updateSelectedRegions()
void Foam::vtkPV3Foam::updateRegionStatus()
{
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::updateSelectedRegions" << endl;
Info<< "<beg> Foam::vtkPV3Foam::updateRegionStatus" << endl;
}
vtkDataArraySelection* arraySelection = reader_->GetRegionSelection();
const label nSelect = arraySelection->GetNumberOfArrays();
if (selectedRegions_.size() != nSelect)
vtkDataArraySelection* regionSelection = reader_->GetRegionSelection();
const label nSelect = regionSelection->GetNumberOfArrays();
if (regionStatus_.size() != nSelect)
{
selectedRegions_.setSize(nSelect);
selectedRegions_ = 0;
regionStatus_.setSize(nSelect);
regionStatus_ = false;
meshChanged_ = true;
}
selectedRegionDatasetIds_.setSize(nSelect);
// this needs fixing if we wish to re-use the datasets
regionDataset_.setSize(nSelect);
regionDataset_ = -1;
// Read the selected cell regions, zones, patches and add to region list
forAll (selectedRegions_, regionId)
forAll(regionStatus_, regionId)
{
int setting = arraySelection->GetArraySetting(regionId);
int setting = regionSelection->GetArraySetting(regionId);
if (selectedRegions_[regionId] != setting)
if (regionStatus_[regionId] != setting)
{
selectedRegions_[regionId] = setting;
regionStatus_[regionId] = setting;
meshChanged_ = true;
}
selectedRegionDatasetIds_[regionId] = -1;
if (debug)
{
Info<< " region[" << regionId << "] = "
<< selectedRegions_[regionId]
<< " : " << arraySelection->GetArrayName(regionId) << endl;
<< regionStatus_[regionId]
<< " : " << regionSelection->GetArrayName(regionId) << endl;
}
}
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::updateSelectedRegions" << endl;
Info<< "<end> Foam::vtkPV3Foam::updateRegionStatus" << endl;
}
}
Foam::wordHashSet Foam::vtkPV3Foam::getSelected
(
vtkDataArraySelection* select
)
{
int nElem = select->GetNumberOfArrays();
wordHashSet selections(2*nElem);
for (int elemI=0; elemI < nElem; ++elemI)
{
if (select->GetArraySetting(elemI))
{
word name(getFirstWord(select->GetArrayName(elemI)));
selections.insert(name);
}
}
return selections;
}
Foam::stringList Foam::vtkPV3Foam::getSelectedArrayEntries
(
vtkDataArraySelection* arraySelection,
vtkDataArraySelection* select,
const bool firstWord
)
{
stringList selections(arraySelection->GetNumberOfArrays());
stringList selections(select->GetNumberOfArrays());
label nElem = 0;
if (debug)
{
Info<< "available(";
forAll (selections, elemI)
forAll(selections, elemI)
{
Info<< " \"" << arraySelection->GetArrayName(elemI) << "\"";
Info<< " \"" << select->GetArrayName(elemI) << "\"";
}
Info<< " )\n"
<< "selected(";
}
forAll (selections, elemI)
forAll(selections, elemI)
{
if (arraySelection->GetArraySetting(elemI))
if (select->GetArraySetting(elemI))
{
if (firstWord)
{
selections[nElem] = getFirstWord
(
arraySelection->GetArrayName(elemI)
select->GetArrayName(elemI)
);
}
else
{
selections[nElem] = arraySelection->GetArrayName(elemI);
selections[nElem] = select->GetArrayName(elemI);
}
if (debug)
@ -341,7 +353,7 @@ Foam::stringList Foam::vtkPV3Foam::getSelectedArrayEntries
Foam::stringList Foam::vtkPV3Foam::getSelectedArrayEntries
(
vtkDataArraySelection* arraySelection,
vtkDataArraySelection* select,
const selectionInfo& selector,
const bool firstWord
)
@ -359,7 +371,7 @@ Foam::stringList Foam::vtkPV3Foam::getSelectedArrayEntries
++elemI
)
{
Info<< " \"" << arraySelection->GetArrayName(elemI) << "\"";
Info<< " \"" << select->GetArrayName(elemI) << "\"";
}
Info<< " )\n"
@ -373,18 +385,18 @@ Foam::stringList Foam::vtkPV3Foam::getSelectedArrayEntries
++elemI
)
{
if (arraySelection->GetArraySetting(elemI))
if (select->GetArraySetting(elemI))
{
if (firstWord)
{
selections[nElem] = getFirstWord
(
arraySelection->GetArrayName(elemI)
select->GetArrayName(elemI)
);
}
else
{
selections[nElem] = arraySelection->GetArrayName(elemI);
selections[nElem] = select->GetArrayName(elemI);
}
if (debug)
@ -408,7 +420,7 @@ Foam::stringList Foam::vtkPV3Foam::getSelectedArrayEntries
void Foam::vtkPV3Foam::setSelectedArrayEntries
(
vtkDataArraySelection* arraySelection,
vtkDataArraySelection* select,
const stringList& selections
)
{
@ -416,13 +428,13 @@ void Foam::vtkPV3Foam::setSelectedArrayEntries
{
Info<< "<beg> Foam::vtkPV3Foam::setSelectedArrayEntries" << endl;
}
const label nEntries = arraySelection->GetNumberOfArrays();
const label nEntries = select->GetNumberOfArrays();
// Reset all current entries to 'not selected'
arraySelection->DisableAllArrays();
select->DisableAllArrays();
// Loop through entries, setting values from selectedEntries
forAll (selections, elemI)
forAll(selections, elemI)
{
if (debug > 1)
{
@ -432,7 +444,7 @@ void Foam::vtkPV3Foam::setSelectedArrayEntries
for (label i=0; i<nEntries; i++)
{
string arrayName = arraySelection->GetArrayName(i);
string arrayName = select->GetArrayName(i);
if (arrayName == selections[elemI])
{
@ -443,7 +455,7 @@ void Foam::vtkPV3Foam::setSelectedArrayEntries
<< endl;
}
arraySelection->EnableArray(arrayName.c_str());
select->EnableArray(arrayName.c_str());
break;
}
}
@ -466,20 +478,19 @@ Foam::vtkPV3Foam::vtkPV3Foam
reader_(reader),
dbPtr_(NULL),
meshPtr_(NULL),
selectInfoVolume_("unzoned"),
selectInfoPatches_("patches"),
selectInfoLagrangian_("lagrangian"),
selectInfoCellZones_("cellZone"),
selectInfoFaceZones_("faceZone"),
selectInfoPointZones_("pointZone"),
selectInfoCellSets_("cellSet"),
selectInfoFaceSets_("faceSet"),
selectInfoPointSets_("pointSet"),
patchTextActorsPtrs_(0),
nMesh_(0),
timeIndex_(-1),
meshChanged_(true),
fieldsChanged_(true)
fieldsChanged_(true),
regionInfoVolume_("unzoned"),
regionInfoPatches_("patches"),
regionInfoLagrangian_("lagrangian"),
regionInfoCellZones_("cellZone"),
regionInfoFaceZones_("faceZone"),
regionInfoPointZones_("pointZone"),
regionInfoCellSets_("cellSet"),
regionInfoFaceSets_("faceSet"),
regionInfoPointSets_("pointSet")
{
if (debug)
{
@ -528,11 +539,7 @@ Foam::vtkPV3Foam::vtkPV3Foam
dbPtr_().functionObjects().off();
// Set initial cloud name
// TODO - TEMPORARY MEASURE UNTIL CAN PROCESS MULTIPLE CLOUDS
cloudName_ = "";
UpdateInformation();
updateInfo();
}
@ -551,22 +558,22 @@ Foam::vtkPV3Foam::~vtkPV3Foam()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::vtkPV3Foam::UpdateInformation()
void Foam::vtkPV3Foam::updateInfo()
{
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::UpdateInformation"
<< " [meshPtr=" << (meshPtr_ ? "set" : "NULL") << "] TimeStep="
<< reader_->GetTimeStep() << endl;
Info<< "<beg> Foam::vtkPV3Foam::updateInfo"
<< " [meshPtr=" << (meshPtr_ ? "set" : "NULL") << "] timeIndex="
<< timeIndex_ << endl;
}
resetCounters();
vtkDataArraySelection* arraySelection = reader_->GetRegionSelection();
vtkDataArraySelection* regionSelection = reader_->GetRegionSelection();
stringList selectedEntries;
// enable 'internalMesh' on the first call
if (arraySelection->GetNumberOfArrays() == 0 && !meshPtr_)
if (regionSelection->GetNumberOfArrays() == 0 && !meshPtr_)
{
selectedEntries.setSize(1);
selectedEntries[0] = "internalMesh";
@ -576,33 +583,25 @@ void Foam::vtkPV3Foam::UpdateInformation()
// preserve the enabled selections
selectedEntries = getSelectedArrayEntries
(
arraySelection,
regionSelection,
false
);
}
// Clear current region list/array
arraySelection->RemoveAllArrays();
regionSelection->RemoveAllArrays();
// Update region array
updateInformationInternalMesh();
updateInformationLagrangian();
updateInformationPatches();
if (reader_->GetIncludeSets())
{
updateInformationSets();
}
if (reader_->GetIncludeZones())
{
updateInformationZones();
}
// Update region array - add Lagrangian at the bottom
updateInfoInternalMesh();
updateInfoPatches();
updateInfoSets();
updateInfoZones();
updateInfoLagrangian();
// restore the enabled selections
setSelectedArrayEntries
(
arraySelection,
regionSelection,
selectedEntries
);
@ -611,24 +610,20 @@ void Foam::vtkPV3Foam::UpdateInformation()
fieldsChanged_ = true;
}
// Update volField array
updateInformationFields<fvPatchField, volMesh>
// Update volume, point and lagrangian fields
updateInfoFields<fvPatchField, volMesh>
(
reader_->GetVolFieldSelection()
);
// Update pointField array
updateInformationFields<pointPatchField, pointMesh>
updateInfoFields<pointPatchField, pointMesh>
(
reader_->GetPointFieldSelection()
);
// Update lagrangian field array
updateInformationLagrangianFields();
updateInfoLagrangianFields();
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::UpdateInformation" << endl;
Info<< "<end> Foam::vtkPV3Foam::updateInfo" << endl;
}
}
@ -702,7 +697,7 @@ void Foam::vtkPV3Foam::Update
reader_->UpdateProgress(0.1);
// Set up region selection(s)
updateSelectedRegions();
updateRegionStatus();
// Update the Foam mesh
updateFoamMesh();
@ -793,29 +788,25 @@ void Foam::vtkPV3Foam::addPatchNames(vtkRenderer* renderer)
// Remove any patch names previously added to the renderer
removePatchNames(renderer);
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::addPatchNames" << endl;
}
// get the display patches, strip off any suffix
const stringList selectedPatches = getSelectedArrayEntries
(
reader_->GetRegionSelection(),
selectInfoPatches_,
regionInfoPatches_,
true
);
if (debug)
{
Info<<"... add patches: " << selectedPatches << endl;
}
if (!selectedPatches.size())
{
return;
}
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::addPatchNames" << nl
<<"... add patches: " << selectedPatches << endl;
}
const polyBoundaryMesh& pbMesh = meshPtr_->boundaryMesh();
// Find the total number of zones
@ -977,11 +968,6 @@ void Foam::vtkPV3Foam::addPatchNames(vtkRenderer* renderer)
void Foam::vtkPV3Foam::removePatchNames(vtkRenderer* renderer)
{
if (debug)
{
Info<< "removePatchNames()" << endl;
}
forAll(patchTextActorsPtrs_, patchI)
{
renderer->RemoveViewProp(patchTextActorsPtrs_[patchI]);

View File

@ -32,23 +32,22 @@ SourceFiles
vtkPV3Foam.C
vtkPV3Foam.H
vtkPV3FoamI.H
vtkPV3FoamAddLagrangianMesh.C
vtkPV3FoamAddPatchMesh.C
vtkPV3FoamAddSetMesh.C
vtkPV3FoamFields.C
vtkPV3FoamMesh.C
vtkPV3FoamMeshLagrangian.C
vtkPV3FoamMeshPatch.C
vtkPV3FoamMeshSet.C
vtkPV3FoamMeshVolume.C
vtkPV3FoamMeshZone.C
vtkPV3FoamFaceField.H
vtkPV3FoamLagrangianFields.H
vtkPV3FoamPatchField.H
vtkPV3FoamPointFields.H
vtkPV3FoamPoints.H
vtkPV3FoamUpdateInfo.C
vtkPV3FoamUpdateInfoFields.H
vtkPV3FoamVolFields.H
vtkPV3FoamAddToSelection.H
vtkPV3FoamAddVolumeMesh.C
vtkPV3FoamAddZoneMesh.C
vtkPV3FoamConvertFields.C
vtkPV3FoamConvertFaceField.H
vtkPV3FoamConvertLagrangianFields.H
vtkPV3FoamConvertMesh.C
vtkPV3FoamConvertPatchFaceField.H
vtkPV3FoamConvertPatchPointField.H
vtkPV3FoamConvertPointFields.H
vtkPV3FoamConvertVolFields.H
vtkPV3FoamInsertNextPoint.H
vtkPV3FoamUpdateInformation.C
vtkPV3FoamUpdateInformationFields.H
// Needed by VTK:
vtkDataArrayTemplateImplicit.txx
@ -104,9 +103,55 @@ class List;
class vtkPV3Foam
{
public:
// Private data
// Public data
//- Access to the controlling vtkPV3FoamReader
vtkPV3FoamReader* reader_;
//- Foam time control
autoPtr<Time> dbPtr_;
//- Foam mesh
fvMesh* meshPtr_;
//- Number of meshes
// TODO - for info only - only set up to process ONE mesh
int nMesh_;
//- The time index
int timeIndex_;
//- Track changes in mesh geometry
bool meshChanged_;
//- Track changes in fields
bool fieldsChanged_;
//- Cell-centre labels used as additional points for decomposed cells
labelList addPointCellLabels_;
//- Label of original cell for decomposed cells (internal mesh)
labelList superCells_;
//- Label of original cell for decomposed cells (cellZone meshes)
List<labelList> zoneSuperCells_;
//- Label of original cell for decomposed cells (cellSet meshes)
List<labelList> csetSuperCells_;
//- List of patch names
List<vtkTextActor*> patchTextActorsPtrs_;
//- Selected geometrical pieces
// [0] = internal mesh, patches, zones, sets, lagrangian
boolList regionStatus_;
//- Selected regions indices in each respective block
labelList regionDataset_;
// Private classes
//- bookkeeping for the GUI checklists and the multi-block organization
class selectionInfo
@ -177,87 +222,20 @@ public:
{
size_ += n;
}
friend Ostream& operator<<(Ostream& os, const selectionInfo& s)
{
os << "selector: " << s.name_
<< " (block " << s.block_ << ") "
<< " = " << s.start_ << " + " << s.size_;
return os;
}
};
private:
// Private data
//- Access to the controlling vtkPV3FoamReader
vtkPV3FoamReader* reader_;
//- Foam time control
autoPtr<Time> dbPtr_;
//- Foam mesh
fvMesh* meshPtr_;
//- First instance and size of various regions
selectionInfo selectInfoVolume_;
selectionInfo selectInfoPatches_;
selectionInfo selectInfoLagrangian_;
selectionInfo selectInfoCellZones_;
selectionInfo selectInfoFaceZones_;
selectionInfo selectInfoPointZones_;
selectionInfo selectInfoCellSets_;
selectionInfo selectInfoFaceSets_;
selectionInfo selectInfoPointSets_;
//- Selected regions
// [0] = internal mesh, then lagrangian, patches, zones, sets
boolList selectedRegions_;
//- Selected regions indices in each respective block
labelList selectedRegionDatasetIds_;
//- Labels of cell-centres used as additional points when decomposing
// polyhedra
labelList addPointCellLabels_;
//- Label of original cell for decomposed cells
// - internal mesh
labelList superCells_;
//- Label of original cell for decomposed cells
// - cellZone meshes
List<labelList> zoneSuperCells_;
//- Label of original cell for decomposed cells
// - cellSet meshes
List<labelList> csetSuperCells_;
//- List of patch names
List<vtkTextActor*> patchTextActorsPtrs_;
// Dataset sizes
//- Number of meshes
// TODO - for info only - only set up to process ONE mesh
int nMesh_;
//- Cloud name to be processed
// TODO - currently only set up to process ONE cloud
word cloudName_;
//- The time index
int timeIndex_;
//- Track changes in mesh geometry
bool meshChanged_;
//- Track changes in fields
bool fieldsChanged_;
selectionInfo regionInfoVolume_;
selectionInfo regionInfoPatches_;
selectionInfo regionInfoLagrangian_;
selectionInfo regionInfoCellZones_;
selectionInfo regionInfoFaceZones_;
selectionInfo regionInfoPointZones_;
selectionInfo regionInfoCellSets_;
selectionInfo regionInfoFaceSets_;
selectionInfo regionInfoPointSets_;
// Private Member Functions
@ -296,44 +274,41 @@ private:
// Update information helper functions
//- Update the regions selected in the GUI
void updateSelectedRegions();
void updateRegionStatus();
//- Internal mesh info
void updateInformationInternalMesh();
void updateInfoInternalMesh();
//- Lagrangian info
void updateInformationLagrangian();
void updateInfoLagrangian();
//- Patch info
void updateInformationPatches();
void updateInfoPatches();
//- Set info
void updateInformationSets();
void updateInfoSets();
//- Zone info
void updateInfoZones();
//- Read zone names for zoneType from file
wordList readZoneNames(const word& zoneType);
//- Zone info
void updateInformationZones();
//- Add to paraview array selection
template<class Type>
label addToSelection
(
vtkDataArraySelection *arraySelection,
vtkDataArraySelection*,
const IOobjectList&,
const string& suffix=string::null
);
//- Field info
template<template<class> class patchType, class meshType>
void updateInformationFields
(
vtkDataArraySelection *fieldSelection
);
void updateInfoFields(vtkDataArraySelection*);
//- Lagrangian field info
void updateInformationLagrangianFields();
void updateInfoLagrangianFields();
// Update helper functions
@ -384,64 +359,48 @@ private:
// Add mesh functions
//- Add internal mesh/cell set meshes
void addVolumeMesh
vtkUnstructuredGrid* volumeVTKMesh
(
const fvMesh&,
vtkUnstructuredGrid*,
labelList& superCells
);
//- Add Lagrangian mesh
void addLagrangianMesh
vtkPolyData* lagrangianVTKMesh
(
const fvMesh&,
vtkPolyData*
const word& cloudName
);
//- Add patch mesh
void addPatchMesh
(
const polyPatch&,
vtkPolyData*
);
vtkPolyData* patchVTKMesh(const polyPatch&);
//- Add face zone mesh
void addFaceZoneMesh
vtkPolyData* faceZoneVTKMesh
(
const fvMesh&,
const labelList& faceLabels,
vtkPolyData*
const labelList& faceLabels
);
//- Add point zone
void addPointZoneMesh
vtkPolyData* pointZoneVTKMesh
(
const fvMesh&,
const labelList& pointLabels,
vtkPolyData*
);
//- Add cell set mesh
void addCellSetMesh
(
const fvMesh&,
vtkUnstructuredGrid*
const labelList& pointLabels
);
//- Add face set mesh
void addFaceSetMesh
vtkPolyData* faceSetVTKMesh
(
const fvMesh&,
const faceSet&,
vtkPolyData*
const faceSet&
);
//- Add point mesh
void addPointSetMesh
vtkPolyData* pointSetVTKMesh
(
const fvMesh&,
const pointSet&,
vtkPolyData*
const pointSet&
);
// Field conversion functions
@ -461,8 +420,8 @@ private:
template<class GeoField>
label addObjectsToSelection
(
vtkDataArraySelection* fieldSelection,
const IOobjectList& objects,
vtkDataArraySelection*,
const IOobjectList&,
const string& suffix=string::null
);
@ -474,14 +433,13 @@ private:
void convertVolFields
(
const fvMesh&,
const volPointInterpolation& pInterp,
const volPointInterpolation&,
const PtrList<PrimitivePatchInterpolation<primitivePatch> >&,
const IOobjectList& objects,
vtkDataArraySelection* fieldSelection,
const IOobjectList&,
vtkMultiBlockDataSet* output
);
//- Volume field - all types except scalar
//- Volume field
template<class Type>
void convertVolField
(
@ -494,7 +452,7 @@ private:
//- Patch field
template<class Type>
void convertPatchFaceField
void convertPatchField
(
const word& name,
const Field<Type>&,
@ -531,13 +489,12 @@ private:
template<class Type>
void convertLagrangianFields
(
const fvMesh&,
const IOobjectList& objects,
vtkDataArraySelection *fieldSelection,
vtkMultiBlockDataSet* output
const IOobjectList&,
vtkMultiBlockDataSet* output,
const label datasetNo
);
//- Lagrangian field - all types except scalar
//- Lagrangian field
template<class Type>
void convertLagrangianField
(
@ -551,29 +508,29 @@ private:
template<class Type>
void convertPointFields
(
const fvMesh& mesh,
const IOobjectList& objects,
vtkDataArraySelection *fieldSelection,
const fvMesh&,
const pointMesh&,
const IOobjectList&,
vtkMultiBlockDataSet* output
);
//- Point fields - all types except scalar
//- Point fields
template<class Type>
void convertPointField
(
const GeometricField<Type, pointPatchField, pointMesh>& ptf,
const GeometricField<Type, fvPatchField, volMesh>& tf,
const GeometricField<Type, pointPatchField, pointMesh>&,
const GeometricField<Type, fvPatchField, volMesh>&,
vtkMultiBlockDataSet* output,
const selectionInfo&,
const label datasetNo
);
//- Patch point field - all types except scalar
//- Patch point field
template<class Type>
void convertPatchPointField
(
const word& name,
const Field<Type>& tf,
const Field<Type>&,
vtkMultiBlockDataSet* output,
const selectionInfo&,
const label datasetNo
@ -585,17 +542,27 @@ private:
//- Extract up to the first non-word characters
inline static word getFirstWord(const char*);
//- Subset an IOobjectList based on a hashSet
static void subsetObjectList
(
IOobjectList&,
const wordHashSet&
);
//- Store the current selection(s)
static wordHashSet getSelected(vtkDataArraySelection*);
//- Store the current selection(s)
static stringList getSelectedArrayEntries
(
vtkDataArraySelection* arraySelection,
vtkDataArraySelection*,
const bool firstWord=false
);
//- Store the current selection(s) for a sub-selection
static stringList getSelectedArrayEntries
(
vtkDataArraySelection* arraySelection,
vtkDataArraySelection*,
const selectionInfo&,
const bool firstWord=false
);
@ -603,8 +570,8 @@ private:
//- Set selection(s)
static void setSelectedArrayEntries
(
vtkDataArraySelection* arraySelection,
const stringList& selectedEntries
vtkDataArraySelection*,
const stringList&
);
@ -640,7 +607,7 @@ public:
// Member Functions
//- Update
void UpdateInformation();
void updateInfo();
void Update
(
@ -658,10 +625,15 @@ public:
//- Remove patch names from the display
void removePatchNames(vtkRenderer* renderer);
//- set the runTime to the requested time
// sets to "constant" on error
bool setTime(const double& requestedTime);
//- set the runTime to the requested time, returns the timeIndex
// sets to "constant" on error and returns -1
int setTime(const double& requestedTime);
//- The current time index
int timeIndex() const
{
return timeIndex_;
}
// Access

View File

@ -28,6 +28,7 @@ License
#define vtkPV3FoamAddToSelection_H
// FOAM includes
#include "IOobjectList.H"
#include "SortableList.H"
// VTK includes
@ -38,7 +39,7 @@ License
template<class Type>
Foam::label Foam::vtkPV3Foam::addToSelection
(
vtkDataArraySelection *arraySelection,
vtkDataArraySelection *select,
const IOobjectList& objectLst,
const string& suffix
)
@ -57,7 +58,7 @@ Foam::label Foam::vtkPV3Foam::addToSelection
{
objectNames.sort();
forAll (objectNames, objI)
forAll(objectNames, objI)
{
if (debug)
{
@ -67,14 +68,14 @@ Foam::label Foam::vtkPV3Foam::addToSelection
if (suffix.size())
{
arraySelection->AddArray
select->AddArray
(
(objectNames[objI] + suffix).c_str()
);
}
else
{
arraySelection->AddArray
select->AddArray
(
objectNames[objI].c_str()
);

View File

@ -1,233 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
\*---------------------------------------------------------------------------*/
#include "vtkPV3Foam.H"
// Foam includes
#include "IOobjectList.H"
#include "vtkPV3FoamReader.h"
// VTK includes
#include "vtkDataArraySelection.h"
#include "vtkPolyData.h"
#include "vtkUnstructuredGrid.h"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
#include "vtkPV3FoamConvertVolFields.H"
#include "vtkPV3FoamConvertPointFields.H"
#include "vtkPV3FoamConvertLagrangianFields.H"
void Foam::vtkPV3Foam::convertVolFields
(
vtkMultiBlockDataSet* output
)
{
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::convertVolFields" << endl;
printMemory();
}
const fvMesh& mesh = *meshPtr_;
// Construct interpolation on the raw mesh
pointMesh pMesh(mesh);
// Search for list of objects for this time
IOobjectList objects(mesh, dbPtr_().timeName());
vtkDataArraySelection* arraySelection = reader_->GetVolFieldSelection();
// Convert volume fields
if (debug)
{
Info<< "converting Foam volume fields" << endl;
}
volPointInterpolation pInterp(mesh, pMesh);
PtrList<PrimitivePatchInterpolation<primitivePatch> >
ppInterpList(mesh.boundaryMesh().size());
forAll(ppInterpList, i)
{
ppInterpList.set
(
i,
new PrimitivePatchInterpolation<primitivePatch>
(
mesh.boundaryMesh()[i]
)
);
}
convertVolFields<Foam::scalar>
(
mesh, pInterp, ppInterpList, objects, arraySelection, output
);
convertVolFields<Foam::vector>
(
mesh, pInterp, ppInterpList, objects, arraySelection, output
);
convertVolFields<Foam::sphericalTensor>
(
mesh, pInterp, ppInterpList, objects, arraySelection, output
);
convertVolFields<Foam::symmTensor>
(
mesh, pInterp, ppInterpList, objects, arraySelection, output
);
convertVolFields<Foam::tensor>
(
mesh, pInterp, ppInterpList, objects, arraySelection, output
);
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::convertVolFields" << endl;
printMemory();
}
}
void Foam::vtkPV3Foam::convertPointFields
(
vtkMultiBlockDataSet* output
)
{
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::convertPointFields" << endl;
printMemory();
}
const fvMesh& mesh = *meshPtr_;
// Search for list of objects for this time
IOobjectList objects(mesh, dbPtr_().timeName());
vtkDataArraySelection* arraySelection = reader_->GetPointFieldSelection();
convertPointFields<Foam::scalar>
(
mesh, objects, arraySelection, output
);
convertPointFields<Foam::vector>
(
mesh, objects, arraySelection, output
);
convertPointFields<Foam::sphericalTensor>
(
mesh, objects, arraySelection, output
);
convertPointFields<Foam::symmTensor>
(
mesh, objects, arraySelection, output
);
convertPointFields<Foam::tensor>
(
mesh, objects, arraySelection, output
);
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::convertPointFields" << endl;
printMemory();
}
}
void Foam::vtkPV3Foam::convertLagrangianFields
(
vtkMultiBlockDataSet* output
)
{
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::convertLagrangianFields" << endl;
printMemory();
}
const fvMesh& mesh = *meshPtr_;
// Search for list of objects for this time
//- TODO - currently hard-coded to ONE cloud
IOobjectList objects
(
mesh,
dbPtr_().timeName(),
"lagrangian"/cloudName_
);
vtkDataArraySelection* arraySelection =
reader_->GetLagrangianFieldSelection();
// Convert Lagrangian fields
if (debug)
{
Info<< "converting Lagrangian fields - "
<< selectInfoLagrangian_ << endl;
}
convertLagrangianFields<Foam::label>
(
mesh, objects, arraySelection, output
);
convertLagrangianFields<Foam::scalar>
(
mesh, objects, arraySelection, output
);
convertLagrangianFields<Foam::vector>
(
mesh, objects, arraySelection, output
);
convertLagrangianFields<Foam::sphericalTensor>
(
mesh, objects, arraySelection, output
);
convertLagrangianFields<Foam::symmTensor>
(
mesh, objects, arraySelection, output
);
convertLagrangianFields<Foam::tensor>
(
mesh, objects, arraySelection, output
);
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::convertLagrangianFields" << endl;
printMemory();
}
}
// ************************************************************************* //

View File

@ -1,151 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
InClass
vtkPV3Foam
\*---------------------------------------------------------------------------*/
#ifndef vtkPV3FoamConvertLagrangianFields_H
#define vtkPV3FoamConvertLagrangianFields_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
void Foam::vtkPV3Foam::convertLagrangianFields
(
const fvMesh& mesh,
const IOobjectList& objects,
vtkDataArraySelection* fieldSelection,
vtkMultiBlockDataSet* output
)
{
const selectionInfo& selector = selectInfoLagrangian_;
IOobjectList fieldObjects
(
objects.lookupClass
(
IOField<Type>::typeName
)
);
label nFields = fieldSelection->GetNumberOfArrays();
for (label i=0; i<nFields; i++)
{
const word fieldName = fieldSelection->GetArrayName(i);
if
(
!fieldSelection->GetArraySetting(i)
|| !fieldObjects.found(fieldName))
{
continue;
}
IOField<Type> iotf
(
IOobject
(
fieldName,
mesh.time().timeName(),
"lagrangian"/cloudName_,
mesh,
IOobject::MUST_READ
)
);
// Convert Lagrangian points
for
(
int regionId = selector.start();
regionId < selector.end();
++regionId
)
{
if (selectedRegions_[regionId])
{
convertLagrangianField
(
iotf, output, selector,
selectedRegionDatasetIds_[regionId]
);
}
}
}
}
template<class Type>
void Foam::vtkPV3Foam::convertLagrangianField
(
const IOField<Type>& tf,
vtkMultiBlockDataSet* output,
const selectionInfo& selector,
const label datasetNo
)
{
const label nComp = pTraits<Type>::nComponents;
vtkPolyData* vtkmesh = vtkPolyData::SafeDownCast
(
GetDataSetFromBlock(output, selector, datasetNo)
);
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<< "converting Lagrangian <Type>Field: " << tf.name() << nl
<< "tf.size() = " << tf.size() << nl
<< "nComp = " << nComp << endl;
}
float vec[nComp];
forAll(tf, i)
{
for (direction d=0; d<nComp; d++)
{
vec[d] = component(tf[i], d);
}
pointData->InsertTuple(i, vec);
}
vtkmesh->GetPointData()->AddArray(pointData);
pointData->Delete();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -27,8 +27,8 @@ InClass
\*---------------------------------------------------------------------------*/
#ifndef vtkPV3FoamConvertFaceField_H
#define vtkPV3FoamConvertFaceField_H
#ifndef vtkPV3FoamFaceField_H
#define vtkPV3FoamFaceField_H
// VTK includes
#include "vtkCellData.h"
@ -60,13 +60,24 @@ void Foam::vtkPV3Foam::convertFaceField
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());
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];
@ -119,13 +130,24 @@ void Foam::vtkPV3Foam::convertFaceField
const labelList& faceNeigh = mesh.faceNeighbour();
vtkFloatArray *cellData = vtkFloatArray::New();
cellData->SetNumberOfTuples(fSet.size());
cellData->SetNumberOfComponents(nComp);
cellData->Allocate(nComp*fSet.size());
cellData->SetName(tf.name().c_str());
cellData->SetNumberOfTuples( fSet.size() );
cellData->SetNumberOfComponents( nComp );
cellData->Allocate( nComp*fSet.size() );
cellData->SetName( tf.name().c_str() );
if (debug)
{
Info<< "convert convertFaceField: "
<< tf.name()
<< " size = " << tf.size()
<< " nComp=" << nComp
<< " nTuples = " << fSet.size() << endl;
}
float vec[nComp];
// for interior faces: average owner/neighbour
// for boundary faces: owner
label faceI = 0;
forAllConstIter(faceSet, fSet, iter)
{
@ -157,7 +179,6 @@ void Foam::vtkPV3Foam::convertFaceField
cellData->Delete();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif

View File

@ -0,0 +1,332 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
\*---------------------------------------------------------------------------*/
#include "vtkPV3Foam.H"
// Foam includes
#include "IOobjectList.H"
#include "vtkPV3FoamReader.h"
// VTK includes
#include "vtkDataArraySelection.h"
#include "vtkPolyData.h"
#include "vtkUnstructuredGrid.h"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
#include "vtkPV3FoamVolFields.H"
#include "vtkPV3FoamPointFields.H"
#include "vtkPV3FoamLagrangianFields.H"
void Foam::vtkPV3Foam::subsetObjectList
(
IOobjectList& objects,
const wordHashSet& selected
)
{
// hash all the selected field names
if (!selected.size())
{
objects.clear();
}
// only keep selected fields
forAllIter(IOobjectList, objects, iter)
{
if (!selected.found(iter()->name()))
{
objects.erase(iter);
}
}
}
void Foam::vtkPV3Foam::convertVolFields
(
vtkMultiBlockDataSet* output
)
{
wordHashSet selectedFields = getSelected
(
reader_->GetVolFieldSelection()
);
if (!selectedFields.size())
{
return;
}
const fvMesh& mesh = *meshPtr_;
// Get objects (fields) for this time - only keep selected fields
IOobjectList objects(mesh, dbPtr_().timeName());
subsetObjectList(objects, selectedFields);
if (!objects.size())
{
return;
}
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::convertVolFields" << nl
<< "converting Foam volume fields" << endl;
forAllConstIter(IOobjectList, objects, iter)
{
Info<< " " << iter()->name()
<< " == " << iter()->objectPath() << nl;
}
printMemory();
}
// Construct interpolation on the raw mesh
pointMesh pMesh(mesh);
volPointInterpolation pInterp(mesh, pMesh);
PtrList<PrimitivePatchInterpolation<primitivePatch> >
ppInterpList(mesh.boundaryMesh().size());
forAll(ppInterpList, i)
{
ppInterpList.set
(
i,
new PrimitivePatchInterpolation<primitivePatch>
(
mesh.boundaryMesh()[i]
)
);
}
convertVolFields<scalar>
(
mesh, pInterp, ppInterpList, objects, output
);
convertVolFields<vector>
(
mesh, pInterp, ppInterpList, objects, output
);
convertVolFields<sphericalTensor>
(
mesh, pInterp, ppInterpList, objects, output
);
convertVolFields<symmTensor>
(
mesh, pInterp, ppInterpList, objects, output
);
convertVolFields<tensor>
(
mesh, pInterp, ppInterpList, objects, output
);
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::convertVolFields" << endl;
printMemory();
}
}
void Foam::vtkPV3Foam::convertPointFields
(
vtkMultiBlockDataSet* output
)
{
wordHashSet selectedFields = getSelected
(
reader_->GetPointFieldSelection()
);
if (!selectedFields.size())
{
return;
}
const fvMesh& mesh = *meshPtr_;
// Get objects (fields) for this time - only keep selected fields
IOobjectList objects(mesh, dbPtr_().timeName());
subsetObjectList(objects, selectedFields);
if (!objects.size())
{
return;
}
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::convertPointFields" << nl
<< "converting Foam volume fields" << endl;
forAllConstIter(IOobjectList, objects, iter)
{
Info<< " " << iter()->name()
<< " == " << iter()->objectPath() << nl;
}
printMemory();
}
// Construct interpolation on the raw mesh
pointMesh pMesh(mesh);
convertPointFields<scalar>
(
mesh, pMesh, objects, output
);
convertPointFields<vector>
(
mesh, pMesh, objects, output
);
convertPointFields<sphericalTensor>
(
mesh, pMesh, objects, output
);
convertPointFields<symmTensor>
(
mesh, pMesh, objects, output
);
convertPointFields<tensor>
(
mesh, pMesh, objects, output
);
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::convertPointFields" << endl;
printMemory();
}
}
void Foam::vtkPV3Foam::convertLagrangianFields
(
vtkMultiBlockDataSet* output
)
{
wordHashSet selectedFields = getSelected
(
reader_->GetLagrangianFieldSelection()
);
if (!selectedFields.size())
{
return;
}
const fvMesh& mesh = *meshPtr_;
selectionInfo& selector = regionInfoLagrangian_;
vtkDataArraySelection* regionSelection = reader_->GetRegionSelection();
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::convertLagrangianFields" << endl;
printMemory();
}
for
(
int regionId = selector.start();
regionId < selector.end();
++regionId
)
{
const label datasetNo = regionDataset_[regionId];
if (!regionStatus_[regionId] || datasetNo < 0)
{
continue;
}
word cloudName = getFirstWord
(
regionSelection->GetArrayName(regionId)
);
// Get the Lagrangian fields for this time and this cloud
// but only keep selected fields
IOobjectList objects
(
mesh,
dbPtr_().timeName(),
"lagrangian"/cloudName
);
subsetObjectList(objects, selectedFields);
if (!objects.size())
{
continue;
}
if (debug)
{
Info<< "converting Foam lagrangian fields" << nl;
forAllConstIter(IOobjectList, objects, iter)
{
Info<< " " << iter()->name()
<< " == " << iter()->objectPath() << nl;
}
}
convertLagrangianFields<label>
(
objects, output, datasetNo
);
convertLagrangianFields<scalar>
(
objects, output, datasetNo
);
convertLagrangianFields<vector>
(
objects, output, datasetNo
);
convertLagrangianFields<sphericalTensor>
(
objects, output, datasetNo
);
convertLagrangianFields<symmTensor>
(
objects, output, datasetNo
);
convertLagrangianFields<tensor>
(
objects, output, datasetNo
);
}
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::convertLagrangianFields" << endl;
printMemory();
}
}
// ************************************************************************* //

View File

@ -27,19 +27,42 @@ InClass
\*---------------------------------------------------------------------------*/
#ifndef vtkPV3FoamConvertPatchPointField_H
#define vtkPV3FoamConvertPatchPointField_H
// VTK includes
#include "vtkPointData.h"
#ifndef vtkPV3FoamLagrangianFields_H
#define vtkPV3FoamLagrangianFields_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
void Foam::vtkPV3Foam::convertPatchPointField
void Foam::vtkPV3Foam::convertLagrangianFields
(
const word& name,
const Field<Type>& pptf,
const IOobjectList& objects,
vtkMultiBlockDataSet* output,
const label datasetNo
)
{
const selectionInfo& selector = regionInfoLagrangian_;
// field subset based on type
IOobjectList fieldObjects
(
objects.lookupClass
(
IOField<Type>::typeName
)
);
forAllIter(IOobjectList, fieldObjects, iter)
{
IOField<Type> tf(*iter());
convertLagrangianField(tf, output, selector, datasetNo);
}
}
template<class Type>
void Foam::vtkPV3Foam::convertLagrangianField
(
const IOField<Type>& tf,
vtkMultiBlockDataSet* output,
const selectionInfo& selector,
const label datasetNo
@ -53,18 +76,27 @@ void Foam::vtkPV3Foam::convertPatchPointField
);
vtkFloatArray *pointData = vtkFloatArray::New();
pointData->SetNumberOfTuples(pptf.size());
pointData->SetNumberOfComponents(nComp);
pointData->Allocate(nComp*pptf.size());
pointData->SetName(name.c_str());
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(pptf, i)
forAll(tf, i)
{
const Type& t = tf[i];
for (direction d=0; d<nComp; d++)
{
vec[d] = component(pptf[i], d);
vec[d] = component(t, d);
}
pointData->InsertTuple(i, vec);

View File

@ -56,13 +56,14 @@ void Foam::vtkPV3Foam::convertMeshVolume
}
const fvMesh& mesh = *meshPtr_;
selectionInfo& selector = selectInfoVolume_;
selectionInfo& selector = regionInfoVolume_;
// set output block and note if anything was added
// set output block, restart at dataset 0
selector.block(blockNo);
bool created = false;
label datasetNo = 0;
// Create the internal mesh and add as dataset 0
// Create the internalMesh
// TODO: multiple regions
for
(
int regionId = selector.start();
@ -70,34 +71,33 @@ void Foam::vtkPV3Foam::convertMeshVolume
++regionId
)
{
if (!selectedRegions_[regionId])
if (!regionStatus_[regionId])
{
continue;
}
// word selectName = getFirstWord
// (
// arraySelection->GetArrayName(regionId)
// );
if (debug)
{
Info<< "Creating VTK internalMesh" << endl;
}
const label datasetId = 0;
vtkUnstructuredGrid* vtkmesh = volumeVTKMesh
(
mesh,
superCells_
);
vtkUnstructuredGrid* vtkmesh = vtkUnstructuredGrid::New();
addVolumeMesh(mesh, vtkmesh, superCells_);
AddToBlock(output, selector, datasetId, vtkmesh, "internalMesh");
selectedRegionDatasetIds_[regionId] = datasetId;
if (vtkmesh)
{
AddToBlock(output, selector, datasetNo, vtkmesh, "internalMesh");
vtkmesh->Delete();
created = true;
regionDataset_[regionId] = datasetNo++;
}
}
if (created)
// was anything added?
if (datasetNo)
{
++blockNo;
}
@ -123,13 +123,14 @@ void Foam::vtkPV3Foam::convertMeshLagrangian
}
const fvMesh& mesh = *meshPtr_;
selectionInfo& selector = selectInfoLagrangian_;
selectionInfo& selector = regionInfoLagrangian_;
vtkDataArraySelection* regionSelection = reader_->GetRegionSelection();
// set output block and note if anything was added
// set output block, restart at dataset 0
selector.block(blockNo);
bool created = false;
label datasetNo = 0;
// Create a single Lagrangian mesh and add as dataset 0
// Create Lagrangian meshes
for
(
int regionId = selector.start();
@ -137,29 +138,28 @@ void Foam::vtkPV3Foam::convertMeshLagrangian
++regionId
)
{
if (!selectedRegions_[regionId])
if (!regionStatus_[regionId])
{
continue;
}
if (debug)
word cloudName = getFirstWord
(
regionSelection->GetArrayName(regionId)
);
vtkPolyData* vtkmesh = lagrangianVTKMesh(mesh, cloudName);
if (vtkmesh)
{
Info<< "Creating VTK Lagrangian mesh" << endl;
}
const label datasetId = 0;
vtkPolyData* vtkmesh = vtkPolyData::New();
addLagrangianMesh(mesh, vtkmesh);
AddToBlock(output, selector, datasetId, vtkmesh, cloudName_);
selectedRegionDatasetIds_[regionId] = datasetId;
AddToBlock(output, selector, datasetNo, vtkmesh, cloudName);
vtkmesh->Delete();
created = true;
regionDataset_[regionId] = datasetNo++;
}
}
if (created)
// was anything added?
if (datasetNo)
{
++blockNo;
}
@ -185,18 +185,17 @@ void Foam::vtkPV3Foam::convertMeshPatches
}
const fvMesh& mesh = *meshPtr_;
selectionInfo& selector = selectInfoPatches_;
vtkDataArraySelection* arraySelection = reader_->GetRegionSelection();
selectionInfo& selector = regionInfoPatches_;
vtkDataArraySelection* regionSelection = reader_->GetRegionSelection();
// set output block and note if anything was added
// set output block, restart at dataset 0
selector.block(blockNo);
bool created = false;
label datasetNo = 0;
if (selector.size())
{
const polyBoundaryMesh& patches = mesh.boundaryMesh();
// Create the patches and add as dataset ...
for
(
int regionId = selector.start();
@ -204,52 +203,41 @@ void Foam::vtkPV3Foam::convertMeshPatches
++regionId
)
{
if (!selectedRegions_[regionId])
word patchName = getFirstWord
(
regionSelection->GetArrayName(regionId)
);
label patchId = patches.findPatchID(patchName);
if (!regionStatus_[regionId] || patchId < 0)
{
continue;
}
word selectName = getFirstWord
(
arraySelection->GetArrayName(regionId)
);
const label patchId = patches.findPatchID(selectName);
if (debug)
{
Info<< "Creating VTK mesh for patch: " << selectName
<< " region index: " << regionId << endl;
Info<< "Creating VTK mesh for patch: " << patchName
<< " patch index: " << patchId << endl;
}
const label datasetId = GetNumberOfDataSets(output, selector);
vtkPolyData* vtkmesh = vtkPolyData::New();
addPatchMesh
(
patches[patchId],
vtkmesh
);
AddToBlock
(
output, selector, datasetId, vtkmesh,
selectName + ":patch"
);
selectedRegionDatasetIds_[regionId] = datasetId;
vtkPolyData* vtkmesh = patchVTKMesh(patches[patchId]);
if (vtkmesh)
{
AddToBlock(output, selector, datasetNo, vtkmesh, patchName);
vtkmesh->Delete();
created = true;
regionDataset_[regionId] = datasetNo++;
}
}
}
if (created)
// was anything added?
if (datasetNo)
{
++blockNo;
}
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::convertMeshPatches" << endl;
@ -271,23 +259,32 @@ void Foam::vtkPV3Foam::convertMeshCellZones
}
const fvMesh& mesh = *meshPtr_;
selectionInfo& selector = selectInfoCellZones_;
selectionInfo& selector = regionInfoCellZones_;
vtkDataArraySelection* regionSelection = reader_->GetRegionSelection();
// set output block and note if anything was added
// set output block, restart at dataset 0
selector.block(blockNo);
bool created = false;
label datasetNo = 0;
// Create the cell zone(s) and add as DataSet(CELLZONE, 0..n)
if (selector.size())
{
const cellZoneMesh& czMesh = mesh.cellZones();
const cellZoneMesh& zMesh = mesh.cellZones();
// use the zoneId directly instead of the name
for (int zoneI=0; zoneI < selector.size(); ++zoneI)
for
(
int regionId = selector.start();
regionId < selector.end();
++regionId
)
{
const int regionId = selector.start() + zoneI;
word zoneName = getFirstWord
(
regionSelection->GetArrayName(regionId)
);
if (!selectedRegions_[regionId])
label zoneId = zMesh.findZoneID(zoneName);
if (!regionStatus_[regionId] || zoneId < 0)
{
continue;
}
@ -295,43 +292,41 @@ void Foam::vtkPV3Foam::convertMeshCellZones
if (debug)
{
Info<< "Creating VTK mesh for cellZone: "
<< zoneI << endl;
<< zoneId << endl;
}
fvMeshSubset subsetter(mesh);
subsetter.setLargeCellSubset(czMesh[zoneI]);
subsetter.setLargeCellSubset(zMesh[zoneId]);
const label datasetId = GetNumberOfDataSets(output, selector);
vtkUnstructuredGrid* vtkmesh = vtkUnstructuredGrid::New();
addVolumeMesh
vtkUnstructuredGrid* vtkmesh = volumeVTKMesh
(
subsetter.subMesh(),
vtkmesh,
zoneSuperCells_[datasetId]
zoneSuperCells_[datasetNo]
);
if (vtkmesh)
{
// renumber - superCells must contain global cell ids
inplaceRenumber
(
subsetter.cellMap(),
zoneSuperCells_[datasetId]
zoneSuperCells_[datasetNo]
);
AddToBlock
(
output, selector, datasetId, vtkmesh,
czMesh.names()[zoneI] + ":cellZone"
output, selector, datasetNo, vtkmesh,
zMesh[zoneId].name() + ":cellZone"
);
selectedRegionDatasetIds_[regionId] = datasetId;
vtkmesh->Delete();
created = true;
regionDataset_[regionId] = datasetNo++;
}
}
}
if (created)
// was anything added?
if (datasetNo)
{
++blockNo;
}
@ -357,12 +352,12 @@ void Foam::vtkPV3Foam::convertMeshCellSets
}
const fvMesh& mesh = *meshPtr_;
selectionInfo& selector = selectInfoCellSets_;
vtkDataArraySelection* arraySelection = reader_->GetRegionSelection();
selectionInfo& selector = regionInfoCellSets_;
vtkDataArraySelection* regionSelection = reader_->GetRegionSelection();
// set output block and note if anything was added
// set output block, restart at dataset 0
selector.block(blockNo);
bool created = false;
label datasetNo = 0;
// Create the cell sets and add as dataset
if (selector.size())
@ -373,57 +368,55 @@ void Foam::vtkPV3Foam::convertMeshCellSets
regionId < selector.end();
++regionId)
{
if (!selectedRegions_[regionId])
if (!regionStatus_[regionId])
{
continue;
}
word selectName = getFirstWord
word selectedName = getFirstWord
(
arraySelection->GetArrayName(regionId)
regionSelection->GetArrayName(regionId)
);
if (debug)
{
Info<< "Creating VTK mesh for cellSet: " << selectName
Info<< "Creating VTK mesh for cellSet: " << selectedName
<< " region index: " << regionId << endl;
}
const cellSet cSet(mesh, selectName);
const cellSet cSet(mesh, selectedName);
fvMeshSubset subsetter(mesh);
subsetter.setLargeCellSubset(cSet);
const label datasetId = GetNumberOfDataSets(output, selector);
vtkUnstructuredGrid* vtkmesh = vtkUnstructuredGrid::New();
addVolumeMesh
vtkUnstructuredGrid* vtkmesh = volumeVTKMesh
(
subsetter.subMesh(),
vtkmesh,
csetSuperCells_[datasetId]
csetSuperCells_[datasetNo]
);
if (vtkmesh)
{
// renumber - superCells must contain global cell ids
inplaceRenumber
(
subsetter.cellMap(),
csetSuperCells_[datasetId]
csetSuperCells_[datasetNo]
);
AddToBlock
(
output, selector, datasetId, vtkmesh,
selectName + ":cellSet"
output, selector, datasetNo, vtkmesh,
selectedName + ":cellSet"
);
selectedRegionDatasetIds_[regionId] = datasetId;
vtkmesh->Delete();
created = true;
regionDataset_[regionId] = datasetNo++;
}
}
}
if (created)
// was anything added?
if (datasetNo)
{
++blockNo;
}
@ -449,58 +442,65 @@ void Foam::vtkPV3Foam::convertMeshFaceZones
}
const fvMesh& mesh = *meshPtr_;
selectionInfo& selector = selectInfoFaceZones_;
selectionInfo& selector = regionInfoFaceZones_;
vtkDataArraySelection* regionSelection = reader_->GetRegionSelection();
// set output block and note if anything was added
// set output block, restart at dataset 0
selector.block(blockNo);
bool created = false;
label datasetNo = 0;
// Create the cell zone(s) and add as datasets
// Create the cell zone(s)
if (selector.size())
{
const faceZoneMesh& fzMesh = mesh.faceZones();
const faceZoneMesh& zMesh = mesh.faceZones();
// use the zoneId directly instead of the name
for (int zoneI=0; zoneI < selector.size(); ++zoneI)
for
(
int regionId = selector.start();
regionId < selector.end();
++regionId
)
{
const int regionId = selector.start() + zoneI;
word zoneName = getFirstWord
(
regionSelection->GetArrayName(regionId)
);
if (!selectedRegions_[regionId])
const label zoneId = zMesh.findZoneID(zoneName);
if (!regionStatus_[regionId] || zoneId < 0)
{
continue;
}
if (debug)
{
Info<< "Creating VTK mesh for faceZone: "
<< zoneI << endl;
Info<< "Creating VTK mesh for faceZone[" << zoneId
<< "] " << zoneName << endl;
}
const label datasetId = GetNumberOfDataSets(output, selector);
vtkPolyData* vtkmesh = vtkPolyData::New();
addFaceZoneMesh
vtkPolyData* vtkmesh = faceZoneVTKMesh
(
mesh,
fzMesh[zoneI],
vtkmesh
zMesh[zoneId]
);
if (vtkmesh)
{
AddToBlock
(
output, selector, datasetId, vtkmesh,
fzMesh.names()[zoneI] + ":faceZone"
output, selector, datasetNo, vtkmesh,
zMesh[zoneId].name() + ":faceZone"
);
selectedRegionDatasetIds_[regionId] = datasetId;
vtkmesh->Delete();
created = true;
regionDataset_[regionId] = datasetNo++;
}
}
}
if (created)
// was anything added?
if (datasetNo)
{
++blockNo;
}
@ -526,12 +526,12 @@ void Foam::vtkPV3Foam::convertMeshFaceSets
}
const fvMesh& mesh = *meshPtr_;
selectionInfo& selector = selectInfoFaceSets_;
vtkDataArraySelection* arraySelection = reader_->GetRegionSelection();
selectionInfo& selector = regionInfoFaceSets_;
vtkDataArraySelection* regionSelection = reader_->GetRegionSelection();
// set output block and note if anything was added
// set output block, restart at dataset 0
selector.block(blockNo);
bool created = false;
label datasetNo = 0;
// Create the face sets and add as dataset
if (selector.size())
@ -543,47 +543,46 @@ void Foam::vtkPV3Foam::convertMeshFaceSets
++regionId
)
{
if (!selectedRegions_[regionId])
if (!regionStatus_[regionId])
{
continue;
}
word selectName = getFirstWord
word selectedName = getFirstWord
(
arraySelection->GetArrayName(regionId)
regionSelection->GetArrayName(regionId)
);
if (debug)
{
Info<< "Creating VTK mesh for faceSet: " << selectName
Info<< "Creating VTK mesh for faceSet: " << selectedName
<< " region index: " << regionId << endl;
}
const faceSet fSet(mesh, selectName);
const faceSet fSet(mesh, selectedName);
const label datasetId = GetNumberOfDataSets(output, selector);
vtkPolyData* vtkmesh = vtkPolyData::New();
addFaceSetMesh
vtkPolyData* vtkmesh = faceSetVTKMesh
(
mesh,
fSet,
vtkmesh
fSet
);
if (vtkmesh)
{
AddToBlock
(
output, selector, datasetId, vtkmesh,
selectName + ":faceSet"
output, selector, datasetNo, vtkmesh,
selectedName + ":faceSet"
);
selectedRegionDatasetIds_[regionId] = datasetId;
vtkmesh->Delete();
created = true;
regionDataset_[regionId] = datasetNo++;
}
}
}
if (created)
// was anything added?
if (datasetNo)
{
++blockNo;
}
@ -609,62 +608,58 @@ void Foam::vtkPV3Foam::convertMeshPointZones
}
const fvMesh& mesh = *meshPtr_;
selectionInfo& selector = selectInfoPointZones_;
selectionInfo& selector = regionInfoPointZones_;
vtkDataArraySelection* regionSelection = reader_->GetRegionSelection();
// set output block and note if anything was added
// set output block, restart at dataset 0
selector.block(blockNo);
bool created = false;
label datasetNo = 0;
// Create the point sets and add as dataset
if (selector.size())
{
const pointZoneMesh& pzMesh = mesh.pointZones();
const pointZoneMesh& zMesh = mesh.pointZones();
// use the zoneId directly instead of the name
for (int zoneI=0; zoneI < selector.size(); ++zoneI)
for
(
int regionId = selector.start();
regionId < selector.end();
++regionId
)
{
const int regionId = selector.start() + zoneI;
word zoneName = getFirstWord
(
regionSelection->GetArrayName(regionId)
);
if (!selectedRegions_[regionId])
label zoneId = zMesh.findZoneID(zoneName);
if (!regionStatus_[regionId] || zoneId < 0)
{
continue;
}
if (debug)
vtkPolyData* vtkmesh = pointZoneVTKMesh(mesh, zMesh[zoneId]);
if (vtkmesh)
{
Info<< "Creating VTK mesh for pointZone: "
<< zoneI << endl;
}
const label datasetId = GetNumberOfDataSets(output, selector);
vtkPolyData* vtkmesh = vtkPolyData::New();
addPointZoneMesh
(
mesh,
pzMesh[zoneI],
vtkmesh
);
AddToBlock
(
output, selector, datasetId, vtkmesh,
pzMesh.names()[zoneI] + ":pointZone"
output, selector, datasetNo, vtkmesh,
zMesh[zoneId].name() + ":pointZone"
);
selectedRegionDatasetIds_[regionId] = datasetId;
vtkmesh->Delete();
created = true;
regionDataset_[regionId] = datasetNo++;
}
}
}
if (created)
// was anything added?
if (datasetNo)
{
++blockNo;
}
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::convertMeshPointZones" << endl;
@ -687,14 +682,13 @@ void Foam::vtkPV3Foam::convertMeshPointSets
}
const fvMesh& mesh = *meshPtr_;
selectionInfo& selector = selectInfoPointSets_;
vtkDataArraySelection* arraySelection = reader_->GetRegionSelection();
selectionInfo& selector = regionInfoPointSets_;
vtkDataArraySelection* regionSelection = reader_->GetRegionSelection();
// set output block and note if anything was added
// set output block, restart at dataset 0
selector.block(blockNo);
bool created = false;
label datasetNo = 0;
// Create the point sets and add as dataset
if (selector.size())
{
for
@ -704,47 +698,41 @@ void Foam::vtkPV3Foam::convertMeshPointSets
++regionId
)
{
if (!selectedRegions_[regionId])
if (!regionStatus_[regionId])
{
continue;
}
word selectName = getFirstWord
word selectedName = getFirstWord
(
arraySelection->GetArrayName(regionId)
regionSelection->GetArrayName(regionId)
);
if (debug)
{
Info<< "Creating VTK mesh for pointSet: " << selectName
Info<< "Creating VTK mesh for pointSet: " << selectedName
<< " region index: " << regionId << endl;
}
const pointSet pSet(mesh, selectName);
const pointSet pSet(mesh, selectedName);
const label datasetId = GetNumberOfDataSets(output, selector);
vtkPolyData* vtkmesh = vtkPolyData::New();
addPointSetMesh
(
mesh,
pSet,
vtkmesh
);
vtkPolyData* vtkmesh = pointSetVTKMesh(mesh, pSet);
if (vtkmesh)
{
AddToBlock
(
output, selector, datasetId, vtkmesh,
selectName + ":pointSet"
output, selector, datasetNo, vtkmesh,
selectedName + ":pointSet"
);
selectedRegionDatasetIds_[regionId] = datasetId;
vtkmesh->Delete();
created = true;
regionDataset_[regionId] = datasetNo++;
}
}
}
if (created)
// was anything added?
if (datasetNo)
{
++blockNo;
}

View File

@ -31,81 +31,68 @@ Description
// Foam includes
#include "Cloud.H"
#include "fvMesh.H"
#include "passiveParticle.H"
#include "vtkPV3FoamInsertNextPoint.H"
#include "IOobjectList.H"
#include "passiveParticle.H"
#include "vtkPV3FoamPoints.H"
// VTK includes
#include "vtkCellArray.h"
#include "vtkPoints.h"
#include "vtkPolyData.h"
#include "vtkUnstructuredGrid.h"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::vtkPV3Foam::addLagrangianMesh
vtkPolyData* Foam::vtkPV3Foam::lagrangianVTKMesh
(
const fvMesh& mesh,
vtkPolyData *vtkmesh
const word& cloudName
)
{
vtkPolyData* vtkmesh = NULL;
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::addLagrangianMesh - timePath "
<< mesh.time().timePath()/"lagrangian" << endl;
Info<< "<beg> Foam::vtkPV3Foam::lagrangianVTKMesh - timePath "
<< mesh.time().timePath()/"lagrangian"/cloudName << endl;
printMemory();
}
fileNameList cloudDirs
(
readDir(mesh.time().timePath()/"lagrangian", fileName::DIRECTORY)
);
if (debug && cloudDirs.size())
{
Info<< "... check cloudDirs: " << cloudDirs << endl;
}
bool foundCloud = false;
forAll(cloudDirs, i)
{
IOobjectList sprayObjs
(
mesh,
mesh.time().timeName(),
"lagrangian"/cloudDirs[i]
"lagrangian"/cloudName
);
IOobject* positionsPtr = sprayObjs.lookup("positions");
if (positionsPtr && !foundCloud)
if (positionsPtr)
{
foundCloud = true;
Cloud<passiveParticle> parcels(mesh, cloudDirs[i], false);
Cloud<passiveParticle> parcels(mesh, cloudName, false);
if (debug)
{
Info<< "cloud with " << parcels.size() << " parcels" << endl;
}
vtkmesh = vtkPolyData::New();
vtkPoints* vtkpoints = vtkPoints::New();
vtkpoints->Allocate(parcels.size());
vtkpoints->Allocate( parcels.size() );
forAllConstIter(Cloud<passiveParticle>, parcels, elmnt)
forAllConstIter(Cloud<passiveParticle>, parcels, iter)
{
vtkPV3FoamInsertNextPoint(vtkpoints, elmnt().position());
vtkPV3FoamInsertNextPoint(vtkpoints, iter().position());
}
vtkmesh->SetPoints(vtkpoints);
vtkpoints->Delete();
}
}
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::addLagrangianMesh" << endl;
Info<< "<end> Foam::vtkPV3Foam::lagrangianVTKMesh" << endl;
printMemory();
}
return vtkmesh;
}

View File

@ -31,7 +31,7 @@ Description
// Foam includes
#include "polyPatch.H"
#include "primitivePatch.H"
#include "vtkPV3FoamInsertNextPoint.H"
#include "vtkPV3FoamPoints.H"
// VTK includes
#include "vtkCellArray.h"
@ -40,15 +40,16 @@ Description
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::vtkPV3Foam::addPatchMesh
vtkPolyData* Foam::vtkPV3Foam::patchVTKMesh
(
const polyPatch& p,
vtkPolyData *vtkmesh
const polyPatch& p
)
{
vtkPolyData* vtkmesh = vtkPolyData::New();
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::addPatchMesh - " << p.name() << endl;
Info<< "<beg> Foam::vtkPV3Foam::patchVTKMesh - " << p.name() << endl;
printMemory();
}
@ -56,7 +57,7 @@ void Foam::vtkPV3Foam::addPatchMesh
const Foam::pointField& points = p.localPoints();
vtkPoints *vtkpoints = vtkPoints::New();
vtkpoints->Allocate(points.size());
vtkpoints->Allocate( points.size() );
forAll(points, i)
{
vtkPV3FoamInsertNextPoint(vtkpoints, points[i]);
@ -69,14 +70,14 @@ void Foam::vtkPV3Foam::addPatchMesh
// Add faces as polygons
const faceList& faces = p.localFaces();
vtkCellArray * vtkcells = vtkCellArray::New();
vtkcells->Allocate(faces.size());
vtkCellArray* vtkcells = vtkCellArray::New();
vtkcells->Allocate( faces.size() );
forAll(faces, faceI)
{
const face& f = faces[faceI];
vtkIdType nodeIds[f.size()];
forAll (f, fp)
forAll(f, fp)
{
nodeIds[fp] = f[fp];
}
@ -88,9 +89,11 @@ void Foam::vtkPV3Foam::addPatchMesh
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::addPatchMesh - " << p.name() << endl;
Info<< "<end> Foam::vtkPV3Foam::patchVTKMesh - " << p.name() << endl;
printMemory();
}
return vtkmesh;
}

View File

@ -31,7 +31,7 @@ Description
// Foam includes
#include "faceSet.H"
#include "pointSet.H"
#include "vtkPV3FoamInsertNextPoint.H"
#include "vtkPV3FoamPoints.H"
// VTK includes
#include "vtkPoints.h"
@ -40,16 +40,17 @@ Description
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::vtkPV3Foam::addFaceSetMesh
vtkPolyData* Foam::vtkPV3Foam::faceSetVTKMesh
(
const fvMesh& mesh,
const faceSet& fSet,
vtkPolyData* vtkmesh
const faceSet& fSet
)
{
vtkPolyData* vtkmesh = vtkPolyData::New();
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::addFaceSetMesh" << endl;
Info<< "<beg> Foam::vtkPV3Foam::faceSetVTKMesh" << endl;
printMemory();
}
@ -65,13 +66,13 @@ void Foam::vtkPV3Foam::addFaceSetMesh
primitiveFacePatch p(patchFaces, mesh.points());
// The balance of this routine should be identical to addPatchMesh
// The balance of this routine should be identical to patchVTKMesh
// Convert Foam mesh vertices to VTK
const pointField& points = p.localPoints();
vtkPoints *vtkpoints = vtkPoints::New();
vtkpoints->Allocate(points.size());
vtkpoints->Allocate( points.size() );
forAll(points, i)
{
vtkPV3FoamInsertNextPoint(vtkpoints, points[i]);
@ -83,13 +84,14 @@ void Foam::vtkPV3Foam::addFaceSetMesh
const faceList& faces = p.localFaces();
vtkCellArray* vtkcells = vtkCellArray::New();
vtkcells->Allocate(p.size());
vtkcells->Allocate( faces.size() );
forAll(faces, faceI)
{
const face& f = faces[faceI];
vtkIdType nodeIds[f.size()];
forAll (f, fp)
forAll(f, fp)
{
nodeIds[fp] = f[fp];
}
@ -101,29 +103,32 @@ void Foam::vtkPV3Foam::addFaceSetMesh
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::addFaceSetMesh" << endl;
Info<< "<end> Foam::vtkPV3Foam::faceSetVTKMesh" << endl;
printMemory();
}
return vtkmesh;
}
void Foam::vtkPV3Foam::addPointSetMesh
vtkPolyData* Foam::vtkPV3Foam::pointSetVTKMesh
(
const fvMesh& mesh,
const pointSet& pSet,
vtkPolyData* vtkmesh
const pointSet& pSet
)
{
vtkPolyData* vtkmesh = vtkPolyData::New();
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::addPointSetMesh" << endl;
Info<< "<beg> Foam::vtkPV3Foam::pointSetVTKMesh" << endl;
printMemory();
}
const pointField& meshPoints = mesh.points();
vtkPoints *vtkpoints = vtkPoints::New();
vtkpoints->Allocate(pSet.size());
vtkpoints->Allocate( pSet.size() );
forAllConstIter(pointSet, pSet, iter)
{
@ -135,9 +140,12 @@ void Foam::vtkPV3Foam::addPointSetMesh
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::addPointSetMesh" << endl;
Info<< "<end> Foam::vtkPV3Foam::pointSetVTKMesh" << endl;
printMemory();
}
return vtkmesh;
}
// ************************************************************************* //

View File

@ -26,35 +26,30 @@ Description
\*---------------------------------------------------------------------------*/
#ifndef vtkPV3FoamAddVolumeMesh_H
#define vtkPV3FoamAddVolumeMesh_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "vtkPV3Foam.H"
// Foam includes
#include "fvMesh.H"
#include "cellModeller.H"
#include "vtkPV3FoamInsertNextPoint.H"
#include "vtkPV3FoamPoints.H"
// VTK includes
#include "vtkCellArray.h"
#include "vtkUnstructuredGrid.h"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::vtkPV3Foam::addVolumeMesh
vtkUnstructuredGrid* Foam::vtkPV3Foam::volumeVTKMesh
(
const fvMesh& mesh,
vtkUnstructuredGrid* vtkmesh,
labelList& superCells
)
{
vtkUnstructuredGrid* vtkmesh = vtkUnstructuredGrid::New();
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::addVolumeMesh" << endl;
Info<< "<beg> Foam::vtkPV3Foam::volumeVTKMesh" << endl;
printMemory();
}
@ -124,10 +119,10 @@ void Foam::vtkPV3Foam::addVolumeMesh
if (debug)
{
Info<<"mesh.nCells() = " << mesh.nCells() << nl
<<"mesh.nPoints() = " << mesh.nPoints() << nl
<<"nAddCells = " << nAddCells << nl
<<"nAddPoints = " << nAddPoints << endl;
Info<<" mesh nCells = " << mesh.nCells() << nl
<<" nPoints = " << mesh.nPoints() << nl
<<" nAddCells = " << nAddCells << nl
<<" nAddPoints = " << nAddPoints << endl;
}
superCells.setSize(mesh.nCells() + nAddCells);
@ -139,7 +134,7 @@ void Foam::vtkPV3Foam::addVolumeMesh
// Convert Foam mesh vertices to VTK
vtkPoints *vtkpoints = vtkPoints::New();
vtkpoints->Allocate(mesh.nPoints() + nAddPoints);
vtkpoints->Allocate( mesh.nPoints() + nAddPoints );
const Foam::pointField& points = mesh.points();
@ -154,21 +149,21 @@ void Foam::vtkPV3Foam::addVolumeMesh
Info<< "... converting cells" << endl;
}
vtkmesh->Allocate(mesh.nCells() + nAddCells);
vtkmesh->Allocate( mesh.nCells() + nAddCells );
// Set counters for additional points and additional cells
label api = 0, aci = 0;
label addPointI = 0, addCellI = 0;
// Create storage for points - needed for mapping from Foam to VTK
// data types - max 'order' = hex = 8 points
vtkIdType nodeIds[8];
forAll(cellShapes, celli)
forAll(cellShapes, cellI)
{
const cellShape& cellShape = cellShapes[celli];
const cellShape& cellShape = cellShapes[cellI];
const cellModel& cellModel = cellShape.model();
superCells[aci++] = celli;
superCells[addCellI++] = cellI;
if (cellModel == tet)
{
@ -265,16 +260,16 @@ void Foam::vtkPV3Foam::addVolumeMesh
// Polyhedral cell. Decompose into tets + prisms.
// Mapping from additional point to cell
addPointCellLabels_[api] = celli;
addPointCellLabels_[addPointI] = cellI;
// Insert the new vertex from the cell-centre
label newVertexLabel = mesh.nPoints() + api;
vtkPV3FoamInsertNextPoint(vtkpoints, mesh.C()[celli]);
label newVertexLabel = mesh.nPoints() + addPointI;
vtkPV3FoamInsertNextPoint(vtkpoints, mesh.C()[cellI]);
// Whether to insert cell in place of original or not.
bool substituteCell = true;
const labelList& cFaces = mesh.cells()[celli];
const labelList& cFaces = mesh.cells()[cellI];
forAll(cFaces, cFaceI)
{
@ -293,13 +288,13 @@ void Foam::vtkPV3Foam::addVolumeMesh
if (substituteCell)
{
thisCellI = celli;
thisCellI = cellI;
substituteCell = false;
}
else
{
thisCellI = mesh.nCells() + aci;
superCells[aci++] = celli;
thisCellI = mesh.nCells() + addCellI;
superCells[addCellI++] = cellI;
}
nodeIds[0] = f[0];
@ -323,13 +318,13 @@ void Foam::vtkPV3Foam::addVolumeMesh
if (substituteCell)
{
thisCellI = celli;
thisCellI = cellI;
substituteCell = false;
}
else
{
thisCellI = mesh.nCells() + aci;
superCells[aci++] = celli;
thisCellI = mesh.nCells() + addCellI;
superCells[addCellI++] = cellI;
}
nodeIds[0] = f[0];
@ -345,7 +340,7 @@ void Foam::vtkPV3Foam::addVolumeMesh
}
}
api++;
addPointI++;
}
}
@ -354,14 +349,11 @@ void Foam::vtkPV3Foam::addVolumeMesh
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::addVolumeMesh" << endl;
Info<< "<end> Foam::vtkPV3Foam::volumeVTKMesh" << endl;
printMemory();
}
return vtkmesh;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -29,7 +29,7 @@ Description
#include "vtkPV3Foam.H"
// Foam includes
#include "vtkPV3FoamInsertNextPoint.H"
#include "vtkPV3FoamPoints.H"
// VTK includes
#include "vtkPoints.h"
@ -39,20 +39,21 @@ Description
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::vtkPV3Foam::addFaceZoneMesh
vtkPolyData* Foam::vtkPV3Foam::faceZoneVTKMesh
(
const fvMesh& mesh,
const labelList& faceLabels,
vtkPolyData* vtkmesh
const labelList& faceLabels
)
{
vtkPolyData* vtkmesh = vtkPolyData::New();
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::addFaceZoneMesh" << endl;
Info<< "<beg> Foam::vtkPV3Foam::faceZoneVTKMesh" << endl;
printMemory();
}
// Construct primitivePatch of faces in fSet.
// Construct primitivePatch of faces in faceZone
const faceList& meshFaces = mesh.faces();
faceList patchFaces(faceLabels.size());
@ -63,31 +64,34 @@ void Foam::vtkPV3Foam::addFaceZoneMesh
primitiveFacePatch p(patchFaces, mesh.points());
// The balance of this routine should be identical to addPatchMesh
// The balance of this routine should be identical to patchVTKMesh
// Convert Foam mesh vertices to VTK
const pointField& points = p.localPoints();
vtkPoints *vtkpoints = vtkPoints::New();
vtkpoints->Allocate(p.size());
vtkPoints* vtkpoints = vtkPoints::New();
vtkpoints->Allocate( points.size() );
forAll(points, i)
{
vtkPV3FoamInsertNextPoint(vtkpoints, points[i]);
}
vtkmesh->SetPoints(vtkpoints);
vtkpoints->Delete();
// Add faces as polygons
const faceList& faces = p.localFaces();
vtkCellArray* vtkcells = vtkCellArray::New();
vtkcells->Allocate(points.size());
vtkcells->Allocate( faces.size() );
forAll(faces, faceI)
{
const face& f = faces[faceI];
vtkIdType nodeIds[f.size()];
forAll (f, fp)
forAll(f, fp)
{
nodeIds[fp] = f[fp];
}
@ -99,30 +103,33 @@ void Foam::vtkPV3Foam::addFaceZoneMesh
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::addFaceZoneMesh" << endl;
Info<< "<end> Foam::vtkPV3Foam::faceZoneVTKMesh" << endl;
printMemory();
}
return vtkmesh;
}
void Foam::vtkPV3Foam::addPointZoneMesh
vtkPolyData* Foam::vtkPV3Foam::pointZoneVTKMesh
(
const fvMesh& mesh,
const labelList& pointLabels,
vtkPolyData* vtkmesh
const labelList& pointLabels
)
{
vtkPolyData* vtkmesh = vtkPolyData::New();
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::addPointZoneMesh" << endl;
Info<< "<beg> Foam::vtkPV3Foam::pointZoneVTKMesh" << endl;
printMemory();
}
const pointField& meshPoints = mesh.points();
vtkPoints *vtkpoints = vtkPoints::New();
vtkpoints->Allocate(pointLabels.size());
vtkpoints->Allocate( pointLabels.size() );
forAll(pointLabels, pointI)
{
@ -134,9 +141,11 @@ void Foam::vtkPV3Foam::addPointZoneMesh
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::addPointZoneMesh" << endl;
Info<< "<beg> Foam::vtkPV3Foam::pointZoneVTKMesh" << endl;
printMemory();
}
return vtkmesh;
}
// ************************************************************************* //

View File

@ -27,19 +27,20 @@ InClass
\*---------------------------------------------------------------------------*/
#ifndef vtkPV3FoamConvertPatchFaceField_H
#define vtkPV3FoamConvertPatchFaceField_H
#ifndef vtkPV3FoamPatchField_H
#define vtkPV3FoamPatchField_H
// VTK includes
#include "vtkCellData.h"
#include "vtkFloatArray.h"
#include "vtkMultiBlockDataSet.h"
#include "vtkPointData.h"
#include "vtkPolyData.h"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
void Foam::vtkPV3Foam::convertPatchFaceField
void Foam::vtkPV3Foam::convertPatchField
(
const word& name,
const Field<Type>& ptf,
@ -55,14 +56,13 @@ void Foam::vtkPV3Foam::convertPatchFaceField
GetDataSetFromBlock(output, selector, datasetNo)
);
vtkFloatArray *cellData = vtkFloatArray::New();
cellData->SetNumberOfTuples(ptf.size());
cellData->SetNumberOfComponents(nComp);
cellData->Allocate(nComp*ptf.size());
cellData->SetName(name.c_str());
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];
@ -79,6 +79,46 @@ void Foam::vtkPV3Foam::convertPatchFaceField
}
// as above, but with PointData()
template<class Type>
void Foam::vtkPV3Foam::convertPatchPointField
(
const word& name,
const Field<Type>& pptf,
vtkMultiBlockDataSet* output,
const selectionInfo& selector,
const label datasetNo
)
{
const label nComp = pTraits<Type>::nComponents;
vtkPolyData* vtkmesh = vtkPolyData::SafeDownCast
(
GetDataSetFromBlock(output, selector, datasetNo)
);
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);
}
pointData->InsertTuple(i, vec);
}
vtkmesh->GetPointData()->AddArray(pointData);
pointData->Delete();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif

View File

@ -27,8 +27,8 @@ InClass
\*---------------------------------------------------------------------------*/
#ifndef vtkPV3FoamConvertPointFields_H
#define vtkPV3FoamConvertPointFields_H
#ifndef vtkPV3FoamPointFields_H
#define vtkPV3FoamPointFields_H
// Foam includes
#include "interpolatePointToCell.H"
@ -39,11 +39,12 @@ template<class Type>
void Foam::vtkPV3Foam::convertPointFields
(
const fvMesh& mesh,
const pointMesh& pMesh,
const IOobjectList& objects,
vtkDataArraySelection* fieldSelection,
vtkMultiBlockDataSet* output
)
{
// field subset based on type
IOobjectList fieldObjects
(
objects.lookupClass
@ -52,20 +53,12 @@ void Foam::vtkPV3Foam::convertPointFields
)
);
label nFields = fieldSelection->GetNumberOfArrays();
const polyBoundaryMesh& patches = mesh.boundaryMesh();
vtkDataArraySelection* regionSelection = reader_->GetRegionSelection();
for (label i=0; i<nFields; i++)
forAllIter(IOobjectList, fieldObjects, iter)
{
const word fieldName = fieldSelection->GetArrayName(i);
if
(
!fieldSelection->GetArraySetting(i)
|| !fieldObjects.found(fieldName))
{
continue;
}
word fieldName = iter()->name();
if (debug)
{
@ -73,17 +66,9 @@ void Foam::vtkPV3Foam::convertPointFields
<< fieldName << endl;
}
pointMesh pMesh(mesh);
GeometricField<Type, pointPatchField, pointMesh> ptf
(
IOobject
(
fieldName,
mesh.time().timeName(),
mesh,
IOobject::MUST_READ
),
*iter(),
pMesh
);
@ -93,14 +78,14 @@ void Foam::vtkPV3Foam::convertPointFields
//
for
(
int regionId = selectInfoVolume_.start();
regionId < selectInfoVolume_.end();
int regionId = regionInfoVolume_.start();
regionId < regionInfoVolume_.end();
++regionId
)
{
const label datasetId = selectedRegionDatasetIds_[regionId];
const label datasetNo = regionDataset_[regionId];
if (!selectedRegions_[regionId] || datasetId < 0)
if (!regionStatus_[regionId] || datasetNo < 0)
{
continue;
}
@ -110,37 +95,43 @@ void Foam::vtkPV3Foam::convertPointFields
ptf,
GeometricField<Type, fvPatchField, volMesh>::null(),
output,
selectInfoVolume_,
datasetId
regionInfoVolume_,
datasetNo
);
}
//
// Convert patches - if activated
//
label regionId = selectInfoPatches_.start();
forAll (patches, patchI)
for
(
int regionId = regionInfoPatches_.start();
regionId < regionInfoPatches_.end();
++regionId
)
{
if (patches[patchI].size())
{
const label datasetId = selectedRegionDatasetIds_[regionId];
word patchName = getFirstWord
(
regionSelection->GetArrayName(regionId)
);
if (selectedRegions_[regionId] && datasetId >= 0)
const label datasetNo = regionDataset_[regionId];
const label patchId = patches.findPatchID(patchName);
if (!regionStatus_[regionId] || datasetNo < 0 || patchId < 0)
{
continue;
}
convertPatchPointField
(
fieldName,
ptf.boundaryField()[patchI].patchInternalField()(),
ptf.boundaryField()[patchId].patchInternalField()(),
output,
selectInfoPatches_,
datasetId
regionInfoPatches_,
datasetNo
);
}
regionId++;
}
}
}
}
@ -157,37 +148,48 @@ void Foam::vtkPV3Foam::convertPointField
{
const label nComp = pTraits<Type>::nComponents;
vtkUnstructuredGrid* internalMesh = vtkUnstructuredGrid::SafeDownCast
vtkUnstructuredGrid* vtkmesh = vtkUnstructuredGrid::SafeDownCast
(
GetDataSetFromBlock(output, selector, datasetNo)
);
vtkFloatArray *pointData = vtkFloatArray::New();
pointData->SetNumberOfTuples(ptf.size() + addPointCellLabels_.size());
pointData->SetNumberOfComponents(nComp);
pointData->Allocate(nComp*ptf.size());
pointData->SetName(tf.name().c_str());
pointData->SetNumberOfTuples( ptf.size() + addPointCellLabels_.size() );
pointData->SetNumberOfComponents( nComp );
pointData->Allocate( nComp*(ptf.size() + addPointCellLabels_.size()) );
pointData->SetName( tf.name().c_str() );
if (debug)
{
Info<< "convert convertPointField: "
<< tf.name()
<< " size = " << ptf.size()
<< " nComp=" << nComp
<< " nTuples = " << (ptf.size() + addPointCellLabels_.size())
<< endl;
}
float vec[nComp];
forAll(ptf, i)
{
const Type& t = ptf[i];
for (direction d=0; d<nComp; d++)
{
vec[d] = component(ptf[i], d);
vec[d] = component(t, d);
}
pointData->InsertTuple(i, vec);
}
// continue insertion from here
label i = ptf.size();
if (&tf != &GeometricField<Type, fvPatchField, volMesh>::null())
{
forAll(addPointCellLabels_, api)
{
Type t = tf[addPointCellLabels_[api]];
const Type& t = tf[addPointCellLabels_[api]];
for (direction d=0; d<nComp; d++)
{
vec[d] = component(t, d);
@ -211,11 +213,10 @@ void Foam::vtkPV3Foam::convertPointField
}
}
internalMesh->GetPointData()->AddArray(pointData);
vtkmesh->GetPointData()->AddArray(pointData);
pointData->Delete();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif

View File

@ -27,8 +27,8 @@ InClass
\*---------------------------------------------------------------------------*/
#ifndef vtkPV3FoamInsertNextPoint_H
#define vtkPV3FoamInsertNextPoint_H
#ifndef vtkPV3FoamPoints_H
#define vtkPV3FoamPoints_H
// VTK includes
#include "vtkPoints.h"
@ -44,6 +44,34 @@ inline void vtkPV3FoamInsertNextPoint
points->InsertNextPoint(p.x(), p.y(), p.z());
}
#if 0
// this should be faster, but didn't get it working ...
inline void vtkPV3FoamSetPoint
(
vtkPoints *points,
const Foam::label id,
const Foam::point& p
)
{
points->SetPoint(id, p.x(), p.y(), p.z());
}
// Convert Foam mesh vertices to VTK
inline vtkPoints* vtkPV3FoamVTKPoints(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
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -38,7 +38,7 @@ License
// local headers
#include "vtkPV3FoamAddToSelection.H"
#include "vtkPV3FoamUpdateInformationFields.H"
#include "vtkPV3FoamUpdateInfoFields.H"
// VTK includes
#include "vtkDataArraySelection.h"
@ -107,7 +107,7 @@ Foam::wordList Foam::vtkPV3Foam::readZoneNames(const word& zoneType)
zonesEntries zones(ioObj);
zoneNames.setSize(zones.size());
forAll (zones, zoneI)
forAll(zones, zoneI)
{
zoneNames[zoneI] = zones[zoneI].keyword();
}
@ -117,14 +117,14 @@ Foam::wordList Foam::vtkPV3Foam::readZoneNames(const word& zoneType)
}
void Foam::vtkPV3Foam::updateInformationInternalMesh()
void Foam::vtkPV3Foam::updateInfoInternalMesh()
{
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::updateInformationInternalMesh" << endl;
Info<< "<beg> Foam::vtkPV3Foam::updateInfoInternalMesh" << endl;
}
vtkDataArraySelection* arraySelection = reader_->GetRegionSelection();
vtkDataArraySelection* regionSelection = reader_->GetRegionSelection();
// Determine number of meshes available
HashTable<const fvMesh*> meshObjects = dbPtr_().lookupClass<const fvMesh>();
@ -132,100 +132,85 @@ void Foam::vtkPV3Foam::updateInformationInternalMesh()
// Determine regions (internal mesh and patches...)
//- Add internal mesh as first entry
selectInfoVolume_ = arraySelection->GetNumberOfArrays();
arraySelection->AddArray("internalMesh");
selectInfoVolume_ += 1;
regionInfoVolume_ = regionSelection->GetNumberOfArrays();
regionSelection->AddArray("internalMesh");
regionInfoVolume_ += 1;
if (debug)
{
// just for debug info
getSelectedArrayEntries(arraySelection);
getSelectedArrayEntries(regionSelection);
Info<< "<end> Foam::vtkPV3Foam::updateInformationInternalMesh" << endl;
Info<< "<end> Foam::vtkPV3Foam::updateInfoInternalMesh" << endl;
}
}
void Foam::vtkPV3Foam::updateInformationLagrangian()
void Foam::vtkPV3Foam::updateInfoLagrangian()
{
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::updateInformationLagrangian" << nl
Info<< "<beg> Foam::vtkPV3Foam::updateInfoLagrangian" << nl
<< " " << dbPtr_->timePath()/"lagrangian" << endl;
}
vtkDataArraySelection* arraySelection = reader_->GetRegionSelection();
// Search for list of lagrangian objects for this time
fileNameList cloudDirs
(
readDir(dbPtr_->timePath()/"lagrangian", fileName::DIRECTORY)
);
selectInfoLagrangian_ = arraySelection->GetNumberOfArrays();
vtkDataArraySelection* regionSelection = reader_->GetRegionSelection();
regionInfoLagrangian_ = regionSelection->GetNumberOfArrays();
if (cloudDirs.size())
int nClouds = 0;
forAll(cloudDirs, cloudI)
{
arraySelection->AddArray("lagrangian");
selectInfoLagrangian_ += 1;
// Add cloud to GUI list
regionSelection->AddArray
(
(cloudDirs[cloudI] + " - lagrangian").c_str()
);
Info<< "... added cloudDirs\n";
++nClouds;
}
if (cloudDirs.size() > 1)
{
WarningIn("void Foam::vtkPV3Foam::updateInformationLagrangian()")
<< "Multiple lagrangian clouds identified. Currently only able "
<< "to process ONE cloud: " << cloudDirs[0]
<< endl;
}
// Set cloud name to first cloud found
// TODO - multiple clouds
cloudName_ = cloudDirs[0];
}
else
{
if (debug)
{
Info<< "... no clouds identified in " <<nl
<< " " <<dbPtr_->timePath()/"lagrangian" << endl;
}
}
regionInfoLagrangian_ += nClouds;
if (debug)
{
// just for debug info
getSelectedArrayEntries(arraySelection);
getSelectedArrayEntries(regionSelection);
Info<< "<end> Foam::vtkPV3Foam::updateInformationLagrangian" << endl;
Info<< "<end> Foam::vtkPV3Foam::updateInfoLagrangian" << endl;
}
}
void Foam::vtkPV3Foam::updateInformationPatches()
void Foam::vtkPV3Foam::updateInfoPatches()
{
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::updateInformationPatches"
Info<< "<beg> Foam::vtkPV3Foam::updateInfoPatches"
<< " [meshPtr=" << (meshPtr_ ? "set" : "NULL") << "]" << endl;
}
vtkDataArraySelection *arraySelection = reader_->GetRegionSelection();
selectInfoPatches_ = arraySelection->GetNumberOfArrays();
vtkDataArraySelection *regionSelection = reader_->GetRegionSelection();
regionInfoPatches_ = regionSelection->GetNumberOfArrays();
int nPatches = 0;
if (meshPtr_)
{
const polyBoundaryMesh& patches = meshPtr_->boundaryMesh();
forAll (patches, patchI)
forAll(patches, patchI)
{
const polyPatch& pp = patches[patchI];
if (pp.size())
{
// Add patch to GUI region list
arraySelection->AddArray
// Add patch to GUI list
regionSelection->AddArray
(
(pp.name() + " - patch").c_str()
);
@ -252,7 +237,7 @@ void Foam::vtkPV3Foam::updateInformationPatches()
);
// Start regions at patches
forAll (patchEntries, entryI)
forAll(patchEntries, entryI)
{
label nFaces
(
@ -262,8 +247,8 @@ void Foam::vtkPV3Foam::updateInformationPatches()
// Valid patch if nFace > 0
if (nFaces)
{
// Add patch to GUI region list
arraySelection->AddArray
// Add patch to GUI list
regionSelection->AddArray
(
(patchEntries[entryI].keyword() + " - patch").c_str()
);
@ -273,27 +258,32 @@ void Foam::vtkPV3Foam::updateInformationPatches()
}
}
selectInfoPatches_ += nPatches;
regionInfoPatches_ += nPatches;
if (debug)
{
// just for debug info
getSelectedArrayEntries(arraySelection);
getSelectedArrayEntries(regionSelection);
Info<< "<end> Foam::vtkPV3Foam::updateInformationPatches" << endl;
Info<< "<end> Foam::vtkPV3Foam::updateInfoPatches" << endl;
}
}
void Foam::vtkPV3Foam::updateInformationZones()
void Foam::vtkPV3Foam::updateInfoZones()
{
if (!reader_->GetIncludeZones())
{
return;
}
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::updateInformationZones"
Info<< "<beg> Foam::vtkPV3Foam::updateInfoZones"
<< " [meshPtr=" << (meshPtr_ ? "set" : "NULL") << "]" << endl;
}
vtkDataArraySelection *arraySelection = reader_->GetRegionSelection();
vtkDataArraySelection *regionSelection = reader_->GetRegionSelection();
wordList namesLst;
@ -309,13 +299,13 @@ void Foam::vtkPV3Foam::updateInformationZones()
namesLst = readZoneNames("cellZones");
}
selectInfoCellZones_ = arraySelection->GetNumberOfArrays();
forAll (namesLst, elemI)
regionInfoCellZones_ = regionSelection->GetNumberOfArrays();
forAll(namesLst, elemI)
{
arraySelection->AddArray((namesLst[elemI] + " - cellZone").c_str());
regionSelection->AddArray((namesLst[elemI] + " - cellZone").c_str());
}
selectInfoCellZones_ += namesLst.size();
zoneSuperCells_.setSize(selectInfoCellZones_.size());
regionInfoCellZones_ += namesLst.size();
zoneSuperCells_.setSize(regionInfoCellZones_.size());
//
@ -330,12 +320,15 @@ void Foam::vtkPV3Foam::updateInformationZones()
namesLst = readZoneNames("faceZones");
}
selectInfoFaceZones_ = arraySelection->GetNumberOfArrays();
forAll (namesLst, elemI)
regionInfoFaceZones_ = regionSelection->GetNumberOfArrays();
forAll(namesLst, elemI)
{
arraySelection->AddArray((namesLst[elemI] + " - faceZone").c_str());
regionSelection->AddArray
(
(namesLst[elemI] + " - faceZone").c_str()
);
}
selectInfoFaceZones_ += namesLst.size();
regionInfoFaceZones_ += namesLst.size();
//
@ -350,32 +343,40 @@ void Foam::vtkPV3Foam::updateInformationZones()
namesLst = readZoneNames("pointZones");
}
selectInfoPointZones_ = arraySelection->GetNumberOfArrays();
forAll (namesLst, elemI)
regionInfoPointZones_ = regionSelection->GetNumberOfArrays();
forAll(namesLst, elemI)
{
arraySelection->AddArray((namesLst[elemI] + " - pointZone").c_str());
regionSelection->AddArray
(
(namesLst[elemI] + " - pointZone").c_str()
);
}
selectInfoPointZones_ += namesLst.size();
regionInfoPointZones_ += namesLst.size();
if (debug)
{
// just for debug info
getSelectedArrayEntries(arraySelection);
getSelectedArrayEntries(regionSelection);
Info<< "<end> Foam::vtkPV3Foam::updateInformationZones" << endl;
Info<< "<end> Foam::vtkPV3Foam::updateInfoZones" << endl;
}
}
void Foam::vtkPV3Foam::updateInformationSets()
void Foam::vtkPV3Foam::updateInfoSets()
{
if (debug)
if (!reader_->GetIncludeSets())
{
Info<< "<beg> Foam::vtkPV3Foam::updateInformationSets" << endl;
return;
}
vtkDataArraySelection *arraySelection = reader_->GetRegionSelection();
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::updateInfoSets" << endl;
}
vtkDataArraySelection *regionSelection = reader_->GetRegionSelection();
// Add names of sets
IOobjectList objects
@ -386,27 +387,27 @@ void Foam::vtkPV3Foam::updateInformationSets()
);
selectInfoCellSets_ = arraySelection->GetNumberOfArrays();
selectInfoCellSets_ += addToSelection<cellSet>
regionInfoCellSets_ = regionSelection->GetNumberOfArrays();
regionInfoCellSets_ += addToSelection<cellSet>
(
arraySelection,
regionSelection,
objects,
" - cellSet"
);
csetSuperCells_.setSize(selectInfoCellSets_.size());
csetSuperCells_.setSize(regionInfoCellSets_.size());
selectInfoFaceSets_ = arraySelection->GetNumberOfArrays();
selectInfoFaceSets_ += addToSelection<faceSet>
regionInfoFaceSets_ = regionSelection->GetNumberOfArrays();
regionInfoFaceSets_ += addToSelection<faceSet>
(
arraySelection,
regionSelection,
objects,
" - faceSet"
);
selectInfoPointSets_ = arraySelection->GetNumberOfArrays();
selectInfoPointSets_ += addToSelection<pointSet>
regionInfoPointSets_ = regionSelection->GetNumberOfArrays();
regionInfoPointSets_ += addToSelection<pointSet>
(
arraySelection,
regionSelection,
objects,
" - pointSet"
);
@ -414,82 +415,102 @@ void Foam::vtkPV3Foam::updateInformationSets()
if (debug)
{
// just for debug info
getSelectedArrayEntries(arraySelection);
getSelectedArrayEntries(regionSelection);
Info<< "<end> Foam::vtkPV3Foam::updateInformationSets" << endl;
Info<< "<end> Foam::vtkPV3Foam::updateInfoSets" << endl;
}
}
void Foam::vtkPV3Foam::updateInformationLagrangianFields()
void Foam::vtkPV3Foam::updateInfoLagrangianFields()
{
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::updateInformationLagrangianFields"
Info<< "<beg> Foam::vtkPV3Foam::updateInfoLagrangianFields"
<< endl;
}
vtkDataArraySelection *arraySelection =
vtkDataArraySelection *fieldSelection =
reader_->GetLagrangianFieldSelection();
vtkDataArraySelection *regionSelection =
reader_->GetRegionSelection();
// preserve the enabled selections
stringList selectedEntries = getSelectedArrayEntries
(
arraySelection,
fieldSelection,
true
);
arraySelection->RemoveAllArrays();
fieldSelection->RemoveAllArrays();
//
// TODO - can currently only get fields from ONE cloud
//
const selectionInfo& selector = regionInfoLagrangian_;
int regionId = selector.start();
if (!selector.size() || regionId < 0)
{
return;
}
word cloudName = getFirstWord
(
regionSelection->GetArrayName(regionId)
);
// TODO - currently hard-coded to ONE cloud
IOobjectList objects
(
dbPtr_(),
dbPtr_().timeName(),
"lagrangian"/cloudName_
"lagrangian"/cloudName
);
addToSelection<IOField<label> >
(
arraySelection,
fieldSelection,
objects
);
addToSelection<IOField<scalar> >
(
arraySelection,
fieldSelection,
objects
);
addToSelection<IOField<vector> >
(
arraySelection,
fieldSelection,
objects
);
addToSelection<IOField<sphericalTensor> >
(
arraySelection,
fieldSelection,
objects
);
addToSelection<IOField<symmTensor> >
(
arraySelection,
fieldSelection,
objects
);
addToSelection<IOField<tensor> >
(
arraySelection,
fieldSelection,
objects
);
// restore the enabled selections
setSelectedArrayEntries
(
arraySelection,
fieldSelection,
selectedEntries
);
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::updateInformationLagrangianFields - "
Info<< "<end> Foam::vtkPV3Foam::updateInfoLagrangianFields - "
<< "lagrangian objects.size() = " << objects.size() << endl;
}
}

View File

@ -27,25 +27,25 @@ InClass
\*---------------------------------------------------------------------------*/
#ifndef vtkPV3FoamUpdateInformationFields_H
#define vtkPV3FoamUpdateInformationFields_H
#ifndef vtkPV3FoamUpdateInfoFields_H
#define vtkPV3FoamUpdateInfoFields_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<template<class> class patchType, class meshType>
void Foam::vtkPV3Foam::updateInformationFields
void Foam::vtkPV3Foam::updateInfoFields
(
vtkDataArraySelection *arraySelection
vtkDataArraySelection *select
)
{
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::updateInformationFields" << endl;
Info<< "<beg> Foam::vtkPV3Foam::updateInfoFields" << endl;
}
stringList selectedEntries;
// enable 'p' and 'U' on the first call
if (arraySelection->GetNumberOfArrays() == 0 && !meshPtr_)
if (select->GetNumberOfArrays() == 0 && !meshPtr_)
{
selectedEntries.setSize(2);
selectedEntries[0] = "p";
@ -54,61 +54,55 @@ void Foam::vtkPV3Foam::updateInformationFields
else
{
// preserve the enabled selections
selectedEntries = getSelectedArrayEntries
(
arraySelection
);
selectedEntries = getSelectedArrayEntries(select);
}
arraySelection->RemoveAllArrays();
select->RemoveAllArrays();
// Search for list of objects for this time
IOobjectList objects(dbPtr_(), dbPtr_().timeName());
// Populate the GUI volume/point field arrays
//- Add volume fields to GUI
addToSelection<GeometricField<scalar, patchType, meshType> >
(
arraySelection,
select,
objects
);
addToSelection<GeometricField<vector, patchType, meshType> >
(
arraySelection,
select,
objects
);
addToSelection<GeometricField<sphericalTensor, patchType, meshType> >
(
arraySelection,
select,
objects
);
addToSelection<GeometricField<symmTensor, patchType, meshType> >
(
arraySelection,
select,
objects
);
addToSelection<GeometricField<tensor, patchType, meshType> >
(
arraySelection,
select,
objects
);
// restore the enabled selections
setSelectedArrayEntries
(
arraySelection,
select,
selectedEntries
);
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::updateInformationFields" << endl;
Info<< "<end> Foam::vtkPV3Foam::updateInfoFields" << endl;
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -27,16 +27,15 @@ InClass
\*---------------------------------------------------------------------------*/
#ifndef vtkPV3FoamConvertVolFields_H
#define vtkPV3FoamConvertVolFields_H
#ifndef vtkPV3FoamVolFields_H
#define vtkPV3FoamVolFields_H
// Foam includes
#include "emptyFvPatchField.H"
#include "wallPolyPatch.H"
#include "faceSet.H"
#include "vtkPV3FoamConvertPatchFaceField.H"
#include "vtkPV3FoamConvertPatchPointField.H"
#include "vtkPV3FoamConvertFaceField.H"
#include "vtkPV3FoamFaceField.H"
#include "vtkPV3FoamPatchField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -47,10 +46,10 @@ void Foam::vtkPV3Foam::convertVolFields
const volPointInterpolation& pInterp,
const PtrList<PrimitivePatchInterpolation<primitivePatch> >& ppInterpList,
const IOobjectList& objects,
vtkDataArraySelection *fieldSelection,
vtkMultiBlockDataSet* output
)
{
// field subset based on type
IOobjectList fieldObjects
(
objects.lookupClass
@ -59,37 +58,16 @@ void Foam::vtkPV3Foam::convertVolFields
)
);
label nFields = fieldSelection->GetNumberOfArrays();
const polyBoundaryMesh& patches = mesh.boundaryMesh();
vtkDataArraySelection* regionSelection = reader_->GetRegionSelection();
vtkDataArraySelection* arraySelector = reader_->GetRegionSelection();
for (label i=0; i<nFields; i++)
forAllIter(IOobjectList, fieldObjects, iter)
{
const word fieldName = fieldSelection->GetArrayName(i);
if
(
!fieldSelection->GetArraySetting(i)
|| !fieldObjects.found(fieldName))
{
continue;
}
if (debug)
{
Info<< "converting volume field: " << fieldName << endl;
}
word fieldName = iter()->name();
GeometricField<Type, fvPatchField, volMesh> tf
(
IOobject
(
fieldName,
mesh.time().timeName(),
mesh,
IOobject::MUST_READ
),
*iter(),
mesh
);
@ -104,14 +82,14 @@ void Foam::vtkPV3Foam::convertVolFields
//
for
(
int regionId = selectInfoVolume_.start();
regionId < selectInfoVolume_.end();
int regionId = regionInfoVolume_.start();
regionId < regionInfoVolume_.end();
++regionId
)
{
const label datasetId = selectedRegionDatasetIds_[regionId];
const label datasetNo = regionDataset_[regionId];
if (!selectedRegions_[regionId] || datasetId < 0)
if (!regionStatus_[regionId] || datasetNo < 0)
{
continue;
}
@ -120,8 +98,8 @@ void Foam::vtkPV3Foam::convertVolFields
(
tf,
output,
selectInfoVolume_,
datasetId,
regionInfoVolume_,
datasetNo,
superCells_
);
convertPointField
@ -129,8 +107,8 @@ void Foam::vtkPV3Foam::convertVolFields
tptf(),
tf,
output,
selectInfoVolume_,
datasetId
regionInfoVolume_,
datasetNo
);
}
@ -139,29 +117,25 @@ void Foam::vtkPV3Foam::convertVolFields
//
for
(
int regionId = selectInfoPatches_.start();
regionId < selectInfoPatches_.end();
int regionId = regionInfoPatches_.start();
regionId < regionInfoPatches_.end();
++regionId
)
{
const label datasetId = selectedRegionDatasetIds_[regionId];
word patchName = getFirstWord
(
regionSelection->GetArrayName(regionId)
);
if (!selectedRegions_[regionId] || datasetId < 0)
const label datasetNo = regionDataset_[regionId];
const label patchId = patches.findPatchID(patchName);
if (!regionStatus_[regionId] || datasetNo < 0 || patchId < 0)
{
continue;
}
word selectName = getFirstWord
(
arraySelector->GetArrayName(regionId)
);
const label patchId = patches.findPatchID(selectName);
const fvPatchField<Type>& ptf
(
tf.boundaryField()[patchId]
);
const fvPatchField<Type>& ptf = tf.boundaryField()[patchId];
if
(
@ -179,24 +153,24 @@ void Foam::vtkPV3Foam::convertVolFields
tf.mesh().boundary()
);
convertPatchFaceField
convertPatchField
(
tf.name(),
fvPatchField<Type>(p, tf).patchInternalField()(),
output,
selectInfoPatches_,
datasetId
regionInfoPatches_,
datasetNo
);
}
else
{
convertPatchFaceField
convertPatchField
(
tf.name(),
ptf,
output,
selectInfoPatches_,
datasetId
regionInfoPatches_,
datasetNo
);
}
@ -205,8 +179,8 @@ void Foam::vtkPV3Foam::convertVolFields
tf.name(),
ppInterpList[patchId].faceToPointInterpolate(ptf)(),
output,
selectInfoPatches_,
datasetId
regionInfoPatches_,
datasetNo
);
}
@ -215,14 +189,14 @@ void Foam::vtkPV3Foam::convertVolFields
//
for
(
int regionId = selectInfoCellZones_.start();
regionId < selectInfoCellZones_.end();
int regionId = regionInfoCellZones_.start();
regionId < regionInfoCellZones_.end();
++regionId
)
{
const label datasetId = selectedRegionDatasetIds_[regionId];
const label datasetNo = regionDataset_[regionId];
if (!selectedRegions_[regionId] || datasetId < 0)
if (!regionStatus_[regionId] || datasetNo < 0)
{
continue;
}
@ -230,7 +204,7 @@ void Foam::vtkPV3Foam::convertVolFields
if (debug)
{
Info<< "wish to convert cellzone: "
<< getFirstWord(arraySelector->GetArrayName(regionId))
<< getFirstWord(regionSelection->GetArrayName(regionId))
<< " regionId: " << regionId
<< " volume field: " << fieldName
<< endl;
@ -240,9 +214,9 @@ void Foam::vtkPV3Foam::convertVolFields
(
tf,
output,
selectInfoCellZones_,
datasetId,
zoneSuperCells_[datasetId]
regionInfoCellZones_,
datasetNo,
zoneSuperCells_[datasetNo]
);
}
@ -251,14 +225,14 @@ void Foam::vtkPV3Foam::convertVolFields
//
for
(
int regionId = selectInfoCellSets_.start();
regionId < selectInfoCellSets_.end();
int regionId = regionInfoCellSets_.start();
regionId < regionInfoCellSets_.end();
++regionId
)
{
const label datasetId = selectedRegionDatasetIds_[regionId];
const label datasetNo = regionDataset_[regionId];
if (!selectedRegions_[regionId] || datasetId < 0)
if (!regionStatus_[regionId] || datasetNo < 0)
{
continue;
}
@ -266,7 +240,7 @@ void Foam::vtkPV3Foam::convertVolFields
if (debug)
{
Info<< "wish to convert cellset: "
<< getFirstWord(arraySelector->GetArrayName(regionId))
<< getFirstWord(regionSelection->GetArrayName(regionId))
<< " regionId: " << regionId
<< " volume field: " << fieldName
<< endl;
@ -276,9 +250,9 @@ void Foam::vtkPV3Foam::convertVolFields
(
tf,
output,
selectInfoCellSets_,
datasetId,
csetSuperCells_[datasetId]
regionInfoCellSets_,
datasetNo,
csetSuperCells_[datasetNo]
);
}
@ -287,14 +261,26 @@ void Foam::vtkPV3Foam::convertVolFields
//
for
(
int regionId = selectInfoFaceZones_.start();
regionId < selectInfoFaceZones_.end();
int regionId = regionInfoFaceZones_.start();
regionId < regionInfoFaceZones_.end();
++regionId
)
{
const label datasetId = selectedRegionDatasetIds_[regionId];
word zoneName = getFirstWord
(
regionSelection->GetArrayName(regionId)
);
const label datasetNo = regionDataset_[regionId];
if (!selectedRegions_[regionId] || datasetId < 0)
if (!regionStatus_[regionId] || datasetNo < 0)
{
continue;
}
const faceZoneMesh& zMesh = mesh.faceZones();
const label zoneId = zMesh.findZoneID(zoneName);
if (zoneId < 0)
{
continue;
}
@ -302,23 +288,20 @@ void Foam::vtkPV3Foam::convertVolFields
if (debug)
{
Info<< "wish to convert facezone: "
<< getFirstWord(arraySelector->GetArrayName(regionId))
<< zoneName
<< " regionId: " << regionId
<< " volume field: " << fieldName
<< endl;
}
const faceZoneMesh& fzMesh = mesh.faceZones();
const label zoneI = regionId - selectInfoFaceZones_.start();
convertFaceField
(
tf,
output,
selectInfoFaceZones_,
datasetId,
regionInfoFaceZones_,
datasetNo,
mesh,
fzMesh[zoneI]
zMesh[zoneId]
);
}
@ -327,21 +310,20 @@ void Foam::vtkPV3Foam::convertVolFields
//
for
(
int regionId = selectInfoFaceSets_.start();
regionId < selectInfoFaceSets_.end();
int regionId = regionInfoFaceSets_.start();
regionId < regionInfoFaceSets_.end();
++regionId
)
{
const label datasetId = selectedRegionDatasetIds_[regionId];
if (!selectedRegions_[regionId] || datasetId < 0)
const label datasetNo = regionDataset_[regionId];
if (!regionStatus_[regionId] || datasetNo < 0)
{
continue;
}
word selectName = getFirstWord
(
arraySelector->GetArrayName(regionId)
regionSelection->GetArrayName(regionId)
);
if (debug)
@ -354,13 +336,12 @@ void Foam::vtkPV3Foam::convertVolFields
const faceSet fSet(mesh, selectName);
convertFaceField
(
tf,
output,
selectInfoFaceSets_,
datasetId,
regionInfoFaceSets_,
datasetNo,
mesh,
fSet
);
@ -387,30 +368,30 @@ void Foam::vtkPV3Foam::convertVolField
);
vtkFloatArray* celldata = vtkFloatArray::New();
celldata->SetNumberOfTuples(superCells.size());
celldata->SetNumberOfComponents(nComp);
celldata->Allocate(nComp*superCells.size());
celldata->SetName(tf.name().c_str());
celldata->SetNumberOfTuples( superCells.size() );
celldata->SetNumberOfComponents( nComp );
celldata->Allocate( nComp*superCells.size() );
celldata->SetName( tf.name().c_str() );
if (debug)
{
Info<< "converting vol<Type>Field: " << tf.name() << nl
<< "field size = " << tf.size() << nl
<< "nTuples = " << superCells.size() << nl
<< "nComp = " << nComp << endl;
Info<< "convert volField: "
<< tf.name()
<< " size = " << tf.size()
<< " nComp=" << nComp
<< " nTuples = " << superCells.size() << endl;
}
float vec[nComp];
forAll(superCells, scI)
forAll(superCells, i)
{
const Type& t = tf[superCells[scI]];
const Type& t = tf[superCells[i]];
for (direction d=0; d<nComp; d++)
{
vec[d] = component(t, d);
}
celldata->InsertTuple(scI, vec);
celldata->InsertTuple(i, vec);
}
vtkmesh->GetCellData()->AddArray(celldata);