3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
test/porousmediumflow/1pnc/implicit/1p2c/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_1P2CNI_CONVECTION_TEST_PROBLEM_HH
28#define DUMUX_1P2CNI_CONVECTION_TEST_PROBLEM_HH
29
30#if HAVE_UG
31#include <dune/grid/uggrid.hh>
32#endif
33#include <dune/grid/yaspgrid.hh>
34
41
45#include "../../spatialparams.hh"
46
47namespace Dumux {
48
49template <class TypeTag>
50class OnePTwoCNIConvectionProblem;
51
52namespace Properties {
53// Create new type tags
54namespace TTag {
55struct OnePTwoCNIConvection { using InheritsFrom = std::tuple<OnePNCNI>; };
56struct OnePTwoCNIConvectionCCTpfa { using InheritsFrom = std::tuple<OnePTwoCNIConvection, CCTpfaModel>; };
57struct OnePTwoCNIConvectionCCMpfa { using InheritsFrom = std::tuple<OnePTwoCNIConvection, CCMpfaModel>; };
58struct OnePTwoCNIConvectionBox { using InheritsFrom = std::tuple<OnePTwoCNIConvection, BoxModel>; };
59} // end namespace TTag
60
61// Set the grid type
62#if HAVE_UG
63template<class TypeTag>
64struct Grid<TypeTag, TTag::OnePTwoCNIConvection> { using type = Dune::UGGrid<2>; };
65#else
66template<class TypeTag>
67struct Grid<TypeTag, TTag::OnePTwoCNIConvection> { using type = Dune::YaspGrid<2>; };
68#endif
69
70// Set the problem property
71template<class TypeTag>
72struct Problem<TypeTag, TTag::OnePTwoCNIConvection> { using type = OnePTwoCNIConvectionProblem<TypeTag>; };
73
74// Set fluid configuration
75template<class TypeTag>
76struct FluidSystem<TypeTag, TTag::OnePTwoCNIConvection>
77{
81};
82
83// Set the spatial parameters
84template<class TypeTag>
85struct SpatialParams<TypeTag, TTag::OnePTwoCNIConvection>
86{
90};
91
92// Define whether mole(true) or mass (false) fractions are used
93template<class TypeTag>
94struct UseMoles<TypeTag, TTag::OnePTwoCNIConvection> { static constexpr bool value = true; };
95} // end namespace Properties
96
122template <class TypeTag>
124{
126
134 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
136
138 using ElementVolumeVariables = typename GridVariables::GridVolumeVariables::LocalView;
139 using ElementFluxVariablesCache = typename GridVariables::GridFluxVariablesCache::LocalView;
140
141 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
142 using Element = typename GridView::template Codim<0>::Entity;
146
147 // copy some indices for convenience
148 enum
149 {
150 // indices of the primary variables
151 pressureIdx = Indices::pressureIdx,
152 temperatureIdx = Indices::temperatureIdx,
153
154 // component indices
155 H2OIdx = FluidSystem::compIdx(FluidSystem::MultiPhaseFluidSystem::H2OIdx),
156 N2Idx = FluidSystem::compIdx(FluidSystem::MultiPhaseFluidSystem::N2Idx),
157
158 // indices of the equations
159 contiH2OEqIdx = Indices::conti0EqIdx + H2OIdx,
160 contiN2EqIdx = Indices::conti0EqIdx + N2Idx,
161 energyEqIdx = Indices::energyEqIdx
162 };
163
165 static constexpr bool useMoles = getPropValue<TypeTag, Properties::UseMoles>();
166 static const int dimWorld = GridView::dimensionworld;
167 using GlobalPosition = typename SubControlVolumeFace::GlobalPosition;
168
169public:
170 OnePTwoCNIConvectionProblem(std::shared_ptr<const GridGeometry> gridGeometry)
172 {
173 //initialize fluid system
174 FluidSystem::init();
175
176 // stating in the console whether mole or mass fractions are used
177 if(useMoles)
178 std::cout<<"problem uses mole fractions"<<std::endl;
179 else
180 std::cout<<"problem uses mass fractions"<<std::endl;
181
182 temperatureExact_.resize(gridGeometry->numDofs(), 290.0);
183
184 darcyVelocity_ = getParam<Scalar>("Problem.DarcyVelocity");
185
186 temperatureHigh_ = 291.;
187 temperatureLow_ = 290.;
188 pressureHigh_ = 2e5;
189 pressureLow_ = 1e5;
190 }
191
193 const std::vector<Scalar>& getExactTemperature()
194 {
195 return temperatureExact_;
196 }
197
199 void updateExactTemperature(const SolutionVector& curSol, Scalar time)
200 {
201 const auto someElement = *(elements(this->gridGeometry().gridView()).begin());
202
203 auto someElemSol = elementSolution(someElement, curSol, this->gridGeometry());
204 const auto someInitSol = initialAtPos(someElement.geometry().center());
205
206 auto someFvGeometry = localView(this->gridGeometry());
207 someFvGeometry.bindElement(someElement);
208 const auto someScv = *(scvs(someFvGeometry).begin());
209
210 VolumeVariables volVars;
211 volVars.update(someElemSol, *this, someElement, someScv);
212
213 const auto porosity = this->spatialParams().porosity(someElement, someScv, someElemSol);
214 const auto densityW = volVars.density();
215 const auto heatCapacityW = IapwsH2O::liquidHeatCapacity(someInitSol[temperatureIdx], someInitSol[pressureIdx]);
216 const auto storageW = densityW*heatCapacityW*porosity;
217 const auto densityS = volVars.solidDensity();
218 const auto heatCapacityS = volVars.solidHeatCapacity();
219 const auto storageTotal = storageW + densityS*heatCapacityS*(1 - porosity);
220 std::cout << "storage: " << storageTotal << '\n';
221
222 using std::max;
223 time = max(time, 1e-10);
224 const Scalar retardedFrontVelocity = darcyVelocity_*storageW/storageTotal/porosity;
225 std::cout << "retarded velocity: " << retardedFrontVelocity << '\n';
226
227 for (const auto& element : elements(this->gridGeometry().gridView()))
228 {
229 auto fvGeometry = localView(this->gridGeometry());
230 fvGeometry.bindElement(element);
231 for (auto&& scv : scvs(fvGeometry))
232 {
233 auto dofIdxGlobal = scv.dofIndex();
234 auto dofPosition = scv.dofPosition();
235 temperatureExact_[dofIdxGlobal] = (dofPosition[0] < retardedFrontVelocity*time) ? temperatureHigh_ : temperatureLow_;
236 }
237 }
238 }
239
243 // \{
244
250 Scalar temperature() const
251 { return 273.15 + 20; } // in [K]
252
253 // \}
254
258 // \{
259
266 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
267 {
268 BoundaryTypes values;
269
270 if(globalPos[0] > this->gridGeometry().bBoxMax()[0] - eps_)
271 {
272 values.setAllDirichlet();
273 }
274 else
275 {
276 values.setAllNeumann();
277 }
278
279 return values;
280 }
281
287 PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
288 {
289 PrimaryVariables values = initial_(globalPos);
290 return values;
291 }
292
310 NumEqVector neumann(const Element& element,
311 const FVElementGeometry& fvGeometry,
312 const ElementVolumeVariables& elemVolVars,
313 const ElementFluxVariablesCache& elemFluxVarsCache,
314 const SubControlVolumeFace& scvf) const
315 {
316 NumEqVector flux(0.0);
317 const auto& globalPos = scvf.ipGlobal();
318 const auto& scv = fvGeometry.scv(scvf.insideScvIdx());
319
320 if(globalPos[0] < eps_)
321 {
322 flux[contiH2OEqIdx] = -darcyVelocity_*elemVolVars[scv].molarDensity();
323 flux[contiN2EqIdx] = -darcyVelocity_*elemVolVars[scv].molarDensity()*elemVolVars[scv].moleFraction(0, N2Idx);
324 flux[energyEqIdx] = -darcyVelocity_
325 *elemVolVars[scv].density()
326 *IapwsH2O::liquidEnthalpy(temperatureHigh_, elemVolVars[scv].pressure());
327 }
328
329 return flux;
330 }
331
332 // \}
333
337 // \{
338
350 NumEqVector sourceAtPos(const GlobalPosition &globalPos) const
351 { return NumEqVector(0.0); }
352
361 PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
362 { return initial_(globalPos); }
363
364 // \}
365private:
366
367 // the internal method for the initial condition
368 PrimaryVariables initial_(const GlobalPosition &globalPos) const
369 {
370 PrimaryVariables priVars;
371 priVars[pressureIdx] = pressureLow_; // initial condition for the pressure
372 priVars[N2Idx] = 1e-10; // initial condition for the N2 molefraction
373 priVars[temperatureIdx] = temperatureLow_;
374 return priVars;
375 }
376 static constexpr Scalar eps_ = 1e-6;
377 Scalar temperatureHigh_;
378 Scalar temperatureLow_;
379 Scalar pressureHigh_;
380 Scalar pressureLow_;
381 Scalar darcyVelocity_;
382
383 std::vector<Scalar> temperatureExact_;
384 };
385
386} // end namespace Dumux
387
388#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 .
An adapter for multi-phase fluid systems to be used with (compositional) one-phase models.
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 pressure(int phaseIdx) noexcept
I/O name of pressure for multiphase systems.
Definition: name.hh:34
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
UndefinedProperty type
Definition: common/properties.hh:57
Property to specify the type of a problem which has to be solved.
Definition: common/properties.hh:69
Property whether to use moles or kg as amount unit for balance equations.
Definition: common/properties.hh:102
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
An adapter for multi-phase fluid systems to be used with (compositional) one-phase models.
Definition: 1padapter.hh:46
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 OnePTwoCModel in combination with the NI model for a convection problem.
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/convection/problem.hh:124
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
Evaluates the initial value for a control volume.
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/convection/problem.hh:361
OnePTwoCNIConvectionProblem(std::shared_ptr< const GridGeometry > gridGeometry)
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/convection/problem.hh:170
void updateExactTemperature(const SolutionVector &curSol, Scalar time)
Udpate the analytical temperature.
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/convection/problem.hh:199
const std::vector< Scalar > & getExactTemperature()
Get the analytical temperature.
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/convection/problem.hh:193
Scalar temperature() const
Returns the temperature within the domain [K].
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/convection/problem.hh:250
NumEqVector sourceAtPos(const GlobalPosition &globalPos) const
Evaluates the source term for all phases within a given sub-control volume.
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/convection/problem.hh:350
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/1pnc/implicit/1p2c/nonisothermal/convection/problem.hh:310
PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
Evaluates the boundary conditions for a Dirichlet Sboundary segment.
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/convection/problem.hh:287
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/1pnc/implicit/1p2c/nonisothermal/convection/problem.hh:266
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/convection/problem.hh:55
std::tuple< OnePNCNI > InheritsFrom
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/convection/problem.hh:55
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/convection/problem.hh:56
std::tuple< OnePTwoCNIConvection, CCTpfaModel > InheritsFrom
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/convection/problem.hh:56
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/convection/problem.hh:57
std::tuple< OnePTwoCNIConvection, CCMpfaModel > InheritsFrom
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/convection/problem.hh:57
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/convection/problem.hh:58
std::tuple< OnePTwoCNIConvection, BoxModel > InheritsFrom
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/convection/problem.hh:58
Dune::YaspGrid< 2 > type
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/convection/problem.hh:67
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/convection/problem.hh:78
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/convection/problem.hh:88
GetPropType< TypeTag, Properties::GridGeometry > GridGeometry
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/convection/problem.hh:87
Definition of the spatial parameters for the 1pnc test problems.
Definition: porousmediumflow/1pnc/implicit/1p2c/spatialparams.hh:41
Adaption of the fully implicit model to the one-phase n-component flow model.
Base class for all porous media problems.