3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
test/porousmediumflow/3p/implicit/conduction/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 *****************************************************************************/
26#ifndef DUMUX_3PNI_CONDUCTION_PROBLEM_HH
27#define DUMUX_3PNI_CONDUCTION_PROBLEM_HH
28
29#include <cmath>
30#include <dune/grid/yaspgrid.hh>
31
41
42#include "spatialparams.hh"
43
44namespace Dumux {
45
46template <class TypeTag>
47class ThreePNIConductionProblem;
48
49namespace Properties {
50// Create new type tags
51namespace TTag {
52struct ThreePNIConduction { using InheritsFrom = std::tuple<ThreePNI>; };
53struct ThreePNIConductionBox { using InheritsFrom = std::tuple<ThreePNIConduction, BoxModel>; };
54struct ThreePNIConductionCCTpfa { using InheritsFrom = std::tuple<ThreePNIConduction, CCTpfaModel>; };
55struct ThreePNIConductionCCMpfa { using InheritsFrom = std::tuple<ThreePNIConduction, CCMpfaModel>; };
56} // end namespace TTag
57
58// Set the grid type
59template<class TypeTag>
60struct Grid<TypeTag, TTag::ThreePNIConduction> { using type = Dune::YaspGrid<2>; };
61
62// Set the problem property
63template<class TypeTag>
64struct Problem<TypeTag, TTag::ThreePNIConduction> { using type = ThreePNIConductionProblem<TypeTag>; };
65
66
67// Set the fluid system
68template<class TypeTag>
69struct FluidSystem<TypeTag, TTag::ThreePNIConduction>
71
72// Set the spatial parameters
73template<class TypeTag>
74struct SpatialParams<TypeTag, TTag::ThreePNIConduction>
75{
79};
80}// end namespace Properties
81
82
108template <class TypeTag>
110{
112
119 using ThermalConductivityModel = GetPropType<TypeTag, Properties::ThermalConductivityModel>;
124
125 // copy some indices for convenience
127 enum {
128 // index of the primary variables
129 pressureIdx = Indices::pressureIdx,
130 swIdx = Indices::swIdx,
131 snIdx = Indices::snIdx,
132 temperatureIdx = Indices::temperatureIdx,
133 wPhaseIdx = FluidSystem::wPhaseIdx
134 };
135
136 enum { dimWorld = GridView::dimensionworld };
137
138 using Element = typename GridView::template Codim<0>::Entity;
139 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
140
141public:
142 ThreePNIConductionProblem(std::shared_ptr<const GridGeometry> gridGeometry)
144 {
145 //initialize fluid system
146 FluidSystem::init();
147
148 name_ = getParam<std::string>("Problem.Name");
149 temperatureHigh_ = 300.0;
150 temperatureExact_.resize(gridGeometry->numDofs());
151 }
152
154 const std::vector<Scalar>& getExactTemperature()
155 {
156 return temperatureExact_;
157 }
158
160 void updateExactTemperature(const SolutionVector& curSol, Scalar time)
161 {
162 const auto someElement = *(elements(this->gridGeometry().gridView()).begin());
163
164 const auto someElemSol = elementSolution(someElement, curSol, this->gridGeometry());
165 const auto someInitSol = initialAtPos(someElement.geometry().center());
166
167 auto someFvGeometry = localView(this->gridGeometry());
168 someFvGeometry.bindElement(someElement);
169 const auto someScv = *(scvs(someFvGeometry).begin());
170
171 VolumeVariables volVars;
172 volVars.update(someElemSol, *this, someElement, someScv);
173
174 const auto porosity = this->spatialParams().porosity(someElement, someScv, someElemSol);
175 const auto densityW = volVars.density(wPhaseIdx);
176 const auto heatCapacityW = IapwsH2O::liquidHeatCapacity(someInitSol[temperatureIdx], someInitSol[pressureIdx]);
177 const auto densityS = volVars.solidDensity();
178 const auto heatCapacityS = volVars.solidHeatCapacity();
179 const auto storage = densityW*heatCapacityW*porosity + densityS*heatCapacityS*(1 - porosity);
180 const auto effectiveThermalConductivity = ThermalConductivityModel::effectiveThermalConductivity(volVars);
181 using std::max;
182 time = max(time, 1e-10);
183 for (const auto& element : elements(this->gridGeometry().gridView()))
184 {
185 auto fvGeometry = localView(this->gridGeometry());
186 fvGeometry.bindElement(element);
187
188 for (auto&& scv : scvs(fvGeometry))
189 {
190 auto globalIdx = scv.dofIndex();
191 const auto& globalPos = scv.dofPosition();
192 using std::erf;
193 using std::sqrt;
194 temperatureExact_[globalIdx] = temperatureHigh_ + (someInitSol[temperatureIdx] - temperatureHigh_)
195 *erf(0.5*sqrt(globalPos[0]*globalPos[0]*storage/time/effectiveThermalConductivity));
196
197 }
198 }
199 }
200
204 // \{
205
211 const std::string& name() const
212 {
213 return name_;
214 }
215 // \}
216
220 // \{
221
228 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
229 {
230 BoundaryTypes values;
231 if(globalPos[0] < eps_ || globalPos[0] > this->gridGeometry().bBoxMax()[0] - eps_)
232 {
233 values.setAllDirichlet();
234 }
235 else
236 {
237 values.setAllNeumann();
238 }
239 return values;
240 }
241
247 PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
248 {
249 PrimaryVariables values = initialAtPos(globalPos);
250
251 if (globalPos[0] < eps_)
252 values[temperatureIdx] = temperatureHigh_;
253 return values;
254 }
255
264 NumEqVector neumannAtPos(const GlobalPosition &globalPos) const
265 {
266 return NumEqVector(0.0);
267 }
268
269 // \}
270
274 // \{
275
288 NumEqVector sourceAtPos(const GlobalPosition &globalPos) const
289 {
290 return NumEqVector(0.0);
291 }
292
299 PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
300 {
301 PrimaryVariables values;
302 values[pressureIdx] = 1e5; // initial condition for the pressure
303 values[swIdx] = 1.0; // initial condition for the wetting phase saturation
304 values[snIdx] = 1e-5; // initial condition for the non-wetting phase saturation
305 values[temperatureIdx] = 290;
306 return values;
307 }
308
309 // \}
310
311private:
312 Scalar temperatureHigh_;
313 static constexpr Scalar eps_ = 1e-6;
314 std::string name_;
315 std::vector<Scalar> temperatureExact_;
316};
317
318} // end namespace Dumux
319#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
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
Test for the ThreePModel in combination with the NI model for a conduction problem.
Definition: test/porousmediumflow/3p/implicit/conduction/problem.hh:110
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/conduction/problem.hh:228
NumEqVector neumannAtPos(const GlobalPosition &globalPos) const
Evaluates the boundary conditions for a Neumann boundary segment.
Definition: test/porousmediumflow/3p/implicit/conduction/problem.hh:264
const std::string & name() const
The problem name.
Definition: test/porousmediumflow/3p/implicit/conduction/problem.hh:211
const std::vector< Scalar > & getExactTemperature()
Get the analytical temperature.
Definition: test/porousmediumflow/3p/implicit/conduction/problem.hh:154
ThreePNIConductionProblem(std::shared_ptr< const GridGeometry > gridGeometry)
Definition: test/porousmediumflow/3p/implicit/conduction/problem.hh:142
void updateExactTemperature(const SolutionVector &curSol, Scalar time)
Udpate the analytical temperature.
Definition: test/porousmediumflow/3p/implicit/conduction/problem.hh:160
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
Evaluates the initial value for a control volume.
Definition: test/porousmediumflow/3p/implicit/conduction/problem.hh:299
NumEqVector sourceAtPos(const GlobalPosition &globalPos) const
Evaluates the source term for all phases within a given sub-controlvolume.
Definition: test/porousmediumflow/3p/implicit/conduction/problem.hh:288
PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
Evaluates the boundary conditions for a Dirichlet boundary segment.
Definition: test/porousmediumflow/3p/implicit/conduction/problem.hh:247
Definition: test/porousmediumflow/3p/implicit/conduction/problem.hh:52
std::tuple< ThreePNI > InheritsFrom
Definition: test/porousmediumflow/3p/implicit/conduction/problem.hh:52
Definition: test/porousmediumflow/3p/implicit/conduction/problem.hh:53
std::tuple< ThreePNIConduction, BoxModel > InheritsFrom
Definition: test/porousmediumflow/3p/implicit/conduction/problem.hh:53
Definition: test/porousmediumflow/3p/implicit/conduction/problem.hh:54
std::tuple< ThreePNIConduction, CCTpfaModel > InheritsFrom
Definition: test/porousmediumflow/3p/implicit/conduction/problem.hh:54
Definition: test/porousmediumflow/3p/implicit/conduction/problem.hh:55
std::tuple< ThreePNIConduction, CCMpfaModel > InheritsFrom
Definition: test/porousmediumflow/3p/implicit/conduction/problem.hh:55
Dune::YaspGrid< 2 > type
Definition: test/porousmediumflow/3p/implicit/conduction/problem.hh:60
GetPropType< TypeTag, Properties::GridGeometry > GridGeometry
Definition: test/porousmediumflow/3p/implicit/conduction/problem.hh:76
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: test/porousmediumflow/3p/implicit/conduction/problem.hh:77
Definition of the spatial parameters for the 3pni problems.
Definition: porousmediumflow/3p/implicit/conduction/spatialparams.hh:44
Adaption of the fully implicit scheme to the three-phase flow model.
Base class for all porous media problems.
Definition of the spatial parameters for the MaxwellStefan problem.