From a342e5acf476f18f1689b309315073fd2607b63b Mon Sep 17 00:00:00 2001 From: Alban de Vaucorbeil Date: Thu, 22 Aug 2024 10:34:36 +1000 Subject: [PATCH] Fix problem with Rigid bodies, contacts and TLMPM. Now rigid bodies need to have their density specified. --- src/material.cpp | 9 ++++++--- src/material.h | 6 +++--- src/solid.cpp | 6 +----- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/material.cpp b/src/material.cpp index 8771e4b8..ee3a2dd1 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -291,7 +291,7 @@ void Material::add_material(vector args) { cp, kappa}); } else if (args[1].compare("rigid") == 0) { - materials.push_back(Mat{args[0], RIGID}); + materials.push_back(Mat{args[0], RIGID, input->parsev(args[2])}); } else { // create the Material int iEOS = material->find_EOS(args[2]); @@ -656,7 +656,9 @@ void Material::read_restart(ifstream *ifr) { materials.push_back(Mat{id, type, rho0, E, nu, cp, kappa}); } else if (type == RIGID) { - materials.push_back(Mat{id, RIGID}); + double rho0; + ifr->read(reinterpret_cast(&rho0), sizeof(double)); + materials.push_back(Mat{id, RIGID, rho0}); } else { error->one(FLERR, "Error: unkown material type" + to_string(type) + ".\n"); } @@ -768,8 +770,9 @@ Mat::Mat(string id_, int type_, double rho0_, double E_, double nu_, double cp_, /*! The arguments are: material ID, material type (see Material::constitutive_model) */ -Mat::Mat(string id_, int type_) { +Mat::Mat(string id_, int type_, double rho0_) { type = type_; id = id_; rigid = true; + rho0 = rho0_; } diff --git a/src/material.h b/src/material.h index f0147801..df5377ed 100644 --- a/src/material.h +++ b/src/material.h @@ -64,7 +64,7 @@ class Mat { Mat(string, int, class EOS *, class Strength *, class Damage *, class Temperature *); ///< Creates an elasto-plastic material Mat(string, int, double, double, double, double, double); ///< Creates a linear or Neo-Hookean material - Mat(string, int); ///< Creates a rigid material + Mat(string, int, double); ///< Creates a rigid material }; /*! Stores all the user defined Equations of State, elasto-plastic, damage, and temperature @@ -124,11 +124,11 @@ class Material : protected Pointers { template static Damage *damage_creator(MPM *,vector); template static Temperature *temperature_creator(MPM *,vector); - const map usage = {{"rigid", "Usage: material(material-ID, \033[1;32mrigid\033[0m)\n"}, + const map usage = {{"rigid", "Usage: material(material-ID, \033[1;32mrigid\033[0m, rho)\n"}, {"linear", "Usage: material(material-ID, \033[1;32mlinear\033[0m, rho, E, nu, optional: cp, optional: kappa, optional: damage-ID)\n"}, {"neo-hookean", "Usage: material(material-ID, \033[1;32mneo-hookean\033[0m, rho, E, nu, optional: cp, optional: kappa, optional: damage-ID)\n"}, {"eos-strength", "Usage: material(material-ID, \033[1;32meos-strength\033[0m, eos-ID, strength-ID, optional: damage-ID, optional: temperature-ID)\n"}}; - const map Nargs = {{"rigid", 2}, + const map Nargs = {{"rigid", 3}, {"linear", 5}, {"neo-hookean", 5}, {"eos-strength", 4}}; diff --git a/src/solid.cpp b/src/solid.cpp index e432ab24..809698a9 100644 --- a/src/solid.cpp +++ b/src/solid.cpp @@ -2022,11 +2022,7 @@ void Solid::populate(vector args) else vol_ = delta * delta * delta; - double mass_; - if (mat->rigid) - mass_ = 1; - else - mass_ = mat->rho0 * vol_; + double mass_ = mat->rho0 * vol_; np_per_cell = (int) input->parsev(args[3]); double xi = 0.5;