diff --git a/python/wrap/test_features.cpp b/python/wrap/test_features.cpp
index 93e3999..723ea1c 100644
--- a/python/wrap/test_features.cpp
+++ b/python/wrap/test_features.cpp
@@ -1,95 +1,49 @@
/*
* 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 .
*
*/
/* -------------------------------------------------------------------------- */
#include "boussinesq.hh"
#include "kelvin.hh"
#include "materials/isotropic_hardening.hh"
#include "mindlin.hh"
#include "model.hh"
#include "model_type.hh"
#include "volume_potential.hh"
#include "wrap.hh"
/* -------------------------------------------------------------------------- */
namespace tamaas {
namespace wrap {
using namespace py::literals;
-template class KOp, model_type type,
- UInt tensor_order>
-void wrapKOp(const std::string& basename, py::module& mod) {
- constexpr UInt dim = model_type_traits::dimension;
- std::stringstream str;
- str << basename << tensor_order;
- py::class_>(mod, str.str().c_str())
- .def(py::init())
- .def("apply",
- [](const KOp& engine, Grid& in,
- Grid& out) { engine.apply(in, out); });
-}
-
-template
-void wrapIsotropicHardening(py::module& mod) {
- constexpr UInt dim = model_type_traits::dimension;
- py::class_(mod, "IsotropicHardening")
- .def(py::init())
- .def_property("h", &IsotropicHardening::getHardeningModulus,
- &IsotropicHardening::setHardeningModulus)
- .def_property("sigma_0", &IsotropicHardening::getYieldStress,
- &IsotropicHardening::setYieldStress)
- .def("computeStress",
- [](IsotropicHardening& iso, Grid& stress,
- const Grid& strain,
- const Grid& strain_increment) {
- iso.computeStress(stress, strain, strain_increment);
- })
- .def("computeInelasticDeformationIncrement",
- [](IsotropicHardening& iso, Grid& stress,
- const Grid& strain,
- const Grid& strain_increment) {
- iso.computeInelasticDeformationIncrement(stress, strain,
- strain_increment);
- });
-}
-
/// Wrap temporary features for testing
void wrapTestFeatures(py::module& mod) {
auto test_module = mod.def_submodule("_test_features");
test_module.doc() =
"Module for testing new features.\n"
"DISCLAIMER: this API is subject to frequent and unannounced changes "
"and should **not** be relied upon!";
- // wrapKOp("Kelvin_", test_module);
- // wrapKOp("Kelvin_", test_module);
- // wrapKOp("Kelvin_", test_module);
- // wrapKOp("Mindlin_", test_module);
- // wrapKOp("Mindlin_", test_module);
- // wrapKOp("Boussinesq_", test_module);
- // wrapKOp("Boussinesq_", test_module);
-
- // wrapIsotropicHardening(test_module);
}
} // namespace wrap
} // namespace tamaas
diff --git a/src/model/materials/isotropic_hardening.hh b/src/model/materials/isotropic_hardening.hh
index abe127e..57a4f8d 100644
--- a/src/model/materials/isotropic_hardening.hh
+++ b/src/model/materials/isotropic_hardening.hh
@@ -1,98 +1,98 @@
/*
* 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 .
*
*/
/* -------------------------------------------------------------------------- */
#ifndef ISOTROPIC_HARDENING_HH
#define ISOTROPIC_HARDENING_HH
/* -------------------------------------------------------------------------- */
#include "grid.hh"
#include "influence.hh"
#include "internal.hh"
#include "material.hh"
#include "model.hh"
#include "model_type.hh"
#include "static_types.hh"
/* -------------------------------------------------------------------------- */
namespace tamaas {
/* -------------------------------------------------------------------------- */
class IsotropicHardening : public Material {
using parent = Material;
static constexpr auto type = model_type::volume_2d;
using trait = model_type_traits;
static constexpr UInt dim = trait::dimension;
using Field = typename parent::Field;
using Mat = SymMatrixProxy;
using CMat = SymMatrixProxy;
public:
/// Constructor
IsotropicHardening(Model* model, Real sigma_0, Real h);
/// Compute plastic strain increment with radial return algorithm
void
computeInelasticDeformationIncrement(Field& increment, const Field& strain,
- const Field& strain_increment) override;
+ const Field& strain_increment);
/// Compute stress
void computeStress(Field& stress, const Field& strain,
const Field& strain_increment) override;
/// Compute stress due to plastic strain increment
void computeEigenStress(Field& stress, const Field& strain,
const Field& strain_increment) override;
/// Update internal variables
void update() override;
void applyTangentIncrement(Field& output, const Field& input,
const Field& strain,
const Field& strain_increment) const;
/// Linear hardening function
static __device__ __host__ Real hardening(Real p, Real h, Real sigma_0) {
return sigma_0 + h * p;
}
Real getHardeningModulus() const { return h; }
Real getYieldStress() const { return sigma_0; }
const GridBase& getPlasticStrain() const { return *plastic_strain; }
GridBase& getPlasticStrain() { return *plastic_strain; }
void setHardeningModulus(Real h_) {
if (h_ < 0)
TAMAAS_EXCEPTION("Hardening modulus should be positive");
h = h_;
}
void setYieldStress(Real sigma_0_) {
if (sigma_0_ < 0)
TAMAAS_EXCEPTION("Yield stress should be positive");
sigma_0 = sigma_0_;
}
protected:
Real sigma_0; /// < initial yield stress
Real h; /// < hardening modulus
Internal plastic_strain, cumulated_plastic_strain;
};
} // namespace tamaas
/* -------------------------------------------------------------------------- */
#endif // ISOTROPIC_HARDENING_HH
diff --git a/src/model/materials/material.hh b/src/model/materials/material.hh
index 1727b15..8566f06 100644
--- a/src/model/materials/material.hh
+++ b/src/model/materials/material.hh
@@ -1,67 +1,61 @@
/*
* 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 .
*
*/
/* -------------------------------------------------------------------------- */
#ifndef MATERIAL_HH
#define MATERIAL_HH
/* -------------------------------------------------------------------------- */
#include "grid.hh"
#include "model.hh"
#include "model_type.hh"
/* -------------------------------------------------------------------------- */
namespace tamaas {
class Material {
// Defining some helper types
protected:
using Field = GridBase;
public:
/// Constructor
Material(Model* model) : model(model) {}
/// Destructor
virtual ~Material() = default;
// Material Interface
public:
- /// Compute the increment of inelastic deformation from the total strain and
- /// total strain increment
- virtual void
- computeInelasticDeformationIncrement(Field& increment, const Field& strain,
- const Field& strain_increment) = 0;
-
/// Compute the stress from total strain and strain increment
virtual void computeStress(Field& stress, const Field& strain,
const Field& strain_increment) = 0;
/// Compute stress due to inelastic increment
virtual void computeEigenStress(Field& stress, const Field& strain,
const Field& strain_increment) = 0;
/// Update internal variables
virtual void update() = 0;
protected:
Model* model;
};
} // namespace tamaas
#endif // MATERIAL_HH
diff --git a/src/model/materials/mfront_material.hh b/src/model/materials/mfront_material.hh
index de778bd..cd4fa70 100644
--- a/src/model/materials/mfront_material.hh
+++ b/src/model/materials/mfront_material.hh
@@ -1,45 +1,45 @@
/*
* 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 .
*
*/
/* -------------------------------------------------------------------------- */
#ifndef MFRONT_MATERIAL_HH
#define MFRONT_MATERIAL_HH
/* -------------------------------------------------------------------------- */
#include "material.hh"
#include "model_type.hh"
/* -------------------------------------------------------------------------- */
namespace tamaas {
/* -------------------------------------------------------------------------- */
-class MFrontMaterial : Material {
+class MFrontMaterial : public Material {
using parent = Material;
static constexpr auto type = model_type::volume_2d;
using trait = model_type_traits;
static constexpr UInt dim = trait::dimension;
using Field = typename parent::Field;
public:
/// Constructor
MFrontMaterial(Model* model, std::string material);
};
} // namespace tamaas
/* -------------------------------------------------------------------------- */
#endif // MFRONT_MATERIAL_HH