libMesh
Loading...
Searching...
No Matches
mesh_output.h
Go to the documentation of this file.
1// The libMesh Finite Element Library.
2// Copyright (C) 2002-2026 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"
26#include "libmesh/libmesh_logging.h"
27#include "libmesh/mesh_base.h"
28#include "libmesh/mesh_serializer.h"
29
30// C++ includes
31#include <cstddef>
32#include <limits>
33#include <string>
34#include <vector>
35
36namespace libMesh
37{
38
39// Forward declares
40class EquationSystems;
41template <typename T> class NumericVector;
42
43
52template <class MT>
54{
55protected:
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
72public:
73
77 virtual ~MeshOutput ();
78
86 virtual void write (const std::string &) = 0;
87
92 virtual void write_equation_systems (const std::string &,
93 const EquationSystems &,
94 const std::set<std::string> * system_names=nullptr);
95
101 virtual void write_discontinuous_equation_systems (const std::string &,
102 const EquationSystems &,
103 const std::set<std::string> * system_names=nullptr);
104
109 virtual void write_nodal_data (const std::string &,
110 const std::vector<Number> &,
111 const std::vector<std::string> &)
112 { libmesh_not_implemented(); }
113
118 virtual void write_nodal_data_discontinuous (const std::string &,
119 const std::vector<Number> &,
120 const std::vector<std::string> &)
121 { libmesh_not_implemented(); }
122
136 virtual void write_nodal_data (const std::string &,
137 const NumericVector<Number> &,
138 const std::vector<std::string> &);
139
149 virtual void write_nodal_data (const std::string &,
150 const EquationSystems &,
151 const std::set<std::string> *);
152
160 unsigned int & ascii_precision ();
161
162protected:
163
164
168 const MT & mesh() const;
169
170
176 virtual bool get_add_sides() { return false; }
177
178
185
194
195private:
196
197
202 const MT * const _obj;
203
207 unsigned int _ascii_precision;
208};
209
210
211
212
213
214
215// ------------------------------------------------------------
216// MeshOutput inline members
217template <class MT>
218inline
219MeshOutput<MT>::MeshOutput (const bool is_parallel_format, const bool serial_only_needed_on_proc_0) :
220 _is_parallel_format(is_parallel_format),
221 _serial_only_needed_on_proc_0(serial_only_needed_on_proc_0),
222 _obj(nullptr),
223 _ascii_precision (std::numeric_limits<Real>::max_digits10)
224{}
225
226
227
228template <class MT>
229inline
230MeshOutput<MT>::MeshOutput (const MT & obj, const bool is_parallel_format, const bool serial_only_needed_on_proc_0) :
231 _is_parallel_format(is_parallel_format),
232 _serial_only_needed_on_proc_0(serial_only_needed_on_proc_0),
233 _obj (&obj),
234 _ascii_precision (std::numeric_limits<Real>::max_digits10)
235{
236 if (!_is_parallel_format && !this->mesh().is_serial())
237 {
238 if (this->mesh().processor_id() == 0)
239 {
240 libmesh_do_once(libMesh::out <<
241 "Warning: This MeshOutput subclass only supports meshes which have been serialized!"
242 << std::endl;);
243 }
244 }
245}
246
247
248
249template <class MT>
250inline
254
255
256
257template <class MT>
258inline
259const MT & MeshOutput<MT>::mesh () const
260{
261 libmesh_assert(_obj);
262 return *_obj;
263}
264
265
266
267template <class MT>
268inline
270{
271 return _ascii_precision;
272}
273
274
275} // namespace libMesh
276
277
278#endif // LIBMESH_MESH_OUTPUT_H
This is the EquationSystems class.
This class defines an abstract interface for Mesh output.
Definition mesh_output.h:54
virtual void write_equation_systems(const std::string &, const EquationSystems &, const std::set< std::string > *system_names=nullptr)
This method implements writing a mesh with data to a specified file where the data is taken from the ...
Definition mesh_output.C:31
const bool _is_parallel_format
Flag specifying whether this format is parallel-capable.
unsigned int _ascii_precision
Precision to use when writing ASCII files.
virtual ~MeshOutput()
Destructor.
virtual void write_discontinuous_equation_systems(const std::string &, const EquationSystems &, const std::set< std::string > *system_names=nullptr)
This method implements writing a mesh with discontinuous data to a specified file where the data is t...
Definition mesh_output.C:89
const MT *const _obj
A pointer to a constant object.
const bool _serial_only_needed_on_proc_0
Flag specifying whether this format can be written by only serializing the mesh to processor zero.
virtual bool get_add_sides()
MeshOutput(const MT &, const bool is_parallel_format=false, const bool serial_only_needed_on_proc_0=false)
Constructor.
MeshOutput(const bool is_parallel_format=false, const bool serial_only_needed_on_proc_0=false)
Default constructor.
virtual void write(const std::string &)=0
This method implements writing a mesh to a specified file.
unsigned int & ascii_precision()
Return/set the precision to use when writing ASCII files.
virtual void write_nodal_data(const std::string &, const std::vector< Number > &, const std::vector< std::string > &)
This method implements writing a mesh with nodal data to a specified file where the nodal data and va...
virtual void write_nodal_data_discontinuous(const std::string &, const std::vector< Number > &, const std::vector< std::string > &)
This method implements writing a mesh with discontinuous data to a specified file where the nodal dat...
const MT & mesh() const
Provides a uniform interface to vector storage schemes for different linear algebra libraries.
The libMesh namespace provides an interface to certain functionality in the library.
libmesh_assert(ctx)
OStreamProxy out
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real