libMesh
exodusII_io_helper.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2024 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 #ifndef LIBMESH_EXODUSII_IO_HELPER_H
19 #define LIBMESH_EXODUSII_IO_HELPER_H
20 
21 #include "libmesh/libmesh_config.h"
22 
23 #ifdef LIBMESH_HAVE_EXODUS_API
24 
25 // Local includes
26 #include "libmesh/parallel_object.h"
27 #include "libmesh/point.h"
28 #include "libmesh/boundary_info.h" // BoundaryInfo::BCTuple
29 #include "libmesh/enum_elem_type.h" // INVALID_ELEM
30 #include "libmesh/exodus_header_info.h"
31 
32 // C++ includes
33 #include <iostream>
34 #include <string>
35 #include <vector>
36 #include <map>
37 
38 // Macros to simplify checking Exodus error codes
39 #define EX_CHECK_ERR(code, msg) \
40  do { \
41  if ((code) < 0) { \
42  libmesh_error_msg((msg)); \
43  } } while (0)
44 
45 #define EX_EXCEPTIONLESS_CHECK_ERR(code, msg) \
46  do { \
47  if ((code) < 0) { \
48  libMesh::err << (msg) << std::endl; \
49  libmesh_exceptionless_error(); \
50  } } while (0)
51 
52 // Before we include a header wrapped in a namespace, we'd better make
53 // sure none of its dependencies end up in that namespace
54 #include <errno.h>
55 #include <stddef.h>
56 #include <stdlib.h>
57 #include <stdint.h>
58 
59 namespace libMesh
60 {
61 
62 // Forward declarations
63 class MeshBase;
64 
74 {
75 public:
83  ExodusII_IO_Helper(const ParallelObject & parent,
84  bool v=false,
85  bool run_only_on_proc0=true,
86  bool single_precision=false);
93  ExodusII_IO_Helper (const ExodusII_IO_Helper &) = default;
95  virtual ~ExodusII_IO_Helper();
96 
103 
108  static int get_exodus_version();
109 
116  const char * get_elem_type() const;
117 
122  void set_add_sides(bool add_sides);
123 
124  bool get_add_sides();
125 
131  void open(const char * filename, bool read_only);
132 
138 
144 
150  void read_qa_records();
151 
157  void print_header();
158 
163  void read_nodes();
164 
169  void read_node_num_map();
170 
175  void read_bex_cv_blocks();
176 
180  void print_nodes(std::ostream & out_stream = libMesh::out);
181 
186  void read_block_info();
187 
191  int get_block_id(int index);
192 
197  std::string get_block_name(int index);
198 
202  int get_side_set_id(int index);
203 
208  std::string get_side_set_name(int index);
209 
213  int get_node_set_id(int index);
214 
219  std::string get_node_set_name(int index);
220 
225  void read_elem_in_block(int block);
226 
231 
236  void read_elem_num_map();
237 
242  void read_sideset_info();
243 
248  void read_nodeset_info();
249 
254  void read_elemset_info();
255 
260  void read_sideset(int id, int offset);
261 
266  void read_elemset(int id, int offset);
267 
273  void read_all_nodesets();
274 
281  void close() noexcept;
282 
286  void read_time_steps();
287 
292  void read_num_time_steps();
293 
298  void read_nodal_var_values(std::string nodal_var_name, int time_step);
299 
304  void read_elemental_var_values(std::string elemental_var_name,
305  int time_step,
306  std::map<dof_id_type, Real> & elem_var_value_map);
307 
311  virtual void create(std::string filename);
312 
316  virtual void initialize(std::string title, const MeshBase & mesh, bool use_discontinuous=false);
317 
321  virtual void write_nodal_coordinates(const MeshBase & mesh, bool use_discontinuous=false);
322 
337  virtual void write_elements(const MeshBase & mesh,
338  bool use_discontinuous=false);
339 
343  virtual void write_sidesets(const MeshBase & mesh);
344 
348  virtual void write_nodesets(const MeshBase & mesh);
349 
353  virtual void initialize_element_variables(std::vector<std::string> names,
354  const std::vector<std::set<subdomain_id_type>> & vars_active_subdomains);
355 
359  void initialize_nodal_variables(std::vector<std::string> names);
360 
364  void initialize_global_variables(std::vector<std::string> names);
365 
369  void write_timestep(int timestep, Real time);
370 
374  void write_elemsets(const MeshBase & mesh);
375 
379  void
381  int timestep,
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);
385 
389  void
391  int timestep,
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);
395 
406  void
408  std::map<BoundaryInfo::BCTuple, unsigned int> & bc_array_indices);
409 
413  void
414  write_nodeset_data (int timestep,
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);
418 
422  void
423  read_nodeset_data (int timestep,
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);
427 
435  void
436  get_nodeset_data_indices (std::map<BoundaryInfo::NodeBCTuple, unsigned int> & bc_array_indices);
437 
441  void
442  write_elemset_data (int timestep,
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);
446 
450  void
451  read_elemset_data (int timestep,
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);
455 
463  void
464  get_elemset_data_indices (std::map<std::pair<dof_id_type, elemset_id_type>, unsigned int> & elemset_array_indices);
465 
478  (const MeshBase & mesh,
479  const std::vector<Real> & values,
480  int timestep,
481  const std::vector<std::set<subdomain_id_type>> & vars_active_subdomains);
482 
498  (const MeshBase & mesh,
499  const std::vector<Real> & values,
500  int timestep,
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);
504 
508  void write_nodal_values(int var_id, const std::vector<Real> & values, int timestep);
509 
513  void write_information_records(const std::vector<std::string> & records);
514 
518  void write_global_values(const std::vector<Real> & values, int timestep);
519 
523  void update();
524 
528  void read_global_values(std::vector<Real> & values, int timestep);
529 
539 
546  void set_hdf5_writing(bool write_hdf5);
547 
560  void write_as_dimension(unsigned dim);
561 
567 
574  std::vector<std::string>
575  get_complex_names(const std::vector<std::string> & names,
576  bool write_complex_abs) const;
577 
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;
586 
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;
598 
604  class Conversion;
605 
611  class NamesData;
612 
617  void message(std::string_view msg);
618 
624  void message(std::string_view msg, int i);
625 
626  // File identification flag
627  int ex_id;
628 
629  // General error flag
630  int ex_err;
631 
632  // struct which contains data fields from the Exodus file header
634 
635  // Problem title (Use vector<char> to emulate a char *)
636  std::vector<char> & title;
637 
638  // Number of dimensions in the mesh
639  int & num_dim;
640 
641  // Total number of nodes in the mesh
642  int & num_nodes;
643 
644  // Total number of elements in the mesh
645  int & num_elem;
646 
647  // Smallest element id which exceeds every element id in the mesh.
648  // (this may exceed num_elem due to mapping)
649  int end_elem_id() const;
650 
651  // Total number of element blocks
653 
654  // Total number of edges
655  int & num_edge;
656 
657  // Total number of edge blocks. The sum of the number of edges in
658  // each block must equal num_edge.
660 
661  // Total number of node sets
663 
664  // Total number of side sets
666 
667  // Total number of element sets
669 
670  // Number of global variables
672 
673  // Number of sideset variables
675 
676  // Number of nodeset variables
678 
679  // Number of elemset variables
681 
682  // Number of elements in this block
684 
685  // Number of nodes in each element
687 
688  // Number of attributes for a given block
689  int num_attr;
690 
691  // Total number of elements in all side sets
693 
694  // Total number of elements in all elem sets
696 
697  // Vector of element block identification numbers
698  std::vector<int> block_ids;
699 
700  // Vector of edge block identification numbers
701  std::vector<int> edge_block_ids;
702 
703  // Vector of nodes in an element
704  std::vector<int> connect;
705 
706  // Vector of the sideset IDs
707  std::vector<int> ss_ids;
708 
709  // Vector of the nodeset IDs
710  std::vector<int> nodeset_ids;
711 
712  // Vector of the elemset IDs
713  std::vector<int> elemset_ids;
714 
715  // Number of sides in each sideset
716  std::vector<int> num_sides_per_set;
717 
718  // Number of nodes in each nodeset
719  std::vector<int> num_nodes_per_set;
720 
721  // Number of elems in each elemset
722  std::vector<int> num_elems_per_set;
723 
724  // Number of distribution factors per sideset
725  std::vector<int> num_df_per_set;
726 
727  // Number of distribution factors per nodeset
728  std::vector<int> num_node_df_per_set;
729 
730  // Number of distribution factors per elemset
731  std::vector<int> num_elem_df_per_set;
732 
733  // Starting indices for each nodeset in the node_sets_node_list vector.
734  // Used in the calls to ex_{put,get}_concat_node_sets().
735  std::vector<int> node_sets_node_index;
736 
737  // Starting indices for each nodeset in the node_sets_dist_fact vector.
738  // Used in the calls to ex_{put,get}_concat_node_sets().
739  std::vector<int> node_sets_dist_index;
740 
741  // Node ids for all nodes in nodesets, concatenated together.
742  // Used in the calls to ex_{put,get}_concat_node_sets().
743  std::vector<int> node_sets_node_list;
744 
745  // Distribution factors for all nodes in all nodesets, concatenated together.
746  // Used in the calls to ex_{put,get}_concat_node_sets().
747  std::vector<Real> node_sets_dist_fact;
748 
749  // List of element numbers in all sidesets
750  std::vector<int> elem_list;
751 
752  // Side (face/edge) number actually on the boundary
753  std::vector<int> side_list;
754 
755  // Side (face/edge) id number
756  std::vector<int> id_list;
757 
758  // List of element numbers in all elemsets
759  std::vector<int> elemset_list;
760 
761  // List of elemset ids for all elements in elemsets
762  std::vector<int> elemset_id_list;
763 
764  // Optional mapping from internal [0,num_nodes) to arbitrary indices
765  std::vector<int> node_num_map;
766 
767  // Optional mapping from internal [0,num_elem) to arbitrary indices
768  std::vector<int> elem_num_map;
769 
770  // x locations of node points
771  std::vector<Real> x;
772 
773  // y locations of node points
774  std::vector<Real> y;
775 
776  // z locations of node points
777  std::vector<Real> z;
778 
779  // Spline weights associated with node points, in IGA meshes
780  std::vector<Real> w;
781 
782  // Number of Bezier Extraction coefficient vectors in a block
783  unsigned int bex_num_elem_cvs;
784 
785  // Bezier Extraction connectivity indices, in IGA meshes
786  std::vector<std::vector<long unsigned int>> bex_cv_conn;
787 
788  // Bezier Extraction coefficient vectors, in IGA meshes
789  // bex_dense_constraint_vecs[block_num][vec_num][column_num] = coef
790  std::vector<std::vector<std::vector<Real>>> bex_dense_constraint_vecs;
791 
792  // Type of element in a given block
793  std::vector<char> elem_type;
794 
795  // Maps libMesh element numbers to Exodus element numbers
796  // gets filled in when write_elements gets called
797  std::map<dof_id_type, dof_id_type> libmesh_elem_num_to_exodus;
798  std::vector<int> exodus_elem_num_to_libmesh;
799 
800  // Map of all node numbers connected to local node numbers to their exodus numbering.
801  // The exodus numbers are stored in here starting with 1
802  std::map<dof_id_type, dof_id_type> libmesh_node_num_to_exodus;
803  std::vector<int> exodus_node_num_to_libmesh;
804 
805  // The number of timesteps in the file, as returned by ex_inquire
807 
808  // The timesteps stored in the solution file, filled by read_time_steps()
809  std::vector<Real> time_steps;
810 
811  // The number of nodal variables in the Exodus file
813 
814  // The names of the nodal variables stored in the Exodus file
815  std::vector<std::string> nodal_var_names;
816 
817  // Holds the nodal variable values for a given variable, one value
818  // per node, indexed by libMesh node id.
819  // This is a map so it can handle Nemesis files as well.
820  std::map<dof_id_type, Real> nodal_var_values;
821 
822  // The number of elemental variables in the Exodus file
824 
825  // The names of the elemental variables stored in the Exodus file
826  std::vector<std::string> elem_var_names;
827 
828  // Holds the elemental variable values for a given variable, one value per element
829  std::vector<Real> elem_var_values;
830 
831  // The names of the global variables stored in the Exodus file
832  std::vector<std::string> global_var_names;
833 
834  // The names of the sideset variables stored in the Exodus file
835  std::vector<std::string> sideset_var_names;
836 
837  // The names of the nodeset variables stored in the Exodus file
838  std::vector<std::string> nodeset_var_names;
839 
840  // The names of the elemset variables stored in the Exodus file
841  std::vector<std::string> elemset_var_names;
842 
843  // Maps of Ids to named entities
844  std::map<int, std::string> id_to_block_names;
845  std::map<int, std::string> id_to_edge_block_names;
846  std::map<int, std::string> id_to_ss_names;
847  std::map<int, std::string> id_to_ns_names;
848  std::map<int, std::string> id_to_elemset_names;
849 
850  // On/Off message flag
851  bool verbose;
852 
853  // This flag gets set after the Exodus file has been successfully opened for writing.
854  // Both the create() and open() (if called with EX_WRITE) functions may set this flag.
856 
857  // This flag gets set after the open() function has been successfully called.
858  // We call open() to open an ExodusII file for reading.
860 
861  // When either create() or open() is called, the Helper stores the
862  // name of the opened file as current_filename. This way, the
863  // ExodusII_IO object can check to see if, on subsequent writes, the
864  // user is asking to write to a *different* filename from the one
865  // that is currently open, and signal an error. The current
866  // ExodusII_IO implementation is designed to work with a single file
867  // only, so if you want to write to multiple Exodus files, use a
868  // different ExodusII_IO object for each one.
869  std::string current_filename;
870 
882  void read_var_names(ExodusVarType type);
883 
885  get_conversion(const ElemType type) const;
886 
888  get_conversion(std::string type_str) const;
889 
890  /*
891  * Returns the sum of node "offsets" that are to be expected from a
892  * parallel nodal solution vector that has had "fake" nodes added on
893  * each processor. This plus a node id gives a valid nodal solution
894  * vector index.
895  */
897  {
898  if (_added_side_node_offsets.empty())
899  return n;
900 
901  // Find the processor id that has node_id in the parallel vec
902  const auto lb = std::upper_bound(_true_node_offsets.begin(),
903  _true_node_offsets.end(), n);
904  libmesh_assert(lb != _true_node_offsets.end());
905  const processor_id_type p = lb - _true_node_offsets.begin();
906 
907  return n + (p ? _added_side_node_offsets[p-1] : 0);
908  }
909 
910  /*
911  * Returns the sum of both added node "offsets" on processors 0
912  * through p-1 and real nodes added on processors 0 to p.
913  * This is the starting index for added nodes' data.
914  */
916  {
917  libmesh_assert (p < _true_node_offsets.size());
918  const dof_id_type added_node_offsets =
919  (_added_side_node_offsets.empty() || !p) ? 0 :
921  return _true_node_offsets[p] + added_node_offsets;
922  }
923 
924 
925 protected:
930  void check_existing_vars(ExodusVarType type, std::vector<std::string> & names, std::vector<std::string> & names_from_file);
931 
937  void write_var_names(ExodusVarType type, const std::vector<std::string> & names);
938 
939  // If true, whenever there is an I/O operation, only perform if if we are on processor 0.
941 
942  // This flag gets set after the create() function has been successfully called.
944 
945  // True once the elem vars are initialized
947 
948  // True once the global vars are initialized
950 
951  // True once the nodal vars are initialized
953 
954  // If true, use the Mesh's dimension (as determined by the dimension
955  // of the elements comprising the mesh) instead of the mesh's
956  // spatial dimension, when writing. By default this is false.
958 
959  // If true, write an HDF5 file when available. If false, write the
960  // old format.
962 
963  // Set once the elem num map has been read
965 
966  // Use this for num_dim when writing the Exodus file. If non-zero, supersedes
967  // any value set in _use_mesh_dimension_instead_of_spatial_dimension.
969 
970  // On output, shift every point by _coordinate_offset
972 
973  // If true, forces single precision I/O
975 
982  std::vector<dof_id_type> _added_side_node_offsets;
983 
989  std::vector<dof_id_type> _true_node_offsets;
990 
1001  {
1002  // If necessary, allocates space to store a version of vec_in in a
1003  // different precision than it was input with.
1004  MappedOutputVector(const std::vector<Real> & vec_in,
1005  bool single_precision_in);
1006 
1007  ~MappedOutputVector() = default;
1008 
1009  // Returns void * pointer to either the mapped data or the
1010  // original data, as necessary.
1011  void * data();
1012 
1013  private:
1014  const std::vector<Real> & our_data;
1016  std::vector<double> double_vec;
1017  std::vector<float> float_vec;
1018  };
1019 
1028  {
1029  MappedInputVector(std::vector<Real> & vec_in,
1030  bool single_precision_in);
1032 
1033  // Returns void * pointer to either the mapped data or the
1034  // original data, as necessary.
1035  void * data();
1036 
1037  private:
1038  std::vector<Real> & our_data;
1040  std::vector<double> double_vec;
1041  std::vector<float> float_vec;
1042  };
1043 
1044 
1045 protected:
1046 
1051  virtual void read_var_names_impl(const char * var_type,
1052  int & count,
1053  std::vector<std::string> & result);
1054 
1055 private:
1056 
1060  bool _add_sides = false;
1061 
1065  void write_var_names_impl(const char * var_type,
1066  int & count,
1067  const std::vector<std::string> & names);
1068 
1073  std::map<std::string, ElemType> element_equivalence_map;
1075 
1084  std::map<int, std::map<ElemType, ExodusII_IO_Helper::Conversion>> conversion_map;
1085  void init_conversion_map();
1086 };
1087 
1088 
1089 
1091 {
1092 public:
1093 
1098  : node_map(nullptr),
1099  inverse_node_map(nullptr),
1100  side_map(nullptr),
1101  inverse_side_map(nullptr),
1102  shellface_map(nullptr),
1103  inverse_shellface_map(nullptr),
1106  dim(0),
1107  n_nodes(0),
1108  exodus_type("")
1109  {}
1110 
1117  int get_node_map(int i) const;
1118 
1129  int get_inverse_node_map(int i) const;
1130 
1137  int get_side_map(int i) const;
1138 
1145  int get_inverse_side_map(int i) const;
1146 
1151  int get_shellface_map(int i) const;
1152 
1156  int get_inverse_shellface_map(int i) const;
1157 
1164  ElemType libmesh_elem_type() const;
1165 
1169  std::string exodus_elem_type() const;
1170 
1174  std::size_t get_shellface_index_offset() const;
1175 
1180  static const int invalid_id;
1181 
1185  const std::vector<int> * node_map;
1186 
1192  const std::vector<int> * inverse_node_map;
1193 
1197  const std::vector<int> * side_map;
1198 
1202  const std::vector<int> * inverse_side_map;
1203 
1209  const std::vector<int> * shellface_map;
1210 
1214  const std::vector<int> * inverse_shellface_map;
1215 
1222 
1228 
1233  int dim;
1234 
1238  int n_nodes;
1239 
1243  std::string exodus_type;
1244 };
1245 
1246 
1247 
1254 {
1255 public:
1261  explicit
1262  NamesData(size_t n_strings, size_t string_length);
1263 
1267  void push_back_entry(const std::string & name);
1268 
1272  char ** get_char_star_star();
1273 
1277  char * get_char_star(int i);
1278 
1279 private:
1280  // C++ data structures for managing string memory
1281  std::vector<std::vector<char>> data_table;
1282  std::vector<char *> data_table_pointers;
1283 
1284  size_t counter;
1285  size_t table_size;
1286 };
1287 
1288 
1289 inline void ExodusII_IO_Helper::set_add_sides(bool add_sides)
1290 {
1291  _add_sides = add_sides;
1292 }
1293 
1294 
1296 {
1297  return _add_sides;
1298 }
1299 
1300 
1302 {
1303  libmesh_assert_equal_to(std::size_t(num_elem), elem_num_map.size());
1304  return _end_elem_id;
1305 }
1306 
1307 
1308 } // namespace libMesh
1309 
1310 #endif // LIBMESH_HAVE_EXODUS_API
1311 
1312 #endif // LIBMESH_EXODUSII_IO_HELPER_H
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.
Definition: elem_quality.C:42
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.
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
void read_node_num_map()
Reads the optional node_num_map from the ExodusII mesh file.
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&#39;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
This class is used as both an external data structure for passing around Exodus file header informati...
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 &#39;nodal_var_name&#39; at the specified time into the &#39;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.
unsigned int dim
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.
MeshBase & mesh
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
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&#39;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 &#39;time_steps&#39; array.
std::vector< int > node_sets_node_index
std::vector< char > & title
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
Definition: id_types.h:104
This is the MeshBase class.
Definition: mesh_base.h:74
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.
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.
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&#39;th underlying char *.
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< std::string > global_var_names
int dim
The element dimension; useful since we don&#39;t seem to have a cheap way to look this up from ElemType...
MappedInputVector(std::vector< Real > &vec_in, bool single_precision_in)
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.
void read_elemset_info()
Reads information about all of the elemsets in the ExodusII mesh file.
libmesh_assert(ctx)
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.
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 &#39;values&#39; vector is in element-major order...
This class facilitates reading in vectors from Exodus file that may be of a different floating point ...
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.
std::vector< dof_id_type > _true_node_offsets
If we&#39;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::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.
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.
std::vector< Real > elem_var_values
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.
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.
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&#39;re adding "fake" sides to visualize SIDE_DISCONTINUOUS variables, _added_side_node_offsets[p] g...
OStreamProxy out
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 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
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::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.
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 &#39;elemental_var_name&#39; at the specified timestep into the &#39;elem...
std::vector< Real > node_sets_dist_fact
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:39
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
std::vector< int > elemset_id_list
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
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
uint8_t dof_id_type
Definition: id_types.h:67
std::vector< std::vector< std::vector< Real > > > bex_dense_constraint_vecs