libMesh
exodusII_io.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2019 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 
19 
20 #ifndef LIBMESH_EXODUSII_IO_H
21 #define LIBMESH_EXODUSII_IO_H
22 
23 
24 // Local includes
25 #include "libmesh/libmesh_common.h"
26 #include "libmesh/mesh_input.h"
27 #include "libmesh/mesh_output.h"
28 #include "libmesh/parallel_object.h"
29 #include "libmesh/boundary_info.h" // BoundaryInfo::BCTuple
30 
31 namespace libMesh
32 {
33 
34 // Forward declarations
35 class EquationSystems;
36 class ExodusII_IO_Helper;
37 class MeshBase;
38 class System;
39 
51 class ExodusII_IO : public MeshInput<MeshBase>,
52  public MeshOutput<MeshBase>,
53  public ParallelObject
54 {
55 public:
56 
61  explicit
63  bool single_precision=false);
64 
68  virtual ~ExodusII_IO ();
69 
77  virtual void read (const std::string & name) override;
78 
82  virtual void write (const std::string & fname) override;
83 
87  void verbose (bool set_verbosity);
88 
92  const std::vector<Real> & get_time_steps();
93 
103  int get_num_time_steps();
104 
110 #ifdef LIBMESH_ENABLE_DEPRECATED
111  void copy_nodal_solution(System & system,
112  std::string var_name,
113  unsigned int timestep=1);
114 #endif
115 
120  void copy_nodal_solution(System & system,
121  std::string system_var_name,
122  std::string exodus_var_name,
123  unsigned int timestep=1);
124 
129  void copy_elemental_solution(System & system,
130  std::string system_var_name,
131  std::string exodus_var_name,
132  unsigned int timestep=1);
133 
137  void copy_scalar_solution(System & system,
138  std::vector<std::string> system_var_names,
139  std::vector<std::string> exodus_var_names,
140  unsigned int timestep=1);
141 
153  void read_elemental_variable(std::string elemental_var_name,
154  unsigned int timestep,
155  std::map<unsigned int, Real> & unique_id_to_value_map);
156 
164  void read_global_variable(std::vector<std::string> global_var_names,
165  unsigned int timestep,
166  std::vector<Real> & global_values);
167 
171  void write_discontinuous_exodusII (const std::string & name,
172  const EquationSystems & es,
173  const std::set<std::string> * system_names=nullptr);
174 
183  void write_timestep_discontinuous (const std::string &fname,
184  const EquationSystems &es,
185  const int timestep,
186  const Real time,
187  const std::set<std::string> * system_names=nullptr);
188 
192  void write_element_data (const EquationSystems & es);
193 
215  void
217  (const EquationSystems & es,
218  const std::set<std::string> * system_names = nullptr,
219  const std::string & var_suffix = "_elem_node_");
220 
227 
231  virtual void write_nodal_data (const std::string &,
232  const std::vector<Number> &,
233  const std::vector<std::string> &) override;
234 
238  void write_nodal_data_discontinuous (const std::string &,
239  const std::vector<Number> &,
240  const std::vector<std::string> &) override;
241 
245  void write_global_data (const std::vector<Number> &,
246  const std::vector<std::string> &);
247 
251  void write_information_records (const std::vector<std::string> &);
252 
261  void write_timestep (const std::string & fname,
262  const EquationSystems & es,
263  const int timestep,
264  const Real time,
265  const std::set<std::string> * system_names=nullptr);
266 
281  void
282  write_sideset_data (int timestep,
283  const std::vector<std::string> & var_names,
284  const std::vector<std::set<boundary_id_type>> & side_ids,
285  const std::vector<std::map<BoundaryInfo::BCTuple, Real>> & bc_vals);
286 
293  void
294  read_sideset_data (int timestep,
295  std::vector<std::string> & var_names,
296  std::vector<std::set<boundary_id_type>> & side_ids,
297  std::vector<std::map<BoundaryInfo::BCTuple, Real>> & bc_vals);
298 
307  void set_output_variables(const std::vector<std::string> & output_variables,
308  bool allow_empty = true);
309 
322 
332  void write_as_dimension(unsigned dim);
333 
349 
355  void append(bool val);
356 
360  const std::vector<std::string> & get_elem_var_names();
361 
365  const std::vector<std::string> & get_nodal_var_names();
366 
370  const std::vector<std::string> & get_global_var_names();
371 
372 #ifdef LIBMESH_HAVE_EXODUS_API
373 
377 #endif
378 
383  void write_nodal_data_common(std::string fname,
384  const std::vector<std::string> & names,
385  bool continuous=true);
386 
387 private:
393 #ifdef LIBMESH_HAVE_EXODUS_API
394  std::unique_ptr<ExodusII_IO_Helper> exio_helper;
395 
401 
405  bool _verbose;
406 
411  bool _append;
412 #endif
413 
418  std::vector<std::string> _output_variables;
419 
426 
427 };
428 
429 
430 } // namespace libMesh
431 
432 
433 #endif // LIBMESH_EXODUSII_IO_H
libMesh::ExodusII_IO::write_nodal_data_common
void write_nodal_data_common(std::string fname, const std::vector< std::string > &names, bool continuous=true)
This function factors out a bunch of code which is common to the write_nodal_data() and write_nodal_d...
Definition: exodusII_io.C:1429
libMesh::System
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition: system.h:100
libMesh::ExodusII_IO::copy_elemental_solution
void copy_elemental_solution(System &system, std::string system_var_name, std::string exodus_var_name, unsigned int timestep=1)
If we read in a elemental solution while reading in a mesh, we can attempt to copy that elemental sol...
Definition: exodusII_io.C:529
libMesh::ExodusII_IO::read_global_variable
void read_global_variable(std::vector< std::string > global_var_names, unsigned int timestep, std::vector< Real > &global_values)
Given a vector of global variables and a time step, returns the values of the global variable at the ...
Definition: exodusII_io.C:630
libMesh::ExodusII_IO::write_as_dimension
void write_as_dimension(unsigned dim)
Directly control the num_dim which is written to the Exodus file.
Definition: exodusII_io.C:451
libMesh::ExodusII_IO::verbose
void verbose(bool set_verbosity)
Set the flag indicating if we should be verbose.
Definition: exodusII_io.C:434
libMesh::ExodusII_IO_Helper
This is the ExodusII_IO_Helper class.
Definition: exodusII_io_helper.h:80
libMesh::ExodusII_IO::write_sideset_data
void write_sideset_data(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)
The Exodus format can also store values on sidesets.
Definition: exodusII_io.C:1305
libMesh
The libMesh namespace provides an interface to certain functionality in the library.
Definition: factoryfunction.C:55
libMesh::ExodusII_IO::write_element_data
void write_element_data(const EquationSystems &es)
Write out element solution.
Definition: exodusII_io.C:662
libMesh::ExodusII_IO::copy_scalar_solution
void copy_scalar_solution(System &system, std::vector< std::string > system_var_names, std::vector< std::string > exodus_var_names, unsigned int timestep=1)
Copy global variables into scalar variables of a System object.
Definition: exodusII_io.C:571
libMesh::ExodusII_IO::_timestep
int _timestep
Stores the current value of the timestep when calling ExodusII_IO::write_timestep().
Definition: exodusII_io.h:400
libMesh::ExodusII_IO::get_num_time_steps
int get_num_time_steps()
Definition: exodusII_io.C:484
libMesh::ExodusII_IO::get_exio_helper
ExodusII_IO_Helper & get_exio_helper()
Return a reference to the ExodusII_IO_Helper object.
Definition: exodusII_io.C:1499
libMesh::ExodusII_IO::write_timestep
void write_timestep(const std::string &fname, const EquationSystems &es, const int timestep, const Real time, const std::set< std::string > *system_names=nullptr)
Writes out the solution at a specific timestep.
Definition: exodusII_io.C:1286
libMesh::ExodusII_IO
The ExodusII_IO class implements reading meshes in the ExodusII file format from Sandia National Labs...
Definition: exodusII_io.h:51
dim
unsigned int dim
Definition: adaptivity_ex3.C:113
libMesh::ExodusII_IO::write_discontinuous_exodusII
void write_discontinuous_exodusII(const std::string &name, const EquationSystems &es, const std::set< std::string > *system_names=nullptr)
Writes a exodusII file with discontinuous data.
Definition: exodusII_io.C:93
libMesh::ExodusII_IO::write_information_records
void write_information_records(const std::vector< std::string > &)
Write out information records.
Definition: exodusII_io.C:1220
libMesh::ExodusII_IO::write_element_data_from_discontinuous_nodal_data
void write_element_data_from_discontinuous_nodal_data(const EquationSystems &es, const std::set< std::string > *system_names=nullptr, const std::string &var_suffix="_elem_node_")
Similar to the function above, but instead of only handling (CONSTANT, MONOMIAL) data,...
Definition: exodusII_io.C:766
libMesh::ExodusII_IO::use_mesh_dimension_instead_of_spatial_dimension
void use_mesh_dimension_instead_of_spatial_dimension(bool val)
In the general case, meshes containing 2D elements can be manifolds living in 3D space,...
Definition: exodusII_io.C:444
libMesh::ExodusII_IO::write_global_data
void write_global_data(const std::vector< Number > &, const std::vector< std::string > &)
Write out global variables.
Definition: exodusII_io.C:1233
libMesh::ExodusII_IO::write_nodal_data
virtual void write_nodal_data(const std::string &, const std::vector< Number > &, const std::vector< std::string > &) override
Write out a nodal solution.
Definition: exodusII_io.C:1124
libMesh::ExodusII_IO::_verbose
bool _verbose
should we be verbose?
Definition: exodusII_io.h:405
libMesh::ExodusII_IO::set_coordinate_offset
void set_coordinate_offset(Point p)
Allows you to set a vector that is added to the coordinates of all of the nodes.
Definition: exodusII_io.C:458
libMesh::ExodusII_IO::copy_nodal_solution
void copy_nodal_solution(System &system, std::string var_name, unsigned int timestep=1)
Backward compatibility version of function that takes a single variable name.
Definition: exodusII_io.C:82
libMesh::MeshBase
This is the MeshBase class.
Definition: mesh_base.h:78
libMesh::ExodusII_IO::~ExodusII_IO
virtual ~ExodusII_IO()
Destructor.
Definition: exodusII_io.C:136
libMesh::ExodusII_IO::get_global_var_names
const std::vector< std::string > & get_global_var_names()
Return list of the global variable names.
Definition: exodusII_io.C:1493
libMesh::ExodusII_IO::read_sideset_data
void read_sideset_data(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)
Similar to write_sideset_data(), this function is used to read the data at a particular timestep.
Definition: exodusII_io.C:1322
libMesh::ExodusII_IO::_output_variables
std::vector< std::string > _output_variables
The names of the variables to be output.
Definition: exodusII_io.h:418
libMesh::ExodusII_IO::_append
bool _append
Default false.
Definition: exodusII_io.h:411
libMesh::Point
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:38
libMesh::ExodusII_IO::exio_helper
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:394
libMesh::ExodusII_IO::_allow_empty_variables
bool _allow_empty_variables
If true, _output_variables is allowed to remain empty.
Definition: exodusII_io.h:425
libMesh::ExodusII_IO::get_time_steps
const std::vector< Real > & get_time_steps()
Definition: exodusII_io.C:473
libMesh::ExodusII_IO::get_nodal_var_names
const std::vector< std::string > & get_nodal_var_names()
Return list of the nodal variable names.
Definition: exodusII_io.C:1481
libMesh::ExodusII_IO::append
void append(bool val)
If true, this flag will cause the ExodusII_IO object to attempt to open an existing file for writing,...
Definition: exodusII_io.C:466
libMesh::ExodusII_IO::read_elemental_variable
void read_elemental_variable(std::string elemental_var_name, unsigned int timestep, std::map< unsigned int, Real > &unique_id_to_value_map)
Given an elemental variable and a time step, returns a mapping from the elements (top parent) unique ...
Definition: exodusII_io.C:615
libMesh::EquationSystems
This is the EquationSystems class.
Definition: equation_systems.h:74
libMesh::MeshOutput
This class defines an abstract interface for Mesh output.
Definition: mesh_output.h:53
libMesh::ExodusII_IO::write_timestep_discontinuous
void write_timestep_discontinuous(const std::string &fname, const EquationSystems &es, const int timestep, const Real time, const std::set< std::string > *system_names=nullptr)
Writes a discontinuous solution at a specific timestep.
Definition: exodusII_io.C:107
libMesh::ExodusII_IO::get_elem_var_names
const std::vector< std::string > & get_elem_var_names()
Return list of the elemental variable names.
Definition: exodusII_io.C:1487
libMesh::ExodusII_IO::ExodusII_IO
ExodusII_IO(MeshBase &mesh, bool single_precision=false)
Constructor.
Definition: exodusII_io.C:49
libMesh::ExodusII_IO::write_nodal_data_discontinuous
void write_nodal_data_discontinuous(const std::string &, const std::vector< Number > &, const std::vector< std::string > &) override
Write out a discontinuous nodal solution.
Definition: exodusII_io.C:1371
libMesh::MeshInput< MeshBase >::mesh
MeshBase & mesh()
Definition: mesh_input.h:169
libMesh::ExodusII_IO::write
virtual void write(const std::string &fname) override
This method implements writing a mesh to a specified file.
Definition: exodusII_io.C:1338
libMesh::Real
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Definition: libmesh_common.h:121
libMesh::ParallelObject
An object whose state is distributed along a set of processors.
Definition: parallel_object.h:55
libMesh::ExodusII_IO::read
virtual void read(const std::string &name) override
This method implements reading a mesh from a specified file.
Definition: exodusII_io.C:143
libMesh::Quality::name
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
libMesh::MeshInput
This class defines an abstract interface for Mesh input.
Definition: mesh_base.h:60
libMesh::ExodusII_IO::set_output_variables
void set_output_variables(const std::vector< std::string > &output_variables, bool allow_empty=true)
Sets the list of variable names to be included in the output.
Definition: exodusII_io.C:72