3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
test/porousmediumflow/richards/implicit/nonisothermal/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 *****************************************************************************/
27#ifndef DUMUX_RICHARDS_CONVECTION_PROBLEM_HH
28#define DUMUX_RICHARDS_CONVECTION_PROBLEM_HH
29
30#include <cmath>
31#include <dune/grid/yaspgrid.hh>
32
36
41#include "../spatialparams.hh"
42
43namespace Dumux {
50template <class TypeTag>
51class RichardsNIConvectionProblem;
52
53namespace Properties {
54// Create new type tags
55namespace TTag {
56struct RichardsNIConvection { using InheritsFrom = std::tuple<RichardsNI>; };
57struct RichardsNIConvectionBox { using InheritsFrom = std::tuple<RichardsNIConvection, BoxModel>; };
58struct RichardsNIConvectionCC { using InheritsFrom = std::tuple<RichardsNIConvection, CCTpfaModel>; };
59} // end namespace TTag
60
61// Set the grid type
62template<class TypeTag>
63struct Grid<TypeTag, TTag::RichardsNIConvection> { using type = Dune::YaspGrid<2>; };
64
65// Set the problem property
66template<class TypeTag>
67struct Problem<TypeTag, TTag::RichardsNIConvection> { using type = RichardsNIConvectionProblem<TypeTag>; };
68
69// Set the fluid system
70template<class TypeTag>
71struct FluidSystem<TypeTag, TTag::RichardsNIConvection> { using type = FluidSystems::H2ON2<GetPropType<TypeTag, Properties::Scalar>, FluidSystems::H2ON2DefaultPolicy</*fastButSimplifiedRelations=*/true>>; };
72
73// Set the spatial parameters
74template<class TypeTag>
75struct SpatialParams<TypeTag, TTag::RichardsNIConvection>
76{
80};
81} // end namespace Properties
82
106template <class TypeTag>
108{
110
113 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
119 using ThermalConductivityModel = GetPropType<TypeTag, Properties::ThermalConductivityModel>;
121 using ElementVolumeVariables = typename GridVariables::GridVolumeVariables::LocalView;
122 using ElementFluxVariablesCache = typename GridVariables::GridFluxVariablesCache::LocalView;
123 using VolumeVariables = typename GridVariables::GridVolumeVariables::VolumeVariables;
125 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
127
128 // copy some indices for convenience
130 enum { dimWorld = GridView::dimensionworld };
131
132 enum {
133 pressureIdx = Indices::pressureIdx,
134 liquidPhaseOnly = Indices::liquidPhaseOnly,
135 liquidPhaseIdx = FluidSystem::liquidPhaseIdx,
136 temperatureIdx = Indices::temperatureIdx
137 };
138
139 using Element = typename GridView::template Codim<0>::Entity;
140
141 using GlobalPosition = typename SubControlVolumeFace::GlobalPosition;
142
143public:
144 RichardsNIConvectionProblem(std::shared_ptr<const GridGeometry> gridGeometry)
146 {
147 // initialize fluid system
148 FluidSystem::init();
149
150 name_ = getParam<std::string>("Problem.Name");
151 darcyVelocity_ = getParam<Scalar>("Problem.DarcyVelocity");
152 temperatureHigh_ = 291.;
153 temperatureLow_ = 290.;
154 pressureHigh_ = 2e5;
155 pressureLow_ = 1e5;
156 temperatureExact_.resize(gridGeometry->numDofs());
157 }
158
160 const std::vector<Scalar>& getExactTemperature()
161 {
162 return temperatureExact_;
163 }
164
166 void updateExactTemperature(const SolutionVector& curSol, Scalar time)
167 {
168 const auto someElement = *(elements(this->gridGeometry().gridView()).begin());
169
170 const auto someElemSol = elementSolution(someElement, curSol, this->gridGeometry());
171 const auto someInitSol = initialAtPos(someElement.geometry().center());
172
173 auto someFvGeometry = localView(this->gridGeometry());
174 someFvGeometry.bindElement(someElement);
175 const auto someScv = *(scvs(someFvGeometry).begin());
176
177 VolumeVariables volVars;
178 volVars.update(someElemSol, *this, someElement, someScv);
179
180 const auto porosity = this->spatialParams().porosity(someElement, someScv, someElemSol);
181 const auto densityW = volVars.density(liquidPhaseIdx);
182 const auto heatCapacityW = IapwsH2O::liquidHeatCapacity(someInitSol[temperatureIdx], someInitSol[pressureIdx]);
183 const auto densityS = volVars.solidDensity();
184 const auto heatCapacityS = volVars.solidHeatCapacity();
185 const auto storage = densityW*heatCapacityW*porosity + densityS*heatCapacityS*(1 - porosity);
186 const auto effectiveThermalConductivity = ThermalConductivityModel::effectiveThermalConductivity(volVars);
187 using std::max;
188 time = max(time, 1e-10);
189 for (const auto& element : elements(this->gridGeometry().gridView()))
190 {
191 auto fvGeometry = localView(this->gridGeometry());
192 fvGeometry.bindElement(element);
193
194 for (auto&& scv : scvs(fvGeometry))
195 {
196 auto globalIdx = scv.dofIndex();
197 const auto& globalPos = scv.dofPosition();
198 using std::erf;
199 using std::sqrt;
200 temperatureExact_[globalIdx] = temperatureHigh_ + (someInitSol[temperatureIdx] - temperatureHigh_)
201 *erf(0.5*sqrt(globalPos[0]*globalPos[0]*storage/time/effectiveThermalConductivity));
202
203 }
204 }
205 }
209 // \{
210
216 const std::string& name() const
217 {
218 return name_;
219 }
220
221 // \}
222
226 // \{
227
234 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
235 {
236 BoundaryTypes values;
237 if(globalPos[0] > this->gridGeometry().bBoxMax()[0] - eps_)
238 {
239 values.setAllDirichlet();
240 }
241 else
242 {
243 values.setAllNeumann();
244 }
245 return values;
246 }
247
255 PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
256 {
257 return initial_(globalPos);
258 }
259
270 NumEqVector neumann(const Element &element,
271 const FVElementGeometry& fvGeometry,
272 const ElementVolumeVariables& elemVolVars,
273 const ElementFluxVariablesCache& elemFluxVarsCache,
274 const SubControlVolumeFace& scvf) const
275 {
276 NumEqVector values(0.0);
277 const auto globalPos = scvf.ipGlobal();
278
279 if(globalPos[0] < eps_)
280 {
281 values[pressureIdx] = -darcyVelocity_*elemVolVars[scvf.insideScvIdx()].density(liquidPhaseIdx);
282 values[temperatureIdx] = -darcyVelocity_*elemVolVars[scvf.insideScvIdx()].density(liquidPhaseIdx)
283 *IapwsH2O::liquidEnthalpy(temperatureHigh_, elemVolVars[scvf.insideScvIdx()].pressure(liquidPhaseIdx));
284 }
285 return values;
286 }
287
288 // \}
289
293 // \{
294
295
303 { return 1e5; };
304
313 PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
314 {
315 return initial_(globalPos);
316 }
317
318 // \}
319
320private:
321 PrimaryVariables initial_(const GlobalPosition &globalPos) const
322 {
323 PrimaryVariables priVars(0.0);
324 priVars.setState(liquidPhaseOnly);
325 priVars[pressureIdx] = pressureLow_; // initial condition for the pressure
326 priVars[temperatureIdx] = temperatureLow_;
327 return priVars;
328 }
329
330 Scalar temperatureHigh_;
331 Scalar temperatureLow_;
332 Scalar pressureHigh_;
333 Scalar pressureLow_;
334 Scalar darcyVelocity_;
335 static constexpr Scalar eps_ = 1e-6;
336 std::string name_;
337 std::vector<Scalar> temperatureExact_;
338};
339
340} // end namespace
341#endif // DUMUX_RICHARDSNI_CONVECTION_PROBLEM_HH
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 TPFA.
Relation for the saturation-dependent effective thermal conductivity.
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
Policy for the H2O-N2 fluid system.
Definition: h2on2.hh:52
A two-phase fluid system with two components water Nitrogen for non-equilibrium models.
Definition: h2on2.hh:69
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
Test for the RichardsModel in combination with the NI model for a convection problem: The simulation ...
Definition: test/porousmediumflow/richards/implicit/nonisothermal/convection/problem.hh:108
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
Evaluates the initial value for a control volume.
Definition: test/porousmediumflow/richards/implicit/nonisothermal/convection/problem.hh:313
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/richards/implicit/nonisothermal/convection/problem.hh:234
PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
Evaluates the boundary conditions for a Dirichlet boundary segment.
Definition: test/porousmediumflow/richards/implicit/nonisothermal/convection/problem.hh:255
Scalar nonWettingReferencePressure() const
Returns the reference pressure [Pa] of the non-wetting fluid phase within a finite volume.
Definition: test/porousmediumflow/richards/implicit/nonisothermal/convection/problem.hh:302
void updateExactTemperature(const SolutionVector &curSol, Scalar time)
Update the analytical temperature.
Definition: test/porousmediumflow/richards/implicit/nonisothermal/convection/problem.hh:166
const std::string & name() const
The problem name.
Definition: test/porousmediumflow/richards/implicit/nonisothermal/convection/problem.hh:216
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/richards/implicit/nonisothermal/convection/problem.hh:270
RichardsNIConvectionProblem(std::shared_ptr< const GridGeometry > gridGeometry)
Definition: test/porousmediumflow/richards/implicit/nonisothermal/convection/problem.hh:144
const std::vector< Scalar > & getExactTemperature()
Get the analytical temperature.
Definition: test/porousmediumflow/richards/implicit/nonisothermal/convection/problem.hh:160
Definition: test/porousmediumflow/richards/implicit/nonisothermal/convection/problem.hh:56
std::tuple< RichardsNI > InheritsFrom
Definition: test/porousmediumflow/richards/implicit/nonisothermal/convection/problem.hh:56
Definition: test/porousmediumflow/richards/implicit/nonisothermal/convection/problem.hh:57
std::tuple< RichardsNIConvection, BoxModel > InheritsFrom
Definition: test/porousmediumflow/richards/implicit/nonisothermal/convection/problem.hh:57
Definition: test/porousmediumflow/richards/implicit/nonisothermal/convection/problem.hh:58
std::tuple< RichardsNIConvection, CCTpfaModel > InheritsFrom
Definition: test/porousmediumflow/richards/implicit/nonisothermal/convection/problem.hh:58
Dune::YaspGrid< 2 > type
Definition: test/porousmediumflow/richards/implicit/nonisothermal/convection/problem.hh:63
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: test/porousmediumflow/richards/implicit/nonisothermal/convection/problem.hh:78
GetPropType< TypeTag, Properties::GridGeometry > GridGeometry
Definition: test/porousmediumflow/richards/implicit/nonisothermal/convection/problem.hh:77
Definition: porousmediumflow/richards/implicit/nonisothermal/spatialparams.hh:40
This model implements a variant of the Richards' equation for quasi-twophase flow.
Base class for all porous media problems.