FlowGenericVanguard.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*/
27#ifndef OPM_FLOW_GENERIC_VANGUARD_HPP
28#define OPM_FLOW_GENERIC_VANGUARD_HPP
29
30#include <dune/common/parallel/communication.hh>
31
32#include <opm/common/OpmLog/OpmLog.hpp>
33
34#include <opm/grid/common/GridEnums.hpp>
35
36#include <opm/input/eclipse/Schedule/Well/WellTestState.hpp>
37
39
40#include <cassert>
41#include <memory>
42#include <optional>
43#include <string>
44#include <unordered_map>
45#include <utility>
46#include <vector>
47
48namespace Opm::Parameters {
49
50struct AllowDistributedWells { static constexpr bool value = false; };
51struct AllowSplittingInactiveWells { static constexpr bool value = true; };
52
53struct EclOutputInterval { static constexpr int value = -1; };
54struct EdgeWeightsMethod { static constexpr auto value = "transmissibility"; };
55struct EnableDryRun { static constexpr auto value = "auto"; };
56struct EnableEclOutput { static constexpr auto value = true; };
57struct EnableOpmRstFile { static constexpr bool value = false; };
58struct ExternalPartition { static constexpr auto* value = ""; };
59
60template<class Scalar>
61struct ImbalanceTol { static constexpr Scalar value = 1.1; };
62
63struct IgnoreKeywords { static constexpr auto value = ""; };
64struct InputSkipMode { static constexpr auto value = "100"; };
65struct MetisParams { static constexpr auto value = "default"; };
66
67#if HAVE_OPENCL || HAVE_ROCSPARSE || HAVE_CUDA
68struct NumJacobiBlocks { static constexpr int value = 0; };
69#endif // HAVE_OPENCL || HAVE_ROCSPARSE || HAVE_CUDA
70
71struct OwnerCellsFirst { static constexpr bool value = true; };
72struct ParsingStrictness { static constexpr auto value = "normal"; };
73struct ActionParsingStrictness { static constexpr auto value = "normal"; };
74
77struct PartitionMethod { static constexpr auto value = "zoltanwell"; };
78struct AddCorners { static constexpr bool value = false; };
79struct NumOverlap { static constexpr int value = 1; };
80struct EdgeConformal { static constexpr bool value = false; };
81struct MinpvMergeCells { static constexpr bool value = false; };
82
83struct SchedRestart{ static constexpr bool value = false; };
84struct SerialPartitioning{ static constexpr bool value = false; };
85
86template<class Scalar>
87struct ZoltanImbalanceTol { static constexpr Scalar value = 1.1; };
88
89struct ZoltanPhgEdgeSizeThreshold { static constexpr auto value = 0.35; };
90
91struct ZoltanParams { static constexpr auto value = "graph"; };
92
93} // namespace Opm::Parameters
94
95namespace Opm {
96
97namespace Action { class State; }
98class Deck;
99class EclipseState;
100struct NumericalAquiferCell;
101class ParseContext;
102class Schedule;
103class Python;
104class SummaryConfig;
105class SummaryState;
106class UDQState;
107class WellTestState;
108
110public:
111 using ParallelWellStruct = std::vector<std::pair<std::string,bool>>;
112
115 std::unique_ptr<UDQState> udqState_;
116 std::unique_ptr<Action::State> actionState_;
117 std::unique_ptr<SummaryState> summaryState_;
118 std::unique_ptr<WellTestState> wtestState_;
119 std::shared_ptr<EclipseState> eclState_;
120 std::shared_ptr<Schedule> eclSchedule_;
121 std::shared_ptr<SummaryConfig> eclSummaryConfig_;
122 };
123
125
133 static void checkDualContinuumSupport(const EclipseState& eclState);
134
140 static void refuseDualContinuum(const EclipseState& eclState, const std::string& gridName);
141
148
154
156
163 static std::string canonicalDeckPath(const std::string& caseName);
164
168 double setupTime()
169 { return setupTime_; }
170
176 static void readDeck(const std::string& filename, const std::string& ignoredKeywords);
177
182
186 const EclipseState& eclState() const
187 { return *eclState_; }
188
189 EclipseState& eclState()
190 { return *eclState_; }
191
195 const Schedule& schedule() const
196 { return *eclSchedule_; }
197
198 Schedule& schedule()
199 { return *eclSchedule_; }
200
205 const SummaryConfig& summaryConfig() const
206 { return *eclSummaryConfig_; }
207
215 SummaryState& summaryState()
216 { return *summaryState_; }
217
218 const SummaryState& summaryState() const
219 { return *summaryState_; }
220
226 Action::State& actionState()
227 { return *actionState_; }
228
229 const Action::State& actionState() const
230 { return *actionState_; }
231
237 UDQState& udqState()
238 { return *udqState_; }
239
240 const UDQState& udqState() const
241 { return *udqState_; }
242
243 std::unique_ptr<WellTestState> transferWTestState() {
244 return std::move(this->wtestState_);
245 }
246
247
254 const std::string& caseName() const
255 { return caseName_; }
256
260 Dune::EdgeWeightMethod edgeWeightsMethod() const
261 { return edgeWeightsMethod_; }
262
266 int numJacobiBlocks() const
267 { return numJacobiBlocks_; }
268
272 bool ownersFirst() const
273 { return ownersFirst_; }
274
275 bool edgeConformal() const
276 { return edgeConformal_; }
277
280 bool minpvMergeCells() const
281 { return minpvMergeCells_; }
282
283#if HAVE_MPI
284 bool addCorners() const
285 { return addCorners_; }
286
287 int numOverlap() const
288 { return numOverlap_; }
289
293 Dune::PartitionMethod partitionMethod() const
294 { return partitionMethod_; }
295
301 { return serialPartitioning_; }
302
307 double imbalanceTol() const
308 {
310 OpmLog::info("The parameter --zoltan-imbalance-tol is deprecated "
311 "and has been renamed to --imbalance-tol, please "
312 "adjust your calls and scripts!");
313 return zoltanImbalanceTol_;
314 } else {
315 return imbalanceTol_;
316 }
317 }
318
319 const std::string& externalPartitionFile() const
320 {
321 return this->externalPartitionFile_;
322 }
323#endif // HAVE_MPI
324
329 { return enableDistributedWells_; }
330
335 bool enableEclOutput() const
336 { return enableEclOutput_; }
337
346 { return parallelWells_; }
347
349 static void setCommunication(std::unique_ptr<Opm::Parallel::Communication> comm)
350 { comm_ = std::move(comm); }
351
354 {
355 assert(comm_ != nullptr);
356 return *comm_;
357 }
358
359 // Private to avoid pulling schedule in header.
360 // Static state is not serialized, only use for restart.
361 template<class Serializer>
362 void serializeOp(Serializer& serializer);
363
364 // Only compares dynamic state.
365 bool operator==(const FlowGenericVanguard& rhs) const;
366
367protected:
368 void updateOutputDir_(std::string outputDir,
369 bool enableEclCompatFile);
370
371 void updateNOSIM_(std::string_view enableDryRun);
372
373 bool drsdtconEnabled() const;
374
375 std::unordered_map<std::size_t, const NumericalAquiferCell*> allAquiferCells() const;
376
377 void init();
378
379 template<class Scalar>
380 static void registerParameters_();
381
383
384 // These variables may be owned by both Python and the simulator
385 static std::unique_ptr<Parallel::Communication> comm_;
386
387 std::string caseName_;
388 std::string fileName_;
389 Dune::EdgeWeightMethod edgeWeightsMethod_;
390
391 // Not guarded by the GPU defines: those are private to the library, and
392 // the class layout must be the same wherever this header is compiled.
394
398
399#if HAVE_MPI
402
403 Dune::PartitionMethod partitionMethod_;
406
410 std::string zoltanParams_;
411
412 std::string metisParams_;
413
415#endif // HAVE_MPI
416
420
421 std::string ignoredKeywords_;
422 std::optional<int> outputInterval_;
425
426 std::unique_ptr<SummaryState> summaryState_;
427 std::unique_ptr<UDQState> udqState_;
428 std::unique_ptr<Action::State> actionState_;
429
430 // Observe that this instance is handled differently from the other state
431 // variables, it will only be initialized for a restart run. While
432 // initializing a restarted run this instance is transferred to the WGState
433 // member in the well model.
434 std::unique_ptr<WellTestState> wtestState_;
435
436 // these attributes point either to the internal or to the external version of the
437 // parser objects.
438 std::shared_ptr<Python> python;
439 // These variables may be owned by both Python and the simulator
440 std::shared_ptr<EclipseState> eclState_;
441 std::shared_ptr<Schedule> eclSchedule_;
442 std::shared_ptr<SummaryConfig> eclSummaryConfig_;
443
450};
451
452} // namespace Opm
453
454#endif // OPM_FLOW_GENERIC_VANGUARD_HPP
Definition: FlowGenericVanguard.hpp:109
bool enableDistributedWells_
Definition: FlowGenericVanguard.hpp:417
bool useMultisegmentWell_
Definition: FlowGenericVanguard.hpp:423
static Parallel::Communication & comm()
Obtain global communicator.
Definition: FlowGenericVanguard.hpp:353
bool ownersFirst_
Definition: FlowGenericVanguard.hpp:395
int numJacobiBlocks_
Definition: FlowGenericVanguard.hpp:393
int numJacobiBlocks() const
Number of blocks in the Block-Jacobi preconditioner.
Definition: FlowGenericVanguard.hpp:266
void updateNOSIM_(std::string_view enableDryRun)
const Schedule & schedule() const
Return a reference to the object that managages the ECL schedule.
Definition: FlowGenericVanguard.hpp:195
std::string zoltanParams_
Definition: FlowGenericVanguard.hpp:410
std::string caseName_
Definition: FlowGenericVanguard.hpp:387
std::unordered_map< std::size_t, const NumericalAquiferCell * > allAquiferCells() const
double setupTime()
Returns the wall time required to set up the simulator before it was born.
Definition: FlowGenericVanguard.hpp:168
bool addCorners() const
Definition: FlowGenericVanguard.hpp:284
std::string ignoredKeywords_
Definition: FlowGenericVanguard.hpp:421
Dune::PartitionMethod partitionMethod_
Definition: FlowGenericVanguard.hpp:403
const SummaryState & summaryState() const
Definition: FlowGenericVanguard.hpp:218
bool serialPartitioning() const
Parameter that decides if partitioning for parallel runs should be performed on a single process only...
Definition: FlowGenericVanguard.hpp:300
static void refuseDualContinuum(const EclipseState &eclState, const std::string &gridName)
Refuses a dual-continuum run on a grid that is not a CpGrid.
static void registerParameters_()
static SimulationModelParams modelParams_
Definition: FlowGenericVanguard.hpp:124
const SummaryConfig & summaryConfig() const
Return a reference to the object that determines which quantities ought to be put into the ECL summar...
Definition: FlowGenericVanguard.hpp:205
bool minpvMergeCells_
Definition: FlowGenericVanguard.hpp:397
bool zoltanImbalanceTolSet_
Definition: FlowGenericVanguard.hpp:407
static SimulationModelParams serializationTestParams()
ParallelWellStruct parallelWells_
Information about wells in parallel.
Definition: FlowGenericVanguard.hpp:449
void serializeOp(Serializer &serializer)
bool enableExperiments_
Definition: FlowGenericVanguard.hpp:424
static void setCommunication(std::unique_ptr< Opm::Parallel::Communication > comm)
Set global communication.
Definition: FlowGenericVanguard.hpp:349
bool enableDistributedWells() const
Whether perforations of a well might be distributed.
Definition: FlowGenericVanguard.hpp:328
bool serialPartitioning_
Definition: FlowGenericVanguard.hpp:404
~FlowGenericVanguard()
Destructor.
Action::State & actionState()
Returns the action state.
Definition: FlowGenericVanguard.hpp:226
std::shared_ptr< SummaryConfig > eclSummaryConfig_
Definition: FlowGenericVanguard.hpp:442
bool minpvMergeCells() const
Definition: FlowGenericVanguard.hpp:280
const EclipseState & eclState() const
Return a reference to the internalized ECL deck.
Definition: FlowGenericVanguard.hpp:186
double imbalanceTol() const
Parameter that sets the imbalance tolarance, depending on the chosen partition method.
Definition: FlowGenericVanguard.hpp:307
FlowGenericVanguard()
Constructor.
double zoltanPhgEdgeSizeThreshold_
Definition: FlowGenericVanguard.hpp:409
bool drsdtconEnabled() const
const std::string & externalPartitionFile() const
Definition: FlowGenericVanguard.hpp:319
Dune::EdgeWeightMethod edgeWeightsMethod_
Definition: FlowGenericVanguard.hpp:389
std::unique_ptr< WellTestState > transferWTestState()
Definition: FlowGenericVanguard.hpp:243
std::shared_ptr< Python > python
Definition: FlowGenericVanguard.hpp:438
const UDQState & udqState() const
Definition: FlowGenericVanguard.hpp:240
static std::string canonicalDeckPath(const std::string &caseName)
Returns the canonical path to a deck file.
void defineSimulationModel(SimulationModelParams &&params)
Set the simulation configuration objects.
bool enableEclOutput() const
Whether or not to emit result files that are compatible with a commercial reservoir simulator.
Definition: FlowGenericVanguard.hpp:335
bool enableEclOutput_
Definition: FlowGenericVanguard.hpp:418
const std::string & caseName() const
Returns the name of the case.
Definition: FlowGenericVanguard.hpp:254
bool ownersFirst() const
Parameter that decide if cells owned by rank are ordered before ghost cells.
Definition: FlowGenericVanguard.hpp:272
Dune::EdgeWeightMethod edgeWeightsMethod() const
Parameter deciding the edge-weight strategy of the load balancer.
Definition: FlowGenericVanguard.hpp:260
std::unique_ptr< WellTestState > wtestState_
Definition: FlowGenericVanguard.hpp:434
UDQState & udqState()
Returns the udq state.
Definition: FlowGenericVanguard.hpp:237
Dune::PartitionMethod partitionMethod() const
Parameter deciding which partition method to use.
Definition: FlowGenericVanguard.hpp:293
bool addCorners_
Definition: FlowGenericVanguard.hpp:400
bool edgeConformal() const
Definition: FlowGenericVanguard.hpp:275
EclipseState & eclState()
Definition: FlowGenericVanguard.hpp:189
double zoltanImbalanceTol_
Definition: FlowGenericVanguard.hpp:408
static std::unique_ptr< Parallel::Communication > comm_
Definition: FlowGenericVanguard.hpp:385
bool operator==(const FlowGenericVanguard &rhs) const
double imbalanceTol_
Definition: FlowGenericVanguard.hpp:405
std::unique_ptr< SummaryState > summaryState_
Definition: FlowGenericVanguard.hpp:426
static void readDeck(const std::string &filename, const std::string &ignoredKeywords)
Read a deck.
std::shared_ptr< Schedule > eclSchedule_
Definition: FlowGenericVanguard.hpp:441
const ParallelWellStruct & parallelWells() const
Retrieve collection (a vector of pairs) of well names and whether or not the corresponding well objec...
Definition: FlowGenericVanguard.hpp:345
Schedule & schedule()
Definition: FlowGenericVanguard.hpp:198
std::string externalPartitionFile_
Definition: FlowGenericVanguard.hpp:414
FlowGenericVanguard(SimulationModelParams &&params)
std::vector< std::pair< std::string, bool > > ParallelWellStruct
Definition: FlowGenericVanguard.hpp:111
bool allow_splitting_inactive_wells_
Definition: FlowGenericVanguard.hpp:419
double setupTime_
Definition: FlowGenericVanguard.hpp:382
std::optional< int > outputInterval_
Definition: FlowGenericVanguard.hpp:422
const Action::State & actionState() const
Definition: FlowGenericVanguard.hpp:229
int numOverlap_
Definition: FlowGenericVanguard.hpp:401
std::unique_ptr< UDQState > udqState_
Definition: FlowGenericVanguard.hpp:427
std::string fileName_
Definition: FlowGenericVanguard.hpp:388
std::string metisParams_
Definition: FlowGenericVanguard.hpp:412
static void checkDualContinuumSupport(const EclipseState &eclState)
Refuses a dual-continuum run with a transfer that has no matrix-fracture coupling.
std::unique_ptr< Action::State > actionState_
Definition: FlowGenericVanguard.hpp:428
SummaryState & summaryState()
Returns the summary state.
Definition: FlowGenericVanguard.hpp:215
int numOverlap() const
Definition: FlowGenericVanguard.hpp:287
std::shared_ptr< EclipseState > eclState_
Definition: FlowGenericVanguard.hpp:440
void updateOutputDir_(std::string outputDir, bool enableEclCompatFile)
bool edgeConformal_
Definition: FlowGenericVanguard.hpp:396
Dune::Communication< MPIComm > Communication
Definition: ParallelCommunication.hpp:30
Definition: blackoilnewtonmethodparams.hpp:31
Definition: blackoilbioeffectsmodules.hh:45
Definition: FlowGenericVanguard.hpp:113
std::unique_ptr< UDQState > udqState_
Definition: FlowGenericVanguard.hpp:115
std::shared_ptr< Schedule > eclSchedule_
Definition: FlowGenericVanguard.hpp:120
std::unique_ptr< SummaryState > summaryState_
Definition: FlowGenericVanguard.hpp:117
std::shared_ptr< EclipseState > eclState_
Definition: FlowGenericVanguard.hpp:119
std::shared_ptr< SummaryConfig > eclSummaryConfig_
Definition: FlowGenericVanguard.hpp:121
double setupTime_
Definition: FlowGenericVanguard.hpp:114
std::unique_ptr< WellTestState > wtestState_
Definition: FlowGenericVanguard.hpp:118
std::unique_ptr< Action::State > actionState_
Definition: FlowGenericVanguard.hpp:116
Definition: FlowGenericVanguard.hpp:73
static constexpr auto value
Definition: FlowGenericVanguard.hpp:73
Definition: FlowGenericVanguard.hpp:78
static constexpr bool value
Definition: FlowGenericVanguard.hpp:78
Definition: FlowGenericVanguard.hpp:50
static constexpr bool value
Definition: FlowGenericVanguard.hpp:50
Definition: FlowGenericVanguard.hpp:51
static constexpr bool value
Definition: FlowGenericVanguard.hpp:51
Definition: FlowGenericVanguard.hpp:53
static constexpr int value
Definition: FlowGenericVanguard.hpp:53
Definition: FlowGenericVanguard.hpp:80
static constexpr bool value
Definition: FlowGenericVanguard.hpp:80
Definition: FlowGenericVanguard.hpp:54
static constexpr auto value
Definition: FlowGenericVanguard.hpp:54
Definition: FlowGenericVanguard.hpp:55
static constexpr auto value
Definition: FlowGenericVanguard.hpp:55
Definition: FlowGenericVanguard.hpp:56
static constexpr auto value
Definition: FlowGenericVanguard.hpp:56
Definition: FlowGenericVanguard.hpp:57
static constexpr bool value
Definition: FlowGenericVanguard.hpp:57
Definition: FlowGenericVanguard.hpp:58
static constexpr auto * value
Definition: FlowGenericVanguard.hpp:58
Definition: FlowGenericVanguard.hpp:63
static constexpr auto value
Definition: FlowGenericVanguard.hpp:63
Definition: FlowGenericVanguard.hpp:61
static constexpr Scalar value
Definition: FlowGenericVanguard.hpp:61
Definition: FlowGenericVanguard.hpp:64
static constexpr auto value
Definition: FlowGenericVanguard.hpp:64
Definition: FlowGenericVanguard.hpp:65
static constexpr auto value
Definition: FlowGenericVanguard.hpp:65
Definition: FlowGenericVanguard.hpp:81
static constexpr bool value
Definition: FlowGenericVanguard.hpp:81
Definition: FlowGenericVanguard.hpp:79
static constexpr int value
Definition: FlowGenericVanguard.hpp:79
Definition: FlowGenericVanguard.hpp:71
static constexpr bool value
Definition: FlowGenericVanguard.hpp:71
Definition: FlowGenericVanguard.hpp:72
static constexpr auto value
Definition: FlowGenericVanguard.hpp:72
Definition: FlowGenericVanguard.hpp:77
static constexpr auto value
Definition: FlowGenericVanguard.hpp:77
Definition: FlowGenericVanguard.hpp:83
static constexpr bool value
Definition: FlowGenericVanguard.hpp:83
Definition: FlowGenericVanguard.hpp:84
static constexpr bool value
Definition: FlowGenericVanguard.hpp:84
Definition: FlowGenericVanguard.hpp:87
static constexpr Scalar value
Definition: FlowGenericVanguard.hpp:87
Definition: FlowGenericVanguard.hpp:91
static constexpr auto value
Definition: FlowGenericVanguard.hpp:91
Definition: FlowGenericVanguard.hpp:89
static constexpr auto value
Definition: FlowGenericVanguard.hpp:89