diff --git a/test/test_model/test_phase_field_model/CMakeLists.txt b/test/test_model/test_phase_field_model/CMakeLists.txt index f6d80939e..fa02e318a 100644 --- a/test/test_model/test_phase_field_model/CMakeLists.txt +++ b/test/test_model/test_phase_field_model/CMakeLists.txt @@ -1,43 +1,27 @@ #=============================================================================== # @file CMakeLists.txt # # @author Mohit Pundir # # @date creation: Thu Dec 20 2018 # @date last modification: Thu Dec 20 2018 # # @brief test for the phase field model # # @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 . # #=============================================================================== -add_mesh(test_one_element test_one_element.geo 2 1) -register_test(test_phase_field_model_2d - SOURCES test_phase_field_model_2d.cc - DEPENDS test_one_element - FILES_TO_COPY material.dat - PACKAGE phase_field - ) - -register_test(test_solid_one_element - SOURCES test_solid_one_element.cc - DEPENDS test_one_element - FILES_TO_COPY material_solid.dat +register_test(test_phasefield_selector + SOURCES test_phasefield_selector.cc + FILES_TO_COPY phasefield_selector.dat phasefield_selector.msh PACKAGE core ) - -register_test(test_phase_solid_coupling - SOURCES test_phase_solid_coupling.cc - DEPENDS test_one_element - FILES_TO_COPY material_coupling.dat - PACKAGE phase_field core - ) diff --git a/test/test_model/test_phase_field_model/phasefield_selector.dat b/test/test_model/test_phase_field_model/phasefield_selector.dat new file mode 100644 index 000000000..c9aa40dc4 --- /dev/null +++ b/test/test_model/test_phase_field_model/phasefield_selector.dat @@ -0,0 +1,20 @@ +phasefield exponential [ + name = chocolate + E = 2 + gc = 2 + l0 = 2 +] + +phasefield exponential [ + name = chewing-gum + E = 1 + gc = 1 + l0 = 1 +] + +phasefield exponential [ + name = candy + E = 3 + gc = 3 + l0 = 3 +] diff --git a/test/test_model/test_phase_field_model/phasefield_selector.msh b/test/test_model/test_phase_field_model/phasefield_selector.msh new file mode 100644 index 000000000..afb5cdac7 --- /dev/null +++ b/test/test_model/test_phase_field_model/phasefield_selector.msh @@ -0,0 +1,22 @@ +$MeshFormat +2.2 0 8 +$EndMeshFormat +$PhysicalNames +3 +1 1 "chocolate" +1 2 "chewing-gum" +1 3 "candy" +$EndPhysicalNames +$Nodes +4 +1 0 0 0 +2 1 0 0 +3 2 0 0 +4 3 0 0 +$EndNodes +$Elements +3 +1 1 2 1 5 1 2 +2 1 2 2 6 2 3 +3 1 2 3 7 3 4 +$EndElements diff --git a/test/test_model/test_phase_field_model/test_phasefield_selector.cc b/test/test_model/test_phase_field_model/test_phasefield_selector.cc new file mode 100644 index 000000000..9f56214c3 --- /dev/null +++ b/test/test_model/test_phase_field_model/test_phasefield_selector.cc @@ -0,0 +1,66 @@ +/** + * @file test_phasefield_selector.cc + * + * @author Mohit Pundir + * + * @date creation: Thu Jun 18 2020 + * @date last modification: Thu Jun 18 2020 + * + * @brief Test for phasefield selector + * + * @section LICENSE + * + * Copyright (©) 2015-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 . + * + */ + +#include "aka_common.hh" +#include "phase_field_model.hh" + +using namespace akantu; + +int main(int argc, char *argv[]){ + + initialize("phasefield_selector.dat", argc, argv); + + Math::setTolerance(1e-8); + + Mesh mesh(1); + mesh.read("phasefield_selector.msh"); + + PhaseFieldModel model(mesh); + auto && selector = std::make_shared>( + "physical_names", model); + model.setPhaseFieldSelector(selector); + + model.initFull(); + + PhaseField & chocolate = model.getPhaseField("chocolate"); + PhaseField & chewing_gum = model.getPhaseField("chewing-gum"); + PhaseField & candy = model.getPhaseField("candy"); + + UInt chocolate_element = chocolate.getElementFilter(_segment_2)(0, 0); + UInt chewing_gum_element = chewing_gum.getElementFilter(_segment_2)(0, 0); + UInt candy_element = candy.getElementFilter(_segment_2)(0, 0); + + if (chocolate_element != 0 || chewing_gum_element != 1 || candy_element != 2 ) { + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +} +