mesh_output.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2018 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_MESH_OUTPUT_H
21 #define LIBMESH_MESH_OUTPUT_H
22 
23 
24 // Local includes
25 #include "libmesh/libmesh_common.h"
27 #include "libmesh/mesh_base.h"
29 
30 // C++ includes
31 #include <cstddef>
32 #include <limits>
33 #include <string>
34 #include <vector>
35 
36 namespace libMesh
37 {
38 
39 // Forward declares
40 class EquationSystems;
41 template <typename T> class NumericVector;
42 
43 
52 template <class MT>
54 {
55 protected:
56 
61  explicit
62  MeshOutput (const bool is_parallel_format = false, const bool serial_only_needed_on_proc_0 = false);
63 
68  explicit
69  MeshOutput (const MT &, const bool is_parallel_format = false, const bool serial_only_needed_on_proc_0 = false);
70 
71 
72 public:
73 
77  virtual ~MeshOutput ();
78 
82  virtual void write (const std::string &) = 0;
83 
88  virtual void write_equation_systems (const std::string &,
89  const EquationSystems &,
90  const std::set<std::string> * system_names=nullptr);
91 
97  virtual void write_discontinuous_equation_systems (const std::string &,
98  const EquationSystems &,
99  const std::set<std::string> * system_names=nullptr);
100 
105  virtual void write_nodal_data (const std::string &,
106  const std::vector<Number> &,
107  const std::vector<std::string> &)
108  { libmesh_not_implemented(); }
109 
114  virtual void write_nodal_data_discontinuous (const std::string &,
115  const std::vector<Number> &,
116  const std::vector<std::string> &)
117  { libmesh_not_implemented(); }
118 
132  virtual void write_nodal_data (const std::string &,
133  const NumericVector<Number> &,
134  const std::vector<std::string> &);
135 
143  unsigned int & ascii_precision ();
144 
145 protected:
146 
147 
151  const MT & mesh() const;
152 
153 
160 
169 
170 private:
171 
172 
177  const MT * const _obj;
178 
182  unsigned int _ascii_precision;
183 };
184 
185 
186 
187 
188 
189 
190 // ------------------------------------------------------------
191 // MeshOutput inline members
192 template <class MT>
193 inline
194 MeshOutput<MT>::MeshOutput (const bool is_parallel_format, const bool serial_only_needed_on_proc_0) :
195  _is_parallel_format(is_parallel_format),
196  _serial_only_needed_on_proc_0(serial_only_needed_on_proc_0),
197  _obj(nullptr),
198  _ascii_precision (std::numeric_limits<Real>::digits10 + 2)
199 {}
200 
201 
202 
203 template <class MT>
204 inline
205 MeshOutput<MT>::MeshOutput (const MT & obj, const bool is_parallel_format, const bool serial_only_needed_on_proc_0) :
206  _is_parallel_format(is_parallel_format),
207  _serial_only_needed_on_proc_0(serial_only_needed_on_proc_0),
208  _obj (&obj),
209  _ascii_precision (std::numeric_limits<Real>::digits10 + 2)
210 {
211  if (!_is_parallel_format && !this->mesh().is_serial())
212  {
213  if (this->mesh().processor_id() == 0)
214  {
215  libmesh_do_once(libMesh::out <<
216  "Warning: This MeshOutput subclass only supports meshes which have been serialized!"
217  << std::endl;);
218  }
219  }
220 }
221 
222 
223 
224 template <class MT>
225 inline
227 {
228 }
229 
230 
231 
232 template <class MT>
233 inline
234 const MT & MeshOutput<MT>::mesh () const
235 {
236  libmesh_assert(_obj);
237  return *_obj;
238 }
239 
240 
241 
242 template <class MT>
243 inline
245 {
246  return _ascii_precision;
247 }
248 
249 
250 } // namespace libMesh
251 
252 
253 #endif // LIBMESH_MESH_OUTPUT_H
const MT & mesh() const
Definition: mesh_output.h:234
virtual void write_nodal_data(const std::string &, const std::vector< Number > &, const std::vector< std::string > &)
Definition: mesh_output.h:105
virtual ~MeshOutput()
Definition: mesh_output.h:226
Manages multiples systems of equations.
virtual void write_nodal_data_discontinuous(const std::string &, const std::vector< Number > &, const std::vector< std::string > &)
Definition: mesh_output.h:114
virtual void write_equation_systems(const std::string &, const EquationSystems &, const std::set< std::string > *system_names=nullptr)
Definition: mesh_output.C:31
const MT *const _obj
Definition: mesh_output.h:177
const bool _is_parallel_format
Definition: mesh_output.h:159
MeshBase & mesh
unsigned int & ascii_precision()
Definition: mesh_output.h:244
MeshOutput(const bool is_parallel_format=false, const bool serial_only_needed_on_proc_0=false)
Definition: mesh_output.h:194
unsigned int _ascii_precision
Definition: mesh_output.h:182
virtual void write_discontinuous_equation_systems(const std::string &, const EquationSystems &, const std::set< std::string > *system_names=nullptr)
Definition: mesh_output.C:92
virtual void write(const std::string &)=0
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const bool _serial_only_needed_on_proc_0
Definition: mesh_output.h:168
OStreamProxy out(std::cout)