3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/transientbc/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_TRANSIENT_BC_TEST_PROBLEM_HH
27#define DUMUX_1P2CNI_TRANSIENT_BC_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 OnePTwoCNITransientBCProblem;
50
51namespace Properties {
52// Create new type tags
53namespace TTag {
54struct OnePTwoCNITransientBC { using InheritsFrom = std::tuple<OnePNCNI>; };
55struct OnePTwoCNITransientBCCCTpfa { using InheritsFrom = std::tuple<OnePTwoCNITransientBC, CCTpfaModel>; };
56struct OnePTwoCNITransientBCCCMpfa { using InheritsFrom = std::tuple<OnePTwoCNITransientBC, CCMpfaModel>; };
57struct OnePTwoCNITransientBCBox { using InheritsFrom = std::tuple<OnePTwoCNITransientBC, BoxModel>; };
58} // end namespace TTag
59
60// Set the grid type
61#if HAVE_UG
62template<class TypeTag>
63struct Grid<TypeTag, TTag::OnePTwoCNITransientBC> { using type = Dune::UGGrid<2>; };
64#else
65template<class TypeTag>
66struct Grid<TypeTag, TTag::OnePTwoCNITransientBC> { using type = Dune::YaspGrid<2>; };
67#endif
68
69// Set the problem property
70template<class TypeTag>
71struct Problem<TypeTag, TTag::OnePTwoCNITransientBC> { using type = OnePTwoCNITransientBCProblem<TypeTag>; };
72
73// Set fluid configuration
74template<class TypeTag>
75struct FluidSystem<TypeTag, TTag::OnePTwoCNITransientBC>
76{
80};
81
82// Set the spatial parameters
83template<class TypeTag>
84struct SpatialParams<TypeTag, TTag::OnePTwoCNITransientBC>
85{
89};
90
91// Define whether mole(true) or mass (false) fractions are used
92template<class TypeTag>
93struct UseMoles<TypeTag, TTag::OnePTwoCNITransientBC> { static constexpr bool value = true; };
94
95#ifndef ENABLECACHING
96#define ENABLECACHING false
97#endif
98
99// Switch on/off caching
100template<class TypeTag>
101struct EnableGridGeometryCache<TypeTag, TTag::OnePTwoCNITransientBC> { static constexpr bool value = ENABLECACHING; };
102template<class TypeTag>
103struct EnableGridFluxVariablesCache<TypeTag, TTag::OnePTwoCNITransientBC> { static constexpr bool value = ENABLECACHING; };
104template<class TypeTag>
105struct EnableGridVolumeVariablesCache<TypeTag, TTag::OnePTwoCNITransientBC> { static constexpr bool value = ENABLECACHING; };
106}
107
133template <class TypeTag>
135{
137
145 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
147 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
148 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
149 using Element = typename GridView::template Codim<0>::Entity;
153
154 // copy some indices for convenience
155 enum
156 {
157 // indices of the primary variables
158 pressureIdx = Indices::pressureIdx,
159 temperatureIdx = Indices::temperatureIdx,
160
161 // component indices
162 H2OIdx = FluidSystem::compIdx(FluidSystem::MultiPhaseFluidSystem::H2OIdx),
163 N2Idx = FluidSystem::compIdx(FluidSystem::MultiPhaseFluidSystem::N2Idx),
164
165 // indices of the equations
166 contiH2OEqIdx = Indices::conti0EqIdx + H2OIdx,
167 contiN2EqIdx = Indices::conti0EqIdx + N2Idx,
168 energyEqIdx = Indices::energyEqIdx
169 };
170
172 static constexpr bool useMoles = getPropValue<TypeTag, Properties::UseMoles>();
173 static const int dimWorld = GridView::dimensionworld;
174 using GlobalPosition = typename SubControlVolumeFace::GlobalPosition;
175
176public:
177 OnePTwoCNITransientBCProblem(std::shared_ptr<const GridGeometry> gridGeometry)
179 {
180 //initialize fluid system
181 FluidSystem::init();
182
183 // stating in the console whether mole or mass fractions are used
184 if(useMoles)
185 std::cout<<"problem uses mole fractions"<<std::endl;
186 else
187 std::cout<<"problem uses mass fractions"<<std::endl;
188 }
189
193 // \{
194
200 Scalar temperature() const
201 { return 273.15 + 20; } // in [K]
202
203 // \}
204
208 // \{
209
216 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
217 {
218 BoundaryTypes values;
219
220 if(globalPos[0] < this->gridGeometry().bBoxMin()[0] + eps_ || globalPos[0] > this->gridGeometry().bBoxMax()[0] - eps_)
221 values.setAllDirichlet();
222 else
223 values.setAllNeumann();
224
225 return values;
226 }
227
233 PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
234 {
235 PrimaryVariables values = initial_(globalPos);
236
237 // make the BCs on the left border time-dependent
238 if (globalPos[0] < this->gridGeometry().bBoxMin()[0] + eps_)
239 {
240 values[pressureIdx] += time_ * 1.0;
241 values[N2Idx] += time_ * 1e-8;
242 values[temperatureIdx] += time_ * 1e-3;
243 }
244
245 return values;
246 }
247
251 NumEqVector neumannAtPos(const GlobalPosition& globalPos) const
252 {
253 return NumEqVector(0.0);
254 }
255
256 // \}
257
261 // \{
262
274 NumEqVector sourceAtPos(const GlobalPosition &globalPos) const
275 { return NumEqVector(0.0); }
276
285 PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
286 { return initial_(globalPos); }
287
293 void setTime(Scalar t)
294 { time_ = t; }
295
296 // \}
297private:
298
299 // the internal method for the initial condition
300 PrimaryVariables initial_(const GlobalPosition& globalPos) const
301 {
302 PrimaryVariables priVars;
303
304 if (globalPos[0] < this->gridGeometry().bBoxMin()[0] + eps_)
305 {
306 priVars[pressureIdx] = 1.1e5; // initial condition for the pressure
307 priVars[N2Idx] = 2e-10; // initial condition for the N2 molefraction
308 priVars[temperatureIdx] = 300.00;
309 }
310 else
311 {
312 priVars[pressureIdx] = 1.0e5;
313 priVars[N2Idx] = 0.0;
314 priVars[temperatureIdx] = 285.00;
315 }
316 return priVars;
317 }
318
319 static constexpr Scalar eps_ = 1e-6;
320 Scalar time_;
321 };
322
323} // end namespace Dumux
324
325#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.
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
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
Definition: common/properties.hh:169
If disabled, the volume variables are not stored (reduces memory, but is slower)
Definition: common/properties.hh:178
specifies if data on flux vars should be saved (faster, but more memory consuming)
Definition: common/properties.hh:188
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
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
Test for the OnePTwoCModel in combination with the NI model for a convection problem.
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/transientbc/problem.hh:135
void setTime(Scalar t)
Set the simulation time.
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/transientbc/problem.hh:293
NumEqVector neumannAtPos(const GlobalPosition &globalPos) const
Evaluates the boundary conditions for a Neumann boundary segment.
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/transientbc/problem.hh:251
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/transientbc/problem.hh:274
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/transientbc/problem.hh:216
OnePTwoCNITransientBCProblem(std::shared_ptr< const GridGeometry > gridGeometry)
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/transientbc/problem.hh:177
PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
Evaluates the boundary conditions for a Dirichlet boundary segment.
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/transientbc/problem.hh:233
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
Evaluates the initial value for a control volume.
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/transientbc/problem.hh:285
Scalar temperature() const
Returns the temperature within the domain [K].
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/transientbc/problem.hh:200
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/transientbc/problem.hh:54
std::tuple< OnePNCNI > InheritsFrom
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/transientbc/problem.hh:54
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/transientbc/problem.hh:55
std::tuple< OnePTwoCNITransientBC, CCTpfaModel > InheritsFrom
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/transientbc/problem.hh:55
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/transientbc/problem.hh:56
std::tuple< OnePTwoCNITransientBC, CCMpfaModel > InheritsFrom
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/transientbc/problem.hh:56
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/transientbc/problem.hh:57
std::tuple< OnePTwoCNITransientBC, BoxModel > InheritsFrom
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/transientbc/problem.hh:57
Dune::YaspGrid< 2 > type
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/transientbc/problem.hh:66
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/transientbc/problem.hh:77
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/transientbc/problem.hh:87
GetPropType< TypeTag, Properties::GridGeometry > GridGeometry
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/transientbc/problem.hh:86
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.
#define ENABLECACHING
Definition: test/porousmediumflow/1pnc/implicit/1p2c/nonisothermal/transientbc/problem.hh:96