diff --git a/test/test_model/test_solid_mechanics_model/test_materials/test_material_fixtures.hh b/test/test_model/test_solid_mechanics_model/test_materials/test_material_fixtures.hh index 5975250b2..4d4129a36 100644 --- a/test/test_model/test_solid_mechanics_model/test_materials/test_material_fixtures.hh +++ b/test/test_model/test_solid_mechanics_model/test_materials/test_material_fixtures.hh @@ -1,180 +1,180 @@ /* -------------------------------------------------------------------------- */ #include "material_elastic.hh" #include "solid_mechanics_model.hh" /* -------------------------------------------------------------------------- */ #include #include #include /* -------------------------------------------------------------------------- */ #define TO_IMPLEMENT AKANTU_EXCEPTION("TEST TO IMPLEMENT") using namespace akantu; /* -------------------------------------------------------------------------- */ template class FriendMaterial : public T { public: ~FriendMaterial() = default; virtual void testComputeStress() { TO_IMPLEMENT; }; virtual void testComputeTangentModuli() { TO_IMPLEMENT; }; virtual void testEnergyDensity() { TO_IMPLEMENT; }; virtual void testPushWaveSpeed() { TO_IMPLEMENT; } virtual void testShearWaveSpeed() { TO_IMPLEMENT; } static inline Matrix getDeviatoricStrain(Real intensity); static inline Matrix getHydrostaticStrain(Real intensity); static inline const Matrix reverseRotation(Matrix mat, Matrix rotation_matrix) { Matrix R = rotation_matrix; Matrix m2 = mat * R; Matrix m1 = R.transpose(); return m1 * m2; }; static inline const Matrix applyRotation(Matrix mat, const Matrix rotation_matrix) { Matrix R = rotation_matrix; Matrix m2 = mat * R.transpose(); Matrix m1 = R; return m1 * m2; }; static inline Matrix getRandomRotation3d(); static inline Matrix getRandomRotation2d(); using T::T; }; /* -------------------------------------------------------------------------- */ template Matrix FriendMaterial::getDeviatoricStrain(Real intensity) { Matrix dev = {{0, 1, 2}, {1, 0, 3}, {2, 3, 0}}; dev *= intensity; return dev; } /* -------------------------------------------------------------------------- */ template Matrix FriendMaterial::getHydrostaticStrain(Real intensity) { Matrix dev = {{1, 0, 0}, {0, 2, 0}, {0, 0, 3}}; dev *= intensity; return dev; } /* -------------------------------------------------------------------------- */ template Matrix FriendMaterial::getRandomRotation3d() { constexpr UInt Dim = 3; // Seed with a real random value, if available std::random_device rd; std::mt19937 gen(rd()); // Standard mersenne_twister_engine seeded with rd() std::uniform_real_distribution<> dis; Vector v1(Dim); Vector v2(Dim); Vector v3(Dim); for (UInt i = 0; i < Dim; ++i) { v1(i) = dis(gen); v2(i) = dis(gen); } v1.normalize(); v2.normalize(); auto d = v1.dot(v2); v2 -= v1 * d; v2.normalize(); d = v1.dot(v2); v2 -= v1 * d; v2.normalize(); v3.crossProduct(v1, v2); Vector test_axis(3); test_axis.crossProduct(v1, v2); test_axis -= v3; if (test_axis.norm() > 8 * std::numeric_limits::epsilon()) { AKANTU_DEBUG_ERROR("The axis vectors do not form a right-handed coordinate " << "system. I. e., ||n1 x n2 - n3|| should be zero, but " << "it is " << test_axis.norm() << "."); } Matrix mat(Dim, Dim); for (UInt i = 0; i < Dim; ++i) { mat(0, i) = v1[i]; mat(1, i) = v2[i]; mat(2, i) = v3[i]; } return mat; } /* -------------------------------------------------------------------------- */ template Matrix FriendMaterial::getRandomRotation2d() { constexpr UInt Dim = 2; // Seed with a real random value, if available std::random_device rd; std::mt19937 gen(rd()); // Standard mersenne_twister_engine seeded with rd() std::uniform_real_distribution<> dis; - Vector v1(Dim); - Vector v2(Dim); + // v1 and v2 are such that they form a right-hand basis with prescribed v3, + // it's need (at least) for the 2d lin. elastic orthotropic material + + Vector v1(3); + Vector v2(3); + Vector v3 = {0,0,1}; for (UInt i = 0; i < Dim; ++i) { v1(i) = dis(gen); - v2(i) = dis(gen); + // v2(i) = dis(gen); } v1.normalize(); - v2.normalize(); - - auto d = v1.dot(v2); - v2 -= v1 * d; - v2.normalize(); + v2.crossProduct(v3,v1); Matrix mat(Dim, Dim); for (UInt i = 0; i < Dim; ++i) { mat(0, i) = v1[i]; mat(1, i) = v2[i]; } return mat; } /* -------------------------------------------------------------------------- */ template class TestMaterialFixture : public ::testing::Test { public: using mat_class = typename T::mat_class; void SetUp() override { constexpr auto spatial_dimension = T::Dim; mesh = std::make_unique(spatial_dimension); model = std::make_unique(*mesh); material = std::make_unique(*model); } void TearDown() override { material.reset(nullptr); model.reset(nullptr); mesh.reset(nullptr); } using friend_class = FriendMaterial; protected: std::unique_ptr mesh; std::unique_ptr model; std::unique_ptr material; }; /* -------------------------------------------------------------------------- */ template