FlowGenericProblem.hpp
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 OPM_FLOW_GENERIC_PROBLEM_HPP
29#define OPM_FLOW_GENERIC_PROBLEM_HPP
30
31#include <opm/material/common/UniformXTabulated2DFunction.hpp>
32#include <opm/material/common/UniformXTabulated2DFunctionBuilder.hpp>
33#include <opm/material/common/Tabulated1DFunction.hpp>
34
36
37#include <array>
38#include <cstddef>
39#include <functional>
40#include <string>
41#include <vector>
42
43namespace Dune {
44class ParameterTree;
45}
46
47namespace Opm {
48
49class Deck;
50class EclipseState;
51class Schedule;
52template<typename Grid, typename GridView> class LookUpData;
53
60template<class GridView, class FluidSystem>
62{
63public:
64 using Scalar = typename FluidSystem::Scalar;
65 using TabulatedTwoDFunction = UniformXTabulated2DFunction<Scalar>;
66 using TabulatedTwoDFunctionBuilder = UniformXTabulated2DFunctionBuilder<Scalar>;
67 using TabulatedFunction = Tabulated1DFunction<Scalar>;
68
69 struct RockParams {
72 };
73
74 FlowGenericProblem(const EclipseState& eclState,
75 const Schedule& schedule,
76 const GridView& gridView);
77
78
79 static FlowGenericProblem serializationTestObject(const EclipseState& eclState,
80 const Schedule& schedule,
81 const GridView& gridView);
82
86 static std::string helpPreamble(int,
87 const char **argv);
88
92 static std::string briefDescription();
93
99 static void setBriefDescription(const std::string& msg)
100 { briefDescription_ = msg; }
101
111 Scalar maxWaterSaturation(unsigned globalDofIdx) const;
112
122 Scalar minOilPressure(unsigned globalDofIdx) const;
123
129 Scalar overburdenPressure(unsigned elementIdx) const;
130
137 {
138 return rockCompPoroMultWc_.empty() &&
139 rockCompTransMultWc_.empty() &&
140 rockCompPoroMult_.empty() &&
141 rockCompTransMult_.empty() &&
142 rockCompTransMultVal_.empty();
143 }
144
153 Scalar referencePorosity(unsigned elementIdx, unsigned timeIdx) const
154 { return referencePorosity_[timeIdx][elementIdx]; }
155
156
165 Scalar rockFraction(unsigned elementIdx, unsigned timeIdx) const {
166 return rockFraction_[timeIdx][elementIdx];
167 };
168
172 Scalar rockBiotComp(unsigned elementIdx) const;
173
177 Scalar rockBiotTemp(unsigned elementIdx) const;
178
182 Scalar lame(unsigned elementIdx) const;
183
187 Scalar biotCoeff(unsigned elementIdx) const;
188
192 Scalar biotTemp(unsigned elementIdx) const;
193
198 void setPorosity(Scalar poro, unsigned elementIdx, unsigned timeIdx = 0)
199 { referencePorosity_[timeIdx][elementIdx] = poro; }
200
204 Scalar solventSaturation(unsigned elemIdx) const;
205
209 Scalar solventRsw(unsigned elemIdx) const;
210
214 Scalar polymerConcentration(unsigned elemIdx) const;
215
219 // TODO: remove this function if not called
220 Scalar polymerMolecularWeight(const unsigned elemIdx) const;
221
225 Scalar microbialConcentration(unsigned elemIdx) const;
226
230 Scalar oxygenConcentration(unsigned elemIdx) const;
231
235 Scalar ureaConcentration(unsigned elemIdx) const;
236
240 Scalar biofilmVolumeFraction(unsigned elemIdx) const;
241
245 Scalar calciteVolumeFraction(unsigned elemIdx) const;
246
250 unsigned pvtRegionIndex(unsigned elemIdx) const;
251
252// const std::vector<int>& pvtRegionArray() const
253// { return pvtnum_; }
254
258 unsigned satnumRegionIndex(unsigned elemIdx) const;
259
263 unsigned miscnumRegionIndex(unsigned elemIdx) const;
264
268 unsigned plmixnumRegionIndex(unsigned elemIdx) const;
269
273 Scalar maxPolymerAdsorption(unsigned elemIdx) const;
274
282 Scalar rockCompressibility(unsigned globalSpaceIdx) const;
283
292 Scalar porosity(unsigned globalSpaceIdx, unsigned timeIdx) const;
293
294 bool vapparsActive(int episodeIdx) const;
295
297 { return numPressurePointsEquil_; }
298
299 bool operator==(const FlowGenericProblem& rhs) const;
300
301 template<class Serializer>
302 void serializeOp(Serializer& serializer)
303 {
304 serializer(maxOilSaturation_);
305 serializer(polymer_);
306 serializer(maxWaterSaturation_);
307 serializer(minRefPressure_);
308 serializer(overburdenPressure_);
309 serializer(solventSaturation_);
310 serializer(solventRsw_);
311 serializer(bioeffects_);
312 }
313
314protected:
315 void initFluidSystem_();
316
320 bool shouldWriteOutput() const
321 { return true; }
322
330 { return false; }
331
332 bool beginEpisode_(bool enableExperiments,
333 int episodeIdx);
334 void beginTimeStep_(bool enableExperiments,
335 int episodeIdx,
336 int timeStepIndex,
337 Scalar startTime,
338 Scalar time,
339 Scalar timeStepSize,
340 Scalar endTime);
341
342 void readRockParameters_(const std::vector<Scalar>& cellCenterDepths,
343 std::function<std::array<int,3>(const unsigned)> ijkIndex);
345
346 void readBlackoilExtentionsInitialConditions_(std::size_t numDof,
347 bool enableSolvent,
348 bool enablePolymer,
349 bool enablePolymerMolarWeight,
350 bool enableBioeffects,
351 bool enableMICP);
352
353 void updatePvtnum_();
354 void updateSatnum_();
355 void updateMiscnum_();
356 void updatePlmixnum_();
357
358 const EclipseState& eclState_;
359 const Schedule& schedule_;
360 const GridView& gridView_;
361
362 static inline std::string briefDescription_;
363 std::array<std::vector<Scalar>, 2> referencePorosity_;
364 std::array<std::vector<Scalar>, 2> rockFraction_;
365
366 std::vector<int> pvtnum_;
367 std::vector<unsigned short> satnum_;
368 std::vector<unsigned short> miscnum_;
369 std::vector<unsigned short> plmixnum_;
370
371 std::vector<RockParams> rockParams_;
372 std::vector<unsigned short> rockTableIdx_;
373 std::vector<TabulatedTwoDFunction> rockCompPoroMultWc_;
374 std::vector<TabulatedTwoDFunction> rockCompTransMultWc_;
375 std::vector<TabulatedFunction> rockCompPoroMult_;
376 std::vector<TabulatedFunction> rockCompTransMult_;
377 // ROCKCOMP HYSTERESIS=HYSTER only: the reversible "elastic" curves built from
378 // ROCKTABH, indexed by (turning pressure, current pressure). Used instead of
379 // rockCompPoroMult_/rockCompTransMult_ whenever the current pressure is above
380 // the lowest pressure the cell has ever reached (this->minRefPressure_).
381 std::vector<TabulatedTwoDFunction> rockCompPoroMultElastic_;
382 std::vector<TabulatedTwoDFunction> rockCompTransMultElastic_;
383 std::vector<Scalar> rockCompTransMultVal_;
384
386 std::vector<Scalar> maxOilSaturation_;
387 std::vector<Scalar> maxWaterSaturation_;
388 std::vector<Scalar> minRefPressure_;
389 std::vector<Scalar> overburdenPressure_;
390 std::vector<Scalar> solventSaturation_;
391 std::vector<Scalar> solventRsw_;
394
395 // time stepping parameters
399
400 // equilibration parameters
402
406
407 // To lookup origin cell indices
408 using Grid = std::remove_cv_t< typename std::remove_reference<decltype(gridView_.grid())>::type>;
411
412 // \brief Function to assign the origin cell index on level zero, for a cell on the leaf grid view.
413 //
414 // For CpGrid with local grid refinement, the field property of a cell on the leaf
415 // is inherited from its parent or equivalent (when has no parent) cell on level zero.
416 std::function<unsigned(unsigned)> lookupIdxOnLevelZeroAssigner_()
417 {
418 return [this](unsigned elemIdx) { return lookUpData_.template getFieldPropIdx<Grid>(elemIdx);};
419 }
420
421private:
422 template<class T>
423 void updateNum(const std::string& name, std::vector<T>& numbers, std::size_t num_regions);
424};
425
426} // namespace Opm
427
428#endif // OPM_FLOW_GENERIC_PROBLEM_HPP
This problem simulates an input file given in the data format used by the commercial ECLiPSE simulato...
Definition: FlowGenericProblem.hpp:62
void setPorosity(Scalar poro, unsigned elementIdx, unsigned timeIdx=0)
Sets the porosity of an element.
Definition: FlowGenericProblem.hpp:198
const EclipseState & eclState_
Definition: FlowGenericProblem.hpp:358
UniformXTabulated2DFunction< Scalar > TabulatedTwoDFunction
Definition: FlowGenericProblem.hpp:65
Scalar maxPolymerAdsorption(unsigned elemIdx) const
Returns the max polymer adsorption value.
Definition: FlowGenericProblem_impl.hpp:971
unsigned pvtRegionIndex(unsigned elemIdx) const
Returns the index the relevant PVT region given a cell index.
Definition: FlowGenericProblem_impl.hpp:930
Scalar oxygenConcentration(unsigned elemIdx) const
Returns the initial oxygen concentration for a given a cell index.
Definition: FlowGenericProblem_impl.hpp:883
Scalar microbialConcentration(unsigned elemIdx) const
Returns the initial microbial concentration for a given a cell index.
Definition: FlowGenericProblem_impl.hpp:871
bool usesDefaultRockCompaction() const
Whether all rock compaction multipliers use their default values.
Definition: FlowGenericProblem.hpp:136
PolymerSolutionContainer< Scalar > polymer_
Definition: FlowGenericProblem.hpp:385
Scalar rockBiotTemp(unsigned elementIdx) const
Returns the rock compressibility of an element due to thermoelasticity.
Definition: FlowGenericProblem_impl.hpp:428
std::array< std::vector< Scalar >, 2 > rockFraction_
Definition: FlowGenericProblem.hpp:364
std::vector< Scalar > rockCompTransMultVal_
Definition: FlowGenericProblem.hpp:383
std::function< unsigned(unsigned)> lookupIdxOnLevelZeroAssigner_()
Definition: FlowGenericProblem.hpp:416
static std::string briefDescription()
Returns a human readable description of the problem for the help message.
Definition: FlowGenericProblem_impl.hpp:149
Scalar solventRsw(unsigned elemIdx) const
Returns the initial solvent dissolved in water for a given a cell index.
Definition: FlowGenericProblem_impl.hpp:834
std::vector< TabulatedTwoDFunction > rockCompPoroMultWc_
Definition: FlowGenericProblem.hpp:373
std::vector< unsigned short > miscnum_
Definition: FlowGenericProblem.hpp:368
Scalar overburdenPressure(unsigned elementIdx) const
Get the pressure of the overburden.
Definition: FlowGenericProblem_impl.hpp:812
void updateMiscnum_()
Definition: FlowGenericProblem_impl.hpp:605
Scalar porosity(unsigned globalSpaceIdx, unsigned timeIdx) const
Direct indexed access to the porosity.
Definition: FlowGenericProblem_impl.hpp:409
Scalar rockCompressibility(unsigned globalSpaceIdx) const
Definition: FlowGenericProblem_impl.hpp:394
Scalar initialTimeStepSize_
Definition: FlowGenericProblem.hpp:397
std::vector< TabulatedTwoDFunction > rockCompTransMultElastic_
Definition: FlowGenericProblem.hpp:382
unsigned miscnumRegionIndex(unsigned elemIdx) const
Returns the index the relevant MISC region given a cell index.
Definition: FlowGenericProblem_impl.hpp:950
bool vapparsActive(int episodeIdx) const
Definition: FlowGenericProblem_impl.hpp:621
int numPressurePointsEquil() const
Definition: FlowGenericProblem.hpp:296
Scalar referencePorosity(unsigned elementIdx, unsigned timeIdx) const
Returns the porosity of an element.
Definition: FlowGenericProblem.hpp:153
std::vector< int > pvtnum_
Definition: FlowGenericProblem.hpp:366
unsigned satnumRegionIndex(unsigned elemIdx) const
Returns the index the relevant saturation function region given a cell index.
Definition: FlowGenericProblem_impl.hpp:940
Scalar maxWaterSaturation(unsigned globalDofIdx) const
Returns an element's historic maximum water phase saturation that was observed during the simulation.
Definition: FlowGenericProblem_impl.hpp:790
std::vector< Scalar > solventSaturation_
Definition: FlowGenericProblem.hpp:390
void readRockCompactionParameters_()
Definition: FlowGenericProblem_impl.hpp:246
Tabulated1DFunction< Scalar > TabulatedFunction
Definition: FlowGenericProblem.hpp:67
void updateSatnum_()
Definition: FlowGenericProblem_impl.hpp:597
void updatePvtnum_()
Definition: FlowGenericProblem_impl.hpp:589
bool enableDriftCompensation_
Definition: FlowGenericProblem.hpp:403
bool enableDriftCompensationTemp_
Definition: FlowGenericProblem.hpp:404
Scalar lame(unsigned elementIdx) const
Direct access to Lame's second parameter in an element.
Definition: FlowGenericProblem_impl.hpp:440
static FlowGenericProblem serializationTestObject(const EclipseState &eclState, const Schedule &schedule, const GridView &gridView)
Definition: FlowGenericProblem_impl.hpp:113
void beginTimeStep_(bool enableExperiments, int episodeIdx, int timeStepIndex, Scalar startTime, Scalar time, Scalar timeStepSize, Scalar endTime)
Definition: FlowGenericProblem_impl.hpp:666
std::vector< TabulatedFunction > rockCompTransMult_
Definition: FlowGenericProblem.hpp:376
Scalar rockFraction(unsigned elementIdx, unsigned timeIdx) const
Returns the rockFraction of an element.
Definition: FlowGenericProblem.hpp:165
std::vector< unsigned short > plmixnum_
Definition: FlowGenericProblem.hpp:369
std::vector< TabulatedTwoDFunction > rockCompPoroMultElastic_
Definition: FlowGenericProblem.hpp:381
std::vector< TabulatedTwoDFunction > rockCompTransMultWc_
Definition: FlowGenericProblem.hpp:374
Scalar calciteVolumeFraction(unsigned elemIdx) const
Returns the initial calcite volume fraction for a given a cell index.
Definition: FlowGenericProblem_impl.hpp:919
CO2H2SolutionContainer< Scalar > CO2H2_
Definition: FlowGenericProblem.hpp:393
unsigned plmixnumRegionIndex(unsigned elemIdx) const
Returns the index the relevant PLMIXNUM (for polymer module) region given a cell index.
Definition: FlowGenericProblem_impl.hpp:960
FlowGenericProblem(const EclipseState &eclState, const Schedule &schedule, const GridView &gridView)
Definition: FlowGenericProblem_impl.hpp:63
BioeffectsSolutionContainer< Scalar > bioeffects_
Definition: FlowGenericProblem.hpp:392
bool enableTuning_
Definition: FlowGenericProblem.hpp:396
Scalar solventSaturation(unsigned elemIdx) const
Returns the initial solvent saturation for a given a cell index.
Definition: FlowGenericProblem_impl.hpp:823
Scalar polymerMolecularWeight(const unsigned elemIdx) const
Returns the polymer molecule weight for a given cell index.
Definition: FlowGenericProblem_impl.hpp:859
std::vector< TabulatedFunction > rockCompPoroMult_
Definition: FlowGenericProblem.hpp:375
const GridView & gridView_
Definition: FlowGenericProblem.hpp:360
void readRockParameters_(const std::vector< Scalar > &cellCenterDepths, std::function< std::array< int, 3 >(const unsigned)> ijkIndex)
Definition: FlowGenericProblem_impl.hpp:156
UniformXTabulated2DFunctionBuilder< Scalar > TabulatedTwoDFunctionBuilder
Definition: FlowGenericProblem.hpp:66
std::vector< Scalar > maxOilSaturation_
Definition: FlowGenericProblem.hpp:386
std::vector< RockParams > rockParams_
Definition: FlowGenericProblem.hpp:371
std::array< std::vector< Scalar >, 2 > referencePorosity_
Definition: FlowGenericProblem.hpp:363
const Schedule & schedule_
Definition: FlowGenericProblem.hpp:359
std::vector< unsigned short > satnum_
Definition: FlowGenericProblem.hpp:367
void serializeOp(Serializer &serializer)
Definition: FlowGenericProblem.hpp:302
Scalar rockBiotComp(unsigned elementIdx) const
Returns the rock compressibility of an element due to poroelasticity.
Definition: FlowGenericProblem_impl.hpp:417
static std::string briefDescription_
Definition: FlowGenericProblem.hpp:362
const LookUpData lookUpData_
Definition: FlowGenericProblem.hpp:410
int numPressurePointsEquil_
Definition: FlowGenericProblem.hpp:401
Scalar minOilPressure(unsigned globalDofIdx) const
Returns an element's historic minimum pressure of the oil phase that was observed during the simulati...
Definition: FlowGenericProblem_impl.hpp:801
std::vector< Scalar > maxWaterSaturation_
Definition: FlowGenericProblem.hpp:387
void initFluidSystem_()
Definition: FlowGenericProblem_impl.hpp:691
bool operator==(const FlowGenericProblem &rhs) const
Definition: FlowGenericProblem_impl.hpp:982
Scalar maxTimeStepAfterWellEvent_
Definition: FlowGenericProblem.hpp:398
Scalar ureaConcentration(unsigned elemIdx) const
Returns the initial urea concentration for a given a cell index.
Definition: FlowGenericProblem_impl.hpp:895
std::vector< Scalar > minRefPressure_
Definition: FlowGenericProblem.hpp:388
bool beginEpisode_(bool enableExperiments, int episodeIdx)
Definition: FlowGenericProblem_impl.hpp:629
bool shouldWriteOutput() const
Always returns true. The ecl output writer takes care of the rest.
Definition: FlowGenericProblem.hpp:320
static void setBriefDescription(const std::string &msg)
Specifies the string returned by briefDescription()
Definition: FlowGenericProblem.hpp:99
Scalar biofilmVolumeFraction(unsigned elemIdx) const
Returns the initial biofilm volume fraction for a given a cell index.
Definition: FlowGenericProblem_impl.hpp:907
std::vector< Scalar > solventRsw_
Definition: FlowGenericProblem.hpp:391
static std::string helpPreamble(int, const char **argv)
Returns the string that is printed before the list of command line parameters in the help message.
Definition: FlowGenericProblem_impl.hpp:134
std::vector< Scalar > overburdenPressure_
Definition: FlowGenericProblem.hpp:389
void readBlackoilExtentionsInitialConditions_(std::size_t numDof, bool enableSolvent, bool enablePolymer, bool enablePolymerMolarWeight, bool enableBioeffects, bool enableMICP)
Definition: FlowGenericProblem_impl.hpp:698
Scalar biotTemp(unsigned elementIdx) const
Direct access to Biot temperature coefficient in an element.
Definition: FlowGenericProblem_impl.hpp:492
bool shouldWriteRestartFile() const
Returns true if an eWoms restart file should be written to disk.
Definition: FlowGenericProblem.hpp:329
Scalar biotCoeff(unsigned elementIdx) const
Direct access to Biot coefficient in an element.
Definition: FlowGenericProblem_impl.hpp:471
void updatePlmixnum_()
Definition: FlowGenericProblem_impl.hpp:613
std::vector< unsigned short > rockTableIdx_
Definition: FlowGenericProblem.hpp:372
bool explicitRockCompaction_
Definition: FlowGenericProblem.hpp:405
typename FluidSystem::Scalar Scalar
Definition: FlowGenericProblem.hpp:64
std::remove_cv_t< typename std::remove_reference< decltype(gridView_.grid())>::type > Grid
Definition: FlowGenericProblem.hpp:408
Scalar polymerConcentration(unsigned elemIdx) const
Returns the initial polymer concentration for a given a cell index.
Definition: FlowGenericProblem_impl.hpp:847
Definition: FlowGenericProblem.hpp:52
Definition: fvbaseprimaryvariables.hh:161
Definition: blackoilbioeffectsmodules.hh:45
Struct holding MICP extension data.
Definition: SolutionContainers.hpp:57
Struct holding CO2 and H2 extension data.
Definition: SolutionContainers.hpp:84
Definition: FlowGenericProblem.hpp:69
Scalar compressibility
Definition: FlowGenericProblem.hpp:71
Scalar referencePressure
Definition: FlowGenericProblem.hpp:70
Struct holding polymer extension data.
Definition: SolutionContainers.hpp:37