19 std::vector<util::Point> *nodes,
20 std::vector<double> *volumes) {
24 io::CSVReader<3> in(filename);
25 in.read_header(io::ignore_extra_column,
"id",
"x",
"volume");
30 while (in.read_row(
id, x, volume)) {
31 volumes->emplace_back(volume);
37 io::CSVReader<4> in(filename);
38 in.read_header(io::ignore_extra_column,
"id",
"x",
"y",
"volume");
42 while (in.read_row(
id, x, y, volume)) {
43 volumes->emplace_back(volume);
49 io::CSVReader<5> in(filename);
50 in.read_header(io::ignore_extra_column,
"id",
"x",
"y",
"z",
"volume");
52 double x, y, z, volume;
54 while (in.read_row(
id, x, y, z, volume)) {
55 volumes->emplace_back(volume);
62 std::vector<util::Point> *nodes,
63 std::vector<double> *rads,
64 std::vector<size_t> *zones) {
70 io::CSVReader<5> in(filename);
71 in.read_header(io::ignore_extra_column,
"i",
"x",
"y",
"z",
"r");
75 while (in.read_row(
id, x, y, z, r)) {
76 rads->emplace_back(r);
78 zones->emplace_back(
id);
83 std::vector<util::Point> *nodes,
84 std::vector<double> *rads,
90 io::CSVReader<5> in(filename);
91 in.read_header(io::ignore_extra_column,
"i",
"x",
"y",
"z",
"r");
95 while (in.read_row(
id, x, y, z, r)) {
97 rads->emplace_back(r);
104 std::vector<util::Point> *nodes,
105 std::vector<double> *rads,
106 std::vector<double> *orients,
107 const size_t &zone) {
113 io::CSVReader<6> in(filename);
114 in.read_header(io::ignore_extra_column,
"i",
"x",
"y",
"z",
"r",
"o");
116 double x, y, z, r, o;
118 while (in.read_row(
id, x, y, z, r, o)) {
120 rads->emplace_back(r);
122 orients->emplace_back(o);
128 std::vector<util::Point> *nodes,
129 size_t &element_type,
size_t &num_elem,
130 std::vector<size_t> *enc,
131 std::vector<std::vector<size_t>> *nec,
132 std::vector<double> *volumes,
bool is_fd) {
135 rdr.readMesh(dim, nodes, element_type, num_elem, enc, nec, volumes, is_fd);
140 std::vector<util::Point> *nodes,
146 rdr.readNodes(nodes);
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."
158 if (u.size() != nodes->size()) {
159 throw std::runtime_error(
161 <<
"Error: Displacement data and node data size do not match."
165 for (
size_t i = 0; i < u.size(); i++)
173 size_t &element_type,
size_t &num_elem,
174 std::vector<size_t> *enc,
175 std::vector<std::vector<size_t>> *nec) {
180 rdr.readCells(dim, element_type, num_elem, enc, nec);
186 std::vector<util::Point> *u,
187 std::vector<util::Point> *v,
188 const std::vector<util::Point> *X) {
193 if (!rdr.readPointData(
"Displacement", u)) {
194 std::vector<util::Point> 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");
204 for (
size_t i = 0; i < y.size(); i++)
205 (*u)[i] = y[i] - (*X)[i];
209 rdr.readPointData(
"Velocity", v);
214 const std::string &tag,
215 std::vector<uint8_t> *
data) {
219 auto st = rdr.readPointData(tag,
data);
225 const std::string &tag,
226 std::vector<size_t> *
data) {
230 auto st = rdr.readPointData(tag,
data);
236 const std::string &tag,
237 std::vector<int> *
data) {
241 auto st = rdr.readPointData(tag,
data);
247 const std::string &tag,
248 std::vector<float> *
data) {
252 auto st = rdr.readPointData(tag,
data);
258 const std::string &tag,
259 std::vector<double> *
data) {
263 auto st = rdr.readPointData(tag,
data);
269 const std::string &tag,
270 std::vector<util::Point> *
data) {
274 auto st = rdr.readPointData(tag,
data);
280 const std::string &tag,
281 std::vector<util::SymMatrix3> *
data) {
285 auto st = rdr.readPointData(tag,
data);
291 const std::string &tag,
292 std::vector<util::Matrix3> *
data) {
296 auto st = rdr.readPointData(tag,
data);
302 const std::string &tag,
303 std::vector<float> *
data) {
307 auto st = rdr.readCellData(tag,
data);
313 const std::string &tag,
314 std::vector<double> *
data) {
318 auto st = rdr.readCellData(tag,
data);
324 const std::string &tag,
325 std::vector<util::Point> *
data) {
329 auto st = rdr.readCellData(tag,
data);
335 const std::string &tag,
336 std::vector<util::SymMatrix3> *
data) {
340 auto st = rdr.readCellData(tag,
data);
346 const std::string &tag,
347 std::vector<util::Matrix3> *
data) {
351 auto st = rdr.readCellData(tag,
data);
357 std::vector<util::Point> *nodes,
358 size_t &element_type,
size_t &num_elem,
359 std::vector<size_t> *enc,
360 std::vector<std::vector<size_t>> *nec,
361 std::vector<double> *volumes,
bool is_fd) {
364 rdr.readMesh(dim, nodes, element_type, num_elem, enc, nec, volumes, is_fd);
369 std::vector<util::Point> *u,
370 std::vector<util::Point> *v,
371 const std::vector<util::Point> *X) {
376 if (!rdr.readPointData(
"Displacement", u)) {
377 std::vector<util::Point> 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");
387 for (
size_t i = 0; i < y.size(); i++)
388 (*u)[i] = y[i] - (*X)[i];
392 rdr.readPointData(
"Velocity", v);
397 const std::string &tag,
398 std::vector<double> *
data) {
402 auto st = rdr.readPointData(tag,
data);
408 size_t &element_type,
size_t &num_elem,
409 std::vector<size_t> *enc,
410 std::vector<std::vector<size_t>> *nec) {
413 rdr.readCells(dim, element_type, num_elem, enc, nec);
A class to read Gmsh (msh) mesh files.
A class to read VTK (.vtu) mesh files.
Collects a message with stream syntax for use in an exception.
bool readMshFilePointData(const std::string &filename, const std::string &tag, std::vector< double > *data)
Reads data of specified tag from the vtu 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.
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.
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.
bool readVtuFileCellData(const std::string &filename, const std::string &tag, std::vector< float > *data)
Reads data of specified tag from the vtu file.
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 orient...
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 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 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.
bool readVtuFilePointData(const std::string &filename, const std::string &tag, std::vector< uint8_t > *data)
Reads data of specified tag from the vtu file.
void readVtuFileNodes(const std::string &filename, size_t dim, std::vector< util::Point > *nodes, bool ref_config=false)
Reads nodal coordinates.
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 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.
A structure to represent 3d vectors.