|
| 1 | +/****************************************************************************** |
| 2 | + * SofaPython3 plugin * |
| 3 | + * (c) 2021 CNRS, University of Lille, INRIA * |
| 4 | + * * |
| 5 | + * This program is free software; you can redistribute it and/or modify it * |
| 6 | + * under the terms of the GNU Lesser General Public License as published by * |
| 7 | + * the Free Software Foundation; either version 2.1 of the License, or (at * |
| 8 | + * your option) any later version. * |
| 9 | + * * |
| 10 | + * This program is distributed in the hope that it will be useful, but WITHOUT * |
| 11 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * |
| 12 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * |
| 13 | + * for more details. * |
| 14 | + * * |
| 15 | + * You should have received a copy of the GNU Lesser General Public License * |
| 16 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. * |
| 17 | + ******************************************************************************* |
| 18 | + * Contact information: contact@sofa-framework.org * |
| 19 | + ******************************************************************************/ |
| 20 | + |
| 21 | +#include <pybind11/pybind11.h> |
| 22 | + |
| 23 | +#include <SofaPython3/SofaDeformable/Binding_LameParameters.h> |
| 24 | +#include <sofa/component/solidmechanics/fem/elastic/impl/LameParameters.h> |
| 25 | + |
| 26 | +namespace sofapython3 |
| 27 | +{ |
| 28 | + |
| 29 | +void moduleAddLameParameters(pybind11::module &m) |
| 30 | +{ |
| 31 | + using namespace sofa::component::solidmechanics::fem::elastic; |
| 32 | + |
| 33 | + m.def( |
| 34 | + "toLameParameters2D", |
| 35 | + [](SReal youngModulus, SReal poissonRatio) { |
| 36 | + LameLambda<SReal> lambda{0}; |
| 37 | + LameMu<SReal> mu{0}; |
| 38 | + toLameParameters<2>(YoungModulus<SReal>(youngModulus), |
| 39 | + PoissonRatio<SReal>(poissonRatio), lambda, mu); |
| 40 | + return std::make_pair(mu.get(), lambda.get()); |
| 41 | + }, |
| 42 | + pybind11::arg("youngModulus"), pybind11::arg("poissonRatio"), |
| 43 | + "Converts Young's modulus and Poisson's ratio to Lamé parameters (mu, " |
| 44 | + "lambda) for 2D."); |
| 45 | + |
| 46 | + m.def( |
| 47 | + "toLameParameters3D", |
| 48 | + [](SReal youngModulus, SReal poissonRatio) { |
| 49 | + LameLambda<SReal> lambda{0}; |
| 50 | + LameMu<SReal> mu{0}; |
| 51 | + toLameParameters<3>(YoungModulus<SReal>(youngModulus), |
| 52 | + PoissonRatio<SReal>(poissonRatio), lambda, mu); |
| 53 | + return std::make_pair(mu.get(), lambda.get()); |
| 54 | + }, |
| 55 | + pybind11::arg("youngModulus"), pybind11::arg("poissonRatio"), |
| 56 | + "Converts Young's modulus and Poisson's ratio to Lamé parameters (mu, " |
| 57 | + "lambda) for 3D."); |
| 58 | +} |
| 59 | + |
| 60 | +} // namespace sofapython3 |
0 commit comments