PeriDEM 0.2.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
rw::reader Namespace Reference

Collection of methods and database related to reading. More...

Data Structures

class  MshReader
 A class to read Gmsh (msh) mesh files. More...
 
class  VtkParticleReader
 A vtk writer for simple point data and complex fem mesh data. More...
 
class  VtkReader
 A class to read VTK (.vtu) mesh files. More...
 

Functions

CSV specific functions
void readCsvFile (const std::string &filename, size_t dim, std::vector< util::Point > *nodes, std::vector< double > *volumes)
 Reads mesh data into node file and element file.
 
void readParticleCsvFile (const std::string &filename, size_t dim, std::vector< util::Point > *nodes, std::vector< double > *rads, std::vector< size_t > *zones)
 Reads particles center location, radius, and zone id.
 
void readParticleCsvFile (const std::string &filename, size_t dim, std::vector< util::Point > *nodes, std::vector< double > *rads, const size_t &zone)
 Reads particles center location, radius, and zone id.
 
void readParticleWithOrientCsvFile (const std::string &filename, size_t dim, std::vector< util::Point > *nodes, std::vector< double > *rads, std::vector< double > *orients, const size_t &zone)
 Reads particles center location, radius, and zone id. In this case, file also provides initial orientation of particles.
 
VTU specific functions
void readVtuFile (const std::string &filename, size_t dim, std::vector< util::Point > *nodes, size_t &element_type, size_t &num_elem, std::vector< size_t > *enc, std::vector< std::vector< size_t > > *nec, std::vector< double > *volumes, bool is_fd=false)
 Reads mesh data into node file and element file.
 
void readVtuFileNodes (const std::string &filename, size_t dim, std::vector< util::Point > *nodes, bool ref_config=false)
 Reads nodal coordinates.
 
void readVtuFileCells (const std::string &filename, size_t dim, size_t &element_type, size_t &num_elem, std::vector< size_t > *enc, std::vector< std::vector< size_t > > *nec)
 Reads cell data, i.e. element-node connectivity and node-element connectivity.
 
void readVtuFileRestart (const std::string &filename, std::vector< util::Point > *u, std::vector< util::Point > *v, const std::vector< util::Point > *X=nullptr)
 Reads mesh data into node file and element file.
 
bool readVtuFilePointData (const std::string &filename, const std::string &tag, std::vector< uint8_t > *data)
 Reads data of specified tag from the vtu file.
 
bool readVtuFilePointData (const std::string &filename, const std::string &tag, std::vector< size_t > *data)
 Reads data of specified tag from the vtu file.
 
bool readVtuFilePointData (const std::string &filename, const std::string &tag, std::vector< int > *data)
 Reads data of specified tag from the vtu file.
 
bool readVtuFilePointData (const std::string &filename, const std::string &tag, std::vector< float > *data)
 Reads data of specified tag from the vtu file.
 
bool readVtuFilePointData (const std::string &filename, const std::string &tag, std::vector< double > *data)
 Reads data of specified tag from the vtu file.
 
bool readVtuFilePointData (const std::string &filename, const std::string &tag, std::vector< util::Point > *data)
 Reads data of specified tag from the vtu file.
 
bool readVtuFilePointData (const std::string &filename, const std::string &tag, std::vector< util::SymMatrix3 > *data)
 Reads data of specified tag from the vtu file.
 
bool readVtuFilePointData (const std::string &filename, const std::string &tag, std::vector< util::Matrix3 > *data)
 Reads data of specified tag from the vtu file.
 
bool readVtuFileCellData (const std::string &filename, const std::string &tag, std::vector< float > *data)
 Reads data of specified tag from the vtu file.
 
bool readVtuFileCellData (const std::string &filename, const std::string &tag, std::vector< double > *data)
 Reads data of specified tag from the vtu file.
 
bool readVtuFileCellData (const std::string &filename, const std::string &tag, std::vector< util::Point > *data)
 Reads data of specified tag from the vtu file.
 
bool readVtuFileCellData (const std::string &filename, const std::string &tag, std::vector< util::SymMatrix3 > *data)
 Reads data of specified tag from the vtu file.
 
bool readVtuFileCellData (const std::string &filename, const std::string &tag, std::vector< util::Matrix3 > *data)
 Reads data of specified tag from the vtu file.
 
MSH specific functions
void readMshFile (const std::string &filename, size_t dim, std::vector< util::Point > *nodes, size_t &element_type, size_t &num_elem, std::vector< size_t > *enc, std::vector< std::vector< size_t > > *nec, std::vector< double > *volumes, bool is_fd=false)
 Reads mesh data into node file and element file.
 
