diff --git a/python/py_integration_scheme.cc b/python/py_integration_scheme.cc index 1f441ee2e..9485d3bb6 100644 --- a/python/py_integration_scheme.cc +++ b/python/py_integration_scheme.cc @@ -1,64 +1,63 @@ /** * Copyright (©) 2022 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_integration_scheme.hh" /* -------------------------------------------------------------------------- */ +#include #include #include #include -#include /* -------------------------------------------------------------------------- */ #include /* -------------------------------------------------------------------------- */ namespace py = pybind11; namespace akantu { /* -------------------------------------------------------------------------- */ void register_integration_schemes(py::module & mod) { - auto IntegrationSchemeBinding = py::class_(mod, "IntegrationScheme") - //.def(py::init()) - ; + auto integration_scheme_class = + py::class_(mod, "IntegrationScheme"); - py::enum_(IntegrationSchemeBinding, "SolutionType") + py::enum_(integration_scheme_class, + "SolutionType") .value("_not_defined", IntegrationScheme::SolutionType::_not_defined) .value("_displacement", IntegrationScheme::SolutionType::_displacement) .value("_temperature", IntegrationScheme::SolutionType::_temperature) .value("_damage", IntegrationScheme::SolutionType::_damage) .value("_velocity", IntegrationScheme::SolutionType::_velocity) - .value("_temperature_rate", IntegrationScheme::SolutionType::_temperature_rate) + .value("_temperature_rate", + IntegrationScheme::SolutionType::_temperature_rate) .value("_acceleration", IntegrationScheme::SolutionType::_acceleration) .export_values(); py::class_( - mod, "IntegrationScheme2ndOrder") - //.def(py::init()) - ; + mod, "IntegrationScheme2ndOrder"); py::class_(mod, "NewmarkBeta") - .def(py::init(), + .def(py::init(), py::arg("dof_manager"), py::arg("id"), py::arg("alpha"), py::arg("beta")); py::class_(mod, "CentralDifference"); py::class_(mod, "TrapezoidalRule2"); py::class_(mod, "FoxGoodwin"); py::class_(mod, "LinearAceleration"); } } // namespace akantu diff --git a/python/py_model.cc b/python/py_model.cc index 4328a40c0..4f0a9312c 100644 --- a/python/py_model.cc +++ b/python/py_model.cc @@ -1,145 +1,149 @@ /** * @file py_model.cc * * @author Guillaume Anciaux * @author Emil Gallyamov * @author Philip Mueller * @author Mohit Pundir * @author Nicolas Richart * * @date creation: Sun Jun 16 2019 * @date last modification: Sat Mar 13 2021 * * @brief pybind11 interface to Model and parent classes * * * @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 #include #include /* -------------------------------------------------------------------------- */ #include #include #include /* -------------------------------------------------------------------------- */ namespace py = pybind11; /* -------------------------------------------------------------------------- */ namespace akantu { /* -------------------------------------------------------------------------- */ void register_model(py::module & mod) { py::class_(mod, "ModelSolver", py::multiple_inheritance()) .def( "getNonLinearSolver", [](ModelSolver & self, const ID & solver_id) -> NonLinearSolver & { return self.getNonLinearSolver(solver_id); }, py::arg("solver_id") = "", py::return_value_policy::reference) .def( "getTimeStepSolver", [](ModelSolver & self, const ID & solver_id) -> TimeStepSolver & { return self.getTimeStepSolver(solver_id); }, py::arg("solver_id") = "", py::return_value_policy::reference) .def( "solveStep", [](ModelSolver & self, const ID & solver_id) { self.solveStep(solver_id); }, py::arg("solver_id") = "") .def( "solveStep", [](ModelSolver & self, SolverCallback & callback, const ID & solver_id) { self.solveStep(callback, solver_id); }, py::arg("callback"), py::arg("solver_id") = ""); py::class_(mod, "Model", py::multiple_inheritance()) .def("setBaseName", &Model::setBaseName) .def("setDirectory", &Model::setDirectory) .def("getFEEngine", &Model::getFEEngine, py::arg("name") = "", py::return_value_policy::reference) .def("getFEEngineBoundary", &Model::getFEEngine, py::arg("name") = "", py::return_value_policy::reference) .def("addDumpFieldVector", &Model::addDumpFieldVector) .def("addDumpField", &Model::addDumpField) .def("setBaseNameToDumper", &Model::setBaseNameToDumper) .def("addDumpFieldVectorToDumper", &Model::addDumpFieldVectorToDumper) .def("addDumpFieldToDumper", &Model::addDumpFieldToDumper) .def("dump", [](Model & self) { self.dump(); }) .def( "dump", [](Model & self, UInt step) { self.dump(step); }, py::arg("step")) .def( "dump", [](Model & self, Real time, UInt step) { self.dump(time, step); }, py::arg("time"), py::arg("step")) .def( "dump", [](Model & self, const std::string & dumper) { self.dump(dumper); }, py::arg("dumper_name")) .def( "dump", [](Model & self, const std::string & dumper, UInt step) { self.dump(dumper, step); }, py::arg("dumper_name"), py::arg("step")) .def( "dump", [](Model & self, const std::string & dumper, Real time, UInt step) { self.dump(dumper, time, step); }, py::arg("dumper_name"), py::arg("time"), py::arg("step")) .def("initNewSolver", &Model::initNewSolver) .def( "getNewSolver", [](Model & self, const std::string id, const TimeStepSolverType & time, const NonLinearSolverType & type) { self.getNewSolver(id, time, type); }, py::return_value_policy::reference) - .def("setIntegrationScheme", - [](Model & self, const std::string id, const std::string primal, - const IntegrationSchemeType & scheme_type, - IntegrationScheme::SolutionType solution_type) { - self.setIntegrationScheme(id, primal, scheme_type, solution_type); - }) + .def( + "setIntegrationScheme", + [](Model & self, const std::string id, const std::string primal, + const IntegrationSchemeType & scheme_type, + IntegrationScheme::SolutionType solution_type) { + self.setIntegrationScheme(id, primal, scheme_type, solution_type); + }, + py::arg("id"), py::arg("primal"), py::arg("scheme_type"), + py::arg("solution_type") = + IntegrationScheme::SolutionType::_not_defined) // .def("setIntegrationScheme", // [](Model & self, const std::string id, const std::string primal, // std::unique_ptr & scheme, // IntegrationScheme::SolutionType solution_type) { // self.setIntegrationScheme(id, primal, scheme, solution_type); // }) .def("getDOFManager", &Model::getDOFManager, py::return_value_policy::reference) .def("assembleMatrix", &Model::assembleMatrix); } } // namespace akantu