groundwaterproblem.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_GROUND_WATER_PROBLEM_HH
29#define EWOMS_GROUND_WATER_PROBLEM_HH
30
31#include <dune/common/fmatrix.hh>
32#include <dune/common/fvector.hh>
33#include <dune/common/version.hh>
34
35#include <dune/grid/yaspgrid.hh>
36#include <dune/grid/io/file/dgfparser/dgfyasp.hh>
37
38#include <opm/material/components/SimpleH2O.hpp>
39#include <opm/material/fluidstates/ImmiscibleFluidState.hpp>
40#include <opm/material/fluidsystems/LiquidPhase.hpp>
41
43
45
47
48#include <sstream>
49#include <string>
50
51namespace Opm {
52template <class TypeTag>
53class GroundWaterProblem;
54}
55
56namespace Opm::Properties {
57
58namespace TTag {
60}
61
62template<class TypeTag>
63struct Fluid<TypeTag, TTag::GroundWaterBaseProblem>
64{
65private:
67
68public:
69 using type = Opm::LiquidPhase<Scalar, Opm::SimpleH2O<Scalar> >;
70};
71
72// Set the grid type
73template<class TypeTag>
74struct Grid<TypeTag, TTag::GroundWaterBaseProblem> { using type = Dune::YaspGrid<2>; };
75// struct Grid<TypeTag, TTag::GroundWaterBaseProblem> { using type = Dune::SGrid<2, 2>; };
76
77template<class TypeTag>
78struct Problem<TypeTag, TTag::GroundWaterBaseProblem>
80
81// Use the conjugated gradient linear solver with the default preconditioner (i.e.,
82// ILU-0) from dune-istl
83template<class TypeTag>
84struct LinearSolverSplice<TypeTag, TTag::GroundWaterBaseProblem> { using type = TTag::ParallelIstlLinearSolver; };
85
86template<class TypeTag>
87struct LinearSolverWrapper<TypeTag, TTag::GroundWaterBaseProblem>
88{ using type = Opm::Linear::SolverWrapperConjugatedGradients<TypeTag>; };
89
90} // namespace Opm::Properties
91
92namespace Opm::Parameters {
93
94template<class Scalar>
95struct LensLowerLeftX { static constexpr Scalar value = 0.25; };
96
97template<class Scalar>
98struct LensLowerLeftY { static constexpr Scalar value = 0.25; };
99
100template<class Scalar>
101struct LensLowerLeftZ { static constexpr Scalar value = 0.25; };
102
103template<class Scalar>
104struct LensUpperRightX { static constexpr Scalar value = 0.75; };
105
106template<class Scalar>
107struct LensUpperRightY { static constexpr Scalar value = 0.75; };
108
109template<class Scalar>
110struct LensUpperRightZ { static constexpr Scalar value = 0.75; };
111
112template<class Scalar>
113struct Permeability { static constexpr Scalar value = 1e-10; };
114
115template<class Scalar>
116struct PermeabilityLens { static constexpr Scalar value = 1e-12; };
117
118} // namespace Opm::Parameters
119
120namespace Opm {
133template <class TypeTag>
134class GroundWaterProblem : public GetPropType<TypeTag, Properties::BaseProblem>
135{
137
141
142 // copy some indices for convenience
144 enum {
145 numPhases = FluidSystem::numPhases,
146
147 // Grid and world dimension
148 dim = GridView::dimension,
149 dimWorld = GridView::dimensionworld,
150
151 // indices of the primary variables
152 pressure0Idx = Indices::pressure0Idx
153 };
154
161
162 using CoordScalar = typename GridView::ctype;
163 using GlobalPosition = Dune::FieldVector<CoordScalar, dimWorld>;
164
165 using DimMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>;
166
167public:
171 GroundWaterProblem(Simulator& simulator)
172 : ParentType(simulator)
173 { }
174
179 {
180 ParentType::finishInit();
181
182 eps_ = 1.0e-3;
183
184 lensLowerLeft_[0] = Parameters::Get<Parameters::LensLowerLeftX<Scalar>>();
185 if (dim > 1)
186 lensLowerLeft_[1] = Parameters::Get<Parameters::LensLowerLeftY<Scalar>>();
187 if (dim > 2)
188 lensLowerLeft_[2] = Parameters::Get<Parameters::LensLowerLeftY<Scalar>>();
189
190 lensUpperRight_[0] = Parameters::Get<Parameters::LensUpperRightX<Scalar>>();
191 if (dim > 1)
192 lensUpperRight_[1] = Parameters::Get<Parameters::LensUpperRightY<Scalar>>();
193 if (dim > 2)
194 lensUpperRight_[2] = Parameters::Get<Parameters::LensUpperRightY<Scalar>>();
195
196 intrinsicPerm_ = this->toDimMatrix_(Parameters::Get<Parameters::Permeability<Scalar>>());
197 intrinsicPermLens_ = this->toDimMatrix_(Parameters::Get<Parameters::PermeabilityLens<Scalar>>());
198 }
199
203 static void registerParameters()
204 {
205 ParentType::registerParameters();
206
207 Parameters::Register<Parameters::LensLowerLeftX<Scalar>>
208 ("The x-coordinate of the lens' lower-left corner [m].");
209 Parameters::Register<Parameters::LensUpperRightX<Scalar>>
210 ("The x-coordinate of the lens' upper-right corner [m].");
211
212 if (dimWorld > 1) {
213 Parameters::Register<Parameters::LensLowerLeftY<Scalar>>
214 ("The y-coordinate of the lens' lower-left corner [m].");
215 Parameters::Register<Parameters::LensUpperRightY<Scalar>>
216 ("The y-coordinate of the lens' upper-right corner [m].");
217 }
218
219 if (dimWorld > 2) {
220 Parameters::Register<Parameters::LensLowerLeftZ<Scalar>>
221 ("The z-coordinate of the lens' lower-left corner [m].");
222 Parameters::Register<Parameters::LensUpperRightZ<Scalar>>
223 ("The z-coordinate of the lens' upper-right corner [m].");
224 }
225
226 Parameters::Register<Parameters::Permeability<Scalar>>
227 ("The intrinsic permeability [m^2] of the ambient material.");
228 Parameters::Register<Parameters::PermeabilityLens<Scalar>>
229 ("The intrinsic permeability [m^2] of the lens.");
230
231 Parameters::SetDefault<Parameters::GridFile>("./data/groundwater_2d.dgf");
232 Parameters::SetDefault<Parameters::EndTime<Scalar>>(1.0);
233 Parameters::SetDefault<Parameters::InitialTimeStepSize<Scalar>>(1.0);
234 Parameters::SetDefault<Parameters::EnableGravity>(true);
235 }
236
240 // \{
241
245 std::string name() const
246 {
247 std::ostringstream oss;
248 oss << "groundwater_" << Model::name();
249 return oss.str();
250 }
251
256 {
257#ifndef NDEBUG
258 this->model().checkConservativeness();
259
260 // Calculate storage terms
261 EqVector storage;
262 this->model().globalStorage(storage);
263
264 // Write mass balance information for rank 0
265 if (this->gridView().comm().rank() == 0) {
266 std::cout << "Storage: " << storage << std::endl << std::flush;
267 }
268#endif // NDEBUG
269 }
270
274 template <class Context>
275 Scalar temperature(const Context& /*context*/,
276 unsigned /*spaceIdx*/,
277 unsigned /*timeIdx*/) const
278 { return 273.15 + 10; } // 10C
279
283 template <class Context>
284 Scalar porosity(const Context& /*context*/,
285 unsigned /*spaceIdx*/,
286 unsigned /*timeIdx*/) const
287 { return 0.4; }
288
292 template <class Context>
293 const DimMatrix& intrinsicPermeability(const Context& context,
294 unsigned spaceIdx,
295 unsigned timeIdx) const
296 {
297 if (isInLens_(context.pos(spaceIdx, timeIdx)))
298 return intrinsicPermLens_;
299 else
300 return intrinsicPerm_;
301 }
302
304
308
312 template <class Context>
313 void boundary(BoundaryRateVector& values, const Context& context,
314 unsigned spaceIdx, unsigned timeIdx) const
315 {
316 const GlobalPosition& globalPos = context.pos(spaceIdx, timeIdx);
317
318 if (onLowerBoundary_(globalPos) || onUpperBoundary_(globalPos)) {
319 Scalar pressure;
320 Scalar T = temperature(context, spaceIdx, timeIdx);
321 if (onLowerBoundary_(globalPos))
322 pressure = 2e5;
323 else // on upper boundary
324 pressure = 1e5;
325
326 Opm::ImmiscibleFluidState<Scalar, FluidSystem,
327 /*storeEnthalpy=*/false> fs;
328 fs.setSaturation(/*phaseIdx=*/0, 1.0);
329 fs.setPressure(/*phaseIdx=*/0, pressure);
330 fs.setTemperature(T);
331
332 typename FluidSystem::template ParameterCache<Scalar> paramCache;
333 paramCache.updateAll(fs);
334 for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) {
335 fs.setDensity(phaseIdx, FluidSystem::density(fs, paramCache, phaseIdx));
336 fs.setViscosity(phaseIdx, FluidSystem::viscosity(fs, paramCache, phaseIdx));
337 }
338
339 // impose an freeflow boundary condition
340 values.setFreeFlow(context, spaceIdx, timeIdx, fs);
341 }
342 else {
343 // no flow boundary
344 values.setNoFlow();
345 }
346 }
347
349
354
358 template <class Context>
359 void initial(PrimaryVariables& values,
360 const Context& /*context*/,
361 unsigned /*spaceIdx*/,
362 unsigned /*timeIdx*/) const
363 {
364 // const GlobalPosition& globalPos = context.pos(spaceIdx, timeIdx);
365 values[pressure0Idx] = 1.0e+5; // + 9.81*1.23*(20-globalPos[dim-1]);
366 }
367
371 template <class Context>
372 void source(RateVector& rate,
373 const Context& /*context*/,
374 unsigned /*spaceIdx*/,
375 unsigned /*timeIdx*/) const
376 { rate = Scalar(0.0); }
377
379
380private:
381 bool onLowerBoundary_(const GlobalPosition& pos) const
382 { return pos[dim - 1] < eps_; }
383
384 bool onUpperBoundary_(const GlobalPosition& pos) const
385 { return pos[dim - 1] > this->boundingBoxMax()[dim - 1] - eps_; }
386
387 bool isInLens_(const GlobalPosition& pos) const
388 {
389 return lensLowerLeft_[0] <= pos[0] && pos[0] <= lensUpperRight_[0]
390 && lensLowerLeft_[1] <= pos[1] && pos[1] <= lensUpperRight_[1];
391 }
392
393 GlobalPosition lensLowerLeft_;
394 GlobalPosition lensUpperRight_;
395
396 DimMatrix intrinsicPerm_;
397 DimMatrix intrinsicPermLens_;
398
399 Scalar eps_;
400};
401} // namespace Opm
402
403#endif
Test for the immisicible VCVF discretization with only a single phase.
Definition: groundwaterproblem.hh:135
Scalar porosity(const Context &, unsigned, unsigned) const
Definition: groundwaterproblem.hh:284
void endTimeStep()
Called by the simulator after each time integration.
Definition: groundwaterproblem.hh:255
GroundWaterProblem(Simulator &simulator)
Definition: groundwaterproblem.hh:171
static void registerParameters()
Definition: groundwaterproblem.hh:203
std::string name() const
The problem name.
Definition: groundwaterproblem.hh:245
Scalar temperature(const Context &, unsigned, unsigned) const
Definition: groundwaterproblem.hh:275
void boundary(BoundaryRateVector &values, const Context &context, unsigned spaceIdx, unsigned timeIdx) const
Evaluate the boundary conditions for a boundary segment.
Definition: groundwaterproblem.hh:313
void source(RateVector &rate, const Context &, unsigned, unsigned) const
Evaluate the source term for all phases within a given sub-control-volume.
Definition: groundwaterproblem.hh:372
const DimMatrix & intrinsicPermeability(const Context &context, unsigned spaceIdx, unsigned timeIdx) const
Definition: groundwaterproblem.hh:293
void finishInit()
Called by the Opm::Simulator in order to initialize the problem.
Definition: groundwaterproblem.hh:178
void initial(PrimaryVariables &values, const Context &, unsigned, unsigned) const
Evaluate the initial value for a control volume.
Definition: groundwaterproblem.hh:359
Defines the properties required for the immiscible multi-phase model.
Defines the common parameters for the porous medium multi-phase models.
Definition: blackoilnewtonmethodparams.hpp:31
auto Get(bool errorIfNotRegistered=true)
Retrieve a runtime parameter.
Definition: parametersystem.hpp:185
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:235
Definition: groundwaterproblem.hh:95
static constexpr Scalar value
Definition: groundwaterproblem.hh:95
Definition: groundwaterproblem.hh:98
static constexpr Scalar value
Definition: groundwaterproblem.hh:98
Definition: groundwaterproblem.hh:101
static constexpr Scalar value
Definition: groundwaterproblem.hh:101
Definition: groundwaterproblem.hh:104
static constexpr Scalar value
Definition: groundwaterproblem.hh:104
Definition: groundwaterproblem.hh:107
static constexpr Scalar value
Definition: groundwaterproblem.hh:107
Definition: groundwaterproblem.hh:110
static constexpr Scalar value
Definition: groundwaterproblem.hh:110
Definition: groundwaterproblem.hh:116
static constexpr Scalar value
Definition: groundwaterproblem.hh:116
Definition: groundwaterproblem.hh:113
static constexpr Scalar value
Definition: groundwaterproblem.hh:113
Opm::LiquidPhase< Scalar, Opm::SimpleH2O< Scalar > > type
Definition: groundwaterproblem.hh:69
The fluid used by the model.
Definition: immiscibleproperties.hh:49
Dune::YaspGrid< 2 > type
Definition: groundwaterproblem.hh:74
The type of the DUNE grid.
Definition: basicproperties.hh:100
Definition: fvbaseproperties.hh:53
Opm::Linear::SolverWrapperConjugatedGradients< TypeTag > type
Definition: groundwaterproblem.hh:88
Definition: linalgproperties.hh:57
The type of the problem.
Definition: fvbaseproperties.hh:81
Definition: groundwaterproblem.hh:59
Definition: parallelistlbackend.hh:40