1#ifndef DUMUX_PYTHON_MATERIAL_COMPONENT_HH
2#define DUMUX_PYTHON_MATERIAL_COMPONENT_HH
4#include <dune/python/pybind11/pybind11.h>
5#include <dune/python/pybind11/stl.h>
32struct Name {
template<
class C>
auto operator()(C&& c) ->
decltype(C::template name<DisableStaticAssert>()) {} };
33struct MolarMass {
template<
class C>
auto operator()(C&& c) ->
decltype(C::template molarMass<DisableStaticAssert>()) {} };
34struct VaporPressure {
template<
class C>
auto operator()(C&& c) ->
decltype(C::template vaporPressure<DisableStaticAssert>(0.0)) {} };
37struct LiquidDensity {
template<
class C>
auto operator()(C&& c) ->
decltype(C::template liquidDensity<DisableStaticAssert>(0.0, 0.0)) {} };
38struct LiquidMolarDensity {
template<
class C>
auto operator()(C&& c) ->
decltype(C::template liquidMolarDensity<DisableStaticAssert>(0.0, 0.0)) {} };
39struct LiquidViscosity {
template<
class C>
auto operator()(C&& c) ->
decltype(C::template liquidViscosity<DisableStaticAssert>(0.0, 0.0)) {} };
40struct LiquidEnthalpy {
template<
class C>
auto operator()(C&& c) ->
decltype(C::template liquidEnthalpy<DisableStaticAssert>(0.0, 0.0)) {} };
42struct LiquidHeatCapacity {
template<
class C>
auto operator()(C&& c) ->
decltype(C::template liquidHeatCapacity<DisableStaticAssert>(0.0, 0.0)) {} };
45struct GasIsIdeal {
template<
class C>
auto operator()(C&& c) ->
decltype(C::template gasIsIdeal<DisableStaticAssert>()) {} };
47struct GasDensity {
template<
class C>
auto operator()(C&& c) ->
decltype(C::template gasDensity<DisableStaticAssert>(0.0, 0.0)) {} };
48struct GasMolarDensity {
template<
class C>
auto operator()(C&& c) ->
decltype(C::template gasMolarDensity<DisableStaticAssert>(0.0, 0.0)) {} };
49struct GasViscosity {
template<
class C>
auto operator()(C&& c) ->
decltype(C::template gasViscosity<DisableStaticAssert>(0.0, 0.0)) {} };
50struct GasEnthalpy {
template<
class C>
auto operator()(C&& c) ->
decltype(C::template gasEnthalpy<DisableStaticAssert>(0.0, 0.0)) {} };
51struct GasInternalEnergy {
template<
class C>
auto operator()(C&& c) ->
decltype(C::template gasInternalEnergy<DisableStaticAssert>(0.0, 0.0)) {} };
52struct GasHeatCapacity {
template<
class C>
auto operator()(C&& c) ->
decltype(C::template gasHeatCapacity<DisableStaticAssert>(0.0, 0.0)) {} };
56struct SolidDensity {
template<
class C>
auto operator()(C&& c) ->
decltype(C::template solidDensity<DisableStaticAssert>(0.0)) {} };
60struct Charge {
template<
class C>
auto operator()(C&& c) ->
decltype(C::template charge<DisableStaticAssert>()) {} };
69template <
class Comp,
class... options>
71 pybind11::class_<Comp, options...> cls)
73 using pybind11::operator
""_a;
75 cls.def(pybind11::init());
78 constexpr auto implements = [](
const auto& c)
80 return !
decltype(
isValid(c)(std::declval<Comp>()))::value;
84 cls.def_property_readonly_static(
"name", &Comp::name);
86 cls.def_property_readonly_static(
"molarMass", &Comp::molarMass);
91 cls.def_property_readonly_static(
"liquidIsCompressible", &Comp::liquidIsCompressible);
93 cls.def_static(
"liquidDensity", &Comp::liquidDensity,
"temperature"_a,
"pressure"_a);
95 cls.def_static(
"liquidMolarDensity", &Comp::liquidMolarDensity,
"temperature"_a,
"pressure"_a);
97 cls.def_static(
"liquidViscosity", &Comp::liquidViscosity,
"temperature"_a,
"pressure"_a);
99 cls.def_static(
"liquidEnthalpy", &Comp::liquidEnthalpy,
"temperature"_a,
"pressure"_a);
101 cls.def_static(
"liquidInternalEnergy", &Comp::liquidInternalEnergy,
"temperature"_a,
"pressure"_a);
103 cls.def_static(
"liquidHeatCapacity", &Comp::liquidHeatCapacity,
"temperature"_a,
"pressure"_a);
105 cls.def_static(
"liquidThermalConductivity", &Comp::liquidThermalConductivity,
"temperature"_a,
"pressure"_a);
107 cls.def_static(
"vaporPressure", &Comp::vaporPressure,
"temperature"_a);
113 cls.def_static(
"gasDensity", &Comp::gasDensity,
"temperature"_a,
"pressure"_a);
115 cls.def_static(
"gasMolarDensity", &Comp::gasMolarDensity,
"temperature"_a,
"pressure"_a);
117 cls.def_property_readonly_static(
"gasIsCompressible", &Comp::gasIsCompressible);
119 cls.def_property_readonly_static(
"gasIsIdeal", &Comp::gasIsIdeal);
121 cls.def_static(
"gasViscosity", &Comp::gasViscosity,
"temperature"_a,
"pressure"_a);
123 cls.def_static(
"gasEnthalpy", &Comp::gasEnthalpy,
"temperature"_a,
"pressure"_a);
125 cls.def_static(
"gasInternalEnergy", &Comp::gasInternalEnergy,
"temperature"_a,
"pressure"_a);
127 cls.def_static(
"gasHeatCapacity", &Comp::gasHeatCapacity,
"temperature"_a,
"pressure"_a);
129 cls.def_static(
"gasThermalConductivity", &Comp::gasThermalConductivity,
"temperature"_a,
"pressure"_a);
135 cls.def_property_readonly_static(
"solidIsCompressible", &Comp::solidIsCompressible);
137 cls.def_property_readonly_static(
"solidDensity", &Comp::solidDensity,
"temperature_a");
139 cls.def_static(
"solidThermalConductivity", &Comp::solidThermalConductivity,
"temperature_a");
141 cls.def_static(
"solidHeatCapacity", &Comp::solidHeatCapacity,
"temperature_a");
147 cls.def_property_readonly_static(
"charge", &Comp::charge);
153 cls.def_property_readonly_static(
"criticalTemperature", &Comp::criticalTemperature);
155 cls.def_property_readonly_static(
"criticalPressure", &Comp::criticalPressure);
A helper function for class member function introspection.
Component traits, i.e. information extracted from components.
constexpr auto isValid(const Expression &t)
A function that creates a test functor to do class member introspection at compile time.
Definition: isvalid.hh:93
Definition: python/assembly/fvassembler.hh:30
void registerComponent(pybind11::handle scope, pybind11::class_< Comp, options... > cls)
Definition: component.hh:70
Definition: component.hh:12
Template which always yields a false value.
Definition: typetraits.hh:35
Component traits, i.e. information extracted from components.
Definition: componenttraits.hh:43
Helper struct to deactivate static assertions in component's base classes.
Definition: component.hh:14
Definition: component.hh:32
auto operator()(C &&c) -> decltype(C::template name< DisableStaticAssert >())
Definition: component.hh:32
Definition: component.hh:33
auto operator()(C &&c) -> decltype(C::template molarMass< DisableStaticAssert >())
Definition: component.hh:33
Definition: component.hh:34
auto operator()(C &&c) -> decltype(C::template vaporPressure< DisableStaticAssert >(0.0))
Definition: component.hh:34
Definition: component.hh:36
auto operator()(C &&c) -> decltype(C::template liquidIsCompressible< DisableStaticAssert >())
Definition: component.hh:36
Definition: component.hh:37
auto operator()(C &&c) -> decltype(C::template liquidDensity< DisableStaticAssert >(0.0, 0.0))
Definition: component.hh:37
Definition: component.hh:38
auto operator()(C &&c) -> decltype(C::template liquidMolarDensity< DisableStaticAssert >(0.0, 0.0))
Definition: component.hh:38
Definition: component.hh:39
auto operator()(C &&c) -> decltype(C::template liquidViscosity< DisableStaticAssert >(0.0, 0.0))
Definition: component.hh:39
Definition: component.hh:40
auto operator()(C &&c) -> decltype(C::template liquidEnthalpy< DisableStaticAssert >(0.0, 0.0))
Definition: component.hh:40
Definition: component.hh:41
auto operator()(C &&c) -> decltype(C::template liquidInternalEnergy< DisableStaticAssert >(0.0, 0.0))
Definition: component.hh:41
Definition: component.hh:42
auto operator()(C &&c) -> decltype(C::template liquidHeatCapacity< DisableStaticAssert >(0.0, 0.0))
Definition: component.hh:42
Definition: component.hh:43
auto operator()(C &&c) -> decltype(C::template liquidThermalConductivity< DisableStaticAssert >(0.0, 0.0))
Definition: component.hh:43
Definition: component.hh:45
auto operator()(C &&c) -> decltype(C::template gasIsIdeal< DisableStaticAssert >())
Definition: component.hh:45
Definition: component.hh:46
auto operator()(C &&c) -> decltype(C::template gasIsCompressible< DisableStaticAssert >())
Definition: component.hh:46
Definition: component.hh:47
auto operator()(C &&c) -> decltype(C::template gasDensity< DisableStaticAssert >(0.0, 0.0))
Definition: component.hh:47
Definition: component.hh:48
auto operator()(C &&c) -> decltype(C::template gasMolarDensity< DisableStaticAssert >(0.0, 0.0))
Definition: component.hh:48
Definition: component.hh:49
auto operator()(C &&c) -> decltype(C::template gasViscosity< DisableStaticAssert >(0.0, 0.0))
Definition: component.hh:49
Definition: component.hh:50
auto operator()(C &&c) -> decltype(C::template gasEnthalpy< DisableStaticAssert >(0.0, 0.0))
Definition: component.hh:50
Definition: component.hh:51
auto operator()(C &&c) -> decltype(C::template gasInternalEnergy< DisableStaticAssert >(0.0, 0.0))
Definition: component.hh:51
Definition: component.hh:52
auto operator()(C &&c) -> decltype(C::template gasHeatCapacity< DisableStaticAssert >(0.0, 0.0))
Definition: component.hh:52
Definition: component.hh:53
auto operator()(C &&c) -> decltype(C::template gasThermalConductivity< DisableStaticAssert >(0.0, 0.0))
Definition: component.hh:53
Definition: component.hh:55
auto operator()(C &&c) -> decltype(C::template solidIsCompressible< DisableStaticAssert >())
Definition: component.hh:55
Definition: component.hh:56
auto operator()(C &&c) -> decltype(C::template solidDensity< DisableStaticAssert >(0.0))
Definition: component.hh:56
Definition: component.hh:57
auto operator()(C &&c) -> decltype(C::template solidThermalConductivity< DisableStaticAssert >(0.0))
Definition: component.hh:57
Definition: component.hh:58
auto operator()(C &&c) -> decltype(C::template solidHeatCapacity< DisableStaticAssert >(0.0))
Definition: component.hh:58
Definition: component.hh:60
auto operator()(C &&c) -> decltype(C::template charge< DisableStaticAssert >())
Definition: component.hh:60
Definition: component.hh:61
auto operator()(C &&c) -> decltype(C::template criticalTemperature< DisableStaticAssert >())
Definition: component.hh:61
Definition: component.hh:62
auto operator()(C &&c) -> decltype(C::template criticalPressure< DisableStaticAssert >())
Definition: component.hh:62