44 if (
model->d_x.size() == 0)
54 d_grid_p = d_reader_p->GetOutput();
55 vtkIdType num_nodes = d_grid_p->GetNumberOfPoints();
57 if (num_nodes !=
model->d_x.size()) {
58 std::cerr <<
"Error: Number of points data = " << num_nodes <<
59 " in file does not match the number of points = "
60 <<
model->d_x.size() <<
". Aborting reading.\n";
65 for (
size_t i = 0; i < num_nodes; i++) {
69 d_grid_p->GetPoint(
id, x);
72 model->setX(i, i_node);
76 vtkPointData *p_field = d_grid_p->GetPointData();
78 std::vector<std::string> tags = {
"Displacement",
"Velocity"};
79 for (
auto tag: tags) {
81 if (p_field->HasArray(tag.c_str())) {
82 vtkDataArray *array = p_field->GetArray(tag.c_str());
84 auto data_a = vtkSmartPointer<vtkDoubleArray>::New();
85 data_a->SetNumberOfComponents(3);
86 data_a->Allocate(3, 1);
88 for (
size_t i = 0; i < array->GetNumberOfTuples(); i++) {
89 array->GetTuples(i, i, data_a);
90 auto xi =
util::Point(data_a->GetValue(0), data_a->GetValue(1),
92 if (tag ==
"Displacement")
94 else if (tag ==
"Velocity")
99 if (tag ==
"Velocity") {
100 std::cerr <<
"Error: Restart file does not have <Velocity> data. "
101 "Aborting reading.\n";
103 }
else if (tag ==
"Displacement") {
105 for (
size_t i=0; i<
model->d_x.size(); i++)
VtkParticleReader(const std::string &filename)
Constructor.
void close()
Closes the file and store it to the hard disk.
void readNodes(model::ModelData *model)
Writes the nodes to the file.
vtkSmartPointer< vtkXMLUnstructuredGridReader > d_reader_p
XML unstructured grid writer.