libMesh
ensight_io.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2017 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 #ifndef LIBMESH_ENSIGHT_IO_H
20 #define LIBMESH_ENSIGHT_IO_H
21 
22 // libMesh includes
23 #include "libmesh/libmesh.h"
24 #include "libmesh/enum_elem_type.h"
25 #include "libmesh/mesh_base.h"
26 #include "libmesh/mesh_output.h"
27 
28 // C++ includes
29 #include <map>
30 #include <string>
31 #include <vector>
32 
33 namespace libMesh
34 {
35 
36 // Forward declarations
37 class EquationSystems;
38 
47 class EnsightIO : public MeshOutput<MeshBase>
48 {
49 public:
50 
54  EnsightIO (const std::string & filename,
55  const EquationSystems & eq);
56 
60  ~EnsightIO () {}
61 
69  void add_scalar (const std::string & system,
70  const std::string & scalar_description,
71  const std::string & s);
72 
80  void add_vector (const std::string & system,
81  const std::string & vec_description,
82  const std::string & u,
83  const std::string & v);
84 
92  void add_vector (const std::string & system,
93  const std::string & vec_description,
94  const std::string & u,
95  const std::string & v,
96  const std::string & w);
105  void write (Real time = 0);
106 
110  virtual void write (const std::string & name) libmesh_override;
111 
112 private:
113  // Represents the vectors that are used by the EnsightIO
114  struct Vectors
115  {
116  std::string description;
117  std::vector<std::string> components;
118  };
119 
120  // Represents the scalars
121  struct Scalars
122  {
123  std::string scalar_name;
124  std::string description;
125  };
126 
127  // Store the variables of system
128  struct SystemVars
129  {
130  std::vector<Vectors> EnsightVectors;
131  std::vector<Scalars> EnsightScalars;
132  };
133 
134  // private methods
135  // write solution in ascii format file
136  void write_ascii (Real time = 0);
137  void write_scalar_ascii (const std::string & sys, const std::string & var);
138  void write_vector_ascii (const std::string & sys, const std::vector<std::string> & vec, const std::string & var_name);
139  void write_solution_ascii ();
140  void write_geometry_ascii ();
141  void write_case();
142 
143  // private Attributes
144  std::string _ensight_file_name;
145  std::vector<Real> _time_steps;
146 
147  // mapping from system names to variable names+descriptions
148  typedef std::map <std::string, SystemVars> system_vars_map_t;
149  system_vars_map_t _system_vars_map;
150 
151  // Reference to the EquationSystems we were constructed with
153 
154  // static mapping between libmesh ElemTypes and Ensight element strings.
155  static std::map<ElemType, std::string> _element_map;
156 
157  // Static function used to build the _element_map.
158  static std::map<ElemType, std::string> build_element_map();
159 };
160 
161 
162 } // namespace libMesh
163 
164 
165 #endif // LIBMESH_ENSIGHT_IO_H
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:39
void write_solution_ascii()
Definition: ensight_io.C:342
void write_geometry_ascii()
Definition: ensight_io.C:165
std::string _ensight_file_name
Definition: ensight_io.h:144
This is the EquationSystems class.
std::map< std::string, SystemVars > system_vars_map_t
Definition: ensight_io.h:148
EnsightIO(const std::string &filename, const EquationSystems &eq)
Constructor.
Definition: ensight_io.C:60
static std::map< ElemType, std::string > build_element_map()
Definition: ensight_io.C:40
std::vector< std::string > components
Definition: ensight_io.h:117
ImplicitSystem & sys
std::vector< Scalars > EnsightScalars
Definition: ensight_io.h:131
PetscBool eq
void write_scalar_ascii(const std::string &sys, const std::string &var)
Definition: ensight_io.C:361
This class defines an abstract interface for Mesh output.
Definition: mesh_output.h:53
The libMesh namespace provides an interface to certain functionality in the library.
void add_vector(const std::string &system, const std::string &vec_description, const std::string &u, const std::string &v)
Tell the EnsightIO interface that the variables (u,v) constitute a vector.
Definition: ensight_io.C:77
~EnsightIO()
Empty destructor.
Definition: ensight_io.h:60
static std::map< ElemType, std::string > _element_map
Definition: ensight_io.h:155
system_vars_map_t _system_vars_map
Definition: ensight_io.h:149
void write_vector_ascii(const std::string &sys, const std::vector< std::string > &vec, const std::string &var_name)
Definition: ensight_io.C:438
void write(Real time=0)
Calls write_ascii() and write_case().
Definition: ensight_io.C:147
const EquationSystems & _equation_systems
Definition: ensight_io.h:152
void add_scalar(const std::string &system, const std::string &scalar_description, const std::string &s)
Tell the EnsightIO interface to output the finite element (not SCALAR) variable named "s"...
Definition: ensight_io.C:117
This class implements writing meshes and solutions in Ensight&#39;s Gold format.
Definition: ensight_io.h:47
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::vector< Real > _time_steps
Definition: ensight_io.h:145
void write_ascii(Real time=0)
Definition: ensight_io.C:155
std::vector< Vectors > EnsightVectors
Definition: ensight_io.h:130