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)
37VTK_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);
206 std::vector<vtkSmartPointer<vtkDataSet>>
GetDataSets(
const std::string& blockname,
246 auto iter = this->DatabaseNames.find(handle.first);
247 if (iter == this->DatabaseNames.end())
249 throw std::runtime_error(
"bad database handle!");
252 const int& fileid = handle.second;
253 auto dbasename = shortname ? vtksys::SystemTools::GetFilenameName(handle.first) : handle.first;
255 auto& dinfo = iter->second;
256 if (dinfo.ProcessCount > 0)
258 return Ioss::Utils::decode_filename(
259 dbasename, dinfo.ProcessCount, *std::next(dinfo.Ranks.begin(), fileid));
270 auto iter = this->DatabaseNames.find(handle.first);
271 if (iter == this->DatabaseNames.end())
273 throw std::runtime_error(
"bad database handle!");
275 const int& fileid = handle.second;
276 auto& dinfo = iter->second;
277 if (dinfo.ProcessCount > 0)
279 return *std::next(dinfo.Ranks.begin(), fileid);
291 if (this->RegionMap.empty())
295 const bool allHandlesAreNew = std::all_of(dbaseHandles.begin(), dbaseHandles.end(),
297 { return this->RegionMap.find(handle) == this->RegionMap.end(); });
298 return !allHandlesAreNew;
310 pair.second->get_database()->closeDatabase();
327 this->RegionMap.clear();
328 this->DatabaseNames.clear();
338 std::vector<int>
GetFileIds(
const std::string& dbasename,
int myrank,
int numRanks)
const;
339 Ioss::Region*
GetRegion(
const std::string& dbasename,
int fileid);
342 return this->
GetRegion(handle.first, handle.second);
358 const Ioss::GroupingEntity* group_entity,
const DatabaseHandle& handle,
int timestep,
359 vtkIdTypeArray* ids_to_extract =
nullptr,
const std::string& cache_key_suffix = std::string());
373 std::vector<std::pair<int, vtkSmartPointer<vtkCellArray>>>
GetTopology(
452 bool remove_unused_points);
503 Ioss::GroupingEntity* group_entity,
const DatabaseHandle& handle,
int timestep,
505 const std::string& cache_key_suffix = std::string());
515 Ioss::Region* region, Ioss::GroupingEntity* group_entity,
const DatabaseHandle& handle,
516 int timestep,
bool read_ioss_ids,
bool mergeExodusEntityBlocks =
false);
523 Ioss::GroupingEntity* group_entity,
const DatabaseHandle& handle,
int timestep,
524 bool mergeExodusEntityBlocks =
false);
530 Ioss::GroupingEntity* group_entity,
const DatabaseHandle& handle);
540 return this->DatasetIndexMap.at(std::make_pair(entity->type(), entity->name()));
559 std::vector<vtkSmartPointer<vtkDataSet>>
GetCGNSDataSets(
const std::string& blockname,
Abstract superclass for all arrays.
represent and manipulate cell attribute data
Store on/off settings for data arrays, etc.
hierarchical representation to use with vtkPartitionedDataSetCollection
represent and manipulate attribute data in a dataset
abstract class to specify dataset behavior
represent and manipulate fields of data
Internal methods and state for the IOSS reader.
vtkTimeStamp SelectionsMTime
void SetDisplacementMagnitude(double s)
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 ...
void ResetCacheAccessCounts()
Cache related API.
vtkIOSSUtilities::DatabaseFormatType Format
bool ReadAssemblies(vtkPartitionedDataSetCollection *output, const DatabaseHandle &handle)
Fills up the vtkDataAssembly with ioss-assemblies, if present.
void ClearCache()
Cache related API.
bool HaveCreatedRegions(const std::vector< DatabaseHandle > &dbaseHandles)
Returns if the given database handles have regions already created.
DatabaseNamesType UnfilteredDatabaseNames
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())
Reads selected field arrays for the given entity block or set.
bool HaveRestartFiles() const
Get if there are restart files available.
std::map< DatabaseHandle, std::shared_ptr< Ioss::Region > > RegionMap
DatabaseNamesType GenerateSubset(const DatabaseNamesType &databases, vtkIOSSReader *self)
Generate a subset based the readers current settings for FileRange and FileStride.
std::map< std::string, std::vector< std::pair< int, double > > > DatabaseTimes
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).
Ioss::Region * GetRegion(const DatabaseHandle &handle)
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...
bool GetGlobalFields(vtkFieldData *fd, const DatabaseHandle &handle, int timestep)
Read global fields.
std::string GetRawFileName(const DatabaseHandle &handle, bool shortname=false) const
Useful for printing error messages etc.
bool GetQAAndInformationRecords(vtkFieldData *fd, const DatabaseHandle &handle)
Read quality assurance and information data from the file.
double DisplacementMagnitude
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.
void ClearCacheUnused()
Cache related API.
Ioss::Region * GetRegion(const std::string &dbasename, int fileid)
std::set< std::string > FileNames
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...
double GetDisplacementMagnitude()
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.
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.
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...
bool GetTopology(vtkUnstructuredGrid *grid, const std::string &blockname, vtkIOSSReader::EntityType vtk_entity_type, const DatabaseHandle &handle)
Fill up the grid with connectivity information for the entity block (or set) with the given name (blo...
void ReleaseHandles()
Releases any open file handles.
bool NeedToUpdateEntityAndFieldSelections(vtkIOSSReader *self, const std::vector< DatabaseHandle > &dbaseHandles)
Checks if the entity and field selections have changed.
bool BuildAssembly(Ioss::Region *region, vtkDataAssembly *assembly, int root, bool add_leaves)
Ioss::PropertyManager DatabaseProperties
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...
bool UpdateTimeInformation(vtkIOSSReader *self)
Read Ioss databases to generate information about timesteps / times in the databases.
vtkIOSSReaderInternal(vtkIOSSReader *reader)
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.
int GetFileProcessor(const DatabaseHandle &handle) const
For spatially partitioned files, this returns the partition identifier for the file identified by the...
std::vector< double > TimestepValues
bool GetMesh(vtkStructuredGrid *grid, const std::string &blockname, vtkIOSSReader::EntityType vtk_entity_type, const DatabaseHandle &handle)
Reads a structured block.
unsigned int GetDataSetIndexForEntity(const Ioss::GroupingEntity *entity) const
std::pair< vtkSmartPointer< vtkUnsignedCharArray >, vtkSmartPointer< vtkCellArray > > CombineTopologies(const std::vector< std::pair< int, vtkSmartPointer< vtkCellArray > > > &topologies)
Combine a vector cell types, cell arrays pairs into a single vtkUnsignedCharArray of cell types and a...
virtual ~vtkIOSSReaderInternal()=default
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.
vtkTimeStamp AssemblyMTime
void Reset()
Clear all regions, databases etc.
bool UpdateAssembly(vtkIOSSReader *self, int *tag)
Populates the vtkDataAssembly used for block/set selection.
vtkIOSSUtilities::DatabaseFormatType GetFormat() const
std::vector< int > GetFileIds(const std::string &dbasename, int myrank, int numRanks) const
vtkDataAssembly * GetAssembly() const
vtkSmartPointer< vtkAbstractArray > ConvertFieldForVTK(vtkAbstractArray *array)
Fields like "ids" have to be vtkIdTypeArray in VTK.
bool GenerateOutput(vtkPartitionedDataSetCollection *output, vtkIOSSReader *self)
Fills up the output data-structure based on the entity blocks/sets chosen and those available.
void ReleaseRegions()
Little more aggressive than ReleaseHandles but less intense than Reset, releases all IOSS regions and...
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.
vtkTimeStamp FileNamesMTime
bool UpdateEntityAndFieldSelections(vtkIOSSReader *self)
Populates various vtkDataArraySelection objects on the vtkIOSSReader with names for entity-blocks,...
vtkTimeStamp DatabaseNamesMTime
vtkIOSSReader * IOSSReader
std::map< std::string, DatabasePartitionInfo > DatabaseNamesType
bool GetGeometry(vtkUnstructuredGrid *grid, const std::string &blockname, const DatabaseHandle &handle)
Fill up grid with point coordinates aka geometry read from the block with the given name (blockname).
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.
void ResetDatabaseNamesMTime()
DatabaseNamesType DatabaseNames
std::set< std::string > Selectors
bool UpdateDatabaseNames(vtkIOSSReader *self)
Processes filenames to populate names for Ioss databases to read.
const std::vector< double > & GetTimeSteps() const
vtkIOSSUtilities::Cache Cache
std::map< std::pair< Ioss::EntityType, std::string >, unsigned int > DatasetIndexMap
std::array< std::set< vtkIOSSUtilities::EntityNameType >, vtkIOSSReader::NUMBER_OF_ENTITY_TYPES > EntityNames
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...
Ioss::Init::Initializer io
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.
vtkTimeStamp TimestepValuesMTime
bool GetGeometry(vtkStructuredGrid *grid, const Ioss::StructuredBlock *groupEntity)
GetGeometry for vtkStructuredGrid i.e.
vtkSmartPointer< vtkDataAssembly > Assembly
Reader for IOSS (Sierra IO System)
void RemoveAllSelections()
void Clear()
Clears the cache.
void ClearUnused()
Removes all cached entries not accessed since most recent call to ResetAccessCounts.
void ResetAccessCounts()
Call this to clear internal count for hits.
dynamic, self-adjusting array of vtkIdType
Composite dataset that groups datasets as a collection.
represent and manipulate point attribute data
concrete class for storing a set of points
Hold a reference to a vtkObjectBase instance.
topologically regular array of data
record modification and/or execution time
dynamic, self-adjusting array of unsigned char
dataset represents arbitrary combinations of all possible cell types
bool operator==(const DatabasePartitionInfo &other) const
std::pair< std::string, int > DatabaseHandle