diff --git a/extra_packages/extra-materials/test/test_material_FE2/test_eigenstrain_homogenization.cc b/extra_packages/extra-materials/test/test_material_FE2/test_eigenstrain_homogenization.cc index d376863e2..72d64b474 100644 --- a/extra_packages/extra-materials/test/test_material_FE2/test_eigenstrain_homogenization.cc +++ b/extra_packages/extra-materials/test/test_material_FE2/test_eigenstrain_homogenization.cc @@ -1,91 +1,91 @@ /** * @file test_eigenstrain_homogenization.cc * @author Aurelia Isabel Cuba Ramos * @date Sun Jan 31 12:27:02 2016 * * @brief test the eigenstrain homogenization * * @section LICENSE * * Copyright (©) 2010-2011 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 "solid_mechanics_model_RVE.hh" using namespace akantu; /* -------------------------------------------------------------------------- */ /* Main */ /* -------------------------------------------------------------------------- */ -int main(int argc, char *argv[]) { +int main(int argc, char * argv[]) { akantu::initialize("mesoscale_materials.dat", argc, argv); const UInt spatial_dimension = 2; Mesh mesh(spatial_dimension); mesh.read("one_inclusion.msh"); SolidMechanicsModelRVE model(mesh, false); - MeshDataMaterialSelector * mat_selector; - mat_selector = new MeshDataMaterialSelector("physical_names", model); - model.setMaterialSelector(*mat_selector); + auto mat_selector = std::make_shared>( + "physical_names", model); + model.setMaterialSelector(mat_selector); /// model initialization model.initFull(); /// apply boundary conditions Matrix grad_u_macro(spatial_dimension, spatial_dimension, 0.); model.applyBoundaryConditions(grad_u_macro); - model.setBaseName ("one-inclusion" ); + model.setBaseName("one-inclusion"); model.addDumpFieldVector("displacement"); - model.addDumpField ("stress" ); - model.addDumpField ("grad_u" ); - model.addDumpField ("blocked_dofs" ); - model.addDumpField ("material_index" ); - model.addDumpField ("eigen_grad_u" ); + model.addDumpField("stress"); + model.addDumpField("grad_u"); + model.addDumpField("blocked_dofs"); + model.addDumpField("material_index"); + model.addDumpField("eigen_grad_u"); model.dump(); /// apply eigenstrain Matrix prestrain(spatial_dimension, spatial_dimension, 0.); for (UInt i = 0; i < spatial_dimension; ++i) - prestrain(i,i) = 0.02; + prestrain(i, i) = 0.02; model.advanceASR(prestrain); model.dump(); Matrix macro_strain(spatial_dimension, spatial_dimension, 0.); model.homogenizeEigenGradU(macro_strain); - + std::cout << "the average eigen_gradu is " << macro_strain << std::endl; Matrix exact_eigenstrain(spatial_dimension, spatial_dimension, 0.); - for(UInt i = 0; i < spatial_dimension; ++i) - exact_eigenstrain(i,i) = 0.00125; + for (UInt i = 0; i < spatial_dimension; ++i) + exact_eigenstrain(i, i) = 0.00125; macro_strain -= exact_eigenstrain; - + if (macro_strain.norm() > 1.e-10) { std::cout << "the test failed!!" << std::endl; finalize(); return EXIT_FAILURE; } finalize(); return EXIT_SUCCESS; } diff --git a/extra_packages/extra-materials/test/test_material_FE2/test_material_FE2.cc b/extra_packages/extra-materials/test/test_material_FE2/test_material_FE2.cc index 762851f84..b8d703b2e 100644 --- a/extra_packages/extra-materials/test/test_material_FE2/test_material_FE2.cc +++ b/extra_packages/extra-materials/test/test_material_FE2/test_material_FE2.cc @@ -1,134 +1,121 @@ /** * @file test_material_FE2.cc * @author Aurelia Isabel Cuba Ramos * @date Sun Jan 31 12:27:02 2016 * * @brief test the material FE2 * * @section LICENSE * * Copyright (©) 2010-2011 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 "solid_mechanics_model.hh" +#include "communicator.hh" #include "material_FE2.hh" +#include "solid_mechanics_model.hh" +/* -------------------------------------------------------------------------- */ using namespace akantu; /* -------------------------------------------------------------------------- */ /* Main */ /* -------------------------------------------------------------------------- */ -int main(int argc, char *argv[]) { +int main(int argc, char * argv[]) { debug::setDebugLevel(dblWarning); - initialize("material.dat" ,argc, argv); - - StaticCommunicator & comm = akantu::StaticCommunicator::getStaticCommunicator(); - Int psize = comm.getNbProc(); + initialize("material.dat", argc, argv); + + const auto & comm = Communicator::getStaticCommunicator(); Int prank = comm.whoAmI(); /// input parameters for the simulation const UInt spatial_dimension = 2; - const ParserSection & parser = getUserParser(); - std::string mesh_file = parser.getParameter("mesh_file" ); + const ParserSection & parser = getUserParser(); + std::string mesh_file = parser.getParameter("mesh_file"); Matrix prestrain_increment = parser.getParameter("prestrain_increment"); - UInt total_steps = parser.getParameter("total_steps"); + UInt total_steps = parser.getParameter("total_steps"); Mesh mesh(spatial_dimension); - akantu::MeshPartition * partition = NULL; - - if(prank == 0) { + if (prank == 0) { mesh.read(mesh_file); - - - /// partition the mesh - partition = new MeshPartitionScotch(mesh, spatial_dimension); - - partition->partitionate(psize); } + mesh.distribute(); + /// model creation SolidMechanicsModel model(mesh); - /// model intialization - model.initParallel(partition); - delete partition; - /// set the material selector - MaterialSelector * mat_selector; - mat_selector = new MaterialSelector(); + auto mat_selector = std::make_shared(); mat_selector->setFallback(3); - model.setMaterialSelector(*mat_selector); - + model.setMaterialSelector(mat_selector); + model.initFull(SolidMechanicsModelOptions(_static)); -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- + */ /// boundary conditions - mesh.createGroupsFromMeshData("physical_names"); // creates groups from mesh names + mesh.createGroupsFromMeshData( + "physical_names"); // creates groups from mesh names model.applyBC(BC::Dirichlet::FixedValue(0, _x), "bottom"); model.applyBC(BC::Dirichlet::FixedValue(0, _y), "bottom"); // model.applyBC(BC::Dirichlet::FixedValue(1.e-2, _y), "top"); - model.setBaseName ("macro_mesh"); + model.setBaseName("macro_mesh"); model.addDumpFieldVector("displacement"); - model.addDumpField ("stress" ); - model.addDumpField ("grad_u" ); - model.addDumpField ("eigen_grad_u" ); - model.addDumpField ("blocked_dofs" ); - model.addDumpField ("material_index" ); - model.addDumpField ("material_stiffness" ); + model.addDumpField("stress"); + model.addDumpField("grad_u"); + model.addDumpField("eigen_grad_u"); + model.addDumpField("blocked_dofs"); + model.addDumpField("material_index"); + model.addDumpField("material_stiffness"); model.dump(); /// solve system model.assembleStiffnessMatrix(); - Real error = 0; + std::cout << "first solve step" << std::endl; - bool converged= model.solveStep<_scm_newton_raphson_tangent_not_computed, _scc_increment>(1e-10, error, 2); - std::cout << "the error is: " << error << std::endl; - AKANTU_DEBUG_ASSERT(converged, "Did not converge"); + model.solveStep(); std::cout << "second solve step" << std::endl; - converged = model.solveStep<_scm_newton_raphson_tangent_not_computed, _scc_increment>(1e-10, error, 2); - std::cout << "the error is: " << error << std::endl; - AKANTU_DEBUG_ASSERT(converged, "Did not converge"); + model.solveStep(); std::cout << "finished solve steps" << std::endl; /// simulate the advancement of the reaction - MaterialFE2 & mat = dynamic_cast & >(model.getMaterial("FE2_mat")); + MaterialFE2 & mat = + dynamic_cast &>( + model.getMaterial("FE2_mat")); Matrix current_prestrain(spatial_dimension, spatial_dimension, 0.); for (UInt i = 0; i < total_steps; ++i) { model.dump(); current_prestrain += prestrain_increment; mat.advanceASR(current_prestrain); model.dump(); /// solve for new displacement at the macro-scale - model.assembleStiffnessMatrix(); - model.solveStep<_scm_newton_raphson_tangent_not_computed, _scc_increment>(1e-10, error, 2); - std::cout << "the error is: " << error << std::endl; - AKANTU_DEBUG_ASSERT(converged, "Did not converge"); + model.solveStep(); } model.dump(); finalize(); - + return EXIT_SUCCESS; } diff --git a/extra_packages/extra-materials/test/test_material_FE2/test_node_selection.cc b/extra_packages/extra-materials/test/test_material_FE2/test_node_selection.cc index 7625464a6..fa7ab0200 100644 --- a/extra_packages/extra-materials/test/test_material_FE2/test_node_selection.cc +++ b/extra_packages/extra-materials/test/test_material_FE2/test_node_selection.cc @@ -1,109 +1,79 @@ /** * @file test_periodic_plate.cc * @author Aurelia Isabel Cuba Ramos * @date Thu Jan 21 10:11:04 2016 * * @brief Test for correct application of periodic boundary conditions * * @section LICENSE * * Copyright (©) 2010-2011 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 /* -------------------------------------------------------------------------- */ #include "solid_mechanics_model_RVE.hh" using namespace akantu; -int main(int argc, char *argv[]) { +int main(int argc, char * argv[]) { akantu::initialize("material_test_boundary.dat", argc, argv); const UInt spatial_dimension = 2; Mesh mesh(spatial_dimension); mesh.read("periodic_plate.msh"); - + SolidMechanicsModelRVE model(mesh, false); - MeshDataMaterialSelector * mat_selector; - mat_selector = new MeshDataMaterialSelector("physical_names", model); - model.setMaterialSelector(*mat_selector); + auto mat_selector = std::make_shared>( + "physical_names", model); + model.setMaterialSelector(mat_selector); /// model initialization model.initFull(); /// apply macroscopic deformation gradient at corner nodes - /// consider a constant strain field + /// consider a constant strain field Matrix grad_u_macro(spatial_dimension, spatial_dimension, 0.); - grad_u_macro(0,1) = 1.; - // grad_u_macro(1,1) = 0.5; - // grad_u_macro(0,0) = 1.; - /// fix top right node - // UInt node = corner_nodes(2); - // boun(node,0) = true; disp(node,0) = 0.; - // boun(node,1) = true; disp(node,1) = 0.; - // /// apply gradu*x at bottom right and top left - // node = corner_nodes(0); - // x(0) = pos(node,0); x(1) = pos(node,1); - // appl_disp.mul(grad_u_macro,x); - // boun(node,0) = true; disp(node,0) = appl_disp(0); - // boun(node,1) = true; disp(node,1) = appl_disp(1); - - // node = corner_nodes(1); - // x(0) = pos(node,0); x(1) = pos(node,1); - // appl_disp.mul(grad_u_macro,x); - // boun(node,0) = true; disp(node,0) = appl_disp(0); - // boun(node,1) = true; disp(node,1) = appl_disp(1); - - // node = corner_nodes(3); - // x(0) = pos(node,0); x(1) = pos(node,1); - // appl_disp.mul(grad_u_macro,x); - // boun(node,0) = true; disp(node,0) = appl_disp(0); - // boun(node,1) = true; disp(node,1) = appl_disp(1); - + grad_u_macro(0, 1) = 1.; model.applyBoundaryConditions(grad_u_macro); - model.setBaseName ("periodic-plate" ); + model.setBaseName("periodic-plate"); model.addDumpFieldVector("displacement"); - model.addDumpField ("stress" ); - model.addDumpField ("grad_u" ); - model.addDumpField ("blocked_dofs" ); - model.addDumpField ("material_index" ); + model.addDumpField("stress"); + model.addDumpField("grad_u"); + model.addDumpField("blocked_dofs"); + model.addDumpField("material_index"); // model.addDumpField ("" ); model.dump(); - /// solve system - model.assembleStiffnessMatrix(); - Real error = 0; - bool converged= model.solveStep<_scm_newton_raphson_tangent_not_computed, _scc_increment>(1e-12, error, 2); - AKANTU_DEBUG_ASSERT(converged, "Did not converge"); + model.solveStep(); - Real average_strain = model.averageTensorField(0,1, "strain"); + Real average_strain = model.averageTensorField(0, 1, "strain"); std::cout << "the average strain is: " << average_strain << std::endl; model.dump(); finalize(); return EXIT_SUCCESS; } diff --git a/extra_packages/extra-materials/test/test_material_damage/test_material_damage_iterative.cc b/extra_packages/extra-materials/test/test_material_damage/test_material_damage_iterative.cc index 033a24dec..a794bdefb 100644 --- a/extra_packages/extra-materials/test/test_material_damage/test_material_damage_iterative.cc +++ b/extra_packages/extra-materials/test/test_material_damage/test_material_damage_iterative.cc @@ -1,201 +1,183 @@ /** * @file test_material_damage_iterative.cc * @author Aurelia Isabel Cuba Ramos * @date Thu Nov 26 12:20:15 2015 * * @brief test the material damage iterative * * @section LICENSE * * Copyright (©) 2010-2011 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 "communicator.hh" #include "material_damage_iterative.hh" #include "solid_mechanics_model.hh" /* -------------------------------------------------------------------------- */ + using namespace akantu; + /* -------------------------------------------------------------------------- */ /* Main */ /* -------------------------------------------------------------------------- */ -int main(int argc, char *argv[]) { +int main(int argc, char * argv[]) { Math::setTolerance(1e-13); debug::setDebugLevel(dblWarning); - initialize("material.dat" ,argc, argv); - + initialize("material.dat", argc, argv); + const UInt spatial_dimension = 2; ElementType element_type = _triangle_3; - StaticCommunicator & comm = akantu::StaticCommunicator::getStaticCommunicator(); + const auto & comm = Communicator::getStaticCommunicator(); Int psize = comm.getNbProc(); Int prank = comm.whoAmI(); /// read the mesh and partion it Mesh mesh(spatial_dimension); - akantu::MeshPartition * partition = NULL; - - if(prank == 0) { + if (prank == 0) { mesh.read("plate.msh"); - - /// partition the mesh - partition = new MeshPartitionScotch(mesh, spatial_dimension); - - partition->partitionate(psize); } + mesh.distribute(); + /// model creation SolidMechanicsModel model(mesh); - model.initParallel(partition); - delete partition; /// initialization of the model - model.initFull(SolidMechanicsModelOptions(_static)); + model.initFull(_analysis_method = _static); /// boundary conditions /// Dirichlet BC - mesh.createGroupsFromMeshData("physical_names"); // creates groups from mesh names + mesh.createGroupsFromMeshData( + "physical_names"); // creates groups from mesh names model.applyBC(BC::Dirichlet::FixedValue(0, _x), "left"); model.applyBC(BC::Dirichlet::FixedValue(0, _y), "bottom"); model.applyBC(BC::Dirichlet::FixedValue(2., _y), "top"); /// add fields that should be dumped model.setBaseName("material_damage_iterative_test"); - model.addDumpFieldVector("displacement");; + model.addDumpFieldVector("displacement"); + ; model.addDumpField("stress"); model.addDumpField("blocked_dofs"); model.addDumpField("residual"); model.addDumpField("grad_u"); model.addDumpField("damage"); model.addDumpField("partitions"); model.addDumpField("material_index"); model.addDumpField("Sc"); model.addDumpField("force"); model.addDumpField("equivalent_stress"); model.dump(); - - MaterialDamageIterative & material = dynamic_cast & >(model.getMaterial(0)); - - Real error; - bool converged = false; + + MaterialDamageIterative & material = + dynamic_cast &>( + model.getMaterial(0)); + UInt nb_damaged_elements = 0; Real max_eq_stress = 0; /// solve the system - converged = model.solveStep<_scm_newton_raphson_tangent_modified, _scc_increment>(1e-12, error, 2); + model.solveStep(); - if (converged == false) { - std::cout << "The error is: " << error << std::endl; - AKANTU_DEBUG_ASSERT(converged, "Did not converge"); - } - - model.dump(); - + model.dump(); - /// check that the normalized equivalent stress - Array & eq_stress = material.getInternal("equivalent_stress")(element_type, _not_ghost); + /// check that the normalized equivalent stress + Array & eq_stress = + material.getInternal("equivalent_stress")(element_type, _not_ghost); Array::const_scalar_iterator eq_stress_it = eq_stress.begin(); UInt nb_elements = mesh.getNbElement(element_type, _not_ghost); for (UInt e = 0; e < nb_elements; ++e, ++eq_stress_it) { if (!Math::are_float_equal(*eq_stress_it, 0.1)) { - std::cout << "Error in the equivalent normalized stress" << std::endl; + std::cout << "Error in the equivalent normalized stress" << std::endl; finalize(); return EXIT_FAILURE; } } - + /// get the maximum equivalent stress max_eq_stress = material.getNormMaxEquivalentStress(); - + nb_damaged_elements = 0; if (max_eq_stress > 1.) nb_damaged_elements = material.updateDamage(); if (nb_damaged_elements) { - std::cout << "Damage occured even though the normalized stress is below 1" << std::endl; + std::cout << "Damage occured even though the normalized stress is below 1" + << std::endl; finalize(); return EXIT_FAILURE; } - /// weaken material locally to cause damage - Array & strength = const_cast &>(material.getInternal("Sc")(element_type, _not_ghost)); + Array & strength = const_cast &>( + material.getInternal("Sc")(element_type, _not_ghost)); Array::scalar_iterator strength_it = strength.begin(); ++strength_it; *strength_it = 0.9; strength_it += 4; *strength_it = 0.898; - /// solve the system again - converged = model.solveStep<_scm_newton_raphson_tangent_modified, _scc_increment>(1e-4, error, 2); - - if (converged == false) { - std::cout << "The error is: " << error << std::endl; - AKANTU_DEBUG_ASSERT(converged, "Did not converge"); - } + model.solveStep(); /// get the maximum equivalent stress max_eq_stress = material.getNormMaxEquivalentStress(); - + nb_damaged_elements = 0; if (max_eq_stress > 1.) nb_damaged_elements = material.updateDamage(); UInt nb_damaged_elements_per_proc = 2; if (nb_damaged_elements != psize * nb_damaged_elements_per_proc) { - std::cout << "Error in number of damaged elements" << std::endl; + std::cout << "Error in number of damaged elements" << std::endl; finalize(); return EXIT_FAILURE; } /// check that damage occured in correct elements Real dam_diff = 0.; - Array & damage = material.getInternal("damage")(element_type, _not_ghost); + Array & damage = + material.getInternal("damage")(element_type, _not_ghost); Array::const_scalar_iterator damage_it = damage.begin(); for (UInt e = 0; e < nb_elements; ++e, ++damage_it) { - if (e==1 || e==5) - dam_diff += std::abs(0.1-*damage_it); - else + if (e == 1 || e == 5) + dam_diff += std::abs(0.1 - *damage_it); + else dam_diff += (*damage_it); } if (dam_diff > 1.e-13) { - std::cout << "Error in damage pattern" << std::endl; + std::cout << "Error in damage pattern" << std::endl; finalize(); return EXIT_FAILURE; - } - + } /// solve to compute the stresses correctly for dumping - converged = model.solveStep<_scm_newton_raphson_tangent_modified, _scc_increment>(1e-4, error, 2); - if (converged == false) { - std::cout << "The error is: " << error << std::endl; - AKANTU_DEBUG_ASSERT(converged, "Did not converge"); - } - - - model.dump(); + model.solveStep(); + + model.dump(); - finalize(); return EXIT_SUCCESS; } diff --git a/extra_packages/extra-materials/test/test_material_damage/test_material_iterative_stiffness_reduction.cc b/extra_packages/extra-materials/test/test_material_damage/test_material_iterative_stiffness_reduction.cc index d4caf07f2..1ae992654 100644 --- a/extra_packages/extra-materials/test/test_material_damage/test_material_iterative_stiffness_reduction.cc +++ b/extra_packages/extra-materials/test/test_material_damage/test_material_iterative_stiffness_reduction.cc @@ -1,125 +1,115 @@ /** * @file test_material_iterative_strength_reduction.cc * @author Aurelia Isabel Cuba Ramos * @date Thu Nov 26 12:20:15 2015 * * @brief test the material iterative stiffness reduction * * @section LICENSE * * Copyright (©) 2010-2011 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 "communicator.hh" #include "material_damage_iterative.hh" #include "solid_mechanics_model.hh" /* -------------------------------------------------------------------------- */ using namespace akantu; /* -------------------------------------------------------------------------- */ /* Main */ /* -------------------------------------------------------------------------- */ -int main(int argc, char *argv[]) { +int main(int argc, char * argv[]) { Math::setTolerance(1e-13); debug::setDebugLevel(dblWarning); - initialize("material_stiffness_reduction.dat" ,argc, argv); - + initialize("material_stiffness_reduction.dat", argc, argv); + const UInt spatial_dimension = 2; ElementType element_type = _triangle_3; - StaticCommunicator & comm = akantu::StaticCommunicator::getStaticCommunicator(); - Int psize = comm.getNbProc(); + const auto & comm = Communicator::getStaticCommunicator(); Int prank = comm.whoAmI(); /// read the mesh and partion it Mesh mesh(spatial_dimension); - akantu::MeshPartition * partition = NULL; - - if(prank == 0) { - + if (prank == 0) { mesh.read("two_elements.msh"); - - /// partition the mesh - partition = new MeshPartitionScotch(mesh, spatial_dimension); - - partition->partitionate(psize); } + mesh.distribute(); /// model creation SolidMechanicsModel model(mesh); - model.initParallel(partition); - delete partition; - /// initialization of the model model.initFull(SolidMechanicsModelOptions(_static)); /// boundary conditions /// Dirichlet BC - mesh.createGroupsFromMeshData("physical_names"); // creates groups from mesh names + mesh.createGroupsFromMeshData( + "physical_names"); // creates groups from mesh names model.applyBC(BC::Dirichlet::FixedValue(0, _x), "left"); model.applyBC(BC::Dirichlet::FixedValue(0, _y), "bottom"); model.applyBC(BC::Dirichlet::FixedValue(2., _y), "top"); /// add fields that should be dumped model.setBaseName("material_iterative_stiffness_reduction_test"); model.addDumpField("material_index"); - model.addDumpFieldVector("displacement");; + model.addDumpFieldVector("displacement"); + ; model.addDumpField("stress"); model.addDumpField("blocked_dofs"); model.addDumpField("residual"); model.addDumpField("grad_u"); model.addDumpField("damage"); model.addDumpField("partitions"); model.addDumpField("Sc"); model.addDumpField("force"); model.addDumpField("equivalent_stress"); model.addDumpField("ultimate_strain"); model.dump(); - - MaterialDamageIterative & material = dynamic_cast & >(model.getMaterial(0)); - - Real error; - bool converged = false; + + MaterialDamageIterative & material = + dynamic_cast &>( + model.getMaterial(0)); + UInt nb_damaged_elements = 0; - Real E = material.getParam("E"); + Real E = material.get("E"); std::cout << std::setprecision(12); - const Array & damage = material.getInternal("damage")(element_type, _not_ghost); - const Array & Sc = material.getInternal("Sc")(element_type, _not_ghost); + const Array & damage = + material.getInternal("damage")(element_type, _not_ghost); + const Array & Sc = + material.getInternal("Sc")(element_type, _not_ghost); + /// solve the system do { - converged = model.solveStep<_scm_newton_raphson_tangent_modified, _scc_increment>(1e-12, error, 2); - - if (converged == false) { - std::cout << "The error is: " << error << std::endl; - AKANTU_DEBUG_ASSERT(converged, "Did not converge"); - } - + model.solveStep(); + nb_damaged_elements = material.updateDamage(); for (UInt e = 0; e < mesh.getNbElement(element_type, _not_ghost); ++e) { - std::cout << "the new modulus is " << (1-damage(0)) * E << std::endl; + std::cout << "the new modulus is " << (1 - damage(0)) * E << std::endl; std::cout << "the new strength is " << Sc(0) << std::endl; } - model.dump(); - + model.dump(); + } while (nb_damaged_elements); finalize(); return EXIT_SUCCESS; }