libMesh
unv_io.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2024 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_UNV_IO_H
21 #define LIBMESH_UNV_IO_H
22 
23 
24 // Local includes
25 #include "libmesh/mesh_input.h"
26 #include "libmesh/mesh_output.h"
27 
28 // C++ includes
29 #include <cstddef>
30 #include <map>
31 #include <string>
32 #include <vector>
33 
34 namespace libMesh
35 {
36 
37 // Forward declarations
38 class MeshBase;
39 
52 class UNVIO : public MeshInput<MeshBase>,
53  public MeshOutput<MeshBase>
54 {
55 
56 public:
57 
62  UNVIO (MeshBase & mesh);
63 
68  UNVIO (const MeshBase & mesh);
69 
73  virtual ~UNVIO ();
74 
78  virtual void read (const std::string &) override;
79 
83  virtual void write (const std::string &) override;
84 
88  bool & verbose ();
89 
94  void read_dataset(std::string file_name);
95 
104  const std::vector<Number> * get_data (Node * node) const;
105 
106 private:
107 
108 
114  void read_implementation (std::istream & in_stream);
115 
121  void write_implementation (std::ostream & out_stream);
122 
123  //-------------------------------------------------------------
124  // read support methods
125 
129  void nodes_in (std::istream & in_file);
130 
137  void elements_in (std::istream & in_file);
138 
143  void groups_in(std::istream & in_file);
144 
145  //-------------------------------------------------------------
146  // write support methods
147 
152  void nodes_out (std::ostream & out_file);
153 
158  void elements_out (std::ostream & out_file);
159 
165  unsigned char max_elem_dimension_seen ();
166 
174  bool need_D_to_e (std::string & number);
175 
176  //-------------------------------------------------------------
177  // local data
178 
182  bool _verbose;
183 
188  std::map<dof_id_type, Node *> _unv_node_id_to_libmesh_node_ptr;
189 
193  static const std::string _nodes_dataset_label;
194 
198  static const std::string _elements_dataset_label;
199 
203  static const std::string _groups_dataset_label;
204 
208  std::map<unsigned, unsigned> _unv_elem_id_to_libmesh_elem_id;
209 
214  std::map<Node *, std::vector<Number>> _node_data;
215 };
216 
217 
218 
219 } // namespace libMesh
220 
221 
222 #endif // LIBMESH_UNV_IO_H
void write_implementation(std::ostream &out_stream)
The actual implementation of the write function.
Definition: unv_io.C:288
bool _verbose
should be be verbose?
Definition: unv_io.h:182
UNVIO(MeshBase &mesh)
Constructor.
Definition: unv_io.C:70
A Node is like a Point, but with more information.
Definition: node.h:52
bool & verbose()
Set the flag indicating if we should be verbose.
Definition: unv_io.C:91
std::map< dof_id_type, Node * > _unv_node_id_to_libmesh_node_ptr
Maps UNV node IDs to libMesh Node*s.
Definition: unv_io.h:188
static const std::string _elements_dataset_label
label for the element dataset
Definition: unv_io.h:198
void nodes_in(std::istream &in_file)
Read nodes from file.
Definition: unv_io.C:300
void read_implementation(std::istream &in_stream)
The actual implementation of the read function.
Definition: unv_io.C:124
void read_dataset(std::string file_name)
Read a UNV data file containing a dataset of type "2414".
Definition: unv_io.C:1163
std::map< Node *, std::vector< Number > > _node_data
Map from libMesh Node* to data at that node, as read in by the read_dataset() function.
Definition: unv_io.h:214
This class defines an abstract interface for Mesh output.
Definition: mesh_output.h:53
unsigned char max_elem_dimension_seen()
Definition: unv_io.C:386
The libMesh namespace provides an interface to certain functionality in the library.
void nodes_out(std::ostream &out_file)
Outputs nodes to the file out_file.
Definition: unv_io.C:872
static const std::string _groups_dataset_label
label for the groups dataset
Definition: unv_io.h:203
void elements_out(std::ostream &out_file)
Outputs the element data to the file out_file.
Definition: unv_io.C:934
This is the MeshBase class.
Definition: mesh_base.h:74
virtual void write(const std::string &) override
This method implements writing a mesh to a specified file.
Definition: unv_io.C:259
This class defines an abstract interface for Mesh input.
Definition: mesh_base.h:56
std::map< unsigned, unsigned > _unv_elem_id_to_libmesh_elem_id
Map UNV element IDs to libmesh element IDs.
Definition: unv_io.h:208
bool need_D_to_e(std::string &number)
Replaces "1.1111D+00" with "1.1111e+00" if necessary.
Definition: unv_io.C:402
const std::vector< Number > * get_data(Node *node) const
Definition: unv_io.C:1319
virtual ~UNVIO()
Destructor.
static const std::string _nodes_dataset_label
label for the node dataset
Definition: unv_io.h:193
virtual void read(const std::string &) override
This method implements reading a mesh from a specified file.
Definition: unv_io.C:98
void elements_in(std::istream &in_file)
Method reads elements and stores them in std::vector<Elem *> _elements in the same order as they come...
Definition: unv_io.C:585
The UNVIO class implements the Ideas UNV universal file format.
Definition: unv_io.h:52
void groups_in(std::istream &in_file)
Reads the "groups" section of the file.
Definition: unv_io.C:419