13#ifndef DUMUX_PYTHON_COMMON_FVSPATIALPARAMS_HH
14#define DUMUX_PYTHON_COMMON_FVSPATIALPARAMS_HH
18#include <dune/common/fvector.hh>
19#include <dune/common/exceptions.hh>
20#include <dune/python/pybind11/pybind11.h>
32template<
class Gr
idGeometry_>
37 using GridView =
typename GridGeometry::GridView;
38 using Scalar =
typename GridView::ctype;
39 using Element =
typename GridView::template Codim<0>::Entity;
43 static constexpr int dimWorld = GridView::dimensionworld;
49 pybind11::object pySpatialParameters)
51 , pySpatialParameters_(pySpatialParameters)
54 if (getParam<bool>(
"Problem.EnableGravity"))
60 , pySpatialParameters_{}
63 if (getParam<bool>(
"Problem.EnableGravity"))
76 template<
class ElementSolution>
79 const ElementSolution& elemSol)
const
81 if (pySpatialParameters_)
83 if (pybind11::hasattr(pySpatialParameters_,
"extrusionFactor"))
84 return pySpatialParameters_.attr(
"extrusionFactor")(element, scv, elemSol).
template cast<Scalar>();
85 else if (pybind11::hasattr(pySpatialParameters_,
"extrusionFactorAtPos"))
86 return pySpatialParameters_.attr(
"extrusionFactorAtPos")(scv.dofPosition()).
template cast<Scalar>();
96 template<
class ElementSolution>
99 const ElementSolution& elemSol)
const
101 if (pySpatialParameters_)
103 if (pybind11::hasattr(pySpatialParameters_,
"temperature"))
104 return pySpatialParameters_.attr(
"temperature")(element, scv, elemSol).
template cast<Scalar>();
105 else if (pybind11::hasattr(pySpatialParameters_,
"temperatureAtPos"))
106 return pySpatialParameters_.attr(
"temperatureAtPos")(scv.dofPosition()).
template cast<Scalar>();
128 {
return *gridGeometry_; }
131 std::shared_ptr<const GridGeometry> gridGeometry_;
132 pybind11::object pySpatialParameters_;
137template<
class SpatialParams,
class... options>
140 using pybind11::operator
""_a;
142 using GridGeometry =
typename SpatialParams::GridGeometry;
144 cls.def(pybind11::init([](std::shared_ptr<const GridGeometry> gridGeometry, pybind11::object p){
145 return std::make_shared<SpatialParams>(gridGeometry, p);
148 cls.def(
"extrusionFactor", &SpatialParams::template extrusionFactor<
decltype(std::ignore)>);
149 cls.def(
"temperature", &SpatialParams::template
temperature<
decltype(std::ignore)>);
150 cls.def(
"gravity", &SpatialParams::gravity);
151 cls.def_property_readonly(
"gridGeometry", &SpatialParams::gridGeometry);
The base class for spatial parameters used with finite-volume schemes.
Definition: python/common/fvspatialparams.hh:34
typename GridGeometry::SubControlVolume SubControlVolume
Definition: python/common/fvspatialparams.hh:40
Dune::FieldVector< Scalar, dimWorld > GravityVector
Definition: python/common/fvspatialparams.hh:46
static constexpr bool isBox
Definition: python/common/fvspatialparams.hh:42
const GridGeometry & gridGeometry() const
The finite volume grid geometry.
Definition: python/common/fvspatialparams.hh:127
typename Element::Geometry::GlobalCoordinate GlobalPosition
Definition: python/common/fvspatialparams.hh:45
typename GridView::template Codim< 0 >::Entity Element
Definition: python/common/fvspatialparams.hh:39
GridGeometry_ GridGeometry
Definition: python/common/fvspatialparams.hh:36
FVSpatialParams(std::shared_ptr< const GridGeometry > gridGeometry)
Definition: python/common/fvspatialparams.hh:58
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:77
typename GridView::ctype Scalar
Definition: python/common/fvspatialparams.hh:38
FVSpatialParams(std::shared_ptr< const GridGeometry > gridGeometry, pybind11::object pySpatialParameters)
Definition: python/common/fvspatialparams.hh:48
const GravityVector & gravity(const GlobalPosition &pos) const
Returns the acceleration due to gravity .
Definition: python/common/fvspatialparams.hh:123
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:97
typename GridGeometry::GridView GridView
Definition: python/common/fvspatialparams.hh:37
static constexpr int dimWorld
Definition: python/common/fvspatialparams.hh:43
The available discretization methods in Dumux.
constexpr Box box
Definition: method.hh:147
std::string temperature() noexcept
I/O name of temperature for equilibrium models.
Definition: name.hh:39
Definition: python/assembly/fvassembler.hh:18
void registerFVSpatialParams(pybind11::handle scope, pybind11::class_< SpatialParams, options... > cls)
Definition: python/common/fvspatialparams.hh:138
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.