$extrastylesheet
00001 // The libMesh Finite Element Library. 00002 // Copyright (C) 2002-2014 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_OUTPUT_H 00021 #define LIBMESH_MESH_OUTPUT_H 00022 00023 00024 // Local includes 00025 #include "libmesh/libmesh_common.h" 00026 #include "libmesh/libmesh_logging.h" 00027 #include "libmesh/mesh_base.h" 00028 #include "libmesh/mesh_serializer.h" 00029 00030 // C++ includes 00031 #include <cstddef> 00032 #include <limits> 00033 #include <string> 00034 #include <vector> 00035 00036 namespace libMesh 00037 { 00038 00039 // Forward declares 00040 class EquationSystems; 00041 00042 00052 // ------------------------------------------------------------ 00053 // MeshOutput class definition 00054 template <class MT> 00055 class MeshOutput 00056 { 00057 protected: 00058 00063 explicit 00064 MeshOutput (const bool is_parallel_format = false); 00065 00070 explicit 00071 MeshOutput (const MT&, const bool is_parallel_format = false); 00072 00073 00074 public: 00075 00079 virtual ~MeshOutput (); 00080 00084 virtual void write (const std::string&) = 0; 00085 00090 virtual void write_equation_systems (const std::string&, 00091 const EquationSystems&, 00092 const std::set<std::string>* system_names=NULL); 00093 00098 virtual void write_nodal_data (const std::string&, 00099 const std::vector<Number>&, 00100 const std::vector<std::string>&) 00101 { libmesh_not_implemented(); } 00102 00110 unsigned int & ascii_precision (); 00111 00112 protected: 00113 00114 00118 const MT& mesh() const; 00119 00120 00126 const bool _is_parallel_format; 00127 00128 00129 private: 00130 00131 00136 const MT* const _obj; 00137 00141 unsigned int _ascii_precision; 00142 00149 void _build_variable_names_and_solution_vector(const EquationSystems& es, 00150 std::vector<Number>& soln, 00151 std::vector<std::string>& names, 00152 const std::set<std::string>* system_names=NULL); 00153 }; 00154 00155 00156 00157 00158 00159 00160 // ------------------------------------------------------------ 00161 // MeshOutput inline members 00162 template <class MT> 00163 inline 00164 MeshOutput<MT>::MeshOutput (const bool is_parallel_format) : 00165 _is_parallel_format(is_parallel_format), 00166 _obj(NULL), 00167 _ascii_precision (std::numeric_limits<Real>::digits10 + 2) 00168 {} 00169 00170 00171 00172 template <class MT> 00173 inline 00174 MeshOutput<MT>::MeshOutput (const MT& obj, const bool is_parallel_format) : 00175 _is_parallel_format(is_parallel_format), 00176 _obj (&obj), 00177 _ascii_precision (std::numeric_limits<Real>::digits10 + 2) 00178 { 00179 if (!_is_parallel_format && !this->mesh().is_serial()) 00180 { 00181 if (this->mesh().processor_id() == 0) 00182 { 00183 libmesh_do_once(libMesh::out << 00184 "Warning: This MeshOutput subclass only supports meshes which have been serialized!" 00185 << std::endl;); 00186 } 00187 } 00188 } 00189 00190 00191 00192 template <class MT> 00193 inline 00194 MeshOutput<MT>::~MeshOutput () 00195 { 00196 } 00197 00198 00199 00200 template <class MT> 00201 inline 00202 const MT& MeshOutput<MT>::mesh () const 00203 { 00204 libmesh_assert(_obj); 00205 return *_obj; 00206 } 00207 00208 00209 00210 template <class MT> 00211 inline 00212 unsigned int & MeshOutput<MT>::ascii_precision () 00213 { 00214 return _ascii_precision; 00215 } 00216 00217 00218 } // namespace libMesh 00219 00220 00221 #endif // LIBMESH_MESH_OUTPUT_H