13#ifndef DUMUX_COMMON_FV_SPATIAL_PARAMS_HH
14#define DUMUX_COMMON_FV_SPATIAL_PARAMS_HH
18#include <dune/common/fvector.hh>
19#include <dune/common/exceptions.hh>
30template<
class GridGeometry,
35 using GridView =
typename GridGeometry::GridView;
36 using Element =
typename GridView::template Codim<0>::Entity;
37 using SubControlVolume =
typename GridGeometry::SubControlVolume;
39 static constexpr int dimWorld = GridView::dimensionworld;
41 using GlobalPosition =
typename Element::Geometry::GlobalCoordinate;
42 using GravityVector = Dune::FieldVector<Scalar, dimWorld>;
49 if (getParam<bool>(
"Problem.EnableGravity"))
50 gravity_[dimWorld-1] = -9.81;
62 template<
class ElementSolution>
64 const SubControlVolume& scv,
65 const ElementSolution& elemSol)
const
68 return asImp_().extrusionFactorAtPos(scv.center());
84 template<
class ElementSolution>
86 const SubControlVolume& scv,
87 const ElementSolution& elemSol)
const
90 return asImp_().temperatureAtPos(scv.center());
99 static const Scalar defaultTemperature = [] ()
101 Scalar defaultTemp = 293.15;
102 if (!
hasParam(
"SpatialParams.Temperature"))
104 std::cout <<
" -- Using the default temperature of " << defaultTemp <<
" in the entire domain. "
105 <<
"Overload temperatureAtPos() in your spatial params class to define a custom temperature field."
106 <<
"Or provide the preferred domain temperature via the SpatialParams.Temperature parameter."
109 const Scalar
temperature = getParam<Scalar>(
"SpatialParams.Temperature", defaultTemp);
113 return defaultTemperature;
126 const GravityVector&
gravity(
const GlobalPosition& pos)
const
131 {
return *gridGeometry_; }
136 {
return *
static_cast<Implementation *
>(
this); }
140 {
return *
static_cast<const Implementation *
>(
this); }
143 std::shared_ptr<const GridGeometry> gridGeometry_;
144 GravityVector gravity_;
The base class for spatial parameters used with finite-volume schemes.
Definition: common/fvspatialparams.hh:34
Scalar temperatureAtPos(const GlobalPosition &globalPos) const
Return the temperature in the domain at the given position.
Definition: common/fvspatialparams.hh:97
Implementation & asImp_()
Returns the implementation of the spatial parameters (static polymorphism)
Definition: 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: common/fvspatialparams.hh:85
Scalar extrusionFactorAtPos(const GlobalPosition &globalPos) const
Return how much the domain is extruded at a given position.
Definition: common/fvspatialparams.hh:74
const Implementation & asImp_() const
Returns the implementation of the spatial parameters (static polymorphism)
Definition: common/fvspatialparams.hh:139
FVSpatialParams(std::shared_ptr< const GridGeometry > gridGeometry)
Definition: common/fvspatialparams.hh:45
const GridGeometry & gridGeometry() const
The finite volume grid geometry.
Definition: common/fvspatialparams.hh:130
const GravityVector & gravity(const GlobalPosition &pos) const
Returns the acceleration due to gravity .
Definition: common/fvspatialparams.hh:126
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: common/fvspatialparams.hh:63
bool hasParam(const std::string ¶m)
Check whether a key exists in the parameter tree.
Definition: parameters.hh:157
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.