void readMshFileRestart (const std::string &filename, std::vector< util::Point > *u, std::vector< util::Point > *v, const std::vector< util::Point > *X=nullptr)
 Reads mesh data into node file and element file.
 
bool readMshFilePointData (const std::string &filename, const std::string &tag, std::vector< double > *data)
 Reads data of specified tag from the vtu file.
 
void readMshFileCells (const std::string &filename, size_t dim, size_t &element_type, size_t &num_elem, std::vector< size_t > *enc, std::vector< std::vector< size_t > > *nec)
 Reads cell data, i.e. element-node connectivity and node-element connectivity.
 

Detailed Description

Collection of methods and database related to reading.

This namespace provides methods and data members specific to reading of the mesh data. Currently, .csv, .vtu and .msh files are supported.

Function Documentation

◆ readCsvFile()

void rw::reader::readCsvFile ( const std::string &  filename,
size_t  dim,
std::vector< util::Point > *  nodes,
std::vector< double > *  volumes 
)

Reads mesh data into node file and element file.

Parameters
filenameName of mesh file
dimDimension
nodesVector of nodes data
volumesVector holding volume of the nodes

Definition at line 16 of file reader.cpp.

18 {
19 nodes->clear();
20 volumes->clear();
21 if (dim == 1) {
22 io::CSVReader<3> in(filename);
23 in.read_header(io::ignore_extra_column, "id", "x", "volume");
24
25 double x;
26 double volume;
27 int id;
28 while (in.read_row(id, x, volume)) {
29 volumes->emplace_back(volume);
30 nodes->emplace_back(util::Point(x, 0., 0.));
31 }
32 }
33
34 if (dim == 2) {
35 io::CSVReader<4> in(filename);
36 in.read_header(io::ignore_extra_column, "id", "x", "y", "volume");
37
38 double x, y, volume;
39 int id;
40 while (in.read_row(id, x, y, volume)) {
41 volumes->emplace_back(volume);
42 nodes->emplace_back(util::Point(x, y, 0.));
43 }
44 }
45
46 if (dim == 3) {
47 io::CSVReader<5> in(filename);
48 in.read_header(io::ignore_extra_column, "id", "x", "y", "z", "volume");
49
50 double x, y, z, volume;
51 int id;
52 while (in.read_row(id, x, y, z, volume)) {
53 volumes->emplace_back(volume);
54 nodes->emplace_back(util::Point(x, y, z));
55 }
56 }
57}
A structure to represent 3d vectors.
Definition point.h:30

Referenced by fe::Mesh::createData().

Here is the caller graph for this function:

◆ readMshFile()

void rw::reader::readMshFile ( const std::string &  filename,
size_t  dim,
std::vector< util::Point > *  nodes,
size_t &  element_type,
size_t &  num_elem,
std::vector< size_t > *  enc,
std::vector< std::vector< size_t > > *  nec,
std::vector< double > *  volumes,
bool  is_fd = false 
)

Reads mesh data into node file and element file.

Parameters
filenameName of mesh file
dimDimension
nodesVector of nodes data
element_typeType of element
num_elemNumber of elements
encVector holding element-node connectivity
necVector holding node-element connectivity
volumesVector holding volume of the nodes
is_fdFlag indicating if this mesh is for finite_difference simulation

Definition at line 351 of file reader.cpp.

356 {
357 // call msh reader
358 auto rdr = rw::reader::MshReader(filename);
359 rdr.readMesh(dim, nodes, element_type, num_elem, enc, nec, volumes, is_fd);
360 rdr.close();
361}
A class to read Gmsh (msh) mesh files.
Definition mshReader.h:28

Referenced by fe::Mesh::createData().

Here is the caller graph for this function:

◆ readMshFileCells()

void rw::reader::readMshFileCells ( const std::string &  filename,
size_t  dim,
size_t &  element_type,
size_t &  num_elem,
std::vector< size_t > *  enc,
std::vector< std::vector< size_t > > *  nec 
)

Reads cell data, i.e. element-node connectivity and node-element connectivity.

Parameters
filenameName of mesh file
dimDimension
element_typeType of element
num_elemNumber of elements
encElement-node connectivity
necNode-element connectivity

Definition at line 401 of file reader.cpp.

404 {
405 // call msh reader
406 auto rdr = rw::reader::MshReader(filename);
407 rdr.readCells(dim, element_type, num_elem, enc, nec);
408 rdr.close();
409}

