diff --git a/python/py_solid_mechanics_model_cohesive.cc b/python/py_solid_mechanics_model_cohesive.cc index ba64b18c5..dfb2a87fc 100644 --- a/python/py_solid_mechanics_model_cohesive.cc +++ b/python/py_solid_mechanics_model_cohesive.cc @@ -1,96 +1,110 @@ /** * @file py_solid_mechanics_model_cohesive.cc * * @author Nicolas Richart * * @date creation: Tue Jul 21 2020 * @date last modification: Tue Sep 29 2020 * * @brief pybind11 interface to SolidMechanicsModelCohesive * * * @section LICENSE * * Copyright (©) 2018-2021 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 "py_aka_array.hh" /* -------------------------------------------------------------------------- */ #include #include /* -------------------------------------------------------------------------- */ #include /* -------------------------------------------------------------------------- */ namespace py = pybind11; /* -------------------------------------------------------------------------- */ namespace akantu { /* -------------------------------------------------------------------------- */ #define def_deprecated(func_name, mesg) \ def(func_name, [](py::args, py::kwargs) { AKANTU_ERROR(mesg); }) #define def_function_nocopy(func_name) \ def( \ #func_name, \ [](SolidMechanicsModel & self) -> decltype(auto) { \ return self.func_name(); \ }, \ py::return_value_policy::reference) #define def_function(func_name) \ def(#func_name, [](SolidMechanicsModel & self) -> decltype(auto) { \ return self.func_name(); \ }) void register_solid_mechanics_model_cohesive(py::module & mod) { py::class_(mod, "CohesiveElementInserter") - .def("setLimit", &CohesiveElementInserter::setLimit); + .def("setLimit", &CohesiveElementInserter::setLimit) + .def( + "getCheckFacets", + [](CohesiveElementInserter & self) { return self.getCheckFacets(); }, + py::return_value_policy::reference) + .def( + "getCheckFacets", + [](CohesiveElementInserter & self, ElementType type, + GhostType ghost_type) { + return self.getCheckFacets(type, ghost_type); + }, + py::return_value_policy::reference) + + .def("addPhysicalSurface", &CohesiveElementInserter::addPhysicalSurface) + .def("addPhysicalVolume", &CohesiveElementInserter::addPhysicalVolume); py::class_( mod, "SolidMechanicsModelCohesiveOptions") .def(py::init(), py::arg("analysis_method") = _explicit_lumped_mass, py::arg("is_extrinsic") = false); py::class_( mod, "SolidMechanicsModelCohesive") .def(py::init(), py::arg("mesh"), py::arg("spatial_dimension") = _all_dimensions, py::arg("id") = "solid_mechanics_model") .def( "initFull", [](SolidMechanicsModel & self, const AnalysisMethod & analysis_method, bool is_extrinsic) { self.initFull(_analysis_method = analysis_method, _is_extrinsic = is_extrinsic); }, py::arg("_analysis_method") = _explicit_lumped_mass, py::arg("_is_extrinsic") = false) .def("checkCohesiveStress", &SolidMechanicsModelCohesive::checkCohesiveStress) .def("getElementInserter", &SolidMechanicsModelCohesive::getElementInserter, py::return_value_policy::reference) .def("updateAutomaticInsertion", &SolidMechanicsModelCohesive::updateAutomaticInsertion); } } // namespace akantu diff --git a/src/mesh_utils/cohesive_element_inserter.hh b/src/mesh_utils/cohesive_element_inserter.hh index 43bbb6624..3ca856ceb 100644 --- a/src/mesh_utils/cohesive_element_inserter.hh +++ b/src/mesh_utils/cohesive_element_inserter.hh @@ -1,175 +1,181 @@ /** * @file cohesive_element_inserter.hh * * @author Fabian Barras * @author Nicolas Richart * @author Marco Vocialta * * @date creation: Wed Dec 04 2013 * @date last modification: Tue Jul 21 2020 * * @brief Cohesive element inserter * * * @section LICENSE * * Copyright (©) 2014-2021 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 "data_accessor.hh" #include "mesh_utils.hh" #include "parsable.hh" /* -------------------------------------------------------------------------- */ #include /* -------------------------------------------------------------------------- */ #ifndef AKANTU_COHESIVE_ELEMENT_INSERTER_HH_ #define AKANTU_COHESIVE_ELEMENT_INSERTER_HH_ namespace akantu { class GlobalIdsUpdater; class FacetSynchronizer; class SolidMechanicsModeslCohesivel; } // namespace akantu namespace akantu { class CohesiveElementInserter : public DataAccessor, public Parsable { /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ public: CohesiveElementInserter(Mesh & mesh, const ID & id = "cohesive_element_inserter"); ~CohesiveElementInserter() override; /* ------------------------------------------------------------------------ */ /* Methods */ /* ------------------------------------------------------------------------ */ public: /// set range limitation for intrinsic cohesive element insertion void setLimit(SpatialDirection axis, Real first_limit, Real second_limit); /// insert intrinsic cohesive elements in a predefined range auto insertIntrinsicElements() -> UInt; /// insert extrinsic cohesive elements (returns the number of new /// cohesive elements) UInt insertElements(bool only_double_facets = false); /// limit check facets to match given insertion limits void limitCheckFacets(); + /// limit insertion to the surfaces + void addPhysicalSurface(const ID & surface_name); + + /// limit insertion to the volumes + void addPhysicalVolume(const ID & surface_name); + protected: void parseSection(const ParserSection & section) override; protected: /// internal version of limitCheckFacets void limitCheckFacets(ElementTypeMapArray & check_facets); /// update facet insertion arrays after facets doubling void updateInsertionFacets(); /// functions for parallel communications inline UInt getNbData(const Array & elements, const SynchronizationTag & tag) const override; inline void packData(CommunicationBuffer & buffer, const Array & elements, const SynchronizationTag & tag) const override; inline void unpackData(CommunicationBuffer & buffer, const Array & elements, const SynchronizationTag & tag) override; /* ------------------------------------------------------------------------ */ /* Accessors */ /* ------------------------------------------------------------------------ */ public: AKANTU_GET_MACRO_NOT_CONST(InsertionFacetsByElement, insertion_facets, ElementTypeMapArray &); AKANTU_GET_MACRO(InsertionFacetsByElement, insertion_facets, const ElementTypeMapArray &); AKANTU_GET_MACRO_BY_ELEMENT_TYPE(InsertionFacets, insertion_facets, bool); AKANTU_GET_MACRO(CheckFacets, check_facets, const ElementTypeMapArray &); AKANTU_GET_MACRO_BY_ELEMENT_TYPE(CheckFacets, check_facets, bool); AKANTU_GET_MACRO_BY_ELEMENT_TYPE_CONST(CheckFacets, check_facets, bool); AKANTU_GET_MACRO(MeshFacets, mesh_facets, const Mesh &); AKANTU_GET_MACRO_NOT_CONST(MeshFacets, mesh_facets, Mesh &); AKANTU_SET_MACRO(IsExtrinsic, is_extrinsic, bool); public: friend class SolidMechanicsModelCohesive; /* ------------------------------------------------------------------------ */ /* Class Members */ /* ------------------------------------------------------------------------ */ private: /// object id ID id; /// main mesh where to insert cohesive elements Mesh & mesh; /// mesh containing facets Mesh & mesh_facets; /// list of facets where to insert elements ElementTypeMapArray insertion_facets; /// limits for element insertion Matrix insertion_limits; /// list of groups to consider for insertion, ignored if empty std::set physical_surfaces; /// list of groups in between which an inside which element are insterted std::set physical_zones; /// vector containing facets in which extrinsic cohesive elements can be /// inserted ElementTypeMapArray check_facets; /// global connectivity ids updater std::unique_ptr global_ids_updater; /// is this inserter used in extrinsic bool is_extrinsic{false}; }; class CohesiveNewNodesEvent : public NewNodesEvent { public: CohesiveNewNodesEvent(const std::string & origin) : NewNodesEvent(origin) {} ~CohesiveNewNodesEvent() override = default; AKANTU_GET_MACRO_NOT_CONST(OldNodesList, old_nodes, Array &); AKANTU_GET_MACRO(OldNodesList, old_nodes, const Array &); private: Array old_nodes; }; } // namespace akantu #include "cohesive_element_inserter_inline_impl.hh" #endif /* AKANTU_COHESIVE_ELEMENT_INSERTER_HH_ */ diff --git a/src/mesh_utils/cohesive_element_inserter_inline_impl.hh b/src/mesh_utils/cohesive_element_inserter_inline_impl.hh index a3afb8ae5..f671cc812 100644 --- a/src/mesh_utils/cohesive_element_inserter_inline_impl.hh +++ b/src/mesh_utils/cohesive_element_inserter_inline_impl.hh @@ -1,91 +1,103 @@ /** * @file cohesive_element_inserter_inline_impl.hh * * @author Nicolas Richart * @author Marco Vocialta * * @date creation: Fri Oct 13 2017 * @date last modification: Wed Nov 11 2020 * * @brief Cohesive element inserter inline functions * * * @section LICENSE * * Copyright (©) 2016-2021 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 "cohesive_element_inserter.hh" /* -------------------------------------------------------------------------- */ #ifndef AKANTU_COHESIVE_ELEMENT_INSERTER_INLINE_IMPL_HH_ #define AKANTU_COHESIVE_ELEMENT_INSERTER_INLINE_IMPL_HH_ namespace akantu { +/* -------------------------------------------------------------------------- */ +inline void +CohesiveElementInserter::addPhysicalSurface(const ID & surface_name) { + physical_surfaces.insert(surface_name); +} + +/* -------------------------------------------------------------------------- */ +inline void +CohesiveElementInserter::addPhysicalVolume(const ID & surface_name) { + physical_zones.insert(surface_name); +} + /* -------------------------------------------------------------------------- */ inline UInt CohesiveElementInserter::getNbData(const Array & elements, const SynchronizationTag & tag) const { AKANTU_DEBUG_IN(); UInt size = 0; if (tag == SynchronizationTag::_ce_groups) { size = elements.size() * sizeof(bool); } AKANTU_DEBUG_OUT(); return size; } /* -------------------------------------------------------------------------- */ inline void CohesiveElementInserter::packData(CommunicationBuffer & buffer, const Array & elements, const SynchronizationTag & tag) const { AKANTU_DEBUG_IN(); if (tag == SynchronizationTag::_ce_groups) { for (const auto & el : elements) { const bool & data = insertion_facets(el); buffer << data; } } AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ inline void CohesiveElementInserter::unpackData(CommunicationBuffer & buffer, const Array & elements, const SynchronizationTag & tag) { AKANTU_DEBUG_IN(); if (tag == SynchronizationTag::_ce_groups) { for (const auto & el : elements) { bool & data = insertion_facets(el); buffer >> data; } } AKANTU_DEBUG_OUT(); } } // namespace akantu #endif /* AKANTU_COHESIVE_ELEMENT_INSERTER_INLINE_IMPL_HH_ */