17 : d_vtkWriter_p(nullptr), d_legacyVtkWriter_p(nullptr),
18 d_mshWriter_p(nullptr), d_format(
"vtu") {}
21 const std::string &format,
22 const std::string &compress_type)
23 : d_vtkWriter_p(nullptr), d_legacyVtkWriter_p(nullptr),
24 d_mshWriter_p(nullptr), d_format(
"vtu") {
25 open(filename, format, compress_type);
29 const std::string &format,
30 const std::string &compress_type) {
32 if (d_format ==
"vtu")
34 else if (d_format ==
"msh")
36 else if (d_format ==
"legacy_vtk")
40 std::cerr <<
"File format " << d_format <<
" is not supported.\n";
46 delete (d_vtkWriter_p);
50 const std::vector<util::Point> *nodes,
51 const std::vector<util::Point> *u) {
53 if (d_format ==
"vtu")
54 d_vtkWriter_p->appendNodes(nodes, u);
55 else if (d_format ==
"msh")
56 d_mshWriter_p->appendNodes(nodes, u);
57 else if (d_format ==
"legacy_vtk")
58 d_legacyVtkWriter_p->appendNodes(nodes, u);
62 const std::vector<util::Point> *nodes,
const size_t &element_type,
63 const std::vector<size_t> *en_con,
const std::vector<util::Point> *u) {
65 if (d_format ==
"vtu")
66 d_vtkWriter_p->appendMesh(nodes, element_type, en_con, u);
67 else if (d_format ==
"msh")
68 d_mshWriter_p->appendMesh(nodes, element_type, en_con, u);
69 else if (d_format ==
"legacy_vtk")
70 d_legacyVtkWriter_p->appendMesh(nodes, element_type, en_con, u);
74 const std::string &name,
const std::vector<uint8_t> *data) {
76 if (d_format ==
"vtu")
77 d_vtkWriter_p->appendPointData(name, data);
78 else if (d_format ==
"msh")
79 d_mshWriter_p->appendPointData(name, data);
80 else if (d_format ==
"legacy_vtk")
81 d_legacyVtkWriter_p->appendPointData(name, data);
85 const std::string &name,
const std::vector<size_t> *data) {
87 if (d_format ==
"vtu")
88 d_vtkWriter_p->appendPointData(name, data);
89 else if (d_format ==
"msh")
90 d_mshWriter_p->appendPointData(name, data);
91 else if (d_format ==
"legacy_vtk")
92 d_legacyVtkWriter_p->appendPointData(name, data);
96 const std::string &name,
const std::vector<int> *data) {
98 if (d_format ==
"vtu")
99 d_vtkWriter_p->appendPointData(name, data);
100 else if (d_format ==
"msh")
101 d_mshWriter_p->appendPointData(name, data);
102 else if (d_format ==
"legacy_vtk")
103 d_legacyVtkWriter_p->appendPointData(name, data);
107 const std::string &name,
const std::vector<float> *data) {
109 if (d_format ==
"vtu")
110 d_vtkWriter_p->appendPointData(name, data);
111 else if (d_format ==
"msh")
112 d_mshWriter_p->appendPointData(name, data);
113 else if (d_format ==
"legacy_vtk")
114 d_legacyVtkWriter_p->appendPointData(name, data);
118 const std::string &name,
const std::vector<double> *data) {
120 if (d_format ==
"vtu")
121 d_vtkWriter_p->appendPointData(name, data);
122 else if (d_format ==
"msh")
123 d_mshWriter_p->appendPointData(name, data);
124 else if (d_format ==
"legacy_vtk")
125 d_legacyVtkWriter_p->appendPointData(name, data);
129 const std::string &name,
const std::vector<util::Point> *data) {
131 if (d_format ==
"vtu")
132 d_vtkWriter_p->appendPointData(name, data);
133 else if (d_format ==
"msh")
134 d_mshWriter_p->appendPointData(name, data);
135 else if (d_format ==
"legacy_vtk")
136 d_legacyVtkWriter_p->appendPointData(name, data);
140 const std::string &name,
const std::vector<util::SymMatrix3> *data) {
142 if (d_format ==
"vtu")
143 d_vtkWriter_p->appendPointData(name, data);
144 else if (d_format ==
"msh")
145 d_mshWriter_p->appendPointData(name, data);
146 else if (d_format ==
"legacy_vtk")
147 d_legacyVtkWriter_p->appendPointData(name, data);
151 const std::string &name,
const std::vector<float> *data) {
153 if (d_format ==
"vtu")
154 d_vtkWriter_p->appendCellData(name, data);
155 else if (d_format ==
"msh")
156 d_mshWriter_p->appendCellData(name, data);
157 else if (d_format ==
"legacy_vtk")
158 d_legacyVtkWriter_p->appendCellData(name, data);
162 const std::string &name,
const std::vector<util::SymMatrix3> *data) {
164 if (d_format ==
"vtu")
165 d_vtkWriter_p->appendCellData(name, data);
166 else if (d_format ==
"msh")
167 d_mshWriter_p->appendCellData(name, data);
168 else if (d_format ==
"legacy_vtk")
169 d_legacyVtkWriter_p->appendCellData(name, data);
174 if (d_format ==
"vtu")
175 d_vtkWriter_p->addTimeStep(timestep);
176 else if (d_format ==
"msh")
177 d_mshWriter_p->addTimeStep(timestep);
178 else if (d_format ==
"legacy_vtk")
179 d_legacyVtkWriter_p->addTimeStep(timestep);
183 const double &data) {
185 if (d_format ==
"vtu")
186 d_vtkWriter_p->appendFieldData(name, data);
187 else if (d_format ==
"msh")
188 d_mshWriter_p->appendFieldData(name, data);
189 else if (d_format ==
"legacy_vtk")
190 d_legacyVtkWriter_p->appendFieldData(name, data);
196 if (d_format ==
"vtu")
197 d_vtkWriter_p->appendFieldData(name, data);
198 else if (d_format ==
"msh")
199 d_mshWriter_p->appendFieldData(name, data);
200 else if (d_format ==
"legacy_vtk")
201 d_legacyVtkWriter_p->appendFieldData(name, data);
206 if (d_format ==
"vtu")
207 d_vtkWriter_p->close();
208 else if (d_format ==
"msh")
209 d_mshWriter_p->close();
210 else if (d_format ==
"legacy_vtk")
211 d_legacyVtkWriter_p->close();
A vtk writer for simple point data and complex fem mesh data.
A .msh writer for simple point data and complex fem mesh data.
A vtk writer for simple point data and complex fem mesh data.
void appendCellData(const std::string &name, const std::vector< float > *data)
Writes the float data associated to cells to the file.
void appendFieldData(const std::string &name, const double &data)
Writes the scalar field data to the file.
void appendNodes(const std::vector< util::Point > *nodes, const std::vector< util::Point > *u=nullptr)
Writes the nodes to the file.
void addTimeStep(const double ×tep)
Writes the time step to the file.
void appendPointData(const std::string &name, const std::vector< uint8_t > *data)
Writes the scalar point data to the file.
void open(const std::string &filename, const std::string &format="vtu", const std::string &compress_type="")
Open a .vtu file.
void close()
Closes the file and store it to the hard disk.
void appendMesh(const std::vector< util::Point > *nodes, const size_t &element_type, const std::vector< size_t > *en_con, const std::vector< util::Point > *u=nullptr)
Writes the mesh data to file.