Referenced by fe::Mesh::readElementData().

Here is the caller graph for this function:

◆ readMshFilePointData()

bool rw::reader::readMshFilePointData ( const std::string &  filename,
const std::string &  tag,
std::vector< double > *  data 
)

Reads data of specified tag from the vtu file.

Parameters
filenameName of mesh file
tagName of point data to be read from .vtu file
dataPointer to vector of point data
Returns
bool True if found the data in file

Definition at line 390 of file reader.cpp.

392 {
393 // call msh reader
394 auto rdr = rw::reader::MshReader(filename);
395 // get velocity
396 auto st = rdr.readPointData(tag, data);
397 rdr.close();
398 return st;
399}

◆ readMshFileRestart()

void rw::reader::readMshFileRestart ( const std::string &  filename,
std::vector< util::Point > *  u,
std::vector< util::Point > *  v,
const std::vector< util::Point > *  X = nullptr 
)

Reads mesh data into node file and element file.

Parameters
filenameName of mesh file
uPointer to vector of nodal displacement
vPointer to vector of nodal velocity
XPointer to vector of nodal reference position (Optional)

Definition at line 363 of file reader.cpp.

366 {
367 // call msh reader
368 auto rdr = rw::reader::MshReader(filename);
369 // if displacement is not in input file, use reference coordinate to get
370 // displacement
371 if (!rdr.readPointData("Displacement", u)) {
372 std::vector<util::Point> y;
373 rdr.readNodes(&y);
374 if (y.size() != X->size()) {
375 std::cerr << "Error: Number of nodes in input file = " << filename
376 << " and number nodes in data X are not same.\n";
377 exit(1);
378 }
379
380 u->resize(y.size());
381 for (size_t i = 0; i < y.size(); i++)
382 (*u)[i] = y[i] - (*X)[i];
383 }
384
385 // get velocity
386 rdr.readPointData("Velocity", v);
387 rdr.close();
388}

◆ readParticleCsvFile() [1/2]

void rw::reader::readParticleCsvFile ( const std::string &  filename,
size_t  dim,
std::vector< util::Point > *  nodes,
std::vector< double > *  rads,
const size_t &  zone 
)

Reads particles center location, radius, and zone id.

Parameters
filenameName of mesh file
dimDimension
nodesVector of center locations
radsVector of radius
zoneOnly reads particle with this zone

Definition at line 80 of file reader.cpp.

83 {
84
85 nodes->clear();
86 rads->clear();
87
88 io::CSVReader<5> in(filename);
89 in.read_header(io::ignore_extra_column, "i", "x", "y", "z", "r");
90
91 double x, y, z, r;
92 int id;
93 while (in.read_row(id, x, y, z, r)) {
94 if (id == zone) {
95 rads->emplace_back(r);
96 nodes->emplace_back(util::Point(x, y, z));
97 }
98 }
99}

◆ readParticleCsvFile() [2/2]

void rw::reader::readParticleCsvFile ( const std::string &  filename,
size_t  dim,
std::vector< util::Point > *  nodes,
std::vector< double > *  rads,
std::vector< size_t > *  zones 
)

Reads particles center location, radius, and zone id.

Parameters
filenameName of mesh file
dimDimension
nodesVector of center locations
radsVector of radius
zonesVector zone ids

Definition at line 59 of file reader.cpp.

62 {
63
64 nodes->clear();
65 zones->clear();
66 rads->clear();
67
68 io::CSVReader<5> in(filename);
69 in.read_header(io::ignore_extra_column, "i", "x", "y", "z", "r");
70
71 double x, y, z, r;
72 int id;
73 while (in.read_row(id, x, y, z, r)) {
74 rads->emplace_back(r);
75 nodes->emplace_back(util::Point(x, y, z));
76 zones->emplace_back(id);
77 }
78}

Referenced by model::DEMModel::createParticlesFromFile().

Here is the caller graph for this function:

◆ readParticleWithOrientCsvFile()

void rw::reader::readParticleWithOrientCsvFile ( const std::string &  filename,
size_t  dim,
std::vector< util::Point > *  nodes,
std::vector< double > *  rads,
std::vector< double > *  orients,
const size_t &  zone 
)

Reads particles center location, radius, and zone id. In this case, file also provides initial orientation of particles.

Parameters
filenameName of mesh file
dimDimension
nodesVector of center locations
radsVector of radius
orientsVector of orientation of particles
zoneOnly reads particle with this zone

