vtkPVFoam: Updated handling of zones

This commit is contained in:
Henry Weller
2024-04-05 11:47:49 +01:00
parent ef3021c55a
commit ed59ea40bf
2 changed files with 21 additions and 24 deletions

View File

@ -360,14 +360,12 @@ class vtkPVFoam
void updateInfoZones(vtkDataArraySelection*); void updateInfoZones(vtkDataArraySelection*);
//- Get non-empty zone names for zoneType from file //- Get non-empty zone names for zoneType from file
wordList getZoneNames(const word& zoneType) const; template<class ZonesType>
wordList getZoneNames(const word& zonesName) const;
//- Get non-empty zone names from mesh info //- Get non-empty zone names from mesh info
template<class ZoneType, class ZonesType> template<class ZonesType>
wordList getZoneNames wordList getZoneNames(const ZonesType&) const;
(
const ZoneList<ZoneType, ZonesType, polyMesh>&
) const;
//- Add objects of Type to paraview array selection //- Add objects of Type to paraview array selection
template<class Type> template<class Type>

View File

@ -50,6 +50,7 @@ namespace Foam
{ {
//- A class for reading zone information without requiring a mesh //- A class for reading zone information without requiring a mesh
template<class ZonesType>
class zonesEntries class zonesEntries
: :
public regIOobject, public regIOobject,
@ -63,7 +64,7 @@ public:
explicit zonesEntries(const IOobject& io) explicit zonesEntries(const IOobject& io)
: :
regIOobject(io), regIOobject(io),
PtrList<entry>(readStream(word("regIOobject"))) PtrList<entry>(readStream(ZonesType::typeName))
{ {
close(); close();
} }
@ -81,20 +82,17 @@ public:
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class ZoneType, class ZonesType> template<class ZonesType>
Foam::wordList Foam::vtkPVFoam::getZoneNames Foam::wordList Foam::vtkPVFoam::getZoneNames(const ZonesType& zones) const
(
const ZoneList<ZoneType, ZonesType, polyMesh>& zmesh
) const
{ {
wordList names(zmesh.size()); wordList names(zones.size());
label nZone = 0; label nZone = 0;
forAll(zmesh, zoneI) forAll(zones, zoneI)
{ {
if (zmesh[zoneI].size()) if (zones[zoneI].size())
{ {
names[nZone++] = zmesh[zoneI].name(); names[nZone++] = zones[zoneI].name();
} }
} }
names.setSize(nZone); names.setSize(nZone);
@ -103,18 +101,19 @@ Foam::wordList Foam::vtkPVFoam::getZoneNames
} }
Foam::wordList Foam::vtkPVFoam::getZoneNames(const word& zoneType) const template<class ZonesType>
Foam::wordList Foam::vtkPVFoam::getZoneNames(const word& zonesName) const
{ {
wordList names; wordList names;
// Mesh not loaded - read from file // Mesh not loaded - read from file
IOobject ioObj typeIOobject<ZonesType> ioObj
( (
zoneType, zonesName,
dbPtr_().findInstance dbPtr_().findInstance
( (
meshDir_, meshDir_,
zoneType, zonesName,
IOobject::READ_IF_PRESENT IOobject::READ_IF_PRESENT
), ),
meshDir_, meshDir_,
@ -126,7 +125,7 @@ Foam::wordList Foam::vtkPVFoam::getZoneNames(const word& zoneType) const
if (ioObj.headerOk()) if (ioObj.headerOk())
{ {
zonesEntries zones(ioObj); const zonesEntries<ZonesType> zones(ioObj);
names.setSize(zones.size()); names.setSize(zones.size());
forAll(zones, zoneI) forAll(zones, zoneI)
@ -523,7 +522,7 @@ void Foam::vtkPVFoam::updateInfoZones
} }
else else
{ {
namesLst = getZoneNames("cellZones"); namesLst = getZoneNames<cellZoneList>("cellZones");
} }
arrayRangeCellZones_.reset(arraySelection->GetNumberOfArrays()); arrayRangeCellZones_.reset(arraySelection->GetNumberOfArrays());
@ -544,7 +543,7 @@ void Foam::vtkPVFoam::updateInfoZones
} }
else else
{ {
namesLst = getZoneNames("faceZones"); namesLst = getZoneNames<faceZoneList>("faceZones");
} }
arrayRangeFaceZones_.reset(arraySelection->GetNumberOfArrays()); arrayRangeFaceZones_.reset(arraySelection->GetNumberOfArrays());
@ -565,7 +564,7 @@ void Foam::vtkPVFoam::updateInfoZones
} }
else else
{ {
namesLst = getZoneNames("pointZones"); namesLst = getZoneNames<pointZoneList>("pointZones");
} }
arrayRangePointZones_.reset(arraySelection->GetNumberOfArrays()); arrayRangePointZones_.reset(arraySelection->GetNumberOfArrays());