diff --git a/test/test_model/test_solid_mechanics_model/CMakeLists.txt b/test/test_model/test_solid_mechanics_model/CMakeLists.txt index 2a452097b..ceee6483a 100644 --- a/test/test_model/test_solid_mechanics_model/CMakeLists.txt +++ b/test/test_model/test_solid_mechanics_model/CMakeLists.txt @@ -1,249 +1,284 @@ #=============================================================================== # @file CMakeLists.txt # # @author Guillaume Anciaux <guillaume.anciaux@epfl.ch> # # @date creation: Fri Sep 03 2010 # @date last modification: Tue Jan 19 2016 # # @brief configuratio for SolidMechanicsModel 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 <http://www.gnu.org/licenses/>. # # @section DESCRIPTION # #=============================================================================== add_akantu_test(test_materials "test_materials") add_akantu_test(patch_tests "patch_tests") add_akantu_test(test_cohesive "cohesive_test") add_akantu_test(test_embedded_interface "test_embedded_interface") #=============================================================================== -add_mesh(test_solid_mechanics_model_square_mesh square.geo 2 1) -add_mesh(test_solid_mechanics_model_circle_mesh1 circle.geo 2 1 OUTPUT circle1.msh) -add_mesh(test_solid_mechanics_model_circle_mesh2 circle.geo 2 2 OUTPUT circle2.msh) - -register_test(test_solid_mechanics_model_square - SOURCES test_solid_mechanics_model_square.cc - DEPENDS test_solid_mechanics_model_square_mesh - FILES_TO_COPY material.dat test_cst_energy.pl - DIRECTORIES_TO_CREATE paraview - PACKAGE core - ) - -register_test(test_solid_mechanics_model_circle_2 - SOURCES test_solid_mechanics_model_circle_2.cc - DEPENDS test_solid_mechanics_model_circle_mesh2 - FILES_TO_COPY material.dat - DIRECTORIES_TO_CREATE paraview - PACKAGE core - ) +#merged in test_solid_mechanics_model_dynamics +#add_mesh(test_solid_mechanics_model_square_mesh square.geo 2 1) +#merged in test_solid_mechanics_model_dynamics +#add_mesh(test_solid_mechanics_model_circle_mesh1 circle.geo 2 1 OUTPUT circle1.msh) +#merged in test_solid_mechanics_model_dynamics +#add_mesh(test_solid_mechanics_model_circle_mesh2 circle.geo 2 2 OUTPUT circle2.msh) + +#merged in test_solid_mechanics_model_dynamics +#register_test(test_solid_mechanics_model_square +# SOURCES test_solid_mechanics_model_square.cc +# DEPENDS test_solid_mechanics_model_square_mesh +# FILES_TO_COPY material.dat test_cst_energy.pl +# DIRECTORIES_TO_CREATE paraview +# PACKAGE core +# ) +# +#register_test(test_solid_mechanics_model_circle_2 +# SOURCES test_solid_mechanics_model_circle_2.cc +# DEPENDS test_solid_mechanics_model_circle_mesh2 +# FILES_TO_COPY material.dat +# DIRECTORIES_TO_CREATE paraview +# PACKAGE core +# ) +# #=============================================================================== -add_mesh(test_bar_traction_2d_mesh1 bar.geo 2 1 OUTPUT bar1.msh) -add_mesh(test_bar_traction_2d_mesh2 bar.geo 2 2 OUTPUT bar2.msh) -add_mesh(test_bar_traction_2d_mesh_structured1 bar_structured.geo 2 1 OUTPUT bar_structured1.msh) - -register_test(test_solid_mechanics_model_bar_traction2d - SOURCES test_solid_mechanics_model_bar_traction2d.cc - DEPENDS test_bar_traction_2d_mesh1 test_bar_traction_2d_mesh2 - FILES_TO_COPY material.dat test_cst_energy.pl - DIRECTORIES_TO_CREATE paraview - PACKAGE core - ) - -register_test(test_solid_mechanics_model_bar_traction2d_structured - SOURCES test_solid_mechanics_model_bar_traction2d_structured.cc - DEPENDS test_bar_traction_2d_mesh_structured1 - FILES_TO_COPY material.dat test_cst_energy.pl - DIRECTORIES_TO_CREATE paraview - PACKAGE core - ) +#merged in test_solid_mechanics_model_dynamics +#add_mesh(test_bar_traction_2d_mesh1 bar.geo 2 1 OUTPUT bar1.msh) +#add_mesh(test_bar_traction_2d_mesh2 bar.geo 2 2 OUTPUT bar2.msh) +#add_mesh(test_bar_traction_2d_mesh_structured1 bar_structured.geo 2 1 OUTPUT bar_structured1.msh) +#register_test(test_solid_mechanics_model_bar_traction2d +# SOURCES test_solid_mechanics_model_bar_traction2d.cc +# DEPENDS test_bar_traction_2d_mesh1 test_bar_traction_2d_mesh2 +# FILES_TO_COPY material.dat test_cst_energy.pl +# DIRECTORIES_TO_CREATE paraview +# PACKAGE core +# ) +# +#register_test(test_solid_mechanics_model_bar_traction2d_structured +# SOURCES test_solid_mechanics_model_bar_traction2d_structured.cc +# DEPENDS test_bar_traction_2d_mesh_structured1 +# FILES_TO_COPY material.dat test_cst_energy.pl +# DIRECTORIES_TO_CREATE paraview +# PACKAGE core +# ) +# #=============================================================================== -add_mesh(test_solid_mechanics_model_segment_mesh segment.geo 1 2) - -register_test(test_solid_mechanics_model_bar_traction2d_parallel - SOURCES test_solid_mechanics_model_bar_traction2d_parallel.cc - DEPENDS test_bar_traction_2d_mesh2 - FILES_TO_COPY material.dat test_cst_energy.pl - DIRECTORIES_TO_CREATE paraview - PACKAGE parallel - ) - -register_test(test_solid_mechanics_model_segment_parallel - SOURCES test_solid_mechanics_model_segment_parallel.cc - DEPENDS test_solid_mechanics_model_segment_mesh - FILES_TO_COPY material.dat test_cst_energy.pl - DIRECTORIES_TO_CREATE paraview - PACKAGE parallel - ) +#merged in test_solid_mechanics_model_dynamics +#add_mesh(test_solid_mechanics_model_segment_mesh segment.geo 1 2) +# +#register_test(test_solid_mechanics_model_bar_traction2d_parallel +# SOURCES test_solid_mechanics_model_bar_traction2d_parallel.cc +# DEPENDS test_bar_traction_2d_mesh2 +# FILES_TO_COPY material.dat test_cst_energy.pl +# DIRECTORIES_TO_CREATE paraview +# PACKAGE parallel +# ) +# +#register_test(test_solid_mechanics_model_segment_parallel +# SOURCES test_solid_mechanics_model_segment_parallel.cc +# DEPENDS test_solid_mechanics_model_segment_mesh +# FILES_TO_COPY material.dat test_cst_energy.pl +# DIRECTORIES_TO_CREATE paraview +# PACKAGE parallel +# ) +# #=============================================================================== #register_test(test_solid_mechanics_model_bar_traction2d_mass_not_lumped # SOURCES test_solid_mechanics_model_bar_traction2d_mass_not_lumped.cc # DEPENDS test_bar_traction_2d_mesh1 test_bar_traction_2d_mesh2 # FILES_TO_COPY material.dat # DIRECTORIES_TO_CREATE paraview # PACKAGE implicit # ) #=============================================================================== add_mesh(test_solid_mechanics_model_segment_mesh1 segment.geo 1 1 OUTPUT segment1.msh) add_mesh(test_implicit_mesh1 square_implicit.geo 2 1 OUTPUT square_implicit1.msh) add_mesh(test_implicit_mesh2 square_implicit.geo 2 2 OUTPUT square_implicit2.msh) register_test(test_solid_mechanics_model_implicit_1d SOURCES test_solid_mechanics_model_implicit_1d.cc DEPENDS test_solid_mechanics_model_segment_mesh1 FILES_TO_COPY material.dat DIRECTORIES_TO_CREATE paraview PACKAGE implicit ) register_test(test_solid_mechanics_model_implicit_2d SOURCES test_solid_mechanics_model_implicit_2d.cc DEPENDS test_implicit_mesh1 test_implicit_mesh2 FILES_TO_COPY material_implicit.dat DIRECTORIES_TO_CREATE paraview PACKAGE implicit ) #=============================================================================== -add_mesh(test_implicit_beam_2d_1 beam_2d.geo 2 1 OUTPUT beam_2d_lin.msh) -add_mesh(test_implicit_beam_2d_2 beam_2d.geo 2 2 OUTPUT beam_2d_quad.msh) -add_mesh(test_implicit_beam_3d_2 beam_3d.geo 3 2 OUTPUT beam_3d_quad.msh) -add_mesh(test_implicit_beam_3d_1 beam_3d.geo 3 1 OUTPUT beam_3d_lin.msh) -register_test(test_solid_mechanics_model_implicit_dynamic_2d - SOURCES test_solid_mechanics_model_implicit_dynamic_2d.cc - DEPENDS test_implicit_beam_2d_1 test_implicit_beam_2d_2 test_implicit_beam_3d_2 test_implicit_beam_3d_1 - FILES_TO_COPY material_implicit_dynamic.dat - DIRECTORIES_TO_CREATE paraview - PACKAGE implicit - ) +#merged in test_solid_mechanics_model_dynamics +#add_mesh(test_implicit_beam_2d_1 beam_2d.geo 2 1 OUTPUT beam_2d_lin.msh) +#add_mesh(test_implicit_beam_2d_2 beam_2d.geo 2 2 OUTPUT beam_2d_quad.msh) +#add_mesh(test_implicit_beam_3d_2 beam_3d.geo 3 2 OUTPUT beam_3d_quad.msh) +#add_mesh(test_implicit_beam_3d_1 beam_3d.geo 3 1 OUTPUT beam_3d_lin.msh) +#register_test(test_solid_mechanics_model_implicit_dynamic_2d +# SOURCES test_solid_mechanics_model_implicit_dynamic_2d.cc +# DEPENDS test_implicit_beam_2d_1 test_implicit_beam_2d_2 test_implicit_beam_3d_2 test_implicit_beam_3d_1 +# FILES_TO_COPY material_implicit_dynamic.dat +# DIRECTORIES_TO_CREATE paraview +# PACKAGE implicit +# ) +# #=============================================================================== # register_test(test_solid_mechanics_model_bar_traction2d_structured_pbc # SOURCES test_solid_mechanics_model_bar_traction2d_structured_pbc.cc # DEPENDS test_bar_traction_2d_mesh_structured1 # FILES_TO_COPY material.dat test_cst_energy.pl # DIRECTORIES_TO_CREATE paraview # PACKAGE core # ) #add_mesh(test_pbc_parallel_mesh square_structured.geo 2 1 OUTPUT square_structured.msh) #register_test(test_solid_mechanics_model_pbc_parallel # SOURCES test_solid_mechanics_model_pbc_parallel.cc # DEPENDS test_pbc_parallel_mesh # FILES_TO_COPY material.dat # DIRECTORIES_TO_CREATE paraview # PACKAGE parallel # ) #=============================================================================== -add_mesh(test_cube3d_mesh1 cube.geo 3 1 OUTPUT cube1.msh) -add_mesh(test_cube3d_mesh2 cube.geo 3 2 OUTPUT cube2.msh) -add_mesh(test_cube3d_mesh_structured cube_structured.geo 3 1 OUTPUT cube_structured.msh) - -register_test(test_solid_mechanics_model_cube3d - SOURCES test_solid_mechanics_model_cube3d.cc - DEPENDS test_cube3d_mesh1 - FILES_TO_COPY material.dat - DIRECTORIES_TO_CREATE paraview - PACKAGE core - ) - -register_test(test_solid_mechanics_model_cube3d_tetra10 - SOURCES test_solid_mechanics_model_cube3d_tetra10.cc - DEPENDS test_cube3d_mesh2 - FILES_TO_COPY material.dat - DIRECTORIES_TO_CREATE paraview - PACKAGE core - ) +#add_mesh(test_cube3d_mesh1 cube.geo 3 1 OUTPUT cube1.msh) +#add_mesh(test_cube3d_mesh2 cube.geo 3 2 OUTPUT cube2.msh) +#add_mesh(test_cube3d_mesh_structured cube_structured.geo 3 1 OUTPUT cube_structured.msh) +# +#register_test(test_solid_mechanics_model_cube3d +# SOURCES test_solid_mechanics_model_cube3d.cc +# DEPENDS test_cube3d_mesh1 +# FILES_TO_COPY material.dat +# DIRECTORIES_TO_CREATE paraview +# PACKAGE core +# ) +# +#register_test(test_solid_mechanics_model_cube3d_tetra10 +# SOURCES test_solid_mechanics_model_cube3d_tetra10.cc +# DEPENDS test_cube3d_mesh2 +# FILES_TO_COPY material.dat +# DIRECTORIES_TO_CREATE paraview +# PACKAGE core +# ) +# # register_test(test_solid_mechanics_model_cube3d_pbc # SOURCES test_solid_mechanics_model_cube3d_pbc.cc # DEPENDS test_cube3d_mesh_structured # FILES_TO_COPY material.dat # DIRECTORIES_TO_CREATE paraview # PACKAGE core # ) #add_mesh(test_solid_mechanics_model_boundary_condition_mesh cube_physical_names.geo 3 1) # register_test(test_solid_mechanics_model_boundary_condition # SOURCES test_solid_mechanics_model_boundary_condition.cc # DEPENDS test_cube3d_mesh1 # FILES_TO_COPY material.dat # PACKAGE core # ) #=============================================================================== add_mesh(test_cube3d_two_mat_mesh cube_two_materials.geo 3 1) register_test(test_solid_mechanics_model_reassign_material SOURCES test_solid_mechanics_model_reassign_material.cc DEPENDS test_cube3d_two_mat_mesh FILES_TO_COPY two_materials.dat PACKAGE parallel PARALLEL ) #=============================================================================== register_test(test_solid_mechanics_model_material_eigenstrain SOURCES test_solid_mechanics_model_material_eigenstrain.cc FILES_TO_COPY cube_3d_tet_4.msh; material_elastic_plane_strain.dat PACKAGE core ) #=============================================================================== register_test(test_material_selector SOURCES test_material_selector.cc FILES_TO_COPY material_selector.dat material_selector.msh PACKAGE core ) package_get_variable(ET_ELEMENT_TYPES core _element_list) foreach(_et ${_element_list}) if(_et STREQUAL _point_1) continue() endif() execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_et}.msh ${CMAKE_CURRENT_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/patch_tests/data) endforeach() #=============================================================================== register_test(test_solid_mechanics_model_linear_elastic_potential_energy SOURCES test_solid_mechanics_model_linear_elastic_potential_energy.cc FILES_TO_COPY test_solid_mechanics_model_linear_elastic_potential_energy_material.dat PACKAGE core GTEST ) register_test(test_solid_mechanics_model_kinetic_energy SOURCES test_solid_mechanics_model_kinetic_energy.cc FILES_TO_COPY test_solid_mechanics_model_kinetic_energy_material.dat PACKAGE implicit GTEST ) + +#=============================================================================== +# dynamics tests +#=============================================================================== + +add_mesh(bar_segment_2 patch_tests/data/bar_segment.geo 1 1 OUTPUT bar_segment_2.msh) +add_mesh(bar_segment_3 patch_tests/data/bar_segment.geo 1 2 OUTPUT bar_segment_3.msh) +add_mesh(bar_triangle_3 patch_tests/data/bar_triangle.geo 2 1 OUTPUT bar_triangle_3.msh) +add_mesh(bar_triangle_6 patch_tests/data/bar_triangle.geo 2 2 OUTPUT bar_triangle_6.msh) +add_mesh(bar_quadrangle_4 patch_tests/data/bar_quadrangle.geo 2 1 OUTPUT bar_quadrangle_4.msh) +add_mesh(bar_quadrangle_8 patch_tests/data/bar_quadrangle.geo 2 2 OUTPUT bar_quadrangle_8.msh) +add_mesh(bar_tetrahedron_4 patch_tests/data/bar_tetrahedron.geo 3 1 OUTPUT bar_tetrahedron_4.msh) +add_mesh(bar_tetrahedron_10 patch_tests/data/bar_tetrahedron.geo 3 2 OUTPUT bar_tetrahedron_10.msh) +add_mesh(bar_hexahedron_8 patch_tests/data/bar_hexahedron.geo 3 1 OUTPUT bar_hexahedron_8.msh) +add_mesh(bar_hexahedron_20 patch_tests/data/bar_hexahedron.geo 3 2 OUTPUT bar_hexahedron_20.msh) + +add_custom_target(patch-test-dynamics-meshes ALL DEPENDS bar_segment_2 bar_segment_3 bar_triangle_3 bar_triangle_6 bar_quadrangle_4 bar_quadrangle_8 bar_tetrahedron_4 bar_tetrahedron_10 bar_hexahedron_8 bar_hexahedron_20) + +register_test(test_solid_mechanics_model_dynamics + SOURCES test_solid_mechanics_model_dynamics.cc + FILES_TO_COPY test_solid_mechanics_model_dynamics_material.dat + PACKAGE core + GTEST + ) diff --git a/test/test_model/test_solid_mechanics_model/patch_tests/data/bar_hexahedron.geo b/test/test_model/test_solid_mechanics_model/patch_tests/data/bar_hexahedron.geo new file mode 100644 index 000000000..cd7c6a709 --- /dev/null +++ b/test/test_model/test_solid_mechanics_model/patch_tests/data/bar_hexahedron.geo @@ -0,0 +1,79 @@ +h = .6; +Point(1) = {0, 0, 0, h}; +Point(2) = {10, 0, 0, h}; + +Point(3) = {0, 1., 0, h}; +Point(4) = {10, 1., 0, h}; + +Point(5) = {0, 0, 1., h}; +Point(6) = {10, 0, 1., h}; + +Point(7) = {0, 1., 1., h}; +Point(8) = {10, 1., 1., h}; + + + +Mesh.SecondOrderIncomplete = 1;//+ +Line(1) = {7, 8}; +//+ +Line(2) = {8, 6}; +//+ +Line(3) = {6, 5}; +//+ +Line(4) = {5, 7}; +//+ +Line(5) = {3, 7}; +//+ +Line(6) = {3, 1}; +//+ +Line(7) = {1, 5}; +//+ +Line(8) = {4, 2}; +//+ +Line(9) = {4, 8}; +//+ +Line(10) = {2, 6}; +//+ +Line(11) = {4, 3}; +//+ +Line(12) = {1, 2}; +//+ +Line Loop(1) = {2, -10, -8, 9}; +//+ +Plane Surface(1) = {1}; +//+ +Line Loop(2) = {7, 4, -5, 6}; +//+ +Plane Surface(2) = {2}; +//+ +Line Loop(3) = {12, 10, 3, -7}; +//+ +Plane Surface(3) = {3}; +//+ +Line Loop(4) = {3, 4, 1, 2}; +//+ +Plane Surface(4) = {4}; +//+ +Line Loop(5) = {1, -9, 11, 5}; +//+ +Plane Surface(5) = {5}; +//+ +Line Loop(6) = {11, 6, 12, -8}; +//+ +Plane Surface(6) = {6}; +//+ +Surface Loop(1) = {3, 6, 5, 4, 2, 1}; +//+ +Volume(1) = {1}; +//+ +Physical Surface("Left") = {2}; +//+ +Physical Surface("Right") = {1}; +//+ +Physical Volume("bulk") = {1}; + +Transfinite Surface "*"; +Transfinite Volume "*"; + +Recombine Surface "*"; +Mesh.SecondOrderIncomplete = 1; \ No newline at end of file diff --git a/test/test_model/test_solid_mechanics_model/patch_tests/data/bar_quadrangle.geo b/test/test_model/test_solid_mechanics_model/patch_tests/data/bar_quadrangle.geo new file mode 100644 index 000000000..4826d400d --- /dev/null +++ b/test/test_model/test_solid_mechanics_model/patch_tests/data/bar_quadrangle.geo @@ -0,0 +1,27 @@ +h = .4; +Point(1) = {0, 0, 0, h}; +Point(2) = {10, 0, 0, h}; + +Point(3) = {0, 1., 0, h}; +Point(4) = {10, 1., 0, h}; + +Line(1) = {1, 2}; +//+ +Line(2) = {4, 3}; +//+ +Line(3) = {2, 4}; +//+ +Line(4) = {3, 1}; +//+ +Line Loop(1) = {1, 3, 2, 4}; +//+ +Plane Surface(1) = {1}; + + +Physical Line("Left") = {4}; +Physical Line("Right") = {3}; +//+ +Physical Surface("bulk") = {1}; +//+ +Recombine Surface {1}; +Mesh.SecondOrderIncomplete = 1; \ No newline at end of file diff --git a/test/test_model/test_solid_mechanics_model/patch_tests/data/bar_segment.geo b/test/test_model/test_solid_mechanics_model/patch_tests/data/bar_segment.geo new file mode 100644 index 000000000..7aa27ae0a --- /dev/null +++ b/test/test_model/test_solid_mechanics_model/patch_tests/data/bar_segment.geo @@ -0,0 +1,8 @@ +h = .6; +Point(1) = {0, 0, 0, h}; +Point(2) = {10, 0, 0, h}; +Line(1) = {1, 2}; +Physical Point("Left") = {1}; +Physical Point("Right") = {2}; +//+ +Physical Line("bulk") = {1}; diff --git a/test/test_model/test_solid_mechanics_model/patch_tests/data/bar_tetrahedron.geo b/test/test_model/test_solid_mechanics_model/patch_tests/data/bar_tetrahedron.geo new file mode 100644 index 000000000..1df0b9749 --- /dev/null +++ b/test/test_model/test_solid_mechanics_model/patch_tests/data/bar_tetrahedron.geo @@ -0,0 +1,73 @@ +h = .6; +Point(1) = {0, 0, 0, h}; +Point(2) = {10, 0, 0, h}; + +Point(3) = {0, 1., 0, h}; +Point(4) = {10, 1., 0, h}; + +Point(5) = {0, 0, 1., h}; +Point(6) = {10, 0, 1., h}; + +Point(7) = {0, 1., 1., h}; +Point(8) = {10, 1., 1., h}; + + + +Mesh.SecondOrderIncomplete = 1;//+ +Line(1) = {7, 8}; +//+ +Line(2) = {8, 6}; +//+ +Line(3) = {6, 5}; +//+ +Line(4) = {5, 7}; +//+ +Line(5) = {3, 7}; +//+ +Line(6) = {3, 1}; +//+ +Line(7) = {1, 5}; +//+ +Line(8) = {4, 2}; +//+ +Line(9) = {4, 8}; +//+ +Line(10) = {2, 6}; +//+ +Line(11) = {4, 3}; +//+ +Line(12) = {1, 2}; +//+ +Line Loop(1) = {2, -10, -8, 9}; +//+ +Plane Surface(1) = {1}; +//+ +Line Loop(2) = {7, 4, -5, 6}; +//+ +Plane Surface(2) = {2}; +//+ +Line Loop(3) = {12, 10, 3, -7}; +//+ +Plane Surface(3) = {3}; +//+ +Line Loop(4) = {3, 4, 1, 2}; +//+ +Plane Surface(4) = {4}; +//+ +Line Loop(5) = {1, -9, 11, 5}; +//+ +Plane Surface(5) = {5}; +//+ +Line Loop(6) = {11, 6, 12, -8}; +//+ +Plane Surface(6) = {6}; +//+ +Surface Loop(1) = {3, 6, 5, 4, 2, 1}; +//+ +Volume(1) = {1}; +//+ +Physical Surface("Left") = {2}; +//+ +Physical Surface("Right") = {1}; +//+ +Physical Volume("bulk") = {1}; diff --git a/test/test_model/test_solid_mechanics_model/patch_tests/data/bar_triangle.geo b/test/test_model/test_solid_mechanics_model/patch_tests/data/bar_triangle.geo new file mode 100644 index 000000000..240c54287 --- /dev/null +++ b/test/test_model/test_solid_mechanics_model/patch_tests/data/bar_triangle.geo @@ -0,0 +1,24 @@ +h = .6; +Point(1) = {0, 0, 0, h}; +Point(2) = {10, 0, 0, h}; + +Point(3) = {0, 1., 0, h}; +Point(4) = {10, 1., 0, h}; + +Line(1) = {1, 2}; +//+ +Line(2) = {4, 3}; +//+ +Line(3) = {2, 4}; +//+ +Line(4) = {3, 1}; +//+ +Line Loop(1) = {1, 3, 2, 4}; +//+ +Plane Surface(1) = {1}; + + +Physical Line("Left") = {4}; +Physical Line("Right") = {3}; +//+ +Physical Surface("bulk") = {1}; diff --git a/test/test_model/test_solid_mechanics_model/test_solid_mechanics_model_dynamics.cc b/test/test_model/test_solid_mechanics_model/test_solid_mechanics_model_dynamics.cc new file mode 100644 index 000000000..9744e0d8e --- /dev/null +++ b/test/test_model/test_solid_mechanics_model/test_solid_mechanics_model_dynamics.cc @@ -0,0 +1,243 @@ +/** + * @file test_solid_mechanics_model_cube3d.cc + * + * @author Guillaume Anciaux <guillaume.anciaux@epfl.ch> + * + * @date creation: Wed Aug 04 2010 + * @date last modification: Thu Aug 06 2015 + * + * @brief test of the class SolidMechanicsModel on the 3d cube + * + * @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 <http://www.gnu.org/licenses/>. + * + */ + +/* -------------------------------------------------------------------------- */ +#include "boundary_condition_functor.hh" +#include "test_solid_mechanics_model_fixture.hh" +/* -------------------------------------------------------------------------- */ + +using namespace akantu; + +namespace { + +template <typename type_> +class TestSMMFixtureDynamics : public TestSMMFixture<type_> { + +public: + static constexpr ElementType type = type_::value; + + void SetUp() override { + if (this->type == _pentahedron_6 || this->type == _pentahedron_15) + return; + + std::cout << "testing type " << this->type << std::endl; + + TestSMMFixture<type_>::SetUp(); + } + + std::string makeMeshName() override { + std::stringstream element_type; + element_type << type; + SCOPED_TRACE(element_type.str().c_str()); + return std::string("bar") + element_type.str() + ".msh"; + } +}; + +template <UInt spatial_dimension> +auto solution_disp = + [](Vector<Real> & disp, const Vector<Real> & coord, Real current_time) { + const auto & x = coord(_x); + constexpr Real k = .5; + constexpr Real omega = k; + disp(_x) = cos(k * x - omega * current_time); + }; + +template <UInt spatial_dimension> +auto solution_vel = + [](Vector<Real> & vel, const Vector<Real> & coord, Real current_time) { + + const auto & x = coord(_x); + constexpr Real k = .5; + constexpr Real omega = k; + vel(_x) = omega * sin(k * x - omega * current_time); + }; + +template <ElementType _type> struct DimensionHelper { + static constexpr int dim = -1; +}; + +template <> struct DimensionHelper<_segment_2> { + static constexpr UInt dim = 1; +}; +template <> struct DimensionHelper<_segment_3> { + static constexpr UInt dim = 1; +}; +template <> struct DimensionHelper<_triangle_3> { + static constexpr UInt dim = 2; +}; +template <> struct DimensionHelper<_triangle_6> { + static constexpr UInt dim = 2; +}; +template <> struct DimensionHelper<_quadrangle_4> { + static constexpr UInt dim = 2; +}; +template <> struct DimensionHelper<_quadrangle_8> { + static constexpr UInt dim = 2; +}; + +template <ElementType _type> +class SolutionFunctor : public BC::Dirichlet::DirichletFunctor { +public: + SolutionFunctor(Real current_time, SolidMechanicsModel & model) + : current_time(current_time), model(model) {} + +public: + // static constexpr UInt dim = DimensionHelper<_type>::dim; + static constexpr UInt dim = ElementClass<_type>::getSpatialDimension(); + + inline void operator()(UInt node, Vector<bool> & flags, Vector<Real> & primal, + const Vector<Real> & coord) const { + + flags(0) = true; + auto & vel = model.getVelocity(); + auto itVel = vel.begin(model.getSpatialDimension()); + Vector<Real> v = itVel[node]; + solution_disp<dim>(primal, coord, current_time); + solution_vel<dim>(v, coord, current_time); + } + +private: + Real current_time; + SolidMechanicsModel & model; +}; + +template <ElementType _type, typename AM> +void test_body(SolidMechanicsModel & model, AM analysis_method) { + + // constexpr UInt dim = DimensionHelper<_type>::dim; + static constexpr UInt dim = ElementClass<_type>::getSpatialDimension(); + + getStaticParser().parse("test_solid_mechanics_model_" + "dynamics_material.dat"); + + model.initFull(SolidMechanicsModelOptions(analysis_method)); + + bool dump_paraview = false; + + if (dump_paraview) { + std::stringstream base_name; + base_name << "bar" << analysis_method << _type; + model.setBaseName(base_name.str()); + model.addDumpFieldVector("displacement"); + model.addDumpField("mass"); + model.addDumpField("velocity"); + model.addDumpField("acceleration"); + model.addDumpFieldVector("external_force"); + model.addDumpFieldVector("internal_force"); + model.addDumpField("stress"); + model.addDumpField("strain"); + } + + Real time_step = model.getStableTimeStep() / 10.; + model.setTimeStep(time_step); + std::cout << "timestep: " << time_step << std::endl; + + UInt nb_nodes = model.getMesh().getNbNodes(); + UInt spatial_dimension = model.getSpatialDimension(); + + auto & nodes = model.getMesh().getNodes(); + auto & disp = model.getDisplacement(); + auto & vel = model.getVelocity(); + + Array<Real> disp_solution(nb_nodes, spatial_dimension); + + Real current_time = 0; + + auto itNodes = nodes.begin(spatial_dimension); + auto itDisp = disp.begin(spatial_dimension); + auto itVel = vel.begin(spatial_dimension); + for (UInt n = 0; n < nb_nodes; ++n, ++itNodes, ++itDisp, ++itVel) { + solution_disp<dim>(*itDisp, *itNodes, current_time); + solution_vel<dim>(*itVel, *itNodes, current_time); + } + + if (dump_paraview) + model.dump(); + + /// boundary conditions + model.applyBC(SolutionFunctor<_type>(current_time, model), "Left"); + model.applyBC(SolutionFunctor<_type>(current_time, model), "Right"); + + Real max_error = 0.; + Real wave_velocity = 1.; // sqrt(E/rho) = sqrt(1/1) = 1 + Real simulation_time = 5 / wave_velocity; + + UInt max_steps = simulation_time / time_step; // 100 + std::cout << "max_steps: " << max_steps << std::endl; + + for (UInt s = 0; s < max_steps; ++s, current_time += time_step) { + + if (dump_paraview) + model.dump(); + + /// boundary conditions + model.applyBC(SolutionFunctor<_type>(current_time, model), "Left"); + model.applyBC(SolutionFunctor<_type>(current_time, model), "Right"); + + // compute the disp solution + auto itDispSolution = disp_solution.begin(spatial_dimension); + itNodes = nodes.begin(spatial_dimension); + for (UInt n = 0; n < nb_nodes; ++n, ++itNodes, ++itDispSolution) { + solution_disp<dim>(*itDispSolution, *itNodes, current_time); + } + // compute the error solution + itDispSolution = disp_solution.begin(spatial_dimension); + itDisp = disp.begin(spatial_dimension); + Real disp_error = 0.; + for (UInt n = 0; n < nb_nodes; ++n, ++itDispSolution, ++itDisp) { + auto diff = *itDispSolution - *itDisp; + + for (UInt i = 0; i < spatial_dimension; ++i) { + disp_error += diff(i) * diff(i); + } + } + disp_error = sqrt(disp_error) / nb_nodes; + max_error = std::max(disp_error, max_error); + ASSERT_NEAR(disp_error, 0., 1e-1); + model.solveStep(); + } + std::cout << "max error: " << max_error << std::endl; +} + +TYPED_TEST_CASE(TestSMMFixtureDynamics, types); + +#ifdef AKANTU_IMPLICIT +TYPED_TEST(TestSMMFixture, DynamicsImplicit) { + if (this->type != _pentahedron_6 && this->type != _pentahedron_15) + test_body<this->type>(*(this->model), _implicit_dynamic); +} +#endif + +TYPED_TEST(TestSMMFixtureDynamics, DynamicsExplicit) { + if (this->type != _pentahedron_6 && this->type != _pentahedron_15) + test_body<this->type>(*(this->model), _explicit_lumped_mass); +} +} diff --git a/test/test_model/test_solid_mechanics_model/test_solid_mechanics_model_dynamics_material.dat b/test/test_model/test_solid_mechanics_model/test_solid_mechanics_model_dynamics_material.dat new file mode 100644 index 000000000..e1c0e15e6 --- /dev/null +++ b/test/test_model/test_solid_mechanics_model/test_solid_mechanics_model_dynamics_material.dat @@ -0,0 +1,6 @@ +material elastic [ + name = uniterial + rho = 1 # density + E = 1 # young's modulus + nu = 0.0 # poisson's ratio +] diff --git a/test/test_model/test_solid_mechanics_model/test_solid_mechanics_model_fixture.hh b/test/test_model/test_solid_mechanics_model/test_solid_mechanics_model_fixture.hh index 078f5086a..1c6683606 100644 --- a/test/test_model/test_solid_mechanics_model/test_solid_mechanics_model_fixture.hh +++ b/test/test_model/test_solid_mechanics_model/test_solid_mechanics_model_fixture.hh @@ -1,48 +1,55 @@ /* -------------------------------------------------------------------------- */ #include "solid_mechanics_model.hh" #include "test_gtest_utils.hh" /* -------------------------------------------------------------------------- */ #include <gtest/gtest.h> #include <vector> /* -------------------------------------------------------------------------- */ #ifndef __AKANTU_TEST_SOLID_MECHANICS_MODEL_FIXTURE_HH__ #define __AKANTU_TEST_SOLID_MECHANICS_MODEL_FIXTURE_HH__ using namespace akantu; template <typename type_> class TestSMMFixture : public ::testing::Test { public: static constexpr const ElementType type = type_::value; - static constexpr const size_t spatial_dimension = ElementClass<type>::getSpatialDimension(); + static constexpr const size_t spatial_dimension = + ElementClass<type>::getSpatialDimension(); void SetUp() override { const auto spatial_dimension = this->spatial_dimension; - std::stringstream element_type; - element_type << type; - SCOPED_TRACE(element_type.str().c_str()); - mesh = std::make_unique<Mesh>(spatial_dimension); - mesh->read(element_type.str() + ".msh"); + mesh->read(this->makeMeshName()); + + std::stringstream element_type; + element_type << type; model = std::make_unique<SolidMechanicsModel>(*mesh, _all_dimensions, element_type.str()); } + virtual std::string makeMeshName() { + std::stringstream element_type; + element_type << type; + SCOPED_TRACE(element_type.str().c_str()); + return element_type.str() + ".msh"; + } + void TearDown() override { model.reset(nullptr); mesh.reset(nullptr); } protected: std::unique_ptr<Mesh> mesh; std::unique_ptr<SolidMechanicsModel> model; }; using types = gtest_list_t<TestElementTypes>; TYPED_TEST_CASE(TestSMMFixture, types); #endif /* __AKANTU_TEST_SOLID_MECHANICS_MODEL_FIXTURE_HH__ */