mesh_input.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2014 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_MESH_INPUT_H
21 #define LIBMESH_MESH_INPUT_H
22 
23 
24 // Local includes
25 #include "libmesh/libmesh_common.h"
26 #include "libmesh/mesh_base.h"
27 
28 // C++ includes
29 #include <cstddef>
30 #include <istream>
31 #include <string>
32 #include <vector>
33 
34 namespace libMesh
35 {
36 
37 
38 
48 // ------------------------------------------------------------
49 // MeshInput class definition
50 template <class MT>
51 class MeshInput
52 {
53  protected:
54 
59  explicit
60  MeshInput (bool is_parallel_format = false);
61 
66  explicit
67  MeshInput (MT&, const bool is_parallel_format = false);
68 
69  public:
70 
74  virtual ~MeshInput ();
75 
79  virtual void read (const std::string&) = 0;
80 
81 
82  protected:
83 
87  MT& mesh ();
88 
93  std::vector<bool> elems_of_dimension;
94 
99  void skip_comment_lines (std::istream& in,
100  const char comment_start);
101 
102 
103  private:
104 
105 
110  MT* _obj;
111 
118 };
119 
120 
121 
122 // ------------------------------------------------------------
123 // MeshInput inline members
124 template <class MT>
125 inline
126 MeshInput<MT>::MeshInput (const bool is_parallel_format) :
127  elems_of_dimension(),
128  _obj (NULL),
129  _is_parallel_format(is_parallel_format)
130 {
131 }
132 
133 
134 
135 template <class MT>
136 inline
137 MeshInput<MT>::MeshInput (MT& obj, const bool is_parallel_format) :
138  elems_of_dimension(),
139  _obj (&obj),
140  _is_parallel_format(is_parallel_format)
141 {
142  if (!_is_parallel_format && !this->mesh().is_serial())
143  {
144  if (this->mesh().processor_id() == 0)
145  {
146  libmesh_do_once(libMesh::out <<
147  "Warning: This MeshOutput subclass only supports meshes which have been serialized!"
148  << std::endl;);
149  }
150  }
151 }
152 
153 
154 
155 template <class MT>
156 inline
158 {
159 }
160 
161 
162 
163 template <class MT>
164 inline
166 {
167  if (_obj == NULL) libmesh_error();
168  return *_obj;
169 }
170 
171 
172 
173 template <class MT>
174 void MeshInput<MT>::skip_comment_lines (std::istream &in,
175  const char comment_start)
176 {
177  char c, line[256];
178 
179  while (in.get(c), c==comment_start)
180  in.getline (line, 255);
181 
182  // put back first character of
183  // first non-comment line
184  in.putback (c);
185 }
186 
187 
188 } // namespace libMesh
189 
190 
191 #endif // LIBMESH_MESH_INPUT_H

Site Created By: libMesh Developers
Last modified: February 07 2014 16:57:06 UTC

Hosted By:
SourceForge.net Logo