[P]arallel [Hi]gh-order [Li]brary for [P]DEs  Latest
Parallel High-Order Library for PDEs through hp-adaptive Discontinuous Galerkin methods
msh_out.h
1 #ifndef __MSH_OUT_H__
2 #define __MSH_OUT_H__
3 
4 #include <deal.II/numerics/data_out.h>
5 #include <deal.II/grid/tria.h>
6 
7 namespace PHiLiP {
8 
9 namespace GridRefinement {
10 
12 enum class StorageType{
13  node,
14  element,
15  elementNode,
16 };
17 
19 enum class DataType{
20  scalar,
21  vector,
22  matrix,
23 };
24 
26 
33 template <int dim>
35 {
36 public:
38  virtual ~MshOutData() = default;
39 
41 
43  explicit MshOutData(
44  StorageType storage_type) :
45  storage_type(storage_type){};
46 
48 
52  void write_msh_data(
53  const dealii::DoFHandler<dim> &dof_handler,
54  std::ostream & out);
55 
56 protected:
58  StorageType storage_type;
59 
61 
65  std::vector<std::string> string_tags;
66 
68 
72  std::vector<double> real_tags;
73 
75 
79  std::vector<int> integer_tags;
80 
82 
86  virtual void write_msh_data_internal(
87  const dealii::DoFHandler<dim> &dof_handler,
88  std::ostream & out) = 0;
89 
91 
94  unsigned int num_entries(
95  const dealii::DoFHandler<dim> &dof_handler);
96 
98 
101  void set_string_tags(
102  std::string name,
103  std::string interpolation_scheme);
104 
106 
108  void set_string_tags(
109  std::string name);
110 
112 
115  void set_real_tags(
116  double time);
117 
118  // sets the integer tags
120 
123  void set_integer_tags(
124  unsigned int time_step,
125  unsigned int num_components,
126  unsigned int num_entries);
127 };
128 
130 
135 template <int dim, typename T>
136 class MshOutDataInternal : public MshOutData<dim>
137 {
138 public:
140 
145  std::vector<T> data,
146  StorageType storage_type,
147  const dealii::DoFHandler<dim> &dof_handler) :
148  MshOutData<dim>(storage_type),
149  data(data)
150  {
151  this->set_integer_tags(0, num_components, this->num_entries(dof_handler));
152  };
153 
155 
161  std::vector<T> data,
162  StorageType storage_type,
163  std::string name,
164  const dealii::DoFHandler<dim> &dof_handler) :
165  MshOutData<dim>(storage_type),
166  data(data)
167  {
168  this->set_integer_tags(0, num_components, this->num_entries(dof_handler));
169  this->set_string_tags(name);
170  }
171 
172 protected:
174 
178  void write_msh_data_internal(
179  const dealii::DoFHandler<dim> &dof_handler,
180  std::ostream & out) override;
181 
182 private:
184 
189  const std::vector<T> data;
190 
192 
195  static const unsigned int num_components;
196 };
197 
199 
207 template <int dim, typename real>
208 class MshOut
209 {
210 public:
212 
215  explicit MshOut(
216  const dealii::DoFHandler<dim> &dof_handler) :
217  dof_handler(dof_handler){};
218 
220 
228  template <typename T>
230  std::vector<T> data,
231  StorageType storage_type)
232  {
233  data_vector.push_back(
234  std::make_shared<MshOutDataInternal<dim,T>>(
235  data,
236  storage_type,
237  dof_handler));
238  }
239 
241 
249  template <typename T>
251  std::vector<T> data,
252  StorageType storage_type,
253  std::string name)
254  {
255  data_vector.push_back(
256  std::make_shared<MshOutDataInternal<dim,T>>(
257  data,
258  storage_type,
259  name,
260  dof_handler));
261  }
262 
264 
272  void write_msh(
273  std::ostream &out);
274 
275 private:
276  const dealii::DoFHandler<dim> & dof_handler;
277  std::vector<std::shared_ptr<MshOutData<dim>>> data_vector;
278 };
279 
280 } // namespace GridRefinement
281 
282 } //namespace PHiLiP
283 
284 #endif // __GMSH_OUT_H__
285 
Output class for GMSH .msh v4.1 file format.
Definition: msh_out.h:208
void add_data_vector(std::vector< T > data, StorageType storage_type)
Add data vector of specified storage type and values.
Definition: msh_out.h:229
void add_data_vector(std::vector< T > data, StorageType storage_type, std::string name)
Add data vector of specified storage type and values with name.
Definition: msh_out.h:250
Data structure class for data fields of .msh files.
Definition: msh_out.h:34
MshOutDataInternal(std::vector< T > data, StorageType storage_type, std::string name, const dealii::DoFHandler< dim > &dof_handler)
Construct data field with name.
Definition: msh_out.h:160
std::vector< double > real_tags
Real tags for the data field.
Definition: msh_out.h:72
Internal data handler class for .msh file data fields.
Definition: msh_out.h:136
Files for the baseline physics.
Definition: ADTypes.hpp:10
MshOutData(StorageType storage_type)
Delegated constructor.
Definition: msh_out.h:43
const dealii::DoFHandler< dim > & dof_handler
Mesh description for acccess to node location and connecitviity information.
Definition: msh_out.h:276
StorageType storage_type
Storage location of the .msh data field entries.
Definition: msh_out.h:58
MshOut(const dealii::DoFHandler< dim > &dof_handler)
Construct mesh output handler.
Definition: msh_out.h:215
const std::vector< T > data
Internal data storage vector.
Definition: msh_out.h:189
std::vector< int > integer_tags
Integer tags for the data field.
Definition: msh_out.h:79
MshOutDataInternal(std::vector< T > data, StorageType storage_type, const dealii::DoFHandler< dim > &dof_handler)
Construct data field.
Definition: msh_out.h:144
static const unsigned int num_components
The number of components per data point.
Definition: msh_out.h:195
std::vector< std::string > string_tags
String tags for the data field.
Definition: msh_out.h:65
std::vector< std::shared_ptr< MshOutData< dim > > > data_vector
Vector of data field entries stored in MshOutDataInternal based on data type of entries.
Definition: msh_out.h:277