42 std::vector<util::Point> *nodes,
43 size_t &element_type,
size_t &num_elem,
44 std::vector<size_t> *enc,
45 std::vector<std::vector<size_t>> *nec,
46 std::vector<double> *volumes,
bool is_fd) {
57 d_grid_p = d_reader_p->GetOutput();
58 vtkIdType num_nodes = d_grid_p->GetNumberOfPoints();
59 vtkIdType num_elems = d_grid_p->GetNumberOfCells();
62 vtkPointData *p_field = d_grid_p->GetPointData();
65 bool has_volume =
true;
66 if (p_field->HasArray(
"Node_Volume") == 0 and
67 p_field->HasArray(
"Volume") == 0)
69 vtkDataArray *vol_array;
71 if (p_field->HasArray(
"Node_Volume"))
72 vol_array = p_field->GetArray(
"Node_Volume");
73 else if (p_field->HasArray(
"Volume"))
74 vol_array = p_field->GetArray(
"Volume");
78 nodes->resize(num_nodes);
79 if (has_volume) volumes->resize(num_nodes);
83 auto u_a = vtkSmartPointer<vtkDoubleArray>::New();
84 u_a->SetNumberOfComponents(3);
87 auto fix_a = vtkSmartPointer<vtkUnsignedIntArray>::New();
88 fix_a->SetNumberOfComponents(1);
89 fix_a->Allocate(1, 1);
91 auto vol_a = vtkSmartPointer<vtkDoubleArray>::New();
92 vol_a->SetNumberOfComponents(1);
93 vol_a->Allocate(1, 1);
95 auto con_a = vtkSmartPointer<vtkIntArray>::New();
96 con_a->SetNumberOfComponents(11);
97 con_a->Allocate(11, 1);
99 for (
size_t i = 0; i < num_nodes; i++) {
103 d_grid_p->GetPoint(
id, x);
106 (*nodes)[i] = i_node;
110 vol_array->GetTuples(i, i, vol_a);
111 (*volumes)[i] = vol_a->GetValue(0);
117 if (is_fd and has_volume)
return;
122 num_elem = num_elems;
125 nec->resize(num_nodes);
128 vtkUnsignedCharArray *elem_types = d_grid_p->GetCellTypesArray();
131 vtkCellData *c_field = d_grid_p->GetCellData();
134 for (
size_t i = 0; i < num_elems; i++) {
137 vtkIdType
const *nodes_ids;
139 d_grid_p->GetCellPoints(
id, num_ids, nodes_ids);
143 elem_types->GetTuples(i, i, fix_a);
144 element_type = fix_a->GetValue(0);
152 enc->resize(nds_per_el * num_elems);
155 for (
size_t j = 0; j < num_ids; j++) {
157 (*enc)[nds_per_el * i + j] = nodes_ids[j];
160 (*nec)[nodes_ids[j]].push_back(i);
185 std::vector<size_t> *enc,
186 std::vector<std::vector<size_t>> *nec) {
187 d_grid_p = d_reader_p->GetOutput();
188 vtkIdType num_nodes = d_grid_p->GetNumberOfPoints();
189 vtkIdType num_elems = d_grid_p->GetNumberOfCells();
192 num_elem = num_elems;
196 nec->resize(num_nodes);
199 vtkUnsignedCharArray *elem_types = d_grid_p->GetCellTypesArray();
202 vtkCellData *c_field = d_grid_p->GetCellData();
205 auto val = vtkSmartPointer<vtkUnsignedIntArray>::New();
206 val->SetNumberOfComponents(1);
210 for (
size_t i = 0; i < num_elems; i++) {
213 vtkIdType
const *nodes_ids;
215 d_grid_p->GetCellPoints(
id, num_ids, nodes_ids);
219 elem_types->GetTuples(i, i, val);
220 element_type = val->GetValue(0);
229 enc->resize(nds_per_el * num_elems);
232 for (
size_t j = 0; j < num_ids; j++) {
234 (*enc)[nds_per_el * i + j] = nodes_ids[j];
237 (*nec)[nodes_ids[j]].push_back(i);
243 std::vector<uint8_t> *data) {
245 d_grid_p = d_reader_p->GetOutput();
246 vtkPointData *p_field = d_grid_p->GetPointData();
249 if (p_field->HasArray(name.c_str()) == 0)
return false;
251 vtkDataArray *array = p_field->GetArray(name.c_str());
255 auto data_a = vtkSmartPointer<vtkDoubleArray>::New();
256 data_a->SetNumberOfComponents(1);
257 data_a->Allocate(1, 1);
259 (*data).resize(array->GetNumberOfTuples());
260 for (
size_t i = 0; i < array->GetNumberOfTuples(); i++) {
261 array->GetTuples(i, i, data_a);
262 (*data)[i] = data_a->GetValue(0);
269 std::vector<size_t> *data) {
271 d_grid_p = d_reader_p->GetOutput();
272 vtkPointData *p_field = d_grid_p->GetPointData();
275 if (p_field->HasArray(name.c_str()) == 0)
return false;
277 vtkDataArray *array = p_field->GetArray(name.c_str());
281 auto data_a = vtkSmartPointer<vtkDoubleArray>::New();
282 data_a->SetNumberOfComponents(1);
283 data_a->Allocate(1, 1);
285 (*data).resize(array->GetNumberOfTuples());
286 for (
size_t i = 0; i < array->GetNumberOfTuples(); i++) {
287 array->GetTuples(i, i, data_a);
288 (*data)[i] = data_a->GetValue(0);
295 std::vector<int> *data) {
297 d_grid_p = d_reader_p->GetOutput();
298 vtkPointData *p_field = d_grid_p->GetPointData();
301 if (p_field->HasArray(name.c_str()) == 0)
return false;
303 vtkDataArray *array = p_field->GetArray(name.c_str());
307 auto data_a = vtkSmartPointer<vtkDoubleArray>::New();
308 data_a->SetNumberOfComponents(1);
309 data_a->Allocate(1, 1);
311 (*data).resize(array->GetNumberOfTuples());
312 for (
size_t i = 0; i < array->GetNumberOfTuples(); i++) {
313 array->GetTuples(i, i, data_a);
314 (*data)[i] = data_a->GetValue(0);
321 std::vector<float> *data) {
323 d_grid_p = d_reader_p->GetOutput();
324 vtkPointData *p_field = d_grid_p->GetPointData();
327 if (p_field->HasArray(name.c_str()) == 0)
return false;
329 vtkDataArray *array = p_field->GetArray(name.c_str());
333 auto data_a = vtkSmartPointer<vtkDoubleArray>::New();
334 data_a->SetNumberOfComponents(1);
335 data_a->Allocate(1, 1);
337 (*data).resize(array->GetNumberOfTuples());
338 for (
size_t i = 0; i < array->GetNumberOfTuples(); i++) {
339 array->GetTuples(i, i, data_a);
340 (*data)[i] = data_a->GetValue(0);
347 std::vector<double> *data) {
349 d_grid_p = d_reader_p->GetOutput();
350 vtkPointData *p_field = d_grid_p->GetPointData();
353 if (p_field->HasArray(name.c_str()) == 0)
return false;
355 vtkDataArray *array = p_field->GetArray(name.c_str());
359 auto data_a = vtkSmartPointer<vtkDoubleArray>::New();
360 data_a->SetNumberOfComponents(1);
361 data_a->Allocate(1, 1);
363 (*data).resize(array->GetNumberOfTuples());
364 for (
size_t i = 0; i < array->GetNumberOfTuples(); i++) {
365 array->GetTuples(i, i, data_a);
366 (*data)[i] = data_a->GetValue(0);
373 std::vector<util::Point> *data) {
375 d_grid_p = d_reader_p->GetOutput();
376 vtkPointData *p_field = d_grid_p->GetPointData();
379 if (p_field->HasArray(name.c_str()) == 0)
return false;
381 vtkDataArray *array = p_field->GetArray(name.c_str());
385 auto data_a = vtkSmartPointer<vtkDoubleArray>::New();
386 data_a->SetNumberOfComponents(3);
387 data_a->Allocate(3, 1);
389 (*data).resize(array->GetNumberOfTuples());
390 for (
size_t i = 0; i < array->GetNumberOfTuples(); i++) {
391 array->GetTuples(i, i, data_a);
392 (*data)[i] =
util::Point(data_a->GetValue(0), data_a->GetValue(1),
393 data_a->GetValue(2));
400 std::vector<util::SymMatrix3> *data) {
402 d_grid_p = d_reader_p->GetOutput();
403 vtkPointData *p_field = d_grid_p->GetPointData();
406 if (p_field->HasArray(name.c_str()) == 0)
return false;
408 vtkDataArray *array = p_field->GetArray(name.c_str());
412 auto data_a = vtkSmartPointer<vtkDoubleArray>::New();
413 data_a->SetNumberOfComponents(6);
414 data_a->Allocate(6, 1);
416 (*data).resize(array->GetNumberOfTuples());
417 for (
size_t i = 0; i < array->GetNumberOfTuples(); i++) {
418 array->GetTuples(i, i, data_a);
420 data_a->GetValue(2), data_a->GetValue(3),
421 data_a->GetValue(4), data_a->GetValue(5)});
428 std::vector<util::Matrix3> *data) {
430 d_grid_p = d_reader_p->GetOutput();
431 vtkPointData *p_field = d_grid_p->GetPointData();
434 if (p_field->HasArray(name.c_str()) == 0)
return false;
436 vtkDataArray *array = p_field->GetArray(name.c_str());
440 auto data_a = vtkSmartPointer<vtkDoubleArray>::New();
441 data_a->SetNumberOfComponents(6);
442 data_a->Allocate(6, 1);
444 (*data).resize(array->GetNumberOfTuples());
445 for (
size_t i = 0; i < array->GetNumberOfTuples(); i++) {
446 array->GetTuples(i, i, data_a);
449 m(0,0) = data_a->GetValue(0);
450 m(1,1) = data_a->GetValue(1);
451 m(2,2) = data_a->GetValue(2);
452 m(1,2) = data_a->GetValue(3);
453 m(0,2) = data_a->GetValue(4);
454 m(0,1) = data_a->GetValue(5);
469 std::vector<float> *data) {
471 d_grid_p = d_reader_p->GetOutput();
472 vtkCellData *c_field = d_grid_p->GetCellData();
475 if (c_field->HasArray(name.c_str()) == 0)
return false;
477 vtkDataArray *array = c_field->GetArray(name.c_str());
481 auto data_a = vtkSmartPointer<vtkDoubleArray>::New();
482 data_a->SetNumberOfComponents(1);
483 data_a->Allocate(1, 1);
485 (*data).resize(array->GetNumberOfTuples());
486 for (
size_t i = 0; i < array->GetNumberOfTuples(); i++) {
487 array->GetTuples(i, i, data_a);
488 (*data)[i] = data_a->GetValue(0);
495 std::vector<double> *data) {
497 d_grid_p = d_reader_p->GetOutput();
498 vtkCellData *c_field = d_grid_p->GetCellData();
501 if (c_field->HasArray(name.c_str()) == 0)
return false;
503 vtkDataArray *array = c_field->GetArray(name.c_str());
507 auto data_a = vtkSmartPointer<vtkDoubleArray>::New();
508 data_a->SetNumberOfComponents(1);
509 data_a->Allocate(1, 1);
511 (*data).resize(array->GetNumberOfTuples());
512 for (
size_t i = 0; i < array->GetNumberOfTuples(); i++) {
513 array->GetTuples(i, i, data_a);
514 (*data)[i] = data_a->GetValue(0);
521 std::vector<util::Point> *data) {
523 d_grid_p = d_reader_p->GetOutput();
524 vtkCellData *c_field = d_grid_p->GetCellData();
527 if (c_field->HasArray(name.c_str()) == 0)
return false;
529 vtkDataArray *array = c_field->GetArray(name.c_str());
533 auto data_a = vtkSmartPointer<vtkDoubleArray>::New();
534 data_a->SetNumberOfComponents(3);
535 data_a->Allocate(3, 1);
537 (*data).resize(array->GetNumberOfTuples());
538 for (
size_t i = 0; i < array->GetNumberOfTuples(); i++) {
539 array->GetTuples(i, i, data_a);
540 (*data)[i] =
util::Point(data_a->GetValue(0), data_a->GetValue(1),
541 data_a->GetValue(2));
548 std::vector<util::SymMatrix3> *data) {
550 d_grid_p = d_reader_p->GetOutput();
551 vtkCellData *c_field = d_grid_p->GetCellData();
554 if (c_field->HasArray(name.c_str()) == 0)
return false;
556 vtkDataArray *array = c_field->GetArray(name.c_str());
560 auto data_a = vtkSmartPointer<vtkDoubleArray>::New();
561 data_a->SetNumberOfComponents(6);
562 data_a->Allocate(6, 1);
564 (*data).resize(array->GetNumberOfTuples());
565 for (
size_t i = 0; i < array->GetNumberOfTuples(); i++) {
566 array->GetTuples(i, i, data_a);
568 data_a->GetValue(2), data_a->GetValue(3),
569 data_a->GetValue(4), data_a->GetValue(5)});
576 std::vector<util::Matrix3> *data) {
578 d_grid_p = d_reader_p->GetOutput();
579 vtkCellData *c_field = d_grid_p->GetCellData();
582 if (c_field->HasArray(name.c_str()) == 0)
return false;
584 vtkDataArray *array = c_field->GetArray(name.c_str());
588 auto data_a = vtkSmartPointer<vtkDoubleArray>::New();
589 data_a->SetNumberOfComponents(6);
590 data_a->Allocate(6, 1);
592 (*data).resize(array->GetNumberOfTuples());
593 for (
size_t i = 0; i < array->GetNumberOfTuples(); i++) {
594 array->GetTuples(i, i, data_a);
597 m(0,0) = data_a->GetValue(0);
598 m(1,1) = data_a->GetValue(1);
599 m(2,2) = data_a->GetValue(2);
600 m(1,2) = data_a->GetValue(3);
601 m(0,2) = data_a->GetValue(4);
602 m(0,1) = data_a->GetValue(5);
void readMesh(size_t dim, std::vector< util::Point > *nodes, size_t &element_type, size_t &num_elems, 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 readCells(size_t dim, size_t &element_type, size_t &num_elems, std::vector< size_t > *enc, std::vector< std::vector< size_t > > *nec)
Reads cell data, i.e. element-node connectivity and node-element connectivity.