13#ifndef DUMUX_TWOPVE_SPATIAL_PARAMS_HH
14#define DUMUX_TWOPVE_SPATIAL_PARAMS_HH
22#include <dune/common/exceptions.hh>
23#include <dune/grid/common/rangegenerators.hh>
48template<
class Gr
idGeometry,
class FineGr
idGeometry,
class Scalar,
class SpatialParamsFine,
class Implementation>
53 using GridView =
typename GridGeometry::GridView;
54 using Element =
typename GridView::template Codim<0>::Entity;
55 using SubControlVolume =
typename GridGeometry::LocalView::SubControlVolume;
56 using GlobalPosition =
typename Element::Geometry::GlobalCoordinate;
71 const ColumnMapping& columnMapping,
73 const Scalar fineCellHeight)
76 , permeabilityIntegral_(
gridGeometry->elementMapper().size(), 0.0)
77 , porosityIntegral_(
gridGeometry->elementMapper().size(), 0.0)
78 , columnHeight_(
gridGeometry->elementMapper().size(), 0.0)
80 using FinePermeability = std::decay_t<
decltype(spatialParamsFine_->permeabilityAtElement(std::declval<
const typename FineGridGeometry::GridView::template Codim<0>::Entity&>()))>;
81 static_assert(std::is_convertible_v<FinePermeability, Scalar>,
"The VE upscaling requires a scalar fine-level permeability");
83 for (
const auto& element : elements(
gridGeometry->gridView()))
85 const auto columnIdx = gridGeometry->elementMapper().index(element);
86 const auto& column = columnMapping.column(columnIdx);
87 const Scalar columnPorosity = spatialParamsFine_->porosityAtElement(column.front());
88 for (const auto& fineElement : column)
91 const Scalar porosityFine = spatialParamsFine_->porosityAtElement(fineElement);
93 if (abs(porosityFine - columnPorosity) > 1e-10*abs(columnPorosity))
94 DUNE_THROW(Dune::InvalidStateException,
"The VE model requires a uniform porosity within each column, column " << columnIdx <<
" has porosities " << columnPorosity <<
" and " << porosityFine);
96 permeabilityIntegral_[columnIdx] += spatialParamsFine_->permeabilityAtElement(fineElement)*fineCellHeight;
97 porosityIntegral_[columnIdx] += porosityFine*fineCellHeight;
100 const Scalar columnHeight = column.size()*fineCellHeight;
101 columnHeight_[columnIdx] = columnHeight;
109 {
return *spatialParamsFine_; }
118 template<
class ElementSolution>
120 const SubControlVolume& scv,
121 const ElementSolution& elemSol)
const
131 template<
class ElementSolution>
133 const SubControlVolume& scv,
134 const ElementSolution& elemSol)
const
138 template<
class ElementSolution>
140 const SubControlVolume&,
141 const ElementSolution&)
const
149 template<
class Flu
idSystem>
151 {
return FluidSystem::phase0Idx; }
155 {
return permeabilityIntegral_[this->
gridGeometry().elementMapper().index(element)]; }
159 {
return porosityIntegral_[this->
gridGeometry().elementMapper().index(element)]; }
163 {
return columnHeight_[this->
gridGeometry().elementMapper().index(element)]; }
166 GlobalPosition
gravity(
const GlobalPosition&)
const
167 {
return GlobalPosition(0.0); }
170 std::shared_ptr<const SpatialParamsFine> spatialParamsFine_;
171 std::vector<PermeabilityType> permeabilityIntegral_;
172 std::vector<Scalar> porosityIntegral_;
173 std::vector<Scalar> columnHeight_;
FVPorousMediumFlowSpatialParamsMP(std::shared_ptr< const GridGeometry > gridGeometry)
Definition fvspatialparamsmp.hh:59
const GridGeometry & gridGeometry() const
The finite volume grid geometry.
Definition common/fvspatialparams.hh:161
Maps horizontal coarse cells to vertically stacked fine cells using horizontal projection.
Definition columnmapping.hh:39
Scalar porosity(const Element &element, const SubControlVolume &scv, const ElementSolution &elemSol) const
Returns the dimensionless column-average porosity.
Definition porousmediumflow/2pve/spatialparams.hh:132
GlobalPosition gravity(const GlobalPosition &) const
Horizontal gravity is zero; vertical gravity enters through fine-level reconstruction.
Definition porousmediumflow/2pve/spatialparams.hh:166
TwoPVESpatialParams(std::shared_ptr< const GridGeometry > gridGeometry, const ColumnMapping &columnMapping, std::shared_ptr< const SpatialParamsFine > spatialParamsFine, const Scalar fineCellHeight)
Computes the coarse-level permeability and porosity of all columns.
Definition porousmediumflow/2pve/spatialparams.hh:70
int wettingPhaseAtPos(const GlobalPosition &globalPos) const
Returns the index of the wetting phase, which the VE model requires to be the first phase.
Definition porousmediumflow/2pve/spatialparams.hh:150
Scalar PermeabilityType
Definition porousmediumflow/2pve/spatialparams.hh:60
Scalar permeabilityIntegralAtElement(const Element &element) const
Vertical integral of the intrinsic permeability [m^3].
Definition porousmediumflow/2pve/spatialparams.hh:154
Scalar porosityIntegralAtElement(const Element &element) const
Vertical integral of porosity [m], used for storage per horizontal measure.
Definition porousmediumflow/2pve/spatialparams.hh:158
Scalar extrusionFactor(const Element &element, const SubControlVolume &, const ElementSolution &) const
Column height [m], used to extrude the horizontal cell and its faces.
Definition porousmediumflow/2pve/spatialparams.hh:139
PermeabilityType permeability(const Element &element, const SubControlVolume &scv, const ElementSolution &elemSol) const
Returns the column-average intrinsic permeability .
Definition porousmediumflow/2pve/spatialparams.hh:119
const SpatialParamsFine & spatialParamsFine() const
Returns the fine-level spatial parameters.
Definition porousmediumflow/2pve/spatialparams.hh:108
Scalar columnHeightAtElement(const Element &element) const
Height of the reconstructed column [m].
Definition porousmediumflow/2pve/spatialparams.hh:162
Manages the maps between the coarse and fine level.
The base class for spatial parameters in multi-phase porous-medium-flow problems.