version 0.4.1
material.hh File Reference

Python bindings for materials. More...

#include <dune/common/classname.hh>
#include <dune/python/common/typeregistry.hh>
#include <dune/python/pybind11/eigen.h>
#include <dune/python/pybind11/pybind11.h>
#include <dune/python/pybind11/stl.h>
#include <ikarus/finiteelements/mechanics/materials.hh>
#include <ikarus/utils/concepts.hh>

Go to the source code of this file.

Namespaces

namespace  Ikarus
 
namespace  Ikarus::Python
 

Macros

#define MAKE_MaterialFunction(clsName, materialName, functionname, vecSize)
 
#define MAKE_MATERIAL_REGISTERY_FUNCTION(name, vecSize)
 

Functions

template<class Material , size_t vecSize, class... options>
void Ikarus::Python::registerMaterial (pybind11::handle scope, pybind11::class_< Material, options... > cls)
 
 Ikarus::Python::MAKE_MATERIAL_REGISTERY_FUNCTION (LinearElasticity, 6)
 
 Ikarus::Python::MAKE_MATERIAL_REGISTERY_FUNCTION (StVenantKirchhoff, 6)
 
 Ikarus::Python::MAKE_MATERIAL_REGISTERY_FUNCTION (NeoHooke, 6)
 

Macro Definition Documentation

◆ MAKE_MATERIAL_REGISTERY_FUNCTION

#define MAKE_MATERIAL_REGISTERY_FUNCTION (   name,
  vecSize 
)
Value:
template <class Material, class... options> \
void register##name(pybind11::handle scope, pybind11::class_<Material, options...> cls) { \
Ikarus::Python::registerMaterial<Material, vecSize>(scope, cls); \
}

◆ MAKE_MaterialFunction

#define MAKE_MaterialFunction (   clsName,
  materialName,
  functionname,
  vecSize 
)
Value:
clsName.def( \
#functionname, \
[](materialName& self, StrainTags straintag, Eigen::Ref<const Eigen::Vector<double, vecSize>> eVoigt_) { \
if constexpr (not Concepts::IsMaterial<LinearElasticityT, materialName>) { \
Eigen::Vector<double, vecSize> eVoigt = eVoigt_; \
if (straintag == StrainTags::rightCauchyGreenTensor) \
return self.template functionname<StrainTags::rightCauchyGreenTensor>(eVoigt); \
else if (straintag == StrainTags::greenLagrangian) \
return self.template functionname<StrainTags::greenLagrangian>(eVoigt); \
else if (straintag == StrainTags::linear) \
DUNE_THROW(Dune::MathError, "Passing linear strain to " + std::string(#materialName) + \
" does not makes sense use LinearElastic class"); \
else if (straintag == StrainTags::displacementGradient) \
DUNE_THROW(Dune::MathError, \
"Passing displacementGradient strain in 6d Voigt notation does not make any sense!"); \
else if (straintag == StrainTags::deformationGradient) \
DUNE_THROW(Dune::MathError, \
"Passing deformationGradient strain in 6d Voigt notation does not make any sense!"); \
else \
DUNE_THROW(Dune::MathError, toString(straintag) + "is not a valid strain tag."); \
} else { \
Eigen::Vector<double, vecSize> eVoigt = eVoigt_; /* Linear elastic path */ \
if (straintag == StrainTags::linear) \
return self.template functionname<StrainTags::linear>(eVoigt); \
else \
DUNE_THROW(Dune::MathError, "Linear elastic material only accepts linear strains!"); \
} \
__builtin_unreachable(); \
}, \
"StrainName"_a, "strainVector"_a);
StrainTags
A strongly typed enum class representing the type of the passed strain.
Definition: tags.hh:19
constexpr std::string toString(DBCOption _e)
Definition: dirichletbcenforcement.hh:7