PeriDEM 0.3.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. The .csv, .vtu and .msh formats are read.

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 18 of file reader.cpp.

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

Referenced by mesh::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 356 of file reader.cpp.

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

Referenced by mesh::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 407 of file reader.cpp.

410 {
411 // call msh reader
412 auto rdr = rw::reader::MshReader(filename);
413 rdr.readCells(dim, element_type, num_elem, enc, nec);
414 rdr.close();
415}

Referenced by mesh::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 396 of file reader.cpp.

398 {
399 // call msh reader
400 auto rdr = rw::reader::MshReader(filename);
401 // get velocity
402 auto st = rdr.readPointData(tag, data);
403 rdr.close();
404 return st;
405}
Definition contact.h:20

◆ 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 368 of file reader.cpp.

371 {
372 // call msh reader
373 auto rdr = rw::reader::MshReader(filename);
374 // if displacement is not in input file, use reference coordinate to get
375 // displacement
376 if (!rdr.readPointData("Displacement", u)) {
377 std::vector<util::Point> y;
378 rdr.readNodes(&y);
379 if (y.size() != X->size()) {
380 throw std::runtime_error(
382 << "Error: Number of nodes in input file = " << filename
383 << " and number nodes in data X are not same.\n");
384 }
385
386 u->resize(y.size());
387 for (size_t i = 0; i < y.size(); i++)
388 (*u)[i] = y[i] - (*X)[i];
389 }
390
391 // get velocity
392 rdr.readPointData("Velocity", v);
393 rdr.close();
394}
Collects a message with stream syntax for use in an exception.
Definition io.h:52

◆ 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 82 of file reader.cpp.

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

◆ 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 61 of file reader.cpp.

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

◆ 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 103 of file reader.cpp.

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

◆ 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 127 of file reader.cpp.

132 {
133 // call vtk reader
134 auto rdr = rw::reader::VtkReader(filename);
135 rdr.readMesh(dim, nodes, element_type, num_elem, enc, nec, volumes, is_fd);
136 rdr.close();
137}
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 312 of file reader.cpp.

314 {
315 // call vtk reader
316 auto rdr = rw::reader::VtkReader(filename);
317 // read data
318 auto st = rdr.readCellData(tag, data);
319 rdr.close();
320 return st;
321}

◆ 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 301 of file reader.cpp.

303 {
304 // call vtk reader
305 auto rdr = rw::reader::VtkReader(filename);
306 // read data
307 auto st = rdr.readCellData(tag, data);
308 rdr.close();
309 return st;
310}

◆ 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 345 of file reader.cpp.

347 {
348 // call vtk reader
349 auto rdr = rw::reader::VtkReader(filename);
350 // read data
351 auto st = rdr.readCellData(tag, data);
352 rdr.close();
353 return st;
354}

◆ 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 323 of file reader.cpp.

325 {
326 // call vtk reader
327 auto rdr = rw::reader::VtkReader(filename);
328 // read data
329 auto st = rdr.readCellData(tag, data);
330 rdr.close();
331 return st;
332}

◆ 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 334 of file reader.cpp.

336 {
337 // call vtk reader
338 auto rdr = rw::reader::VtkReader(filename);
339 // read data
340 auto st = rdr.readCellData(tag, data);
341 rdr.close();
342 return st;
343}

◆ 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 172 of file reader.cpp.

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

Referenced by mesh::Mesh::createData(), and mesh::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 139 of file reader.cpp.

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

Referenced by mesh::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 257 of file reader.cpp.

259 {
260 // call vtk reader
261 auto rdr = rw::reader::VtkReader(filename);
262 // read data
263 auto st = rdr.readPointData(tag, data);
264 rdr.close();
265 return st;
266}

◆ 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 246 of file reader.cpp.

248 {
249 // call vtk reader
250 auto rdr = rw::reader::VtkReader(filename);
251 // read data
252 auto st = rdr.readPointData(tag, data);
253 rdr.close();
254 return st;
255}

◆ 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 235 of file reader.cpp.

237 {
238 // call vtk reader
239 auto rdr = rw::reader::VtkReader(filename);
240 // read data
241 auto st = rdr.readPointData(tag, data);
242 rdr.close();
243 return st;
244}

◆ 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 224 of file reader.cpp.

226 {
227 // call vtk reader
228 auto rdr = rw::reader::VtkReader(filename);
229 // read data
230 auto st = rdr.readPointData(tag, data);
231 rdr.close();
232 return st;
233}

◆ 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 213 of file reader.cpp.

215 {
216 // call vtk reader
217 auto rdr = rw::reader::VtkReader(filename);
218 // read data
219 auto st = rdr.readPointData(tag, data);
220 rdr.close();
221 return st;
222}

Referenced by mesh::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 290 of file reader.cpp.

292 {
293 // call vtk reader
294 auto rdr = rw::reader::VtkReader(filename);
295 // read data
296 auto st = rdr.readPointData(tag, data);
297 rdr.close();
298 return st;
299}

◆ 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 268 of file reader.cpp.

270 {
271 // call vtk reader
272 auto rdr = rw::reader::VtkReader(filename);
273 // read data
274 auto st = rdr.readPointData(tag, data);
275 rdr.close();
276 return st;
277}

◆ 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 279 of file reader.cpp.

281 {
282 // call vtk reader
283 auto rdr = rw::reader::VtkReader(filename);
284 // read data
285 auto st = rdr.readPointData(tag, data);
286 rdr.close();
287 return st;
288}

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

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