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  Copyright (C) 2009-2013 by Andreas Lauser
5  Copyright (C) 2010 by Benjamin Faigle
6  Copyright (C) 2010 by Klaus Mosthaf
7 
8  This file is part of the Open Porous Media project (OPM).
9 
10  OPM is free software: you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation, either version 2 of the License, or
13  (at your option) any later version.
14 
15  OPM is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with OPM. If not, see <http://www.gnu.org/licenses/>.
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 <ewoms/disc/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 <ewoms/io/cubegridmanager.hh> /*@\label{tutorial1:include-grid-manager}@*/
49 
50 // For Dune::FieldMatrix
51 #include <dune/common/fmatrix.hh>
52 #include <dune/common/version.hh>
53 
54 namespace Ewoms {
55 // forward declaration of the problem class
56 template <class TypeTag>
58 }
59 
60 namespace Ewoms {
61 namespace Properties {
62 // Create a new type tag for the problem
63 NEW_TYPE_TAG(Tutorial1Problem, INHERITS_FROM(ImmiscibleTwoPhaseModel)); /*@\label{tutorial1:create-type-tag}@*/
64 
65 // Select the vertex centered finite volume method as spatial discretization
66 SET_TAG_PROP(Tutorial1Problem, SpatialDiscretizationSplice,
67  VcfvDiscretization); /*@\label{tutorial1:set-spatial-discretization}@*/
68 
69 // Set the "Problem" property
71  Ewoms::Tutorial1Problem<TypeTag>); /*@\label{tutorial1:set-problem}@*/
72 
73 // Set grid and the grid manager to be used
74 SET_TYPE_PROP(Tutorial1Problem, Grid, Dune::YaspGrid</*dim=*/2>); /*@\label{tutorial1:set-grid}@*/
75 SET_TYPE_PROP(Tutorial1Problem, GridManager, Ewoms::CubeGridManager<TypeTag>); /*@\label{tutorial1:set-grid-manager}@*/
76 
77 // Set the wetting phase /*@\label{tutorial1:2p-system-start}@*/
79  WettingPhase, /*@\label{tutorial1:wettingPhase}@*/
80  Opm::LiquidPhase<typename GET_PROP_TYPE(TypeTag, Scalar),
81  Opm::SimpleH2O<typename GET_PROP_TYPE(TypeTag, Scalar)> >);
82 
83 // Set the non-wetting phase
85  NonwettingPhase, /*@\label{tutorial1:nonwettingPhase}@*/
86  Opm::LiquidPhase<typename GET_PROP_TYPE(TypeTag, Scalar),
87  Opm::LNAPL<typename GET_PROP_TYPE(TypeTag, Scalar)> >); /*@\label{tutorial1:2p-system-end}@*/
88 
89 // Set the material law
91 {
92 private:
93  // create a class holding the necessary information for a
94  // two-phase capillary pressure law
95  typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
96  typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem;
97  enum { wettingPhaseIdx = FluidSystem::wettingPhaseIdx };
98  enum { nonWettingPhaseIdx = FluidSystem::nonWettingPhaseIdx };
99  typedef Opm::TwoPhaseMaterialTraits<Scalar, wettingPhaseIdx, nonWettingPhaseIdx> Traits;
100 
101  // define the material law which is parameterized by effective
102  // saturations
103  typedef Opm::RegularizedBrooksCorey<Traits> RawMaterialLaw; /*@\label{tutorial1:rawlaw}@*/
104 
105 public:
106  // Convert absolute saturations into effective ones before passing
107  // it to the base capillary pressure law
108  typedef Opm::EffToAbsLaw<RawMaterialLaw> type; /*@\label{tutorial1:eff2abs}@*/
109 };
110 
111 // Disable gravity
112 SET_BOOL_PROP(Tutorial1Problem, EnableGravity, false); /*@\label{tutorial1:gravity}@*/
113 
114 // define how long the simulation should run [s]
115 SET_SCALAR_PROP(Tutorial1Problem, EndTime, 100e3); /*@\label{tutorial1:default-params-begin}@*/
116 
117 // define the size of the initial time step [s]
118 SET_SCALAR_PROP(Tutorial1Problem, InitialTimeStepSize, 125.0);
119 
120 // define the physical size of the problem's domain [m]
121 SET_SCALAR_PROP(Tutorial1Problem, DomainSizeX, 300.0); /*@\label{tutorial1:grid-default-params-begin}@*/
122 SET_SCALAR_PROP(Tutorial1Problem, DomainSizeY, 60.0);
123 SET_SCALAR_PROP(Tutorial1Problem, DomainSizeZ, 0.0);
124 
125 // // define the number of cells used for discretizing the physical domain
126 SET_INT_PROP(Tutorial1Problem, CellsX, 100);
127 SET_INT_PROP(Tutorial1Problem, CellsY, 1);
128 SET_INT_PROP(Tutorial1Problem, CellsZ, 1); /*@\label{tutorial1:default-params-end}@*/
129 } // namespace Properties
130 } // namespace Ewoms
131 
132 namespace Ewoms {
134 template <class TypeTag>
135 class Tutorial1Problem
136  : public GET_PROP_TYPE(TypeTag, BaseProblem) /*@\label{tutorial1:def-problem}@*/
137 {
138  typedef typename GET_PROP_TYPE(TypeTag, BaseProblem) ParentType;
139  typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
140  typedef typename GET_PROP_TYPE(TypeTag, GridView) GridView;
141 
142  // Grid dimension
143  enum { dimWorld = GridView::dimensionworld };
144 
145  // The type of the intrinsic permeability tensor
146  typedef Dune::FieldMatrix<Scalar, dimWorld, dimWorld> DimMatrix;
147 
148  // eWoms specific types are specified via the property system
149  typedef typename GET_PROP_TYPE(TypeTag, Simulator) Simulator;
150  typedef typename GET_PROP_TYPE(TypeTag, PrimaryVariables) PrimaryVariables;
151  typedef typename GET_PROP_TYPE(TypeTag, RateVector) RateVector;
152  typedef typename GET_PROP_TYPE(TypeTag, BoundaryRateVector) BoundaryRateVector;
153  typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem;
154  typedef typename GET_PROP_TYPE(TypeTag, Indices) Indices;
155  typedef typename GET_PROP_TYPE(TypeTag, MaterialLaw) MaterialLaw;
156  typedef typename GET_PROP_TYPE(TypeTag, MaterialLawParams) MaterialLawParams; /*@\label{tutorial1:matLawObjectType}@*/
157 
158  // phase indices
159  enum { numPhases = FluidSystem::numPhases };
160  enum { wettingPhaseIdx = FluidSystem::wettingPhaseIdx };
161  enum { nonWettingPhaseIdx = FluidSystem::nonWettingPhaseIdx };
162 
163  // Indices of the conservation equations
164  enum { contiWettingEqIdx = Indices::conti0EqIdx + wettingPhaseIdx };
165  enum { contiNonWettingEqIdx = Indices::conti0EqIdx + nonWettingPhaseIdx };
166 
167 public:
171  : ParentType(simulator)
172  , eps_(3e-6)
173  { }
174 
178  void finishInit()
179  {
180  ParentType::finishInit();
181 
182  // Use an isotropic and homogeneous intrinsic permeability
183  K_ = this->toDimMatrix_(1e-7);
184 
185  // Parameters of the Brooks-Corey law
186  materialParams_.setEntryPressure(500.0 /*Pa*/); /*@\label{tutorial1:setLawParams}@*/
187  materialParams_.setLambda(2); // shape parameter
188 
189  // Set the residual saturations
190  materialParams_.setResidualSaturation(wettingPhaseIdx, 0.0);
191  materialParams_.setResidualSaturation(nonWettingPhaseIdx, 0.0);
192 
193  // wrap up the initialization of the material law's parameters
194  materialParams_.finalize();
195  }
196 
198  std::string name() const
199  { return "tutorial1"; }
200 
202  template <class Context>
203  Scalar temperature(const Context &context, int spaceIdx, int timeIdx) const
204  { return 283.15; }
205 
207  template <class Context>
208  const DimMatrix &intrinsicPermeability(const Context &context, /*@\label{tutorial1:permeability}@*/
209  int spaceIdx, int timeIdx) const
210  { return K_; }
211 
213  template <class Context>
214  Scalar porosity(const Context &context,
215  int spaceIdx, int timeIdx) const /*@\label{tutorial1:porosity}@*/
216  { return 0.2; }
217 
219  template <class Context>
220  const MaterialLawParams &materialLawParams(const Context &context, /*@\label{tutorial1:matLawParams}@*/
221  int spaceIdx, int timeIdx) const
222  { return materialParams_; }
223 
225  template <class Context>
226  void boundary(BoundaryRateVector &values, const Context &context,
227  int spaceIdx, int timeIdx) const
228  {
229  const auto &pos = context.pos(spaceIdx, timeIdx);
230  if (pos[0] < eps_) {
231  // Free-flow conditions on left boundary
232  const auto &materialParams = this->materialLawParams(context, spaceIdx, timeIdx);
233 
234  Opm::ImmiscibleFluidState<Scalar, FluidSystem> fs;
235  Scalar Sw = 1.0;
236  fs.setSaturation(wettingPhaseIdx, Sw);
237  fs.setSaturation(nonWettingPhaseIdx, 1.0 - Sw);
238  fs.setTemperature(temperature(context, spaceIdx, timeIdx));
239 
240  Scalar pC[numPhases];
241  MaterialLaw::capillaryPressures(pC, materialParams, fs);
242  fs.setPressure(wettingPhaseIdx, 200e3);
243  fs.setPressure(nonWettingPhaseIdx, 200e3 + pC[nonWettingPhaseIdx] - pC[nonWettingPhaseIdx]);
244 
245  values.setFreeFlow(context, spaceIdx, timeIdx, fs);
246  }
247  else if (pos[0] > this->boundingBoxMax()[0] - eps_) {
248  // forced outflow at the right boundary
249  RateVector massRate(0.0);
250 
251  massRate[contiWettingEqIdx] = 0.0; // [kg / (s m^2)]
252  massRate[contiNonWettingEqIdx] = 3e-2; // [kg / (s m^2)]
253 
254  values.setMassRate(massRate);
255  }
256  else // no flow at the remaining boundaries
257  values.setNoFlow();
258  }
259 
263  template <class Context>
264  void source(RateVector &source, const Context &context, int spaceIdx,
265  int timeIdx) const
266  {
267  source[contiWettingEqIdx] = 0.0;
268  source[contiNonWettingEqIdx] = 0.0;
269  }
270 
272  template <class Context>
273  void initial(PrimaryVariables &values, const Context &context, int spaceIdx,
274  int timeIdx) const
275  {
276  Opm::ImmiscibleFluidState<Scalar, FluidSystem> fs;
277 
278  // the domain is initially fully saturated by LNAPL
279  Scalar Sw = 0.0;
280  fs.setSaturation(wettingPhaseIdx, Sw);
281  fs.setSaturation(nonWettingPhaseIdx, 1.0 - Sw);
282 
283  // the temperature is given by the temperature() method
284  fs.setTemperature(temperature(context, spaceIdx, timeIdx));
285 
286  // set pressure of the wetting phase to 200 kPa = 2 bar
287  Scalar pC[numPhases];
288  MaterialLaw::capillaryPressures(pC, materialLawParams(context, spaceIdx,
289  timeIdx),
290  fs);
291  fs.setPressure(wettingPhaseIdx, 200e3);
292  fs.setPressure(nonWettingPhaseIdx, 200e3 + pC[nonWettingPhaseIdx] - pC[nonWettingPhaseIdx]);
293 
294  values.assignNaive(fs);
295  }
296 
297 private:
298  DimMatrix K_;
299  // Object that holds the parameters of required by the capillary pressure law.
300  MaterialLawParams materialParams_; /*@\label{tutorial1:matParamsObject}@*/
301 
302  // small epsilon value
303  Scalar eps_;
304 };
305 } // namespace Ewoms
306 
307 #endif
308 
void source(RateVector &source, const Context &context, int spaceIdx, int timeIdx) const
Definition: tutorial1problem.hh:264
SET_SCALAR_PROP(NumericModel, EndTime,-1e100)
The default value for the simulation's end time.
SET_TAG_PROP(FvBaseDiscretization, LinearSolverSplice, ParallelIterativeLinearSolver)
use a parallel iterative linear solver by default
#define GET_PROP_TYPE(TypeTag, PropTagName)
Access the type attribute of a property for a type tag.
Definition: propertysystem.hh:485
SET_PROP(NumericModel, ParameterTree)
Set the ParameterTree property.
Definition: basicproperties.hh:117
A fully-implicit multi-phase flow model which assumes immiscibility of the phases.
SET_INT_PROP(NumericModel, GridGlobalRefinements, 0)
void finishInit()
Definition: tutorial1problem.hh:178
Scalar temperature(const Context &context, int spaceIdx, int timeIdx) const
Returns the temperature at a given position.
Definition: tutorial1problem.hh:203
SET_TYPE_PROP(NumericModel, Scalar, double)
Set the default type of scalar values to double.
Manages the initializing and running of time dependent problems.
Definition: simulator.hh:73
Provides a grid manager which a regular grid made of quadrilaterals.
Definition: baseauxiliarymodule.hh:35
std::string name() const
Specifies the problem name. This is used for files generated by the simulation.
Definition: tutorial1problem.hh:198
The base class for the vertex centered finite volume discretization scheme.
Definition: vcfvdiscretization.hh:42
Scalar porosity(const Context &context, int spaceIdx, int timeIdx) const
Defines the porosity [-] of the medium at a given position.
Definition: tutorial1problem.hh:214
const DimMatrix & intrinsicPermeability(const Context &context, int spaceIdx, int timeIdx) const
Returns the intrinsic permeability tensor [m^2] at a position.
Definition: tutorial1problem.hh:208
The base class for the vertex centered finite volume discretization scheme.
Provides a grid manager which a regular grid made of quadrilaterals.
Definition: cubegridmanager.hh:64
NEW_TYPE_TAG(AuxModule)
Tutorial1Problem(Simulator &simulator)
Definition: tutorial1problem.hh:170
void boundary(BoundaryRateVector &values, const Context &context, int spaceIdx, int timeIdx) const
Evaluates the boundary conditions.
Definition: tutorial1problem.hh:226
const MaterialLawParams & materialLawParams(const Context &context, int spaceIdx, int timeIdx) const
Returns the parameter object for the material law at a given position.
Definition: tutorial1problem.hh:220
SET_BOOL_PROP(FvBaseDiscretization, EnableVtkOutput, true)
Enable the VTK output by default.
#define INHERITS_FROM(...)
Syntactic sugar for NEW_TYPE_TAG.
Definition: propertysystem.hh:229
void initial(PrimaryVariables &values, const Context &context, int spaceIdx, int timeIdx) const
Evaluates the initial value at a given position in the domain.
Definition: tutorial1problem.hh:273
Tutorial problem using the "immiscible" model.
Definition: tutorial1problem.hh:57