libMesh
nemesis_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_NEMESIS_IO_H
21 #define LIBMESH_NEMESIS_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 Nemesis_IO_Helper;
37 
50 class Nemesis_IO : public MeshInput<MeshBase>,
51  public MeshOutput<MeshBase>,
52  public ParallelObject
53 {
54 
55 public:
56 
61  explicit
62  Nemesis_IO (MeshBase & mesh, bool single_precision=false);
63 
67  virtual ~Nemesis_IO ();
68 
74  virtual void read (const std::string & base_filename) override;
75 
79  virtual void write (const std::string & base_filename) override;
80 
84  void write_timestep (const std::string & fname,
85  const EquationSystems & es,
86  const int timestep,
87  const Real time);
88 
98  void set_output_variables(const std::vector<std::string> & output_variables,
99  bool allow_empty = true);
100 
104  virtual void write_nodal_data (const std::string & fname,
105  const std::vector<Number> & soln,
106  const std::vector<std::string> & names) override;
107 
111  virtual void write_nodal_data (const std::string & fname,
112  const EquationSystems & es,
113  const std::set<std::string> * system_names) override;
114 
118  virtual void write_nodal_data (const std::string & fname,
119  const NumericVector<Number> & parallel_soln,
120  const std::vector<std::string> & names) override;
121 
129  void write_element_data (const EquationSystems & es);
130 
134  void verbose (bool set_verbosity);
135 
139  void write_global_data (const std::vector<Number> &,
140  const std::vector<std::string> &);
141 
145  void write_information_records (const std::vector<std::string> &);
146 
152  void append(bool val);
153 
154 private:
155 #if defined(LIBMESH_HAVE_EXODUS_API) && defined(LIBMESH_HAVE_NEMESIS_API)
156  std::unique_ptr<Nemesis_IO_Helper> nemhelper;
157 
163 #endif
164 
168  bool _verbose;
169 
174  bool _append;
175 
181  void prepare_to_write_nodal_data (const std::string & fname,
182  const std::vector<std::string> & names);
183 
188  std::vector<std::string> _output_variables;
189 
196 };
197 
198 
199 } // namespace libMesh
200 
201 
202 #endif // LIBMESH_NEMESIS_IO_H
libMesh::Nemesis_IO::write
virtual void write(const std::string &base_filename) override
This method implements writing a mesh to a specified file.
Definition: nemesis_io.C:1183
libMesh::Nemesis_IO
The Nemesis_IO class implements reading parallel meshes in the Nemesis file format from Sandia Nation...
Definition: nemesis_io.h:50
libMesh::Nemesis_IO::append
void append(bool val)
If true, this flag will cause the Nemesis_IO object to attempt to open an existing file for writing,...
Definition: nemesis_io.C:133
libMesh::Nemesis_IO::write_global_data
void write_global_data(const std::vector< Number > &, const std::vector< std::string > &)
Write out global variables.
Definition: nemesis_io.C:1510
libMesh
The libMesh namespace provides an interface to certain functionality in the library.
Definition: factoryfunction.C:55
libMesh::Nemesis_IO::~Nemesis_IO
virtual ~Nemesis_IO()
Destructor.
Definition: nemesis_io.C:114
libMesh::Nemesis_IO::write_timestep
void write_timestep(const std::string &fname, const EquationSystems &es, const int timestep, const Real time)
Write one timestep's worth of the solution.
Definition: nemesis_io.C:1241
libMesh::Nemesis_IO::prepare_to_write_nodal_data
void prepare_to_write_nodal_data(const std::string &fname, const std::vector< std::string > &names)
Helper function containing code shared between the two different versions of write_nodal_data which t...
Definition: nemesis_io.C:1268
libMesh::Nemesis_IO::nemhelper
std::unique_ptr< Nemesis_IO_Helper > nemhelper
Definition: nemesis_io.h:156
libMesh::Nemesis_IO::Nemesis_IO
Nemesis_IO(MeshBase &mesh, bool single_precision=false)
Constructor.
Definition: nemesis_io.C:90
libMesh::NumericVector< Number >
libMesh::Nemesis_IO::read
virtual void read(const std::string &base_filename) override
Implements reading the mesh from several different files.
Definition: nemesis_io.C:150
libMesh::MeshBase
This is the MeshBase class.
Definition: mesh_base.h:78
libMesh::Nemesis_IO::_verbose
bool _verbose
Controls whether extra debugging information is printed to the screen or not.
Definition: nemesis_io.h:168
libMesh::Nemesis_IO::write_nodal_data
virtual void write_nodal_data(const std::string &fname, const std::vector< Number > &soln, const std::vector< std::string > &names) override
Output a nodal solution from data in soln.
Definition: nemesis_io.C:1483
libMesh::Nemesis_IO::set_output_variables
void set_output_variables(const std::vector< std::string > &output_variables, bool allow_empty=true)
Specify the list of variables which should be included in the output (whitelist) If empty,...
Definition: nemesis_io.C:140
libMesh::Nemesis_IO::_timestep
int _timestep
Keeps track of the current timestep index being written.
Definition: nemesis_io.h:162
libMesh::EquationSystems
This is the EquationSystems class.
Definition: equation_systems.h:74
libMesh::Nemesis_IO::write_element_data
void write_element_data(const EquationSystems &es)
Write out element solution in parallel, without localizing the solution vector.
Definition: nemesis_io.C:1401
libMesh::Nemesis_IO::_allow_empty_variables
bool _allow_empty_variables
If true, _output_variables is allowed to remain empty.
Definition: nemesis_io.h:195
libMesh::MeshOutput
This class defines an abstract interface for Mesh output.
Definition: mesh_output.h:53
libMesh::Nemesis_IO::_append
bool _append
Default false.
Definition: nemesis_io.h:174
libMesh::Nemesis_IO::_output_variables
std::vector< std::string > _output_variables
The names of the variables to be output.
Definition: nemesis_io.h:188
libMesh::Nemesis_IO::verbose
void verbose(bool set_verbosity)
Set the flag indicating if we should be verbose.
Definition: nemesis_io.C:120
libMesh::MeshInput< MeshBase >::mesh
MeshBase & mesh()
Definition: mesh_input.h:169
libMesh::Nemesis_IO::write_information_records
void write_information_records(const std::vector< std::string > &)
Write out information records.
Definition: nemesis_io.C:1575
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::MeshInput
This class defines an abstract interface for Mesh input.
Definition: mesh_base.h:60