Page MenuHomec4science

materials.cpp
No OneTemporary

File Metadata

Created
Tue, Apr 30, 14:29

materials.cpp

/*
* SPDX-License-Indentifier: AGPL-3.0-or-later
*
* Copyright (©) 2016-2023 EPFL (École Polytechnique Fédérale de Lausanne),
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
* Copyright (©) 2020-2023 Lucas Frérot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "materials/isotropic_hardening.hh"
#include "materials/material.hh"
#include "wrap.hh"
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
namespace tamaas {
namespace wrap {
using namespace py::literals;
class PyMaterial : public Material {
using Field = typename Material::Field;
public:
using Material::Material;
void computeStress(Field& stress, const Field& strain,
const Field& strain_increment) override {
// NOLINTNEXTLINE(readability-else-after-return)
PYBIND11_OVERLOAD_PURE(void, Material, computeStress, stress, strain,
strain_increment);
}
void computeEigenStress(Field& stress, const Field& strain,
const Field& strain_increment) override {
// NOLINTNEXTLINE(readability-else-after-return)
PYBIND11_OVERLOAD_PURE(void, Material, computeEigenStress, stress, strain,
strain_increment);
}
void update() override {
// NOLINTNEXTLINE(readability-else-after-return)
PYBIND11_OVERRIDE_PURE(void, Material, update);
}
};
void wrapMaterialInterface(py::module& mod) {
py::class_<Material, PyMaterial, std::shared_ptr<Material>>(mod, "Material")
.def(py::init<Model*>(), py::keep_alive<1, 2>())
.def("computeStress", &Material::computeStress)
.def("computeEigenStress", &Material::computeEigenStress);
}
void wrapIsotropicHardening(py::module& mod) {
py::class_<IsotropicHardening, Material, std::shared_ptr<IsotropicHardening>>(
mod, "IsotropicHardening")
.def(py::init<Model*, Real, Real>(), "model"_a, "sigma_y"_a,
"hardening"_a, py::keep_alive<1, 2>())
.def("computeInelasticDeformationIncrement",
&IsotropicHardening::computeInelasticDeformationIncrement);
}
void wrapMaterials(py::module& m) {
auto mod = m.def_submodule("materials");
wrapMaterialInterface(mod);
wrapIsotropicHardening(mod);
}
} // namespace wrap
} // namespace tamaas

Event Timeline