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
37#include <opm/simulators/flow/FlowsContainer.hpp>
42#include <opm/simulators/flow/RegionPhasePVAverage.hpp>
44#include <opm/simulators/flow/RSTConv.hpp>
46
47#include <opm/simulators/utils/ParallelCommunication.hpp>
48
49#include <array>
50#include <cstddef>
51#include <functional>
52#include <map>
53#include <optional>
54#include <unordered_map>
55#include <utility>
56#include <vector>
57
58namespace Opm::Parameters {
59
60struct ForceDisableFluidInPlaceOutput { static constexpr bool value = false; };
61struct ForceDisableResvFluidInPlaceOutput { static constexpr bool value = false; };
62
63} // namespace Opm::Parameters
64
65namespace Opm {
66
67namespace data { class Solution; }
69class EclipseState;
70class Schedule;
71class SummaryConfig;
73class SummaryState;
74
75template<class FluidSystem>
77public:
78 using Scalar = typename FluidSystem::Scalar;
79
80 // Virtual destructor for safer inheritance.
82
86 static void registerParameters();
87
88 void outputTimeStamp(const std::string& lbl,
89 double elapsed,
90 int rstep,
91 boost::posix_time::ptime currentDate);
92
96
100
101 // write cumulative production and injection reports to output
102 void outputCumLog(std::size_t reportStepNum,
103 const bool connData);
104
105 // write production report to output
106 void outputProdLog(std::size_t reportStepNum,
107 const bool connData);
108
109 // write injection report to output
110 void outputInjLog(std::size_t reportStepNum,
111 const bool connData);
112
113 // write msw report to output
114 void outputMSWLog(std::size_t reportStepNum);
115
116 // calculate Initial Fluid In Place
117 void calc_initial_inplace(const Parallel::Communication& comm);
118
119 // calculate Fluid In Place
120 Inplace calc_inplace(std::map<std::string, double>& miscSummaryData,
121 std::map<std::string, std::vector<double>>& regionData,
122 const Parallel::Communication& comm);
123
124 void outputFipAndResvLog(const Inplace& inplace,
125 const std::size_t reportStepNum,
126 double elapsed,
127 boost::posix_time::ptime currentDate,
128 const bool substep,
129 const Parallel::Communication& comm);
130
131 void outputErrorLog(const Parallel::Communication& comm) const;
132
133 void addRftDataToWells(data::Wells& wellDatas,
134 std::size_t reportStepNum,
135 const Parallel::Communication& comm)
136 { this->rftC_.addToWells(wellDatas, reportStepNum, comm); }
137
141 void assignToSolution(data::Solution& sol);
142
143 void setRestart(const data::Solution& sol,
144 unsigned elemIdx,
145 unsigned globalDofIndex);
146
147 Scalar getSolventSaturation(unsigned elemIdx) const
148 {
149 if (sSol_.size() > elemIdx)
150 return sSol_[elemIdx];
151
152 return 0;
153 }
154
155 Scalar getSolventRsw(unsigned elemIdx) const
156 {
157 if (rswSol_.size() > elemIdx)
158 return rswSol_[elemIdx];
159
160 return 0;
161 }
162
163 Scalar getPolymerConcentration(unsigned elemIdx) const
164 {
165 if (cPolymer_.size() > elemIdx)
166 return cPolymer_[elemIdx];
167
168 return 0;
169 }
170
171 Scalar getFoamConcentration(unsigned elemIdx) const
172 {
173 if (cFoam_.size() > elemIdx)
174 return cFoam_[elemIdx];
175
176 return 0;
177 }
178
179 Scalar getSaltConcentration(unsigned elemIdx) const
180 {
181 if (cSalt_.size() > elemIdx)
182 return cSalt_[elemIdx];
183
184 return 0;
185 }
186
187 Scalar getSaltSaturation(unsigned elemIdx) const
188 {
189 if (pSalt_.size() > elemIdx)
190 return pSalt_[elemIdx];
191
192 return 0;
193 }
194
195 Scalar getPermFactor(unsigned elemIdx) const
196 {
197 if (permFact_.size() > elemIdx)
198 return permFact_[elemIdx];
199
200 return 0;
201 }
202
203 const std::vector<Scalar>& getFluidPressure() const
204 { return fluidPressure_; }
205
206 const MICPContainer<Scalar>& getMICP() const
207 { return this->micpC_; }
208
209 const FlowsContainer<FluidSystem>& getFlows() const
210 { return this->flowsC_; }
211
212 bool needInterfaceFluxes([[maybe_unused]] const bool isSubStep) const
213 {
214 return this->interRegionFlows_.wantInterRegflowSummary();
215 }
216
217 const std::map<std::pair<std::string, int>, double>& getBlockData()
218 {
219 return blockData_;
220 }
221
222 std::map<std::pair<std::string, int>, double>& getExtraBlockData()
223 {
224 return extraBlockData_;
225 }
226
227 const Inplace& initialInplace() const
228 {
229 return this->initialInplace_.value();
230 }
231
232 bool localDataValid() const{
233 return local_data_valid_;
234 }
235
236 void invalidateLocalData(){
237 local_data_valid_ = false;
238 }
239
240 void validateLocalData(){
241 local_data_valid_ = true;
242 }
243
244 template<class Serializer>
245 void serializeOp(Serializer& serializer)
246 {
247 serializer(initialInplace_);
248 }
249
250 RSTConv& getConv()
251 { return this->rst_conv_; }
252
253 const RSTConv& getConv() const
254 { return this->rst_conv_; }
255
260 void assignGlobalFieldsToSolution(data::Solution& sol);
261
262protected:
263 using ScalarBuffer = std::vector<Scalar>;
264 using StringBuffer = std::vector<std::string>;
265 enum { numPhases = FluidSystem::numPhases };
266 enum { numComponents = FluidSystem::numComponents };
267 static constexpr int gasPhaseIdx = FluidSystem::gasPhaseIdx;
268 static constexpr int oilPhaseIdx = FluidSystem::oilPhaseIdx;
269 static constexpr int waterPhaseIdx = FluidSystem::waterPhaseIdx;
270 enum { gasCompIdx = FluidSystem::gasCompIdx };
271 enum { oilCompIdx = FluidSystem::oilCompIdx };
272 enum { waterCompIdx = FluidSystem::waterCompIdx };
273 using Dir = FaceDir::DirEnum;
274
275 GenericOutputBlackoilModule(const EclipseState& eclState,
276 const Schedule& schedule,
277 const SummaryConfig& summaryConfig,
278 const SummaryState& summaryState,
279 const std::string& moduleVersionName,
280 RSTConv::LocalToGlobalCellFunc globalCell,
281 const Parallel::Communication& comm,
282 bool enableEnergy,
283 bool enableTemperature,
284 bool enableMech,
285 bool enableSolvent,
286 bool enablePolymer,
287 bool enableFoam,
288 bool enableBrine,
289 bool enableSaltPrecipitation,
290 bool enableExtbo,
291 bool enableMICP);
292
293 void doAllocBuffers(unsigned bufferSize,
294 unsigned reportStepNum,
295 const bool substep,
296 const bool log,
297 const bool isRestart,
299 unsigned numOutputNnc = 0,
300 std::map<std::string, int> rstKeywords = {});
301
302 void makeRegionSum(Inplace& inplace,
303 const std::string& region_name,
304 const Parallel::Communication& comm) const;
305
306 Inplace accumulateRegionSums(const Parallel::Communication& comm);
307
308 void updateSummaryRegionValues(const Inplace& inplace,
309 std::map<std::string, double>& miscSummaryData,
310 std::map<std::string, std::vector<double>>& regionData) const;
311
312 static bool isOutputCreationDirective_(const std::string& keyword);
313
314 // Sum Fip values over regions.
315 static ScalarBuffer regionSum(const ScalarBuffer& property,
316 const std::vector<int>& regionId,
317 const std::size_t maxNumberOfRegions,
318 const Parallel::Communication& comm);
319
320 static int regionMax(const std::vector<int>& region,
321 const Parallel::Communication& comm);
322
323 static void update(Inplace& inplace,
324 const std::string& region_name,
325 const Inplace::Phase phase,
326 const std::size_t ntFip,
327 const ScalarBuffer& values);
328
329 static Scalar sum(const ScalarBuffer& v);
330
331 void setupBlockData(std::function<bool(int)> isCartIdxOnThisRank);
332 void setupExtraBlockData(const std::size_t reportStepNum,
333 std::function<bool(int)> isCartIdxOnThisRank);
334
335 virtual bool isDefunctParallelWell(std::string wname) const = 0;
336
337 const EclipseState& eclState_;
338 const Schedule& schedule_;
339 const SummaryState& summaryState_;
340
341 SummaryConfig summaryConfig_;
342
343 InterRegFlowMap interRegionFlows_;
344 LogOutputHelper<Scalar> logOutput_;
345
346 bool enableEnergy_{false};
347 bool enableTemperature_{false};
348 bool enableMech_{false};
349
350 bool enableSolvent_{false};
351 bool enablePolymer_{false};
352 bool enableFoam_{false};
353 bool enableBrine_{false};
354 bool enableSaltPrecipitation_{false};
355 bool enableExtbo_{false};
356 bool enableMICP_{false};
357
358 bool forceDisableFipOutput_{false};
359 bool forceDisableFipresvOutput_{false};
360 bool computeFip_{false};
361
363 std::unordered_map<std::string, std::vector<int>> regions_;
364 std::unordered_map<Inplace::Phase, std::vector<SummaryConfigNode>> regionNodes_;
365
366 std::vector<SummaryConfigNode> RPRNodes_;
367 std::vector<SummaryConfigNode> RPRPNodes_;
368
369 std::vector<int> failedCellsPb_;
370 std::vector<int> failedCellsPd_;
371
372 ScalarBuffer gasFormationVolumeFactor_;
373 ScalarBuffer hydrocarbonPoreVolume_;
374 ScalarBuffer pressureTimesPoreVolume_;
375 ScalarBuffer pressureTimesHydrocarbonVolume_;
376 ScalarBuffer dynamicPoreVolume_;
377 ScalarBuffer rPorV_;
378 ScalarBuffer fluidPressure_;
379 ScalarBuffer temperature_;
380 ScalarBuffer rs_;
381 ScalarBuffer rsw_;
382 ScalarBuffer rv_;
383 ScalarBuffer rvw_;
384 ScalarBuffer overburdenPressure_;
385 ScalarBuffer oilSaturationPressure_;
386 ScalarBuffer drsdtcon_;
387 ScalarBuffer sSol_;
388 ScalarBuffer rswSol_;
389 ScalarBuffer cPolymer_;
390 ScalarBuffer cFoam_;
391 ScalarBuffer cSalt_;
392 ScalarBuffer pSalt_;
393 ScalarBuffer permFact_;
395 ScalarBuffer soMax_;
396 ScalarBuffer swMax_;
397 ScalarBuffer sgmax_;
398 ScalarBuffer shmax_;
399 ScalarBuffer somin_;
400 ScalarBuffer swmin_;
401 ScalarBuffer ppcw_;
402 ScalarBuffer gasDissolutionFactor_;
403 ScalarBuffer oilVaporizationFactor_;
404 ScalarBuffer gasDissolutionFactorInWater_;
405 ScalarBuffer waterVaporizationFactor_;
406 ScalarBuffer bubblePointPressure_;
407 ScalarBuffer dewPointPressure_;
408 ScalarBuffer rockCompPorvMultiplier_;
409 ScalarBuffer minimumOilPressure_;
410 ScalarBuffer saturatedOilFormationVolumeFactor_;
411 ScalarBuffer rockCompTransMultiplier_;
413 ScalarBuffer pcgw_;
414 ScalarBuffer pcow_;
415 ScalarBuffer pcog_;
416
417 // buffers for mechanical output
419
420 std::array<ScalarBuffer, numPhases> saturation_;
421 std::array<ScalarBuffer, numPhases> invB_;
422 std::array<ScalarBuffer, numPhases> density_;
423 std::array<ScalarBuffer, numPhases> viscosity_;
424 std::array<ScalarBuffer, numPhases> relativePermeability_;
425
427
428 std::array<ScalarBuffer, numPhases> residual_;
429
431
434
435 std::map<std::pair<std::string, int>, double> blockData_;
436 // Extra block data required for non-summary output reasons
437 // Example is the block pressures for RPTSCHED WELLS=2
438 std::map<std::pair<std::string, int>, double> extraBlockData_;
439
440 std::optional<Inplace> initialInplace_;
441 bool local_data_valid_{false};
442
443 std::optional<RegionPhasePoreVolAverage> regionAvgDensity_;
444};
445
446} // namespace Opm
447
448#endif // OPM_GENERIC_OUTPUT_BLACK_OIL_MODULE_HPP
Output module for the results black oil model writing in ECL binary format.
Output module for the results black oil model writing in ECL binary format.
MPI-aware facility for converting collection of tuples of region ID pairs and associate flow rates in...
Output module for the results black oil model writing in ECL binary format.
Output module for the results black oil model writing in ECL binary format.
Output module for the results black oil model writing in ECL binary format.
Output module for the results black oil model writing in ECL binary format.
Definition ExtboContainer.hpp:37
Definition FIPContainer.hpp:47
Definition FlowsContainer.hpp:42
Definition GenericOutputBlackoilModule.hpp:76
void assignGlobalFieldsToSolution(data::Solution &sol)
Assign fields that are in global numbering to the solution.
Definition GenericOutputBlackoilModule.cpp:1191
void prepareDensityAccumulation()
Clear internal arrays for parallel accumulation of per-region phase density averages.
Definition GenericOutputBlackoilModule.cpp:185
RSTConv rst_conv_
Helper class for RPTRST CONV.
Definition GenericOutputBlackoilModule.hpp:433
void accumulateDensityParallel()
Run cross-rank parallel accumulation of per-region phase density running sums (average values).
Definition GenericOutputBlackoilModule.cpp:194
void assignToSolution(data::Solution &sol)
Move all buffers to data::Solution.
Definition GenericOutputBlackoilModule.cpp:319
static void registerParameters()
Register all run-time parameters for the Vtk output module.
Definition GenericOutputBlackoilModule.cpp:163
Inter-region flow accumulation maps for all region definition arrays.
Definition InterRegFlows.hpp:179
Definition LogOutputHelper.hpp:45
Definition MICPContainer.hpp:38
Definition MechContainer.hpp:45
Definition RFTContainer.hpp:44
Class computing RPTRST CONV output.
Definition RSTConv.hpp:36
Definition TracerContainer.hpp:39
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:60
Definition GenericOutputBlackoilModule.hpp:61