My Project
Loading...
Searching...
No Matches
GenericOutputBlackoilModule.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 Consult the COPYING file in the top-level source directory of this
19 module for the precise wording of the license and the list of
20 copyright holders.
21*/
26#ifndef OPM_GENERIC_OUTPUT_BLACK_OIL_MODULE_HPP
27#define OPM_GENERIC_OUTPUT_BLACK_OIL_MODULE_HPP
28
29#include <opm/input/eclipse/EclipseState/Grid/FaceDir.hpp>
30#include <opm/input/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
31
32#include <opm/output/data/Wells.hpp>
33#include <opm/output/eclipse/Inplace.hpp>
34
35#include <opm/simulators/flow/FlowsData.hpp>
38#include <opm/simulators/flow/RegionPhasePVAverage.hpp>
39
40#include <opm/simulators/utils/ParallelCommunication.hpp>
41
42#include <array>
43#include <cstddef>
44#include <functional>
45#include <map>
46#include <optional>
47#include <unordered_map>
48#include <utility>
49#include <vector>
50
51namespace Opm {
52
53namespace data { class Solution; }
54class EclipseState;
55class Schedule;
56class SummaryConfig;
58class SummaryState;
59
60template<class FluidSystem>
62public:
63 using Scalar = typename FluidSystem::Scalar;
64
65 // Virtual destructor for safer inheritance.
67
68 Scalar* getPRESSURE_ptr(void) {
69 return (this->fluidPressure_.data()) ;
70 };
71
72 int getPRESSURE_size( void ) {
73 return (this->fluidPressure_.size()) ;
74 };
75
76 void outputTimeStamp(const std::string& lbl,
77 double elapsed,
78 int rstep,
79 boost::posix_time::ptime currentDate);
80
84
88
89 // write cumulative production and injection reports to output
90 void outputCumLog(std::size_t reportStepNum);
91
92 // write production report to output
93 void outputProdLog(std::size_t reportStepNum);
94
95 // write injection report to output
96 void outputInjLog(std::size_t reportStepNum);
97
98 // calculate Fluid In Place
99 Inplace calc_inplace(std::map<std::string, double>& miscSummaryData,
100 std::map<std::string, std::vector<double>>& regionData,
101 const Parallel::Communication& comm);
102
103 void outputFipAndResvLog(const Inplace& inplace,
104 const std::size_t reportStepNum,
105 double elapsed,
106 boost::posix_time::ptime currentDate,
107 const bool substep,
108 const Parallel::Communication& comm);
109
110 void outputErrorLog(const Parallel::Communication& comm) const;
111
112 void addRftDataToWells(data::Wells& wellDatas,
113 std::size_t reportStepNum);
114
118 void assignToSolution(data::Solution& sol);
119
120 void setRestart(const data::Solution& sol,
121 unsigned elemIdx,
122 unsigned globalDofIndex);
123
124 Scalar getSolventSaturation(unsigned elemIdx) const
125 {
126 if (sSol_.size() > elemIdx)
127 return sSol_[elemIdx];
128
129 return 0;
130 }
131
132 Scalar getSolventRsw(unsigned elemIdx) const
133 {
134 if (rswSol_.size() > elemIdx)
135 return rswSol_[elemIdx];
136
137 return 0;
138 }
139
140 Scalar getPolymerConcentration(unsigned elemIdx) const
141 {
142 if (cPolymer_.size() > elemIdx)
143 return cPolymer_[elemIdx];
144
145 return 0;
146 }
147
148 Scalar getFoamConcentration(unsigned elemIdx) const
149 {
150 if (cFoam_.size() > elemIdx)
151 return cFoam_[elemIdx];
152
153 return 0;
154 }
155
156 Scalar getSaltConcentration(unsigned elemIdx) const
157 {
158 if (cSalt_.size() > elemIdx)
159 return cSalt_[elemIdx];
160
161 return 0;
162 }
163
164 Scalar getSaltSaturation(unsigned elemIdx) const
165 {
166 if (pSalt_.size() > elemIdx)
167 return pSalt_[elemIdx];
168
169 return 0;
170 }
171
172 Scalar getPermFactor(unsigned elemIdx) const
173 {
174 if (permFact_.size() > elemIdx)
175 return permFact_[elemIdx];
176
177 return 0;
178 }
179
180 Scalar getMicrobialConcentration(unsigned elemIdx) const
181 {
182 if (cMicrobes_.size() > elemIdx)
183 return cMicrobes_[elemIdx];
184
185 return 0;
186 }
187
188 Scalar getOxygenConcentration(unsigned elemIdx) const
189 {
190 if (cOxygen_.size() > elemIdx)
191 return cOxygen_[elemIdx];
192
193 return 0;
194 }
195
196 Scalar getUreaConcentration(unsigned elemIdx) const
197 {
198 if (cUrea_.size() > elemIdx)
199 return cUrea_[elemIdx];
200
201 return 0;
202 }
203
204 Scalar getBiofilmConcentration(unsigned elemIdx) const
205 {
206 if (cBiofilm_.size() > elemIdx)
207 return cBiofilm_[elemIdx];
208
209 return 0;
210 }
211
212 Scalar getCalciteConcentration(unsigned elemIdx) const
213 {
214 if (cCalcite_.size() > elemIdx)
215 return cCalcite_[elemIdx];
216
217 return 0;
218 }
219
220 const std::array<FlowsData<double>, 3>& getFlowsn() const
221 {
222 return this->flowsn_;
223 }
224
225 bool hasFlowsn() const
226 {
227 return enableFlowsn_;
228 }
229
230 bool hasFlows() const
231 {
232 return enableFlows_;
233 }
234
235 bool hasBlockFlows() const
236 {
237 return blockFlows_;
238 }
239
240 bool anyFlows() const
241 {
242 return anyFlows_;
243 }
244
245 const std::array<FlowsData<double>, 3>& getFloresn() const
246 {
247 return this->floresn_;
248 }
249
250 bool hasFloresn() const
251 {
252 return enableFloresn_;
253 }
254
255 bool hasFlores() const
256 {
257 return enableFlores_;
258 }
259
260 bool anyFlores() const
261 {
262 return anyFlores_;
263 }
264
265 bool needInterfaceFluxes([[maybe_unused]] const bool isSubStep) const
266 {
267 return this->interRegionFlows_.wantInterRegflowSummary();
268 }
269
270 const std::map<std::pair<std::string, int>, double>& getBlockData()
271 {
272 return blockData_;
273 }
274
275 const Inplace& initialInplace() const
276 {
277 return this->initialInplace_.value();
278 }
279
280 bool localDataValid() const{
281 return local_data_valid_;
282 }
283
284 void invalidateLocalData(){
285 local_data_valid_ = false;
286 }
287
288 void validateLocalData(){
289 local_data_valid_ = true;
290 }
291
292 void setCnvData(const std::vector<std::vector<int>>& data)
293 {
294 cnvData_ = data;
295 }
296
297 template<class Serializer>
298 void serializeOp(Serializer& serializer)
299 {
300 serializer(initialInplace_);
301 }
302
307 void assignGlobalFieldsToSolution(data::Solution& sol);
308
309protected:
310 using ScalarBuffer = std::vector<Scalar>;
311 using StringBuffer = std::vector<std::string>;
312 enum { numPhases = FluidSystem::numPhases };
313 enum { numComponents = FluidSystem::numComponents };
314 enum { gasPhaseIdx = FluidSystem::gasPhaseIdx };
315 enum { oilPhaseIdx = FluidSystem::oilPhaseIdx };
316 enum { waterPhaseIdx = FluidSystem::waterPhaseIdx };
317 enum { gasCompIdx = FluidSystem::gasCompIdx };
318 enum { oilCompIdx = FluidSystem::oilCompIdx };
319 enum { waterCompIdx = FluidSystem::waterCompIdx };
320 using Dir = FaceDir::DirEnum;
321
322 GenericOutputBlackoilModule(const EclipseState& eclState,
323 const Schedule& schedule,
324 const SummaryConfig& summaryConfig,
325 const SummaryState& summaryState,
326 const std::string& moduleVersionName,
327 bool enableEnergy,
328 bool enableTemperature,
329 bool enableMech,
330 bool enableSolvent,
331 bool enablePolymer,
332 bool enableFoam,
333 bool enableBrine,
334 bool enableSaltPrecipitation,
335 bool enableExtbo,
336 bool enableMICP);
337
338 void doAllocBuffers(unsigned bufferSize,
339 unsigned reportStepNum,
340 const bool substep,
341 const bool log,
342 const bool isRestart,
343 const bool vapparsActive,
344 const bool enablePCHysteresis,
346 const bool enableWettingHysteresis,
347 unsigned numTracers,
348 const std::vector<bool>& enableSolTracers,
349 unsigned numOutputNnc);
350
351 void makeRegionSum(Inplace& inplace,
352 const std::string& region_name,
353 const Parallel::Communication& comm) const;
354
355 Inplace accumulateRegionSums(const Parallel::Communication& comm);
356
357 void updateSummaryRegionValues(const Inplace& inplace,
358 std::map<std::string, double>& miscSummaryData,
359 std::map<std::string, std::vector<double>>& regionData) const;
360
361 static bool isOutputCreationDirective_(const std::string& keyword);
362
363 // Sum Fip values over regions.
364 static ScalarBuffer regionSum(const ScalarBuffer& property,
365 const std::vector<int>& regionId,
366 const std::size_t maxNumberOfRegions,
367 const Parallel::Communication& comm);
368
369 static int regionMax(const std::vector<int>& region,
370 const Parallel::Communication& comm);
371
372 static void update(Inplace& inplace,
373 const std::string& region_name,
374 const Inplace::Phase phase,
375 const std::size_t ntFip,
376 const ScalarBuffer& values);
377
378 static Scalar sum(const ScalarBuffer& v);
379
380 void setupBlockData(std::function<bool(int)> isCartIdxOnThisRank);
381
382 virtual bool isDefunctParallelWell(std::string wname) const = 0;
383
384 const EclipseState& eclState_;
385 const Schedule& schedule_;
386 const SummaryState& summaryState_;
387
388 SummaryConfig summaryConfig_;
389
390 InterRegFlowMap interRegionFlows_;
391 LogOutputHelper<Scalar> logOutput_;
392
393 bool enableEnergy_{false};
394 bool enableTemperature_{false};
395 bool enableMech_{false};
396
397 bool enableSolvent_{false};
398 bool enablePolymer_{false};
399 bool enableFoam_{false};
400 bool enableBrine_{false};
401 bool enableSaltPrecipitation_{false};
402 bool enableExtbo_{false};
403 bool enableMICP_{false};
404
405 bool forceDisableFipOutput_{false};
406 bool forceDisableFipresvOutput_{false};
407 bool computeFip_{false};
408
412 bool noPrefix {false};
413
416 bool surface {false};
417
420 bool reservoir {false};
421
422 void clearBits()
423 {
424 this->noPrefix = this->surface = this->reservoir = false;
425 }
426
427 explicit operator bool() const
428 {
429 return this->noPrefix || this->surface || this->reservoir;
430 }
431 } outputFipRestart_{};
432
433 bool anyFlows_{false};
434 bool anyFlores_{false};
435 bool blockFlows_{false};
436 bool enableFlows_{false};
437 bool enableFlores_{false};
438 bool enableFlowsn_{false};
439 bool enableFloresn_{false};
440
441 std::unordered_map<Inplace::Phase, ScalarBuffer> fip_;
442 std::unordered_map<std::string, std::vector<int>> regions_;
443 std::unordered_map<Inplace::Phase, std::vector<SummaryConfigNode>> regionNodes_;
444
445 std::vector<SummaryConfigNode> RPRNodes_;
446 std::vector<SummaryConfigNode> RPRPNodes_;
447
448 std::vector<int> failedCellsPb_;
449 std::vector<int> failedCellsPd_;
450
451 ScalarBuffer gasFormationVolumeFactor_;
452 ScalarBuffer hydrocarbonPoreVolume_;
453 ScalarBuffer pressureTimesPoreVolume_;
454 ScalarBuffer pressureTimesHydrocarbonVolume_;
455 ScalarBuffer dynamicPoreVolume_;
456 ScalarBuffer rPorV_;
457 ScalarBuffer fluidPressure_;
458 ScalarBuffer temperature_;
459 ScalarBuffer rs_;
460 ScalarBuffer rsw_;
461 ScalarBuffer rv_;
462 ScalarBuffer rvw_;
463 ScalarBuffer overburdenPressure_;
464 ScalarBuffer oilSaturationPressure_;
465 ScalarBuffer drsdtcon_;
466 ScalarBuffer sSol_;
467 ScalarBuffer rswSol_;
468 ScalarBuffer cPolymer_;
469 ScalarBuffer cFoam_;
470 ScalarBuffer cSalt_;
471 ScalarBuffer pSalt_;
472 ScalarBuffer permFact_;
473 ScalarBuffer extboX_;
474 ScalarBuffer extboY_;
475 ScalarBuffer extboZ_;
476 ScalarBuffer mFracOil_;
477 ScalarBuffer mFracGas_;
478 ScalarBuffer mFracCo2_;
479 ScalarBuffer soMax_;
480 ScalarBuffer swMax_;
481 ScalarBuffer sgmax_;
482 ScalarBuffer shmax_;
483 ScalarBuffer somin_;
484 ScalarBuffer swmin_;
485 ScalarBuffer ppcw_;
486 ScalarBuffer gasDissolutionFactor_;
487 ScalarBuffer oilVaporizationFactor_;
488 ScalarBuffer gasDissolutionFactorInWater_;
489 ScalarBuffer waterVaporizationFactor_;
490 ScalarBuffer bubblePointPressure_;
491 ScalarBuffer dewPointPressure_;
492 ScalarBuffer rockCompPorvMultiplier_;
493 ScalarBuffer minimumOilPressure_;
494 ScalarBuffer saturatedOilFormationVolumeFactor_;
495 ScalarBuffer rockCompTransMultiplier_;
496 ScalarBuffer cMicrobes_;
497 ScalarBuffer cOxygen_;
498 ScalarBuffer cUrea_;
499 ScalarBuffer cBiofilm_;
500 ScalarBuffer cCalcite_;
501 ScalarBuffer pcgw_;
502 ScalarBuffer pcow_;
503 ScalarBuffer pcog_;
504
505 // buffers for mechanical output
506 ScalarBuffer mechPotentialForce_;
507 ScalarBuffer mechPotentialPressForce_;
508 ScalarBuffer mechPotentialTempForce_;
509
510 ScalarBuffer dispX_;
511 ScalarBuffer dispY_;
512 ScalarBuffer dispZ_;
513 ScalarBuffer stressXX_;
514 ScalarBuffer stressYY_;
515 ScalarBuffer stressZZ_;
516 ScalarBuffer stressXY_;
517 ScalarBuffer stressXZ_;
518 ScalarBuffer stressYZ_;
519 ScalarBuffer delstressXX_;
520 ScalarBuffer delstressYY_;
521 ScalarBuffer delstressZZ_;
522 ScalarBuffer delstressXY_;
523 ScalarBuffer delstressXZ_;
524 ScalarBuffer delstressYZ_;
525 ScalarBuffer strainXX_;
526 ScalarBuffer strainYY_;
527 ScalarBuffer strainZZ_;
528 ScalarBuffer strainXY_;
529 ScalarBuffer strainXZ_;
530 ScalarBuffer strainYZ_;
531
532 std::array<ScalarBuffer, numPhases> saturation_;
533 std::array<ScalarBuffer, numPhases> invB_;
534 std::array<ScalarBuffer, numPhases> density_;
535 std::array<ScalarBuffer, numPhases> viscosity_;
536 std::array<ScalarBuffer, numPhases> relativePermeability_;
537
538 std::vector<ScalarBuffer> freeTracerConcentrations_;
539 std::vector<ScalarBuffer> solTracerConcentrations_;
540
541 std::array<ScalarBuffer, numPhases> residual_;
542
543 std::array<std::array<ScalarBuffer, numPhases>, 6> flows_;
544 std::array<std::array<ScalarBuffer, numPhases>, 6> flores_;
545
546 std::array<FlowsData<double>, 3> floresn_;
547 std::array<FlowsData<double>, 3> flowsn_;
548
549 std::map<std::size_t, Scalar> oilConnectionPressures_;
550 std::map<std::size_t, Scalar> waterConnectionSaturations_;
551 std::map<std::size_t, Scalar> gasConnectionSaturations_;
552 std::map<std::pair<std::string, int>, double> blockData_;
553
554 std::vector<std::vector<int>> cnvData_;
555
556 std::optional<Inplace> initialInplace_;
557 bool local_data_valid_{false};
558
559 std::optional<RegionPhasePoreVolAverage> regionAvgDensity_;
560};
561
562} // namespace Opm
563
564#endif // OPM_GENERIC_OUTPUT_BLACK_OIL_MODULE_HPP
MPI-aware facility for converting collection of tuples of region ID pairs and associate flow rates in...
Definition GenericOutputBlackoilModule.hpp:61
std::vector< std::vector< int > > cnvData_
Data for CNV_xxx arrays.
Definition GenericOutputBlackoilModule.hpp:554
void assignGlobalFieldsToSolution(data::Solution &sol)
Assign fields that are in global numbering to the solution.
Definition GenericOutputBlackoilModule.cpp:1695
void prepareDensityAccumulation()
Clear internal arrays for parallel accumulation of per-region phase density averages.
Definition GenericOutputBlackoilModule.cpp:287
void accumulateDensityParallel()
Run cross-rank parallel accumulation of per-region phase density running sums (average values).
Definition GenericOutputBlackoilModule.cpp:296
void assignToSolution(data::Solution &sol)
Move all buffers to data::Solution.
Definition GenericOutputBlackoilModule.cpp:446
Inter-region flow accumulation maps for all region definition arrays.
Definition InterRegFlows.hpp:179
Definition LogOutputHelper.hpp:42
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilboundaryratevector.hh:37
std::string moduleVersionName()
Return the version name of the module, for example "2015.10" (for a release branch) or "2016....
Definition moduleVersion.cpp:34
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:242
Definition GenericOutputBlackoilModule.hpp:409
bool surface
Whether or not run requests surface condition fluid-in-place restart file output using the 'SFIP' mne...
Definition GenericOutputBlackoilModule.hpp:416
bool reservoir
Whether or not run requests reservoir condition fluid-in-place restart file output using the 'RFIP' m...
Definition GenericOutputBlackoilModule.hpp:420
bool noPrefix
Whether or not run requests (surface condition) fluid-in-place restart file output using the 'FIP' mn...
Definition GenericOutputBlackoilModule.hpp:412