diff --git a/test/test_model/patch_tests/CMakeLists.txt b/test/test_model/patch_tests/CMakeLists.txt index 88e950335..5c2be61ba 100644 --- a/test/test_model/patch_tests/CMakeLists.txt +++ b/test/test_model/patch_tests/CMakeLists.txt @@ -1,87 +1,96 @@ #=============================================================================== # @file CMakeLists.txt # # @author David Simon Kammer # @author Nicolas Richart # # @date creation: Fri Oct 22 2010 # @date last modification: Mon Dec 07 2015 # # @brief configuration for patch tests # # @section LICENSE # # Copyright (©) 2010-2012, 2014, 2015 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 . # # @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 FILES_TO_COPY data/material_anisotropic.dat UNSTABLE) 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_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 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 PACKAGE python_interface 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 + 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_elastic_explicit.py b/test/test_model/patch_tests/patch_test_linear_elastic_explicit.py index 7ea90b917..6a1abd7e0 100644 --- a/test/test_model/patch_tests/patch_test_linear_elastic_explicit.py +++ b/test/test_model/patch_tests/patch_test_linear_elastic_explicit.py @@ -1,27 +1,27 @@ #!/usr/bin/env python3 from patch_test_linear_solid_mechanics_fixture import TestPatchTestSMMLinear import akantu -import unittest + def foo(self): filename = "material_check_stress_plane_stress.dat" if self.plane_strain: filename = "material_check_stress_plane_strain.dat" self.initModel(akantu._explicit_lumped_mass, filename) coordinates = self.mesh.getNodes() displacement = self.model.getDisplacement() # set the position of all nodes to the static solution self.setLinearDOF(displacement, coordinates) for s in range(0, 100): self.model.solveStep() ekin = self.model.getEnergy("kinetic") self.assertAlmostEqual(0, ekin, 1e-16) self.checkAll() TestPatchTestSMMLinear.TYPED_TEST(foo, "Explicit") diff --git a/test/test_model/patch_tests/patch_test_linear_solid_mechanics_fixture.py b/test/test_model/patch_tests/patch_test_linear_solid_mechanics_fixture.py index fa64d3e53..1f43b8f50 100644 --- a/test/test_model/patch_tests/patch_test_linear_solid_mechanics_fixture.py +++ b/test/test_model/patch_tests/patch_test_linear_solid_mechanics_fixture.py @@ -1,70 +1,50 @@ #!/usr/bin/env python3 import patch_test_linear_fixture import numpy as np import akantu class TestPatchTestSMMLinear(patch_test_linear_fixture.TestPatchTestLinear): plane_strain = True model_type = akantu.SolidMechanicsModel def applyBC(self): - patch_test_linear_fixture.TestPatchTestLinear.applyBC(self) + super().applyBC() displacement = self.model.getDisplacement() self.applyBConDOFs(displacement) def checkAll(self): displacement = self.model.getDisplacement() mat = self.model.getMaterial(0) self.checkDOFs(displacement) self.checkGradient(mat.getGradU(self.elem_type), displacement) def foo(pstrain): nu = self.model.getMaterial(0).getParamReal("nu") E = self.model.getMaterial(0).getParamReal("E") strain = (pstrain + pstrain.transpose()) / 2. trace = strain.trace() _lambda = nu * E / ((1 + nu) * (1 - 2 * nu)) mu = E / (2 * (1 + nu)) if (not self.plane_strain): _lambda = nu * E / (1 - nu * nu) stress = np.zeros((self.dim, self.dim)) if self.dim == 1: stress[0, 0] = E * strain[0, 0] else: stress[:, :] = ( _lambda * trace * np.eye(self.dim) + 2 * mu * strain) return stress self.checkResults(foo, mat.getStress(self.elem_type), displacement) - - -# template struct invalid_plan_stress : std::true_type {} -# template -# struct invalid_plan_stress> -# : aka::bool_constant::getSpatialDimension() != -# 2 and -# not bool_c::value> {} -# -# using true_false = -# std::tuple, aka::bool_constant> -# -# template using valid_types = aka::negation> -# -# using types = gtest_list_t< -# tuple_filter_t>> -# -# TYPED_TEST_CASE(TestPatchTestSMMLinear, types) - -#endif /* __AKANTU_PATCH_TEST_LINEAR_SOLID_MECHANICS_FIXTURE_HH__ */