PeriDEM 0.3.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::VtkWriter * d_vtkWriter_p
 Pointer to the vtk writer class.
 
rw::writer::LegacyVtkWriter * d_legacyVtkWriter_p
 Pointer to the vtk writer class.
 
rw::writer::MshWriter * d_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 18 of file writer.cpp.

19 : d_vtkWriter_p(nullptr), d_legacyVtkWriter_p(nullptr),
20 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 22 of file writer.cpp.

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

References open().

Here is the call graph for this function:

◆ ~Writer()

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

Destructor.

Definition at line 48 of file writer.cpp.

48 {
49 delete (d_vtkWriter_p);
50}

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 175 of file writer.cpp.

175 {
176
177 if (d_format == "vtu")
178 d_vtkWriter_p->addTimeStep(timestep);
179 else if (d_format == "msh")
180 d_mshWriter_p->addTimeStep(timestep);
181 else if (d_format == "legacy_vtk")
183}
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 153 of file writer.cpp.

154 {
155
156 if (d_format == "vtu")
158 else if (d_format == "msh")
160 else if (d_format == "legacy_vtk")
162}
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.
Definition contact.h:20

◆ 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 164 of file writer.cpp.

165 {
166
167 if (d_format == "vtu")
169 else if (d_format == "msh")
171 else if (d_format == "legacy_vtk")
173}

◆ 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 185 of file writer.cpp.

186 {
187
188 if (d_format == "vtu")
190 else if (d_format == "msh")
192 else if (d_format == "legacy_vtk")
194}
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 196 of file writer.cpp.

197 {
198
199 if (d_format == "vtu")
201 else if (d_format == "msh")
203 else if (d_format == "legacy_vtk")
205}

◆ 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 64 of file writer.cpp.

66 {
67
68 if (d_format == "vtu")
69 d_vtkWriter_p->appendMesh(nodes, element_type, en_con, u);
70 else if (d_format == "msh")
71 d_mshWriter_p->appendMesh(nodes, element_type, en_con, u);
72 else if (d_format == "legacy_vtk")
73 d_legacyVtkWriter_p->appendMesh(nodes, element_type, en_con, u);
74}
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:94
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:50

Referenced by anonymous_namespace{particleMesh.cpp}::maybeWriteMeshFile().

Here is the caller graph for this function:

◆ 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 52 of file writer.cpp.

54 {
55
56 if (d_format == "vtu")
57 d_vtkWriter_p->appendNodes(nodes, u);
58 else if (d_format == "msh")
59 d_mshWriter_p->appendNodes(nodes, u);
60 else if (d_format == "legacy_vtk")
62}
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:60
void appendNodes(const std::vector< util::Point > *nodes, const std::vector< util::Point > *u=nullptr)
Writes the nodes to the file.
Definition vtkWriter.cpp:33

◆ 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 120 of file writer.cpp.

121 {
122
123 if (d_format == "vtu")
125 else if (d_format == "msh")
127 else if (d_format == "legacy_vtk")
129}
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 109 of file writer.cpp.

110 {
111
112 if (d_format == "vtu")
114 else if (d_format == "msh")
116 else if (d_format == "legacy_vtk")
118}

◆ 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 98 of file writer.cpp.

99 {
100
101 if (d_format == "vtu")
103 else if (d_format == "msh")
105 else if (d_format == "legacy_vtk")
107}

◆ 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 87 of file writer.cpp.

88 {
89
90 if (d_format == "vtu")
92 else if (d_format == "msh")
94 else if (d_format == "legacy_vtk")
96}

◆ 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 76 of file writer.cpp.

77 {
78
79 if (d_format == "vtu")
81 else if (d_format == "msh")
83 else if (d_format == "legacy_vtk")
85}

◆ 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 131 of file writer.cpp.

132 {
133
134 if (d_format == "vtu")
136 else if (d_format == "msh")
138 else if (d_format == "legacy_vtk")
140}

◆ 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 142 of file writer.cpp.

143 {
144
145 if (d_format == "vtu")
147 else if (d_format == "msh")
149 else if (d_format == "legacy_vtk")
151}

◆ close()

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

Closes the file and store it to the hard disk.

Definition at line 207 of file writer.cpp.

207 {
208
209 if (d_format == "vtu")
211 else if (d_format == "msh")
213 else if (d_format == "legacy_vtk")
215}
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.

Referenced by anonymous_namespace{particleMesh.cpp}::maybeWriteMeshFile().

Here is the caller graph for this function:

◆ 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 30 of file writer.cpp.

32 {
33 d_format = format;
34 if (d_format == "vtu")
35 d_vtkWriter_p = new rw::writer::VtkWriter(filename, compress_type);
36 else if (d_format == "msh")
37 d_mshWriter_p = new rw::writer::MshWriter(filename, compress_type);
38 else if (d_format == "legacy_vtk")
40 new rw::writer::LegacyVtkWriter(filename, compress_type);
41 else {
42 throw std::runtime_error(
44 << "File format " << d_format << " is not supported.\n");
45 }
46}
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:29
A vtk writer for simple point data and complex fem mesh data.
Definition vtkWriter.h:28
Collects a message with stream syntax for use in an exception.
Definition io.h:52

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: