3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
test/porousmediumflow/1pnc/implicit/nonequilibrium/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 OnePTwoCThermalNonequilibriumProblem;
50
51namespace Properties {
52// Create new type tags
53namespace TTag {
54struct OnePTwoCThermalNonequilibrium { using InheritsFrom = std::tuple<OnePNCNonEquil>; };
55struct OnePTwoCThermalNonequilibriumCCTpfa { using InheritsFrom = std::tuple<OnePTwoCThermalNonequilibrium, CCTpfaModel>; };
56struct OnePTwoCThermalNonequilibriumBox { using InheritsFrom = std::tuple<OnePTwoCThermalNonequilibrium, BoxModel>; };
57} // end namespace TTag
58
59template<class TypeTag>
60struct Grid<TypeTag, TTag::OnePTwoCThermalNonequilibrium> { using type = Dune::YaspGrid<2>; };
61
62// Set the problem property
63template<class TypeTag>
64struct Problem<TypeTag, TTag::OnePTwoCThermalNonequilibrium> { using type = OnePTwoCThermalNonequilibriumProblem<TypeTag>; };
65
66// Set fluid configuration
67template<class TypeTag>
68struct FluidSystem<TypeTag, TTag::OnePTwoCThermalNonequilibrium>
69{
73};
74
75// Set the spatial parameters
76template<class TypeTag>
77struct SpatialParams<TypeTag, TTag::OnePTwoCThermalNonequilibrium>
78{
82};
83
84// Define whether mole(true) or mass (false) fractions are used
85template<class TypeTag>
86struct UseMoles<TypeTag, TTag::OnePTwoCThermalNonequilibrium> { static constexpr bool value = true; };
87}
88
106template <class TypeTag>
108{
110
118 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
120
122 using ElementVolumeVariables = typename GridVariables::GridVolumeVariables::LocalView;
123 using ElementFluxVariablesCache = typename GridVariables::GridFluxVariablesCache::LocalView;
124
125 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
126 using Element = typename GridView::template Codim<0>::Entity;
130
131 // copy some indices for convenience
132 enum
133 {
134 // indices of the primary variables
135 pressureIdx = Indices::pressureIdx,
136 temperatureIdx = Indices::temperatureIdx,
137 temperatureSolidIdx = Indices::temperatureSolidIdx,
138
139 // component indices
140 H2OIdx = FluidSystem::compIdx(FluidSystem::MultiPhaseFluidSystem::H2OIdx),
141 N2Idx = FluidSystem::compIdx(FluidSystem::MultiPhaseFluidSystem::N2Idx),
142
143 // indices of the equations
144 contiH2OEqIdx = Indices::conti0EqIdx + H2OIdx,
145 contiN2EqIdx = Indices::conti0EqIdx + N2Idx,
146 energyEqIdx = Indices::energyEqIdx
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 OnePTwoCThermalNonequilibriumProblem(std::shared_ptr<const GridGeometry> gridGeometry)
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 darcyVelocity_ = getParam<Scalar>("Problem.DarcyVelocity");
168 }
169
170 void setGridVariables(std::shared_ptr<GridVariables> gridVariables)
171 { gridVariables_ = gridVariables; }
172
173 const GridVariables& gridVariables() const
174 { return *gridVariables_; }
175
179 // \{
180
181 // \}
182
186 // \{
187
194 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
195 {
196 BoundaryTypes values;
197
198 if(globalPos[0] < eps_)
199 values.setAllDirichlet();
200 else
201 values.setAllNeumann();
202
203 return values;
204 }
205
211 PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
212 {
213 PrimaryVariables values = initial_(globalPos);
214
215 return values;
216 }
217
235 NumEqVector neumann(const Element& element,
236 const FVElementGeometry& fvGeometry,
237 const ElementVolumeVariables& elemVolVars,
238 const ElementFluxVariablesCache& elemFluxVarsCache,
239 const SubControlVolumeFace& scvf) const
240 {
241 NumEqVector flux(0.0);
242 const auto& globalPos = scvf.ipGlobal();
243 const auto& scv = fvGeometry.scv(scvf.insideScvIdx());
244
245 if (globalPos[0] > this->gridGeometry().bBoxMax()[0] - eps_)
246 {
247 flux[contiH2OEqIdx] = -darcyVelocity_*elemVolVars[scv].molarDensity();
248 flux[contiN2EqIdx] = -darcyVelocity_*elemVolVars[scv].molarDensity()*elemVolVars[scv].moleFraction(0, N2Idx);
249 flux[energyEqIdx] = -darcyVelocity_
250 *elemVolVars[scv].density()
251 *IapwsH2O::liquidEnthalpy(305, elemVolVars[scv].pressure());
252 }
253 return flux;
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
288 // \}
289private:
290
291 // the internal method for the initial condition
292 PrimaryVariables initial_(const GlobalPosition &globalPos) const
293 {
294 PrimaryVariables priVars;
295 priVars[pressureIdx] = 1e5; // initial condition for the pressure
296 priVars[N2Idx] = 1e-5; // initial condition for the N2 molefraction
297 priVars[temperatureIdx] = 285.;
298 priVars[temperatureSolidIdx] = 285.;
299 return priVars;
300 }
301 static constexpr Scalar eps_ = 1e-6;
302 std::shared_ptr<GridVariables> gridVariables_;
303 Scalar darcyVelocity_;
304 };
305
306} // end namespace Dumux
307
308#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
std::string pressure(int phaseIdx) noexcept
I/O name of pressure for multiphase systems.
Definition: name.hh:34
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
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 liquidEnthalpy(Scalar temperature, Scalar pressure)
Specific enthalpy of liquid water .
Definition: h2o.hh:217
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
Definition of a problem, for the 1pnc problem.
Definition: test/porousmediumflow/1pnc/implicit/nonequilibrium/problem.hh:108
OnePTwoCThermalNonequilibriumProblem(std::shared_ptr< const GridGeometry > gridGeometry)
Definition: test/porousmediumflow/1pnc/implicit/nonequilibrium/problem.hh:155
NumEqVector neumann(const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const ElementFluxVariablesCache &elemFluxVarsCache, const SubControlVolumeFace &scvf) const
Evaluates the boundary conditions for a Neumann boundary segment.
Definition: test/porousmediumflow/1pnc/implicit/nonequilibrium/problem.hh:235
NumEqVector sourceAtPos(const GlobalPosition &globalPos) const
Evaluates the source term for all phases within a given sub-control volume.
Definition: test/porousmediumflow/1pnc/implicit/nonequilibrium/problem.hh:274
PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
Evaluates the boundary conditions for a Dirichlet boundary segment.
Definition: test/porousmediumflow/1pnc/implicit/nonequilibrium/problem.hh:211
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
Evaluates the initial value for a control volume.
Definition: test/porousmediumflow/1pnc/implicit/nonequilibrium/problem.hh:285
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/nonequilibrium/problem.hh:194
const GridVariables & gridVariables() const
Definition: test/porousmediumflow/1pnc/implicit/nonequilibrium/problem.hh:173
void setGridVariables(std::shared_ptr< GridVariables > gridVariables)
Definition: test/porousmediumflow/1pnc/implicit/nonequilibrium/problem.hh:170
Definition: test/porousmediumflow/1pnc/implicit/nonequilibrium/problem.hh:54
std::tuple< OnePNCNonEquil > InheritsFrom
Definition: test/porousmediumflow/1pnc/implicit/nonequilibrium/problem.hh:54
Definition: test/porousmediumflow/1pnc/implicit/nonequilibrium/problem.hh:55
std::tuple< OnePTwoCThermalNonequilibrium, CCTpfaModel > InheritsFrom
Definition: test/porousmediumflow/1pnc/implicit/nonequilibrium/problem.hh:55
Definition: test/porousmediumflow/1pnc/implicit/nonequilibrium/problem.hh:56
std::tuple< OnePTwoCThermalNonequilibrium, BoxModel > InheritsFrom
Definition: test/porousmediumflow/1pnc/implicit/nonequilibrium/problem.hh:56
Dune::YaspGrid< 2 > type
Definition: test/porousmediumflow/1pnc/implicit/nonequilibrium/problem.hh:60
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: test/porousmediumflow/1pnc/implicit/nonequilibrium/problem.hh:70
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: test/porousmediumflow/1pnc/implicit/nonequilibrium/problem.hh:80
GetPropType< TypeTag, Properties::GridGeometry > GridGeometry
Definition: test/porousmediumflow/1pnc/implicit/nonequilibrium/problem.hh:79
Definition of the spatial parameters for the 1pnc test problems.
Definition: porousmediumflow/1pnc/implicit/nonequilibrium/spatialparams.hh:43
Adaption of the fully implicit model to the one-phase n-component flow model.
Base class for all porous media problems.
Definition of the spatial parameters for the MaxwellStefan problem.