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 outputWellspecReport(const std::vector<std::string>& changedWells,
125 const std::size_t reportStepNum,
126 const double elapsed,
127 boost::posix_time::ptime currentDate) const;
128
129 void outputErrorLog(const Parallel::Communication& comm) const;
130
131 void addRftDataToWells(data::Wells& wellDatas,
132 std::size_t reportStepNum,
133 const Parallel::Communication& comm)
134 { this->rftC_.addToWells(wellDatas, reportStepNum, comm); }
135
139 void assignToSolution(data::Solution& sol);
140
141 void setRestart(const data::Solution& sol,
142 unsigned elemIdx,
143 unsigned globalDofIndex);
144
145 Scalar getSolventSaturation(unsigned elemIdx) const
146 {
147 if (sSol_.size() > elemIdx)
148 return sSol_[elemIdx];
149
150 return 0;
151 }
152
153 Scalar getSolventRsw(unsigned elemIdx) const
154 {
155 if (rswSol_.size() > elemIdx)
156 return rswSol_[elemIdx];
157
158 return 0;
159 }
160
161 Scalar getPolymerConcentration(unsigned elemIdx) const
162 {
163 if (cPolymer_.size() > elemIdx)
164 return cPolymer_[elemIdx];
165
166 return 0;
167 }
168
169 Scalar getFoamConcentration(unsigned elemIdx) const
170 {
171 if (cFoam_.size() > elemIdx)
172 return cFoam_[elemIdx];
173
174 return 0;
175 }
176
177 Scalar getSaltConcentration(unsigned elemIdx) const
178 {
179 if (cSalt_.size() > elemIdx)
180 return cSalt_[elemIdx];
181
182 return 0;
183 }
184
185 Scalar getSaltSaturation(unsigned elemIdx) const
186 {
187 if (pSalt_.size() > elemIdx)
188 return pSalt_[elemIdx];
189
190 return 0;
191 }
192
193 Scalar getPermFactor(unsigned elemIdx) const
194 {
195 if (permFact_.size() > elemIdx)
196 return permFact_[elemIdx];
197
198 return 0;
199 }
200
201 const std::vector<Scalar>& getFluidPressure() const
202 { return fluidPressure_; }
203
204 const MICPContainer<Scalar>& getMICP() const
205 { return this->micpC_; }
206
207 const FlowsContainer<FluidSystem>& getFlows() const
208 { return this->flowsC_; }
209
210 bool needInterfaceFluxes([[maybe_unused]] const bool isSubStep) const
211 {
212 return this->interRegionFlows_.wantInterRegflowSummary();
213 }
214
215 const std::map<std::pair<std::string, int>, double>& getBlockData()
216 {
217 return blockData_;
218 }
219
220 std::map<std::pair<std::string, int>, double>& getExtraBlockData()
221 {
222 return extraBlockData_;
223 }
224
225 const std::optional<Inplace>& initialInplace() const
226 {
227 return this->initialInplace_;
228 }
229
230 bool localDataValid() const{
231 return local_data_valid_;
232 }
233
234 void invalidateLocalData(){
235 local_data_valid_ = false;
236 }
237
238 void validateLocalData(){
239 local_data_valid_ = true;
240 }
241
242 template<class Serializer>
243 void serializeOp(Serializer& serializer)
244 {
245 serializer(initialInplace_);
246 }
247
248 RSTConv& getConv()
249 { return this->rst_conv_; }
250
251 const RSTConv& getConv() const
252 { return this->rst_conv_; }
253
258 void assignGlobalFieldsToSolution(data::Solution& sol);
259
260protected:
261 using ScalarBuffer = std::vector<Scalar>;
262 using StringBuffer = std::vector<std::string>;
263 enum { numPhases = FluidSystem::numPhases };
264 enum { numComponents = FluidSystem::numComponents };
265 static constexpr int gasPhaseIdx = FluidSystem::gasPhaseIdx;
266 static constexpr int oilPhaseIdx = FluidSystem::oilPhaseIdx;
267 static constexpr int waterPhaseIdx = FluidSystem::waterPhaseIdx;
268 enum { gasCompIdx = FluidSystem::gasCompIdx };
269 enum { oilCompIdx = FluidSystem::oilCompIdx };
270 enum { waterCompIdx = FluidSystem::waterCompIdx };
271 using Dir = FaceDir::DirEnum;
272
273 GenericOutputBlackoilModule(const EclipseState& eclState,
274 const Schedule& schedule,
275 const SummaryConfig& summaryConfig,
276 const SummaryState& summaryState,
277 const std::string& moduleVersionName,
278 RSTConv::LocalToGlobalCellFunc globalCell,
279 const Parallel::Communication& comm,
280 bool enableEnergy,
281 bool enableTemperature,
282 bool enableMech,
283 bool enableSolvent,
284 bool enablePolymer,
285 bool enableFoam,
286 bool enableBrine,
287 bool enableSaltPrecipitation,
288 bool enableExtbo,
289 bool enableMICP);
290
291 void doAllocBuffers(unsigned bufferSize,
292 unsigned reportStepNum,
293 const bool substep,
294 const bool log,
295 const bool isRestart,
297 unsigned numOutputNnc = 0,
298 std::map<std::string, int> rstKeywords = {});
299
300 void makeRegionSum(Inplace& inplace,
301 const std::string& region_name,
302 const Parallel::Communication& comm) const;
303
304 Inplace accumulateRegionSums(const Parallel::Communication& comm);
305
306 void updateSummaryRegionValues(const Inplace& inplace,
307 std::map<std::string, double>& miscSummaryData,
308 std::map<std::string, std::vector<double>>& regionData) const;
309
310 static bool isOutputCreationDirective_(const std::string& keyword);
311
312 // Sum Fip values over regions.
313 static ScalarBuffer regionSum(const ScalarBuffer& property,
314 const std::vector<int>& regionId,
315 const std::size_t maxNumberOfRegions,
316 const Parallel::Communication& comm);
317
318 static int regionMax(const std::vector<int>& region,
319 const Parallel::Communication& comm);
320
321 static void update(Inplace& inplace,
322 const std::string& region_name,
323 const Inplace::Phase phase,
324 const std::size_t ntFip,
325 const ScalarBuffer& values);
326
327 static Scalar sum(const ScalarBuffer& v);
328
329 void setupBlockData(std::function<bool(int)> isCartIdxOnThisRank);
330 void setupExtraBlockData(const std::size_t reportStepNum,
331 std::function<bool(int)> isCartIdxOnThisRank);
332
333 virtual bool isDefunctParallelWell(std::string wname) const = 0;
334
335 const EclipseState& eclState_;
336 const Schedule& schedule_;
337 const SummaryState& summaryState_;
338
339 SummaryConfig summaryConfig_;
340
341 InterRegFlowMap interRegionFlows_;
342 LogOutputHelper<Scalar> logOutput_;
343
344 bool enableEnergy_{false};
345 bool enableTemperature_{false};
346 bool enableMech_{false};
347
348 bool enableSolvent_{false};
349 bool enablePolymer_{false};
350 bool enableFoam_{false};
351 bool enableBrine_{false};
352 bool enableSaltPrecipitation_{false};
353 bool enableExtbo_{false};
354 bool enableMICP_{false};
355
356 bool forceDisableFipOutput_{false};
357 bool forceDisableFipresvOutput_{false};
358 bool computeFip_{false};
359
361 std::unordered_map<std::string, std::vector<int>> regions_;
362 std::unordered_map<Inplace::Phase, std::vector<SummaryConfigNode>> regionNodes_;
363
364 std::vector<SummaryConfigNode> RPRNodes_;
365 std::vector<SummaryConfigNode> RPRPNodes_;
366
367 std::vector<int> failedCellsPb_;
368 std::vector<int> failedCellsPd_;
369
370 ScalarBuffer gasFormationVolumeFactor_;
371 ScalarBuffer hydrocarbonPoreVolume_;
372 ScalarBuffer pressureTimesPoreVolume_;
373 ScalarBuffer pressureTimesHydrocarbonVolume_;
374 ScalarBuffer dynamicPoreVolume_;
375 ScalarBuffer rPorV_;
376 ScalarBuffer fluidPressure_;
377 ScalarBuffer temperature_;
378 ScalarBuffer rs_;
379 ScalarBuffer rsw_;
380 ScalarBuffer rv_;
381 ScalarBuffer rvw_;
382 ScalarBuffer overburdenPressure_;
383 ScalarBuffer oilSaturationPressure_;
384 ScalarBuffer drsdtcon_;
385 ScalarBuffer sSol_;
386 ScalarBuffer rswSol_;
387 ScalarBuffer cPolymer_;
388 ScalarBuffer cFoam_;
389 ScalarBuffer cSalt_;
390 ScalarBuffer pSalt_;
391 ScalarBuffer permFact_;
393 ScalarBuffer soMax_;
394 ScalarBuffer swMax_;
395 ScalarBuffer sgmax_;
396 ScalarBuffer shmax_;
397 ScalarBuffer somin_;
398 ScalarBuffer swmin_;
399 ScalarBuffer ppcw_;
400 ScalarBuffer gasDissolutionFactor_;
401 ScalarBuffer oilVaporizationFactor_;
402 ScalarBuffer gasDissolutionFactorInWater_;
403 ScalarBuffer waterVaporizationFactor_;
404 ScalarBuffer bubblePointPressure_;
405 ScalarBuffer dewPointPressure_;
406 ScalarBuffer rockCompPorvMultiplier_;
407 ScalarBuffer minimumOilPressure_;
408 ScalarBuffer saturatedOilFormationVolumeFactor_;
409 ScalarBuffer rockCompTransMultiplier_;
411 ScalarBuffer pcgw_;
412 ScalarBuffer pcow_;
413 ScalarBuffer pcog_;
414
415 // buffers for mechanical output
417
418 std::array<ScalarBuffer, numPhases> saturation_;
419 std::array<ScalarBuffer, numPhases> invB_;
420 std::array<ScalarBuffer, numPhases> density_;
421 std::array<ScalarBuffer, numPhases> viscosity_;
422 std::array<ScalarBuffer, numPhases> relativePermeability_;
423
425
426 std::array<ScalarBuffer, numPhases> residual_;
427
429
432
433 std::map<std::pair<std::string, int>, double> blockData_;
434 // Extra block data required for non-summary output reasons
435 // Example is the block pressures for RPTSCHED WELLS=2
436 std::map<std::pair<std::string, int>, double> extraBlockData_;
437
438 std::optional<Inplace> initialInplace_;
439 bool local_data_valid_{false};
440
441 std::optional<RegionPhasePoreVolAverage> regionAvgDensity_;
442};
443
444} // namespace Opm
445
446#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:1198
void prepareDensityAccumulation()
Clear internal arrays for parallel accumulation of per-region phase density averages.
Definition GenericOutputBlackoilModule.cpp:212
RSTConv rst_conv_
Helper class for RPTRST CONV.
Definition GenericOutputBlackoilModule.hpp:431
void accumulateDensityParallel()
Run cross-rank parallel accumulation of per-region phase density running sums (average values).
Definition GenericOutputBlackoilModule.cpp:221
void assignToSolution(data::Solution &sol)
Move all buffers to data::Solution.
Definition GenericOutputBlackoilModule.cpp:308
static void registerParameters()
Register all run-time parameters for the Vtk output module.
Definition GenericOutputBlackoilModule.cpp:190
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