Skip to content

Commit

Permalink
Variable renames and 3d Test Case
Browse files Browse the repository at this point in the history
  • Loading branch information
cgeudeker committed Mar 2, 2021
1 parent 2c44bee commit 30ef52e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
8 changes: 4 additions & 4 deletions include/materials/linear_elastic.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ class LinearElastic : public Material<Tdim> {
double poisson_ratio_{std::numeric_limits<double>::max()};
//! Bulk modulus
double bulk_modulus_{std::numeric_limits<double>::max()};
//! S-Wave Velocity
double s_wave_velocity_{std::numeric_limits<double>::max()};
//! P-Wave Velocity
double p_wave_velocity_{std::numeric_limits<double>::max()};
//! Compressional Wave Velocity
double vp_{std::numeric_limits<double>::max()};
//! Shear Wave Velocity
double vs_{std::numeric_limits<double>::max()};
}; // LinearElastic class
} // namespace mpm

Expand Down
6 changes: 4 additions & 2 deletions include/materials/linear_elastic.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ mpm::LinearElastic<Tdim>::LinearElastic(unsigned id,
double shear_modulus = youngs_modulus_ / (2.0 * (1. + poisson_ratio_));

// Calculate wave velocities
p_wave_velocity_ = sqrt(constrained_modulus / density_);
s_wave_velocity_ = sqrt(shear_modulus / density_);
vp_ = sqrt(constrained_modulus / density_);
vs_ = sqrt(shear_modulus / density_);

properties_ = material_properties;
properties_["pwave_velocity"] = vp_;
properties_["swave_velocity"] = vs_;

// Set elastic tensor
this->compute_elastic_tensor();
Expand Down
24 changes: 18 additions & 6 deletions tests/materials/linear_elastic_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -148,18 +148,16 @@ TEST_CASE("LinearElastic is checked in 2D", "[material][linear_elastic][2D]") {

SECTION("LinearElastic check properties earthquake") {
unsigned id = 0;
jmaterial["p_wave_velocity"] = 116.023870223;
jmaterial["s_wave_velocity"] = 62.0173672946;

auto material =
Factory<mpm::Material<Dim>, unsigned, const Json&>::instance()->create(
"LinearElastic2D", std::move(id), jmaterial);

// Get P-Wave and S-Wave Velocities
REQUIRE(material->template property<double>("p_wave_velocity") ==
Approx(jmaterial["p_wave_velocity"]).epsilon(Tolerance));
REQUIRE(material->template property<double>("s_wave_velocity") ==
Approx(jmaterial["s_wave_velocity"]).epsilon(Tolerance));
REQUIRE(material->template property<double>("pwave_velocity") ==
Approx(116.023870223).epsilon(Tolerance));
REQUIRE(material->template property<double>("swave_velocity") ==
Approx(62.0173672946).epsilon(Tolerance));
}
}

Expand Down Expand Up @@ -303,4 +301,18 @@ TEST_CASE("LinearElastic is checked in 3D", "[material][linear_elastic][3D]") {
REQUIRE(stress(4) == Approx(7.69230769230769e+01).epsilon(Tolerance));
REQUIRE(stress(5) == Approx(1.15384615384615e+02).epsilon(Tolerance));
}

SECTION("LinearElastic check properties earthquake") {
unsigned id = 0;

auto material =
Factory<mpm::Material<Dim>, unsigned, const Json&>::instance()->create(
"LinearElastic3D", std::move(id), jmaterial);

// Get P-Wave and S-Wave Velocities
REQUIRE(material->template property<double>("pwave_velocity") ==
Approx(116.023870223).epsilon(Tolerance));
REQUIRE(material->template property<double>("swave_velocity") ==
Approx(62.0173672946).epsilon(Tolerance));
}
}

0 comments on commit 30ef52e

Please sign in to comment.