mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: improve internal bookkeeping in paraview readers
- has the selected values directly and use these lookup names to store directly into a hash. This replaces several parallel lists of decomp information etc and makes it easier.
This commit is contained in:
@ -47,6 +47,20 @@ License
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
defineTypeNameAndDebug(vtkPVFoam, 0);
|
defineTypeNameAndDebug(vtkPVFoam, 0);
|
||||||
|
|
||||||
|
// file-scope
|
||||||
|
static word updateStateName(polyMesh::readUpdateState state)
|
||||||
|
{
|
||||||
|
switch (state)
|
||||||
|
{
|
||||||
|
case polyMesh::UNCHANGED: return "UNCHANGED";
|
||||||
|
case polyMesh::POINTS_MOVED: return "POINTS_MOVED";
|
||||||
|
case polyMesh::TOPO_CHANGE: return "TOPO_CHANGE";
|
||||||
|
case polyMesh::TOPO_PATCH_CHANGE: return "TOPO_PATCH_CHANGE";
|
||||||
|
};
|
||||||
|
|
||||||
|
return "UNKNOWN";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -138,27 +152,15 @@ int Foam::vtkPVFoam::setTime(int nRequest, const double requestTimes[])
|
|||||||
<< ", nearestIndex = " << nearestIndex << endl;
|
<< ", nearestIndex = " << nearestIndex << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// See what has changed
|
||||||
// see what has changed
|
|
||||||
if (timeIndex_ != nearestIndex)
|
if (timeIndex_ != nearestIndex)
|
||||||
{
|
{
|
||||||
timeIndex_ = nearestIndex;
|
timeIndex_ = nearestIndex;
|
||||||
runTime.setTime(Times[nearestIndex], nearestIndex);
|
runTime.setTime(Times[nearestIndex], nearestIndex);
|
||||||
|
|
||||||
// the fields change each time
|
// When the changes, so do the fields
|
||||||
fieldsChanged_ = true;
|
fieldsChanged_ = true;
|
||||||
|
meshState_ = meshPtr_ ? meshPtr_->readUpdate() : polyMesh::TOPO_CHANGE;
|
||||||
if (meshPtr_)
|
|
||||||
{
|
|
||||||
if (meshPtr_->readUpdate() != polyMesh::UNCHANGED)
|
|
||||||
{
|
|
||||||
meshChanged_ = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
meshChanged_ = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
reader_->UpdateProgress(0.05);
|
reader_->UpdateProgress(0.05);
|
||||||
|
|
||||||
@ -171,7 +173,7 @@ int Foam::vtkPVFoam::setTime(int nRequest, const double requestTimes[])
|
|||||||
Info<< "<end> setTime() - selectedTime="
|
Info<< "<end> setTime() - selectedTime="
|
||||||
<< Times[nearestIndex].name() << " index=" << timeIndex_
|
<< Times[nearestIndex].name() << " index=" << timeIndex_
|
||||||
<< "/" << Times.size()
|
<< "/" << Times.size()
|
||||||
<< " meshChanged=" << Switch(meshChanged_)
|
<< " meshUpdateState=" << updateStateName(meshState_)
|
||||||
<< " fieldsChanged=" << Switch(fieldsChanged_) << endl;
|
<< " fieldsChanged=" << Switch(fieldsChanged_) << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,7 +181,20 @@ int Foam::vtkPVFoam::setTime(int nRequest, const double requestTimes[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::word Foam::vtkPVFoam::getPartName(const int partId)
|
Foam::word Foam::vtkPVFoam::getPartName(const int partId) const
|
||||||
|
{
|
||||||
|
if (selectedPartIds_.found(partId))
|
||||||
|
{
|
||||||
|
return getFoamName(selectedPartIds_[partId]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return word::null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::word Foam::vtkPVFoam::getReaderPartName(const int partId) const
|
||||||
{
|
{
|
||||||
return getFoamName(reader_->GetPartArrayName(partId));
|
return getFoamName(reader_->GetPartArrayName(partId));
|
||||||
}
|
}
|
||||||
@ -199,7 +214,7 @@ Foam::vtkPVFoam::vtkPVFoam
|
|||||||
meshRegion_(polyMesh::defaultRegion),
|
meshRegion_(polyMesh::defaultRegion),
|
||||||
meshDir_(polyMesh::meshSubDir),
|
meshDir_(polyMesh::meshSubDir),
|
||||||
timeIndex_(-1),
|
timeIndex_(-1),
|
||||||
meshChanged_(true),
|
meshState_(polyMesh::TOPO_CHANGE),
|
||||||
fieldsChanged_(true),
|
fieldsChanged_(true),
|
||||||
rangeVolume_("unzoned"),
|
rangeVolume_("unzoned"),
|
||||||
rangePatches_("patch"),
|
rangePatches_("patch"),
|
||||||
@ -334,7 +349,7 @@ void Foam::vtkPVFoam::updateInfo()
|
|||||||
// time of the vtkDataArraySelection, but the qt/paraview proxy
|
// time of the vtkDataArraySelection, but the qt/paraview proxy
|
||||||
// layer doesn't care about that anyhow.
|
// layer doesn't care about that anyhow.
|
||||||
|
|
||||||
stringList enabledEntries;
|
HashSet<string> enabledEntries;
|
||||||
if (!partSelection->GetNumberOfArrays() && !meshPtr_)
|
if (!partSelection->GetNumberOfArrays() && !meshPtr_)
|
||||||
{
|
{
|
||||||
// enable 'internalMesh' on the first call
|
// enable 'internalMesh' on the first call
|
||||||
@ -356,10 +371,10 @@ void Foam::vtkPVFoam::updateInfo()
|
|||||||
updateInfoZones(partSelection);
|
updateInfoZones(partSelection);
|
||||||
updateInfoLagrangian(partSelection);
|
updateInfoLagrangian(partSelection);
|
||||||
|
|
||||||
// restore the enabled selections
|
// Adjust/restore the enabled selections
|
||||||
setSelectedArrayEntries(partSelection, enabledEntries);
|
setSelectedArrayEntries(partSelection, enabledEntries);
|
||||||
|
|
||||||
if (meshChanged_)
|
if (meshState_ != polyMesh::UNCHANGED)
|
||||||
{
|
{
|
||||||
fieldsChanged_ = true;
|
fieldsChanged_ = true;
|
||||||
}
|
}
|
||||||
@ -408,37 +423,48 @@ void Foam::vtkPVFoam::Update
|
|||||||
}
|
}
|
||||||
|
|
||||||
vtkDataArraySelection* selection = reader_->GetPartSelection();
|
vtkDataArraySelection* selection = reader_->GetPartSelection();
|
||||||
label nElem = selection->GetNumberOfArrays();
|
const int n = selection->GetNumberOfArrays();
|
||||||
|
|
||||||
if (partStatus_.size() != nElem)
|
// All previously selected (enabled) names
|
||||||
|
HashSet<string> original;
|
||||||
|
forAllConstIters(selectedPartIds_, iter)
|
||||||
{
|
{
|
||||||
partStatus_.setSize(nElem);
|
original.insert(iter.object());
|
||||||
partStatus_ = false;
|
|
||||||
meshChanged_ = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// this needs fixing if we wish to re-use the datasets
|
selectedPartIds_.clear();
|
||||||
partDataset_.setSize(nElem);
|
|
||||||
partDataset_ = -1;
|
|
||||||
|
|
||||||
// Read the selected mesh parts (zones, patches ...) and add to list
|
for (int id=0; id < n; ++id)
|
||||||
forAll(partStatus_, partId)
|
|
||||||
{
|
{
|
||||||
const int setting = selection->GetArraySetting(partId);
|
string str(selection->GetArrayName(id));
|
||||||
|
bool status = selection->GetArraySetting(id);
|
||||||
|
|
||||||
if (partStatus_[partId] != setting)
|
if (status)
|
||||||
{
|
{
|
||||||
partStatus_[partId] = setting;
|
selectedPartIds_.set(id, str); // id -> name
|
||||||
meshChanged_ = true;
|
|
||||||
|
if (!original.erase(str))
|
||||||
|
{
|
||||||
|
// New part, or newly enabled
|
||||||
|
//? meshChanged_ = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (original.erase(str))
|
||||||
|
{
|
||||||
|
// Part disappeared, or newly disabled
|
||||||
|
//? meshChanged_ = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug > 1)
|
if (debug > 1)
|
||||||
{
|
{
|
||||||
Info<< " part[" << partId << "] = "
|
Info<< " part[" << id << "] = " << status
|
||||||
<< partStatus_[partId]
|
<< " : " << str << nl;
|
||||||
<< " : " << selection->GetArrayName(partId) << endl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Info<< "<end> updateMeshPartsStatus" << endl;
|
Info<< "<end> updateMeshPartsStatus" << endl;
|
||||||
@ -467,8 +493,7 @@ void Foam::vtkPVFoam::Update
|
|||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Info<< "Creating OpenFOAM mesh for region " << meshRegion_
|
Info<< "Creating OpenFOAM mesh for region " << meshRegion_
|
||||||
<< " at time=" << dbPtr_().timeName()
|
<< " at time=" << dbPtr_().timeName() << endl;
|
||||||
<< endl;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -483,7 +508,7 @@ void Foam::vtkPVFoam::Update
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
meshChanged_ = true;
|
meshState_ = polyMesh::TOPO_CHANGE; // New mesh
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -502,6 +527,20 @@ void Foam::vtkPVFoam::Update
|
|||||||
|
|
||||||
reader_->UpdateProgress(0.4);
|
reader_->UpdateProgress(0.4);
|
||||||
|
|
||||||
|
// Update cached, saved, unneed values:
|
||||||
|
HashSet<string> nowActive;
|
||||||
|
forAllConstIters(selectedPartIds_, iter)
|
||||||
|
{
|
||||||
|
nowActive.insert(iter.object());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dispose of unneeded components
|
||||||
|
cachedVtp_.retain(nowActive);
|
||||||
|
cachedVtu_.retain(nowActive);
|
||||||
|
|
||||||
|
// Reset (expire) dataset ids
|
||||||
|
partDataset_.clear();
|
||||||
|
|
||||||
// Convert meshes - start port0 at block=0
|
// Convert meshes - start port0 at block=0
|
||||||
int blockNo = 0;
|
int blockNo = 0;
|
||||||
|
|
||||||
@ -549,21 +588,12 @@ void Foam::vtkPVFoam::Update
|
|||||||
}
|
}
|
||||||
reader_->UpdateProgress(0.95);
|
reader_->UpdateProgress(0.95);
|
||||||
|
|
||||||
meshChanged_ = fieldsChanged_ = false;
|
fieldsChanged_ = false;
|
||||||
|
meshState_ = polyMesh::UNCHANGED;
|
||||||
|
|
||||||
// Standard memory cleanup
|
// Standard memory cleanup
|
||||||
forAll(regionVtus_, i)
|
cachedVtp_.clear();
|
||||||
{
|
cachedVtu_.clear();
|
||||||
regionVtus_[i].clear();
|
|
||||||
}
|
|
||||||
forAll(zoneVtus_, i)
|
|
||||||
{
|
|
||||||
zoneVtus_[i].clear();
|
|
||||||
}
|
|
||||||
forAll(csetVtus_, i)
|
|
||||||
{
|
|
||||||
csetVtus_[i].clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -160,7 +160,17 @@ class vtkPVFoam
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef polyDecomp foamVtuData;
|
//- Bookkeeping for vtkPolyData
|
||||||
|
class foamVtpData
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
//- Bookkeeping for vtkUnstructuredGrid
|
||||||
|
class foamVtuData
|
||||||
|
:
|
||||||
|
public polyDecomp
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// Private Data
|
// Private Data
|
||||||
@ -184,20 +194,26 @@ class vtkPVFoam
|
|||||||
int timeIndex_;
|
int timeIndex_;
|
||||||
|
|
||||||
//- Track changes in mesh geometry
|
//- Track changes in mesh geometry
|
||||||
bool meshChanged_;
|
enum polyMesh::readUpdateState meshState_;
|
||||||
|
|
||||||
//- Track changes in fields
|
//- Track changes in fields
|
||||||
bool fieldsChanged_;
|
bool fieldsChanged_;
|
||||||
|
|
||||||
//- Selected geometrical parts (internalMesh, patches, ...)
|
//- The index of selected parts mapped to their names
|
||||||
boolList partStatus_;
|
Map<string> selectedPartIds_;
|
||||||
|
|
||||||
//- Datasets corresponding to selected geometrical pieces
|
//- Datasets corresponding to selected geometrical pieces
|
||||||
// a negative number indicates that no vtkmesh exists for this piece
|
Map<label> partDataset_;
|
||||||
labelList partDataset_;
|
|
||||||
|
//- Any information for 2D (VTP) geometries
|
||||||
|
HashTable<foamVtpData, string> cachedVtp_;
|
||||||
|
|
||||||
|
//- Cell maps and other information for 3D (VTU) geometries
|
||||||
|
HashTable<foamVtuData, string> cachedVtu_;
|
||||||
|
|
||||||
//- First instance and size of various mesh parts
|
//- First instance and size of various mesh parts
|
||||||
// used to index into partStatus_ and partDataset_
|
// used to index into selectedPartIds and thus indirectly into
|
||||||
|
// cachedVtp, cachedVtu and partDataset
|
||||||
arrayRange rangeVolume_;
|
arrayRange rangeVolume_;
|
||||||
arrayRange rangePatches_;
|
arrayRange rangePatches_;
|
||||||
arrayRange rangeLagrangian_;
|
arrayRange rangeLagrangian_;
|
||||||
@ -208,16 +224,6 @@ class vtkPVFoam
|
|||||||
arrayRange rangeFaceSets_;
|
arrayRange rangeFaceSets_;
|
||||||
arrayRange rangePointSets_;
|
arrayRange rangePointSets_;
|
||||||
|
|
||||||
//- Decomposed cells information (mesh regions)
|
|
||||||
// TODO: regions
|
|
||||||
List<foamVtuData> regionVtus_;
|
|
||||||
|
|
||||||
//- Decomposed cells information (cellZone meshes)
|
|
||||||
List<foamVtuData> zoneVtus_;
|
|
||||||
|
|
||||||
//- Decomposed cells information (cellSet meshes)
|
|
||||||
List<foamVtuData> csetVtus_;
|
|
||||||
|
|
||||||
//- List of patch names for rendering to window
|
//- List of patch names for rendering to window
|
||||||
List<vtkSmartPointer<vtkTextActor>> patchTextActors_;
|
List<vtkSmartPointer<vtkTextActor>> patchTextActors_;
|
||||||
|
|
||||||
@ -230,19 +236,24 @@ class vtkPVFoam
|
|||||||
// Update information helper functions
|
// Update information helper functions
|
||||||
|
|
||||||
//- Internal mesh info
|
//- Internal mesh info
|
||||||
void updateInfoInternalMesh(vtkDataArraySelection*);
|
void updateInfoInternalMesh(vtkDataArraySelection* select);
|
||||||
|
|
||||||
//- Lagrangian info
|
//- Lagrangian info
|
||||||
void updateInfoLagrangian(vtkDataArraySelection*);
|
void updateInfoLagrangian(vtkDataArraySelection* select);
|
||||||
|
|
||||||
//- Patch info
|
//- Patch info, modifies enabledEntries
|
||||||
void updateInfoPatches(vtkDataArraySelection*, stringList&);
|
void updateInfoPatches
|
||||||
|
(
|
||||||
|
vtkDataArraySelection* select,
|
||||||
|
HashSet<string>& enabledEntries
|
||||||
|
);
|
||||||
|
|
||||||
//- Set info
|
//- Set info
|
||||||
void updateInfoSets(vtkDataArraySelection*);
|
void updateInfoSets(vtkDataArraySelection* select);
|
||||||
|
|
||||||
//- Zone info
|
//- Zone info
|
||||||
void updateInfoZones(vtkDataArraySelection*);
|
void updateInfoZones(vtkDataArraySelection* select);
|
||||||
|
|
||||||
|
|
||||||
//- Get non-empty zone names for zoneType from file
|
//- Get non-empty zone names for zoneType from file
|
||||||
wordList getZoneNames(const word& zoneType) const;
|
wordList getZoneNames(const word& zoneType) const;
|
||||||
@ -395,8 +406,7 @@ class vtkPVFoam
|
|||||||
const GeometricField<Type, fvPatchField, volMesh>& fld,
|
const GeometricField<Type, fvPatchField, volMesh>& fld,
|
||||||
autoPtr<GeometricField<Type, pointPatchField, pointMesh>>& ptfPtr,
|
autoPtr<GeometricField<Type, pointPatchField, pointMesh>>& ptfPtr,
|
||||||
vtkMultiBlockDataSet* output,
|
vtkMultiBlockDataSet* output,
|
||||||
const arrayRange& range,
|
const arrayRange& range
|
||||||
const List<foamVtuData>& vtuDataList
|
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Lagrangian fields - all types
|
//- Lagrangian fields - all types
|
||||||
@ -423,8 +433,7 @@ class vtkPVFoam
|
|||||||
(
|
(
|
||||||
const GeometricField<Type, pointPatchField, pointMesh>& pfld,
|
const GeometricField<Type, pointPatchField, pointMesh>& pfld,
|
||||||
vtkMultiBlockDataSet* output,
|
vtkMultiBlockDataSet* output,
|
||||||
const arrayRange& range,
|
const arrayRange& range
|
||||||
const List<foamVtuData>& vtuDataList
|
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Point field
|
//- Point field
|
||||||
@ -447,8 +456,12 @@ class vtkPVFoam
|
|||||||
const hashedWordList& retain
|
const hashedWordList& retain
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Get the first word from selectedPartIds_
|
||||||
|
word getPartName(const int partId) const;
|
||||||
|
|
||||||
//- Get the first word from the reader 'parts' selection
|
//- Get the first word from the reader 'parts' selection
|
||||||
word getPartName(const int partId);
|
word getReaderPartName(const int partId) const;
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|||||||
@ -84,8 +84,7 @@ void Foam::vtkPVFoam::convertVolField
|
|||||||
fld,
|
fld,
|
||||||
ptfPtr,
|
ptfPtr,
|
||||||
output,
|
output,
|
||||||
rangeVolume_,
|
rangeVolume_
|
||||||
regionVtus_
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Convert activated cellZones
|
// Convert activated cellZones
|
||||||
@ -94,8 +93,7 @@ void Foam::vtkPVFoam::convertVolField
|
|||||||
fld,
|
fld,
|
||||||
ptfPtr,
|
ptfPtr,
|
||||||
output,
|
output,
|
||||||
rangeCellZones_,
|
rangeCellZones_
|
||||||
zoneVtus_
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Convert activated cellSets
|
// Convert activated cellSets
|
||||||
@ -104,21 +102,30 @@ void Foam::vtkPVFoam::convertVolField
|
|||||||
fld,
|
fld,
|
||||||
ptfPtr,
|
ptfPtr,
|
||||||
output,
|
output,
|
||||||
rangeCellSets_,
|
rangeCellSets_
|
||||||
csetVtus_
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Convert patches - if activated
|
// Convert patches - if activated
|
||||||
|
// - skip field conversion for groups
|
||||||
//
|
//
|
||||||
for (auto partId : rangePatches_)
|
for (auto partId : rangePatches_)
|
||||||
{
|
{
|
||||||
|
if
|
||||||
|
(
|
||||||
|
!selectedPartIds_.found(partId)
|
||||||
|
|| selectedPartIds_[partId].startsWith("group/")
|
||||||
|
)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const word patchName = getPartName(partId);
|
const word patchName = getPartName(partId);
|
||||||
const label datasetNo = partDataset_[partId];
|
const label datasetNo = partDataset_.lookup(partId, -1);
|
||||||
const label patchId = patches.findPatchID(patchName);
|
const label patchId = patches.findPatchID(patchName);
|
||||||
|
|
||||||
if (!partStatus_[partId] || patchId < 0)
|
if (patchId < 0)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -199,10 +206,15 @@ void Foam::vtkPVFoam::convertVolField
|
|||||||
//
|
//
|
||||||
for (auto partId : rangeFaceZones_)
|
for (auto partId : rangeFaceZones_)
|
||||||
{
|
{
|
||||||
const word zoneName = getPartName(partId);
|
if (!selectedPartIds_.found(partId))
|
||||||
const label datasetNo = partDataset_[partId];
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!partStatus_[partId] || datasetNo < 0)
|
const word zoneName = getPartName(partId);
|
||||||
|
const label datasetNo = partDataset_.lookup(partId, -1);
|
||||||
|
|
||||||
|
if (datasetNo < 0)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -239,14 +251,14 @@ void Foam::vtkPVFoam::convertVolField
|
|||||||
//
|
//
|
||||||
for (auto partId : rangeFaceSets_)
|
for (auto partId : rangeFaceSets_)
|
||||||
{
|
{
|
||||||
const word selectName = getPartName(partId);
|
if (!selectedPartIds_.found(partId))
|
||||||
const label datasetNo = partDataset_[partId];
|
|
||||||
|
|
||||||
if (!partStatus_[partId])
|
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const word selectName = getPartName(partId);
|
||||||
|
const label datasetNo = partDataset_.lookup(partId, -1);
|
||||||
|
|
||||||
vtkPolyData* vtkmesh = getDataFromBlock<vtkPolyData>
|
vtkPolyData* vtkmesh = getDataFromBlock<vtkPolyData>
|
||||||
(
|
(
|
||||||
output, rangeFaceSets_, datasetNo
|
output, rangeFaceSets_, datasetNo
|
||||||
@ -373,23 +385,23 @@ void Foam::vtkPVFoam::convertVolFieldBlock
|
|||||||
const GeometricField<Type, fvPatchField, volMesh>& fld,
|
const GeometricField<Type, fvPatchField, volMesh>& fld,
|
||||||
autoPtr<GeometricField<Type, pointPatchField, pointMesh>>& ptfPtr,
|
autoPtr<GeometricField<Type, pointPatchField, pointMesh>>& ptfPtr,
|
||||||
vtkMultiBlockDataSet* output,
|
vtkMultiBlockDataSet* output,
|
||||||
const arrayRange& range,
|
const arrayRange& range
|
||||||
const List<foamVtuData>& vtuDataList
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
for (auto partId : range)
|
for (auto partId : range)
|
||||||
{
|
{
|
||||||
const label datasetNo = partDataset_[partId];
|
if (!selectedPartIds_.found(partId))
|
||||||
|
|
||||||
if (!partStatus_[partId])
|
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto& longName = selectedPartIds_[partId];
|
||||||
|
const label datasetNo = partDataset_.lookup(partId, -1);
|
||||||
|
|
||||||
vtkUnstructuredGrid* vtkmesh =
|
vtkUnstructuredGrid* vtkmesh =
|
||||||
getDataFromBlock<vtkUnstructuredGrid>(output, range, datasetNo);
|
getDataFromBlock<vtkUnstructuredGrid>(output, range, datasetNo);
|
||||||
|
|
||||||
if (!vtkmesh)
|
if (!vtkmesh || !cachedVtu_.found(longName))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -397,13 +409,17 @@ void Foam::vtkPVFoam::convertVolFieldBlock
|
|||||||
vtkSmartPointer<vtkFloatArray> cdata = convertVolFieldToVTK
|
vtkSmartPointer<vtkFloatArray> cdata = convertVolFieldToVTK
|
||||||
(
|
(
|
||||||
fld,
|
fld,
|
||||||
vtuDataList[datasetNo]
|
cachedVtu_[longName]
|
||||||
);
|
);
|
||||||
vtkmesh->GetCellData()->AddArray(cdata);
|
vtkmesh->GetCellData()->AddArray(cdata);
|
||||||
|
|
||||||
if (ptfPtr.valid())
|
if (ptfPtr.valid())
|
||||||
{
|
{
|
||||||
convertPointField(vtkmesh, ptfPtr(), fld, vtuDataList[datasetNo]);
|
convertPointField
|
||||||
|
(
|
||||||
|
vtkmesh, ptfPtr(), fld,
|
||||||
|
cachedVtu_[longName]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -446,44 +462,53 @@ void Foam::vtkPVFoam::convertPointFields
|
|||||||
GeometricField<Type, pointPatchField, pointMesh> pfld(*iter(), pMesh);
|
GeometricField<Type, pointPatchField, pointMesh> pfld(*iter(), pMesh);
|
||||||
|
|
||||||
|
|
||||||
// Convert activated internalMesh regions
|
// Convert internalMesh (if selected)
|
||||||
convertPointFieldBlock
|
convertPointFieldBlock
|
||||||
(
|
(
|
||||||
pfld,
|
pfld,
|
||||||
output,
|
output,
|
||||||
rangeVolume_,
|
rangeVolume_
|
||||||
regionVtus_
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Convert activated cellZones
|
// Convert (selected) cellZones
|
||||||
convertPointFieldBlock
|
convertPointFieldBlock
|
||||||
(
|
(
|
||||||
pfld,
|
pfld,
|
||||||
output,
|
output,
|
||||||
rangeCellZones_,
|
rangeCellZones_
|
||||||
zoneVtus_
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Convert activated cellSets
|
// Convert (selected) cellSets
|
||||||
convertPointFieldBlock
|
convertPointFieldBlock
|
||||||
(
|
(
|
||||||
pfld,
|
pfld,
|
||||||
output,
|
output,
|
||||||
rangeCellSets_,
|
rangeCellSets_
|
||||||
csetVtus_
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Convert patches - if activated
|
// Convert patches (if selected)
|
||||||
//
|
//
|
||||||
for (auto partId : rangePatches_)
|
for (auto partId : rangePatches_)
|
||||||
{
|
{
|
||||||
|
if (!selectedPartIds_.found(partId))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const auto& longName = selectedPartIds_[partId];
|
||||||
|
|
||||||
|
if (longName.startsWith("group/"))
|
||||||
|
{
|
||||||
|
// Skip patch-groups
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const word patchName = getPartName(partId);
|
const word patchName = getPartName(partId);
|
||||||
const label datasetNo = partDataset_[partId];
|
const label datasetNo = partDataset_.lookup(partId, -1);
|
||||||
const label patchId = patches.findPatchID(patchName);
|
const label patchId = patches.findPatchID(patchName);
|
||||||
|
|
||||||
if (!partStatus_[partId] || patchId < 0)
|
if (patchId < 0)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -506,15 +531,20 @@ void Foam::vtkPVFoam::convertPointFields
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Convert faceZones - if activated
|
// Convert (selected) faceZones
|
||||||
//
|
//
|
||||||
for (auto partId : rangeFaceZones_)
|
for (auto partId : rangeFaceZones_)
|
||||||
{
|
{
|
||||||
|
if (!selectedPartIds_.found(partId))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const word zoneName = getPartName(partId);
|
const word zoneName = getPartName(partId);
|
||||||
const label datasetNo = partDataset_[partId];
|
const label datasetNo = partDataset_.lookup(partId, -1);
|
||||||
const label zoneId = mesh.faceZones().findZoneID(zoneName);
|
const label zoneId = mesh.faceZones().findZoneID(zoneName);
|
||||||
|
|
||||||
if (!partStatus_[partId] || zoneId < 0)
|
if (zoneId < 0)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -552,34 +582,35 @@ void Foam::vtkPVFoam::convertPointFieldBlock
|
|||||||
(
|
(
|
||||||
const GeometricField<Type, pointPatchField, pointMesh>& pfld,
|
const GeometricField<Type, pointPatchField, pointMesh>& pfld,
|
||||||
vtkMultiBlockDataSet* output,
|
vtkMultiBlockDataSet* output,
|
||||||
const arrayRange& range,
|
const arrayRange& range
|
||||||
const List<foamVtuData>& vtuDataList
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
for (auto partId : range)
|
for (auto partId : range)
|
||||||
{
|
{
|
||||||
const label datasetNo = partDataset_[partId];
|
if (!selectedPartIds_.found(partId))
|
||||||
|
|
||||||
if (!partStatus_[partId])
|
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto& longName = selectedPartIds_[partId];
|
||||||
|
const label datasetNo = partDataset_.lookup(partId, -1);
|
||||||
|
|
||||||
vtkUnstructuredGrid* vtkmesh = getDataFromBlock<vtkUnstructuredGrid>
|
vtkUnstructuredGrid* vtkmesh = getDataFromBlock<vtkUnstructuredGrid>
|
||||||
(
|
(
|
||||||
output, range, datasetNo
|
output, range, datasetNo
|
||||||
);
|
);
|
||||||
|
|
||||||
if (vtkmesh)
|
if (!vtkmesh || !cachedVtu_.found(longName))
|
||||||
{
|
{
|
||||||
convertPointField
|
convertPointField
|
||||||
(
|
(
|
||||||
vtkmesh,
|
vtkmesh,
|
||||||
pfld,
|
pfld,
|
||||||
GeometricField<Type, fvPatchField, volMesh>::null(),
|
GeometricField<Type, fvPatchField, volMesh>::null(),
|
||||||
vtuDataList[datasetNo]
|
cachedVtu_[longName]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -878,16 +909,16 @@ Foam::vtkPVFoam::convertVolFieldToVTK
|
|||||||
}
|
}
|
||||||
|
|
||||||
float vec[nComp];
|
float vec[nComp];
|
||||||
forAll(cellMap, i)
|
forAll(cellMap, idx)
|
||||||
{
|
{
|
||||||
const Type& t = fld[cellMap[i]];
|
const Type& t = fld[cellMap[idx]];
|
||||||
for (direction d=0; d<nComp; ++d)
|
for (direction d=0; d<nComp; ++d)
|
||||||
{
|
{
|
||||||
vec[d] = component(t, d);
|
vec[d] = component(t, d);
|
||||||
}
|
}
|
||||||
foamPvFields::remapTuple<Type>(vec);
|
foamPvFields::remapTuple<Type>(vec);
|
||||||
|
|
||||||
fldData->SetTuple(i, vec);
|
fldData->SetTuple(idx, vec);
|
||||||
}
|
}
|
||||||
|
|
||||||
return fldData;
|
return fldData;
|
||||||
|
|||||||
@ -226,10 +226,15 @@ void Foam::vtkPVFoam::convertLagrangianFields
|
|||||||
|
|
||||||
for (auto partId : range)
|
for (auto partId : range)
|
||||||
{
|
{
|
||||||
const word cloudName = getPartName(partId);
|
if (!selectedPartIds_.found(partId))
|
||||||
const label datasetNo = partDataset_[partId];
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!partStatus_[partId] || datasetNo < 0)
|
const word cloudName = getPartName(partId);
|
||||||
|
const label datasetNo = partDataset_.lookup(partId, -1);
|
||||||
|
|
||||||
|
if (datasetNo < 0)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,9 +53,6 @@ void Foam::vtkPVFoam::convertMeshVolume
|
|||||||
label datasetNo = 0; // restart at dataset 0
|
label datasetNo = 0; // restart at dataset 0
|
||||||
const fvMesh& mesh = *meshPtr_;
|
const fvMesh& mesh = *meshPtr_;
|
||||||
|
|
||||||
// resize for decomposed polyhedra
|
|
||||||
regionVtus_.setSize(range.size());
|
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Info<< "<beg> convertMeshVolume" << endl;
|
Info<< "<beg> convertMeshVolume" << endl;
|
||||||
@ -66,23 +63,24 @@ void Foam::vtkPVFoam::convertMeshVolume
|
|||||||
// this looks like more than one part, but it isn't
|
// this looks like more than one part, but it isn't
|
||||||
for (auto partId : range)
|
for (auto partId : range)
|
||||||
{
|
{
|
||||||
const word partName = "internalMesh";
|
if (!selectedPartIds_.found(partId))
|
||||||
|
|
||||||
if (!partStatus_[partId])
|
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto& longName = selectedPartIds_[partId];
|
||||||
|
const word partName = getPartName(partId);
|
||||||
|
|
||||||
vtkSmartPointer<vtkUnstructuredGrid> vtkmesh = volumeVTKMesh
|
vtkSmartPointer<vtkUnstructuredGrid> vtkmesh = volumeVTKMesh
|
||||||
(
|
(
|
||||||
mesh,
|
mesh,
|
||||||
regionVtus_[datasetNo]
|
cachedVtu_(longName)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (vtkmesh)
|
if (vtkmesh)
|
||||||
{
|
{
|
||||||
addToBlock(output, vtkmesh, range, datasetNo, partName);
|
addToBlock(output, vtkmesh, range, datasetNo, partName);
|
||||||
partDataset_[partId] = datasetNo++;
|
partDataset_.set(partId, datasetNo++);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,20 +117,20 @@ void Foam::vtkPVFoam::convertMeshLagrangian
|
|||||||
|
|
||||||
for (auto partId : range)
|
for (auto partId : range)
|
||||||
{
|
{
|
||||||
const word cloudName = getPartName(partId);
|
if (!selectedPartIds_.found(partId))
|
||||||
|
|
||||||
if (!partStatus_[partId])
|
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const word cloudName = getPartName(partId);
|
||||||
|
|
||||||
vtkSmartPointer<vtkPolyData> vtkmesh =
|
vtkSmartPointer<vtkPolyData> vtkmesh =
|
||||||
lagrangianVTKMesh(mesh, cloudName);
|
lagrangianVTKMesh(mesh, cloudName);
|
||||||
|
|
||||||
if (vtkmesh)
|
if (vtkmesh)
|
||||||
{
|
{
|
||||||
addToBlock(output, vtkmesh, range, datasetNo, cloudName);
|
addToBlock(output, vtkmesh, range, datasetNo, cloudName);
|
||||||
partDataset_[partId] = datasetNo++;
|
partDataset_.set(partId, datasetNo++);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,30 +168,28 @@ void Foam::vtkPVFoam::convertMeshPatches
|
|||||||
|
|
||||||
for (auto partId : range)
|
for (auto partId : range)
|
||||||
{
|
{
|
||||||
if (!partStatus_[partId])
|
if (!selectedPartIds_.found(partId))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
const auto& longName = selectedPartIds_[partId];
|
||||||
const word patchName = getPartName(partId);
|
const word partName = getPartName(partId);
|
||||||
|
|
||||||
labelHashSet
|
|
||||||
patchIds(patches.patchSet(List<wordRe>(1, wordRe(patchName))));
|
|
||||||
|
|
||||||
if (debug)
|
|
||||||
{
|
|
||||||
Info<< "Creating VTK mesh for patches [" << patchIds <<"] "
|
|
||||||
<< patchName << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
vtkSmartPointer<vtkPolyData> vtkmesh;
|
vtkSmartPointer<vtkPolyData> vtkmesh;
|
||||||
if (patchIds.size() == 1)
|
|
||||||
{
|
if (longName.startsWith("group/"))
|
||||||
vtkmesh = patchVTKMesh(patchName, patches[patchIds.begin().key()]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
// Patch group. Collect patch faces.
|
// Patch group. Collect patch faces.
|
||||||
|
|
||||||
|
const labelList& patchIds =
|
||||||
|
patches.groupPatchIDs().lookup(partName, labelList());
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Info<< "Creating VTK mesh for patches [" << patchIds <<"] "
|
||||||
|
<< longName << endl;
|
||||||
|
}
|
||||||
|
|
||||||
label sz = 0;
|
label sz = 0;
|
||||||
for (auto id : patchIds)
|
for (auto id : patchIds)
|
||||||
{
|
{
|
||||||
@ -210,23 +206,37 @@ void Foam::vtkPVFoam::convertMeshPatches
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uindirectPrimitivePatch pp
|
if (faceLabels.size())
|
||||||
(
|
{
|
||||||
UIndirectList<face>
|
uindirectPrimitivePatch pp
|
||||||
(
|
(
|
||||||
mesh.faces(),
|
UIndirectList<face>(mesh.faces(), faceLabels),
|
||||||
faceLabels
|
mesh.points()
|
||||||
),
|
);
|
||||||
mesh.points()
|
|
||||||
);
|
|
||||||
|
|
||||||
vtkmesh = patchVTKMesh(patchName, pp);
|
vtkmesh = patchVTKMesh(partName, pp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const label patchId = patches.findPatchID(partName);
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Info<< "Creating VTK mesh for patch [" << patchId <<"] "
|
||||||
|
<< partName << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (patchId >= 0)
|
||||||
|
{
|
||||||
|
vtkmesh = patchVTKMesh(partName, patches[patchId]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vtkmesh)
|
if (vtkmesh)
|
||||||
{
|
{
|
||||||
addToBlock(output, vtkmesh, range, datasetNo, patchName);
|
addToBlock(output, vtkmesh, range, datasetNo, partName);
|
||||||
partDataset_[partId] = datasetNo++;
|
partDataset_.set(partId, datasetNo++);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,9 +265,6 @@ void Foam::vtkPVFoam::convertMeshCellZones
|
|||||||
label datasetNo = 0; // restart at dataset 0
|
label datasetNo = 0; // restart at dataset 0
|
||||||
const fvMesh& mesh = *meshPtr_;
|
const fvMesh& mesh = *meshPtr_;
|
||||||
|
|
||||||
// resize for decomposed polyhedra
|
|
||||||
zoneVtus_.setSize(range.size());
|
|
||||||
|
|
||||||
if (range.empty())
|
if (range.empty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -272,10 +279,16 @@ void Foam::vtkPVFoam::convertMeshCellZones
|
|||||||
const cellZoneMesh& zMesh = mesh.cellZones();
|
const cellZoneMesh& zMesh = mesh.cellZones();
|
||||||
for (auto partId : range)
|
for (auto partId : range)
|
||||||
{
|
{
|
||||||
|
if (!selectedPartIds_.found(partId))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto& longName = selectedPartIds_[partId];
|
||||||
const word zoneName = getPartName(partId);
|
const word zoneName = getPartName(partId);
|
||||||
const label zoneId = zMesh.findZoneID(zoneName);
|
const label zoneId = zMesh.findZoneID(zoneName);
|
||||||
|
|
||||||
if (!partStatus_[partId] || zoneId < 0)
|
if (zoneId < 0)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -292,28 +305,28 @@ void Foam::vtkPVFoam::convertMeshCellZones
|
|||||||
vtkSmartPointer<vtkUnstructuredGrid> vtkmesh = volumeVTKMesh
|
vtkSmartPointer<vtkUnstructuredGrid> vtkmesh = volumeVTKMesh
|
||||||
(
|
(
|
||||||
subsetter.subMesh(),
|
subsetter.subMesh(),
|
||||||
zoneVtus_[datasetNo]
|
cachedVtu_(longName)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (vtkmesh)
|
if (vtkmesh)
|
||||||
{
|
{
|
||||||
// cellMap + addPointCellLabels must contain global cell ids
|
// Convert cellMap, addPointCellLabels to global cell ids
|
||||||
inplaceRenumber
|
inplaceRenumber
|
||||||
(
|
(
|
||||||
subsetter.cellMap(),
|
subsetter.cellMap(),
|
||||||
zoneVtus_[datasetNo].cellMap()
|
cachedVtu_[longName].cellMap()
|
||||||
);
|
);
|
||||||
inplaceRenumber
|
inplaceRenumber
|
||||||
(
|
(
|
||||||
subsetter.cellMap(),
|
subsetter.cellMap(),
|
||||||
zoneVtus_[datasetNo].additionalIds()
|
cachedVtu_[longName].additionalIds()
|
||||||
);
|
);
|
||||||
|
|
||||||
// copy pointMap as well, otherwise pointFields fail
|
// copy pointMap as well, otherwise pointFields fail
|
||||||
zoneVtus_[datasetNo].pointMap() = subsetter.pointMap();
|
cachedVtu_[longName].pointMap() = subsetter.pointMap();
|
||||||
|
|
||||||
addToBlock(output, vtkmesh, range, datasetNo, zoneName);
|
addToBlock(output, vtkmesh, range, datasetNo, zoneName);
|
||||||
partDataset_[partId] = datasetNo++;
|
partDataset_.set(partId, datasetNo++);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,9 +355,6 @@ void Foam::vtkPVFoam::convertMeshCellSets
|
|||||||
label datasetNo = 0; // restart at dataset 0
|
label datasetNo = 0; // restart at dataset 0
|
||||||
const fvMesh& mesh = *meshPtr_;
|
const fvMesh& mesh = *meshPtr_;
|
||||||
|
|
||||||
// resize for decomposed polyhedra
|
|
||||||
csetVtus_.setSize(range.size());
|
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Info<< "<beg> convertMeshCellSets" << endl;
|
Info<< "<beg> convertMeshCellSets" << endl;
|
||||||
@ -353,13 +363,14 @@ void Foam::vtkPVFoam::convertMeshCellSets
|
|||||||
|
|
||||||
for (auto partId : range)
|
for (auto partId : range)
|
||||||
{
|
{
|
||||||
const word partName = getPartName(partId);
|
if (!selectedPartIds_.found(partId))
|
||||||
|
|
||||||
if (!partStatus_[partId])
|
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto& longName = selectedPartIds_[partId];
|
||||||
|
const word partName = getPartName(partId);
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Info<< "Creating VTK mesh for cellSet=" << partName << endl;
|
Info<< "Creating VTK mesh for cellSet=" << partName << endl;
|
||||||
@ -372,28 +383,28 @@ void Foam::vtkPVFoam::convertMeshCellSets
|
|||||||
vtkSmartPointer<vtkUnstructuredGrid> vtkmesh = volumeVTKMesh
|
vtkSmartPointer<vtkUnstructuredGrid> vtkmesh = volumeVTKMesh
|
||||||
(
|
(
|
||||||
subsetter.subMesh(),
|
subsetter.subMesh(),
|
||||||
csetVtus_[datasetNo]
|
cachedVtu_(longName)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (vtkmesh)
|
if (vtkmesh)
|
||||||
{
|
{
|
||||||
// cellMap + addPointCellLabels must contain global cell ids
|
// Convert cellMap, addPointCellLabels to global cell ids
|
||||||
inplaceRenumber
|
inplaceRenumber
|
||||||
(
|
(
|
||||||
subsetter.cellMap(),
|
subsetter.cellMap(),
|
||||||
csetVtus_[datasetNo].cellMap()
|
cachedVtu_[longName].cellMap()
|
||||||
);
|
);
|
||||||
inplaceRenumber
|
inplaceRenumber
|
||||||
(
|
(
|
||||||
subsetter.cellMap(),
|
subsetter.cellMap(),
|
||||||
csetVtus_[datasetNo].additionalIds()
|
cachedVtu_[longName].additionalIds()
|
||||||
);
|
);
|
||||||
|
|
||||||
// copy pointMap as well, otherwise pointFields fail
|
// copy pointMap as well, otherwise pointFields fail
|
||||||
csetVtus_[datasetNo].pointMap() = subsetter.pointMap();
|
cachedVtu_[longName].pointMap() = subsetter.pointMap();
|
||||||
|
|
||||||
addToBlock(output, vtkmesh, range, datasetNo, partName);
|
addToBlock(output, vtkmesh, range, datasetNo, partName);
|
||||||
partDataset_[partId] = datasetNo++;
|
partDataset_.set(partId, datasetNo++);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -436,10 +447,15 @@ void Foam::vtkPVFoam::convertMeshFaceZones
|
|||||||
const faceZoneMesh& zMesh = mesh.faceZones();
|
const faceZoneMesh& zMesh = mesh.faceZones();
|
||||||
for (auto partId : range)
|
for (auto partId : range)
|
||||||
{
|
{
|
||||||
|
if (!selectedPartIds_.found(partId))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const word zoneName = getPartName(partId);
|
const word zoneName = getPartName(partId);
|
||||||
const label zoneId = zMesh.findZoneID(zoneName);
|
const label zoneId = zMesh.findZoneID(zoneName);
|
||||||
|
|
||||||
if (!partStatus_[partId] || zoneId < 0)
|
if (zoneId < 0)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -456,7 +472,7 @@ void Foam::vtkPVFoam::convertMeshFaceZones
|
|||||||
if (vtkmesh)
|
if (vtkmesh)
|
||||||
{
|
{
|
||||||
addToBlock(output, vtkmesh, range, datasetNo, zoneName);
|
addToBlock(output, vtkmesh, range, datasetNo, zoneName);
|
||||||
partDataset_[partId] = datasetNo++;
|
partDataset_.set(partId, datasetNo++);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -493,26 +509,24 @@ void Foam::vtkPVFoam::convertMeshFaceSets
|
|||||||
|
|
||||||
for (auto partId : range)
|
for (auto partId : range)
|
||||||
{
|
{
|
||||||
const word partName = getPartName(partId);
|
if (!selectedPartIds_.found(partId))
|
||||||
|
|
||||||
if (!partStatus_[partId])
|
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const word partName = getPartName(partId);
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Info<< "Creating VTK mesh for faceSet=" << partName << endl;
|
Info<< "Creating VTK mesh for faceSet=" << partName << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// faces in sorted order for more reliability
|
// faces in sorted order for more reliability
|
||||||
|
const labelList faceLabels = faceSet(mesh, partName).sortedToc();
|
||||||
|
|
||||||
uindirectPrimitivePatch p
|
uindirectPrimitivePatch p
|
||||||
(
|
(
|
||||||
UIndirectList<face>
|
UIndirectList<face>(mesh.faces(), faceLabels),
|
||||||
(
|
|
||||||
mesh.faces(),
|
|
||||||
faceSet(mesh, partName).sortedToc()
|
|
||||||
),
|
|
||||||
mesh.points()
|
mesh.points()
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -527,7 +541,7 @@ void Foam::vtkPVFoam::convertMeshFaceSets
|
|||||||
if (vtkmesh)
|
if (vtkmesh)
|
||||||
{
|
{
|
||||||
addToBlock(output, vtkmesh, range, datasetNo, partName);
|
addToBlock(output, vtkmesh, range, datasetNo, partName);
|
||||||
partDataset_[partId] = datasetNo++;
|
partDataset_.set(partId, datasetNo++);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -567,10 +581,15 @@ void Foam::vtkPVFoam::convertMeshPointZones
|
|||||||
const pointZoneMesh& zMesh = mesh.pointZones();
|
const pointZoneMesh& zMesh = mesh.pointZones();
|
||||||
for (auto partId : range)
|
for (auto partId : range)
|
||||||
{
|
{
|
||||||
|
if (!selectedPartIds_.found(partId))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const word zoneName = getPartName(partId);
|
const word zoneName = getPartName(partId);
|
||||||
const label zoneId = zMesh.findZoneID(zoneName);
|
const label zoneId = zMesh.findZoneID(zoneName);
|
||||||
|
|
||||||
if (!partStatus_[partId] || zoneId < 0)
|
if (zoneId < 0)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -600,7 +619,7 @@ void Foam::vtkPVFoam::convertMeshPointZones
|
|||||||
if (vtkmesh)
|
if (vtkmesh)
|
||||||
{
|
{
|
||||||
addToBlock(output, vtkmesh, range, datasetNo, zoneName);
|
addToBlock(output, vtkmesh, range, datasetNo, zoneName);
|
||||||
partDataset_[partId] = datasetNo++;
|
partDataset_.set(partId, datasetNo++);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -619,7 +638,6 @@ void Foam::vtkPVFoam::convertMeshPointZones
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::vtkPVFoam::convertMeshPointSets
|
void Foam::vtkPVFoam::convertMeshPointSets
|
||||||
(
|
(
|
||||||
vtkMultiBlockDataSet* output,
|
vtkMultiBlockDataSet* output,
|
||||||
@ -639,13 +657,13 @@ void Foam::vtkPVFoam::convertMeshPointSets
|
|||||||
|
|
||||||
for (auto partId : range)
|
for (auto partId : range)
|
||||||
{
|
{
|
||||||
const word partName = getPartName(partId);
|
if (!selectedPartIds_.found(partId))
|
||||||
|
|
||||||
if (!partStatus_[partId])
|
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const word partName = getPartName(partId);
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Info<< "Creating VTK mesh for pointSet=" << partName << endl;
|
Info<< "Creating VTK mesh for pointSet=" << partName << endl;
|
||||||
@ -676,7 +694,7 @@ void Foam::vtkPVFoam::convertMeshPointSets
|
|||||||
if (vtkmesh)
|
if (vtkmesh)
|
||||||
{
|
{
|
||||||
addToBlock(output, vtkmesh, range, datasetNo, partName);
|
addToBlock(output, vtkmesh, range, datasetNo, partName);
|
||||||
partDataset_[partId] = datasetNo++;
|
partDataset_.set(partId, datasetNo++);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -136,7 +136,7 @@ Foam::wordList Foam::vtkPVFoam::getZoneNames(const word& zoneType) const
|
|||||||
|
|
||||||
void Foam::vtkPVFoam::updateInfoInternalMesh
|
void Foam::vtkPVFoam::updateInfoInternalMesh
|
||||||
(
|
(
|
||||||
vtkDataArraySelection* arraySelection
|
vtkDataArraySelection* select
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
@ -146,8 +146,8 @@ void Foam::vtkPVFoam::updateInfoInternalMesh
|
|||||||
|
|
||||||
// Determine mesh parts (internalMesh, patches...)
|
// Determine mesh parts (internalMesh, patches...)
|
||||||
//- Add internal mesh as first entry
|
//- Add internal mesh as first entry
|
||||||
rangeVolume_.reset(arraySelection->GetNumberOfArrays(), 1);
|
rangeVolume_.reset(select->GetNumberOfArrays(), 1);
|
||||||
arraySelection->AddArray("internalMesh");
|
select->AddArray("internalMesh");
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
@ -158,7 +158,7 @@ void Foam::vtkPVFoam::updateInfoInternalMesh
|
|||||||
|
|
||||||
void Foam::vtkPVFoam::updateInfoLagrangian
|
void Foam::vtkPVFoam::updateInfoLagrangian
|
||||||
(
|
(
|
||||||
vtkDataArraySelection* arraySelection
|
vtkDataArraySelection* select
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
@ -167,7 +167,6 @@ void Foam::vtkPVFoam::updateInfoLagrangian
|
|||||||
<< " " << dbPtr_->timePath()/cloud::prefix << endl;
|
<< " " << dbPtr_->timePath()/cloud::prefix << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// use the db directly since this might be called without a mesh,
|
// use the db directly since this might be called without a mesh,
|
||||||
// but the region must get added back in
|
// but the region must get added back in
|
||||||
fileName lagrangianPrefix(cloud::prefix);
|
fileName lagrangianPrefix(cloud::prefix);
|
||||||
@ -182,11 +181,11 @@ void Foam::vtkPVFoam::updateInfoLagrangian
|
|||||||
readDir(dbPtr_->timePath()/lagrangianPrefix, fileName::DIRECTORY)
|
readDir(dbPtr_->timePath()/lagrangianPrefix, fileName::DIRECTORY)
|
||||||
);
|
);
|
||||||
|
|
||||||
rangeLagrangian_.reset(arraySelection->GetNumberOfArrays());
|
rangeLagrangian_.reset(select->GetNumberOfArrays());
|
||||||
forAll(cloudDirs, cloudi)
|
forAll(cloudDirs, cloudi)
|
||||||
{
|
{
|
||||||
// Add cloud to GUI list
|
// Add cloud to GUI list
|
||||||
arraySelection->AddArray
|
select->AddArray
|
||||||
(
|
(
|
||||||
("lagrangian/" + cloudDirs[cloudi]).c_str()
|
("lagrangian/" + cloudDirs[cloudi]).c_str()
|
||||||
);
|
);
|
||||||
@ -202,8 +201,8 @@ void Foam::vtkPVFoam::updateInfoLagrangian
|
|||||||
|
|
||||||
void Foam::vtkPVFoam::updateInfoPatches
|
void Foam::vtkPVFoam::updateInfoPatches
|
||||||
(
|
(
|
||||||
vtkDataArraySelection* arraySelection,
|
vtkDataArraySelection* select,
|
||||||
stringList& enabledEntries
|
HashSet<string>& enabledEntries
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
@ -212,14 +211,13 @@ void Foam::vtkPVFoam::updateInfoPatches
|
|||||||
<< " [meshPtr=" << (meshPtr_ ? "set" : "null") << "]" << endl;
|
<< " [meshPtr=" << (meshPtr_ ? "set" : "null") << "]" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
HashSet<string> enabledEntriesSet(enabledEntries);
|
rangePatches_.reset(select->GetNumberOfArrays());
|
||||||
|
|
||||||
rangePatches_.reset(arraySelection->GetNumberOfArrays());
|
|
||||||
|
|
||||||
if (meshPtr_)
|
if (meshPtr_)
|
||||||
{
|
{
|
||||||
const polyBoundaryMesh& patches = meshPtr_->boundaryMesh();
|
const polyBoundaryMesh& patches = meshPtr_->boundaryMesh();
|
||||||
const HashTable<labelList>& groups = patches.groupPatchIDs();
|
const HashTable<labelList>& groups = patches.groupPatchIDs();
|
||||||
|
DynamicList<string> displayNames(groups.size());
|
||||||
|
|
||||||
// Add (non-zero) patch groups to the list of mesh parts
|
// Add (non-zero) patch groups to the list of mesh parts
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
@ -243,29 +241,38 @@ void Foam::vtkPVFoam::updateInfoPatches
|
|||||||
|
|
||||||
// Valid patch if nFace > 0 - add patch to GUI list
|
// Valid patch if nFace > 0 - add patch to GUI list
|
||||||
const string dpyName = "group/" + groupName;
|
const string dpyName = "group/" + groupName;
|
||||||
arraySelection->AddArray(dpyName.c_str());
|
displayNames.append(dpyName);
|
||||||
++rangePatches_;
|
|
||||||
|
|
||||||
if (enabledEntriesSet.found(dpyName))
|
// Optionally replace group with patch name selections
|
||||||
|
// - must remove the group from the select itself, otherwise
|
||||||
|
// it can toggle on, but not toggle off very well
|
||||||
|
if
|
||||||
|
(
|
||||||
|
!reader_->GetShowGroupsOnly()
|
||||||
|
&& enabledEntries.erase(dpyName)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (!reader_->GetShowGroupsOnly())
|
for (auto patchId : patchIDs)
|
||||||
{
|
{
|
||||||
enabledEntriesSet.erase(dpyName);
|
const polyPatch& pp = patches[patchId];
|
||||||
for (auto patchId : patchIDs)
|
if (pp.size())
|
||||||
{
|
{
|
||||||
const polyPatch& pp = patches[patchId];
|
enabledEntries.insert
|
||||||
if (pp.size())
|
(
|
||||||
{
|
"patch/" + pp.name()
|
||||||
enabledEntriesSet.insert
|
);
|
||||||
(
|
|
||||||
"patch/" + pp.name()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sort group names
|
||||||
|
Foam::sort(displayNames);
|
||||||
|
for (const auto& name : displayNames)
|
||||||
|
{
|
||||||
|
select->AddArray(name.c_str());
|
||||||
|
++rangePatches_;
|
||||||
|
}
|
||||||
|
|
||||||
// Add (non-zero) patches to the list of mesh parts
|
// Add (non-zero) patches to the list of mesh parts
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
@ -279,7 +286,7 @@ void Foam::vtkPVFoam::updateInfoPatches
|
|||||||
if (pp.size())
|
if (pp.size())
|
||||||
{
|
{
|
||||||
// Add patch to GUI list
|
// Add patch to GUI list
|
||||||
arraySelection->AddArray
|
select->AddArray
|
||||||
(
|
(
|
||||||
("patch/" + pp.name()).c_str()
|
("patch/" + pp.name()).c_str()
|
||||||
);
|
);
|
||||||
@ -308,36 +315,24 @@ void Foam::vtkPVFoam::updateInfoPatches
|
|||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
// this should only ever fail if the mesh region doesn't exist
|
// This should only ever fail if the mesh region doesn't exist
|
||||||
if (ioObj.typeHeaderOk<polyBoundaryMesh>(true, false))
|
if (ioObj.typeHeaderOk<polyBoundaryMesh>(true, false))
|
||||||
{
|
{
|
||||||
polyBoundaryMeshEntries patchEntries(ioObj);
|
polyBoundaryMeshEntries patchEntries(ioObj);
|
||||||
|
|
||||||
// Read patches and determine sizes
|
// Read patches, determine sizes and patch groups
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
wordList names(patchEntries.size());
|
wordList names(patchEntries.size());
|
||||||
labelList sizes(patchEntries.size());
|
labelList sizes(patchEntries.size());
|
||||||
|
HashTable<labelHashSet> groups(2*patchEntries.size());
|
||||||
forAll(patchEntries, patchi)
|
|
||||||
{
|
|
||||||
const dictionary& patchDict = patchEntries[patchi].dict();
|
|
||||||
|
|
||||||
sizes[patchi] = readLabel(patchDict.lookup("nFaces"));
|
|
||||||
names[patchi] = patchEntries[patchi].keyword();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Add (non-zero) patch groups to the list of mesh parts
|
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
HashTable<labelHashSet> groups(patchEntries.size());
|
|
||||||
|
|
||||||
forAll(patchEntries, patchi)
|
forAll(patchEntries, patchi)
|
||||||
{
|
{
|
||||||
const dictionary& patchDict = patchEntries[patchi].dict();
|
const dictionary& patchDict = patchEntries[patchi].dict();
|
||||||
wordList groupNames;
|
wordList groupNames;
|
||||||
|
|
||||||
|
sizes[patchi] = readLabel(patchDict.lookup("nFaces"));
|
||||||
|
names[patchi] = patchEntries[patchi].keyword();
|
||||||
|
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
sizes[patchi] // Valid patch if nFace > 0
|
sizes[patchi] // Valid patch if nFace > 0
|
||||||
@ -351,26 +346,31 @@ void Foam::vtkPVFoam::updateInfoPatches
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Add (non-zero) patch groups to the list of mesh parts
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
DynamicList<string> displayNames(groups.size());
|
||||||
|
|
||||||
forAllConstIters(groups, iter)
|
forAllConstIters(groups, iter)
|
||||||
{
|
{
|
||||||
const auto& groupName = iter.key();
|
const auto& groupName = iter.key();
|
||||||
const auto& patchIDs = iter.object();
|
const auto& patchIDs = iter.object();
|
||||||
|
|
||||||
const string dpyName = "group/" + groupName;
|
const string dpyName = "group/" + groupName;
|
||||||
arraySelection->AddArray(dpyName.c_str());
|
displayNames.append(dpyName);
|
||||||
++rangePatches_;
|
|
||||||
|
|
||||||
// Optionally replace with patch name selection
|
// Optionally replace group with patch name selections
|
||||||
|
// - must remove the group from the select itself, otherwise
|
||||||
|
// it can toggle on, but not toggle off very well
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
enabledEntriesSet.found(dpyName)
|
!reader_->GetShowGroupsOnly()
|
||||||
&& !reader_->GetShowGroupsOnly()
|
&& enabledEntries.erase(dpyName)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
enabledEntriesSet.erase(dpyName);
|
|
||||||
for (auto patchId : patchIDs)
|
for (auto patchId : patchIDs)
|
||||||
{
|
{
|
||||||
enabledEntriesSet.insert
|
enabledEntries.insert
|
||||||
(
|
(
|
||||||
"patch/" + names[patchId]
|
"patch/" + names[patchId]
|
||||||
);
|
);
|
||||||
@ -378,6 +378,13 @@ void Foam::vtkPVFoam::updateInfoPatches
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sort group names
|
||||||
|
Foam::sort(displayNames);
|
||||||
|
for (const auto& name : displayNames)
|
||||||
|
{
|
||||||
|
select->AddArray(name.c_str());
|
||||||
|
++rangePatches_;
|
||||||
|
}
|
||||||
|
|
||||||
// Add (non-zero) patches to the list of mesh parts
|
// Add (non-zero) patches to the list of mesh parts
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
@ -389,7 +396,7 @@ void Foam::vtkPVFoam::updateInfoPatches
|
|||||||
// Valid patch if nFace > 0 - add patch to GUI list
|
// Valid patch if nFace > 0 - add patch to GUI list
|
||||||
if (sizes[patchi])
|
if (sizes[patchi])
|
||||||
{
|
{
|
||||||
arraySelection->AddArray
|
select->AddArray
|
||||||
(
|
(
|
||||||
("patch/" + names[patchi]).c_str()
|
("patch/" + names[patchi]).c_str()
|
||||||
);
|
);
|
||||||
@ -400,9 +407,6 @@ void Foam::vtkPVFoam::updateInfoPatches
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update enabled entries in case of group selection
|
|
||||||
enabledEntries = enabledEntriesSet.toc();
|
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Info<< "<end> updateInfoPatches" << endl;
|
Info<< "<end> updateInfoPatches" << endl;
|
||||||
@ -412,7 +416,7 @@ void Foam::vtkPVFoam::updateInfoPatches
|
|||||||
|
|
||||||
void Foam::vtkPVFoam::updateInfoZones
|
void Foam::vtkPVFoam::updateInfoZones
|
||||||
(
|
(
|
||||||
vtkDataArraySelection* arraySelection
|
vtkDataArraySelection* select
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (!reader_->GetIncludeZones())
|
if (!reader_->GetIncludeZones())
|
||||||
@ -440,10 +444,10 @@ void Foam::vtkPVFoam::updateInfoZones
|
|||||||
namesLst = getZoneNames("cellZones");
|
namesLst = getZoneNames("cellZones");
|
||||||
}
|
}
|
||||||
|
|
||||||
rangeCellZones_.reset(arraySelection->GetNumberOfArrays());
|
rangeCellZones_.reset(select->GetNumberOfArrays());
|
||||||
forAll(namesLst, elemI)
|
forAll(namesLst, elemI)
|
||||||
{
|
{
|
||||||
arraySelection->AddArray
|
select->AddArray
|
||||||
(
|
(
|
||||||
("cellZone/" + namesLst[elemI]).c_str()
|
("cellZone/" + namesLst[elemI]).c_str()
|
||||||
);
|
);
|
||||||
@ -463,10 +467,10 @@ void Foam::vtkPVFoam::updateInfoZones
|
|||||||
namesLst = getZoneNames("faceZones");
|
namesLst = getZoneNames("faceZones");
|
||||||
}
|
}
|
||||||
|
|
||||||
rangeFaceZones_.reset(arraySelection->GetNumberOfArrays());
|
rangeFaceZones_.reset(select->GetNumberOfArrays());
|
||||||
forAll(namesLst, elemI)
|
forAll(namesLst, elemI)
|
||||||
{
|
{
|
||||||
arraySelection->AddArray
|
select->AddArray
|
||||||
(
|
(
|
||||||
("faceZone/" + namesLst[elemI]).c_str()
|
("faceZone/" + namesLst[elemI]).c_str()
|
||||||
);
|
);
|
||||||
@ -486,10 +490,10 @@ void Foam::vtkPVFoam::updateInfoZones
|
|||||||
namesLst = getZoneNames("pointZones");
|
namesLst = getZoneNames("pointZones");
|
||||||
}
|
}
|
||||||
|
|
||||||
rangePointZones_.reset(arraySelection->GetNumberOfArrays());
|
rangePointZones_.reset(select->GetNumberOfArrays());
|
||||||
forAll(namesLst, elemI)
|
forAll(namesLst, elemI)
|
||||||
{
|
{
|
||||||
arraySelection->AddArray
|
select->AddArray
|
||||||
(
|
(
|
||||||
("pointZone/" + namesLst[elemI]).c_str()
|
("pointZone/" + namesLst[elemI]).c_str()
|
||||||
);
|
);
|
||||||
@ -505,7 +509,7 @@ void Foam::vtkPVFoam::updateInfoZones
|
|||||||
|
|
||||||
void Foam::vtkPVFoam::updateInfoSets
|
void Foam::vtkPVFoam::updateInfoSets
|
||||||
(
|
(
|
||||||
vtkDataArraySelection* arraySelection
|
vtkDataArraySelection* select
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (!reader_->GetIncludeSets())
|
if (!reader_->GetIncludeSets())
|
||||||
@ -545,26 +549,26 @@ void Foam::vtkPVFoam::updateInfoSets
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
rangeCellSets_.reset(arraySelection->GetNumberOfArrays());
|
rangeCellSets_.reset(select->GetNumberOfArrays());
|
||||||
rangeCellSets_ += addToSelection<cellSet>
|
rangeCellSets_ += addToSelection<cellSet>
|
||||||
(
|
(
|
||||||
arraySelection,
|
select,
|
||||||
objects,
|
objects,
|
||||||
"cellSet/"
|
"cellSet/"
|
||||||
);
|
);
|
||||||
|
|
||||||
rangeFaceSets_.reset(arraySelection->GetNumberOfArrays());
|
rangeFaceSets_.reset(select->GetNumberOfArrays());
|
||||||
rangeFaceSets_ += addToSelection<faceSet>
|
rangeFaceSets_ += addToSelection<faceSet>
|
||||||
(
|
(
|
||||||
arraySelection,
|
select,
|
||||||
objects,
|
objects,
|
||||||
"faceSet/"
|
"faceSet/"
|
||||||
);
|
);
|
||||||
|
|
||||||
rangePointSets_.reset(arraySelection->GetNumberOfArrays());
|
rangePointSets_.reset(select->GetNumberOfArrays());
|
||||||
rangePointSets_ += addToSelection<pointSet>
|
rangePointSets_ += addToSelection<pointSet>
|
||||||
(
|
(
|
||||||
arraySelection,
|
select,
|
||||||
objects,
|
objects,
|
||||||
"pointSet/"
|
"pointSet/"
|
||||||
);
|
);
|
||||||
@ -586,8 +590,8 @@ void Foam::vtkPVFoam::updateInfoLagrangianFields
|
|||||||
Info<< "<beg> updateInfoLagrangianFields" << endl;
|
Info<< "<beg> updateInfoLagrangianFields" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// preserve the enabled selections
|
// Preserve the enabled selections
|
||||||
stringList enabledEntries = getSelectedArrayEntries(select);
|
HashSet<string> enabledEntries = getSelectedArrayEntries(select);
|
||||||
select->RemoveAllArrays();
|
select->RemoveAllArrays();
|
||||||
|
|
||||||
// TODO - currently only get fields from ONE cloud
|
// TODO - currently only get fields from ONE cloud
|
||||||
@ -600,8 +604,9 @@ void Foam::vtkPVFoam::updateInfoLagrangianFields
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int partId = range.start();
|
// Add Lagrangian fields even if particles are not enabled?
|
||||||
word cloudName = getPartName(partId);
|
const int partId = range.start();
|
||||||
|
const word cloudName = getReaderPartName(partId);
|
||||||
|
|
||||||
// use the db directly since this might be called without a mesh,
|
// use the db directly since this might be called without a mesh,
|
||||||
// but the region must get added back in
|
// but the region must get added back in
|
||||||
@ -625,7 +630,7 @@ void Foam::vtkPVFoam::updateInfoLagrangianFields
|
|||||||
addToSelection<IOField<symmTensor>>(select, objects);
|
addToSelection<IOField<symmTensor>>(select, objects);
|
||||||
addToSelection<IOField<tensor>>(select, objects);
|
addToSelection<IOField<tensor>>(select, objects);
|
||||||
|
|
||||||
// restore the enabled selections
|
// Restore the enabled selections
|
||||||
setSelectedArrayEntries(select, enabledEntries);
|
setSelectedArrayEntries(select, enabledEntries);
|
||||||
|
|
||||||
if (debug > 1)
|
if (debug > 1)
|
||||||
|
|||||||
@ -45,7 +45,7 @@ void Foam::vtkPVFoam::updateInfoFields
|
|||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
stringList enabledEntries;
|
HashSet<string> enabledEntries;
|
||||||
if (!select->GetNumberOfArrays() && !meshPtr_)
|
if (!select->GetNumberOfArrays() && !meshPtr_)
|
||||||
{
|
{
|
||||||
// enable 'p' and 'U' only on the first call
|
// enable 'p' and 'U' only on the first call
|
||||||
@ -126,7 +126,7 @@ void Foam::vtkPVFoam::updateInfoFields
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// restore the enabled selections
|
// Restore the enabled selections
|
||||||
setSelectedArrayEntries(select, enabledEntries);
|
setSelectedArrayEntries(select, enabledEntries);
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
|
|||||||
@ -303,10 +303,11 @@ void Foam::vtkPVblockMesh::updateInfo()
|
|||||||
vtkDataArraySelection* blockSelection = reader_->GetBlockSelection();
|
vtkDataArraySelection* blockSelection = reader_->GetBlockSelection();
|
||||||
vtkDataArraySelection* edgeSelection = reader_->GetCurvedEdgesSelection();
|
vtkDataArraySelection* edgeSelection = reader_->GetCurvedEdgesSelection();
|
||||||
|
|
||||||
// preserve the enabled selections if possible
|
|
||||||
stringList enabledParts;
|
|
||||||
stringList enabledEdges;
|
|
||||||
const bool firstTime = (!blockSelection->GetNumberOfArrays() && !meshPtr_);
|
const bool firstTime = (!blockSelection->GetNumberOfArrays() && !meshPtr_);
|
||||||
|
|
||||||
|
// Preserve the enabled selections if possible
|
||||||
|
HashSet<string> enabledParts;
|
||||||
|
HashSet<string> enabledEdges;
|
||||||
if (!firstTime)
|
if (!firstTime)
|
||||||
{
|
{
|
||||||
enabledParts = getSelectedArrayEntries(blockSelection);
|
enabledParts = getSelectedArrayEntries(blockSelection);
|
||||||
@ -326,7 +327,7 @@ void Foam::vtkPVblockMesh::updateInfo()
|
|||||||
// Update curved edges list
|
// Update curved edges list
|
||||||
updateInfoEdges(edgeSelection);
|
updateInfoEdges(edgeSelection);
|
||||||
|
|
||||||
// restore the enabled selections
|
// Restore the enabled selections
|
||||||
if (!firstTime)
|
if (!firstTime)
|
||||||
{
|
{
|
||||||
setSelectedArrayEntries(blockSelection, enabledParts);
|
setSelectedArrayEntries(blockSelection, enabledParts);
|
||||||
|
|||||||
@ -194,22 +194,22 @@ Foam::hashedWordList Foam::foamPvCore::getSelected
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::stringList Foam::foamPvCore::getSelectedArrayEntries
|
Foam::HashSet<Foam::string>
|
||||||
|
Foam::foamPvCore::getSelectedArrayEntries
|
||||||
(
|
(
|
||||||
vtkDataArraySelection* select
|
vtkDataArraySelection* select
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
stringList selections(select->GetNumberOfArrays());
|
const int n = select->GetNumberOfArrays();
|
||||||
label nElem = 0;
|
HashSet<string> selections(2*n);
|
||||||
|
|
||||||
forAll(selections, elemI)
|
for (int i=0; i < n; ++i)
|
||||||
{
|
{
|
||||||
if (select->GetArraySetting(elemI))
|
if (select->GetArraySetting(i))
|
||||||
{
|
{
|
||||||
selections[nElem++] = select->GetArrayName(elemI);
|
selections.insert(select->GetArrayName(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
selections.setSize(nElem);
|
|
||||||
|
|
||||||
if (debug > 1)
|
if (debug > 1)
|
||||||
{
|
{
|
||||||
@ -221,9 +221,9 @@ Foam::stringList Foam::foamPvCore::getSelectedArrayEntries
|
|||||||
}
|
}
|
||||||
Info<< " )\nselected(";
|
Info<< " )\nselected(";
|
||||||
|
|
||||||
forAll(selections, elemI)
|
for (auto k : selections)
|
||||||
{
|
{
|
||||||
Info<< " " << selections[elemI];
|
Info<< " " << k;
|
||||||
}
|
}
|
||||||
Info<< " )\n";
|
Info<< " )\n";
|
||||||
}
|
}
|
||||||
@ -232,65 +232,61 @@ Foam::stringList Foam::foamPvCore::getSelectedArrayEntries
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::stringList Foam::foamPvCore::getSelectedArrayEntries
|
Foam::HashSet<Foam::string>
|
||||||
|
Foam::foamPvCore::getSelectedArrayEntries
|
||||||
(
|
(
|
||||||
vtkDataArraySelection* select,
|
vtkDataArraySelection* select,
|
||||||
const arrayRange& selector
|
const arrayRange& slice
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
stringList selections(selector.size());
|
const int n = select->GetNumberOfArrays();
|
||||||
label nElem = 0;
|
HashSet<string> enabled(2*n);
|
||||||
|
|
||||||
for (auto i : selector)
|
for (auto i : slice)
|
||||||
{
|
{
|
||||||
if (select->GetArraySetting(i))
|
if (select->GetArraySetting(i))
|
||||||
{
|
{
|
||||||
selections[nElem++] = select->GetArrayName(i);
|
enabled.insert(select->GetArrayName(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
selections.setSize(nElem);
|
|
||||||
|
|
||||||
if (debug > 1)
|
if (debug > 1)
|
||||||
{
|
{
|
||||||
Info<< "available(";
|
Info<< "available(";
|
||||||
for (auto i : selector)
|
for (auto i : slice)
|
||||||
{
|
{
|
||||||
Info<< " \"" << select->GetArrayName(i) << "\"";
|
Info<< " \"" << select->GetArrayName(i) << "\"";
|
||||||
}
|
}
|
||||||
Info<< " )\nselected(";
|
Info<< " )\nselected(";
|
||||||
|
|
||||||
forAll(selections, elemI)
|
for (auto k : enabled)
|
||||||
{
|
{
|
||||||
Info<< " " << selections[elemI];
|
Info<< " " << k;
|
||||||
}
|
}
|
||||||
Info<< " )\n";
|
Info<< " )\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
return selections;
|
return enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::foamPvCore::setSelectedArrayEntries
|
void Foam::foamPvCore::setSelectedArrayEntries
|
||||||
(
|
(
|
||||||
vtkDataArraySelection* select,
|
vtkDataArraySelection* select,
|
||||||
const stringList& selections
|
const HashSet<string>& enabled
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const int n = select->GetNumberOfArrays();
|
const int n = select->GetNumberOfArrays();
|
||||||
|
// disable everything not explicitly enabled
|
||||||
select->DisableAllArrays();
|
select->DisableAllArrays();
|
||||||
|
|
||||||
// Loop through entries, setting values from selectedEntries
|
// Loop through entries, enabling as required
|
||||||
for (int i=0; i < n; ++i)
|
for (int i=0; i < n; ++i)
|
||||||
{
|
{
|
||||||
const string arrayName(select->GetArrayName(i));
|
const char* arrayName = select->GetArrayName(i);
|
||||||
|
if (enabled.found(arrayName))
|
||||||
forAll(selections, elemI)
|
|
||||||
{
|
{
|
||||||
if (selections[elemI] == arrayName)
|
select->EnableArray(arrayName);
|
||||||
{
|
|
||||||
select->EnableArray(arrayName.c_str());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,6 +39,7 @@ SourceFiles
|
|||||||
#include "pointList.H"
|
#include "pointList.H"
|
||||||
#include "wordList.H"
|
#include "wordList.H"
|
||||||
#include "Hash.H"
|
#include "Hash.H"
|
||||||
|
#include "HashSet.H"
|
||||||
#include "hashedWordList.H"
|
#include "hashedWordList.H"
|
||||||
#include "labelRange.H"
|
#include "labelRange.H"
|
||||||
|
|
||||||
@ -208,25 +209,25 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
//- Retrieve the current selections
|
//- Retrieve the currently enabled selections
|
||||||
static stringList getSelectedArrayEntries
|
static HashSet<string> getSelectedArrayEntries
|
||||||
(
|
(
|
||||||
vtkDataArraySelection* select
|
vtkDataArraySelection* select
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Retrieve a sub-list of the current selections
|
//- Retrieve a sub-list of the currently enabled selections
|
||||||
static stringList getSelectedArrayEntries
|
static HashSet<string> getSelectedArrayEntries
|
||||||
(
|
(
|
||||||
vtkDataArraySelection* select,
|
vtkDataArraySelection* select,
|
||||||
const arrayRange& selector
|
const arrayRange& slice
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
//- Set selection(s)
|
//- Enable the selection(s)
|
||||||
static void setSelectedArrayEntries
|
static void setSelectedArrayEntries
|
||||||
(
|
(
|
||||||
vtkDataArraySelection* select,
|
vtkDataArraySelection* select,
|
||||||
const stringList& selections
|
const HashSet<string>& enabled
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user