libMesh
ucd_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_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
libMesh::UCDIO::_writing_element_map
static std::map< ElemType, std::string > _writing_element_map
Definition: ucd_io.h:149
libMesh::UCDIO::write_implementation
void write_implementation(std::ostream &out_stream)
The actual implementation of the write function.
Definition: ucd_io.C:251
libMesh::dof_id_type
uint8_t dof_id_type
Definition: id_types.h:67
n_vars
unsigned int n_vars
Definition: adaptivity_ex3.C:116
libMesh::UCDIO::UCDIO
UCDIO(const MeshBase &mesh)
Constructor.
Definition: ucd_io.h:72
libMesh::UCDIO::read_implementation
void read_implementation(std::istream &in_stream)
The actual implementation of the read function.
Definition: ucd_io.C:126
libMesh
The libMesh namespace provides an interface to certain functionality in the library.
Definition: factoryfunction.C:55
libMesh::UCDIO::write_soln
void write_soln(std::ostream &out, const MeshBase &mesh, const std::vector< std::string > &names, const std::vector< Number > &soln)
Writes all nodal solution variables.
Definition: ucd_io.C:366
libMesh::MeshBase
This is the MeshBase class.
Definition: mesh_base.h:78
libMesh::UCDIO::build_reading_element_map
static std::map< std::string, ElemType > build_reading_element_map()
Definition: ucd_io.C:70
libMesh::UCDIO::_reading_element_map
static std::map< std::string, ElemType > _reading_element_map
Definition: ucd_io.h:153
libMesh::UCDIO::read
virtual void read(const std::string &) override
This method implements reading a mesh from a specified file in UCD format.
Definition: ucd_io.C:84
libMesh::MeshOutput
This class defines an abstract interface for Mesh output.
Definition: mesh_output.h:53
libMesh::UCDIO::write_header
void write_header(std::ostream &out, const MeshBase &mesh, dof_id_type n_elems, unsigned int n_vars)
Write UCD format header.
Definition: ucd_io.C:274
libMesh::UCDIO::write
virtual void write(const std::string &) override
This method implements writing a mesh to a specified file in UCD format.
Definition: ucd_io.C:105
libMesh::UCDIO::UCDIO
UCDIO(MeshBase &mesh)
Constructor.
Definition: ucd_io.h:62
libMesh::UCDIO::build_writing_element_map
static std::map< ElemType, std::string > build_writing_element_map()
Definition: ucd_io.C:54
libMesh::UCDIO::write_nodal_data
virtual void write_nodal_data(const std::string &fname, const std::vector< Number > &soln, const std::vector< std::string > &names) override
This method implements writing a mesh and solution to a specified file in UCD format.
Definition: ucd_io.C:333
libMesh::MeshInput< MeshBase >::mesh
MeshBase & mesh()
Definition: mesh_input.h:169
libMesh::UCDIO::write_interior_elems
void write_interior_elems(std::ostream &out, const MeshBase &mesh)
Write element information.
Definition: ucd_io.C:311
libMesh::out
OStreamProxy out
libMesh::UCDIO
This class implements reading & writing meshes in the AVS's UCD format.
Definition: ucd_io.h:52
int
void ErrorVector unsigned int
Definition: adjoints_ex3.C:360
libMesh::UCDIO::write_nodes
void write_nodes(std::ostream &out, const MeshBase &mesh)
Write node information.
Definition: ucd_io.C:293
libMesh::MeshInput
This class defines an abstract interface for Mesh input.
Definition: mesh_base.h:60
libMesh::ElemType
ElemType
Defines an enum for geometric element types.
Definition: enum_elem_type.h:33