PeriDEM 0.2.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
rw::writer::Writer Class Reference

A interface class writing data. More...

#include <writer.h>

Collaboration diagram for rw::writer::Writer:

Public Member Functions

 Writer ()
 Constructor.
 
 Writer (const std::string &filename, const std::string &format="vtu", const std::string &compress_type="")
 Constructor.
 
 ~Writer ()
 Destructor.
 
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.
 
Mesh data
void appendNodes (const std::vector< util::Point > *nodes, const std::vector< util::Point > *u=nullptr)
 Writes the nodes to the file.
 
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.
 
Point data
void appendPointData (const std::string &name, const std::vector< uint8_t > *data)
 Writes the scalar point data to the file.
 
void appendPointData (const std::string &name, const std::vector< size_t > *data)
 Writes the scalar point data to the file.
 
void appendPointData (const std::string &name, const std::vector< int > *data)
 Writes the scalar point data to the file.
 
void appendPointData (const std::string &name, const std::vector< float > *data)
 Writes the scalar point data to the file.
 
void appendPointData (const std::string &name, const std::vector< double > *data)
 Writes the scalar point data to the file.
 
void appendPointData (const std::string &name, const std::vector< util::Point > *data)
 Writes the vector point data to the file.
 
void appendPointData (const std::string &name, const std::vector< util::SymMatrix3 > *data)
 Writes the symmetric matrix data associated to nodes to the file.
 
Cell data
void appendCellData (const std::string &name, const std::vector< float > *data)
 Writes the float data associated to cells to the file.
 
void appendCellData (const std::string &name, const std::vector< util::SymMatrix3 > *data)
 Writes the symmetric matrix data associated to cells to the file.
 
Field data
void appendFieldData (const std::string &name, const double &data)
 Writes the scalar field data to the file.
 
void appendFieldData (const std::string &name, const float &data)
 Writes the scalar field data to the file.
 
void addTimeStep (const double &timestep)
 Writes the time step to the file.
 

Private Attributes

rw::writer::VtkWriterd_vtkWriter_p
 Pointer to the vtk writer class.
 
rw::writer::LegacyVtkWriterd_legacyVtkWriter_p
 Pointer to the vtk writer class.
 
rw::writer::MshWriterd_mshWriter_p
 Pointer to the vtk writer class.
 
std::string d_format
 Format of output file.
 

Detailed Description

A interface class writing data.

This interface separates the caller from vtk library.

Definition at line 44 of file writer.h.

Constructor & Destructor Documentation

◆ Writer() [1/2]

rw::writer::Writer::Writer ( )

Constructor.

Definition at line 16 of file writer.cpp.

17 : d_vtkWriter_p(nullptr), d_legacyVtkWriter_p(nullptr),
18 d_mshWriter_p(nullptr), d_format("vtu") {}
rw::writer::MshWriter * d_mshWriter_p
Pointer to the vtk writer class.
Definition writer.h:231
std::string d_format
Format of output file.
Definition writer.h:234
rw::writer::VtkWriter * d_vtkWriter_p
Pointer to the vtk writer class.
Definition writer.h:225
rw::writer::LegacyVtkWriter * d_legacyVtkWriter_p
Pointer to the vtk writer class.
Definition writer.h:228

◆ Writer() [2/2]

rw::writer::Writer::Writer ( const std::string &  filename,
const std::string &  format = "vtu",
const std::string &  compress_type = "" 
)
explicit

Constructor.

Creates and opens .vtu file of name given by filename. The file remains open till the close() function is invoked or if the instance of this class is destroyed.

Parameters
filenameName of file which will be created
formatFormat of the output file, e.g. "vtu", "msh"
compress_typeSpecify the compression type (optional)

Definition at line 20 of file writer.cpp.

23 : d_vtkWriter_p(nullptr), d_legacyVtkWriter_p(nullptr),
24 d_mshWriter_p(nullptr), d_format("vtu") {
25 open(filename, format, compress_type);
26}
void open(const std::string &filename, const std::string &format="vtu", const std::string &compress_type="")
Open a .vtu file.
Definition writer.cpp:28

References open().

Here is the call graph for this function:

◆ ~Writer()

