NLMech  0.1.0
mshWriter.h
1 // Copyright (c) 2019 Prashant K. Jha
2 //
3 // Distributed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
4 // (See accompanying file LICENSE.txt)
5 
6 #ifndef RW_MSHWRITER_H
7 #define RW_MSHWRITER_H
8 
9 #include "util/matrix.h" // definition of SymMatrix3
10 #include "util/point.h" // definition of Point3
11 #include <fstream>
12 #include <vector>
13 
14 namespace rw {
15 
16 namespace writer {
17 
22 class MshWriter {
23 
24 public:
34  explicit MshWriter(const std::string &filename, const std::string &compress_type = "");
35 
46  void appendNodes(const std::vector<util::Point3> *nodes,
47  const std::vector<util::Point3> *u = nullptr);
48 
57  void appendMesh(const std::vector<util::Point3> *nodes,
58  const size_t &element_type,
59  const std::vector<size_t> *en_con,
60  const std::vector<util::Point3> *u = nullptr);
61 
74  void appendPointData(const std::string &name,
75  const std::vector<uint8_t> *data);
76 
82  void appendPointData(const std::string &name,
83  const std::vector<size_t> *data);
84 
90  void appendPointData(const std::string &name, const std::vector<int> *data);
91 
97  void appendPointData(const std::string &name, const std::vector<float> *data);
98 
104  void appendPointData(const std::string &name,
105  const std::vector<double> *data);
106 
112  void appendPointData(const std::string &name,
113  const std::vector<util::Point3> *data);
114 
121  void appendPointData(const std::string &name,
122  const std::vector<util::SymMatrix3> *data);
123 
136  void appendCellData(const std::string &name, const std::vector<float> *data);
137 
143  void appendCellData(const std::string &name,
144  const std::vector<util::SymMatrix3> *data);
145 
158  void appendFieldData(const std::string &name, const double &data);
159 
165  void appendFieldData(const std::string &name, const float &data);
166 
171  void addTimeStep(const double &timestep);
172 
178  void close();
179 
180 private:
194  void writeMshDataHeader(const std::string &name, int field_type,
195  size_t num_data, bool is_node_data = true);
196 
198  std::string d_filename;
199 
201  std::string d_compressType;
202 
204  FILE *d_file;
205 };
206 
207 } // namespace writer
208 
209 } // namespace rw
210 
211 #endif // RW_MSHWRITER_H
A .msh writer for simple point data and complex fem mesh data.
Definition: mshWriter.h:22
std::string d_compressType
compression_type Specify the compressor (if any)
Definition: mshWriter.h:201
void addTimeStep(const double &timestep)
Writes the time step to the file.
Definition: mshWriter.cpp:214
void writeMshDataHeader(const std::string &name, int field_type, size_t num_data, bool is_node_data=true)
utility function
Definition: mshWriter.cpp:19
FILE * d_file
vtk/vtu file
Definition: mshWriter.h:204
void appendFieldData(const std::string &name, const double &data)
Writes the scalar field data to the file.
Definition: mshWriter.cpp:230
void close()
Closes the file and store it to the hard disk.
Definition: mshWriter.cpp:223
MshWriter(const std::string &filename, const std::string &compress_type="")
Constructor.
Definition: mshWriter.cpp:15
void appendPointData(const std::string &name, const std::vector< uint8_t > *data)
Writes the scalar point data to the file.
Definition: mshWriter.cpp:113
void appendMesh(const std::vector< util::Point3 > *nodes, const size_t &element_type, const std::vector< size_t > *en_con, const std::vector< util::Point3 > *u=nullptr)
Writes the mesh data to file.
Definition: mshWriter.cpp:84
void appendCellData(const std::string &name, const std::vector< float > *data)
Writes the float data associated to cells to the file.
Definition: mshWriter.cpp:191
void appendNodes(const std::vector< util::Point3 > *nodes, const std::vector< util::Point3 > *u=nullptr)
Writes the nodes to the file.
Definition: mshWriter.cpp:51
std::string d_filename
filename
Definition: mshWriter.h:198
Data mamanger to share the global simulation data between the classes.
Definition: DataManager.h:55
Collection of methods and database related to reading and writing.
Definition: QuasiStaticModel.h:60