mesh_input.h
Go to the documentation of this file.00001 // The libMesh Finite Element Library. 00002 // Copyright (C) 2002-2012 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner 00003 00004 // This library is free software; you can redistribute it and/or 00005 // modify it under the terms of the GNU Lesser General Public 00006 // License as published by the Free Software Foundation; either 00007 // version 2.1 of the License, or (at your option) any later version. 00008 00009 // This library is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 // Lesser General Public License for more details. 00013 00014 // You should have received a copy of the GNU Lesser General Public 00015 // License along with this library; if not, write to the Free Software 00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 00018 00019 00020 #ifndef LIBMESH_MESH_INPUT_H 00021 #define LIBMESH_MESH_INPUT_H 00022 00023 00024 // Local includes 00025 #include "libmesh/libmesh_common.h" 00026 #include "libmesh/mesh_base.h" 00027 00028 // C++ includes 00029 #include <cstddef> 00030 #include <istream> 00031 #include <string> 00032 #include <vector> 00033 00034 namespace libMesh 00035 { 00036 00037 00038 00048 // ------------------------------------------------------------ 00049 // MeshInput class definition 00050 template <class MT> 00051 class MeshInput 00052 { 00053 protected: 00054 00059 explicit 00060 MeshInput (bool is_parallel_format = false); 00061 00066 explicit 00067 MeshInput (MT&, const bool is_parallel_format = false); 00068 00069 public: 00070 00074 virtual ~MeshInput (); 00075 00079 virtual void read (const std::string&) = 0; 00080 00081 00082 protected: 00083 00087 MT& mesh (); 00088 00093 std::vector<bool> elems_of_dimension; 00094 00099 void skip_comment_lines (std::istream& in, 00100 const char comment_start); 00101 00102 00103 private: 00104 00105 00110 MT* _obj; 00111 00117 const bool _is_parallel_format; 00118 }; 00119 00120 00121 00122 // ------------------------------------------------------------ 00123 // MeshInput inline members 00124 template <class MT> 00125 inline 00126 MeshInput<MT>::MeshInput (const bool is_parallel_format) : 00127 elems_of_dimension(), 00128 _obj (NULL), 00129 _is_parallel_format(is_parallel_format) 00130 { 00131 } 00132 00133 00134 00135 template <class MT> 00136 inline 00137 MeshInput<MT>::MeshInput (MT& obj, const bool is_parallel_format) : 00138 elems_of_dimension(), 00139 _obj (&obj), 00140 _is_parallel_format(is_parallel_format) 00141 { 00142 if (!_is_parallel_format && !this->mesh().is_serial()) 00143 { 00144 if (libMesh::processor_id() == 0) 00145 { 00146 libmesh_do_once(libMesh::out << 00147 "Warning: This MeshOutput subclass only supports meshes which have been serialized!" 00148 << std::endl;); 00149 } 00150 } 00151 } 00152 00153 00154 00155 template <class MT> 00156 inline 00157 MeshInput<MT>::~MeshInput () 00158 { 00159 } 00160 00161 00162 00163 template <class MT> 00164 inline 00165 MT& MeshInput<MT>::mesh () 00166 { 00167 if (_obj == NULL) libmesh_error(); 00168 return *_obj; 00169 } 00170 00171 00172 00173 template <class MT> 00174 void MeshInput<MT>::skip_comment_lines (std::istream &in, 00175 const char comment_start) 00176 { 00177 char c, line[256]; 00178 00179 while (in.get(c), c==comment_start) 00180 in.getline (line, 255); 00181 00182 // put back first character of 00183 // first non-comment line 00184 in.putback (c); 00185 } 00186 00187 00188 } // namespace libMesh 00189 00190 00191 #endif // LIBMESH_MESH_INPUT_H
Site Created By: libMesh Developers
Last modified: February 05 2013 19:54:47 UTC
Hosted By: