libMesh
ucd_io.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2017 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 #include "libmesh/enum_elem_type.h"
31 
32 namespace libMesh
33 {
34 
35 // Forward declarations
36 class MeshBase;
37 
44 class UCDIO : public MeshInput<MeshBase>,
45  public MeshOutput<MeshBase>
46 {
47 public:
48 
53  explicit
55  MeshInput<MeshBase> (mesh),
56  MeshOutput<MeshBase>(mesh)
57  {}
58 
63  explicit
64  UCDIO (const MeshBase & mesh) :
65  MeshOutput<MeshBase> (mesh)
66  {}
67 
72  virtual void read (const std::string &) libmesh_override;
73 
78  virtual void write (const std::string &) libmesh_override;
79 
85 
90  virtual void write_nodal_data(const std::string & fname,
91  const std::vector<Number> & soln,
92  const std::vector<std::string> & names) libmesh_override;
93 
94 
95 private:
96 
102  void read_implementation (std::istream & in_stream);
103 
109  void write_implementation (std::ostream & out_stream);
110 
114  void write_header(std::ostream & out,
115  const MeshBase & mesh,
116  dof_id_type n_elems,
117  unsigned int n_vars);
118 
122  void write_nodes(std::ostream & out,
123  const MeshBase & mesh);
124 
128  void write_interior_elems(std::ostream & out,
129  const MeshBase & mesh);
130 
134  void write_soln(std::ostream & out,
135  const MeshBase & mesh,
136  const std::vector<std::string> & names,
137  const std::vector<Number> & soln);
138 
139  // Static map from libmesh ElementType -> UCD description string for
140  // use during writing.
141  static std::map<ElemType, std::string> _writing_element_map;
142 
143  // Static map from libmesh UCD description string -> ElementType for
144  // use during reading.
145  static std::map<std::string, ElemType> _reading_element_map;
146 
147  // Static function used to build the _writing_element_map.
148  static std::map<ElemType, std::string> build_writing_element_map();
149 
150  // Static function used to build the _reading_element_map.
151  static std::map<std::string, ElemType> build_reading_element_map();
152 };
153 
154 } // namespace libMesh
155 
156 
157 #endif // LIBMESH_UCD_IO_H
virtual void read(const std::string &) libmesh_override
This method implements reading a mesh from a specified file in UCD format.
Definition: ucd_io.C:78
UCDIO(const MeshBase &mesh)
Constructor.
Definition: ucd_io.h:64
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:353
This class defines an abstract interface for Mesh output.
Definition: mesh_output.h:53
static std::map< ElemType, std::string > _writing_element_map
Definition: ucd_io.h:141
const unsigned int n_vars
Definition: tecplot_io.C:68
The libMesh namespace provides an interface to certain functionality in the library.
This is the MeshBase class.
Definition: mesh_base.h:68
void read_implementation(std::istream &in_stream)
The actual implementation of the read function.
Definition: ucd_io.C:120
UCDIO(MeshBase &mesh)
Constructor.
Definition: ucd_io.h:54
This class implements reading & writing meshes in the AVS&#39;s UCD format.
Definition: ucd_io.h:44
This class defines an abstract interface for Mesh input.
Definition: mesh_base.h:50
static std::map< ElemType, std::string > build_writing_element_map()
Definition: ucd_io.C:48
virtual void write_nodal_data(const std::string &fname, const std::vector< Number > &soln, const std::vector< std::string > &names) libmesh_override
This method implements writing a mesh and solution to a specified file in UCD format.
Definition: ucd_io.C:320
void write_nodes(std::ostream &out, const MeshBase &mesh)
Write node information.
Definition: ucd_io.C:277
static std::map< std::string, ElemType > build_reading_element_map()
Definition: ucd_io.C:64
OStreamProxy out
void write_interior_elems(std::ostream &out, const MeshBase &mesh)
Write element information.
Definition: ucd_io.C:295
virtual void write(const std::string &) libmesh_override
This method implements writing a mesh to a specified file in UCD format.
Definition: ucd_io.C:99
void write_implementation(std::ostream &out_stream)
The actual implementation of the write function.
Definition: ucd_io.C:235
static std::map< std::string, ElemType > _reading_element_map
Definition: ucd_io.h:145
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)
Write UCD format header.
Definition: ucd_io.C:258