Definition at line 101 of file reader.cpp.

105 {
106
107 nodes->clear();
108 rads->clear();
109 orients->clear();
110
111 io::CSVReader<6> in(filename);
112 in.read_header(io::ignore_extra_column, "i", "x", "y", "z", "r", "o");
113
114 double x, y, z, r, o;
115 int id;
116 while (in.read_row(id, x, y, z, r, o)) {
117 if (id == zone) {
118 rads->emplace_back(r);
119 nodes->emplace_back(util::Point(x, y, z));
120 orients->emplace_back(o);
121 }
122 }
123}

Referenced by model::DEMModel::createParticlesFromFile().

Here is the caller graph for this function:

◆ readVtuFile()

void rw::reader::readVtuFile ( const std::string &  filename,
size_t  dim,
std::vector< util::Point > *  nodes,
size_t &  element_type,
size_t &  num_elem,
std::vector< size_t > *  enc,
std::vector< std::vector< size_t > > *  nec,
std::vector< double > *  volumes,
bool  is_fd = false 
)

Reads mesh data into node file and element file.

Parameters
filenameName of mesh file
dimDimension
nodesVector of nodes data
element_typeType of element
num_elemNumber of elements
encVector holding element-node connectivity
necVector holding node-element connectivity
volumesVector holding volume of the nodes
is_fdFlag indicating if this mesh is for finite_difference simulation

Definition at line 125 of file reader.cpp.

130 {
131 // call vtk reader
132 auto rdr = rw::reader::VtkReader(filename);
133 rdr.readMesh(dim, nodes, element_type, num_elem, enc, nec, volumes, is_fd);
134 rdr.close();
135}
A class to read VTK (.vtu) mesh files.
Definition vtkReader.h:32

◆ readVtuFileCellData() [1/5]

bool rw::reader::readVtuFileCellData ( const std::string &  filename,
const std::string &  tag,
std::vector< double > *  data 
)

Reads data of specified tag from the vtu file.

Parameters
filenameName of mesh file
tagName of point data to be read from .vtu file
dataPointer to vector of point data
Returns
bool True if found the data in file

Definition at line 307 of file reader.cpp.

309 {
310 // call vtk reader
311 auto rdr = rw::reader::VtkReader(filename);
312 // read data
313 auto st = rdr.readCellData(tag, data);
314 rdr.close();
315 return st;
316}

◆ readVtuFileCellData() [2/5]

bool rw::reader::readVtuFileCellData ( const std::string &  filename,
const std::string &  tag,
std::vector< float > *  data 
)

Reads data of specified tag from the vtu file.

Parameters
filenameName of mesh file
tagName of point data to be read from .vtu file
dataPointer to vector of point data
Returns
bool True if found the data in file

Definition at line 296 of file reader.cpp.

298 {
299 // call vtk reader
300 auto rdr = rw::reader::VtkReader(filename);
301 // read data
302 auto st = rdr.readCellData(tag, data);
303 rdr.close();
304 return st;
305}

◆ readVtuFileCellData() [3/5]

bool rw::reader::readVtuFileCellData ( const std::string &  filename,
const std::string &  tag,
std::vector< util::Matrix3 > *  data 
)

Reads data of specified tag from the vtu file.

Parameters
filenameName of mesh file
tagName of point data to be read from .vtu file
dataPointer to vector of point data
Returns
bool True if found the data in file

Definition at line 340 of file reader.cpp.

342 {
343 // call vtk reader
344 auto rdr = rw::reader::VtkReader(filename);
345 // read data
346 auto st = rdr.readCellData(tag, data);
347 rdr.close();
348 return st;
349}

◆ readVtuFileCellData() [4/5]

bool rw::reader::readVtuFileCellData ( const std::string &  filename,
const std::string &  tag,
std::vector< util::Point > *  data 
)

Reads data of specified tag from the vtu file.

Parameters
filenameName of mesh file
tagName of point data to be read from .vtu file
dataPointer to vector of point data
Returns
bool True if found the data in file

Definition at line 318 of file reader.cpp.

320 {
321 // call vtk reader
322 auto rdr = rw::reader::VtkReader(filename);
323 // read data
324 auto st = rdr.readCellData(tag, data);
325 rdr.close();
326 return st;
327}

◆ readVtuFileCellData() [5/5]

bool rw::reader::readVtuFileCellData ( const std::string &  filename,
const std::string &  tag,
std::vector< util::SymMatrix3 > *  data 
)

Reads data of specified tag from the vtu file.

