libMesh
Loading...
Searching...
No Matches
ensight_io.h
Go to the documentation of this file.
1// The libMesh Finite Element Library.
2// Copyright (C) 2002-2026 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/mesh_base.h"
25#include "libmesh/mesh_output.h"
26
27// C++ includes
28#include <map>
29#include <string>
30#include <vector>
31
32namespace libMesh
33{
34
35// Forward declarations
36class EquationSystems;
37enum ElemType : int;
38
47class EnsightIO : public MeshOutput<MeshBase>
48{
49public:
50
54 EnsightIO (const std::string & filename,
55 const EquationSystems & eq);
56
60 ~EnsightIO () = default;
61
69 void add_scalar (const std::string & system,
70 std::string_view scalar_description,
71 std::string_view s);
72
80 void add_vector (const std::string & system,
81 std::string_view vec_description,
82 std::string u,
83 std::string v);
84
92 void add_vector (const std::string & system,
93 std::string_view vec_description,
94 std::string u,
95 std::string v,
96 std::string w);
105 void write (Real time = 0);
106
110 virtual void write (const std::string & name) override;
111
112private:
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
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 (std::string_view sys, std::string_view var);
138 void write_vector_ascii (std::string_view sys, const std::vector<std::string> & vec, std::string_view var_name);
139 void write_solution_ascii ();
140 void write_geometry_ascii ();
141 void write_case();
142
143 // private Attributes
145 std::vector<Real> _time_steps;
146
147 // mapping from system names to variable names+descriptions
148 std::map <std::string, SystemVars> _system_vars_map;
149
150 // Reference to the EquationSystems we were constructed with
152
153 // static mapping between libmesh ElemTypes and Ensight element strings.
154 static std::map<ElemType, std::string> _element_map;
155
156 // Static function used to build the _element_map.
157 static std::map<ElemType, std::string> build_element_map();
158};
159
160
161} // namespace libMesh
162
163
164#endif // LIBMESH_ENSIGHT_IO_H
void ErrorVector unsigned int
This class implements writing meshes and solutions in Ensight's Gold format.
Definition ensight_io.h:48
~EnsightIO()=default
Empty destructor.
std::vector< Real > _time_steps
Definition ensight_io.h:145
void write_ascii(Real time=0)
Definition ensight_io.C:160
const EquationSystems & _equation_systems
Definition ensight_io.h:151
void write_scalar_ascii(std::string_view sys, std::string_view var)
Definition ensight_io.C:334
void write(Real time=0)
Calls write_ascii() and write_case().
Definition ensight_io.C:152
static std::map< ElemType, std::string > build_element_map()
Definition ensight_io.C:45
void write_geometry_ascii()
Definition ensight_io.C:170
void write_solution_ascii()
Definition ensight_io.C:318
void add_scalar(const std::string &system, std::string_view scalar_description, std::string_view s)
Tell the EnsightIO interface to output the finite element (not SCALAR) variable named "s".
Definition ensight_io.C:122
std::map< std::string, SystemVars > _system_vars_map
Definition ensight_io.h:148
std::string _ensight_file_name
Definition ensight_io.h:144
static std::map< ElemType, std::string > _element_map
Definition ensight_io.h:154
void add_vector(const std::string &system, std::string_view vec_description, std::string u, std::string v)
Tell the EnsightIO interface that the variables (u,v) constitute a vector.
Definition ensight_io.C:82
void write_vector_ascii(std::string_view sys, const std::vector< std::string > &vec, std::string_view var_name)
Definition ensight_io.C:405
This is the EquationSystems class.
This class defines an abstract interface for Mesh output.
Definition mesh_output.h:54
The libMesh namespace provides an interface to certain functionality in the library.
ElemType
Defines an enum for geometric element types.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::vector< Scalars > EnsightScalars
Definition ensight_io.h:131
std::vector< Vectors > EnsightVectors
Definition ensight_io.h:130
std::vector< std::string > components
Definition ensight_io.h:117