3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
test/porousmediumflow/3p/implicit/convection/problem.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 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
25#ifndef DUMUX_3PNI_CONVECTION_PROBLEM_HH
26#define DUMUX_3PNI_CONVECTION_PROBLEM_HH
27
28#include <cmath>
29#include <dune/grid/yaspgrid.hh>
30
40
41#include "../conduction/spatialparams.hh"
42
43namespace Dumux {
48template <class TypeTag>
49class ThreePNIConvectionProblem;
50
51namespace Properties {
52// Create new type tags
53namespace TTag {
54struct ThreePNIConvection { using InheritsFrom = std::tuple<ThreePNI>; };
55struct ThreePNIConvectionBox { using InheritsFrom = std::tuple<ThreePNIConvection, BoxModel>; };
56struct ThreePNIConvectionCCTpfa { using InheritsFrom = std::tuple<ThreePNIConvection, CCTpfaModel>; };
57struct ThreePNIConvectionCCMpfa { using InheritsFrom = std::tuple<ThreePNIConvection, CCMpfaModel>; };
58} // end namespace TTag
59
60// Set the grid type
61template<class TypeTag>
62struct Grid<TypeTag, TTag::ThreePNIConvection> { using type = Dune::YaspGrid<2>; };
63
64// Set the problem property
65template<class TypeTag>
66struct Problem<TypeTag, TTag::ThreePNIConvection> { using type = ThreePNIConvectionProblem<TypeTag>; };
67
68
69// Set the fluid system
70template<class TypeTag>
71struct FluidSystem<TypeTag, TTag::ThreePNIConvection>
73
74// Set the spatial parameters
75template<class TypeTag>
76struct SpatialParams<TypeTag, TTag::ThreePNIConvection>
77{
81};
82} // end namespace Properties
83
110template <class TypeTag>
112{
114
117 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
123
125 using ElementVolumeVariables = typename GridVariables::GridVolumeVariables::LocalView;
126 using ElementFluxVariablesCache = typename GridVariables::GridFluxVariablesCache::LocalView;
127 using VolumeVariables = typename GridVariables::GridVolumeVariables::VolumeVariables;
128
130 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
132
133 // copy some indices for convenience
135 enum {
136 // index of the primary variables
137 pressureIdx = Indices::pressureIdx,
138 swIdx = Indices::swIdx,
139 snIdx = Indices::snIdx,
140 temperatureIdx = Indices::temperatureIdx,
141 wPhaseIdx = FluidSystem::wPhaseIdx,
142 conti0EqIdx = Indices::conti0EqIdx,
143 energyEqIdx = Indices::energyEqIdx
144 };
145
146 enum { dimWorld = GridView::dimensionworld };
147
148 using Element = typename GridView::template Codim<0>::Entity;
149 using GlobalPosition = typename SubControlVolumeFace::GlobalPosition;
150
151public:
152 ThreePNIConvectionProblem(std::shared_ptr<const GridGeometry> gridGeometry)
154 {
155 //initialize fluid system
156 FluidSystem::init();
157
158 name_ = getParam<std::string>("Problem.Name");
159 outputInterval_ = getParam<int>("Problem.OutputInterval");
160 darcyVelocity_ = getParam<Scalar>("Problem.DarcyVelocity");
161
162 temperatureHigh_ = 291.;
163 temperatureLow_ = 290.;
164 pressureHigh_ = 2e5;
165 pressureLow_ = 1e5;
166
167 temperatureExact_.resize(this->gridGeometry().numDofs());
168 }
169
171 const std::vector<Scalar>& getExactTemperature()
172 {
173 return temperatureExact_;
174 }
175
177 void updateExactTemperature(const SolutionVector& curSol, Scalar time)
178 {
179 const auto someElement = *(elements(this->gridGeometry().gridView()).begin());
180
181 const auto someElemSol = elementSolution(someElement, curSol, this->gridGeometry());
182 const auto someInitSol = initialAtPos(someElement.geometry().center());
183
184 auto someFvGeometry = localView(this->gridGeometry());
185 someFvGeometry.bindElement(someElement);
186 const auto someScv = *(scvs(someFvGeometry).begin());
187
188 VolumeVariables volVars;
189 volVars.update(someElemSol, *this, someElement, someScv);
190
191 const auto porosity = this->spatialParams().porosity(someElement, someScv, someElemSol);
192 const auto densityW = volVars.density(wPhaseIdx);
193 const auto heatCapacityW = IapwsH2O::liquidHeatCapacity(someInitSol[temperatureIdx], someInitSol[pressureIdx]);
194 const auto storageW = densityW*heatCapacityW*porosity;
195 const auto densityS = volVars.solidDensity();
196 const auto heatCapacityS = volVars.solidHeatCapacity();
197 const auto storageTotal = storageW + densityS*heatCapacityS*(1 - porosity);
198 std::cout << "storage: " << storageTotal << '\n';
199
200 using std::max;
201 time = max(time, 1e-10);
202 const Scalar retardedFrontVelocity = darcyVelocity_*storageW/storageTotal/porosity;
203 std::cout << "retarded velocity: " << retardedFrontVelocity << '\n';
204
205 for (const auto& element : elements(this->gridGeometry().gridView()))
206 {
207 auto fvGeometry = localView(this->gridGeometry());
208 fvGeometry.bindElement(element);
209 for (auto&& scv : scvs(fvGeometry))
210 {
211 auto dofIdxGlobal = scv.dofIndex();
212 auto dofPosition = scv.dofPosition();
213 temperatureExact_[dofIdxGlobal] = (dofPosition[0] < retardedFrontVelocity*time) ? temperatureHigh_ : temperatureLow_;
214 }
215 }
216 }
217
221 // \{
222
228 const std::string& name() const
229 {
230 return name_;
231 }
232
233 // \}
234
238 // \{
239
246 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
247 {
248 BoundaryTypes values;
249 if(globalPos[0] > this->gridGeometry().bBoxMax()[0] - eps_)
250 {
251 values.setAllDirichlet();
252 }
253 else
254 {
255 values.setAllNeumann();
256 }
257 return values;
258 }
259
266 PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
267 {
268 return initialAtPos(globalPos);
269 }
270
281 NumEqVector neumann(const Element &element,
282 const FVElementGeometry& fvGeometry,
283 const ElementVolumeVariables& elemVolVars,
284 const ElementFluxVariablesCache& elemFluxVarsCache,
285 const SubControlVolumeFace& scvf) const
286 {
287 NumEqVector values(0.0);
288 const auto globalPos = scvf.ipGlobal();
289 const auto& volVars = elemVolVars[scvf.insideScvIdx()];
290
291 if(globalPos[0] < eps_)
292 {
293 values[conti0EqIdx] = -darcyVelocity_*volVars.density(wPhaseIdx);
294 values[energyEqIdx] = -darcyVelocity_*volVars.density(wPhaseIdx)
295 *IapwsH2O::liquidEnthalpy(temperatureHigh_, volVars.pressure(wPhaseIdx));
296 }
297 return values;
298 }
299
300 // \}
301
305 // \{
306
313 PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
314 {
315 PrimaryVariables values;
316 values[pressureIdx] = pressureLow_; // initial condition for the pressure
317 values[swIdx] = 1.0; // initial condition for the wetting phase saturation
318 values[snIdx] = 1e-10; // initial condition for the non-wetting phase saturation
319 values[temperatureIdx] = temperatureLow_;
320 return values;
321 }
322
323 // \}
324
325private:
326 Scalar temperatureHigh_;
327 Scalar temperatureLow_;
328 Scalar pressureHigh_;
329 Scalar pressureLow_;
330 Scalar darcyVelocity_;
331 static constexpr Scalar eps_ = 1e-6;
332 std::string name_;
333 int outputInterval_;
334 std::vector<Scalar> temperatureExact_;
335};
336
337} // end namespace Dumux
338
339#endif
Element solution classes and factory functions.
Defines a type tag and some properties for models using the box scheme.
Properties for all models using cell-centered finite volume scheme with mpfa.
Properties for all models using cell-centered finite volume scheme with TPFA.
Material properties of pure water .
Relation for the saturation-dependent effective thermal conductivity.
A three-phase fluid system featuring gas, NAPL and water as phases and distilled water and air (Pseu...
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:38
auto elementSolution(const Element &element, const SolutionVector &sol, const GridGeometry &gg) -> std::enable_if_t< GridGeometry::discMethod==DiscretizationMethod::box, BoxElementSolution< typename GridGeometry::LocalView, std::decay_t< decltype(std::declval< SolutionVector >()[0])> > >
Make an element solution for box schemes.
Definition: box/elementsolution.hh:115
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition: propertysystem.hh:149
std::string porosity() noexcept
I/O name of porosity.
Definition: name.hh:139
Base class for all finite-volume problems.
Definition: common/fvproblem.hh:50
const GridGeometry & gridGeometry() const
The finite volume grid geometry.
Definition: common/fvproblem.hh:588
The DUNE grid type.
Definition: common/properties.hh:57
Property to specify the type of a problem which has to be solved.
Definition: common/properties.hh:69
The type of the spatial parameters object.
Definition: common/properties.hh:221
The type of the fluid system to use.
Definition: common/properties.hh:223
Material properties of pure water .
Definition: h2o.hh:61
static const Scalar liquidHeatCapacity(Scalar temperature, Scalar pressure)
Specific isobaric heat capacity of liquid water .
Definition: h2o.hh:281
static const Scalar liquidEnthalpy(Scalar temperature, Scalar pressure)
Specific enthalpy of liquid water .
Definition: h2o.hh:217
A three-phase fluid system featuring gas, NAPL and water as phases and distilled water and air (Pseu...
Definition: h2oairmesitylene.hh:57
Base class for all fully implicit porous media problems.
Definition: dumux/porousmediumflow/problem.hh:39
SpatialParams & spatialParams()
Returns the spatial parameters object.
Definition: dumux/porousmediumflow/problem.hh:146
Definition of the spatial parameters for the 3pni problems.
Definition: porousmediumflow/3p/implicit/conduction/spatialparams.hh:44
Test for the ThreePModel in combination with the NI model for a convection problem.
Definition: test/porousmediumflow/3p/implicit/convection/problem.hh:112
const std::vector< Scalar > & getExactTemperature()
Get exact temperature vector for output.
Definition: test/porousmediumflow/3p/implicit/convection/problem.hh:171
void updateExactTemperature(const SolutionVector &curSol, Scalar time)
Udpate the analytical temperature.
Definition: test/porousmediumflow/3p/implicit/convection/problem.hh:177
BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
Specifies which kind of boundary condition should be used for which equation on a given boundary segm...
Definition: test/porousmediumflow/3p/implicit/convection/problem.hh:246
PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
Evaluates the boundary conditions for a Dirichlet boundary segment.
Definition: test/porousmediumflow/3p/implicit/convection/problem.hh:266
NumEqVector neumann(const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const ElementFluxVariablesCache &elemFluxVarsCache, const SubControlVolumeFace &scvf) const
Evaluates the boundary conditions for a Neumann boundary segment.
Definition: test/porousmediumflow/3p/implicit/convection/problem.hh:281
const std::string & name() const
The problem name.
Definition: test/porousmediumflow/3p/implicit/convection/problem.hh:228
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
Evaluates the initial value for a control volume.
Definition: test/porousmediumflow/3p/implicit/convection/problem.hh:313
ThreePNIConvectionProblem(std::shared_ptr< const GridGeometry > gridGeometry)
Definition: test/porousmediumflow/3p/implicit/convection/problem.hh:152
Definition: test/porousmediumflow/3p/implicit/convection/problem.hh:54
std::tuple< ThreePNI > InheritsFrom
Definition: test/porousmediumflow/3p/implicit/convection/problem.hh:54
Definition: test/porousmediumflow/3p/implicit/convection/problem.hh:55
std::tuple< ThreePNIConvection, BoxModel > InheritsFrom
Definition: test/porousmediumflow/3p/implicit/convection/problem.hh:55
Definition: test/porousmediumflow/3p/implicit/convection/problem.hh:56
std::tuple< ThreePNIConvection, CCTpfaModel > InheritsFrom
Definition: test/porousmediumflow/3p/implicit/convection/problem.hh:56
Definition: test/porousmediumflow/3p/implicit/convection/problem.hh:57
std::tuple< ThreePNIConvection, CCMpfaModel > InheritsFrom
Definition: test/porousmediumflow/3p/implicit/convection/problem.hh:57
Dune::YaspGrid< 2 > type
Definition: test/porousmediumflow/3p/implicit/convection/problem.hh:62
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: test/porousmediumflow/3p/implicit/convection/problem.hh:79
GetPropType< TypeTag, Properties::GridGeometry > GridGeometry
Definition: test/porousmediumflow/3p/implicit/convection/problem.hh:78
Adaption of the fully implicit scheme to the three-phase flow model.
Base class for all porous media problems.