Parameters
filenameName of mesh file
tagName of point data to be read from .vtu file
dataPointer to vector of point data
Returns
bool True if found the data in file

Definition at line 329 of file reader.cpp.

331 {
332 // call vtk reader
333 auto rdr = rw::reader::VtkReader(filename);
334 // read data
335 auto st = rdr.readCellData(tag, data);
336 rdr.close();
337 return st;
338}

◆ readVtuFileCells()

void rw::reader::readVtuFileCells ( const std::string &  filename,
size_t  dim,
size_t &  element_type,
size_t &  num_elem,
std::vector< size_t > *  enc,
std::vector< std::vector< size_t > > *  nec 
)

Reads cell data, i.e. element-node connectivity and node-element connectivity.

Parameters
filenameName of mesh file
dimDimension
element_typeType of element
num_elemNumber of elements
encElement-node connectivity
necNode-element connectivity

Definition at line 168 of file reader.cpp.

171 {
172 // call vtk reader
173 auto rdr = rw::reader::VtkReader(filename);
174
175 // below will read the current position of nodes
176 rdr.readCells(dim, element_type, num_elem, enc, nec);
177
178 rdr.close();
179}

Referenced by fe::Mesh::createData(), and fe::Mesh::readElementData().

Here is the caller graph for this function:

◆ readVtuFileNodes()

void rw::reader::readVtuFileNodes ( const std::string &  filename,
size_t  dim,
std::vector< util::Point > *  nodes,
bool  ref_config = false 
)

Reads nodal coordinates.

Parameters
filenameName of mesh file
dimDimension
nodesVector of nodes data
ref_configFlag which specifies if we need to subtract the displacement from nodes obtained from vtu file to get reference position of nodes

Definition at line 137 of file reader.cpp.

139 {
140 // call vtk reader
141 auto rdr = rw::reader::VtkReader(filename);
142
143 // below will read the current position of nodes
144 rdr.readNodes(nodes);
145
146 // need to subtract the displacement to get reference configuration of nodes
147 if (ref_config) {
148 std::vector<util::Point> u;
149 if (rdr.readPointData("Displacement", &u)) {
150 std::cerr << "Error: Did not find displacement in the vtu file."
151 << std::endl;
152 exit(1);
153 }
154
155 if (u.size() != nodes->size()) {
156 std::cerr << "Error: Displacement data and node data size do not match."
157 << std::endl;
158 exit(1);
159 }
160
161 for (size_t i = 0; i < u.size(); i++)
162 (*nodes)[i] -= u[i];
163 }
164
165 rdr.close();
166}

Referenced by fe::Mesh::createData().

Here is the caller graph for this function:

◆ readVtuFilePointData() [1/8]

bool rw::reader::readVtuFilePointData ( const std::string &  filename,
const std::string &  tag,
std::vector< double > *  data 
)

Reads data of specified tag from the vtu file.

Parameters
filenameName of mesh file
tagName of point data to be read from .vtu file
dataPointer to vector of point data
Returns
bool True if found the data in file

Definition at line 252 of file reader.cpp.

254 {
255 // call vtk reader
256 auto rdr = rw::reader::VtkReader(filename);
257 // read data
258 auto st = rdr.readPointData(tag, data);
259 rdr.close();
260 return st;
261}

◆ readVtuFilePointData() [2/8]

bool rw::reader::readVtuFilePointData ( const std::string &  filename,
const std::string &  tag,
std::vector< float > *  data 
)

Reads data of specified tag from the vtu file.

Parameters
filenameName of mesh file
tagName of point data to be read from .vtu file
dataPointer to vector of point data
Returns
bool True if found the data in file

Definition at line 241 of file reader.cpp.

243 {
244 // call vtk reader
245 auto rdr = rw::reader::VtkReader(filename);
246 // read data
247 auto st = rdr.readPointData(tag, data);
248 rdr.close();
249 return st;
250}

◆ readVtuFilePointData() [3/8]

bool rw::reader::readVtuFilePointData ( const std::string &  filename,
const std::string &  tag,
std::vector< int > *  data 
)

Reads data of specified tag from the vtu file.

Parameters
filenameName of mesh file
tagName of point data to be read from .vtu file
dataPointer to vector of point data
Returns
bool True if found the data in file

Definition at line 230 of file reader.cpp.

232 {
233 // call vtk reader
234 auto rdr = rw::reader::VtkReader(filename);
235 // read data
236 auto st = rdr.readPointData(tag, data);
237 rdr.close();
238 return st;
239}

