diff --git a/test/test_model/patch_tests/CMakeLists.txt b/test/test_model/patch_tests/CMakeLists.txt index e69812f48..11b93baca 100644 --- a/test/test_model/patch_tests/CMakeLists.txt +++ b/test/test_model/patch_tests/CMakeLists.txt @@ -1,110 +1,115 @@ #=============================================================================== # @file CMakeLists.txt # # @author Guillaume Anciaux <guillaume.anciaux@epfl.ch> # @author David Simon Kammer <david.kammer@epfl.ch> # @author Nicolas Richart <nicolas.richart@epfl.ch> # # @date creation: Fri Oct 22 2010 # @date last modification: Thu Feb 08 2018 # # @brief configuration for patch tests # # @section LICENSE # # Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) # # Akantu is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. # # Akantu is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License along with Akantu. If not, see <http://www.gnu.org/licenses/>. # # @section DESCRIPTION # #=============================================================================== add_subdirectory(data) register_gtest_sources(SOURCES patch_test_linear_elastic_explicit.cc PACKAGE solid_mechanics FILES_TO_COPY data/material_check_stress_plane_strain.dat data/material_check_stress_plane_stress.dat) register_gtest_sources(SOURCES patch_test_linear_elastic_implicit.cc PACKAGE solid_mechanics implicit FILES_TO_COPY data/material_check_stress_plane_strain.dat data/material_check_stress_plane_stress.dat) register_gtest_sources(SOURCES patch_test_linear_anisotropic_explicit.cc PACKAGE solid_mechanics lapack + UNSTABLE FILES_TO_COPY data/material_anisotropic.dat) register_gtest_sources(SOURCES test_lumped_mass.cc PACKAGE solid_mechanics FILES_TO_COPY data/material_lumped.dat) register_gtest_sources( SOURCES patch_test_linear_heat_transfer_explicit.cc FILES_TO_COPY data/heat_transfer_input.dat PACKAGE heat_transfer) register_gtest_sources( SOURCES patch_test_linear_heat_transfer_static.cc FILES_TO_COPY data/heat_transfer_input.dat PACKAGE heat_transfer implicit) register_gtest_sources( SOURCES patch_test_linear_heat_transfer_implicit.cc FILES_TO_COPY data/heat_transfer_input.dat - PACKAGE heat_transfer implicit) + PACKAGE heat_transfer implicit + UNSTABLE + ) register_gtest_test(patch_test_linear FILES_TO_COPY ${PATCH_TEST_MESHES}) register_test(test_linear_elastic_explicit_python SCRIPT patch_test_linear_elastic_explicit.py PYTHON PACKAGE python_interface FILES_TO_COPY patch_test_linear_fixture.py FILES_TO_COPY patch_test_linear_solid_mechanics_fixture.py FILES_TO_COPY ${PATCH_TEST_MESHES}) register_test(test_linear_elastic_static_python SCRIPT patch_test_linear_elastic_static.py PYTHON PACKAGE python_interface implicit FILES_TO_COPY patch_test_linear_fixture.py FILES_TO_COPY patch_test_linear_solid_mechanics_fixture.py) register_test(test_linear_anisotropic_explicit_python SCRIPT patch_test_linear_anisotropic_explicit.py PYTHON + UNSTABLE PACKAGE python_interface lapack FILES_TO_COPY patch_test_linear_fixture.py FILES_TO_COPY patch_test_linear_solid_mechanics_fixture.py FILES_TO_COPY data/material_anisotropic.dat) register_test(patch_test_linear_heat_transfer_explicit_python SCRIPT patch_test_linear_heat_transfer_explicit.py PYTHON PACKAGE python_interface heat_transfer FILES_TO_COPY patch_test_linear_fixture.py FILES_TO_COPY patch_test_linear_heat_transfer_fixture.py FILES_TO_COPY data/heat_transfer_input.dat) register_test(patch_test_linear_heat_transfer_static_python SCRIPT patch_test_linear_heat_transfer_static.py PYTHON PACKAGE python_interface heat_transfer implicit FILES_TO_COPY patch_test_linear_fixture.py FILES_TO_COPY patch_test_linear_heat_transfer_fixture.py FILES_TO_COPY data/heat_transfer_input.dat) register_test(patch_test_linear_heat_transfer_implicit_python SCRIPT patch_test_linear_heat_transfer_implicit.py PYTHON + UNSTABLE PACKAGE python_interface heat_transfer implicit FILES_TO_COPY patch_test_linear_fixture.py FILES_TO_COPY patch_test_linear_heat_transfer_fixture.py FILES_TO_COPY data/heat_transfer_input.dat) diff --git a/test/test_model/patch_tests/patch_test_linear_heat_transfer_static.py b/test/test_model/patch_tests/patch_test_linear_heat_transfer_static.py index 57186040b..ede63a7b8 100644 --- a/test/test_model/patch_tests/patch_test_linear_heat_transfer_static.py +++ b/test/test_model/patch_tests/patch_test_linear_heat_transfer_static.py @@ -1,33 +1,33 @@ #!/usr/bin/env python3 # ------------------------------------------------------------------------------ __author__ = "Guillaume Anciaux" __copyright__ = "Copyright (C) 2016-2018, EPFL (Ecole Polytechnique Fédérale" \ " de Lausanne) Laboratory (LSMS - Laboratoire de Simulation" \ " en Mécanique des Solides)" __credits__ = ["Guillaume Anciaux"] __license__ = "L-GPLv3" __maintainer__ = "Guillaume Anciaux" __email__ = "guillaume.anciaux@epfl.ch" # ------------------------------------------------------------------------------ from patch_test_linear_heat_transfer_fixture import TestPatchTestHTMLinear import akantu def foo(self): self.initModel(akantu.HeatTransferModelOptions(akantu._static), "heat_transfer_input.dat") solver = self.model.getNonLinearSolver() solver.set("max_iterations", 2) solver.set("threshold", 2e-4) solver.set("convergence_type", akantu._scc_residual) self.model.solveStep() self.checkAll() akantu.initialize() -TestPatchTestHTMLinear.TYPED_TEST(foo, "Implicit") +TestPatchTestHTMLinear.TYPED_TEST(foo, "Static") diff --git a/test/test_model/test_solid_mechanics_model/test_materials/test_plastic_materials.cc b/test/test_model/test_solid_mechanics_model/test_materials/test_plastic_materials.cc index ae25dc305..1494ab26a 100644 --- a/test/test_model/test_solid_mechanics_model/test_materials/test_plastic_materials.cc +++ b/test/test_model/test_solid_mechanics_model/test_materials/test_plastic_materials.cc @@ -1,191 +1,191 @@ /** * @file test_plastic_materials.cc * * @author Guillaume Anciaux <guillaume.anciaux@epfl.ch> * * @date creation: Fri Nov 17 2017 * @date last modification: Wed Feb 21 2018 * * @brief Tests the plastic material * * @section LICENSE * * Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * * Akantu is free software: you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) any * later version. * * Akantu is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public License * along with Akantu. If not, see <http://www.gnu.org/licenses/>. * */ /* -------------------------------------------------------------------------- */ #include "material_linear_isotropic_hardening.hh" #include "solid_mechanics_model.hh" #include "test_material_fixtures.hh" #include <gtest/gtest.h> #include <type_traits> /* -------------------------------------------------------------------------- */ using namespace akantu; -using types = ::testing::Types<Traits<MaterialLinearIsotropicHardening, 1>, - Traits<MaterialLinearIsotropicHardening, 2>, +using types = ::testing::Types<// Traits<MaterialLinearIsotropicHardening, 1>, + // Traits<MaterialLinearIsotropicHardening, 2>, Traits<MaterialLinearIsotropicHardening, 3>>; /* -------------------------------------------------------------------------- */ template <> void FriendMaterial<MaterialLinearIsotropicHardening<3>>::testComputeStress() { Real E = 1.; // Real nu = .3; Real nu = 0.; Real rho = 1.; Real sigma_0 = 1.; Real h = 0.; Real bulk_modulus_K = E / 3. / (1 - 2. * nu); Real shear_modulus_mu = 0.5 * E / (1 + nu); setParam("E", E); setParam("nu", nu); setParam("rho", rho); setParam("sigma_y", sigma_0); setParam("h", h); Matrix<Real> rotation_matrix = getRandomRotation3d(); Real max_strain = 10.; Real strain_steps = 100; Real dt = max_strain / strain_steps; std::vector<double> steps(strain_steps); std::iota(steps.begin(), steps.end(), 0.); Matrix<Real> previous_grad_u_rot = Matrix<Real>(3, 3, 0.); Matrix<Real> previous_sigma = Matrix<Real>(3, 3, 0.); Matrix<Real> previous_sigma_rot = Matrix<Real>(3, 3, 0.); Matrix<Real> inelastic_strain_rot = Matrix<Real>(3, 3, 0.); Matrix<Real> inelastic_strain = Matrix<Real>(3, 3, 0.); Matrix<Real> previous_inelastic_strain = Matrix<Real>(3, 3, 0.); Matrix<Real> previous_inelastic_strain_rot = Matrix<Real>(3, 3, 0.); Matrix<Real> sigma_rot(3, 3, 0.); Real iso_hardening = 0.; Real previous_iso_hardening = 0.; // hydrostatic loading (should not plastify) for (auto && i : steps) { auto t = i * dt; auto grad_u = this->getHydrostaticStrain(t); auto grad_u_rot = this->applyRotation(grad_u, rotation_matrix); this->computeStressOnQuad(grad_u_rot, previous_grad_u_rot, sigma_rot, previous_sigma_rot, inelastic_strain_rot, previous_inelastic_strain_rot, iso_hardening, previous_iso_hardening, 0., 0.); auto sigma = this->reverseRotation(sigma_rot, rotation_matrix); Matrix<Real> sigma_expected = t * 3. * bulk_modulus_K * Matrix<Real>::eye(3, 1.); Real stress_error = (sigma - sigma_expected).norm<L_inf>(); ASSERT_NEAR(stress_error, 0., 1e-13); ASSERT_NEAR(inelastic_strain_rot.norm<L_inf>(), 0., 1e-13); previous_grad_u_rot = grad_u_rot; previous_sigma_rot = sigma_rot; previous_inelastic_strain_rot = inelastic_strain_rot; previous_iso_hardening = iso_hardening; } // deviatoric loading (should plastify) // stress at onset of plastication Real beta = sqrt(42); Real t_P = sigma_0 / 2. / shear_modulus_mu / beta; Matrix<Real> sigma_P = sigma_0 / beta * this->getDeviatoricStrain(1.); for (auto && i : steps) { auto t = i * dt; auto grad_u = this->getDeviatoricStrain(t); auto grad_u_rot = this->applyRotation(grad_u, rotation_matrix); Real iso_hardening, previous_iso_hardening; this->computeStressOnQuad(grad_u_rot, previous_grad_u_rot, sigma_rot, previous_sigma_rot, inelastic_strain_rot, previous_inelastic_strain_rot, iso_hardening, previous_iso_hardening, 0., 0.); auto sigma = this->reverseRotation(sigma_rot, rotation_matrix); auto inelastic_strain = this->reverseRotation(inelastic_strain_rot, rotation_matrix); if (t < t_P) { Matrix<Real> sigma_expected = shear_modulus_mu * (grad_u + grad_u.transpose()); Real stress_error = (sigma - sigma_expected).norm<L_inf>(); ASSERT_NEAR(stress_error, 0., 1e-13); ASSERT_NEAR(inelastic_strain_rot.norm<L_inf>(), 0., 1e-13); } else if (t > t_P + dt) { // skip the transition from non plastic to plastic auto delta_lambda_expected = dt / t * previous_sigma.doubleDot(grad_u + grad_u.transpose()) / 2.; auto delta_inelastic_strain_expected = delta_lambda_expected * 3. / 2. / sigma_0 * previous_sigma; auto inelastic_strain_expected = delta_inelastic_strain_expected + previous_inelastic_strain; ASSERT_NEAR((inelastic_strain - inelastic_strain_expected).norm<L_inf>(), 0., 1e-13); auto delta_sigma_expected = 2. * shear_modulus_mu * (0.5 * dt / t * (grad_u + grad_u.transpose()) - delta_inelastic_strain_expected); auto delta_sigma = sigma - previous_sigma; ASSERT_NEAR((delta_sigma_expected - delta_sigma).norm<L_inf>(), 0., 1e-13); } previous_sigma = sigma; previous_sigma_rot = sigma_rot; previous_grad_u_rot = grad_u_rot; previous_inelastic_strain = inelastic_strain; previous_inelastic_strain_rot = inelastic_strain_rot; } } namespace { template <typename T> class TestPlasticMaterialFixture : public ::TestMaterialFixture<T> {}; TYPED_TEST_CASE(TestPlasticMaterialFixture, types); -TYPED_TEST(TestPlasticMaterialFixture, DISABLED_ComputeStress) { +TYPED_TEST(TestPlasticMaterialFixture, ComputeStress) { this->material->testComputeStress(); } TYPED_TEST(TestPlasticMaterialFixture, DISABLED_EnergyDensity) { this->material->testEnergyDensity(); } TYPED_TEST(TestPlasticMaterialFixture, DISABLED_ComputeTangentModuli) { this->material->testComputeTangentModuli(); } TYPED_TEST(TestPlasticMaterialFixture, DISABLED_ComputeCelerity) { this->material->testCelerity(); } } /*****************************************************************/