|
Sierra Toolkit
Version of the Day
|
Namespaces | |
| stk_example_io | |
Functions | |
| bool | stk::io::include_entity (const Ioss::GroupingEntity *entity) |
| void | stk::io::internal_part_processing (Ioss::GroupingEntity *entity, stk::mesh::fem::FEMMetaData &meta) |
| void | stk::io::internal_part_processing (Ioss::EntityBlock *entity, stk::mesh::fem::FEMMetaData &meta) |
| void | stk::io::internal_part_processing (Ioss::GroupingEntity *entity, stk::mesh::MetaData &meta) |
| void | stk::io::internal_part_processing (Ioss::EntityBlock *entity, stk::mesh::MetaData &meta) |
| template<typename T > | |
| void | stk::io::default_part_processing (const std::vector< T * > &entities, stk::mesh::fem::FEMMetaData &fem_meta) |
| template<typename T > | |
| void | stk::io::default_part_processing (const std::vector< T * > &entities, stk::mesh::MetaData &meta, const stk::mesh::EntityRank) |
| void | stk::io::define_output_db (Ioss::Region &io_region, const mesh::BulkData &bulk_data, const Ioss::Region *input_region, const stk::mesh::Selector *anded_selector, const bool sort_stk_parts) |
| void | stk::io::write_output_db (Ioss::Region &io_region, const stk::mesh::BulkData &bulk, const stk::mesh::Selector *anded_selector) |
| bool | stk::io::is_valid_part_field (const stk::mesh::FieldBase *field, const stk::mesh::EntityRank part_type, const stk::mesh::Part &part, const stk::mesh::Part &universal, const Ioss::Field::RoleType filter_role, bool add_all) |
| void | stk::io::ioss_add_fields (const stk::mesh::Part &part, const stk::mesh::EntityRank part_type, Ioss::GroupingEntity *entity, const Ioss::Field::RoleType filter_role, const bool add_all) |
| void | stk::io::define_io_fields (Ioss::GroupingEntity *entity, Ioss::Field::RoleType role, stk::mesh::Part &part, stk::mesh::EntityRank part_type) |
| const CellTopologyData * | stk::io::map_topology_ioss_to_cell (const Ioss::ElementTopology *topology) |
| std::string | stk::io::map_topology_cell_to_ioss (const CellTopologyData *cell_top, int spatial_dimension) |
| void | stk::io::get_entity_list (Ioss::GroupingEntity *io_entity, stk::mesh::EntityRank part_type, const stk::mesh::BulkData &bulk, std::vector< stk::mesh::Entity * > &entities) |
| void | stk::io::field_data_from_ioss (const stk::mesh::FieldBase *field, std::vector< stk::mesh::Entity * > &entities, Ioss::GroupingEntity *io_entity, const std::string &io_fld_name) |
| void | stk::io::field_data_to_ioss (const stk::mesh::FieldBase *field, std::vector< stk::mesh::Entity * > &entities, Ioss::GroupingEntity *io_entity, const std::string &io_fld_name, Ioss::Field::RoleType filter_role) |
| const stk::mesh::Field< double, stk::mesh::ElementNode > * | stk::io::get_distribution_factor_field (const stk::mesh::Part &p) |
| void | stk::io::set_distribution_factor_field (stk::mesh::Part &p, const stk::mesh::Field< double, stk::mesh::ElementNode > &df_field) |
| const Ioss::Field::RoleType * | stk::io::get_field_role (const stk::mesh::FieldBase &f) |
| void | stk::io::set_field_role (stk::mesh::FieldBase &f, const Ioss::Field::RoleType &role) |
| bool | stk::io::is_part_io_part (stk::mesh::Part &part) |
| void | stk::io::put_io_part_attribute (mesh::Part &part, Ioss::GroupingEntity *entity) |
| void | stk::io::remove_io_part_attribute (mesh::Part &part) |
| const Ioss::GroupingEntity * | stk::io::get_associated_ioss_entity (const mesh::Part &part) |
| size_t | stk::io::db_api_int_size (const Ioss::GroupingEntity *entity) |
| bool | stk::io::invalid_rank (stk::mesh::EntityRank rank) |
| stk::mesh::EntityRank | stk::io::part_primary_entity_rank (const stk::mesh::Part &part) |
| stk::mesh::EntityRank | stk::io::element_rank (const stk::mesh::MetaData &meta) |
| stk::mesh::EntityRank | stk::io::side_rank (const stk::mesh::MetaData &meta) |
| stk::mesh::EntityRank | stk::io::face_rank (const stk::mesh::MetaData &meta) |
| stk::mesh::EntityRank | stk::io::edge_rank (const stk::mesh::MetaData &meta) |
| stk::mesh::EntityRank | stk::io::node_rank (const stk::mesh::MetaData &meta) |
| void | stk::io::set_cell_topology (stk::mesh::Part &part, const CellTopologyData *const cell_topology) |
| const CellTopologyData * | stk::io::get_cell_topology (const stk::mesh::Part &part) |
| void | stk::io::initialize_spatial_dimension (stk::mesh::fem::FEMMetaData &fem_meta, size_t spatial_dimension, const std::vector< std::string > &entity_rank_names) |
| void | stk::io::initialize_spatial_dimension (stk::mesh::MetaData &meta, size_t spatial_dimension, const std::vector< std::string > &entity_rank_names) |
| void | stk::io::get_io_field_type (const stk::mesh::FieldBase *field, const stk::mesh::FieldRestriction &res, std::pair< std::string, Ioss::Field::BasicType > *result) |
| int | main (int argc, char **argv) |
The code samples below should closely match the code in the example file stk_io/use_cases/io_example.cpp which is compilable and executable. It can be used to experiment with the stk::io and Ioss functionality. If there is any discrepancy between the documentation below and the code found in io_example.cpp; trust the actual code.
The following include files are required for this example.
The io_example function provides all mesh input and results output functionality for this example application. It would most likely be split into multiple functions in a real application. The function takes as arguments an MPI communicator; the name of the mesh file to read from and the name of the results database to write to.
The IO system must be initialized via a call to Ioss::Init::Initializer. This sets up which database types are supported and performs other behind the scenes initialization duties.
The input mesh file must be associated with an Ioss::DatabaseIO object. The IO system must be told the type of the database to be opened; in this example, the type is "exodusII". If the file does not exist or could not be opened, the Ioss::IOFactory will return NULL; if the file does exist and can be opened, but has other problems, then the dbi->ok() function will return false.
Once the datbase has been opened, it is then associated with an Ioss::Region which is the main interface to the mesh description stored in the mesh database.
The stk::io functions provide a basic subsetting capability. If an Ioss entity (Ioss::ElementBlock, Ioss::NodeSet, Ioss::FaceSet, Ioss::EdgeSet, ...) has the "omitted" property defined and the value of the property is "1", then the associated entity will be omitted from the stk::mesh model. At any time prior to defining the stk::mesh::MetaData, the application can set the property on any entities that should be omitted from the model.
The following code example shows how this subsetting capability works by omitting the element blocks with names "cblock", "eblock", "i1", and "i2". These are element blocks in a file that is used in one of the stk::io use cases.
The following block of code shows how the Ioss metadata is queried and used to define the stk::mesh::MetaData for the analysis model. Each of the process_* functions is described in more detail later on.
At this point, the application would define other stk::mesh::Field's that exist on the mesh parts or any other data that needs to be set before the meta data is comitted. Once this is done, the meta data can be commited.
The following block of code defines a stk::mesh::BulkData object and populates it with the bulk data from the mesh database. Each of the process_* function is described in more detail later on. Following this, the analysis mesh is defined and ready for use.
Once the analysis mesh is defined, the application will typically want to define one or more output databases; for example, results, heartbeat, history, and/or restart. In the example below, a results database is defined and associated with an Ioss::Region. The define_output_db() function extracts the metadata from the stk::mesh MetaData and BulkData so that the output region corresponds as much as possible to the input region. The "in_region" argument to the function is optional and if present will synchronize names and ids in the input mesh with the corresponding entities in the output mesh.
Once the output database metadata is defined, the write_output_db() function is called to output the initial data to the file corresponding to this database. Following this call, the file should contain all of the non-transient data corresponding to the analysis mesh.
At this time, the application would define what stk::mesh::Field fields should be output to the results database and what they would be named.
In this example, all fields existing on the input mesh database are defined on the parts in the stk::mesh.
The real app would also only register a subset of the stk::mesh fields as output fields and would probably have a mapping from the internally used name to some name picked by the user. In this example, all Ioss::Field::TRANSIENT fields defined on the stk::mesh are output to the results database and the internal stk::mesh field name is used as the name on the database....
See ioss_add_fields() for more details on how to add a field.
At this time, the input and output databases are ready for reading and/or writing transient field data. This is where an application would typically have its execute loop which marches through time.
In the example below, the code queries the input mesh region for the number of timesteps it contains and then simply reads all data on the input database for each timestep and writes the corresponding data to the results database.
As the input and output Ioss::Region objects go out of scope, they will close the files associated with them and do all cleanup.
The Sierra Toolkit IO product contains functions related to the transfer of data between the Ioss classes and the stk::mesh classes. These functions do not provide a total turnkey mesh reading or results writing capability; rather, they provide helper functions for the application to use which make it easier to read and/or write the data. The application has full control over the mesh reading and results/restart writing.
| bool stk::io::include_entity | ( | const Ioss::GroupingEntity * | entity | ) |
Returns true if the Ioss 'entity' should be a 'part' in the analysis mesh. Returns false if the application is only using a subset of the database entities and this entity is not to be used. The function checks whether the "omitted" property exists and if it does, whether the value of the property is "1". The "omitted" property is set by the application during parsing or pre-mesh reading time.
Definition at line 1035 of file IossBridge.cpp.
| void stk::io::internal_part_processing | ( | Ioss::GroupingEntity * | entity, |
| stk::mesh::MetaData & | meta | ||
| ) |
Definition at line 792 of file IossBridge.cpp.
| void stk::io::internal_part_processing | ( | Ioss::EntityBlock * | entity, |
| stk::mesh::MetaData & | meta | ||
| ) |
Definition at line 807 of file IossBridge.cpp.
| void stk::io::default_part_processing | ( | const std::vector< T * > & | entities, |
| stk::mesh::fem::FEMMetaData & | fem_meta | ||
| ) |
This is the primary function used by an application to define the stk::mesh which corresponds to the Ioss mesh read from the finite element model (e.g. exodusII file). For all entities in the passed in 'entities' list, the function will determine whether the entity should be included (see stk::io::include_entity()), and it will then delcare a part corresponding to the entity. It also adds the io_part attribute (see stk::io::define_output_db()) which will cause the part to be output to a results or restart file.
Definition at line 93 of file IossBridge.hpp.
| void stk::io::default_part_processing | ( | const std::vector< T * > & | entities, |
| stk::mesh::MetaData & | meta, | ||
| const stk::mesh::EntityRank | |||
| ) |
Definition at line 104 of file IossBridge.hpp.
| void stk::io::define_output_db | ( | Ioss::Region & | io_region, |
| const mesh::BulkData & | bulk_data, | ||
| const Ioss::Region * | input_region = NULL, |
||
| const stk::mesh::Selector * | anded_selector = NULL, |
||
| const bool | sort_stk_parts = false |
||
| ) |
Given the newly created Ioss::Region 'io_region', define the model corresponding to the stk::mesh 'bulk_data'. If the optional 'input_region' is passed as an argument, then synchronize all names and ids found on 'input_region' to the output region 'io_region'. The routine will query all parts in 'bulk_data' and if they are io_parts (define by the existance of the IOPartAttribute attribute on the part), then a corresponding Ioss entity will be defined. This routine only deals with the non-transient portion of the model; no transient fields are defined at this point.
| [in] | sort_stk_parts | Force a sorted order on the stk_mesh parts so all pieces of a decomposed mesh have consistent part ordering. Normally not necessary, since MetaData is created from a parallel-consistent data base. It is useful in cases such as streaming refinement where each piece of a parallel- decomposed mesh is read in sequentially and parts are thus possibly created in different orderings. |
Definition at line 1277 of file IossBridge.cpp.
| void stk::io::write_output_db | ( | Ioss::Region & | io_region, |
| const mesh::BulkData & | bulk, | ||
| const stk::mesh::Selector * | anded_selector = NULL |
||
| ) |
Given an Ioss::Region 'io_region' which has already had its metadata defined via 'define_output_db()' call; transfer all bulk data (node coordinates, element connectivity, ...) to the output database that corresponds to this Ioss::Region. At return, all non-transient portions of the output database will have been output.
Definition at line 1644 of file IossBridge.cpp.
| bool stk::io::is_valid_part_field | ( | const stk::mesh::FieldBase * | field, |
| const stk::mesh::EntityRank | part_type, | ||
| const stk::mesh::Part & | part, | ||
| const stk::mesh::Part & | universal, | ||
| const Ioss::Field::RoleType | filter_role, | ||
| bool | add_all | ||
| ) |
Determine whether the field is defined on the specified part and should also be associated with a Ioss GroupingEntity for input or output
Determine whether the field is defined on the specified part and should also be associated with an Ioss::GroupingEntity for input or output.
The 'universal' part is argument currently only used for an EntityRank of type 'node'. In this case, the field is only valid if it does exist on 'part', but does not exist on 'universal' unless 'part' and 'universal' are the same part. The motivation for this is that an Ioss::NodeBlock corresponds to the universal part and an Ioss::NodeSet corresponds to the sub part. Without the check, all nodeblock fields would also be defined on the nodeset which is not what is desired.
The 'filter_role' only selects fields with the specified role (e.g., TRANSIENT, ATTRIBUTE, ..., see Ioss documentation for valid roles) unless 'add_all == true' is specified.
The field's role is defined via a call to 'stk::io::set_field_role'
Definition at line 620 of file IossBridge.cpp.
| void stk::io::ioss_add_fields | ( | const stk::mesh::Part & | part, |
| const stk::mesh::EntityRank | part_type, | ||
| Ioss::GroupingEntity * | entity, | ||
| const Ioss::Field::RoleType | filter_role, | ||
| const bool | add_all | ||
| ) |
Add all stk::Fields on the entities of the specified part_type on the specified part of the specified role * to the specified Ioss::GroupingEntity
Add all stk::Fields on the specified part of the specified filter_role to the specified Ioss::GroupingEntity. Retrieves all fields; calls 'is_valid_part_field'; and adds those that return true.
Definition at line 868 of file IossBridge.cpp.
| void stk::io::define_io_fields | ( | Ioss::GroupingEntity * | entity, |
| Ioss::Field::RoleType | role, | ||
| stk::mesh::Part & | part, | ||
| stk::mesh::EntityRank | part_type | ||
| ) |
For the given Ioss::GroupingEntity "entity", find all fields that exist on the input database of type "role" and declare them on the give stk::mesh::Part "part". The "part_type" argument specifies the entity type (node, element, ...) that the field should be declared on for this "part"
The "role" will typically be either "ATTRIBUTE" or "TRANSIENT"
For the given Ioss::GroupingEntity "entity", find all fields that exist on the input database of type "role" and declare them on the give stk::mesh::Part "part". The "part_type" argument specifies the entity type (node, element, ...) that the field should be declared on for this "part"
The "role" will typically be either "ATTRIBUTE" or "TRANSIENT"
This is essentially the complement of the 'ioss_add_fields' function.
Definition at line 905 of file IossBridge.cpp.
| const CellTopologyData * stk::io::map_topology_ioss_to_cell | ( | const Ioss::ElementTopology * | topology | ) |
Given an Ioss::ElementTopolgy, return the corresponding CellTopologyData. If a corresponding topology is not found, a runtime error exception will be thrown.
Definition at line 670 of file IossBridge.cpp.
| std::string stk::io::map_topology_cell_to_ioss | ( | const CellTopologyData * | cell_top, |
| int | spatial_dimension | ||
| ) |
Given a CellTopologyData and a spatial_dimension, return the corresponding Ioss::ElementTopology. If a corresponding topology is not found, a runtime error exception will be thrown.
Definition at line 687 of file IossBridge.cpp.
| void stk::io::get_entity_list | ( | Ioss::GroupingEntity * | io_entity, |
| stk::mesh::EntityRank | part_type, | ||
| const stk::mesh::BulkData & | bulk, | ||
| std::vector< stk::mesh::Entity * > & | entities | ||
| ) |
For the given Ioss entity, create a vector of stk::mesh::Entity pointers such that the entities in the 'entities' list match the order of the entities in the Ioss entity. If there is not a corresponding stk::mesh::Entity, the entry at that location will be NULL. Upon return, the size of the 'entities' list should match the number of entities in 'io_entity'. The returned list is typically used to get/put field data from/to an Ioss::GroupingEntity to/from an stk::mesh::Field. See stk::io::field_data_from_ioss() and stk::io::field_data_to_ioss() for examples.
Definition at line 952 of file IossBridge.cpp.
| void stk::io::field_data_from_ioss | ( | const stk::mesh::FieldBase * | field, |
| std::vector< stk::mesh::Entity * > & | entities, | ||
| Ioss::GroupingEntity * | io_entity, | ||
| const std::string & | io_fld_name | ||
| ) |
Fill the specified 'field' with data from the Ioss field named 'io_fld_name' on the Ioss entity 'io_entity'. The mapping from the meshobjects in the Ioss io_entity to the stk::mesh::Entities is given by the 'entities' list.
Definition at line 964 of file IossBridge.cpp.
| void stk::io::field_data_to_ioss | ( | const stk::mesh::FieldBase * | field, |
| std::vector< stk::mesh::Entity * > & | entities, | ||
| Ioss::GroupingEntity * | io_entity, | ||
| const std::string & | io_fld_name, | ||
| Ioss::Field::RoleType | filter_role | ||
| ) |
Extract data from the specified 'field' and put it to the Ioss field named 'io_fld_name' on the Ioss entity 'io_entity'. The mapping from the meshobjects in the Ioss io_entity to the stk::mesh::Entities is given by the 'entities' list.
Definition at line 999 of file IossBridge.cpp.
| const mesh::Field< double, mesh::ElementNode > * stk::io::get_distribution_factor_field | ( | const mesh::Part & | p | ) |
Returns the stk::mesh::Field which contains the distribution factors for the specified part 'p'. Returns NULL if there is no such field.
Definition at line 1702 of file IossBridge.cpp.
| void stk::io::set_distribution_factor_field | ( | mesh::Part & | p, |
| const mesh::Field< double, mesh::ElementNode > & | df_field | ||
| ) |
Defines the stk::mesh::Field which contains the distribution factors for the specified part 'p'.
Definition at line 1707 of file IossBridge.cpp.
| const Ioss::Field::RoleType * stk::io::get_field_role | ( | const mesh::FieldBase & | f | ) |
Returns the Ioss::Field::RoleType of the mesh::Field 'f'. This must have earlier been defined using stk::io::set_field_role(). Returns NULL if the role was not defined.
Definition at line 1714 of file IossBridge.cpp.
| void stk::io::set_field_role | ( | mesh::FieldBase & | f, |
| const Ioss::Field::RoleType & | role | ||
| ) |
Defines the Ioss::Field::RoleType of the mesh::Field 'f' to be 'role'.
Definition at line 1719 of file IossBridge.cpp.
| bool stk::io::is_part_io_part | ( | mesh::Part & | part | ) |
Returns whether the mesh::Part 'p' should be output to a results or restart database. Or, in other words, whether the part should have an Ioss::GroupingEntity of the correct type defined in an Ioss::Region. The function will return true if the part 'p' has an IOPartAttribute defined on it. The attributed is defined via the stk::io::put_io_part_attribute() function.
Definition at line 1697 of file IossBridge.cpp.
| void stk::io::put_io_part_attribute | ( | mesh::Part & | part, |
| Ioss::GroupingEntity * | entity = NULL |
||
| ) |
Define an attribute on the specified part 'part' indicating that this part should be used for io.
Definition at line 570 of file IossBridge.cpp.
| void stk::io::remove_io_part_attribute | ( | mesh::Part & | part | ) |
Remove the existing attribute on the specified part 'part' that indicates that this part should be used for io.
Definition at line 589 of file IossBridge.cpp.
| void stk::io::initialize_spatial_dimension | ( | mesh::MetaData & | meta, |
| size_t | spatial_dimension, | ||
| const std::vector< std::string > & | entity_rank_names | ||
| ) |
Definition at line 468 of file IossBridge.cpp.