PeriDEM 0.2.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
writer.h
Go to the documentation of this file.
1/*
2 * -------------------------------------------
3 * Copyright (c) 2021 - 2024 Prashant K. Jha
4 * -------------------------------------------
5 * PeriDEM https://github.com/prashjha/PeriDEM
6 *
7 * Distributed under the Boost Software License, Version 1.0. (See accompanying
8 * file LICENSE)
9 */
10
11#ifndef RW_WRITER_H
12#define RW_WRITER_H
13
14#include "util/point.h" // definition of Point
15#include "util/matrix.h" // definition of SymMatrix3
16#include <cstdint> // uint8_t type
17#include <cstring> // string and size_t type
18#include <vector>
19
20// forward declaration
21namespace rw {
22namespace writer {
23class VtkWriter;
24class LegacyVtkWriter;
25class MshWriter;
26}
27} // namespace rw
28
29namespace rw {
30
37namespace writer {
38
44class Writer {
45
46public:
50 Writer();
51
63 explicit Writer(const std::string &filename, const std::string &format =
64 "vtu", const std::string &compress_type = "");
65
67 ~Writer();
68
76 void open(const std::string &filename, const std::string &format = "vtu",
77 const std::string &compress_type = "");
78
89 void appendNodes(const std::vector<util::Point> *nodes,
90 const std::vector<util::Point> *u = nullptr);
91
100 void appendMesh(const std::vector<util::Point> *nodes,
101 const size_t &element_type,
102 const std::vector<size_t> *en_con,
103 const std::vector<util::Point> *u = nullptr);
104
117 void appendPointData(const std::string &name,
118 const std::vector<uint8_t> *data);
119
125 void appendPointData(const std::string &name,
126 const std::vector<size_t> *data);
127
133 void appendPointData(const std::string &name, const std::vector<int> *data);
134
140 void appendPointData(const std::string &name, const std::vector<float> *data);
141
147 void appendPointData(const std::string &name,
148 const std::vector<double> *data);
149
155 void appendPointData(const std::string &name,
156 const std::vector<util::Point> *data);
157
164 void appendPointData(const std::string &name,
165 const std::vector<util::SymMatrix3> *data);
166
179 void appendCellData(const std::string &name, const std::vector<float> *data);
180
186 void appendCellData(const std::string &name,
187 const std::vector<util::SymMatrix3> *data);
188
201 void appendFieldData(const std::string &name, const double &data);
202
208 void appendFieldData(const std::string &name, const float &data);
209
214 void addTimeStep(const double &timestep);
215
221 void close();
222
223private:
226
229
232
234 std::string d_format;
235
236}; // class Writer
237
238} // namespace writer
239
240} // namespace rw
241
242#endif // RW_WRITER_H
A vtk writer for simple point data and complex fem mesh data.
A .msh writer for simple point data and complex fem mesh data.
Definition mshWriter.h:24
A vtk writer for simple point data and complex fem mesh data.
Definition vtkWriter.h:28
A interface class writing data.
Definition writer.h:44
void appendCellData(const std::string &name, const std::vector< float > *data)
Writes the float data associated to cells to the file.
Definition writer.cpp:150
rw::writer::MshWriter * d_mshWriter_p
Pointer to the vtk writer class.
Definition writer.h:231
void appendFieldData(const std::string &name, const double &data)
Writes the scalar field data to the file.
Definition writer.cpp:182
void appendNodes(const std::vector< util::Point > *nodes, const std::vector< util::Point > *u=nullptr)
Writes the nodes to the file.
Definition writer.cpp:49
void addTimeStep(const double &timestep)
Writes the time step to the file.
Definition writer.cpp:172
void appendPointData(const std::string &name, const std::vector< uint8_t > *data)
Writes the scalar point data to the file.
Definition writer.cpp:73
std::string d_format
Format of output file.
Definition writer.h:234
~Writer()
Destructor.
Definition writer.cpp:45
void open(const std::string &filename, const std::string &format="vtu", const std::string &compress_type="")
Open a .vtu file.
Definition writer.cpp:28
Writer()
Constructor.
Definition writer.cpp:16
void close()
Closes the file and store it to the hard disk.
Definition writer.cpp:204
rw::writer::VtkWriter * d_vtkWriter_p
Pointer to the vtk writer class.
Definition writer.h:225
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.
Definition writer.cpp:61
rw::writer::LegacyVtkWriter * d_legacyVtkWriter_p
Pointer to the vtk writer class.
Definition writer.h:228
Collection of methods and database related to reading and writing.