3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
test/porousmediumflow/3p3c/implicit/infiltration/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_INFILTRATION_THREEPTHREEC_PROBLEM_HH
27#define DUMUX_INFILTRATION_THREEPTHREEC_PROBLEM_HH
28
29#include <dune/grid/yaspgrid.hh>
30
36
37#include "spatialparams.hh"
38
39namespace Dumux {
40
46template <class TypeTag>
47class InfiltrationThreePThreeCProblem;
48
49namespace Properties {
50// Create new type tags
51namespace TTag {
52struct InfiltrationThreePThreeC { using InheritsFrom = std::tuple<ThreePThreeC>; };
53struct InfiltrationThreePThreeCBox { using InheritsFrom = std::tuple<InfiltrationThreePThreeC, BoxModel>; };
54struct InfiltrationThreePThreeCCCTpfa { using InheritsFrom = std::tuple<InfiltrationThreePThreeC, CCTpfaModel>; };
55} // end namespace TTag
56
57// Set the grid type
58template<class TypeTag>
59struct Grid<TypeTag, TTag::InfiltrationThreePThreeC> { using type = Dune::YaspGrid<2>; };
60
61// Set the problem property
62template<class TypeTag>
63struct Problem<TypeTag, TTag::InfiltrationThreePThreeC> { using type = InfiltrationThreePThreeCProblem<TypeTag>; };
64
65// Set the spatial parameters
66template<class TypeTag>
67struct SpatialParams<TypeTag, TTag::InfiltrationThreePThreeC>
68{
72};
73
74// Set the fluid system
75template<class TypeTag>
76struct FluidSystem<TypeTag, TTag::InfiltrationThreePThreeC>
78}
79
111template <class TypeTag >
113{
115
120
121 // copy some indices for convenience
122 enum {
123 pressureIdx = Indices::pressureIdx,
124 switch1Idx = Indices::switch1Idx,
125 switch2Idx = Indices::switch2Idx,
126
127 // phase state
128 wgPhaseOnly = Indices::wgPhaseOnly,
129
130 contiWEqIdx = Indices::conti0EqIdx + FluidSystem::wCompIdx,
131 contiNEqIdx = Indices::conti0EqIdx + FluidSystem::nCompIdx,
132 contiAEqIdx = Indices::conti0EqIdx + FluidSystem::gCompIdx,
133
134 // world dimension
135 dimWorld = GridView::dimensionworld
136 };
137
142
143 using Element = typename GridView::template Codim<0>::Entity;
144 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
145
146public:
147 InfiltrationThreePThreeCProblem(std::shared_ptr<const GridGeometry> gridGeometry)
149 {
150 temperature_ = 273.15 + 10.0; // -> 10 degrees Celsius
151 FluidSystem::init(/*tempMin=*/temperature_ - 1,
152 /*tempMax=*/temperature_ + 1,
153 /*nTemp=*/3,
154 /*pressMin=*/0.8*1e5,
155 /*pressMax=*/3*1e5,
156 /*nPress=*/200);
157
158 name_ = getParam<std::string>("Problem.Name");
159 }
160
166 const std::string& name() const
167 { return name_; }
168
176 Scalar temperatureAtPos(const GlobalPosition &globalPos) const
177 {
178 return temperature_;
179 }
180
181 // \}
182
186 // \{
187
194 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
195 {
196 BoundaryTypes values;
197 if(globalPos[0] > this->gridGeometry().bBoxMax()[0] - eps_)
198 values.setAllDirichlet();
199 else if(globalPos[0] < this->gridGeometry().bBoxMin()[0] + eps_)
200 values.setAllDirichlet();
201 else
202 values.setAllNeumann();
203 return values;
204 }
205
213 PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
214 { return initial_(globalPos); }
215
224 NumEqVector neumannAtPos(const GlobalPosition &globalPos) const
225 {
226 NumEqVector values(0.0);
227
228 // negative values for injection
229 if ((globalPos[0] < 80.0 + eps_) && (globalPos[0] > 55.0 - eps_) && (globalPos[1] > 10.0 - eps_))
230 {
231 values[contiWEqIdx] = -0.0;
232 //mole flow conversion to mass flow with molar mass M(Mesit.)=0,120 kg/mol --> 1.2e-4 kg/(sm)
233 //the 3p3c model uses mole fractions
234 values[contiNEqIdx] = -0.001;
235 values[contiAEqIdx] = -0.0;
236 }
237
238 return values;
239 }
240
241 // \}
242
246 // \{
247
256 PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
257 { return initial_(globalPos); }
258
259private:
260 // internal method for the initial condition
261 PrimaryVariables initial_(const GlobalPosition &globalPos) const
262 {
263 PrimaryVariables values(0.0);
264 values.setState(wgPhaseOnly);
265
266 Scalar y = globalPos[1];
267 Scalar x = globalPos[0];
268 Scalar sw, swr=0.12, sgr=0.03;
269
270 if(y >(-1.E-3*x+5) - eps_)
271 {
272 Scalar pc = 9.81 * 1000.0 * (y - (-5E-4*x+5));
273 if (pc < 0.0) pc = 0.0;
274
275 sw = invertPcgw_(pc, this->spatialParams().materialLawParamsAtPos(globalPos));
276 if (sw < swr) sw = swr;
277 if (sw > 1.-sgr) sw = 1.-sgr;
278
279 values[pressureIdx] = 1e5 ;
280 values[switch1Idx] = sw;
281 values[switch2Idx] = 1.e-6;
282 }else {
283 values[pressureIdx] = 1e5 + 9.81 * 1000.0 * ((-5E-4*x+5) - y);
284 values[switch1Idx] = 1.-sgr;
285 values[switch2Idx] = 1.e-6;
286 }
287 return values;
288 }
289
290 template<class MaterialLawParams>
291 static Scalar invertPcgw_(Scalar pcIn, const MaterialLawParams &pcParams)
292 {
293 using MaterialLaw = typename ParentType::SpatialParams::MaterialLaw;
294 Scalar lower,upper;
295 int k;
296 int maxIt = 50;
297 Scalar bisLimit = 1.;
298 Scalar sw, pcgw;
299 lower=0.0; upper=1.0;
300 for (k=1; k<=25; k++)
301 {
302 sw = 0.5*(upper+lower);
303 pcgw = MaterialLaw::pcgw(pcParams, sw);
304 Scalar delta = pcgw-pcIn;
305 if (delta<0.) delta*=-1.;
306 if (delta<bisLimit)
307 {
308 return(sw);
309 }
310 if (k==maxIt) {
311 return(sw);
312 }
313 if (pcgw>pcIn) lower=sw;
314 else upper=sw;
315 }
316 return(sw);
317 }
318
319 Scalar temperature_;
320 static constexpr Scalar eps_ = 1e-6;
321 std::string name_;
322};
323} //end namespace Dumux
324
325#endif
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.
A three-phase fluid system featuring gas, NAPL and water as phases and distilled water and air (Pseu...
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
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
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
Isothermal NAPL infiltration problem: LNAPL contaminates the unsaturated and the saturated groundwate...
Definition: test/porousmediumflow/3p3c/implicit/infiltration/problem.hh:113
Scalar temperatureAtPos(const GlobalPosition &globalPos) const
Returns the temperature within the domain.
Definition: test/porousmediumflow/3p3c/implicit/infiltration/problem.hh:176
const std::string & name() const
The problem name.
Definition: test/porousmediumflow/3p3c/implicit/infiltration/problem.hh:166
InfiltrationThreePThreeCProblem(std::shared_ptr< const GridGeometry > gridGeometry)
Definition: test/porousmediumflow/3p3c/implicit/infiltration/problem.hh:147
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
Evaluates the initial value for a control volume.
Definition: test/porousmediumflow/3p3c/implicit/infiltration/problem.hh:256
PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
Evaluates the boundary conditions for a Dirichlet boundary segment.
Definition: test/porousmediumflow/3p3c/implicit/infiltration/problem.hh:213
NumEqVector neumannAtPos(const GlobalPosition &globalPos) const
Evaluates the boundary conditions for a Neumann boundary segment.
Definition: test/porousmediumflow/3p3c/implicit/infiltration/problem.hh:224
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/3p3c/implicit/infiltration/problem.hh:194
Definition: test/porousmediumflow/3p3c/implicit/infiltration/problem.hh:52
std::tuple< ThreePThreeC > InheritsFrom
Definition: test/porousmediumflow/3p3c/implicit/infiltration/problem.hh:52
Definition: test/porousmediumflow/3p3c/implicit/infiltration/problem.hh:53
std::tuple< InfiltrationThreePThreeC, BoxModel > InheritsFrom
Definition: test/porousmediumflow/3p3c/implicit/infiltration/problem.hh:53
Definition: test/porousmediumflow/3p3c/implicit/infiltration/problem.hh:54
std::tuple< InfiltrationThreePThreeC, CCTpfaModel > InheritsFrom
Definition: test/porousmediumflow/3p3c/implicit/infiltration/problem.hh:54
Dune::YaspGrid< 2 > type
Definition: test/porousmediumflow/3p3c/implicit/infiltration/problem.hh:59
GetPropType< TypeTag, Properties::GridGeometry > GridGeometry
Definition: test/porousmediumflow/3p3c/implicit/infiltration/problem.hh:69
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: test/porousmediumflow/3p3c/implicit/infiltration/problem.hh:70
Definition of the spatial parameters for the infiltration problem.
Definition: porousmediumflow/3p3c/implicit/infiltration/spatialparams.hh:46
Adaption of the fully implicit scheme to the three-phase three-component flow model.
Base class for all porous media problems.
Definition of the spatial parameters for the MaxwellStefan problem.