3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
test/porousmediumflow/richards/implicit/nonisothermal/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_RICHARDS_CONDUCTION_PROBLEM_HH
27#define DUMUX_RICHARDS_CONDUCTION_PROBLEM_HH
28
29#include <cmath>
30#include <dune/grid/yaspgrid.hh>
31
35
40#include "../spatialparams.hh"
41
42namespace Dumux {
43
49template <class TypeTag>
50class RichardsNIConductionProblem;
51
52namespace Properties {
53// Create new type tags
54namespace TTag {
55struct RichardsNIConduction { using InheritsFrom = std::tuple<RichardsNI>; };
56struct RichardsNIConductionBox { using InheritsFrom = std::tuple<RichardsNIConduction, BoxModel>; };
57struct RichardsNIConductionCC { using InheritsFrom = std::tuple<RichardsNIConduction, CCTpfaModel>; };
58} // end namespace TTag
59
60// Set the grid type
61template<class TypeTag>
62struct Grid<TypeTag, TTag::RichardsNIConduction> { using type = Dune::YaspGrid<2>; };
63
64// Set the problem property
65template<class TypeTag>
66struct Problem<TypeTag, TTag::RichardsNIConduction> { using type = RichardsNIConductionProblem<TypeTag>; };
67
68// Set the fluid system
69template<class TypeTag>
70struct FluidSystem<TypeTag, TTag::RichardsNIConduction> { using type = FluidSystems::H2ON2<GetPropType<TypeTag, Properties::Scalar>, FluidSystems::H2ON2DefaultPolicy</*fastButSimplifiedRelations=*/true>>; };
71
72// Set the spatial parameters
73template<class TypeTag>
74struct SpatialParams<TypeTag, TTag::RichardsNIConduction>
75{
79};
80} // end namespace Properties
81
104template <class TypeTag>
106{
108
116 using ThermalConductivityModel = GetPropType<TypeTag, Properties::ThermalConductivityModel>;
120
122 enum { dimWorld = GridView::dimensionworld };
123
124 enum {
125 pressureIdx = Indices::pressureIdx,
126 liquidPhaseOnly = Indices::liquidPhaseOnly,
127 liquidPhaseIdx = FluidSystem::liquidPhaseIdx,
128 temperatureIdx = Indices::temperatureIdx
129 };
130
131 using Element = typename GridView::template Codim<0>::Entity;
132
133 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
134
135public:
136 RichardsNIConductionProblem(std::shared_ptr<const GridGeometry> gridGeometry)
138 {
139 //initialize fluid system
140 FluidSystem::init();
141
142 name_ = getParam<std::string>("Problem.Name");
143 temperatureHigh_ = 300.;
144 temperatureExact_.resize(gridGeometry->numDofs());
145 }
146
148 const std::vector<Scalar>& getExactTemperature()
149 {
150 return temperatureExact_;
151 }
152
154 void updateExactTemperature(const SolutionVector& curSol, Scalar time)
155 {
156 const auto someElement = *(elements(this->gridGeometry().gridView()).begin());
157
158 const auto someElemSol = elementSolution(someElement, curSol, this->gridGeometry());
159 const auto someInitSol = initialAtPos(someElement.geometry().center());
160
161 auto someFvGeometry = localView(this->gridGeometry());
162 someFvGeometry.bindElement(someElement);
163 const auto someScv = *(scvs(someFvGeometry).begin());
164
165 VolumeVariables volVars;
166 volVars.update(someElemSol, *this, someElement, someScv);
167
168 const auto porosity = this->spatialParams().porosity(someElement, someScv, someElemSol);
169 const auto densityW = volVars.density(liquidPhaseIdx);
170 const auto heatCapacityW = IapwsH2O::liquidHeatCapacity(someInitSol[temperatureIdx], someInitSol[pressureIdx]);
171 const auto densityS =volVars.solidDensity();
172 const auto heatCapacityS = volVars.solidHeatCapacity();
173 const auto storage = densityW*heatCapacityW*porosity + densityS*heatCapacityS*(1 - porosity);
174 const auto effectiveThermalConductivity = ThermalConductivityModel::effectiveThermalConductivity(volVars);
175 using std::max;
176 time = max(time, 1e-10);
177 for (const auto& element : elements(this->gridGeometry().gridView()))
178 {
179 auto fvGeometry = localView(this->gridGeometry());
180 fvGeometry.bindElement(element);
181
182 for (auto&& scv : scvs(fvGeometry))
183 {
184 auto globalIdx = scv.dofIndex();
185 const auto& globalPos = scv.dofPosition();
186 using std::erf;
187 using std::sqrt;
188 temperatureExact_[globalIdx] = temperatureHigh_ + (someInitSol[temperatureIdx] - temperatureHigh_)
189 *erf(0.5*sqrt(globalPos[0]*globalPos[0]*storage/time/effectiveThermalConductivity));
190
191 }
192 }
193 }
197 // \{
198
204 const std::string& name() const
205 {
206 return name_;
207 }
208 // \}
209
213 // \{
214
221 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
222 {
223 BoundaryTypes values;
224 if(globalPos[0] < eps_ || globalPos[0] > this->gridGeometry().bBoxMax()[0] - eps_)
225 {
226 values.setAllDirichlet();
227 }
228 else
229 {
230 values.setAllNeumann();
231 }
232 return values;
233 }
234
242 PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
243 {
244 PrimaryVariables values(0.0);
245 values = initial_(globalPos);
246
247 if (globalPos[0] < eps_)
248 {
249 values[temperatureIdx] = temperatureHigh_;
250 }
251 return values;
252 }
253
263 NumEqVector neumannAtPos(const GlobalPosition &globalPos) const
264 {
265 NumEqVector values(0.0);
266 return values;
267 }
268
269 // \}
270
274 // \{
275
283 { return 1e5; };
284
293 PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
294 {
295 return initial_(globalPos);
296 }
297
298 // \}
299
300private:
301 PrimaryVariables initial_(const GlobalPosition &globalPos) const
302 {
303 PrimaryVariables priVars(0.0);
304 priVars.setState(liquidPhaseOnly);
305 priVars[pressureIdx] = 1e5; // initial condition for the pressure
306
307 priVars[temperatureIdx] = 290.;
308 return priVars;
309 }
310
311 Scalar temperatureHigh_;
312 static constexpr Scalar eps_ = 1e-6;
313 std::string name_;
314 int outputInterval_;
315 std::vector<Scalar> temperatureExact_;
316};
317
318} // end namespace Dumux
319#endif // DUMUX_RICHARDSNINI_CONDUCTION_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
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 conduction problem: The simulation ...
Definition: test/porousmediumflow/richards/implicit/nonisothermal/conduction/problem.hh:106
const std::vector< Scalar > & getExactTemperature()
Get the analytical temperature.
Definition: test/porousmediumflow/richards/implicit/nonisothermal/conduction/problem.hh:148
PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
Evaluates the boundary conditions for a Dirichlet boundary segment.
Definition: test/porousmediumflow/richards/implicit/nonisothermal/conduction/problem.hh:242
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
Evaluates the initial value for a control volume.
Definition: test/porousmediumflow/richards/implicit/nonisothermal/conduction/problem.hh:293
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/conduction/problem.hh:221
void updateExactTemperature(const SolutionVector &curSol, Scalar time)
Udpate the analytical temperature.
Definition: test/porousmediumflow/richards/implicit/nonisothermal/conduction/problem.hh:154
Scalar nonWettingReferencePressure() const
Returns the reference pressure [Pa] of the non-wetting fluid phase within a finite volume.
Definition: test/porousmediumflow/richards/implicit/nonisothermal/conduction/problem.hh:282
RichardsNIConductionProblem(std::shared_ptr< const GridGeometry > gridGeometry)
Definition: test/porousmediumflow/richards/implicit/nonisothermal/conduction/problem.hh:136
NumEqVector neumannAtPos(const GlobalPosition &globalPos) const
Evaluates the boundary conditions for a Neumann boundary segment.
Definition: test/porousmediumflow/richards/implicit/nonisothermal/conduction/problem.hh:263
const std::string & name() const
The problem name.
Definition: test/porousmediumflow/richards/implicit/nonisothermal/conduction/problem.hh:204
Definition: test/porousmediumflow/richards/implicit/nonisothermal/conduction/problem.hh:55
std::tuple< RichardsNI > InheritsFrom
Definition: test/porousmediumflow/richards/implicit/nonisothermal/conduction/problem.hh:55
Definition: test/porousmediumflow/richards/implicit/nonisothermal/conduction/problem.hh:56
std::tuple< RichardsNIConduction, BoxModel > InheritsFrom
Definition: test/porousmediumflow/richards/implicit/nonisothermal/conduction/problem.hh:56
Definition: test/porousmediumflow/richards/implicit/nonisothermal/conduction/problem.hh:57
std::tuple< RichardsNIConduction, CCTpfaModel > InheritsFrom
Definition: test/porousmediumflow/richards/implicit/nonisothermal/conduction/problem.hh:57
Dune::YaspGrid< 2 > type
Definition: test/porousmediumflow/richards/implicit/nonisothermal/conduction/problem.hh:62
GetPropType< TypeTag, Properties::GridGeometry > GridGeometry
Definition: test/porousmediumflow/richards/implicit/nonisothermal/conduction/problem.hh:76
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: test/porousmediumflow/richards/implicit/nonisothermal/conduction/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.