25#ifndef DUMUX_PYTHON_COMMON_FVSPATIALPARAMS_HH
26#define DUMUX_PYTHON_COMMON_FVSPATIALPARAMS_HH
30#include <dune/common/fvector.hh>
31#include <dune/common/exceptions.hh>
33#include <dune/python/pybind11/pybind11.h>
42template<
class Gr
idGeometry_>
47 using GridView =
typename GridGeometry::GridView;
48 using Scalar =
typename GridView::ctype;
49 using Element =
typename GridView::template Codim<0>::Entity;
53 static constexpr int dimWorld = GridView::dimensionworld;
59 pybind11::object pySpatialParameters)
61 , pySpatialParameters_(pySpatialParameters)
64 if (getParam<bool>(
"Problem.EnableGravity"))
70 , pySpatialParameters_{}
73 if (getParam<bool>(
"Problem.EnableGravity"))
86 template<
class ElementSolution>
89 const ElementSolution& elemSol)
const
91 if (pySpatialParameters_)
93 if (pybind11::hasattr(pySpatialParameters_,
"extrusionFactor"))
94 return pySpatialParameters_.attr(
"extrusionFactor")(element, scv, elemSol).
template cast<Scalar>();
95 else if (pybind11::hasattr(pySpatialParameters_,
"extrusionFactorAtPos"))
96 return pySpatialParameters_.attr(
"extrusionFactorAtPos")(scv.dofPosition()).
template cast<Scalar>();
106 template<
class ElementSolution>
109 const ElementSolution& elemSol)
const
111 if (pySpatialParameters_)
113 if (pybind11::hasattr(pySpatialParameters_,
"temperature"))
114 return pySpatialParameters_.attr(
"temperature")(element, scv, elemSol).
template cast<Scalar>();
115 else if (pybind11::hasattr(pySpatialParameters_,
"temperatureAtPos"))
116 return pySpatialParameters_.attr(
"temperatureAtPos")(scv.dofPosition()).
template cast<Scalar>();
138 {
return *gridGeometry_; }
141 std::shared_ptr<const GridGeometry> gridGeometry_;
142 pybind11::object pySpatialParameters_;
147template<
class SpatialParams,
class... options>
150 using pybind11::operator
""_a;
152 using GridGeometry =
typename SpatialParams::GridGeometry;
154 cls.def(pybind11::init([](std::shared_ptr<const GridGeometry> gridGeometry, pybind11::object p){
155 return std::make_shared<SpatialParams>(gridGeometry, p);
158 cls.def(
"extrusionFactor", &SpatialParams::template extrusionFactor<
decltype(std::ignore)>);
159 cls.def(
"temperature", &SpatialParams::template
temperature<
decltype(std::ignore)>);
160 cls.def(
"gravity", &SpatialParams::gravity);
161 cls.def_property_readonly(
"gridGeometry", &SpatialParams::gridGeometry);
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
constexpr Box box
Definition: method.hh:139
std::string temperature() noexcept
I/O name of temperature for equilibrium models.
Definition: name.hh:51
Definition: python/assembly/fvassembler.hh:30
void registerFVSpatialParams(pybind11::handle scope, pybind11::class_< SpatialParams, options... > cls)
Definition: python/common/fvspatialparams.hh:148
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
Dune::FieldVector< Scalar, dimWorld > GravityVector
Definition: python/common/fvspatialparams.hh:56
static constexpr bool isBox
Definition: python/common/fvspatialparams.hh:52
const GridGeometry & gridGeometry() const
The finite volume grid geometry.
Definition: python/common/fvspatialparams.hh:137
typename Element::Geometry::GlobalCoordinate GlobalPosition
Definition: python/common/fvspatialparams.hh:55
typename GridView::template Codim< 0 >::Entity Element
Definition: python/common/fvspatialparams.hh:49
GridGeometry_ GridGeometry
Definition: python/common/fvspatialparams.hh:46
FVSpatialParams(std::shared_ptr< const GridGeometry > gridGeometry)
Definition: python/common/fvspatialparams.hh:68
Scalar extrusionFactor(const Element &element, const SubControlVolume &scv, const ElementSolution &elemSol) const
Return how much the domain is extruded at a given sub-control volume.
Definition: python/common/fvspatialparams.hh:87
typename GridView::ctype Scalar
Definition: python/common/fvspatialparams.hh:48
FVSpatialParams(std::shared_ptr< const GridGeometry > gridGeometry, pybind11::object pySpatialParameters)
Definition: python/common/fvspatialparams.hh:58
const GravityVector & gravity(const GlobalPosition &pos) const
Returns the acceleration due to gravity .
Definition: python/common/fvspatialparams.hh:133
Scalar temperature(const Element &element, const SubControlVolume &scv, const ElementSolution &elemSol) const
Return the temperature in the given sub-control volume.
Definition: python/common/fvspatialparams.hh:107
typename GridGeometry::GridView GridView
Definition: python/common/fvspatialparams.hh:47
static constexpr int dimWorld
Definition: python/common/fvspatialparams.hh:53