18 #ifndef LIBMESH_EXODUSII_IO_HELPER_H 19 #define LIBMESH_EXODUSII_IO_HELPER_H 21 #include "libmesh/libmesh_config.h" 23 #ifdef LIBMESH_HAVE_EXODUS_API 26 #include "libmesh/parallel_object.h" 27 #include "libmesh/point.h" 28 #include "libmesh/boundary_info.h" 29 #include "libmesh/enum_elem_type.h" 30 #include "libmesh/exodus_header_info.h" 39 #define EX_CHECK_ERR(code, msg) \ 42 libmesh_error_msg((msg)); \ 45 #define EX_EXCEPTIONLESS_CHECK_ERR(code, msg) \ 48 libMesh::err << (msg) << std::endl; \ 49 libmesh_exceptionless_error(); \ 85 bool run_only_on_proc0=
true,
86 bool single_precision=
false);
131 void open(
const char * filename,
bool read_only);
281 void close() noexcept;
306 std::map<dof_id_type, Real> & elem_var_value_map);
311 virtual void create(std::string filename);
338 bool use_discontinuous=
false);
354 const std::vector<std::set<subdomain_id_type>> & vars_active_subdomains);
382 const std::vector<std::string> & var_names,
383 const std::vector<std::set<boundary_id_type>> & side_ids,
384 const std::vector<std::map<BoundaryInfo::BCTuple, Real>> & bc_vals);
392 std::vector<std::string> & var_names,
393 std::vector<std::set<boundary_id_type>> & side_ids,
394 std::vector<std::map<BoundaryInfo::BCTuple, Real>> & bc_vals);
408 std::map<BoundaryInfo::BCTuple, unsigned int> & bc_array_indices);
415 const std::vector<std::string> & var_names,
416 const std::vector<std::set<boundary_id_type>> & node_boundary_ids,
417 const std::vector<std::map<BoundaryInfo::NodeBCTuple, Real>> & bc_vals);
424 std::vector<std::string> & var_names,
425 std::vector<std::set<boundary_id_type>> & node_boundary_ids,
426 std::vector<std::map<BoundaryInfo::NodeBCTuple, Real>> & bc_vals);
443 const std::vector<std::string> & var_names,
444 const std::vector<std::set<elemset_id_type>> & elemset_ids_in,
445 const std::vector<std::map<std::pair<dof_id_type, elemset_id_type>,
Real>> & elemset_vals);
452 std::vector<std::string> & var_names,
453 std::vector<std::set<elemset_id_type>> & elemset_ids_in,
454 std::vector<std::map<std::pair<dof_id_type, elemset_id_type>,
Real>> & elemset_vals);
479 const std::vector<Real> & values,
481 const std::vector<std::set<subdomain_id_type>> & vars_active_subdomains);
499 const std::vector<Real> & values,
501 const std::vector<std::set<subdomain_id_type>> & vars_active_subdomains,
502 const std::vector<std::string> & derived_var_names,
503 const std::map<
subdomain_id_type, std::vector<std::string>> & subdomain_to_var_names);
574 std::vector<std::string>
576 bool write_complex_abs)
const;
582 std::vector<std::set<subdomain_id_type>>
584 (
const std::vector<std::set<subdomain_id_type>> & vars_active_subdomains,
585 bool write_complex_abs)
const;
594 std::map<subdomain_id_type, std::vector<std::string>>
596 (
const std::map<
subdomain_id_type, std::vector<std::string>> & subdomain_to_var_names,
597 bool write_complex_abs)
const;
617 void message(std::string_view msg);
624 void message(std::string_view msg,
int i);
1005 bool single_precision_in);
1030 bool single_precision_in);
1053 std::vector<std::string> & result);
1067 const std::vector<std::string> & names);
1262 NamesData(
size_t n_strings,
size_t string_length);
1310 #endif // LIBMESH_HAVE_EXODUS_API 1312 #endif // LIBMESH_EXODUSII_IO_HELPER_H std::vector< int > elemset_list
const std::vector< int > * node_map
Pointer to the node map for this element.
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
virtual void write_sidesets(const MeshBase &mesh)
Writes the sidesets contained in "mesh".
std::vector< int > num_elems_per_set
void write_sideset_data(const MeshBase &mesh, int timestep, const std::vector< std::string > &var_names, const std::vector< std::set< boundary_id_type >> &side_ids, const std::vector< std::map< BoundaryInfo::BCTuple, Real >> &bc_vals)
Write sideset data for the requested timestep.
void use_mesh_dimension_instead_of_spatial_dimension(bool val)
Sets the underlying value of the boolean flag _use_mesh_dimension_instead_of_spatial_dimension.
std::vector< int > id_list
void write_var_names(ExodusVarType type, const std::vector< std::string > &names)
Wraps calls to exII::ex_put_var_names() and exII::ex_put_var_param().
This class facilitates inline conversion of an input data vector to a different precision level...
ElemType
Defines an enum for geometric element types.
std::vector< std::string > sideset_var_names
std::vector< int > node_num_map
void read_node_num_map()
Reads the optional node_num_map from the ExodusII mesh file.
bool _elem_vars_initialized
std::vector< int > num_sides_per_set
const char * get_elem_type() const
void get_elemset_data_indices(std::map< std::pair< dof_id_type, elemset_id_type >, unsigned int > &elemset_array_indices)
Similar to read_elemset_data(), but instead of creating one std::map per elemset per variable...
void read_elemset(int id, int offset)
Reads information about elemset id and inserts it into the global elemset array at the position offse...
std::vector< std::string > elem_var_names
void read_elemset_data(int timestep, std::vector< std::string > &var_names, std::vector< std::set< elemset_id_type >> &elemset_ids_in, std::vector< std::map< std::pair< dof_id_type, elemset_id_type >, Real >> &elemset_vals)
Read elemset variables, if any, into the provided data structures.
ExodusHeaderInfo read_header() const
Reads an ExodusII mesh file header, leaving this object's internal data structures unchanged...
std::map< int, std::string > id_to_ss_names
std::vector< std::string > get_complex_names(const std::vector< std::string > &names, bool write_complex_abs) const
virtual ~ExodusII_IO_Helper()
std::string get_block_name(int index)
Get the block name for the given block index if supplied in the mesh file.
std::map< int, std::string > id_to_edge_block_names
void read_sideset_info()
Reads information about all of the sidesets in the ExodusII mesh file.
void read_nodal_var_values(std::string nodal_var_name, int time_step)
Reads the nodal values for the variable 'nodal_var_name' at the specified time into the 'nodal_var_va...
ExodusII_IO_Helper(const ParallelObject &parent, bool v=false, bool run_only_on_proc0=true, bool single_precision=false)
Constructor.
void write_information_records(const std::vector< std::string > &records)
Writes the vector of information records.
virtual void read_var_names_impl(const char *var_type, int &count, std::vector< std::string > &result)
read_var_names() dispatches to this function.
static const int invalid_id
An invalid_id that can be returned to signal failure in case something goes wrong.
void write_as_dimension(unsigned dim)
Sets the value of _write_as_dimension.
std::vector< int > exodus_elem_num_to_libmesh
std::map< dof_id_type, Real > nodal_var_values
std::string get_side_set_name(int index)
Get the side set name for the given side set index if supplied in the mesh file.
bool _global_vars_initialized
void get_sideset_data_indices(const MeshBase &mesh, std::map< BoundaryInfo::BCTuple, unsigned int > &bc_array_indices)
Similar to read_sideset_data(), but instead of creating one std::map per sideset per variable...
dof_id_type node_id_to_vec_id(dof_id_type n) const
std::vector< int > block_ids
std::vector< int > side_list
virtual void write_nodesets(const MeshBase &mesh)
Writes the nodesets contained in "mesh".
ExodusII_IO_Helper & operator=(const ExodusII_IO_Helper &)=delete
This class contains references so it can't be default copy/move-assigned.
void read_bex_cv_blocks()
Reads the optional bex_cv_blocks from the ExodusII mesh file.
void read_nodeset_data(int timestep, std::vector< std::string > &var_names, std::vector< std::set< boundary_id_type >> &node_boundary_ids, std::vector< std::map< BoundaryInfo::NodeBCTuple, Real >> &bc_vals)
Read nodeset variables, if any, into the provided data structures.
MappedOutputVector(const std::vector< Real > &vec_in, bool single_precision_in)
std::vector< Real > time_steps
virtual void write_elements(const MeshBase &mesh, bool use_discontinuous=false)
Writes the elements contained in "mesh".
std::vector< std::set< subdomain_id_type > > get_complex_vars_active_subdomains(const std::vector< std::set< subdomain_id_type >> &vars_active_subdomains, bool write_complex_abs) const
returns a "tripled" copy of vars_active_subdomains, which is necessary in the complex-valued case...
void write_elemsets(const MeshBase &mesh)
Write elemsets stored on the Mesh to the exo file.
const ExodusII_IO_Helper::Conversion & get_conversion(const ElemType type) const
void print_nodes(std::ostream &out_stream=libMesh::out)
Prints the nodal information, by default to libMesh::out.
The libMesh namespace provides an interface to certain functionality in the library.
std::vector< std::vector< char > > data_table
void read_time_steps()
Reads and stores the timesteps in the 'time_steps' array.
std::vector< int > node_sets_node_index
std::vector< char > & title
ExodusHeaderInfo header_info
void write_nodal_values(int var_id, const std::vector< Real > &values, int timestep)
Writes the vector of values to a nodal variable.
bool _add_sides
Set to true iff we want to write separate "side" elements too.
void message(std::string_view msg)
Prints the message defined in msg.
void check_existing_vars(ExodusVarType type, std::vector< std::string > &names, std::vector< std::string > &names_from_file)
When appending: during initialization, check that variable names in the file match those you attempt ...
const std::vector< int > * inverse_side_map
Pointer to the inverse side map for this element.
void read_nodes()
Reads the nodal data (x,y,z coordinates) from the ExodusII mesh file.
std::string exodus_type
The string corresponding to the Exodus type for this element.
std::vector< std::string > nodeset_var_names
std::map< dof_id_type, dof_id_type > libmesh_node_num_to_exodus
int n_nodes
The number of nodes per element; useful likewise.
uint8_t processor_id_type
This is the MeshBase class.
void close() noexcept
Closes the ExodusII mesh file.
void write_element_values(const MeshBase &mesh, const std::vector< Real > &values, int timestep, const std::vector< std::set< subdomain_id_type >> &vars_active_subdomains)
Writes the vector of values to the element variables.
void write_timestep(int timestep, Real time)
Writes the time for the timestep.
bool _use_mesh_dimension_instead_of_spatial_dimension
void read_edge_blocks(MeshBase &mesh)
Read in edge blocks, storing information in the BoundaryInfo object.
const std::vector< int > * inverse_shellface_map
Pointer to the inverse shellface map for this element.
virtual void initialize_element_variables(std::vector< std::string > names, const std::vector< std::set< subdomain_id_type >> &vars_active_subdomains)
Sets up the nodal variables.
std::vector< float > float_vec
void set_add_sides(bool add_sides)
Sets whether or not to write extra "side" elements.
void open(const char *filename, bool read_only)
Opens an ExodusII mesh file named filename.
char * get_char_star(int i)
Provide access to the i'th underlying char *.
std::vector< int > nodeset_ids
void update()
Uses ex_update() to flush buffers to file.
void push_back_entry(const std::string &name)
Adds another name to the current data table.
void read_all_nodesets()
New API that reads all nodesets simultaneously.
void read_global_values(std::vector< Real > &values, int timestep)
Reads the vector of global variables.
std::vector< int > elem_list
std::vector< double > double_vec
std::vector< std::string > global_var_names
int dim
The element dimension; useful since we don't seem to have a cheap way to look this up from ElemType...
void read_var_names(ExodusVarType type)
void write_nodeset_data(int timestep, const std::vector< std::string > &var_names, const std::vector< std::set< boundary_id_type >> &node_boundary_ids, const std::vector< std::map< BoundaryInfo::NodeBCTuple, Real >> &bc_vals)
Write nodeset data for the requested timestep.
std::vector< int > connect
void read_elemset_info()
Reads information about all of the elemsets in the ExodusII mesh file.
std::vector< int > elemset_ids
void write_elemset_data(int timestep, const std::vector< std::string > &var_names, const std::vector< std::set< elemset_id_type >> &elemset_ids_in, const std::vector< std::map< std::pair< dof_id_type, elemset_id_type >, Real >> &elemset_vals)
Write elemset data for the requested timestep.
std::vector< int > ss_ids
int get_inverse_shellface_map(int i) const
void write_element_values_element_major(const MeshBase &mesh, const std::vector< Real > &values, int timestep, const std::vector< std::set< subdomain_id_type >> &vars_active_subdomains, const std::vector< std::string > &derived_var_names, const std::map< subdomain_id_type, std::vector< std::string >> &subdomain_to_var_names)
Same as the function above, but assume the input 'values' vector is in element-major order...
void read_nodeset_info()
Reads information about all of the nodesets in the ExodusII mesh file.
This is the ExodusII_IO_Helper class.
void set_coordinate_offset(Point p)
Allows you to set a vector that is added to the coordinates of all of the nodes.
void write_global_values(const std::vector< Real > &values, int timestep)
Writes the vector of global variables.
int get_inverse_node_map(int i) const
std::vector< dof_id_type > _true_node_offsets
If we're adding "fake" sides to visualize SIDE_DISCONTINUOUS variables, we also need to know how many...
An object whose state is distributed along a set of processors.
void read_elem_in_block(int block)
Reads all of the element connectivity for block block in the ExodusII mesh file.
std::size_t get_shellface_index_offset() const
std::map< dof_id_type, dof_id_type > libmesh_elem_num_to_exodus
const std::vector< int > * shellface_map
Pointer to the shellface map for this element.
int get_node_map(int i) const
int num_elem_all_elemsets
void initialize_global_variables(std::vector< std::string > names)
Sets up the global variables.
void read_sideset_data(const MeshBase &mesh, int timestep, std::vector< std::string > &var_names, std::vector< std::set< boundary_id_type >> &side_ids, std::vector< std::map< BoundaryInfo::BCTuple, Real >> &bc_vals)
Read sideset variables, if any, into the provided data structures.
unsigned _write_as_dimension
std::vector< Real > elem_var_values
std::vector< char * > data_table_pointers
unsigned int bex_num_elem_cvs
std::vector< int > num_node_df_per_set
char ** get_char_star_star()
Provide access to the underlying C data table.
int get_node_set_id(int index)
Get the node set id for the given node set index.
ExodusVarType
Wraps calls to exII::ex_get_var_names() and exII::ex_get_var_param().
std::map< std::string, ElemType > element_equivalence_map
Defines equivalence classes of Exodus element types that map to libmesh ElemTypes.
const std::vector< Real > & our_data
virtual void initialize(std::string title, const MeshBase &mesh, bool use_discontinuous=false)
Initializes the Exodus file.
virtual void create(std::string filename)
Opens an ExodusII mesh file named filename for writing.
std::vector< int > node_sets_node_list
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void read_num_time_steps()
Reads the number of timesteps currently stored in the Exodus file and stores it in the num_time_steps...
void read_block_info()
Reads information for all of the blocks in the ExodusII mesh file.
const std::vector< int > * side_map
Pointer to the side map for this element.
void read_elem_num_map()
Reads the optional node_num_map from the ExodusII mesh file.
ElemType libmesh_elem_type() const
~MappedOutputVector()=default
void read_and_store_header_info()
Reads an ExodusII mesh file header, and stores required information on this object.
void read_sideset(int id, int offset)
Reads information about sideset id and inserts it into the global sideset array at the position offse...
std::vector< dof_id_type > _added_side_node_offsets
If we're adding "fake" sides to visualize SIDE_DISCONTINUOUS variables, _added_side_node_offsets[p] g...
int get_inverse_side_map(int i) const
NamesData(size_t n_strings, size_t string_length)
Constructor.
size_t shellface_index_offset
The shellface index offset defines the offset due to a difference between libMesh and Exodus in index...
void init_element_equivalence_map()
void set_hdf5_writing(bool write_hdf5)
Set to true (the default) to write files in an HDF5-based file format (when HDF5 is available)...
std::map< int, std::string > id_to_block_names
std::vector< int > elem_num_map
int get_side_set_id(int index)
Get the side set id for the given side set index.
std::vector< std::string > elemset_var_names
void print_header()
Prints the ExodusII mesh file header, which includes the mesh title, the number of nodes...
std::vector< int > exodus_node_num_to_libmesh
std::map< int, std::string > id_to_ns_names
void initialize_nodal_variables(std::vector< std::string > names)
Sets up the nodal variables.
std::vector< int > num_nodes_per_set
std::string exodus_elem_type() const
std::vector< std::string > nodal_var_names
std::string get_node_set_name(int index)
Get the node set name for the given node set index if supplied in the mesh file.
void init_conversion_map()
std::string current_filename
std::map< int, std::string > id_to_elemset_names
const std::vector< int > * inverse_node_map
Pointer to the inverse node map for this element.
ElemType libmesh_type
The canonical (i.e.
std::vector< int > edge_block_ids
void read_qa_records()
Reads the QA records from an ExodusII file.
This class is useful for managing anything that requires a char ** input/output in ExodusII file...
void read_elemental_var_values(std::string elemental_var_name, int time_step, std::map< dof_id_type, Real > &elem_var_value_map)
Reads elemental values for the variable 'elemental_var_name' at the specified timestep into the 'elem...
std::vector< char > elem_type
std::vector< Real > node_sets_dist_fact
A Point defines a location in LIBMESH_DIM dimensional Real space.
void get_nodeset_data_indices(std::map< BoundaryInfo::NodeBCTuple, unsigned int > &bc_array_indices)
Similar to read_nodeset_data(), but instead of creating one std::map per nodeset per variable...
int get_block_id(int index)
Get the block number for the given block index.
std::vector< int > num_df_per_set
std::map< subdomain_id_type, std::vector< std::string > > get_complex_subdomain_to_var_names(const std::map< subdomain_id_type, std::vector< std::string >> &subdomain_to_var_names, bool write_complex_abs) const
Takes a map from subdomain id -> vector of active variable names as input and returns a corresponding...
std::map< int, std::map< ElemType, ExodusII_IO_Helper::Conversion > > conversion_map
Associates libMesh ElemTypes with node/face/edge/etc.
std::vector< int > node_sets_dist_index
int get_shellface_map(int i) const
std::vector< int > elemset_id_list
int num_elem_all_sidesets
virtual void write_nodal_coordinates(const MeshBase &mesh, bool use_discontinuous=false)
Writes the nodal coordinates contained in "mesh".
std::vector< int > num_elem_df_per_set
static int get_exodus_version()
dof_id_type added_node_offset_on(processor_id_type p) const
void write_var_names_impl(const char *var_type, int &count, const std::vector< std::string > &names)
write_var_names() dispatches to this function.
std::vector< std::vector< long unsigned int > > bex_cv_conn
int get_side_map(int i) const
std::vector< std::vector< std::vector< Real > > > bex_dense_constraint_vecs
bool _nodal_vars_initialized