gmv_io.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_GMV_IO_H
21 #define LIBMESH_GMV_IO_H
22 
23 // Local includes
24 #include "libmesh/libmesh_common.h"
25 #include "libmesh/mesh_output.h"
26 #include "libmesh/mesh_input.h"
27 
28 #ifdef LIBMESH_FORWARD_DECLARE_ENUMS
29 namespace libMesh
30 {
31 enum ElemType : int;
32 }
33 #else
34 #include "libmesh/enum_elem_type.h"
35 #endif
36 
37 // C++ includes
38 #include <map>
39 
40 namespace libMesh
41 {
42 
43 // Forward declarations
44 class MeshBase;
45 
54 class GMVIO : public MeshInput<MeshBase>,
55  public MeshOutput<MeshBase>
56 {
57 public:
58 
63  explicit
64  GMVIO (const MeshBase &);
65 
70  explicit
71  GMVIO (MeshBase &);
72 
76  virtual void write (const std::string &) override;
77 
81  virtual void read (const std::string & mesh_file) override;
82 
88 
93  virtual void write_nodal_data (const std::string &,
94  const std::vector<Number> &,
95  const std::vector<std::string> &) override;
96 
103  bool & binary () { return _binary; }
104 
109  bool & discontinuous() { return _discontinuous; }
110 
115  bool & partitioning() { return _partitioning; }
116 
123 
129 
134  bool & p_levels() { return _p_levels; }
135 
139  void write_discontinuous_gmv (const std::string & name,
140  const EquationSystems & es,
141  const bool write_partitioning,
142  const std::set<std::string> * system_names=nullptr) const;
143 
144 
151  void write_ascii_new_impl (const std::string &,
152  const std::vector<Number> * = nullptr,
153  const std::vector<std::string> * = nullptr);
154 
166  void add_cell_centered_data (const std::string & cell_centered_data_name,
167  const std::vector<Real> * cell_centered_data_vals);
168 
174 
175 private:
176 
183  void write_ascii_old_impl (const std::string &,
184  const std::vector<Number> * = nullptr,
185  const std::vector<std::string> * = nullptr);
186 
192  void write_binary (const std::string &,
193  const std::vector<Number> * = nullptr,
194  const std::vector<std::string> * = nullptr);
195 
199  bool _binary;
200 
205 
210 
216 
221 
225  bool _p_levels;
226 
233  std::map<std::string, const std::vector<Real> * > _cell_centered_data;
234 
238  void _read_nodes();
239  unsigned int _next_elem_id;
240  void _read_one_cell();
241  ElemType gmv_elem_to_libmesh_elem(std::string elemname);
242  void _read_materials();
243  void _read_var();
244  std::map<std::string, std::vector<Number>> _nodal_data;
245 
250  static std::map<std::string, ElemType> _reading_element_map;
251 
255  static std::map<std::string, ElemType> build_reading_element_map();
256 };
257 
258 } // namespace libMesh
259 
260 
261 #endif // LIBMESH_GMV_IO_H
std::string name(const ElemQuality q)
Definition: elem_quality.C:42
virtual void read(const std::string &mesh_file) override
Definition: gmv_io.C:1881
void _read_var()
Definition: gmv_io.C:2032
Manages multiples systems of equations.
void _read_nodes()
Definition: gmv_io.C:2068
bool _binary
Definition: gmv_io.h:199
static std::map< std::string, ElemType > _reading_element_map
Definition: gmv_io.h:250
virtual void write(const std::string &) override
Definition: gmv_io.C:269
void write_binary(const std::string &, const std::vector< Number > *=nullptr, const std::vector< std::string > *=nullptr)
Definition: gmv_io.C:1230
unsigned int _next_elem_id
Definition: gmv_io.h:239
bool _discontinuous
Definition: gmv_io.h:204
bool & partitioning()
Definition: gmv_io.h:115
std::map< std::string, std::vector< Number > > _nodal_data
Definition: gmv_io.h:244
Base class for Mesh.
Definition: mesh_base.h:77
bool & binary()
Definition: gmv_io.h:103
virtual void write_nodal_data(const std::string &, const std::vector< Number > &, const std::vector< std::string > &) override
Definition: gmv_io.C:279
bool & write_subdomain_id_as_material()
Definition: gmv_io.h:122
ElemType gmv_elem_to_libmesh_elem(std::string elemname)
Definition: gmv_io.C:2151
std::map< std::string, const std::vector< Real > *> _cell_centered_data
Definition: gmv_io.h:233
static std::map< std::string, ElemType > build_reading_element_map()
Definition: gmv_io.C:207
bool _write_subdomain_id_as_material
Definition: gmv_io.h:215
bool & p_levels()
Definition: gmv_io.h:134
bool _subdivide_second_order
Definition: gmv_io.h:220
void copy_nodal_solution(EquationSystems &es)
Definition: gmv_io.C:2168
void _read_materials()
Definition: gmv_io.C:2044
void write_ascii_old_impl(const std::string &, const std::vector< Number > *=nullptr, const std::vector< std::string > *=nullptr)
Definition: gmv_io.C:568
bool & subdivide_second_order()
Definition: gmv_io.h:128
void write_ascii_new_impl(const std::string &, const std::vector< Number > *=nullptr, const std::vector< std::string > *=nullptr)
Definition: gmv_io.C:293
GMVIO(const MeshBase &)
Definition: gmv_io.C:240
bool & discontinuous()
Definition: gmv_io.h:109
void _read_one_cell()
Definition: gmv_io.C:2087
void add_cell_centered_data(const std::string &cell_centered_data_name, const std::vector< Real > *cell_centered_data_vals)
Definition: gmv_io.C:1864
bool _p_levels
Definition: gmv_io.h:225
bool _partitioning
Definition: gmv_io.h:209
void write_discontinuous_gmv(const std::string &name, const EquationSystems &es, const bool write_partitioning, const std::set< std::string > *system_names=nullptr) const
Definition: gmv_io.C:1551