11 #include VTK_IOSS(Ionit_Initializer.h)
12 #include VTK_IOSS(Ioss_Assembly.h)
13 #include VTK_IOSS(Ioss_DatabaseIO.h)
14 #include VTK_IOSS(Ioss_EdgeBlock.h)
15 #include VTK_IOSS(Ioss_EdgeSet.h)
16 #include VTK_IOSS(Ioss_ElementBlock.h)
17 #include VTK_IOSS(Ioss_ElementSet.h)
18 #include VTK_IOSS(Ioss_ElementTopology.h)
19 #include VTK_IOSS(Ioss_FaceBlock.h)
20 #include VTK_IOSS(Ioss_FaceSet.h)
21 #include VTK_IOSS(Ioss_IOFactory.h)
22 #include VTK_IOSS(Ioss_NodeBlock.h)
23 #include VTK_IOSS(Ioss_NodeSet.h)
24 #include VTK_IOSS(Ioss_Region.h)
25 #include VTK_IOSS(Ioss_SideBlock.h)
26 #include VTK_IOSS(Ioss_SideSet.h)
27 #include VTK_IOSS(Ioss_StructuredBlock.h)
37 VTK_ABI_NAMESPACE_BEGIN
78 Ioss::Init::Initializer
io;
87 std::map<std::string, std::vector<std::pair<int, double>>>
DatabaseTimes;
99 std::map<DatabaseHandle, std::shared_ptr<Ioss::Region>>
RegionMap;
177 vtkIOSSReader*
self,
const std::vector<DatabaseHandle>& dbaseHandles);
240 std::vector<DatabaseHandle>
GetDatabaseHandles(
int piece,
int npieces,
int timestep)
const;
247 auto iter = this->DatabaseNames.find(handle.first);
248 if (iter == this->DatabaseNames.end())
250 throw std::runtime_error(
"bad database handle!");
253 const int& fileid = handle.second;
254 auto dbasename = shortname ? vtksys::SystemTools::GetFilenameName(handle.first) : handle.first;
256 auto& dinfo = iter->second;
257 if (dinfo.ProcessCount > 0)
259 return Ioss::Utils::decode_filename(
260 dbasename, dinfo.ProcessCount, *
std::next(dinfo.Ranks.begin(), fileid));
271 auto iter = this->DatabaseNames.find(handle.first);
272 if (iter == this->DatabaseNames.end())
274 throw std::runtime_error(
"bad database handle!");
276 const int& fileid = handle.second;
277 auto& dinfo = iter->second;
278 if (dinfo.ProcessCount > 0)
280 return *
std::next(dinfo.Ranks.begin(), fileid);
292 if (this->RegionMap.empty())
296 const bool allHandlesAreNew =
297 std::all_of(dbaseHandles.begin(), dbaseHandles.end(), [&](
const DatabaseHandle& handle)
298 {
return this->RegionMap.find(handle) == this->RegionMap.end(); });
299 return !allHandlesAreNew;
309 for (
const auto& pair : this->RegionMap)
311 pair.second->get_database()->closeDatabase();
328 this->RegionMap.clear();
329 this->DatabaseNames.clear();
341 const std::string& dbasename,
int fileid, Ioss::DatabaseUsage dbUsage = Ioss::READ_RESTART);
344 return this->
GetRegion(handle.first, handle.second);
360 const Ioss::GroupingEntity* group_entity,
const DatabaseHandle& handle,
int timestep,
375 std::vector<std::pair<int, vtkSmartPointer<vtkCellArray>>>
GetTopology(
461 bool remove_unused_points);
517 Ioss::GroupingEntity* group_entity,
const DatabaseHandle& handle,
int timestep,
529 Ioss::Region* region, Ioss::GroupingEntity* group_entity,
const DatabaseHandle& handle,
530 int timestep,
bool read_ioss_ids,
bool mergeExodusEntityBlocks =
false);
537 Ioss::GroupingEntity* group_entity,
const DatabaseHandle& handle,
int timestep,
538 bool mergeExodusEntityBlocks =
false);
544 Ioss::GroupingEntity* group_entity,
const DatabaseHandle& handle);
554 return this->DatasetIndexMap.at(std::make_pair(entity->type(), entity->name()));
587 VTK_ABI_NAMESPACE_END
Ioss::Init::Initializer io
vtkDataAssembly * GetAssembly() const
bool UpdateTimeInformation(vtkIOSSReader *self)
Read Ioss databases to generate information about timesteps / times in the databases.
vtkTimeStamp SelectionsMTime
bool GetMesh(vtkUnstructuredGrid *grid, const std::string &blockname, vtkIOSSReader::EntityType vtk_entity_type, const DatabaseHandle &handle, bool remove_unused_points)
Adds geometry (points) and topology (cell) information to the grid for the entity block or set chosen...
Ioss::Region * GetRegion(const std::string &dbasename, int fileid, Ioss::DatabaseUsage dbUsage=Ioss::READ_RESTART)
vtkSmartPointer< vtkAbstractArray > ConvertFieldForVTK(vtkAbstractArray *array)
Fields like "ids" have to be vtkIdTypeArray in VTK.
represent and manipulate point attribute data
std::array< std::set< vtkIOSSUtilities::EntityNameType >, vtkIOSSReader::NUMBER_OF_ENTITY_TYPES > EntityNames
void Reset()
Clear all regions, databases etc.
abstract class to specify dataset behavior
std::vector< vtkSmartPointer< vtkDataSet > > GetDataSets(const std::string &blockname, vtkIOSSReader::EntityType vtk_entity_type, const DatabaseHandle &handle, int timestep, vtkIOSSReader *self)
Reads datasets (meshes and fields) for the given block.
Abstract superclass for all arrays.
bool GenerateFileId(vtkDataSetAttributes *cellData, vtkIdType numberOfCells, Ioss::GroupingEntity *group_entity, const DatabaseHandle &handle)
Adds 'file_id' array to indicate which file the dataset was read from.
bool GetQAAndInformationRecords(vtkFieldData *fd, const DatabaseHandle &handle)
Read quality assurance and information data from the file.
bool ReadAssemblies(vtkPartitionedDataSetCollection *output, const DatabaseHandle &handle)
Fills up the vtkDataAssembly with ioss-assemblies, if present.
std::map< std::pair< Ioss::EntityType, std::string >, unsigned int > DatasetIndexMap
bool HaveCreatedRegions(const std::vector< DatabaseHandle > &dbaseHandles)
Returns if the given database handles have regions already created.
record modification and/or execution time
represent and manipulate cell attribute data
bool GetEntityMesh(vtkUnstructuredGrid *grid, const std::vector< std::string > &blockNames, vtkIOSSReader::EntityType vtk_entity_type, const DatabaseHandle &handle)
Adds geometry (points) and topology (cell) information to the grid for all the entity blocks or sets ...
std::string GetRawFileName(const DatabaseHandle &handle, bool shortname=false) const
Useful for printing error messages etc.
void ResetCacheAccessCounts()
Cache related API.
Ioss::GroupingEntity * GetNodeBlock(const Ioss::Region *region, const std::string &blockname)
Get IOSS NodeBlock blockname if it exists, otherwise get first Nodeblock in region.
void ReleaseHandles()
Releases any open file handles.
Internal methods and state for the IOSS reader.
const std::vector< double > & GetTimeSteps() const
bool GenerateOutput(vtkPartitionedDataSetCollection *output, vtkIOSSReader *self)
Fills up the output data-structure based on the entity blocks/sets chosen and those available...
std::map< std::string, std::vector< std::pair< int, double > > > DatabaseTimes
concrete class for storing a set of points
dynamic, self-adjusting array of vtkIdType
virtual ~vtkIOSSReaderInternal()=default
std::vector< DatabaseHandle > GetDatabaseHandles(int piece, int npieces, int timestep) const
Returns the list of fileids, if any to be read for a given "piece" for the chosen timestep...
bool GenerateEntityIdArray(vtkCellData *cd, vtkIdType numberOfCells, const std::string &blockname, vtkIOSSReader::EntityType vtk_entity_type, const DatabaseHandle &handle)
Add "id" array to the dataset using the id for the grouping entity, if any.
bool UpdateEntityAndFieldSelections(vtkIOSSReader *self)
Populates various vtkDataArraySelection objects on the vtkIOSSReader with names for entity-blocks...
std::map< std::string, DatabasePartitionInfo > DatabaseNamesType
bool HaveRestartFiles() const
Get if there are restart files available.
void GenerateElementAndSideIds(vtkDataSet *dataset, Ioss::SideSet *sideSet, const DatabaseHandle &handle, const std::string &blockname, vtkIOSSReader::EntityType vtk_entity_type)
Add field-data arrays holding side-set specifications (i.e., (cell-id, side-id) tuples) for use by th...
vtkSmartPointer< vtkAbstractArray > GetField(const std::string &fieldname, Ioss::Region *region, const Ioss::GroupingEntity *group_entity, const DatabaseHandle &handle, int timestep, vtkIdTypeArray *ids_to_extract=nullptr, const std::string &cache_key_suffix=std::string())
Reads a field with name fieldname from entity block or set with chosen name (blockname) and type (vtk...
std::pair< std::string, int > DatabaseHandle
DatabaseNamesType GenerateSubset(const DatabaseNamesType &databases, vtkIOSSReader *self)
Generate a subset based the readers current settings for FileRange and FileStride.
std::vector< vtkSmartPointer< vtkDataSet > > GetExodusDataSets(const std::string &blockname, vtkIOSSReader::EntityType vtk_entity_type, const DatabaseHandle &handle, int timestep, vtkIOSSReader *self)
Called by GetDataSets to process each type of dataset.
Ioss::PropertyManager DatabaseProperties
vtkTimeStamp AssemblyMTime
std::vector< int > GetFileIds(const std::string &dbasename, int myrank, int numRanks) const
std::map< DatabaseHandle, std::shared_ptr< Ioss::Region > > RegionMap
void SetDisplacementMagnitude(double s)
bool GetNodeFields(vtkDataSetAttributes *dsa, vtkDataArraySelection *selection, Ioss::Region *region, Ioss::GroupingEntity *group_entity, const DatabaseHandle &handle, int timestep, bool read_ioss_ids, bool mergeExodusEntityBlocks=false)
This reads node fields for an entity block or set.
vtkTimeStamp TimestepValuesMTime
vtkIOSSUtilities::DatabaseFormatType Format
std::vector< std::pair< int, vtkSmartPointer< vtkCellArray > > > GetTopology(const std::string &blockname, vtkIOSSReader::EntityType vtk_entity_type, const DatabaseHandle &handle)
Get a vector of cell arrays and their cell type for the entity block (or set) with the given name (bl...
double GetDisplacementMagnitude()
DatabaseNamesType UnfilteredDatabaseNames
Store on/off settings for data arrays, etc.
bool operator==(const DatabasePartitionInfo &other) const
dataset represents arbitrary combinations of all possible cell types
abstract superclass for arrays of numeric data
vtkSmartPointer< vtkDataSet > GetExodusEntityDataSet(const std::vector< std::string > &blockNames, vtkIOSSReader::EntityType vtk_entity_type, const DatabaseHandle &handle, int timestep, vtkIOSSReader *self)
Reads datasets (meshes and fields) for the given exodus entity.
vtkIOSSUtilities::Cache Cache
vtkIOSSReaderInternal(vtkIOSSReader *reader)
bool UpdateDatabaseNames(vtkIOSSReader *self)
Processes filenames to populate names for Ioss databases to read.
vtkSmartPointer< vtkPoints > GetGeometry(const std::string &blockname, const DatabaseHandle &handle)
Get with point coordinates aka geometry read from the block with the given name (blockname).
vtkIOSSReader * IOSSReader
bool UpdateAssembly(vtkIOSSReader *self, int *tag)
Populates the vtkDataAssembly used for block/set selection.
DatabaseNamesType DatabaseNames
represent and manipulate attribute data in a dataset
void Clear()
Clears the cache.
int GetFileProcessor(const DatabaseHandle &handle) const
For spatially partitioned files, this returns the partition identifier for the file identified by the...
void ClearCacheUnused()
Cache related API.
std::set< std::string > FileNames
Ioss::Region * GetRegion(const DatabaseHandle &handle)
std::vector< double > TimestepValues
unsigned int GetDataSetIndexForEntity(const Ioss::GroupingEntity *entity) const
void ReleaseRegions()
Little more aggressive than ReleaseHandles but less intense than Reset, releases all IOSS regions and...
Reader for IOSS (Sierra IO System)
topologically regular array of data
vtkTimeStamp DatabaseNamesMTime
hierarchical representation to use with vtkPartitionedDataSetCollection
bool ApplyDisplacements(vtkPointSet *grid, Ioss::Region *region, Ioss::GroupingEntity *group_entity, const DatabaseHandle &handle, int timestep, bool mergeExodusEntityBlocks=false)
Reads node block array with displacements and then transforms the points in the grid using those disp...
void ResetAccessCounts()
Call this to clear internal count for hits.
vtkTimeStamp FileNamesMTime
std::pair< vtkSmartPointer< vtkDataArray >, vtkSmartPointer< vtkCellArray > > CombineTopologies(const std::vector< std::pair< int, vtkSmartPointer< vtkCellArray >>> &topologies)
Combine a vector cell types, cell arrays pairs into a single vtkDataArray of cell types and a vtkCell...
std::set< std::string > Selectors
vtkIOSSUtilities::DatabaseFormatType GetFormat() const
void ClearCache()
Cache related API.
double DisplacementMagnitude
vtkSmartPointer< vtkDataAssembly > Assembly
void ResetDatabaseNamesMTime()
bool BuildAssembly(Ioss::Region *region, vtkDataAssembly *assembly, int root, bool add_leaves)
bool GetFields(vtkDataSetAttributes *dsa, vtkDataArraySelection *selection, Ioss::Region *region, Ioss::GroupingEntity *group_entity, const DatabaseHandle &handle, int timestep, bool read_ioss_ids, vtkIdTypeArray *ids_to_extract=nullptr, const std::string &cache_key_suffix=std::string(), vtkFieldData *field_data=nullptr)
Reads selected field arrays for the given entity block or set.
void ClearUnused()
Removes all cached entries not accessed since most recent call to ResetAccessCounts.
bool GetGlobalFields(vtkDataArraySelection *globalFieldSelection, vtkFieldData *fd, const DatabaseHandle &handle, int timestep)
Read global fields.
Represents and manipulates a collection of data arrays.
std::vector< vtkSmartPointer< vtkDataSet > > GetCGNSDataSets(const std::string &blockname, vtkIOSSReader::EntityType vtk_entity_type, const DatabaseHandle &handle, int timestep, vtkIOSSReader *self)
Called by GetDataSets to process each type of dataset.
bool NeedToUpdateEntityAndFieldSelections(vtkIOSSReader *self, const std::vector< DatabaseHandle > &dbaseHandles)
Checks if the entity and field selections have changed.
void RemoveAllSelections()
Composite dataset that groups datasets as a collection.