PeriDEM 0.3.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
anonymous_namespace{vtkParticleWriter.cpp} Namespace Reference

Functions

void appendPointArraysForNodes (vtkUnstructuredGrid *grid, const data::ModelData *model, const std::vector< size_t > &gids, const std::vector< std::string > &tags)
 

Function Documentation

◆ appendPointArraysForNodes()

void anonymous_namespace{vtkParticleWriter.cpp}::appendPointArraysForNodes ( vtkUnstructuredGrid *  grid,
const data::ModelData *  model,
const std::vector< size_t > &  gids,
const std::vector< std::string > &  tags 
)

Definition at line 389 of file vtkParticleWriter.cpp.

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
421 if (util::methods::isTagInList("Displacement", tags))
422 add_vec3("Displacement", model->d_u);
423 if (util::methods::isTagInList("Velocity", tags))
424 add_vec3("Velocity", model->d_v);
425 if (util::methods::isTagInList("Force_Density", tags))
426 add_vec3("Force_Density", model->d_f);
427 if (util::methods::isTagInList("Force", tags)) {
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 }
444 if (util::methods::isTagInList("Damage_Z", tags) && !model->d_Z.empty())
445 add_scalar("Damage_Z", [&](size_t g) { return model->d_Z[g]; });
446 if (util::methods::isTagInList("Damage", tags) && !model->d_phi.empty())
447 add_scalar("Damage", [&](size_t g) { return model->d_phi[g]; });
448 if (util::methods::isTagInList("Damage_Bond", tags) && !model->d_phiBond.empty())
449 add_scalar("Damage_Bond", [&](size_t g) { return model->d_phiBond[g]; });
450 if (util::methods::isTagInList("Particle_ID", tags))
451 add_scalar("Particle_ID", [&](size_t g) {
452 return static_cast<double>(
453 model->getParticleFromAllList(model->d_ptId[g])->getId());
454 });
455}
std::vector< float > d_Z
Damage at nodes.
Definition modelData.h:818
std::vector< util::Point > d_u
Displacement of the nodes.
Definition modelData.h:748
std::vector< util::Point > d_f
Total force on the nodes.
Definition modelData.h:757
std::vector< size_t > d_ptId
Global node to particle id (walls are assigned id after last particle id)
Definition modelData.h:764
std::vector< float > d_phi
Damage function at the nodes (volume-weighted, Silling 2000)
Definition modelData.h:834
std::vector< double > d_vol
Nodal volumes.
Definition modelData.h:760
std::vector< util::Point > d_v
Velocity of the nodes.
Definition modelData.h:751
std::vector< float > d_phiBond
Damage as broken-bond count fraction (Bhattacharya & Lipton 2023)
Definition modelData.h:837
const particle::BaseParticle * getParticleFromAllList(size_t i) const
Get pointer to base particle.
Definition modelData.h:86
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.
Definition vecMethods.h:284

References appendPointArraysForNodes(), data::ModelData::d_f, data::ModelData::d_phi, data::ModelData::d_phiBond, data::ModelData::d_ptId, data::ModelData::d_u, data::ModelData::d_v, data::ModelData::d_vol, data::ModelData::d_Z, particle::BaseParticle::getId(), data::ModelData::getParticleFromAllList(), and util::methods::isTagInList().

Referenced by appendPointArraysForNodes().

Here is the call graph for this function:
Here is the caller graph for this function: