version 3.11-dev
Loading...
Searching...
No Matches
porousmediumflow/2pve/spatialparams.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3//
4// SPDX-FileCopyrightText: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12
13#ifndef DUMUX_TWOPVE_SPATIAL_PARAMS_HH
14#define DUMUX_TWOPVE_SPATIAL_PARAMS_HH
15
16#include <cmath>
17#include <memory>
18#include <type_traits>
19#include <utility>
20#include <vector>
21
22#include <dune/common/exceptions.hh>
23#include <dune/grid/common/rangegenerators.hh>
24
27
28namespace Dumux {
29
48template<class GridGeometry, class FineGridGeometry, class Scalar, class SpatialParamsFine, class Implementation>
50: public FVPorousMediumFlowSpatialParamsMP<GridGeometry, Scalar, Implementation>
51{
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;
58
59public:
60 using PermeabilityType = Scalar;
61
70 TwoPVESpatialParams(std::shared_ptr<const GridGeometry> gridGeometry,
71 const ColumnMapping& columnMapping,
72 std::shared_ptr<const SpatialParamsFine> spatialParamsFine,
73 const Scalar fineCellHeight)
74 : ParentType(gridGeometry)
75 , spatialParamsFine_(spatialParamsFine)
76 , permeabilityIntegral_(gridGeometry->elementMapper().size(), 0.0)
77 , porosityIntegral_(gridGeometry->elementMapper().size(), 0.0)
78 , columnHeight_(gridGeometry->elementMapper().size(), 0.0)
79 {
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");
82
83 for (const auto& element : elements(gridGeometry->gridView()))
84 {
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)
89 {
90 using std::abs;
91 const Scalar porosityFine = spatialParamsFine_->porosityAtElement(fineElement);
92 // the gas plume distance follows from the water balance of the unweighted saturation profile
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);
95
96 permeabilityIntegral_[columnIdx] += spatialParamsFine_->permeabilityAtElement(fineElement)*fineCellHeight;
97 porosityIntegral_[columnIdx] += porosityFine*fineCellHeight;
98 }
99
100 const Scalar columnHeight = column.size()*fineCellHeight;
101 columnHeight_[columnIdx] = columnHeight;
102 }
103 }
104
108 const SpatialParamsFine& spatialParamsFine() const
109 { return *spatialParamsFine_; }
110
118 template<class ElementSolution>
119 PermeabilityType permeability(const Element& element,
120 const SubControlVolume& scv,
121 const ElementSolution& elemSol) const
122 { return permeabilityIntegralAtElement(element)/columnHeightAtElement(element); }
123
131 template<class ElementSolution>
132 Scalar porosity(const Element& element,
133 const SubControlVolume& scv,
134 const ElementSolution& elemSol) const
135 { return porosityIntegralAtElement(element)/columnHeightAtElement(element); }
136
138 template<class ElementSolution>
139 Scalar extrusionFactor(const Element& element,
140 const SubControlVolume&,
141 const ElementSolution&) const
142 { return columnHeightAtElement(element); }
143
149 template<class FluidSystem>
150 int wettingPhaseAtPos(const GlobalPosition& globalPos) const
151 { return FluidSystem::phase0Idx; }
152
154 Scalar permeabilityIntegralAtElement(const Element& element) const
155 { return permeabilityIntegral_[this->gridGeometry().elementMapper().index(element)]; }
156
158 Scalar porosityIntegralAtElement(const Element& element) const
159 { return porosityIntegral_[this->gridGeometry().elementMapper().index(element)]; }
160
162 Scalar columnHeightAtElement(const Element& element) const
163 { return columnHeight_[this->gridGeometry().elementMapper().index(element)]; }
164
166 GlobalPosition gravity(const GlobalPosition&) const
167 { return GlobalPosition(0.0); }
168
169private:
170 std::shared_ptr<const SpatialParamsFine> spatialParamsFine_;
171 std::vector<PermeabilityType> permeabilityIntegral_;
172 std::vector<Scalar> porosityIntegral_;
173 std::vector<Scalar> columnHeight_;
174};
175
176} // end namespace Dumux
177
178#endif
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.
Definition adapt.hh:17