Skip to content

Commit 21b86fb

Browse files
ktboltdivyaadil23
authored andcommitted
Check constitutive model ustruct 320 (SimVascular#321)
* Change file name. * Add functions to check for a valid constitutive model for ustruct equations.
1 parent 8461785 commit 21b86fb

File tree

5 files changed

+34
-13
lines changed

5 files changed

+34
-13
lines changed

Code/Source/solver/Parameters.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
#include "Parameters.h"
6464
#include "consts.h"
6565
#include "LinearAlgebra.h"
66+
#include "ustruct.h"
6667

6768
#include <iostream>
6869
#include <regex>
@@ -791,6 +792,20 @@ void ConstitutiveModelParameters::set_values(tinyxml2::XMLElement* xml_elem)
791792
value_set = true;
792793
}
793794

795+
/// @brief Check if a constitutive model is valid for the given equation.
796+
//
797+
void ConstitutiveModelParameters::check_constitutive_model(const Parameter<std::string>& eq_type_str)
798+
{
799+
auto eq_type = consts::equation_name_to_type.at(eq_type_str.value());
800+
auto model = consts::constitutive_model_name_to_type.at(type.value());
801+
802+
if (eq_type == consts::EquationType::phys_ustruct) {
803+
if (! ustruct::constitutive_model_is_valid(model)) {
804+
throw std::runtime_error("The " + type.value() + " constitutive model is not valid for ustruct equations.");
805+
}
806+
}
807+
}
808+
794809
//////////////////////////////////////////////////////////
795810
// CoupleCplBCParameters //
796811
//////////////////////////////////////////////////////////
@@ -1864,7 +1879,6 @@ void EquationParameters::set_values(tinyxml2::XMLElement* eq_elem)
18641879
//
18651880
while (item != nullptr) {
18661881
auto name = std::string(item->Value());
1867-
//std::cout << "[EquationParameters::set_values] name: " << name << std::endl;
18681882

18691883
if (name == BodyForceParameters::xml_element_name_) {
18701884
auto bf_params = new BodyForceParameters();
@@ -1878,6 +1892,7 @@ void EquationParameters::set_values(tinyxml2::XMLElement* eq_elem)
18781892

18791893
} else if (name == ConstitutiveModelParameters::xml_element_name_) {
18801894
default_domain->constitutive_model.set_values(item);
1895+
default_domain->constitutive_model.check_constitutive_model(type);
18811896

18821897
} else if (name == CoupleCplBCParameters::xml_element_name_) {
18831898
couple_to_cplBC.set_values(item);

Code/Source/solver/Parameters.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,7 @@ class ConstitutiveModelParameters : public ParameterLists
510510
public:
511511
ConstitutiveModelParameters();
512512
void print_parameters();
513+
void check_constitutive_model(const Parameter<std::string>& eq_type);
513514
bool defined() const { return value_set; };
514515
void set_values(tinyxml2::XMLElement* modl_params);
515516
static const std::string xml_element_name_;

Code/Source/solver/mat_models.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -408,21 +408,13 @@ void compute_pk2cc(const ComMod& com_mod, const CepMod& cep_mod, const dmnType&
408408
// Now, add isochoric and total stress, elasticity tensors
409409
switch (stM.isoType) {
410410
case ConstitutiveModelType::stIso_lin: {
411-
if (ustruct) {
412-
throw std::runtime_error("[compute_pk2cc] Linear isotropic material model not valid for ustruct physics.");
413-
}
414-
415411
double g1 = stM.C10; // mu
416412
S += g1*Idm;
417413
return;
418414
} break;
419415

420416
// St.Venant-Kirchhoff
421417
case ConstitutiveModelType::stIso_StVK: {
422-
if (ustruct) {
423-
throw std::runtime_error("[compute_pk2cc] St.Venant-Kirchhoff material model not valid for ustruct physics.");
424-
}
425-
426418
double g1 = stM.C10; // lambda
427419
double g2 = stM.C01 * 2.0; // 2*mu
428420

@@ -432,10 +424,6 @@ void compute_pk2cc(const ComMod& com_mod, const CepMod& cep_mod, const dmnType&
432424

433425
// modified St.Venant-Kirchhoff
434426
case ConstitutiveModelType::stIso_mStVK: {
435-
if (ustruct) {
436-
throw std::runtime_error("[compute_pk2cc] Modified St.Venant-Kirchhoff material model not valid for ustruct physics.");
437-
}
438-
439427
double g1 = stM.C10; // kappa
440428
double g2 = stM.C01; // mu
441429

Code/Source/solver/ustruct.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,21 @@ void b_ustruct_3d(const ComMod& com_mod, const int eNoN, const double w, const V
210210
}
211211
}
212212

213+
/// @brief Check is a constitutive model is valid for the ustruct equation.
214+
//
215+
bool constitutive_model_is_valid(consts::ConstitutiveModelType model)
216+
{
217+
using namespace consts;
218+
219+
static std::set<ConstitutiveModelType> unsupported_models {
220+
ConstitutiveModelType::stIso_lin,
221+
ConstitutiveModelType::stIso_StVK,
222+
ConstitutiveModelType::stIso_mStVK
223+
};
224+
225+
return unsupported_models.count(model) == 0;
226+
}
227+
213228
/// @brief Reproduces Fortran CONSTRUCT_uSOLID.
214229
//
215230
void construct_usolid(ComMod& com_mod, CepMod& cep_mod, const mshType& lM, const Array<double>& Ag,

Code/Source/solver/ustruct.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ void b_ustruct_3d(const ComMod& com_mod, const int eNoN, const double w, const V
4343
const Array<double>& Nx, const Array<double>& dl, const Vector<double>& hl, const Vector<double>& nV,
4444
Array<double>& lR, Array3<double>& lK, Array3<double>& lKd);
4545

46+
bool constitutive_model_is_valid(consts::ConstitutiveModelType model);
47+
4648
void construct_usolid(ComMod& com_mod, CepMod& cep_mod, const mshType& lM, const Array<double>& Ag, const Array<double>& Yg,
4749
const Array<double>& Dg);
4850

0 commit comments

Comments
 (0)