3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
test/porousmediumflow/1pnc/implicit/1p2c/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_1P2CNI_CONDUCTION_TEST_PROBLEM_HH
27#define DUMUX_1P2CNI_CONDUCTION_TEST_PROBLEM_HH
28
29#if HAVE_UG
30#include <dune/grid/uggrid.hh>
31#endif
32#include <dune/grid/yaspgrid.hh>
33
40
44#include "../../spatialparams.hh"
45
46namespace Dumux {
47
48template <class TypeTag>
49class OnePTwoCNIConductionProblem;
50
51namespace Properties {
52// Create new type tags
53namespace TTag {
54struct OnePTwoCNIConduction { using InheritsFrom = std::tuple<OnePNCNI>; };
55struct OnePTwoCNIConductionCCTpfa { using InheritsFrom = std::tuple<OnePTwoCNIConduction, CCTpfaModel>; };
56struct OnePTwoCNIConductionCCMpfa { using InheritsFrom = std::tuple<OnePTwoCNIConduction, CCMpfaModel>; };
57struct OnePTwoCNIConductionBox { using InheritsFrom = std::tuple<OnePTwoCNIConduction, BoxModel>; };
58} // end namespace TTag
59
60// Set the grid type
61#if HAVE_UG
62template<class TypeTag>
63struct Grid<TypeTag, TTag::OnePTwoCNIConduction> { using type = Dune::UGGrid<2>; };
64#else
65template<class TypeTag>
66struct Grid<TypeTag, TTag::OnePTwoCNIConduction> { using type = Dune::YaspGrid<2>; };
67#endif
68
69// Set the problem property
70template<class TypeTag>
71struct Problem<TypeTag, TTag::OnePTwoCNIConduction> { using type = OnePTwoCNIConductionProblem<TypeTag>; };
72
73// Set fluid configuration
74template<class TypeTag>
75struct FluidSystem<TypeTag, TTag::OnePTwoCNIConduction>
76{
80};
81
82// Set the spatial parameters
83template<class TypeTag>
84struct SpatialParams<TypeTag, TTag::OnePTwoCNIConduction>
85{
89};
90
91// Define whether mole(true) or mass (false) fractions are used
92template<class TypeTag>
93struct UseMoles<TypeTag, TTag::OnePTwoCNIConduction> { static constexpr bool value = true; };
94}
95
120template <class TypeTag>
122{
124
133 using Element = typename GridView::template Codim<0>::Entity;
134 using ThermalConductivityModel = GetPropType<TypeTag, Properties::ThermalConductivityModel>;
138
139 // copy some indices for convenience
140 enum
141 {
142 // indices of the primary variables
143 pressureIdx = Indices::pressureIdx,
144 temperatureIdx = Indices::temperatureIdx,
145
146 N2Idx = FluidSystem::compIdx(FluidSystem::MultiPhaseFluidSystem::N2Idx)
147 };
148
150 static constexpr bool useMoles = getPropValue<TypeTag, Properties::UseMoles>();
151 static const int dimWorld = GridView::dimensionworld;
152 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
153
154public:
155 OnePTwoCNIConductionProblem(std::shared_ptr<const GridGeometry> gridGeometry)
156 : ParentType(gridGeometry), temperatureHigh_(300.0)
157 {
158 //initialize fluid system
159 FluidSystem::init();
160
161 // stating in the console whether mole or mass fractions are used
162 if(useMoles)
163 std::cout<<"problem uses mole fractions"<<std::endl;
164 else
165 std::cout<<"problem uses mass fractions"<<std::endl;
166
167 temperatureExact_.resize(gridGeometry->numDofs(), 290.0);
168 }
169
171 const std::vector<Scalar>& getExactTemperature()
172 {
173 return temperatureExact_;
174 }
175
177 void updateExactTemperature(const SolutionVector& curSol, Scalar time)
178 {
179 const auto someElement = *(elements(this->gridGeometry().gridView()).begin());
180
181 auto someElemSol = elementSolution(someElement, curSol, this->gridGeometry());
182 const auto someInitSol = initialAtPos(someElement.geometry().center());
183
184 auto someFvGeometry = localView(this->gridGeometry());
185 someFvGeometry.bindElement(someElement);
186 const auto someScv = *(scvs(someFvGeometry).begin());
187
188 VolumeVariables volVars;
189 volVars.update(someElemSol, *this, someElement, someScv);
190
191 const auto porosity = this->spatialParams().porosity(someElement, someScv, someElemSol);
192 const auto densityW = volVars.density();
193 const auto heatCapacityW = IapwsH2O::liquidHeatCapacity(someInitSol[temperatureIdx], someInitSol[pressureIdx]);
194 const auto densityS = volVars.solidDensity();
195 const auto heatCapacityS = volVars.solidHeatCapacity();
196 const auto storage = densityW*heatCapacityW*porosity + densityS*heatCapacityS*(1 - porosity);
197 const auto effectiveThermalConductivity = ThermalConductivityModel::effectiveThermalConductivity(volVars);
198 using std::max;
199 time = max(time, 1e-10);
200 for (const auto& element : elements(this->gridGeometry().gridView()))
201 {
202 auto fvGeometry = localView(this->gridGeometry());
203 fvGeometry.bindElement(element);
204
205 for (auto&& scv : scvs(fvGeometry))
206 {
207 auto globalIdx = scv.dofIndex();
208 const auto& globalPos = scv.dofPosition();
209 using std::erf;
210 using std::sqrt;
211 temperatureExact_[globalIdx] = temperatureHigh_ + (someInitSol[temperatureIdx] - temperatureHigh_)
212 *erf(0.5*sqrt(globalPos[0]*globalPos[0]*storage/time/effectiveThermalConductivity));
213
214 }
215 }
216 }
217
221 // \{
222
228 Scalar temperature() const
229 { return 273.15 + 20; } // in [K]
230
231 // \}
232
236 // \{
237
244 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
245 {
246 BoundaryTypes values;
247
248 if(globalPos[0] < eps_ || globalPos[0] > this->gridGeometry().bBoxMax()[0] - eps_)
249 {
250 values.setAllDirichlet();
251 }
252 else
253 {
254 values.setAllNeumann();
255 }
256
257 return values;
258 }
259
265 PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
266 {
267 PrimaryVariables values = initial_(globalPos);
268
269 // condition for the temperature at left boundary
270 if (globalPos[0] < eps_)
271 values[temperatureIdx] = temperatureHigh_;
272
273 return values;
274 }
275
279 NumEqVector neumannAtPos(const GlobalPosition &globalPos) const
280 { return NumEqVector(0.0); }
281
282 // \}
283
287 // \{
288
300 NumEqVector sourceAtPos(const GlobalPosition &globalPos) const
301 { return NumEqVector(0.0); }
302
311 PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
312 { return initial_(globalPos); }
313
314 // \}
315private:
316
317 // the internal method for the initial condition
318 PrimaryVariables initial_(const GlobalPosition &globalPos) const
319 {
320 PrimaryVariables priVars;
321 priVars[pressureIdx] = 1e5; // initial condition for the pressure
322 priVars[N2Idx] = 1e-5; // initial condition for the N2 molefraction
323 priVars[temperatureIdx] = 290.;
324 return priVars;
325 }
326 static constexpr Scalar eps_ = 1e-6;
327 Scalar temperatureHigh_;
328 std::vector<Scalar> temperatureExact_;
329 };
330
331} // end namespace Dumux
332
333#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 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
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
Definition of a problem, for the 1pnc problem.
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/conduction/problem.hh:122
Scalar temperature() const
Returns the temperature within the domain [K].
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/conduction/problem.hh:228
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
Evaluates the initial value for a control volume.
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/conduction/problem.hh:311
OnePTwoCNIConductionProblem(std::shared_ptr< const GridGeometry > gridGeometry)
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/conduction/problem.hh:155
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/conduction/problem.hh:300
void updateExactTemperature(const SolutionVector &curSol, Scalar time)
Udpate the analytical temperature.
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/conduction/problem.hh:177
const std::vector< Scalar > & getExactTemperature()
Get the analytical temperature.
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/conduction/problem.hh:171
NumEqVector neumannAtPos(const GlobalPosition &globalPos) const
Evaluates the boundary conditions for a Neumann boundary segment.
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/conduction/problem.hh:279
PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
Evaluates the boundary conditions for a Dirichlet boundary segment.
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/conduction/problem.hh:265
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/conduction/problem.hh:244
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/conduction/problem.hh:54
std::tuple< OnePNCNI > InheritsFrom
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/conduction/problem.hh:54
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/conduction/problem.hh:55
std::tuple< OnePTwoCNIConduction, CCTpfaModel > InheritsFrom
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/conduction/problem.hh:55
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/conduction/problem.hh:56
std::tuple< OnePTwoCNIConduction, CCMpfaModel > InheritsFrom
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/conduction/problem.hh:56
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/conduction/problem.hh:57
std::tuple< OnePTwoCNIConduction, BoxModel > InheritsFrom
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/conduction/problem.hh:57
Dune::YaspGrid< 2 > type
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/conduction/problem.hh:66
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/conduction/problem.hh:77
GetPropType< TypeTag, Properties::GridGeometry > GridGeometry
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/conduction/problem.hh:86
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/conduction/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.