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 EclOutputInterval { static constexpr int value = -1; };
52struct EdgeWeightsMethod { static constexpr int value = 1; };
53struct EnableDryRun { static constexpr auto value = "auto"; };
54struct EnableOpmRstFile { static constexpr bool value = false; };
55struct ExternalPartition { static constexpr auto* value = ""; };
56
57template<class Scalar>
58struct ImbalanceTol { static constexpr Scalar value = 1.1; };
59
60struct IgnoreKeywords { static constexpr auto value = ""; };
61struct InputSkipMode { static constexpr auto value = "100"; };
62struct MetisParams { static constexpr auto value = "default"; };
63
64#if HAVE_OPENCL || HAVE_ROCSPARSE || HAVE_CUDA
65struct NumJacobiBlocks { static constexpr int value = 0; };
66#endif
67
68struct OwnerCellsFirst { static constexpr bool value = true; };
69struct ParsingStrictness { static constexpr auto value = "normal"; };
70struct ActionParsingStrictness { static constexpr auto value = "normal"; };
71
72 // 0: simple, 1: Zoltan, 2: METIS, see GridEnums.hpp
73struct PartitionMethod { static constexpr int value = 1; };
74
75struct SchedRestart{ static constexpr bool value = false; };
76struct SerialPartitioning{ static constexpr bool value = false; };
77
78template<class Scalar>
79struct ZoltanImbalanceTol { static constexpr Scalar value = 1.1; };
80
81struct ZoltanParams { static constexpr auto value = "graph"; };
82
83} // namespace Opm::Parameters
84
85namespace Opm {
86
87namespace Action { class State; }
88class Deck;
89class EclipseState;
90struct NumericalAquiferCell;
91class ParseContext;
92class Schedule;
93class Python;
94class SummaryConfig;
95class SummaryState;
96class UDQState;
97class WellTestState;
98
100public:
101 using ParallelWellStruct = std::vector<std::pair<std::string,bool>>;
102
105 std::unique_ptr<UDQState> udqState_;
106 std::unique_ptr<Action::State> actionState_;
107 std::unique_ptr<SummaryState> summaryState_;
108 std::unique_ptr<WellTestState> wtestState_;
109 std::shared_ptr<EclipseState> eclState_;
110 std::shared_ptr<Schedule> eclSchedule_;
111 std::shared_ptr<SummaryConfig> eclSummaryConfig_;
112 };
113
115
122
128
130
137 static std::string canonicalDeckPath(const std::string& caseName);
138
142 double setupTime()
143 { return setupTime_; }
144
149 static void readDeck(const std::string& filename);
150
155
159 const EclipseState& eclState() const
160 { return *eclState_; }
161
162 EclipseState& eclState()
163 { return *eclState_; }
164
168 const Schedule& schedule() const
169 { return *eclSchedule_; }
170
171 Schedule& schedule()
172 { return *eclSchedule_; }
173
178 const SummaryConfig& summaryConfig() const
179 { return *eclSummaryConfig_; }
180
188 SummaryState& summaryState()
189 { return *summaryState_; }
190
191 const SummaryState& summaryState() const
192 { return *summaryState_; }
193
199 Action::State& actionState()
200 { return *actionState_; }
201
202 const Action::State& actionState() const
203 { return *actionState_; }
204
210 UDQState& udqState()
211 { return *udqState_; }
212
213 const UDQState& udqState() const
214 { return *udqState_; }
215
216 std::unique_ptr<WellTestState> transferWTestState() {
217 return std::move(this->wtestState_);
218 }
219
220
227 const std::string& caseName() const
228 { return caseName_; }
229
233 Dune::EdgeWeightMethod edgeWeightsMethod() const
234 { return edgeWeightsMethod_; }
235
239 int numJacobiBlocks() const
240 {
241#if HAVE_OPENCL || HAVE_ROCSPARSE || HAVE_CUDA
242 return numJacobiBlocks_;
243#else
244 return 0;
245#endif
246 }
247
251 bool ownersFirst() const
252 { return ownersFirst_; }
253
254#if HAVE_MPI
258 Dune::PartitionMethod partitionMethod() const
259 { return partitionMethod_; }
265 { return serialPartitioning_; }
266
270 double imbalanceTol() const
271 {
273 OpmLog::info("The parameter --zoltan-imbalance-tol is deprecated and has been renamed to --imbalance-tol, please adjust your calls and scripts!");
274 return zoltanImbalanceTol_;
275 } else {
276 return imbalanceTol_;
277 }
278 }
279
280 const std::string& externalPartitionFile() const
281 {
282 return this->externalPartitionFile_;
283 }
284#endif
285
290 { return enableDistributedWells_; }
291
299 { return parallelWells_; }
300
302 static void setCommunication(std::unique_ptr<Opm::Parallel::Communication> comm)
303 { comm_ = std::move(comm); }
304
307 {
308 assert(comm_);
309 return *comm_;
310 }
311
312 // Private to avoid pulling schedule in header.
313 // Static state is not serialized, only use for restart.
314 template<class Serializer>
315 void serializeOp(Serializer& serializer);
316
317 // Only compares dynamic state.
318 bool operator==(const FlowGenericVanguard& rhs) const;
319
320protected:
321 void updateOutputDir_(std::string outputDir,
322 bool enableEclCompatFile);
323
324 void updateNOSIM_(std::string_view enableDryRun);
325
326 bool drsdtconEnabled() const;
327
328 std::unordered_map<std::size_t, const NumericalAquiferCell*> allAquiferCells() const;
329
330 void init();
331
332 template<class Scalar>
333 static void registerParameters_();
334
336
337 // These variables may be owned by both Python and the simulator
338 static std::unique_ptr<Parallel::Communication> comm_;
339
340 std::string caseName_;
341 std::string fileName_;
342 Dune::EdgeWeightMethod edgeWeightsMethod_;
343
344#if HAVE_OPENCL || HAVE_ROCSPARSE || HAVE_CUDA
345 int numJacobiBlocks_{0};
346#endif
347
349#if HAVE_MPI
350 Dune::PartitionMethod partitionMethod_;
353
356 std::string zoltanParams_;
357
358 std::string metisParams_;
359
361#endif
363 std::string ignoredKeywords_;
364 std::optional<int> outputInterval_;
367
368 std::unique_ptr<SummaryState> summaryState_;
369 std::unique_ptr<UDQState> udqState_;
370 std::unique_ptr<Action::State> actionState_;
371
372 // Observe that this instance is handled differently from the other state
373 // variables, it will only be initialized for a restart run. While
374 // initializing a restarted run this instance is transferred to the WGState
375 // member in the well model.
376 std::unique_ptr<WellTestState> wtestState_;
377
378 // these attributes point either to the internal or to the external version of the
379 // parser objects.
380 std::shared_ptr<Python> python;
381 // These variables may be owned by both Python and the simulator
382 std::shared_ptr<EclipseState> eclState_;
383 std::shared_ptr<Schedule> eclSchedule_;
384 std::shared_ptr<SummaryConfig> eclSummaryConfig_;
385
392};
393
394} // namespace Opm
395
396#endif // OPM_FLOW_GENERIC_VANGUARD_HPP
Definition: FlowGenericVanguard.hpp:99
bool enableDistributedWells_
Definition: FlowGenericVanguard.hpp:362
bool useMultisegmentWell_
Definition: FlowGenericVanguard.hpp:365
static Parallel::Communication & comm()
Obtain global communicator.
Definition: FlowGenericVanguard.hpp:306
bool ownersFirst_
Definition: FlowGenericVanguard.hpp:348
int numJacobiBlocks() const
Number of blocks in the Block-Jacobi preconditioner.
Definition: FlowGenericVanguard.hpp:239
void updateNOSIM_(std::string_view enableDryRun)
const Schedule & schedule() const
Return a reference to the object that managages the ECL schedule.
Definition: FlowGenericVanguard.hpp:168
std::string zoltanParams_
Definition: FlowGenericVanguard.hpp:356
std::string caseName_
Definition: FlowGenericVanguard.hpp:340
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:142
std::string ignoredKeywords_
Definition: FlowGenericVanguard.hpp:363
Dune::PartitionMethod partitionMethod_
Definition: FlowGenericVanguard.hpp:350
const SummaryState & summaryState() const
Definition: FlowGenericVanguard.hpp:191
bool serialPartitioning() const
Parameter that decides if partitioning for parallel runs should be performed on a single process only...
Definition: FlowGenericVanguard.hpp:264
static void registerParameters_()
static SimulationModelParams modelParams_
Definition: FlowGenericVanguard.hpp:114
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:178
bool zoltanImbalanceTolSet_
Definition: FlowGenericVanguard.hpp:354
static SimulationModelParams serializationTestParams()
ParallelWellStruct parallelWells_
Information about wells in parallel.
Definition: FlowGenericVanguard.hpp:391
void serializeOp(Serializer &serializer)
bool enableExperiments_
Definition: FlowGenericVanguard.hpp:366
static void setCommunication(std::unique_ptr< Opm::Parallel::Communication > comm)
Set global communication.
Definition: FlowGenericVanguard.hpp:302
bool enableDistributedWells() const
Whether perforations of a well might be distributed.
Definition: FlowGenericVanguard.hpp:289
bool serialPartitioning_
Definition: FlowGenericVanguard.hpp:351
~FlowGenericVanguard()
Destructor.
Action::State & actionState()
Returns the action state.
Definition: FlowGenericVanguard.hpp:199
std::shared_ptr< SummaryConfig > eclSummaryConfig_
Definition: FlowGenericVanguard.hpp:384
const EclipseState & eclState() const
Return a reference to the internalized ECL deck.
Definition: FlowGenericVanguard.hpp:159
double imbalanceTol() const
Parameter that sets the imbalance tolarance, depending on the chosen partition method.
Definition: FlowGenericVanguard.hpp:270
FlowGenericVanguard()
Constructor.
bool drsdtconEnabled() const
const std::string & externalPartitionFile() const
Definition: FlowGenericVanguard.hpp:280
Dune::EdgeWeightMethod edgeWeightsMethod_
Definition: FlowGenericVanguard.hpp:342
std::unique_ptr< WellTestState > transferWTestState()
Definition: FlowGenericVanguard.hpp:216
std::shared_ptr< Python > python
Definition: FlowGenericVanguard.hpp:380
const UDQState & udqState() const
Definition: FlowGenericVanguard.hpp:213
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.
const std::string & caseName() const
Returns the name of the case.
Definition: FlowGenericVanguard.hpp:227
bool ownersFirst() const
Parameter that decide if cells owned by rank are ordered before ghost cells.
Definition: FlowGenericVanguard.hpp:251
Dune::EdgeWeightMethod edgeWeightsMethod() const
Parameter deciding the edge-weight strategy of the load balancer.
Definition: FlowGenericVanguard.hpp:233
std::unique_ptr< WellTestState > wtestState_
Definition: FlowGenericVanguard.hpp:376
UDQState & udqState()
Returns the udq state.
Definition: FlowGenericVanguard.hpp:210
Dune::PartitionMethod partitionMethod() const
Parameter deciding which partition method to use.
Definition: FlowGenericVanguard.hpp:258
EclipseState & eclState()
Definition: FlowGenericVanguard.hpp:162
double zoltanImbalanceTol_
Definition: FlowGenericVanguard.hpp:355
static std::unique_ptr< Parallel::Communication > comm_
Definition: FlowGenericVanguard.hpp:338
bool operator==(const FlowGenericVanguard &rhs) const
static void readDeck(const std::string &filename)
Read a deck.
double imbalanceTol_
Definition: FlowGenericVanguard.hpp:352
std::unique_ptr< SummaryState > summaryState_
Definition: FlowGenericVanguard.hpp:368
std::shared_ptr< Schedule > eclSchedule_
Definition: FlowGenericVanguard.hpp:383
const ParallelWellStruct & parallelWells() const
Returns vector with name and whether the has local perforated cells for all wells.
Definition: FlowGenericVanguard.hpp:298
Schedule & schedule()
Definition: FlowGenericVanguard.hpp:171
std::string externalPartitionFile_
Definition: FlowGenericVanguard.hpp:360
FlowGenericVanguard(SimulationModelParams &&params)
std::vector< std::pair< std::string, bool > > ParallelWellStruct
Definition: FlowGenericVanguard.hpp:101
double setupTime_
Definition: FlowGenericVanguard.hpp:335
std::optional< int > outputInterval_
Definition: FlowGenericVanguard.hpp:364
const Action::State & actionState() const
Definition: FlowGenericVanguard.hpp:202
std::unique_ptr< UDQState > udqState_
Definition: FlowGenericVanguard.hpp:369
std::string fileName_
Definition: FlowGenericVanguard.hpp:341
std::string metisParams_
Definition: FlowGenericVanguard.hpp:358
std::unique_ptr< Action::State > actionState_
Definition: FlowGenericVanguard.hpp:370
SummaryState & summaryState()
Returns the summary state.
Definition: FlowGenericVanguard.hpp:188
std::shared_ptr< EclipseState > eclState_
Definition: FlowGenericVanguard.hpp:382
void updateOutputDir_(std::string outputDir, bool enableEclCompatFile)
Dune::Communication< MPIComm > Communication
Definition: ParallelCommunication.hpp:30
Definition: blackoilnewtonmethodparams.hpp:31
Definition: blackoilboundaryratevector.hh:37
Definition: FlowGenericVanguard.hpp:103
std::unique_ptr< UDQState > udqState_
Definition: FlowGenericVanguard.hpp:105
std::shared_ptr< Schedule > eclSchedule_
Definition: FlowGenericVanguard.hpp:110
std::unique_ptr< SummaryState > summaryState_
Definition: FlowGenericVanguard.hpp:107
std::shared_ptr< EclipseState > eclState_
Definition: FlowGenericVanguard.hpp:109
std::shared_ptr< SummaryConfig > eclSummaryConfig_
Definition: FlowGenericVanguard.hpp:111
double setupTime_
Definition: FlowGenericVanguard.hpp:104
std::unique_ptr< WellTestState > wtestState_
Definition: FlowGenericVanguard.hpp:108
std::unique_ptr< Action::State > actionState_
Definition: FlowGenericVanguard.hpp:106
Definition: FlowGenericVanguard.hpp:70
static constexpr auto value
Definition: FlowGenericVanguard.hpp:70
Definition: FlowGenericVanguard.hpp:50
static constexpr bool value
Definition: FlowGenericVanguard.hpp:50
Definition: FlowGenericVanguard.hpp:51
static constexpr int value
Definition: FlowGenericVanguard.hpp:51
Definition: FlowGenericVanguard.hpp:52
static constexpr int value
Definition: FlowGenericVanguard.hpp:52
Definition: FlowGenericVanguard.hpp:53
static constexpr auto value
Definition: FlowGenericVanguard.hpp:53
Definition: FlowGenericVanguard.hpp:54
static constexpr bool value
Definition: FlowGenericVanguard.hpp:54
Definition: FlowGenericVanguard.hpp:55
static constexpr auto * value
Definition: FlowGenericVanguard.hpp:55
Definition: FlowGenericVanguard.hpp:60
static constexpr auto value
Definition: FlowGenericVanguard.hpp:60
Definition: FlowGenericVanguard.hpp:58
static constexpr Scalar value
Definition: FlowGenericVanguard.hpp:58
Definition: FlowGenericVanguard.hpp:61
static constexpr auto value
Definition: FlowGenericVanguard.hpp:61
Definition: FlowGenericVanguard.hpp:62
static constexpr auto value
Definition: FlowGenericVanguard.hpp:62
Definition: FlowGenericVanguard.hpp:68
static constexpr bool value
Definition: FlowGenericVanguard.hpp:68
Definition: FlowGenericVanguard.hpp:69
static constexpr auto value
Definition: FlowGenericVanguard.hpp:69
Definition: FlowGenericVanguard.hpp:73
static constexpr int value
Definition: FlowGenericVanguard.hpp:73
Definition: FlowGenericVanguard.hpp:75
static constexpr bool value
Definition: FlowGenericVanguard.hpp:75
Definition: FlowGenericVanguard.hpp:76
static constexpr bool value
Definition: FlowGenericVanguard.hpp:76
Definition: FlowGenericVanguard.hpp:79
static constexpr Scalar value
Definition: FlowGenericVanguard.hpp:79
Definition: FlowGenericVanguard.hpp:81
static constexpr auto value
Definition: FlowGenericVanguard.hpp:81