tutorial1problem.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 This file is part of the Open Porous Media project (OPM).
5
6 OPM 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 2 of the License, or
9 (at your option) any later version.
10
11 OPM 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 OPM. If not, see <http://www.gnu.org/licenses/>.
18
19 Consult the COPYING file in the top-level source directory of this
20 module for the precise wording of the license and the list of
21 copyright holders.
22*/
28#ifndef EWOMS_TUTORIAL1_PROBLEM_HH /*@\label{tutorial1:guardian1}@*/
29#define EWOMS_TUTORIAL1_PROBLEM_HH /*@\label{tutorial1:guardian2}@*/
30
31// The numerical model
33
34// The spatial discretization (VCFV == Vertex-Centered Finite Volumes)
35#include <opm/models/discretization/vcfv/vcfvdiscretization.hh> /*@\label{tutorial1:include-discretization}@*/
36
37// The chemical species that are used
38#include <opm/material/components/SimpleH2O.hpp>
39#include <opm/material/components/Lnapl.hpp>
40
41// Headers required for the capillary pressure law
42#include <opm/material/fluidmatrixinteractions/RegularizedBrooksCorey.hpp> /*@\label{tutorial1:rawLawInclude}@*/
43#include <opm/material/fluidmatrixinteractions/EffToAbsLaw.hpp>
44#include <opm/material/fluidmatrixinteractions/MaterialTraits.hpp>
45
46// For the DUNE grid
47#include <dune/grid/yaspgrid.hh> /*@\label{tutorial1:include-grid-manager}@*/
48#include <opm/models/io/cubegridvanguard.hh> /*@\label{tutorial1:include-grid-manager}@*/
49
50// For Dune::FieldMatrix
51#include <dune/common/fmatrix.hh>
52#include <dune/common/version.hh>
53
54namespace Opm {
55// forward declaration of the problem class
56template <class TypeTag>
57class Tutorial1Problem;
58}
59
60namespace Opm::Properties {
61
62// Create a new type tag for the problem
63// Create new type tags
64namespace TTag {
65struct Tutorial1Problem { using InheritsFrom = std::tuple<ImmiscibleTwoPhaseModel>; };
66} // end namespace TTag
67
68// Select the vertex centered finite volume method as spatial discretization
69template<class TypeTag>
71{ using type = TTag::VcfvDiscretization; }; /*@\label{tutorial1:set-spatial-discretization}@*/
72
73// Set the "Problem" property
74template<class TypeTag>
75struct Problem<TypeTag, TTag::Tutorial1Problem>
76{ using type = Opm::Tutorial1Problem<TypeTag>; }; /*@\label{tutorial1:set-problem}@*/
77
78// Set grid and the grid manager to be used
79template<class TypeTag>
80struct Grid<TypeTag, TTag::Tutorial1Problem> { using type = Dune::YaspGrid</*dim=*/2>; }; /*@\label{tutorial1:set-grid}@*/
81template<class TypeTag>
82struct Vanguard<TypeTag, TTag::Tutorial1Problem> { using type = Opm::CubeGridVanguard<TypeTag>; }; /*@\label{tutorial1:set-grid-manager}@*/
83
84// Set the wetting phase /*@\label{tutorial1:2p-system-start}@*/
85template<class TypeTag>
86struct WettingPhase<TypeTag, TTag::Tutorial1Problem> /*@\label{tutorial1:wettingPhase}@*/
87{
89 using type = Opm::LiquidPhase<Scalar, Opm::SimpleH2O<Scalar> >;
90};
91
92// Set the non-wetting phase
93template<class TypeTag>
94struct NonwettingPhase<TypeTag, TTag::Tutorial1Problem> /*@\label{tutorial1:nonwettingPhase}@*/
95{
97 using type = Opm::LiquidPhase<Scalar, Opm::LNAPL<Scalar> >;
98}; /*@\label{tutorial1:2p-system-end}@*/
99
100// Set the material law
101template<class TypeTag>
102struct MaterialLaw<TypeTag, TTag::Tutorial1Problem>
103{
104private:
105 // create a class holding the necessary information for a
106 // two-phase capillary pressure law
109 enum { wettingPhaseIdx = FluidSystem::wettingPhaseIdx };
110 enum { nonWettingPhaseIdx = FluidSystem::nonWettingPhaseIdx };
111 using Traits = Opm::TwoPhaseMaterialTraits<Scalar, wettingPhaseIdx, nonWettingPhaseIdx>;
112
113 // define the material law which is parameterized by effective
114 // saturations
115 using RawMaterialLaw = Opm::RegularizedBrooksCorey<Traits>; /*@\label{tutorial1:rawlaw}@*/
116
117public:
118 // Convert absolute saturations into effective ones before passing
119 // it to the base capillary pressure law
120 using type = Opm::EffToAbsLaw<RawMaterialLaw>; /*@\label{tutorial1:eff2abs}@*/
121};
122
123// Disable gravity
124template<class TypeTag>
125struct EnableGravity<TypeTag, TTag::Tutorial1Problem> { static constexpr bool value = false; }; /*@\label{tutorial1:gravity}@*/
126
127// define how long the simulation should run [s]
128template<class TypeTag>
129struct EndTime<TypeTag, TTag::Tutorial1Problem>
130{
132 static constexpr type value = 100e3;
133}; /*@\label{tutorial1:default-params-begin}@*/
134
135// define the size of the initial time step [s]
136template<class TypeTag>
138{
140 static constexpr type value = 125.0;
141};
142
143// define the physical size of the problem's domain [m]
144template<class TypeTag>
145struct DomainSizeX<TypeTag, TTag::Tutorial1Problem>
146{
148 static constexpr type value = 300.0;
149}; /*@\label{tutorial1:grid-default-params-begin}@*/
150template<class TypeTag>
151struct DomainSizeY<TypeTag, TTag::Tutorial1Problem>
152{
154 static constexpr type value = 60.0;
155};
156template<class TypeTag>
157struct DomainSizeZ<TypeTag, TTag::Tutorial1Problem>
158{
160 static constexpr type value = 0.0;
161};
162
163// // define the number of cells used for discretizing the physical domain
164template<class TypeTag>
165struct CellsX<TypeTag, TTag::Tutorial1Problem> { static constexpr unsigned value = 100; };
166template<class TypeTag>
167struct CellsY<TypeTag, TTag::Tutorial1Problem> { static constexpr unsigned value = 1; };
168template<class TypeTag>
169struct CellsZ<TypeTag, TTag::Tutorial1Problem> { static constexpr unsigned value = 1; }; /*@\label{tutorial1:default-params-end}@*/
170
171} // namespace Opm::Properties
172
173namespace Opm {
175template <class TypeTag>
177 : public GetPropType<TypeTag, Properties::BaseProblem> /*@\label{tutorial1:def-problem}@*/
178{
182
183 // Grid dimension
184 enum { dimWorld = GridView::dimensionworld };
185
186 // The type of the intrinsic permeability tensor
187 using DimMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>;
188
189 // eWoms specific types are specified via the property system
197 using MaterialLawParams = GetPropType<TypeTag, Properties::MaterialLawParams>; /*@\label{tutorial1:matLawObjectType}@*/
198
199 // phase indices
200 enum { numPhases = FluidSystem::numPhases };
201 enum { wettingPhaseIdx = FluidSystem::wettingPhaseIdx };
202 enum { nonWettingPhaseIdx = FluidSystem::nonWettingPhaseIdx };
203
204 // Indices of the conservation equations
205 enum { contiWettingEqIdx = Indices::conti0EqIdx + wettingPhaseIdx };
206 enum { contiNonWettingEqIdx = Indices::conti0EqIdx + nonWettingPhaseIdx };
207
208public:
211 Tutorial1Problem(Simulator& simulator)
212 : ParentType(simulator)
213 , eps_(3e-6)
214 { }
215
220 {
221 ParentType::finishInit();
222
223 // Use an isotropic and homogeneous intrinsic permeability
224 K_ = this->toDimMatrix_(1e-7);
225
226 // Parameters of the Brooks-Corey law
227 materialParams_.setEntryPressure(500.0 /*Pa*/); /*@\label{tutorial1:setLawParams}@*/
228 materialParams_.setLambda(2); // shape parameter
229
230 // Set the residual saturations
231 materialParams_.setResidualSaturation(wettingPhaseIdx, 0.0);
232 materialParams_.setResidualSaturation(nonWettingPhaseIdx, 0.0);
233
234 // wrap up the initialization of the material law's parameters
235 materialParams_.finalize();
236 }
237
239 std::string name() const
240 { return "tutorial1"; }
241
243 template <class Context>
244 Scalar temperature(const Context& /*context*/,
245 unsigned /*spaceIdx*/, unsigned /*timeIdx*/) const
246 { return 283.15; }
247
249 template <class Context>
250 const DimMatrix& intrinsicPermeability(const Context& /*context*/, /*@\label{tutorial1:permeability}@*/
251 unsigned /*spaceIdx*/, unsigned /*timeIdx*/) const
252 { return K_; }
253
255 template <class Context>
256 Scalar porosity(const Context& /*context*/,
257 unsigned /*spaceIdx*/, unsigned /*timeIdx*/) const /*@\label{tutorial1:porosity}@*/
258 { return 0.2; }
259
261 template <class Context>
262 const MaterialLawParams& materialLawParams(const Context& /*context*/, /*@\label{tutorial1:matLawParams}@*/
263 unsigned /*spaceIdx*/, unsigned /*timeIdx*/) const
264 { return materialParams_; }
265
267 template <class Context>
268 void boundary(BoundaryRateVector& values, const Context& context,
269 unsigned spaceIdx, unsigned timeIdx) const
270 {
271 const auto& pos = context.pos(spaceIdx, timeIdx);
272 if (pos[0] < eps_) {
273 // Free-flow conditions on left boundary
274 const auto& materialParams = this->materialLawParams(context, spaceIdx, timeIdx);
275
276 Opm::ImmiscibleFluidState<Scalar, FluidSystem> fs;
277 Scalar Sw = 1.0;
278 fs.setSaturation(wettingPhaseIdx, Sw);
279 fs.setSaturation(nonWettingPhaseIdx, 1.0 - Sw);
280 fs.setTemperature(temperature(context, spaceIdx, timeIdx));
281
282 Scalar pC[numPhases];
283 MaterialLaw::capillaryPressures(pC, materialParams, fs);
284 fs.setPressure(wettingPhaseIdx, 200e3);
285 fs.setPressure(nonWettingPhaseIdx, 200e3 + pC[nonWettingPhaseIdx] - pC[nonWettingPhaseIdx]);
286
287 typename FluidSystem::template ParameterCache<Scalar> paramCache;
288 paramCache.updateAll(fs);
289 for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) {
290 fs.setDensity(phaseIdx, FluidSystem::density(fs, paramCache, phaseIdx));
291 fs.setViscosity(phaseIdx, FluidSystem::viscosity(fs, paramCache, phaseIdx));
292 }
293
294 values.setFreeFlow(context, spaceIdx, timeIdx, fs);
295 }
296 else if (pos[0] > this->boundingBoxMax()[0] - eps_) {
297 // forced outflow at the right boundary
298 RateVector massRate(0.0);
299
300 massRate[contiWettingEqIdx] = 0.0; // [kg / (s m^2)]
301 massRate[contiNonWettingEqIdx] = 3e-2; // [kg / (s m^2)]
302
303 values.setMassRate(massRate);
304 }
305 else // no flow at the remaining boundaries
306 values.setNoFlow();
307 }
308
312 template <class Context>
313 void source(RateVector& sourceRate, const Context& /*context*/,
314 unsigned /*spaceIdx*/, unsigned /*timeIdx*/) const
315 {
316 sourceRate[contiWettingEqIdx] = 0.0;
317 sourceRate[contiNonWettingEqIdx] = 0.0;
318 }
319
321 template <class Context>
322 void initial(PrimaryVariables& values, const Context& context,
323 unsigned spaceIdx, unsigned timeIdx) const
324 {
325 Opm::ImmiscibleFluidState<Scalar, FluidSystem> fs;
326
327 // the domain is initially fully saturated by LNAPL
328 Scalar Sw = 0.0;
329 fs.setSaturation(wettingPhaseIdx, Sw);
330 fs.setSaturation(nonWettingPhaseIdx, 1.0 - Sw);
331
332 // the temperature is given by the temperature() method
333 fs.setTemperature(temperature(context, spaceIdx, timeIdx));
334
335 // set pressure of the wetting phase to 200 kPa = 2 bar
336 Scalar pC[numPhases];
337 MaterialLaw::capillaryPressures(pC, materialLawParams(context, spaceIdx, timeIdx),
338 fs);
339 fs.setPressure(wettingPhaseIdx, 200e3);
340 fs.setPressure(nonWettingPhaseIdx, 200e3 + pC[nonWettingPhaseIdx] - pC[nonWettingPhaseIdx]);
341
342 values.assignNaive(fs);
343 }
344
345private:
346 DimMatrix K_;
347 // Object that holds the parameters of required by the capillary pressure law.
348 MaterialLawParams materialParams_; /*@\label{tutorial1:matParamsObject}@*/
349
350 // small epsilon value
351 Scalar eps_;
352};
353} // namespace Opm
354
355#endif
356
Provides a simulator vanguad which creates a regular grid made of quadrilaterals.
Definition: cubegridvanguard.hh:52
Tutorial problem using the "immiscible" model.
Definition: tutorial1problem.hh:178
const DimMatrix & intrinsicPermeability(const Context &, unsigned, unsigned) const
Returns the intrinsic permeability tensor [m^2] at a position.
Definition: tutorial1problem.hh:250
Scalar porosity(const Context &, unsigned, unsigned) const
Defines the porosity [-] of the medium at a given position.
Definition: tutorial1problem.hh:256
void initial(PrimaryVariables &values, const Context &context, unsigned spaceIdx, unsigned timeIdx) const
Evaluates the initial value at a given position in the domain.
Definition: tutorial1problem.hh:322
void finishInit()
Definition: tutorial1problem.hh:219
Tutorial1Problem(Simulator &simulator)
Definition: tutorial1problem.hh:211
void boundary(BoundaryRateVector &values, const Context &context, unsigned spaceIdx, unsigned timeIdx) const
Evaluates the boundary conditions.
Definition: tutorial1problem.hh:268
void source(RateVector &sourceRate, const Context &, unsigned, unsigned) const
Definition: tutorial1problem.hh:313
std::string name() const
Specifies the problem name. This is used for files generated by the simulation.
Definition: tutorial1problem.hh:239
const MaterialLawParams & materialLawParams(const Context &, unsigned, unsigned) const
Returns the parameter object for the material law at a given position.
Definition: tutorial1problem.hh:262
Scalar temperature(const Context &, unsigned, unsigned) const
Returns the temperature at a given position.
Definition: tutorial1problem.hh:244
Definition: blackoilmodel.hh:72
Definition: blackoilboundaryratevector.hh:37
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:242
grid resolution
Definition: basicproperties.hh:157
Definition: basicproperties.hh:159
Definition: basicproperties.hh:161
GetPropType< TypeTag, Scalar > type
Definition: tutorial1problem.hh:147
domain size
Definition: basicproperties.hh:149
GetPropType< TypeTag, Scalar > type
Definition: tutorial1problem.hh:153
Definition: basicproperties.hh:151
GetPropType< TypeTag, Scalar > type
Definition: tutorial1problem.hh:159
Definition: basicproperties.hh:153
Returns whether gravity is considered in the problem.
Definition: multiphasebaseproperties.hh:79
GetPropType< TypeTag, Scalar > type
Definition: tutorial1problem.hh:131
The default value for the simulation's end time.
Definition: basicproperties.hh:133
Dune::YaspGrid< 2 > type
Definition: tutorial1problem.hh:80
The type of the DUNE grid.
Definition: basicproperties.hh:93
GetPropType< TypeTag, Scalar > type
Definition: tutorial1problem.hh:139
The default value for the simulation's initial time step size.
Definition: basicproperties.hh:137
Opm::EffToAbsLaw< RawMaterialLaw > type
Definition: tutorial1problem.hh:120
The material law which ought to be used (extracted from the spatial parameters)
Definition: multiphasebaseproperties.hh:51
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: tutorial1problem.hh:96
Opm::LiquidPhase< Scalar, Opm::LNAPL< Scalar > > type
Definition: tutorial1problem.hh:97
The non-wetting phase for two-phase models.
Definition: immiscibleproperties.hh:44
The type of the problem.
Definition: fvbaseproperties.hh:98
The splice to be used for the spatial discretization.
Definition: multiphasebaseproperties.hh:39
Definition: tutorial1problem.hh:65
std::tuple< ImmiscibleTwoPhaseModel > InheritsFrom
Definition: tutorial1problem.hh:65
Definition: vcfvproperties.hh:41
Property which provides a Vanguard (manages grids)
Definition: basicproperties.hh:89
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: tutorial1problem.hh:88
Opm::LiquidPhase< Scalar, Opm::SimpleH2O< Scalar > > type
Definition: tutorial1problem.hh:89
The wetting phase for two-phase models.
Definition: immiscibleproperties.hh:41