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>
32#include <dune/python/pybind11/pybind11.h>
44template<
class Gr
idGeometry_>
49 using GridView =
typename GridGeometry::GridView;
50 using Scalar =
typename GridView::ctype;
51 using Element =
typename GridView::template Codim<0>::Entity;
55 static constexpr int dimWorld = GridView::dimensionworld;
61 pybind11::object pySpatialParameters)
63 , pySpatialParameters_(pySpatialParameters)
66 if (getParam<bool>(
"Problem.EnableGravity"))
72 , pySpatialParameters_{}
75 if (getParam<bool>(
"Problem.EnableGravity"))
88 template<
class ElementSolution>
91 const ElementSolution& elemSol)
const
93 if (pySpatialParameters_)
95 if (pybind11::hasattr(pySpatialParameters_,
"extrusionFactor"))
96 return pySpatialParameters_.attr(
"extrusionFactor")(element, scv, elemSol).
template cast<Scalar>();
97 else if (pybind11::hasattr(pySpatialParameters_,
"extrusionFactorAtPos"))
98 return pySpatialParameters_.attr(
"extrusionFactorAtPos")(scv.dofPosition()).
template cast<Scalar>();
108 template<
class ElementSolution>
111 const ElementSolution& elemSol)
const
113 if (pySpatialParameters_)
115 if (pybind11::hasattr(pySpatialParameters_,
"temperature"))
116 return pySpatialParameters_.attr(
"temperature")(element, scv, elemSol).
template cast<Scalar>();
117 else if (pybind11::hasattr(pySpatialParameters_,
"temperatureAtPos"))
118 return pySpatialParameters_.attr(
"temperatureAtPos")(scv.dofPosition()).
template cast<Scalar>();
140 {
return *gridGeometry_; }
143 std::shared_ptr<const GridGeometry> gridGeometry_;
144 pybind11::object pySpatialParameters_;
149template<
class SpatialParams,
class... options>
152 using pybind11::operator
""_a;
154 using GridGeometry =
typename SpatialParams::GridGeometry;
156 cls.def(pybind11::init([](std::shared_ptr<const GridGeometry> gridGeometry, pybind11::object p){
157 return std::make_shared<SpatialParams>(gridGeometry, p);
160 cls.def(
"extrusionFactor", &SpatialParams::template extrusionFactor<
decltype(std::ignore)>);
161 cls.def(
"temperature", &SpatialParams::template
temperature<
decltype(std::ignore)>);
162 cls.def(
"gravity", &SpatialParams::gravity);
163 cls.def_property_readonly(
"gridGeometry", &SpatialParams::gridGeometry);
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
The available discretization methods in Dumux.
constexpr Box box
Definition: method.hh:136
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:150
The base class for spatial parameters used with finite-volume schemes.
Definition: python/common/fvspatialparams.hh:46
typename GridGeometry::SubControlVolume SubControlVolume
Definition: python/common/fvspatialparams.hh:52
Dune::FieldVector< Scalar, dimWorld > GravityVector
Definition: python/common/fvspatialparams.hh:58
static constexpr bool isBox
Definition: python/common/fvspatialparams.hh:54
const GridGeometry & gridGeometry() const
The finite volume grid geometry.
Definition: python/common/fvspatialparams.hh:139
typename Element::Geometry::GlobalCoordinate GlobalPosition
Definition: python/common/fvspatialparams.hh:57
typename GridView::template Codim< 0 >::Entity Element
Definition: python/common/fvspatialparams.hh:51
GridGeometry_ GridGeometry
Definition: python/common/fvspatialparams.hh:48
FVSpatialParams(std::shared_ptr< const GridGeometry > gridGeometry)
Definition: python/common/fvspatialparams.hh:70
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:89
typename GridView::ctype Scalar
Definition: python/common/fvspatialparams.hh:50
FVSpatialParams(std::shared_ptr< const GridGeometry > gridGeometry, pybind11::object pySpatialParameters)
Definition: python/common/fvspatialparams.hh:60
const GravityVector & gravity(const GlobalPosition &pos) const
Returns the acceleration due to gravity .
Definition: python/common/fvspatialparams.hh:135
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:109
typename GridGeometry::GridView GridView
Definition: python/common/fvspatialparams.hh:49
static constexpr int dimWorld
Definition: python/common/fvspatialparams.hh:55