diff --git a/test/test_model/patch_tests/CMakeLists.txt b/test/test_model/patch_tests/CMakeLists.txt index e9241560a..bf01bd82c 100644 --- a/test/test_model/patch_tests/CMakeLists.txt +++ b/test/test_model/patch_tests/CMakeLists.txt @@ -1,124 +1,126 @@ #=============================================================================== # @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) + data/material_check_stress_plane_stress.dat + data/material_check_stress_plane_strain_finite_deformation.dat + data/material_check_stress_plane_stress_finite_deformation.dat) register_gtest_sources(SOURCES patch_test_linear_anisotropic.cc PACKAGE solid_mechanics lapack FILES_TO_COPY data/material_anisotropic_1.dat data/material_anisotropic_2.dat data/material_anisotropic_3.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 ) register_gtest_test(patch_test_linear FILES_TO_COPY ${PATCH_TEST_MESHES}) register_test(test_linear_elastic_explicit_python SCRIPT test_patch_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 test_patch_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 test_patch_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_3.dat) register_test(patch_test_linear_heat_transfer_explicit_python SCRIPT test_patch_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 test_patch_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 test_patch_linear_heat_transfer_implicit.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) diff --git a/test/test_model/patch_tests/data/material_check_stress_plane_strain.dat b/test/test_model/patch_tests/data/material_check_stress_plane_strain.dat index b7297c018..12edad981 100644 --- a/test/test_model/patch_tests/data/material_check_stress_plane_strain.dat +++ b/test/test_model/patch_tests/data/material_check_stress_plane_strain.dat @@ -1,9 +1,10 @@ permissive_parser = true material elastic [ name = steel rho = 7800 # density E = 2.1e11 # young's modulus nu = 0.3 # poisson's ratio - Plane_Stress = 0 # plane strain + Plane_Stress = false # plane strain + finite_deformation = false ] diff --git a/test/test_model/patch_tests/data/material_check_stress_plane_strain.dat b/test/test_model/patch_tests/data/material_check_stress_plane_strain_finite_deformation.dat similarity index 64% copy from test/test_model/patch_tests/data/material_check_stress_plane_strain.dat copy to test/test_model/patch_tests/data/material_check_stress_plane_strain_finite_deformation.dat index b7297c018..a245880c8 100644 --- a/test/test_model/patch_tests/data/material_check_stress_plane_strain.dat +++ b/test/test_model/patch_tests/data/material_check_stress_plane_strain_finite_deformation.dat @@ -1,9 +1,8 @@ -permissive_parser = true - material elastic [ name = steel rho = 7800 # density E = 2.1e11 # young's modulus nu = 0.3 # poisson's ratio - Plane_Stress = 0 # plane strain + Plane_Stress = false # plane strain + finite_deformation = false ] diff --git a/test/test_model/patch_tests/data/material_check_stress_plane_stress.dat b/test/test_model/patch_tests/data/material_check_stress_plane_stress.dat index 91d80b72f..5f276a3eb 100644 --- a/test/test_model/patch_tests/data/material_check_stress_plane_stress.dat +++ b/test/test_model/patch_tests/data/material_check_stress_plane_stress.dat @@ -1,7 +1,8 @@ material elastic [ name = steel rho = 7800 # density E = 2.1e11 # young's modulus nu = 0.3 # poisson's ratio - Plane_Stress = 1 # plane stress + Plane_Stress = true # plane stress + finite_deformation = false ] diff --git a/test/test_model/patch_tests/data/material_check_stress_plane_strain.dat b/test/test_model/patch_tests/data/material_check_stress_plane_stress_finite_deformation.dat similarity index 65% copy from test/test_model/patch_tests/data/material_check_stress_plane_strain.dat copy to test/test_model/patch_tests/data/material_check_stress_plane_stress_finite_deformation.dat index b7297c018..76776546e 100644 --- a/test/test_model/patch_tests/data/material_check_stress_plane_strain.dat +++ b/test/test_model/patch_tests/data/material_check_stress_plane_stress_finite_deformation.dat @@ -1,9 +1,8 @@ -permissive_parser = true - material elastic [ name = steel rho = 7800 # density E = 2.1e11 # young's modulus nu = 0.3 # poisson's ratio - Plane_Stress = 0 # plane strain + Plane_Stress = true # plane stress + finite_deformation = true ] diff --git a/test/test_model/patch_tests/patch_test_linear_elastic_explicit.cc b/test/test_model/patch_tests/patch_test_linear_elastic_explicit.cc index 3f1ae279a..1f0cd7ff6 100644 --- a/test/test_model/patch_tests/patch_test_linear_elastic_explicit.cc +++ b/test/test_model/patch_tests/patch_test_linear_elastic_explicit.cc @@ -1,56 +1,81 @@ /** * @file patch_test_linear_elastic_explicit.cc * * @author Nicolas Richart <nicolas.richart@epfl.ch> * * @date creation: Tue Jan 30 2018 * * @brief patch test solid mechanics explicit * * @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 "patch_test_linear_solid_mechanics_fixture.hh" /* -------------------------------------------------------------------------- */ TYPED_TEST(TestPatchTestSMMLinear, Explicit) { std::string filename = "material_check_stress_plane_stress.dat"; if (this->plane_strain) filename = "material_check_stress_plane_strain.dat"; this->initModel(_explicit_lumped_mass, filename); const auto & coordinates = this->mesh->getNodes(); auto & displacement = this->model->getDisplacement(); // set the position of all nodes to the static solution for (auto && tuple : zip(make_view(coordinates, this->dim), make_view(displacement, this->dim))) { this->setLinearDOF(std::get<1>(tuple), std::get<0>(tuple)); } for (UInt s = 0; s < 100; ++s) { this->model->solveStep(); } auto ekin = this->model->getEnergy("kinetic"); EXPECT_NEAR(0, ekin, 1e-16); this->checkAll(); } + +/* -------------------------------------------------------------------------- */ +TYPED_TEST(TestPatchTestSMMLinear, ExplicitFiniteDeformation) { + std::string filename = "material_check_stress_plane_stress_finite_deformation.dat"; + if (this->plane_strain) + filename = "material_check_stress_plane_strain_finite_deformation.dat"; + + this->initModel(_explicit_lumped_mass, filename); + + const auto & coordinates = this->mesh->getNodes(); + auto & displacement = this->model->getDisplacement(); + // set the position of all nodes to the static solution + for (auto && tuple : zip(make_view(coordinates, this->dim), + make_view(displacement, this->dim))) { + this->setLinearDOF(std::get<1>(tuple), std::get<0>(tuple)); + } + for (UInt s = 0; s < 100; ++s) { + this->model->solveStep(); + } + + auto ekin = this->model->getEnergy("kinetic"); + EXPECT_NEAR(0, ekin, 1e-16); + + this->checkAll(); +} diff --git a/test/test_model/patch_tests/patch_test_linear_elastic_implicit.cc b/test/test_model/patch_tests/patch_test_linear_elastic_implicit.cc index 176451091..450d82326 100644 --- a/test/test_model/patch_tests/patch_test_linear_elastic_implicit.cc +++ b/test/test_model/patch_tests/patch_test_linear_elastic_implicit.cc @@ -1,51 +1,121 @@ /** * @file patch_test_linear_elastic_implicit.cc * * @author Nicolas Richart <nicolas.richart@epfl.ch> * * @date creation: Tue Jan 30 2018 * * @brief Patch test for SolidMechanics implicit * * @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 "patch_test_linear_solid_mechanics_fixture.hh" /* -------------------------------------------------------------------------- */ #include "non_linear_solver.hh" /* -------------------------------------------------------------------------- */ +using namespace akantu; + TYPED_TEST(TestPatchTestSMMLinear, Implicit) { std::string filename = "material_check_stress_plane_stress.dat"; if (this->plane_strain) filename = "material_check_stress_plane_strain.dat"; + this->initModel(_implicit_dynamic, filename); + + const auto & coordinates = this->mesh->getNodes(); + auto & displacement = this->model->getDisplacement(); + // set the position of all nodes to the static solution + for (auto && tuple : zip(make_view(coordinates, this->dim), + make_view(displacement, this->dim))) { + this->setLinearDOF(std::get<1>(tuple), std::get<0>(tuple)); + } + for (UInt s = 0; s < 100; ++s) { + this->model->solveStep(); + } + + auto ekin = this->model->getEnergy("kinetic"); + EXPECT_NEAR(0, ekin, 1e-16); + + this->checkAll(); +} + +/* -------------------------------------------------------------------------- */ +TYPED_TEST(TestPatchTestSMMLinear, Static) { + std::string filename = "material_check_stress_plane_stress.dat"; + if (this->plane_strain) + filename = "material_check_stress_plane_strain.dat"; + + this->initModel(_static, filename); + + auto & solver = this->model->getNonLinearSolver(); + solver.set("max_iterations", 2); + solver.set("threshold", 2e-4); + solver.set("convergence_type", SolveConvergenceCriteria::_residual); + + this->model->solveStep(); + + this->checkAll(); +} + +/* -------------------------------------------------------------------------- */ +TYPED_TEST(TestPatchTestSMMLinear, ImplicitFiniteDeformation) { + std::string filename = "material_check_stress_plane_stress_finite_deformation.dat"; + if (this->plane_strain) + filename = "material_check_stress_plane_strain_finite_deformation.dat"; + + this->initModel(_implicit_dynamic, filename); + + const auto & coordinates = this->mesh->getNodes(); + auto & displacement = this->model->getDisplacement(); + // set the position of all nodes to the static solution + for (auto && tuple : zip(make_view(coordinates, this->dim), + make_view(displacement, this->dim))) { + this->setLinearDOF(std::get<1>(tuple), std::get<0>(tuple)); + } + for (UInt s = 0; s < 100; ++s) { + this->model->solveStep(); + } + + auto ekin = this->model->getEnergy("kinetic"); + EXPECT_NEAR(0, ekin, 1e-16); + + this->checkAll(); +} + +/* -------------------------------------------------------------------------- */ +TYPED_TEST(TestPatchTestSMMLinear, StaticFiniteDeformation) { + std::string filename = "material_check_stress_plane_stress_finite_deformation.dat"; + if (this->plane_strain) + filename = "material_check_stress_plane_strain_finite_deformation.dat"; + this->initModel(_static, filename); auto & solver = this->model->getNonLinearSolver(); solver.set("max_iterations", 2); solver.set("threshold", 2e-4); solver.set("convergence_type", SolveConvergenceCriteria::_residual); this->model->solveStep(); this->checkAll(); }