27#include "ioss_export.h"
53 class StructuredBlock;
59 class CoordinateFrame;
83 using AliasMap = std::map<std::string, std::string, std::less<>>;
95 explicit Region(
DatabaseIO *iodatabase =
nullptr,
const std::string &my_name =
"");
108 void output_summary(std::ostream &strm,
bool do_transient =
true)
const;
113 IOSS_NODISCARD int64_t node_global_to_local(int64_t global,
bool must_exist =
true)
const;
115 bool begin_mode(
State new_state);
116 bool end_mode(
State current_state);
122 return add_state_nl(time);
124 virtual int add_state_nl(
double time);
128 IOSS_NODISCARD virtual double get_state_time(
int state = -1)
const;
130 double begin_state(
int state);
131 double end_state(
int state);
160 IOSS_NODISCARD std::tuple<std::string, int, double> get_db_max_time()
const;
171 IOSS_NODISCARD std::tuple<std::string, int, double> get_db_min_time()
const;
186 bool add(
Blob *blob);
235 bool add_alias(
const std::string &db_name,
const std::string &alias,
EntityType type);
236 bool add_alias(
const std::string &db_name,
const std::string &alias);
249 void transfer_mesh_aliases(
Region *to)
const;
252 void synchronize_id_and_name(
const Region *from,
bool sync_attribute_field_names =
false);
261 IOSS_NODISCARD bool is_valid_io_entity(
const std::string &my_name,
unsigned int io_type,
262 std::string *my_type =
nullptr)
const;
285 void add_information_record(
const std::string &info);
288 void add_qa_record(
const std::string &code,
const std::string &code_qa,
289 const std::string &date =
"",
const std::string &time =
"");
291 template <
typename T,
typename U>
292 std::vector<size_t> get_entity_field_data(
const std::string &field_name,
293 const std::vector<T *> &entity_container,
294 std::vector<U> &field_data)
const;
296 void register_mesh_modification_observer(std::shared_ptr<DynamicTopologyObserver> observer);
299 return topologyObserver;
302 void reset_topology_modification();
303 void set_topology_modification(
unsigned int type);
306 void start_new_output_database_entry(
int steps = 0);
316 ifDatabaseExists = if_exists;
320 return ifDatabaseExists;
326 IOSS_NODISCARD bool load_internal_change_set_mesh(
const std::string &set_name);
327 IOSS_NODISCARD bool load_internal_change_set_mesh(
const int set_index);
329 IOSS_NODISCARD std::tuple<std::string, int, double> locate_db_state(
double targetTime)
const;
332 std::string get_internal_change_set_name()
const;
333 void update_dynamic_topology();
334 void clone_and_replace_output_database(
int steps = 0);
335 void add_output_database_change_set(
int steps = 0,
bool force_addition =
false);
337 int64_t internal_get_field_data(
const Field &field,
void *data,
338 size_t data_size = 0)
const override;
340 int64_t internal_put_field_data(
const Field &field,
void *data,
341 size_t data_size = 0)
const override;
343 int64_t internal_get_zc_field_data(
const Field &field,
void **data,
344 size_t *data_size)
const override;
347 template <
typename T>
348 std::vector<size_t> internal_get_entity_field_data(
const std::string &field_name,
349 const std::vector<T *> &entity_container,
350 void *data,
size_t data_size = 0)
const;
355 bool add_alias_nl(
const std::string &db_name,
const std::string &alias,
EntityType type);
358 bool begin_mode_nl(
State new_state);
359 bool end_mode_nl(
State current_state);
361 void delete_database()
override;
385 int currentState{-1};
386 mutable int stateCount{0};
387 bool modelDefined{
false};
388 bool transientDefined{
false};
392 unsigned int dbChangeCount{1};
393 unsigned int fileCyclicCount{
397 bool modelWritten{
false};
398 bool transientWritten{
false};
399 bool fileGroupsStarted{
false};
411 return static_cast<unsigned int>((get_database()->entity_field_support() & fld_type) != 0U) != 0U;
416 return get_database()->node_global_to_local(global, must_exist);
426 return get_database()->get_information_records();
436 return get_database()->add_information_records(info);
446 return get_database()->add_information_record(info);
460 const std::string &date,
const std::string &time)
463 return get_database()->add_qa_record(code, code_qa, date, time);
484 return get_database()->get_qa_records();
489 template <
typename T>
491 const std::vector<T *> &entity_container)
496 for (
const T *entity : entity_container) {
497 if (entity->field_exists(field_name)) {
500 if (found && field.
get_role() != role) {
501 std::ostringstream errmsg;
505 <<
" on entity " << entity->name() <<
" does not match previously found role "
519 template <
typename T>
521 const std::vector<T *> &entity_container)
525 for (
const T *entity : entity_container) {
526 if (entity->field_exists(field_name)) {
538template <
typename T,
typename U>
540 const std::vector<T *> &entity_container,
541 std::vector<U> &field_data)
const
546 return std::vector<size_t>(entity_container.size() + 1, 0);
551 field_data.resize(field_count);
552 size_t data_size = field_count *
sizeof(U);
554 std::vector<size_t> offsets =
555 internal_get_entity_field_data(field_name, entity_container,
Data(field_data), data_size);
557 assert(offsets.size() == (entity_container.size() + 1));
558 assert(offsets[entity_container.size()] == field_count);
566 const std::vector<T *> &entity_container,
void *data,
567 size_t data_size)
const
569 return get_database()->get_entity_field_data(field_name, entity_container, data, data_size);
#define IOSS_FUNC_ENTER(m)
Definition Ioss_CodeTypes.h:105
#define IOSS_NODISCARD
Definition Ioss_CodeTypes.h:55
IOSS_NODISCARD constexpr T * Data(std::vector< T > &vec)
Definition Ioss_Utils.h:56
void IOSS_ERROR(const std::ostringstream &errmsg)
Definition Ioss_Utils.h:38
A homogeneous collection of other GroupingEntities.
Definition Ioss_Assembly.h:31
A homogeneous collection of other GroupingEntities.
Definition Ioss_Blob.h:31
Definition Ioss_CommSet.h:27
Definition Ioss_CoordinateFrame.h:19
An input or output Database.
Definition Ioss_DatabaseIO.h:63
A collection of element edges with the same topology.
Definition Ioss_EdgeBlock.h:29
A collection of element edges.
Definition Ioss_EdgeSet.h:30
A collection of elements having the same topology.
Definition Ioss_ElementBlock.h:29
A collection of elements.
Definition Ioss_ElementSet.h:30
A collection of element faces with the same topology.
Definition Ioss_FaceBlock.h:29
A collection of element faces.
Definition Ioss_FaceSet.h:30
Holds metadata for bulk data associated with a GroupingEntity.
Definition Ioss_Field.h:25
IOSS_NODISCARD const VariableType * raw_storage() const
Definition Ioss_Field.h:168
RoleType
Definition Ioss_Field.h:69
@ INTERNAL
Definition Ioss_Field.h:70
IOSS_NODISCARD const std::string & get_name() const
Definition Ioss_Field.h:127
IOSS_NODISCARD std::string role_string() const
Definition Ioss_Field.C:414
IOSS_NODISCARD RoleType get_role() const
Get the role (MESH, ATTRIBUTE, TRANSIENT, REDUCTION, etc.) of the data in the field.
Definition Ioss_Field.h:184
Base class for all 'grouping' entities. The following derived classes are typical:
Definition Ioss_GroupingEntity.h:67
A collection of all nodes in the region.
Definition Ioss_NodeBlock.h:33
A collection of nodes.
Definition Ioss_NodeSet.h:29
A named value that has a known type.
Definition Ioss_Property.h:27
A grouping entity that contains other grouping entities.
Definition Ioss_Region.h:93
BlobContainer blobs
Definition Ioss_Region.h:382
void add_qa_record(const std::string &code, const std::string &code_qa, const std::string &date="", const std::string &time="")
Add a QA record, which consists of 4 strings, to the region's database.
Definition Ioss_Region.h:459
IOSS_NODISCARD bool model_defined() const
Determine whether the metadata defining the model (nontransient, geometry, and toploloty) has been se...
Definition Ioss_Region.h:138
IOSS_NODISCARD std::string type_string() const override
Get the name of the particular type of entity.
Definition Ioss_Region.h:99
void add_information_records(const Ioss::NameList &info)
Add multiple information records (informative strings) to the region's database.
Definition Ioss_Region.h:433
IOSS_NODISCARD EntityType type() const override
Get the EntityType, which indicates the particular type of GroupingEntity this is.
Definition Ioss_Region.h:102
StructuredBlockContainer structuredBlocks
Definition Ioss_Region.h:380
IOSS_NODISCARD bool transient_defined() const
Determine whether the metadata related to the transient data has been set.
Definition Ioss_Region.h:145
AssemblyContainer assemblies
Definition Ioss_Region.h:381
IOSS_NODISCARD std::string contains_string() const override
What does this entity contain.
Definition Ioss_Region.h:101
IOSS_NODISCARD const Ioss::NameList & get_information_records() const
Get all information records (informative strings) for the region's database.
Definition Ioss_Region.h:423
void set_topology_change_count(unsigned int new_count)
Definition Ioss_Region.h:308
IOSS_NODISCARD int get_current_state() const
Get the index (1-based) of the currently-active state.
Definition Ioss_Region.h:407
int currentState
Definition Ioss_Region.h:385
std::shared_ptr< DynamicTopologyObserver > topologyObserver
Definition Ioss_Region.h:390
IOSS_NODISCARD int64_t node_global_to_local(int64_t global, bool must_exist=true) const
Definition Ioss_Region.h:414
IOSS_NODISCARD IfDatabaseExistsBehavior get_if_database_exists_behavior() const
Definition Ioss_Region.h:318
IOSS_NODISCARD bool model_is_written() const
Definition Ioss_Region.h:323
ElementBlockContainer elementBlocks
Definition Ioss_Region.h:370
EdgeBlockContainer edgeBlocks
Definition Ioss_Region.h:368
std::vector< size_t > get_entity_field_data(const std::string &field_name, const std::vector< T * > &entity_container, std::vector< U > &field_data) const
Definition Ioss_Region.h:539
EdgeSetContainer edgeSets
Definition Ioss_Region.h:373
IOSS_NODISCARD std::shared_ptr< DynamicTopologyObserver > get_mesh_modification_observer() const
Definition Ioss_Region.h:297
FaceBlockContainer faceBlocks
Definition Ioss_Region.h:369
NodeBlockContainer nodeBlocks
Definition Ioss_Region.h:367
void set_if_database_exists_behavior(IfDatabaseExistsBehavior if_exists)
Definition Ioss_Region.h:314
CommSetContainer commSets
Definition Ioss_Region.h:378
ElementSetContainer elementSets
Definition Ioss_Region.h:375
StateTimeContainer stateTimes
Definition Ioss_Region.h:383
std::vector< size_t > internal_get_entity_field_data(const std::string &field_name, const std::vector< T * > &entity_container, void *data, size_t data_size=0) const
Definition Ioss_Region.h:565
IOSS_NODISCARD const Ioss::NameList & get_qa_records() const
Get all QA records, each of which consists of 4 strings, from the region's database.
Definition Ioss_Region.h:481
IOSS_NODISCARD bool supports_field_type(Ioss::EntityType fld_type) const
Definition Ioss_Region.h:409
std::map< EntityType, AliasMap > aliases_
Stores alias mappings.
Definition Ioss_Region.h:364
virtual int add_state(double time)
Definition Ioss_Region.h:119
void add_information_record(const std::string &info)
Add an information record (an informative string) to the region's database.
Definition Ioss_Region.h:443
IOSS_NODISCARD unsigned int get_file_cyclic_count() const
Definition Ioss_Region.h:312
NodeSetContainer nodeSets
Definition Ioss_Region.h:372
CoordinateFrameContainer coordinateFrames
Definition Ioss_Region.h:379
IOSS_NODISCARD std::string short_type_string() const override
Get a short name of the particular type of entity.
Definition Ioss_Region.h:100
FaceSetContainer faceSets
Definition Ioss_Region.h:374
void set_file_cyclic_count(unsigned int new_count)
Definition Ioss_Region.h:311
SideSetContainer sideSets
Definition Ioss_Region.h:377
IOSS_NODISCARD bool transient_is_written() const
Definition Ioss_Region.h:324
IOSS_NODISCARD unsigned int get_topology_change_count() const
Definition Ioss_Region.h:309
A collection of element sides having the same topology.
Definition Ioss_SideBlock.h:37
A collection of element sides.
Definition Ioss_SideSet.h:29
A structured zone – i,j,k.
Definition Ioss_StructuredBlock.h:91
IOSS_NODISCARD int component_count() const
Definition Ioss_VariableType.h:154
size_t get_field_data_count_for_entities(const std::string &field_name, const std::vector< T * > &entity_container)
Definition Ioss_Region.h:520
The main namespace for the Ioss library.
Definition Ioad_DatabaseIO.C:40
std::vector< CommSet * > CommSetContainer
Definition Ioss_Region.h:78
State
Access states for a database.
Definition Ioss_State.h:15
std::vector< FaceSet * > FaceSetContainer
Definition Ioss_Region.h:73
std::vector< ElementBlock * > ElementBlockContainer
Definition Ioss_Region.h:69
Ioss::NameList NameList
Definition Ioss_ChangeSetFactory.h:25
std::vector< FaceBlock * > FaceBlockContainer
Definition Ioss_Region.h:68
std::map< std::string, std::string, std::less<> > AliasMap
Definition Ioss_Region.h:83
std::vector< EdgeBlock * > EdgeBlockContainer
Definition Ioss_Region.h:67
bool verify_field_exists_in_entity_group(const std::string &field_name, const std::vector< T * > &entity_container)
Definition Ioss_Region.h:490
std::vector< ElementSet * > ElementSetContainer
Definition Ioss_Region.h:74
std::vector< Ioss::Blob * > BlobContainer
Definition Ioss_Region.h:64
std::vector< NodeSet * > NodeSetContainer
Definition Ioss_Region.h:71
std::vector< double > StateTimeContainer
Definition Ioss_Region.h:79
std::vector< SideSet * > SideSetContainer
Definition Ioss_Region.h:76
std::vector< EdgeSet * > EdgeSetContainer
Definition Ioss_Region.h:72
MeshType
The mesh type – structured, unstructured, hybrid (future), or unknown.
Definition Ioss_MeshType.h:12
std::vector< CoordinateFrame > CoordinateFrameContainer
Definition Ioex_Utils.h:46
std::vector< Ioss::Assembly * > AssemblyContainer
Definition Ioss_Region.h:63
std::vector< NodeBlock * > NodeBlockContainer
Definition Ioss_Region.h:66
std::vector< StructuredBlock * > StructuredBlockContainer
Definition Ioss_Region.h:77
IfDatabaseExistsBehavior
Definition Ioss_DBUsage.h:32
@ DB_OVERWRITE
Definition Ioss_DBUsage.h:33
EntityType
The particular type of GroupingEntity.
Definition Ioss_EntityType.h:12
@ REGION
Definition Ioss_EntityType.h:25