3.3.0
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
porousmediumflow/2p/sequential/transport/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 *****************************************************************************/
24#ifndef DUMUX_TRANSPORTPROBLEM_2P_HH
25#define DUMUX_TRANSPORTPROBLEM_2P_HH
26
27#include "properties.hh"
30
31namespace Dumux {
32namespace Properties {
33// Set the model properties
34template<class TypeTag>
35struct Model<TypeTag, TTag::TransportTwoP>
36{
38};
39//this Property should be set by the pressure model, only for a pure transport it is set here for the transportproblem!
40template<class TypeTag>
41struct Velocity<TypeTag, TTag::TransportTwoP> { using type = FVVelocityDefault<TypeTag>; };
42} // end namespace Properties
43
50template<class TypeTag>
51class TransportProblem2P : public OneModelProblem<TypeTag>
52{
53 using Implementation = GetPropType<TypeTag, Properties::Problem>;
55
57 using Grid = typename GridView::Grid;
59
61
62 // material properties
64
66 using Solution = typename SolutionTypes::ScalarSolution;
67
68 using Element = typename GridView::Traits::template Codim<0>::Entity;
69
71
72 enum {
73 dim = Grid::dimension,
74 dimWorld = Grid::dimensionworld
75 };
76 enum
77 {
78 transportEqIdx = Indices::transportEqIdx
79 };
80
81 using GlobalPosition = Dune::FieldVector<Scalar, dimWorld>;
82
83 // private!! copy constructor
85 {}
86
87public:
88
95 TransportProblem2P(TimeManager& timeManager, Grid& grid)
96 : ParentType(timeManager, grid),
97 gravity_(0)
98 {
99 cFLFactor_ = getParam<Scalar>("Impet.CFLFactor");
100
101 spatialParams_ = std::make_shared<SpatialParams>(asImp_());
102
103 gravity_ = 0;
104 if (getParam<bool>("Problem.EnableGravity"))
105 gravity_[dim - 1] = - 9.81;
106 }
107
115 TransportProblem2P(TimeManager& timeManager, Grid& grid, SpatialParams& spatialParams)
116 : ParentType(timeManager, grid),
117 gravity_(0)
118 {
119 cFLFactor_ = getParam<Scalar>("Impet.CFLFactor");
120
121 spatialParams_ = Dune::stackobject_to_shared_ptr<SpatialParams>(spatialParams);
122
123 gravity_ = 0;
124 if (getParam<bool>("Problem.EnableGravity"))
125 gravity_[dim - 1] = - 9.81;
126 }
127
131 // \{
132
139 Scalar temperature(const Element& element) const
140 {
141 return this->asImp_().temperatureAtPos(element.geometry().center());
142 }
143
150 Scalar temperatureAtPos(const GlobalPosition& globalPos) const
151 {
152 // Throw an exception (there is no initial condition)
153 DUNE_THROW(Dune::InvalidStateException,
154 "The problem does not provide "
155 "a temperatureAtPos() method.");
156 }
157
164 Scalar referencePressure(const Element& element) const
165 {
166 return this->asImp_().referencePressureAtPos(element.geometry().center());
167 }
168
175 Scalar referencePressureAtPos(const GlobalPosition& globalPos) const
176 {
177 // Throw an exception (there is no initial condition)
178 DUNE_THROW(Dune::InvalidStateException,
179 "The problem does not provide "
180 "a referencePressureAtPos() method.");
181 }
182
189 const GlobalPosition &gravity() const
190 { return gravity_; }
191
195 SpatialParams &spatialParams()
196 { return *spatialParams_; }
197
201 const SpatialParams &spatialParams() const
202 { return *spatialParams_; }
203
204
212 {
213 // allocate temporary vectors for the updates
214 Solution updateVector;
215
216 Scalar t = this->timeManager().time();
217 Scalar dt = 1e100;
218
219 // obtain the first update and the time step size
220 this->model().update(t, dt, updateVector);
221
222 //make sure t_old + dt is not larger than tend
223 using std::min;
224 dt = min(dt*cFLFactor_, this->timeManager().episodeMaxTimeStepSize());
225 this->timeManager().setTimeStepSize(dt);
226
227 // explicit Euler: Sat <- Sat + dt*N(Sat)
228 this->model().updateTransportedQuantity(updateVector);
229 }
230
231 // \}
232
233private:
235 Implementation &asImp_()
236 { return *static_cast<Implementation *>(this); }
237
239 const Implementation &asImp_() const
240 { return *static_cast<const Implementation *>(this); }
241
242 GlobalPosition gravity_;
243
244 // material properties
245 std::shared_ptr<SpatialParams> spatialParams_;
246
247 Scalar cFLFactor_;
248};
249
250} // end namespace Dumux
251
252#endif
Default implementation of velocity class.
Base class for definition of an sequential diffusion (pressure) or transport problem.
Definition: adapt.hh:29
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type GetProp
get the type of a property (equivalent to old macro GET_PROP(...))
Definition: propertysystem.hh:140
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
GetPropType< TypeTag, Properties::TransportModel > type
Definition: porousmediumflow/2p/sequential/transport/problem.hh:37
Base class for a sequential two-phase transport problem.
Definition: porousmediumflow/2p/sequential/transport/problem.hh:52
TransportProblem2P(TimeManager &timeManager, Grid &grid)
The constructor.
Definition: porousmediumflow/2p/sequential/transport/problem.hh:95
void timeIntegration()
Time integration of the model.
Definition: porousmediumflow/2p/sequential/transport/problem.hh:211
Scalar temperature(const Element &element) const
Returns the temperature within the domain.
Definition: porousmediumflow/2p/sequential/transport/problem.hh:139
const SpatialParams & spatialParams() const
Returns the spatial parameters object.
Definition: porousmediumflow/2p/sequential/transport/problem.hh:201
Scalar referencePressureAtPos(const GlobalPosition &globalPos) const
Returns the reference pressure for evaluation of constitutive relations.
Definition: porousmediumflow/2p/sequential/transport/problem.hh:175
SpatialParams & spatialParams()
Returns the spatial parameters object.
Definition: porousmediumflow/2p/sequential/transport/problem.hh:195
TransportProblem2P(TimeManager &timeManager, Grid &grid, SpatialParams &spatialParams)
The constructor.
Definition: porousmediumflow/2p/sequential/transport/problem.hh:115
const GlobalPosition & gravity() const
Returns the acceleration due to gravity.
Definition: porousmediumflow/2p/sequential/transport/problem.hh:189
Scalar temperatureAtPos(const GlobalPosition &globalPos) const
Returns the temperature within the domain.
Definition: porousmediumflow/2p/sequential/transport/problem.hh:150
Scalar referencePressure(const Element &element) const
Returns the reference pressure for evaluation of constitutive relations.
Definition: porousmediumflow/2p/sequential/transport/problem.hh:164
Default implementation of a velocity class.
Definition: velocitydefault.hh:42
Base class for definition of an sequential diffusion (pressure) or transport problem.
Definition: onemodelproblem.hh:46
TimeManager & timeManager()
Returns TimeManager object used by the simulation.
Definition: onemodelproblem.hh:551
Model & model()
Returns numerical model used for the problem.
Definition: onemodelproblem.hh:575
The type of the mode.
Definition: porousmediumflow/sequential/properties.hh:70
The type velocity reconstruction.
Definition: porousmediumflow/sequential/properties.hh:79
Base file for properties related to sequential models.