392 {
393 double value[3] = {0., 0., 0.};
394 auto add_vec3 = [&](const char *name, const std::vector<util::Point> &field) {
395 auto array = vtkSmartPointer<vtkDoubleArray>::New();
396 array->SetNumberOfComponents(3);
397 array->SetName(name);
398 array->SetComponentName(0, "x");
399 array->SetComponentName(1, "y");
400 array->SetComponentName(2, "z");
401 for (size_t g : gids) {
402 const auto &ui = field[g];
403 value[0] = ui.d_x;
404 value[1] = ui.d_y;
405 value[2] = ui.d_z;
406 array->InsertNextTuple(value);
407 }
408 grid->GetPointData()->AddArray(array);
409 };
410 auto add_scalar = [&](const char *name, auto getter) {
411 auto array = vtkSmartPointer<vtkDoubleArray>::New();
412 array->SetNumberOfComponents(1);
413 array->SetName(name);
414 for (size_t g : gids) {
415 value[0] = static_cast<double>(getter(g));
416 array->InsertNextTuple(value);
417 }
418 grid->GetPointData()->AddArray(array);
419 };
420
422 add_vec3(
"Displacement", model->
d_u);
424 add_vec3(
"Velocity", model->
d_v);
426 add_vec3(
"Force_Density", model->
d_f);
428 auto array = vtkSmartPointer<vtkDoubleArray>::New();
429 array->SetNumberOfComponents(3);
430 array->SetName("Force");
431 array->SetComponentName(0, "x");
432 array->SetComponentName(1, "y");
433 array->SetComponentName(2, "z");
434 for (size_t g : gids) {
435 const auto &fi = model->
d_f[g];
436 const double vol = model->
d_vol[g];
437 value[0] = fi.d_x * vol;
438 value[1] = fi.d_y * vol;
439 value[2] = fi.d_z * vol;
440 array->InsertNextTuple(value);
441 }
442 grid->GetPointData()->AddArray(array);
443 }
445 add_scalar(
"Damage_Z", [&](
size_t g) {
return model->
d_Z[g]; });
447 add_scalar(
"Damage", [&](
size_t g) {
return model->
d_phi[g]; });
449 add_scalar(
"Damage_Bond", [&](
size_t g) {
return model->
d_phiBond[g]; });
451 add_scalar("Particle_ID", [&](size_t g) {
452 return static_cast<double>(
454 });
455}
std::vector< float > d_Z
Damage at nodes.
std::vector< util::Point > d_u
Displacement of the nodes.
std::vector< util::Point > d_f
Total force on the nodes.
std::vector< size_t > d_ptId
Global node to particle id (walls are assigned id after last particle id)
std::vector< float > d_phi
Damage function at the nodes (volume-weighted, Silling 2000)
std::vector< double > d_vol
Nodal volumes.
std::vector< util::Point > d_v
Velocity of the nodes.
std::vector< float > d_phiBond
Damage as broken-bond count fraction (Bhattacharya & Lipton 2023)
const particle::BaseParticle * getParticleFromAllList(size_t i) const
Get pointer to base particle.
size_t getId() const
Get id.
bool isTagInList(const std::string &tag, const std::vector< std::string > &tags)
Returns true if tag is found in the list of tags.