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