24#ifndef DUMUX_PYTHON_POROUSMEDIUMFLOW_FVSPATIALPARAMS_1P_HH
25#define DUMUX_PYTHON_POROUSMEDIUMFLOW_FVSPATIALPARAMS_1P_HH
27#include <dune/python/pybind11/pybind11.h>
28#include <dune/python/pybind11/stl.h>
34template<
class Gr
idGeometry_,
class PT>
42 using Scalar =
typename GridGeometry::GridView::ctype;
43 using Element =
typename GridGeometry::GridView::template Codim<0>::Entity;
48 pybind11::object pySpatialParams)
50 , pySpatialParams_(pySpatialParams)
53 template<
class ElementSolution>
56 const ElementSolution& elemSol)
const
58 if (pybind11::hasattr(pySpatialParams_,
"permeability"))
59 return pySpatialParams_.attr(
"permeability")(element, scv, elemSol).
template cast<PermeabilityType>();
61 return pySpatialParams_.attr(
"permeabilityAtPos")(scv.center()).
template cast<PermeabilityType>();
64 template<
class ElementSolution>
67 const ElementSolution& elemSol)
const
69 if (pybind11::hasattr(pySpatialParams_,
"porosity"))
70 return pySpatialParams_.attr(
"porosity")(element, scv, elemSol).
template cast<Scalar>();
72 return pySpatialParams_.attr(
"porosityAtPos")(scv.center()).
template cast<Scalar>();
75 template<
class Sol
idSystem,
class ElementSolution>
78 const ElementSolution& elemSol,
82 if (pybind11::hasattr(pySpatialParams_,
"inertVolumeFraction"))
83 return pySpatialParams_.attr(
"inertVolumeFraction")(element, scv, elemSol, compIdx).
template cast<Scalar>();
84 else if (pybind11::hasattr(pySpatialParams_,
"inertVolumeFractionAtPos"))
85 return pySpatialParams_.attr(
"inertVolumeFractionAtPos")(scv.center(), compIdx).
template cast<Scalar>();
87 return 1.0 - this->
porosity(element, scv, elemSol);
94 pybind11::object pySpatialParams_;
97template <
class SpatialParams,
class... options>
100 using pybind11::operator
""_a;
101 using GridGeometry =
typename SpatialParams::GridGeometry;
103 cls.def(pybind11::init([](std::shared_ptr<const GridGeometry> gridGeometry, pybind11::object p){
104 return std::make_shared<SpatialParams>(gridGeometry, p);
107 cls.def(
"permeability", &SpatialParams::template
permeability<
decltype(std::ignore)>);
108 cls.def(
"porosity", &SpatialParams::template
porosity<
decltype(std::ignore)>);
109 cls.def(
"inertVolumeFraction", &SpatialParams::template inertVolumeFraction<
decltype(std::ignore),
decltype(std::ignore)>);
std::string permeability() noexcept
I/O name of permeability.
Definition: name.hh:143
std::string porosity() noexcept
I/O name of porosity.
Definition: name.hh:139
Definition: python/assembly/fvassembler.hh:30
void registerFVSpatialParamsOneP(pybind11::handle scope, pybind11::class_< SpatialParams, options... > cls)
Definition: python/porousmediumflow/spatialparams.hh:98
The base class for spatial parameters used with finite-volume schemes.
Definition: python/common/fvspatialparams.hh:44
typename GridGeometry::SubControlVolume SubControlVolume
Definition: python/common/fvspatialparams.hh:50
const GridGeometry & gridGeometry() const
The finite volume grid geometry.
Definition: python/common/fvspatialparams.hh:137
typename GridView::template Codim< 0 >::Entity Element
Definition: python/common/fvspatialparams.hh:49
GridGeometry_ GridGeometry
Definition: python/common/fvspatialparams.hh:46
typename GridView::ctype Scalar
Definition: python/common/fvspatialparams.hh:48
Definition: python/porousmediumflow/spatialparams.hh:37
static constexpr bool evaluatePermeabilityAtScvfIP()
Definition: python/porousmediumflow/spatialparams.hh:90
PermeabilityType permeability(const Element &element, const SubControlVolume &scv, const ElementSolution &elemSol) const
Definition: python/porousmediumflow/spatialparams.hh:54
Scalar inertVolumeFraction(const Element &element, const SubControlVolume &scv, const ElementSolution &elemSol, int compIdx) const
Definition: python/porousmediumflow/spatialparams.hh:76
FVSpatialParamsOneP(std::shared_ptr< const GridGeometry > gridGeometry, pybind11::object pySpatialParams)
Definition: python/porousmediumflow/spatialparams.hh:47
Scalar porosity(const Element &element, const SubControlVolume &scv, const ElementSolution &elemSol) const
Definition: python/porousmediumflow/spatialparams.hh:65
PT PermeabilityType
Definition: python/porousmediumflow/spatialparams.hh:45
Basic spatial parameters to be used with finite-volume schemes.