libMesh
Loading...
Searching...
No Matches
ucd_io.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_UCD_IO_H
21#define LIBMESH_UCD_IO_H
22
23// Local includes
24#include "libmesh/libmesh_common.h"
25#include "libmesh/mesh_input.h"
26#include "libmesh/mesh_output.h"
27
28// C++ includes
29#include <map>
30
31namespace libMesh
32{
33
34// Forward declarations
35class MeshBase;
36enum ElemType : int;
37
44class UCDIO : public MeshInput<MeshBase>,
45 public MeshOutput<MeshBase>
46{
47public:
48
53 explicit
58
63 explicit
64 UCDIO (const MeshBase & mesh) :
66 {}
67
72 virtual void read (const std::string &) override;
73
78 virtual void write (const std::string &) 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) override;
93
94
95private:
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
unsigned int n_vars
void ErrorVector unsigned int
This is the MeshBase class.
Definition mesh_base.h:81
This class defines an abstract interface for Mesh input.
Definition mesh_input.h:49
This class defines an abstract interface for Mesh output.
Definition mesh_output.h:54
This class implements reading & writing meshes in the AVS's UCD format.
Definition ucd_io.h:46
void write_implementation(std::ostream &out_stream)
The actual implementation of the write function.
Definition ucd_io.C:249
static std::map< std::string, ElemType > _reading_element_map
Definition ucd_io.h:145
static std::map< std::string, ElemType > build_reading_element_map()
Definition ucd_io.C:68
virtual void write(const std::string &) override
This method implements writing a mesh to a specified file in UCD format.
Definition ucd_io.C:103
UCDIO(const MeshBase &mesh)
Constructor.
Definition ucd_io.h:64
static std::map< ElemType, std::string > build_writing_element_map()
Definition ucd_io.C:52
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:364
UCDIO(MeshBase &mesh)
Constructor.
Definition ucd_io.h:54
void write_nodes(std::ostream &out, const MeshBase &mesh)
Write node information.
Definition ucd_io.C:291
void read_implementation(std::istream &in_stream)
The actual implementation of the read function.
Definition ucd_io.C:124
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:272
void write_interior_elems(std::ostream &out, const MeshBase &mesh)
Write element information.
Definition ucd_io.C:309
static std::map< ElemType, std::string > _writing_element_map
Definition ucd_io.h:141
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:331
virtual void read(const std::string &) override
This method implements reading a mesh from a specified file in UCD format.
Definition ucd_io.C:82
The libMesh namespace provides an interface to certain functionality in the library.
ElemType
Defines an enum for geometric element types.
OStreamProxy out
uint8_t dof_id_type
Definition id_types.h:67