rw::writer::Writer::~Writer ( )

Destructor.

Definition at line 45 of file writer.cpp.

45 {
46 delete (d_vtkWriter_p);
47}

Member Function Documentation

◆ addTimeStep()

void rw::writer::Writer::addTimeStep ( const double &  timestep)

Writes the time step to the file.

Parameters
timestepCurrent time step of the simulation

Definition at line 172 of file writer.cpp.

172 {
173
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")
180}
void addTimeStep(const double &timestep)
Writes the time step to the file.
void addTimeStep(const double &timestep)
Writes the time step to the file.
void addTimeStep(const double &timestep)
Writes the time step to the file.

◆ appendCellData() [1/2]

void rw::writer::Writer::appendCellData ( const std::string &  name,
const std::vector< float > *  data 
)

Writes the float data associated to cells to the file.

Parameters
nameName of the data
dataVector containing the data

Definition at line 150 of file writer.cpp.

151 {
152
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")
159}
void appendCellData(const std::string &name, const std::vector< float > *data)
Writes the float data associated to cells to the file.
void appendCellData(const std::string &name, const std::vector< float > *data)
Writes the float data associated to cells to the file.
void appendCellData(const std::string &name, const std::vector< float > *data)
Writes the float data associated to cells to the file.

◆ appendCellData() [2/2]

void rw::writer::Writer::appendCellData ( const std::string &  name,
const std::vector< util::SymMatrix3 > *  data 
)

Writes the symmetric matrix data associated to cells to the file.

Parameters
nameName of the data
dataVector containing the data

Definition at line 161 of file writer.cpp.

162 {
163
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")
170}

◆ appendFieldData() [1/2]

void rw::writer::Writer::appendFieldData ( const std::string &  name,
const double &  data 
)

Writes the scalar field data to the file.

Parameters
nameName of the data
dataValue

Definition at line 182 of file writer.cpp.

183 {
184
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")
191}
void appendFieldData(const std::string &name, const double &data)
Writes the scalar field data to the file.
void appendFieldData(const std::string &name, const double &data)
Writes the scalar field data to the file.
void appendFieldData(const std::string &name, const double &data)
Writes the scalar field data to the file.

◆ appendFieldData() [2/2]

void rw::writer::Writer::appendFieldData ( const std::string &  name,
const float &  data 
)

Writes the scalar field data to the file.

Parameters
nameName of the data
dataValue

Definition at line 193 of file writer.cpp.

194 {
195
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")
202}

◆ appendMesh()

void rw::writer::Writer::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.

Parameters
nodesVector of nodal coordinates
element_typeType of element
en_conVector of element-node connectivity
uVector of nodal displacement

Definition at line 61 of file writer.cpp.

63 {
64
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);
71}
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.
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 mshWriter.cpp:87
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 vtkWriter.cpp:49

◆ appendNodes()

void rw::writer::Writer::appendNodes ( const std::vector< util::Point > *  nodes,
const std::vector< util::Point > *  u = nullptr 
)

Writes the nodes to the file.

Parameters
nodesReference positions of the nodes
uNodal displacements

Definition at line 49 of file writer.cpp.

51 {
52
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")
59}
void appendNodes(const std::vector< util::Point > *nodes)
Writes the nodes to the file.
void appendNodes(const std::vector< util::Point > *nodes, const std::vector< util::Point > *u=nullptr)
Writes the nodes to the file.
Definition mshWriter.cpp:54
void appendNodes(const std::vector< util::Point > *nodes, const std::vector< util::Point > *u=nullptr)
Writes the nodes to the file.
Definition vtkWriter.cpp:32

◆ appendPointData() [1/7]

void rw::writer::Writer::appendPointData ( const std::string &  name,
const std::vector< double > *  data 
)

Writes the scalar point data to the file.

Parameters
nameName of the data
dataVector containing the data

Definition at line 117 of file writer.cpp.

118 {
119
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")
126}
void appendPointData(const std::string &name, const std::vector< uint8_t > *data)
Writes the scalar point data to the file.
void appendPointData(const std::string &name, const std::vector< uint8_t > *data)
Writes the scalar point data to the file.
void appendPointData(const std::string &name, const std::vector< uint8_t > *data)
Writes the scalar point data to the file.
Definition vtkWriter.cpp:95

