diff --git a/python/py_akantu.cc b/python/py_akantu.cc
index 071814a72..245d02bd6 100644
--- a/python/py_akantu.cc
+++ b/python/py_akantu.cc
@@ -1,169 +1,169 @@
/**
* Copyright (©) 2018-2023 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* This file is part of Akantu
*
* 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_config.hh"
// for NLSNotConvergedException
#include "non_linear_solver.hh"
/* -------------------------------------------------------------------------- */
#include "py_aka_common.hh"
#include "py_aka_error.hh"
#include "py_boundary_conditions.hh"
#include "py_constitutive_law.hh"
#include "py_constitutive_law_selector.hh"
#include "py_dof_manager.hh"
#include "py_dumpable.hh"
#include "py_fe_engine.hh"
#include "py_group_manager.hh"
#include "py_integration_scheme.hh"
#include "py_mesh.hh"
#include "py_model.hh"
#include "py_parser.hh"
#include "py_solver.hh"
#if defined(AKANTU_SOLID_MECHANICS)
#include "py_material.hh"
#include "py_solid_mechanics_model.hh"
#endif
#if defined(AKANTU_DIFFUSION)
#include "py_heat_transfer_model.hh"
#endif
#if defined(AKANTU_COHESIVE_ELEMENT)
#include "py_fragment_manager.hh"
#include "py_solid_mechanics_model_cohesive.hh"
#endif
#if defined(AKANTU_CONTACT_MECHANICS)
#include "py_contact_mechanics_model.hh"
#include "py_model_couplers.hh"
#endif
#if defined(AKANTU_PHASE_FIELD)
#include "py_phase_field_model.hh"
#endif
#if defined(AKANTU_STRUCTURAL_MECHANICS)
#include "py_structural_mechanics_model.hh"
#endif
/* -------------------------------------------------------------------------- */
#include
/* -------------------------------------------------------------------------- */
#include
/* -------------------------------------------------------------------------- */
#include
/* -------------------------------------------------------------------------- */
namespace py = pybind11;
namespace akantu {
void register_all(pybind11::module & mod) {
register_initialize(mod);
register_enums(mod);
register_error(mod);
register_functions(mod);
register_parser(mod);
register_solvers(mod);
- register_group_manager(mod);
register_dumpable(mod);
+ register_group_manager(mod);
register_mesh(mod);
register_fe_engine(mod);
register_integration_schemes(mod);
register_dof_manager(mod);
register_boundary_conditions(mod);
register_model(mod);
register_constitutive_law_selector(mod);
register_constitutive_law_internal_handler(mod);
#if defined(AKANTU_DIFFUSION)
register_heat_transfer_model(mod);
#endif
#if defined(AKANTU_SOLID_MECHANICS)
register_solid_mechanics_model(mod);
register_material(mod);
#endif
#if defined(AKANTU_COHESIVE_ELEMENT)
register_solid_mechanics_model_cohesive(mod);
register_fragment_manager(mod);
#endif
#if defined(AKANTU_STRUCTURAL_MECHANICS)
register_structural_mechanics_model(mod);
#endif
#if defined(AKANTU_CONTACT_MECHANICS)
register_contact_mechanics_model(mod);
register_model_couplers(mod);
#endif
#if defined(AKANTU_PHASE_FIELD)
register_phase_field_model(mod);
register_phase_field_coupler(mod);
#endif
}
} // namespace akantu
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
PYBIND11_MODULE(py11_akantu, mod) {
mod.doc() = "Akantu python interface";
static py::exception akantu_exception(mod,
"Exception");
static py::exception
akantu_exception_nls_not_converged(mod, "NLSNotConvergedException");
py::register_exception_translator([](std::exception_ptr ptr) {
try {
if (ptr) {
std::rethrow_exception(ptr);
}
} catch (akantu::debug::NLSNotConvergedException & e) {
akantu_exception_nls_not_converged(e.info().c_str());
} catch (akantu::debug::Exception & e) {
if (akantu::debug::debugger.printBacktrace()) {
akantu::debug::printBacktrace();
}
akantu_exception(e.info().c_str());
}
});
akantu::register_all(mod);
mod.def("has_mpi",
[]() {
#if defined(AKANTU_USE_MPI)
return true;
#else
return false;
#endif
})
.def("getVersion", &akantu::getVersion);
} // Module akantu
diff --git a/python/py_group_manager.cc b/python/py_group_manager.cc
index 3209c42a3..5e43fef7a 100644
--- a/python/py_group_manager.cc
+++ b/python/py_group_manager.cc
@@ -1,175 +1,176 @@
/**
* Copyright (©) 2019-2023 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* This file is part of Akantu
*
* 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
+#include
#include
/* -------------------------------------------------------------------------- */
#include
/* -------------------------------------------------------------------------- */
#include
#include
/* -------------------------------------------------------------------------- */
namespace py = pybind11;
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
void register_group_manager(py::module & mod) {
/* ------------------------------------------------------------------------ */
py::class_(mod, "NodeGroup")
.def(
"getNodes",
[](NodeGroup & self) -> decltype(auto) { return self.getNodes(); },
py::return_value_policy::reference)
.def("__len__", &NodeGroup::size)
.def(
"__iter__",
[](const NodeGroup & self) {
return py::make_iterator(self.begin(), self.end());
},
py::keep_alive<0, 1>())
.def("__contains__", [](const NodeGroup & self,
UInt node) { return self.find(node) != -1; })
.def("getName", &NodeGroup::getName)
.def("clear", &NodeGroup::clear)
.def("empty", &NodeGroup::empty)
.def("append", &NodeGroup::append)
.def(
"add",
[](NodeGroup & self, UInt node, bool check_for_duplicate) {
auto && it = self.add(node, check_for_duplicate);
return *it;
},
py::arg("node"), py::arg("check_for_duplicate") = true)
.def("remove", &NodeGroup::add);
/* ------------------------------------------------------------------------ */
py::class_(mod, "ElementGroup")
.def(
"getNodeGroup",
[](ElementGroup & self) -> decltype(auto) {
return self.getNodeGroup();
},
py::return_value_policy::reference)
.def("getName", &ElementGroup::getName)
.def(
"getElements",
[](ElementGroup & self) -> decltype(auto) {
return self.getElements();
},
py::return_value_policy::reference)
.def(
"getNodeGroup",
[](ElementGroup & self) -> decltype(auto) {
return self.getNodeGroup();
},
py::return_value_policy::reference)
.def("__len__", [](const ElementGroup & self) { return self.size(); })
.def("clear", [](ElementGroup & self) { self.clear(); })
.def("empty", &ElementGroup::empty)
.def("append", &ElementGroup::append)
.def("optimize", &ElementGroup::optimize)
.def(
"add",
[](ElementGroup & self, const Element & element, bool add_nodes,
bool check_for_duplicate) {
self.add(element, add_nodes, check_for_duplicate);
},
py::arg("element"), py::arg("add_nodes") = false,
py::arg("check_for_duplicate") = true)
.def("fillFromNodeGroup", &ElementGroup::fillFromNodeGroup)
.def("addDimension", &ElementGroup::addDimension);
/* ------------------------------------------------------------------------ */
py::class_(mod, "GroupManager")
.def(
"getElementGroup",
[](GroupManager & self, const std::string & name) -> decltype(auto) {
return self.getElementGroup(name);
},
py::return_value_policy::reference)
.def("iterateElementGroups",
[](GroupManager & self) -> decltype(auto) {
std::vector> groups;
for (auto & group : self.iterateElementGroups()) {
groups.emplace_back(group);
}
return groups;
})
.def("iterateNodeGroups",
[](GroupManager & self) -> decltype(auto) {
std::vector> groups;
for (auto & group : self.iterateNodeGroups()) {
groups.emplace_back(group);
}
return groups;
})
.def("createNodeGroup", &GroupManager::createNodeGroup,
py::return_value_policy::reference)
.def(
"createElementGroup",
[](GroupManager & self, const std::string & id, Int spatial_dimension,
bool replace_group) -> decltype(auto) {
return self.createElementGroup(id, spatial_dimension,
replace_group);
},
py::arg("id"), py::arg("spatial_dimension"),
py::arg("replace_group") = false, py::return_value_policy::reference)
.def("createGroupsFromMeshDataUInt",
&GroupManager::createGroupsFromMeshData)
.def("createElementGroupFromNodeGroup",
&GroupManager::createElementGroupFromNodeGroup, py::arg("name"),
py::arg("node_group"), py::arg("dimension") = _all_dimensions)
.def(
"getNodeGroup",
[](GroupManager & self, const std::string & name) -> decltype(auto) {
return self.getNodeGroup(name);
},
py::return_value_policy::reference)
.def(
"nodeGroups",
[](GroupManager & self) {
std::vector groups;
for (auto & g : self.iterateNodeGroups()) {
groups.push_back(&g);
}
return groups;
},
py::return_value_policy::reference)
.def(
"elementGroups",
[](GroupManager & self) {
std::vector groups;
for (auto & g : self.iterateElementGroups()) {
groups.push_back(&g);
}
return groups;
},
py::return_value_policy::reference)
.def("createBoundaryGroupFromGeometry",
&GroupManager::createBoundaryGroupFromGeometry);
}
} // namespace akantu