libMesh
exodusII_io.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2017 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 
30 // C++ includes
31 
32 namespace libMesh
33 {
34 
35 // Forward declarations
36 class EquationSystems;
37 class ExodusII_IO_Helper;
38 class MeshBase;
39 class System;
40 
52 class ExodusII_IO : public MeshInput<MeshBase>,
53  public MeshOutput<MeshBase>,
54  public ParallelObject
55 {
56 public:
57 
62  explicit
64  bool single_precision=false);
65 
69  virtual ~ExodusII_IO ();
70 
78  virtual void read (const std::string & name) libmesh_override;
79 
83  virtual void write (const std::string & fname) libmesh_override;
84 
88  void verbose (bool set_verbosity);
89 
93  const std::vector<Real> & get_time_steps();
94 
104  int get_num_time_steps();
105 
111 #ifdef LIBMESH_ENABLE_DEPRECATED
112  void copy_nodal_solution(System & system,
113  std::string var_name,
114  unsigned int timestep=1);
115 #endif
116 
121  void copy_nodal_solution(System & system,
122  std::string system_var_name,
123  std::string exodus_var_name,
124  unsigned int timestep=1);
125 
130  void copy_elemental_solution(System & system,
131  std::string system_var_name,
132  std::string exodus_var_name,
133  unsigned int timestep=1);
134 
138  void write_discontinuous_exodusII (const std::string & name,
139  const EquationSystems & es,
140  const std::set<std::string> * system_names=libmesh_nullptr);
141 
145  void write_element_data (const EquationSystems & es);
146 
152 
156  virtual void write_nodal_data (const std::string &,
157  const std::vector<Number> &,
158  const std::vector<std::string> &) libmesh_override;
159 
163  void write_nodal_data_discontinuous (const std::string &,
164  const std::vector<Number> &,
165  const std::vector<std::string> &);
166 
170  void write_global_data (const std::vector<Number> &,
171  const std::vector<std::string> &);
172 
176  void write_information_records (const std::vector<std::string> &);
177 
185  void write_timestep (const std::string & fname,
186  const EquationSystems & es,
187  const int timestep,
188  const Real time);
189 
198  void set_output_variables(const std::vector<std::string> & output_variables,
199  bool allow_empty = true);
200 
213 
223  void write_as_dimension(unsigned dim);
224 
240 
246  void append(bool val);
247 
251  const std::vector<std::string> & get_elem_var_names();
252 
256  const std::vector<std::string> & get_nodal_var_names();
257 
258 private:
264 #ifdef LIBMESH_HAVE_EXODUS_API
266 
272 
276  bool _verbose;
277 
282  bool _append;
283 #endif
284 
289  std::vector<std::string> _output_variables;
290 
295  void write_nodal_data_common(std::string fname,
296  const std::vector<std::string> & names,
297  bool continuous=true);
298 
305 
306 };
307 
308 
309 } // namespace libMesh
310 
311 
312 #endif // LIBMESH_EXODUSII_IO_H
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:39
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, thus by default we write all meshes with the Exodus dimension set to LIBMESH_DIM = mesh.spatial_dimension().
Definition: exodusII_io.C:408
This is the EquationSystems class.
void write_as_dimension(unsigned dim)
Directly control the num_dim which is written to the Exodus file.
Definition: exodusII_io.C:415
void write_timestep(const std::string &fname, const EquationSystems &es, const int timestep, const Real time)
Writes out the solution at a specific timestep.
Definition: exodusII_io.C:773
unsigned int dim
The ExodusII_IO class implements reading meshes in the ExodusII file format from Sandia National Labs...
Definition: exodusII_io.h:52
const class libmesh_nullptr_t libmesh_nullptr
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:78
This class defines an abstract interface for Mesh output.
Definition: mesh_output.h:53
The libMesh namespace provides an interface to certain functionality in the library.
ExodusII_IO(MeshBase &mesh, bool single_precision=false)
Constructor.
Definition: exodusII_io.C:45
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:430
This is the MeshBase class.
Definition: mesh_base.h:68
std::unique_ptr< T > UniquePtr
Definition: auto_ptr.h:46
virtual void write_nodal_data(const std::string &, const std::vector< Number > &, const std::vector< std::string > &) libmesh_override
Write out a nodal solution.
Definition: exodusII_io.C:631
int _timestep
Stores the current value of the timestep when calling ExodusII_IO::write_timestep().
Definition: exodusII_io.h:271
This class defines an abstract interface for Mesh input.
Definition: mesh_base.h:50
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:68
bool _verbose
should we be verbose?
Definition: exodusII_io.h:276
bool _append
Default false.
Definition: exodusII_io.h:282
This is the base class for classes which contain information related to any physical process that mig...
Definition: system.h:76
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:491
const std::vector< Real > & get_time_steps()
Definition: exodusII_io.C:437
std::vector< std::string > _output_variables
The names of the variables to be output.
Definition: exodusII_io.h:289
void write_information_records(const std::vector< std::string > &)
Write out information records.
Definition: exodusII_io.C:707
void verbose(bool set_verbosity)
Set the flag indicating if we should be verbose.
Definition: exodusII_io.C:398
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:884
This class forms the base class for all other classes that are expected to be implemented in parallel...
void write_global_data(const std::vector< Number > &, const std::vector< std::string > &)
Write out global variables.
Definition: exodusII_io.C:720
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void read(const std::string &name) libmesh_override
This method implements reading a mesh from a specified file.
Definition: exodusII_io.C:116
virtual void write(const std::string &fname) libmesh_override
This method implements writing a mesh to a specified file.
Definition: exodusII_io.C:789
virtual ~ExodusII_IO()
Destructor.
Definition: exodusII_io.C:109
const std::vector< std::string > & get_elem_var_names()
Return list of the elemental variable names.
Definition: exodusII_io.C:949
void write_element_data(const EquationSystems &es)
Write out element solution.
Definition: exodusII_io.C:535
bool _allow_empty_variables
If true, _output_variables is allowed to remain empty.
Definition: exodusII_io.h:304
UniquePtr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:265
void write_nodal_data_discontinuous(const std::string &, const std::vector< Number > &, const std::vector< std::string > &)
Write out a discontinuous nodal solution.
Definition: exodusII_io.C:826
const std::vector< std::string > & get_nodal_var_names()
Return list of the nodal variable names.
Definition: exodusII_io.C:943
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:38
void write_discontinuous_exodusII(const std::string &name, const EquationSystems &es, const std::set< std::string > *system_names=libmesh_nullptr)
Writes a exodusII file with discontinuous data.
Definition: exodusII_io.C:89
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:422