◆ appendPointData() [2/7]

void rw::writer::Writer::appendPointData ( const std::string &  name,
const std::vector< float > *  data 
)

Writes the scalar point data to the file.

Parameters
nameName of the data
dataVector containing the data

Definition at line 106 of file writer.cpp.

107 {
108
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")
115}

◆ appendPointData() [3/7]

void rw::writer::Writer::appendPointData ( const std::string &  name,
const std::vector< int > *  data 
)

Writes the scalar point data to the file.

Parameters
nameName of the data
dataVector containing the data

Definition at line 95 of file writer.cpp.

96 {
97
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")
104}

◆ appendPointData() [4/7]

void rw::writer::Writer::appendPointData ( const std::string &  name,
const std::vector< size_t > *  data 
)

Writes the scalar point data to the file.

Parameters
nameName of the data
dataVector containing the data

Definition at line 84 of file writer.cpp.

85 {
86
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")
93}

◆ appendPointData() [5/7]

void rw::writer::Writer::appendPointData ( const std::string &  name,
const std::vector< uint8_t > *  data 
)

Writes the scalar point data to the file.

Parameters
nameName of the data
dataVector containing the data

Definition at line 73 of file writer.cpp.

74 {
75
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")
82}

◆ appendPointData() [6/7]

void rw::writer::Writer::appendPointData ( const std::string &  name,
const std::vector< util::Point > *  data 
)

Writes the vector point data to the file.

Parameters
nameName of the data
dataVector containing the data

Definition at line 128 of file writer.cpp.

129 {
130
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")
137}

◆ appendPointData() [7/7]

void rw::writer::Writer::appendPointData ( const std::string &  name,
const std::vector< util::SymMatrix3 > *  data 
)

Writes the symmetric matrix data associated to nodes to the file.

Parameters
nameName of the data
dataVector containing the data

Definition at line 139 of file writer.cpp.

140 {
141
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")
148}

◆ close()

void rw::writer::Writer::close ( )

Closes the file and store it to the hard disk.

Definition at line 204 of file writer.cpp.

204 {
205
206 if (d_format == "vtu")
208 else if (d_format == "msh")
210 else if (d_format == "legacy_vtk")
212}
void close()
Closes the file and store it to the hard disk.
void close()
Closes the file and store it to the hard disk.
void close()
Closes the file and store it to the hard disk.

◆ open()

void rw::writer::Writer::open ( const std::string &  filename,
const std::string &  format = "vtu",
const std::string &  compress_type = "" 
)

Open a .vtu file.

Parameters
filenameName of file which will be created
formatFormat of the output file, e.g. "vtu", "msh"
compress_typeCompression type (optional)

Definition at line 28 of file writer.cpp.

30 {
31 d_format = format;
32 if (d_format == "vtu")
33 d_vtkWriter_p = new rw::writer::VtkWriter(filename, compress_type);
34 else if (d_format == "msh")
35 d_mshWriter_p = new rw::writer::MshWriter(filename, compress_type);
36 else if (d_format == "legacy_vtk")
38 new rw::writer::LegacyVtkWriter(filename, compress_type);
39 else {
40 std::cerr << "File format " << d_format << " is not supported.\n";
41 exit(1);
42 }
43}
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

Referenced by Writer().

Here is the caller graph for this function:

Field Documentation

◆ d_format

std::string rw::writer::Writer::d_format
private

Format of output file.

Definition at line 234 of file writer.h.

◆ d_legacyVtkWriter_p

rw::writer::LegacyVtkWriter* rw::writer::Writer::d_legacyVtkWriter_p
private

Pointer to the vtk writer class.

Definition at line 228 of file writer.h.

◆ d_mshWriter_p

rw::writer::MshWriter* rw::writer::Writer::d_mshWriter_p
private

Pointer to the vtk writer class.

Definition at line 231 of file writer.h.

◆ d_vtkWriter_p

rw::writer::VtkWriter* rw::writer::Writer::d_vtkWriter_p
private

Pointer to the vtk writer class.

Definition at line 225 of file writer.h.


The documentation for this class was generated from the following files: