3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
problem_convection.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 *****************************************************************************/
28#ifndef DUMUX_1PNI_CONVECTION_PROBLEM_HH
29#define DUMUX_1PNI_CONVECTION_PROBLEM_HH
30
31#include <cmath>
32#include <dune/grid/yaspgrid.hh>
33
43#include "spatialparams.hh"
44
45namespace Dumux {
46
47template <class TypeTag>
48class OnePNIConvectionProblem;
49
50namespace Properties {
51
52// Create new type tags
53namespace TTag {
54struct OnePNIConvection { using InheritsFrom = std::tuple<OnePNI>; };
55struct OnePNIConvectionBox { using InheritsFrom = std::tuple<OnePNIConvection, BoxModel>; };
56struct OnePNIConvectionCCTpfa { using InheritsFrom = std::tuple<OnePNIConvection, CCTpfaModel>; };
57struct OnePNIConvectionCCMpfa { using InheritsFrom = std::tuple<OnePNIConvection, CCMpfaModel>; };
58} // end namespace TTag
59
60// Set the grid type
61template<class TypeTag>
62struct Grid<TypeTag, TTag::OnePNIConvection> { using type = Dune::YaspGrid<1>; };
63
64// Set the problem property
65template<class TypeTag>
66struct Problem<TypeTag, TTag::OnePNIConvection> { using type = OnePNIConvectionProblem<TypeTag>; };
67
68// Set the fluid system
69template<class TypeTag>
70struct FluidSystem<TypeTag, TTag::OnePNIConvection>
71{
74};
75
76// Set the spatial parameters
77template<class TypeTag>
78struct SpatialParams<TypeTag, TTag::OnePNIConvection>
79{
83};
84} // end namespace Properties
85
109template <class TypeTag>
111{
115 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
116 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
120
122 using ElementVolumeVariables = typename GridVariables::GridVolumeVariables::LocalView;
123 using ElementFluxVariablesCache = typename GridVariables::GridFluxVariablesCache::LocalView;
124 using VolumeVariables = typename GridVariables::GridVolumeVariables::VolumeVariables;
127
128 enum { dimWorld = GridView::dimensionworld };
129
130 // copy some indices for convenience
132 enum {
133 // indices of the primary variables
134 pressureIdx = Indices::pressureIdx,
135 temperatureIdx = Indices::temperatureIdx
136 };
137 enum {
138 // index of the transport equation
139 conti0EqIdx = Indices::conti0EqIdx,
140 energyEqIdx = Indices::energyEqIdx
141 };
142
144 using Element = typename GridView::template Codim<0>::Entity;
145 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
147
148public:
149 OnePNIConvectionProblem(std::shared_ptr<const GridGeometry> gridGeometry, const std::string& paramGroup)
151 {
152 //initialize fluid system
153 FluidSystem::init();
154
155 name_ = getParam<std::string>("Problem.Name");
156 darcyVelocity_ = getParam<Scalar>("Problem.DarcyVelocity");
157
158 temperatureHigh_ = 291.0;
159 temperatureLow_ = 290.0;
160 pressureHigh_ = 2e5;
161 pressureLow_ = 1e5;
162
163 temperatureExact_.resize(this->gridGeometry().numDofs());
164 }
165
167 const std::vector<Scalar>& getExactTemperature()
168 {
169 return temperatureExact_;
170 }
171
173 void updateExactTemperature(const SolutionVector& curSol, Scalar time)
174 {
175 const auto someElement = *(elements(this->gridGeometry().gridView()).begin());
176
177 auto someElemSol = elementSolution(someElement, curSol, this->gridGeometry());
178 const auto someInitSol = initialAtPos(someElement.geometry().center());
179
180 auto someFvGeometry = localView(this->gridGeometry());
181 someFvGeometry.bindElement(someElement);
182 const auto someScv = *(scvs(someFvGeometry).begin());
183
184 VolumeVariables volVars;
185 volVars.update(someElemSol, *this, someElement, someScv);
186
187 const auto porosity = this->spatialParams().porosity(someElement, someScv, someElemSol);
188 const auto densityW = volVars.density();
189 const auto heatCapacityW = IapwsH2O::liquidHeatCapacity(someInitSol[temperatureIdx], someInitSol[pressureIdx]);
190 const auto storageW = densityW*heatCapacityW*porosity;
191 const auto densityS = volVars.solidDensity();
192 const auto heatCapacityS = volVars.solidHeatCapacity();
193 const auto storageTotal = storageW + densityS*heatCapacityS*(1 - porosity);
194 std::cout << "storage: " << storageTotal << '\n';
195
196 using std::max;
197 time = max(time, 1e-10);
198 const Scalar retardedFrontVelocity = darcyVelocity_*storageW/storageTotal/porosity;
199 std::cout << "retarded velocity: " << retardedFrontVelocity << '\n';
200
201 for (const auto& element : elements(this->gridGeometry().gridView()))
202 {
203 auto fvGeometry = localView(this->gridGeometry());
204 fvGeometry.bindElement(element);
205 for (auto&& scv : scvs(fvGeometry))
206 {
207 auto dofIdxGlobal = scv.dofIndex();
208 auto dofPosition = scv.dofPosition();
209 temperatureExact_[dofIdxGlobal] = (dofPosition[0] < retardedFrontVelocity*time) ? temperatureHigh_ : temperatureLow_;
210 }
211 }
212 }
213
217 // \{
218
224 const std::string& name() const
225 {
226 return name_;
227 }
228
229 // \}
230
234 // \{
235
242 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
243 {
244 BoundaryTypes bcTypes;
245
246 if(globalPos[0] > this->gridGeometry().bBoxMax()[0] - eps_)
247 bcTypes.setAllDirichlet();
248 else
249 bcTypes.setAllNeumann();
250
251 return bcTypes;
252 }
253
261 PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
262 {
263 return initial_(globalPos);
264 }
265
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();
294 values[energyEqIdx] = values[conti0EqIdx]*IapwsH2O::liquidEnthalpy(temperatureHigh_, volVars.pressure());
295 }
296 return values;
297 }
298
299 // \}
300
304 // \{
305
314 PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
315 {
316 return initial_(globalPos);
317 }
318
319 // \}
320
321private:
322 // the internal method for the initial condition
323 PrimaryVariables initial_(const GlobalPosition &globalPos) const
324 {
325 PrimaryVariables priVars(0.0);
326 priVars[pressureIdx] = pressureLow_; // initial condition for the pressure
327 priVars[temperatureIdx] = temperatureLow_;
328 return priVars;
329 }
330
331 Scalar temperatureHigh_;
332 Scalar temperatureLow_;
333 Scalar pressureHigh_;
334 Scalar pressureLow_;
335 Scalar darcyVelocity_;
336 static constexpr Scalar eps_ = 1e-6;
337 std::string name_;
338 std::vector<Scalar> temperatureExact_;
339};
340
341} // end namespace Dumux
342
343#endif // DUMUX_1PNI_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 mpfa.
Properties for all models using cell-centered finite volume scheme with TPFA.
Material properties of pure water .
Reation for a simple effective thermal conductivity.
A liquid phase consisting of a single component.
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 std::string & paramGroup() const
The parameter group in which to retrieve runtime parameters.
Definition: common/fvproblem.hh:592
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 liquid phase consisting of a single component.
Definition: 1pliquid.hh:46
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 OnePModel in combination with the NI model for a convection problem.
Definition: problem_convection.hh:111
const std::vector< Scalar > & getExactTemperature()
Get exact temperature vector for output.
Definition: problem_convection.hh:167
OnePNIConvectionProblem(std::shared_ptr< const GridGeometry > gridGeometry, const std::string &paramGroup)
Definition: problem_convection.hh:149
const std::string & name() const
The problem name.
Definition: problem_convection.hh:224
PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
Evaluates the boundary conditions for a Dirichlet control volume.
Definition: problem_convection.hh:261
void updateExactTemperature(const SolutionVector &curSol, Scalar time)
Udpate the analytical temperature.
Definition: problem_convection.hh:173
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 in dependency on the current solutio...
Definition: problem_convection.hh:281
BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
Specifies which kind of boundary condition should be used for which equation on a given boundary segm...
Definition: problem_convection.hh:242
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
Evaluates the initial value for a control volume.
Definition: problem_convection.hh:314
Definition: problem_convection.hh:54
std::tuple< OnePNI > InheritsFrom
Definition: problem_convection.hh:54
Definition: problem_convection.hh:55
std::tuple< OnePNIConvection, BoxModel > InheritsFrom
Definition: problem_convection.hh:55
Definition: problem_convection.hh:56
std::tuple< OnePNIConvection, CCTpfaModel > InheritsFrom
Definition: problem_convection.hh:56
Definition: problem_convection.hh:57
std::tuple< OnePNIConvection, CCMpfaModel > InheritsFrom
Definition: problem_convection.hh:57
Dune::YaspGrid< 1 > type
Definition: problem_convection.hh:62
GetPropType< TypeTag, Properties::GridGeometry > GridGeometry
Definition: problem_convection.hh:80
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: problem_convection.hh:81
Definition of the spatial parameters for the 1pni problems.
Definition: porousmediumflow/1p/implicit/nonisothermal/spatialparams.hh:41
A single-phase, isothermal flow model using the fully implicit scheme.
Base class for all porous media problems.
Definition of the spatial parameters for the MaxwellStefan problem.