$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 #ifndef LIBMESH_ENSIGHT_IO_H 00020 #define LIBMESH_ENSIGHT_IO_H 00021 00022 // libMesh includes 00023 #include "libmesh/libmesh.h" 00024 #include "libmesh/enum_elem_type.h" 00025 #include "libmesh/mesh_base.h" 00026 #include "libmesh/mesh_output.h" 00027 00028 // C++ includes 00029 #include <map> 00030 #include <string> 00031 #include <vector> 00032 00033 namespace libMesh 00034 { 00035 00036 // Forward declarations 00037 class EquationSystems; 00038 00043 class EnsightIO : public MeshOutput<MeshBase> 00044 { 00045 public: 00046 00050 EnsightIO (const std::string &filename, const EquationSystems &eq); 00051 00052 ~EnsightIO (); 00053 00058 void add_vector (const std::string &system, const std::string &vec_description, 00059 const std::string &u, const std::string &v); 00060 00064 void add_vector (const std::string &system, const std::string &vec_description, 00065 const std::string &u, const std::string &v, const std::string &w); 00066 00070 void add_scalar (const std::string &system, const std::string &scalar_description, 00071 const std::string &s); 00072 00076 virtual void write (const std::string &name); 00077 00081 void write (const double time = 0); 00082 00083 bool& has_mesh_refinement(); 00084 00085 private: 00086 00087 // Define aux. structures 00088 00089 // Represents the vectors that are used by the EnsightIO 00090 struct Vectors 00091 { 00092 std::string description; 00093 std::vector<std::string> components; 00094 }; 00095 00096 // Represents the scalars 00097 struct Scalars 00098 { 00099 std::string scalar_name; 00100 std::string description; 00101 }; 00102 00103 // Store the variables of system 00104 struct SystemVars 00105 { 00106 std::vector<Vectors> EnsightVectors; 00107 std::vector<Scalars> EnsightScalars; 00108 }; 00109 00110 00111 typedef std::map <std::string, SystemVars> SystemsVarsMap; 00112 typedef std::map <std::string, SystemVars>::iterator SystemsVarsMapIterator; 00113 typedef std::pair<std::string, SystemVars> SystemsVarsValue; 00114 00115 // private methods 00116 // write solution in ascii format file 00117 void write_ascii (const double time = 0); 00118 void write_scalar_ascii (const std::string &sys, const std::string &var); 00119 void write_vector_ascii (const std::string &sys, const std::vector<std::string> &vec, const std::string &var_name); 00120 void write_solution_ascii (); 00121 void write_geometry_ascii (); 00122 00123 00124 void write_case(); 00125 void elem_type_to_string (ElemType, char*); 00126 00127 // private Attributes 00128 std::string _ensight_file_name; 00129 std::vector<double> _time_steps; 00130 SystemsVarsMap _systems_vars_map; 00131 const EquationSystems &_equation_systems; 00132 }; 00133 00134 00135 } // namespace libMesh 00136 00137 00138 #endif // LIBMESH_ENSIGHT_IO_H