Go to the documentation of this file.
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"
38 #define EX_CHECK_ERR(code, msg) \
41 libmesh_error_msg((msg)); \
44 #define EX_EXCEPTIONLESS_CHECK_ERR(code, msg) \
47 libMesh::err << (msg) << std::endl; \
48 libmesh_exceptionless_error(); \
58 #include <libmesh/ignore_warnings.h>
64 #include <libmesh/restore_warnings.h>
92 bool run_only_on_proc0=
true,
93 bool single_precision=
false);
119 void open(
const char * filename,
bool read_only);
252 int inquire(
int req_info, std::string error_msg=
"");
277 std::map<dof_id_type, Real> & elem_var_value_map);
282 virtual void create(std::string filename);
314 const std::vector<std::set<subdomain_id_type>> & vars_active_subdomains);
337 const std::vector<std::string> & var_names,
338 const std::vector<std::set<boundary_id_type>> & side_ids,
339 const std::vector<std::map<BoundaryInfo::BCTuple, Real>> & bc_vals);
347 std::vector<std::string> & var_names,
348 std::vector<std::set<boundary_id_type>> & side_ids,
349 std::vector<std::map<BoundaryInfo::BCTuple, Real>> & bc_vals);
364 const std::vector<Real> & values,
366 const std::vector<std::set<subdomain_id_type>> & vars_active_subdomains);
384 const std::vector<Real> & values,
386 const std::vector<std::set<subdomain_id_type>> & vars_active_subdomains,
387 const std::vector<std::string> & derived_var_names,
388 const std::map<
subdomain_id_type, std::vector<std::string>> & subdomain_to_var_names);
444 std::vector<std::string>
get_complex_names(
const std::vector<std::string> & names)
const;
451 const std::vector<std::set<subdomain_id_type>> & vars_active_subdomains)
const;
460 std::map<subdomain_id_type, std::vector<std::string>>
462 const std::map<
subdomain_id_type, std::vector<std::string>> & subdomain_to_var_names)
const;
482 void message(
const std::string & msg);
489 void message(
const std::string & msg,
int i);
756 bool single_precision_in);
781 bool single_precision_in);
803 std::vector<std::string> & result);
810 const std::vector<std::string> & names);
993 NamesData(
size_t n_strings,
size_t string_length);
1022 #endif // LIBMESH_HAVE_EXODUS_API
1024 #endif // LIBMESH_EXODUSII_IO_HELPER_H
ExodusII_IO_Helper(const ParallelObject &parent, bool v=false, bool run_only_on_proc0=true, bool single_precision=false)
Constructor.
std::map< int, std::string > id_to_ss_names
std::vector< std::vector< char > > data_table
int get_block_id(int index)
Get the block number for the given block index.
std::vector< std::string > global_var_names
const ExodusII_IO_Helper::Conversion & get_conversion(const ElemType type) const
std::vector< int > node_num_map
std::vector< char * > data_table_pointers
std::vector< int > node_sets_dist_index
std::map< int, int > libmesh_node_num_to_exodus
std::string exodus_elem_type() const
std::string current_filename
const std::vector< int > * side_map
Pointer to the side map for this element.
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< int > side_list
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 ...
void read_header()
Reads an ExodusII mesh file header.
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.
ElemType libmesh_type
The canonical (i.e.
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.
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().
int get_node_map(int i) const
std::vector< float > float_vec
std::vector< std::string > nodal_var_names
std::vector< int > block_ids
void print_header()
Prints the ExodusII mesh file header, which includes the mesh title, the number of nodes,...
std::map< int, int > libmesh_elem_num_to_exodus
This is the ExodusII_IO_Helper class.
int get_side_set_id(int index)
Get the side set id for the given side set index.
std::vector< int > edge_block_ids
The libMesh namespace provides an interface to certain functionality in the library.
std::vector< int > num_node_df_per_set
std::vector< Real > elem_var_values
std::vector< int > num_sides_per_set
std::vector< double > double_vec
virtual void create(std::string filename)
Opens an ExodusII mesh file named filename for writing.
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...
int get_shellface_map(int i) const
void write_as_dimension(unsigned dim)
Sets the value of _write_as_dimension.
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.
void read_nodes()
Reads the nodal data (x,y,z coordinates) from the ExodusII mesh file.
const std::vector< int > * inverse_side_map
Pointer to the inverse side map for this element.
std::map< int, std::string > id_to_ns_names
std::map< ElemType, ExodusII_IO_Helper::Conversion > conversion_map
Associates libMesh ElemTypes with node/face/edge/etc.
bool _global_vars_initialized
void read_sideset(int id, int offset)
Reads information about sideset id and inserts it into the global sideset array at the position offse...
void read_block_info()
Reads information for all of the blocks in the ExodusII mesh file.
const std::vector< int > * shellface_map
Pointer to the shellface map for this element.
std::vector< int > node_sets_node_list
void read_num_time_steps()
Reads the number of timesteps currently stored in the Exodus file and stores it in the num_time_steps...
~MappedOutputVector()=default
void read_node_num_map()
Reads the optional node_num_map from the ExodusII mesh file.
std::vector< std::set< subdomain_id_type > > get_complex_vars_active_subdomains(const std::vector< std::set< subdomain_id_type >> &vars_active_subdomains) const
returns a "tripled" copy of vars_active_subdomains, which is necessary in the complex-valued case.
void read_time_steps()
Reads and stores the timesteps in the 'time_steps' array.
void print_nodes(std::ostream &out=libMesh::out)
Prints the nodal information, by default to libMesh::out.
This is the MeshBase class.
std::vector< int > ss_ids
void init_element_equivalence_map()
std::vector< std::string > elem_var_names
This class facilitates inline conversion of an input data vector to a different precision level,...
const std::vector< int > * node_map
Pointer to the node map for this element.
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,...
std::vector< char > title
std::vector< int > nodeset_ids
void initialize_nodal_variables(std::vector< std::string > names)
Sets up the nodal variables.
const std::vector< Real > & our_data
bool _use_mesh_dimension_instead_of_spatial_dimension
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 write_var_names_impl(const char *var_type, int &count, const std::vector< std::string > &names)
write_var_names() dispatches to this function.
bool _elem_vars_initialized
std::map< int, std::string > id_to_edge_block_names
MappedOutputVector(const std::vector< Real > &vec_in, bool single_precision_in)
std::vector< int > num_df_per_set
int get_side_map(int i) const
static const int invalid_id
An invalid_id that can be returned to signal failure in case something goes wrong.
A Point defines a location in LIBMESH_DIM dimensional Real space.
virtual ~ExodusII_IO_Helper()
ExodusII_IO_Helper & operator=(const ExodusII_IO_Helper &)=default
virtual void write_sidesets(const MeshBase &mesh)
Writes the sidesets contained in "mesh".
virtual void write_nodal_coordinates(const MeshBase &mesh, bool use_discontinuous=false)
Writes the nodal coordinates contained in "mesh".
std::vector< int > exodus_elem_num_to_libmesh
unsigned _write_as_dimension
void write_timestep(int timestep, Real time)
Writes the time for the timestep.
void read_global_values(std::vector< Real > &values, int timestep)
Reads the vector of global variables.
ExodusVarType
Wraps calls to exII::ex_get_var_names() and exII::ex_get_var_param().
std::vector< char > elem_type
std::map< std::string, ElemType > element_equivalence_map
Defines equivalence classes of Exodus element types that map to libmesh ElemTypes.
void read_edge_blocks(MeshBase &mesh)
Read in edge blocks, storing information in the BoundaryInfo object.
void read_sideset_info()
Reads information about all of the sidesets in the ExodusII mesh file.
void open(const char *filename, bool read_only)
Opens an ExodusII mesh file named filename.
std::vector< int > id_list
void write_nodal_values(int var_id, const std::vector< Real > &values, int timestep)
Writes the vector of values to a nodal variable.
char * get_char_star(int i)
Provide access to the i'th underlying char *.
void close()
Closes the ExodusII mesh file.
const char * get_elem_type() const
void read_nodeset(int id)
Reads information about nodeset id and inserts it into the global nodeset array at the position offse...
void read_var_names(ExodusVarType type)
std::vector< int > exodus_node_num_to_libmesh
void initialize_global_variables(std::vector< std::string > names)
Sets up the global variables.
void read_elem_num_map()
Reads the optional node_num_map from the ExodusII mesh file.
int get_inverse_shellface_map(int i) const
ElemType libmesh_elem_type() const
int get_inverse_node_map(int i) const
char ** get_char_star_star()
Provide access to the underlying C data table.
void init_conversion_map()
std::string exodus_type
The string corresponding to the Exodus type for this element.
void read_elem_in_block(int block)
Reads all of the element connectivity for block block in the ExodusII mesh file.
std::vector< int > num_nodes_per_set
std::map< int, std::string > id_to_block_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.
virtual void initialize(std::string title, const MeshBase &mesh, bool use_discontinuous=false)
Initializes the Exodus file.
virtual void write_elements(const MeshBase &mesh, bool use_discontinuous=false)
Writes the elements contained in "mesh".
std::vector< int > elem_list
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.
void set_coordinate_offset(Point p)
Allows you to set a vector that is added to the coordinates of all of the nodes.
std::vector< int > node_sets_node_index
int get_inverse_side_map(int i) const
NamesData(size_t n_strings, size_t string_length)
Constructor.
const std::vector< int > * inverse_shellface_map
Pointer to the inverse shellface map for this element.
std::vector< Real > nodal_var_values
size_t shellface_index_offset
The shellface index offset defines the offset due to a difference between libMesh and Exodus in index...
This class is useful for managing anything that requires a char ** input/output in ExodusII file.
void message(const std::string &msg)
Prints the message defined in msg.
virtual void write_nodesets(const MeshBase &mesh)
Writes the nodesets contained in "mesh".
std::vector< std::string > sideset_var_names
std::size_t get_shellface_index_offset() const
void read_qa_records()
Reads the QA records from an ExodusII file.
std::vector< int > node_list
void push_back_entry(const std::string &name)
Adds another name to the current data table.
std::vector< int > connect
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) const
Takes a map from subdomain id -> vector of active variable names as input and returns a corresponding...
std::vector< Real > node_sets_dist_fact
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void write_global_values(const std::vector< Real > &values, int timestep)
Writes the vector of global variables.
An object whose state is distributed along a set of processors.
int inquire(int req_info, std::string error_msg="")
void read_all_nodesets()
New API that reads all nodesets simultaneously.
void write_information_records(const std::vector< std::string > &records)
Writes the vector of information records.
std::vector< Real > time_steps
bool _nodal_vars_initialized
int num_elem_all_sidesets
void read_nodeset_info()
Reads information about all of the nodesets in the ExodusII mesh file.
int get_node_set_id(int index)
Get the node set id for the given node set index.
std::vector< std::string > get_complex_names(const std::vector< std::string > &names) const
void read_var_names_impl(const char *var_type, int &count, std::vector< std::string > &result)
read_var_names() dispatches to this function.
const std::vector< int > * inverse_node_map
Pointer to the inverse node map for this element.
std::string get_block_name(int index)
Get the block name for the given block index if supplied in the mesh file.
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
ElemType
Defines an enum for geometric element types.
std::vector< int > elem_num_map
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.