◆ readVtuFilePointData() [4/8]

bool rw::reader::readVtuFilePointData ( const std::string &  filename,
const std::string &  tag,
std::vector< size_t > *  data 
)

Reads data of specified tag from the vtu file.

Parameters
filenameName of mesh file
tagName of point data to be read from .vtu file
dataPointer to vector of point data
Returns
bool True if found the data in file

Definition at line 219 of file reader.cpp.

221 {
222 // call vtk reader
223 auto rdr = rw::reader::VtkReader(filename);
224 // read data
225 auto st = rdr.readPointData(tag, data);
226 rdr.close();
227 return st;
228}

◆ readVtuFilePointData() [5/8]

bool rw::reader::readVtuFilePointData ( const std::string &  filename,
const std::string &  tag,
std::vector< uint8_t > *  data 
)

Reads data of specified tag from the vtu file.

Parameters
filenameName of mesh file
tagName of point data to be read from .vtu file
dataPointer to vector of point data
Returns
bool True if found the data in file

Definition at line 208 of file reader.cpp.

210 {
211 // call vtk reader
212 auto rdr = rw::reader::VtkReader(filename);
213 // read data
214 auto st = rdr.readPointData(tag, data);
215 rdr.close();
216 return st;
217}

Referenced by fe::Mesh::createData().

Here is the caller graph for this function:

◆ readVtuFilePointData() [6/8]

bool rw::reader::readVtuFilePointData ( const std::string &  filename,
const std::string &  tag,
std::vector< util::Matrix3 > *  data 
)

Reads data of specified tag from the vtu file.

Parameters
filenameName of mesh file
tagName of point data to be read from .vtu file
dataPointer to vector of point data
Returns
bool True if found the data in file

Definition at line 285 of file reader.cpp.

287 {
288 // call vtk reader
289 auto rdr = rw::reader::VtkReader(filename);
290 // read data
291 auto st = rdr.readPointData(tag, data);
292 rdr.close();
293 return st;
294}

◆ readVtuFilePointData() [7/8]

bool rw::reader::readVtuFilePointData ( const std::string &  filename,
const std::string &  tag,
std::vector< util::Point > *  data 
)

Reads data of specified tag from the vtu file.

Parameters
filenameName of mesh file
tagName of point data to be read from .vtu file
dataPointer to vector of point data
Returns
bool True if found the data in file

Definition at line 263 of file reader.cpp.

265 {
266 // call vtk reader
267 auto rdr = rw::reader::VtkReader(filename);
268 // read data
269 auto st = rdr.readPointData(tag, data);
270 rdr.close();
271 return st;
272}

◆ readVtuFilePointData() [8/8]

bool rw::reader::readVtuFilePointData ( const std::string &  filename,
const std::string &  tag,
std::vector< util::SymMatrix3 > *  data 
)

Reads data of specified tag from the vtu file.

Parameters
filenameName of mesh file
tagName of point data to be read from .vtu file
dataPointer to vector of point data
Returns
bool True if found the data in file

Definition at line 274 of file reader.cpp.

276 {
277 // call vtk reader
278 auto rdr = rw::reader::VtkReader(filename);
279 // read data
280 auto st = rdr.readPointData(tag, data);
281 rdr.close();
282 return st;
283}

◆ readVtuFileRestart()

void rw::reader::readVtuFileRestart ( const std::string &  filename,
std::vector< util::Point > *  u,
std::vector< util::Point > *  v,
const std::vector< util::Point > *  X = nullptr 
)

Reads mesh data into node file and element file.

Parameters
filenameName of mesh file
uPointer to vector of nodal displacement
vPointer to vector of nodal velocity
XPointer to vector of nodal reference position (Optional)

Definition at line 181 of file reader.cpp.

184 {
185 // call vtk reader
186 auto rdr = rw::reader::VtkReader(filename);
187 // if displacement is not in input file, use reference coordinate to get
188 // displacement
189 if (!rdr.readPointData("Displacement", u)) {
190 std::vector<util::Point> y;
191 rdr.readNodes(&y);
192 if (y.size() != X->size()) {
193 std::cerr << "Error: Number of nodes in input file = " << filename
194 << " and number nodes in data X are not same.\n";
195 exit(1);
196 }
197
198 u->resize(y.size());
199 for (size_t i = 0; i < y.size(); i++)
200 (*u)[i] = y[i] - (*X)[i];
201 }
202
203 // get velocity
204 rdr.readPointData("Velocity", v);
205 rdr.close();
206}