ucd_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_UCD_IO_H
21 #define LIBMESH_UCD_IO_H
22 
23 // C++ includes
24 #include <map>
25 
26 // Local includes
27 #include "libmesh/libmesh_common.h"
28 #include "libmesh/mesh_input.h"
29 #include "libmesh/mesh_output.h"
30 
31 #ifdef LIBMESH_FORWARD_DECLARE_ENUMS
32 namespace libMesh
33 {
34 enum ElemType : int;
35 }
36 #else
37 #include "libmesh/enum_elem_type.h"
38 #endif
39 
40 namespace libMesh
41 {
42 
43 // Forward declarations
44 class MeshBase;
45 
52 class UCDIO : public MeshInput<MeshBase>,
53  public MeshOutput<MeshBase>
54 {
55 public:
56 
61  explicit
65  {}
66 
71  explicit
72  UCDIO (const MeshBase & mesh) :
74  {}
75 
80  virtual void read (const std::string &) override;
81 
86  virtual void write (const std::string &) override;
87 
93 
98  virtual void write_nodal_data(const std::string & fname,
99  const std::vector<Number> & soln,
100  const std::vector<std::string> & names) override;
101 
102 
103 private:
104 
110  void read_implementation (std::istream & in_stream);
111 
117  void write_implementation (std::ostream & out_stream);
118 
122  void write_header(std::ostream & out,
123  const MeshBase & mesh,
124  dof_id_type n_elems,
125  unsigned int n_vars);
126 
130  void write_nodes(std::ostream & out,
131  const MeshBase & mesh);
132 
136  void write_interior_elems(std::ostream & out,
137  const MeshBase & mesh);
138 
142  void write_soln(std::ostream & out,
143  const MeshBase & mesh,
144  const std::vector<std::string> & names,
145  const std::vector<Number> & soln);
146 
147  // Static map from libmesh ElementType -> UCD description string for
148  // use during writing.
149  static std::map<ElemType, std::string> _writing_element_map;
150 
151  // Static map from libmesh UCD description string -> ElementType for
152  // use during reading.
153  static std::map<std::string, ElemType> _reading_element_map;
154 
155  // Static function used to build the _writing_element_map.
156  static std::map<ElemType, std::string> build_writing_element_map();
157 
158  // Static function used to build the _reading_element_map.
159  static std::map<std::string, ElemType> build_reading_element_map();
160 };
161 
162 } // namespace libMesh
163 
164 
165 #endif // LIBMESH_UCD_IO_H
virtual void read(const std::string &) override
Definition: ucd_io.C:82
UCDIO(const MeshBase &mesh)
Definition: ucd_io.h:72
void write_soln(std::ostream &out, const MeshBase &mesh, const std::vector< std::string > &names, const std::vector< Number > &soln)
Definition: ucd_io.C:357
static std::map< ElemType, std::string > _writing_element_map
Definition: ucd_io.h:149
const unsigned int n_vars
Definition: tecplot_io.C:69
Base class for Mesh.
Definition: mesh_base.h:77
void read_implementation(std::istream &in_stream)
Definition: ucd_io.C:124
UCDIO(MeshBase &mesh)
Definition: ucd_io.h:62
static std::map< ElemType, std::string > build_writing_element_map()
Definition: ucd_io.C:52
void write_nodes(std::ostream &out, const MeshBase &mesh)
Definition: ucd_io.C:281
static std::map< std::string, ElemType > build_reading_element_map()
Definition: ucd_io.C:68
void write_interior_elems(std::ostream &out, const MeshBase &mesh)
Definition: ucd_io.C:299
void write_implementation(std::ostream &out_stream)
Definition: ucd_io.C:239
static std::map< std::string, ElemType > _reading_element_map
Definition: ucd_io.h:153
virtual void write_nodal_data(const std::string &fname, const std::vector< Number > &soln, const std::vector< std::string > &names) override
Definition: ucd_io.C:324
OStreamProxy out(std::cout)
virtual void write(const std::string &) override
Definition: ucd_io.C:103
uint8_t dof_id_type
Definition: id_types.h:64
void write_header(std::ostream &out, const MeshBase &mesh, dof_id_type n_elems, unsigned int n_vars)
Definition: ucd_io.C:262