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/grid/common/GridEnums.hpp>
33
34#include <opm/input/eclipse/Schedule/Well/WellTestState.hpp>
35
37
38#include <cassert>
39#include <memory>
40#include <optional>
41#include <string>
42#include <unordered_map>
43#include <utility>
44#include <vector>
45
46namespace Opm {
47
48namespace Action { class State; }
49class Deck;
50class EclipseState;
51struct NumericalAquiferCell;
52class ParseContext;
53class Schedule;
54class Python;
55class SummaryConfig;
56class SummaryState;
57class UDQState;
58class WellTestState;
59
61public:
62 using ParallelWellStruct = std::vector<std::pair<std::string,bool>>;
63
65 double setupTime_;
66 std::unique_ptr<UDQState> udqState_;
67 std::unique_ptr<Action::State> actionState_;
68 std::unique_ptr<SummaryState> summaryState_;
69 std::unique_ptr<WellTestState> wtestState_;
70 std::shared_ptr<EclipseState> eclState_;
71 std::shared_ptr<Schedule> eclSchedule_;
72 std::shared_ptr<SummaryConfig> eclSummaryConfig_;
73 };
74
76
83
89
91
98 static std::string canonicalDeckPath(const std::string& caseName);
99
103 double setupTime()
104 { return setupTime_; }
105
110 static void readDeck(const std::string& filename);
111
116
120 const EclipseState& eclState() const
121 { return *eclState_; }
122
123 EclipseState& eclState()
124 { return *eclState_; }
125
129 const Schedule& schedule() const
130 { return *eclSchedule_; }
131
132 Schedule& schedule()
133 { return *eclSchedule_; }
134
139 const SummaryConfig& summaryConfig() const
140 { return *eclSummaryConfig_; }
141
149 SummaryState& summaryState()
150 { return *summaryState_; }
151
152 const SummaryState& summaryState() const
153 { return *summaryState_; }
154
160 Action::State& actionState()
161 { return *actionState_; }
162
163 const Action::State& actionState() const
164 { return *actionState_; }
165
171 UDQState& udqState()
172 { return *udqState_; }
173
174 const UDQState& udqState() const
175 { return *udqState_; }
176
177 WellTestState transferWTestState() {
178 return *this->wtestState_.release();
179 }
180
181
188 const std::string& caseName() const
189 { return caseName_; }
190
194 Dune::EdgeWeightMethod edgeWeightsMethod() const
195 { return edgeWeightsMethod_; }
196
200 int numJacobiBlocks() const
201 {
202#if HAVE_OPENCL || HAVE_ROCSPARSE || HAVE_CUDA
203 return numJacobiBlocks_;
204#else
205 return 0;
206#endif
207 }
208
212 bool ownersFirst() const
213 { return ownersFirst_; }
214
215#if HAVE_MPI
221 { return serialPartitioning_; }
222
226 double zoltanImbalanceTol() const
227 { return zoltanImbalanceTol_; }
228
229 const std::string& externalPartitionFile() const
230 {
231 return this->externalPartitionFile_;
232 }
233#endif
234
239 { return enableDistributedWells_; }
240
248 { return parallelWells_; }
249
251 static void setCommunication(std::unique_ptr<Opm::Parallel::Communication> comm)
252 { comm_ = std::move(comm); }
253
256 {
257 assert(comm_);
258 return *comm_;
259 }
260
261 // Private to avoid pulling schedule in header.
262 // Static state is not serialized, only use for restart.
263 template<class Serializer>
264 void serializeOp(Serializer& serializer);
265
266 // Only compares dynamic state.
267 bool operator==(const FlowGenericVanguard& rhs) const;
268
269protected:
270 void updateOutputDir_(std::string outputDir,
271 bool enableEclCompatFile);
272
273 bool drsdtconEnabled() const;
274
275 std::unordered_map<std::size_t, const NumericalAquiferCell*> allAquiferCells() const;
276
277 void init();
278
280
281 // These variables may be owned by both Python and the simulator
282 static std::unique_ptr<Parallel::Communication> comm_;
283
284 std::string caseName_;
285 std::string fileName_;
286 Dune::EdgeWeightMethod edgeWeightsMethod_;
287
288#if HAVE_OPENCL || HAVE_ROCSPARSE || HAVE_CUDA
289 int numJacobiBlocks_{0};
290#endif
291
293#if HAVE_MPI
296 std::string zoltanParams_;
298#endif
300 std::string ignoredKeywords_;
301 std::optional<int> outputInterval_;
304
305 std::unique_ptr<SummaryState> summaryState_;
306 std::unique_ptr<UDQState> udqState_;
307 std::unique_ptr<Action::State> actionState_;
308
309 // Observe that this instance is handled differently from the other state
310 // variables, it will only be initialized for a restart run. While
311 // initializing a restarted run this instance is transferred to the WGState
312 // member in the well model.
313 std::unique_ptr<WellTestState> wtestState_;
314
315 // these attributes point either to the internal or to the external version of the
316 // parser objects.
317 std::shared_ptr<Python> python;
318 // These variables may be owned by both Python and the simulator
319 std::shared_ptr<EclipseState> eclState_;
320 std::shared_ptr<Schedule> eclSchedule_;
321 std::shared_ptr<SummaryConfig> eclSummaryConfig_;
322
329};
330
331} // namespace Opm
332
333#endif // OPM_FLOW_GENERIC_VANGUARD_HPP
Definition: FlowGenericVanguard.hpp:60
bool enableDistributedWells_
Definition: FlowGenericVanguard.hpp:299
bool useMultisegmentWell_
Definition: FlowGenericVanguard.hpp:302
static Parallel::Communication & comm()
Obtain global communicator.
Definition: FlowGenericVanguard.hpp:255
bool ownersFirst_
Definition: FlowGenericVanguard.hpp:292
int numJacobiBlocks() const
Number of blocks in the Block-Jacobi preconditioner.
Definition: FlowGenericVanguard.hpp:200
const Schedule & schedule() const
Return a reference to the object that managages the ECL schedule.
Definition: FlowGenericVanguard.hpp:129
std::string zoltanParams_
Definition: FlowGenericVanguard.hpp:296
std::string caseName_
Definition: FlowGenericVanguard.hpp:284
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:103
std::string ignoredKeywords_
Definition: FlowGenericVanguard.hpp:300
WellTestState transferWTestState()
Definition: FlowGenericVanguard.hpp:177
const SummaryState & summaryState() const
Definition: FlowGenericVanguard.hpp:152
bool serialPartitioning() const
Parameter that decides if partitioning for parallel runs should be performed on a single process only...
Definition: FlowGenericVanguard.hpp:220
static SimulationModelParams modelParams_
Definition: FlowGenericVanguard.hpp:75
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:139
static SimulationModelParams serializationTestParams()
ParallelWellStruct parallelWells_
Information about wells in parallel.
Definition: FlowGenericVanguard.hpp:328
void serializeOp(Serializer &serializer)
bool enableExperiments_
Definition: FlowGenericVanguard.hpp:303
static void setCommunication(std::unique_ptr< Opm::Parallel::Communication > comm)
Set global communication.
Definition: FlowGenericVanguard.hpp:251
bool enableDistributedWells() const
Whether perforations of a well might be distributed.
Definition: FlowGenericVanguard.hpp:238
double zoltanImbalanceTol() const
Parameter that sets the zoltan imbalance tolarance.
Definition: FlowGenericVanguard.hpp:226
bool serialPartitioning_
Definition: FlowGenericVanguard.hpp:294
~FlowGenericVanguard()
Destructor.
Action::State & actionState()
Returns the action state.
Definition: FlowGenericVanguard.hpp:160
std::shared_ptr< SummaryConfig > eclSummaryConfig_
Definition: FlowGenericVanguard.hpp:321
const EclipseState & eclState() const
Return a reference to the internalized ECL deck.
Definition: FlowGenericVanguard.hpp:120
FlowGenericVanguard()
Constructor.
bool drsdtconEnabled() const
const std::string & externalPartitionFile() const
Definition: FlowGenericVanguard.hpp:229
Dune::EdgeWeightMethod edgeWeightsMethod_
Definition: FlowGenericVanguard.hpp:286
std::shared_ptr< Python > python
Definition: FlowGenericVanguard.hpp:317
const UDQState & udqState() const
Definition: FlowGenericVanguard.hpp:174
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:188
bool ownersFirst() const
Parameter that decide if cells owned by rank are ordered before ghost cells.
Definition: FlowGenericVanguard.hpp:212
Dune::EdgeWeightMethod edgeWeightsMethod() const
Parameter deciding the edge-weight strategy of the load balancer.
Definition: FlowGenericVanguard.hpp:194
std::unique_ptr< WellTestState > wtestState_
Definition: FlowGenericVanguard.hpp:313
UDQState & udqState()
Returns the udq state.
Definition: FlowGenericVanguard.hpp:171
EclipseState & eclState()
Definition: FlowGenericVanguard.hpp:123
double zoltanImbalanceTol_
Definition: FlowGenericVanguard.hpp:295
static std::unique_ptr< Parallel::Communication > comm_
Definition: FlowGenericVanguard.hpp:282
bool operator==(const FlowGenericVanguard &rhs) const
static void readDeck(const std::string &filename)
Read a deck.
std::unique_ptr< SummaryState > summaryState_
Definition: FlowGenericVanguard.hpp:305
std::shared_ptr< Schedule > eclSchedule_
Definition: FlowGenericVanguard.hpp:320
const ParallelWellStruct & parallelWells() const
Returns vector with name and whether the has local perforated cells for all wells.
Definition: FlowGenericVanguard.hpp:247
Schedule & schedule()
Definition: FlowGenericVanguard.hpp:132
std::string externalPartitionFile_
Definition: FlowGenericVanguard.hpp:297
FlowGenericVanguard(SimulationModelParams &&params)
std::vector< std::pair< std::string, bool > > ParallelWellStruct
Definition: FlowGenericVanguard.hpp:62
double setupTime_
Definition: FlowGenericVanguard.hpp:279
std::optional< int > outputInterval_
Definition: FlowGenericVanguard.hpp:301
const Action::State & actionState() const
Definition: FlowGenericVanguard.hpp:163
std::unique_ptr< UDQState > udqState_
Definition: FlowGenericVanguard.hpp:306
std::string fileName_
Definition: FlowGenericVanguard.hpp:285
std::unique_ptr< Action::State > actionState_
Definition: FlowGenericVanguard.hpp:307
SummaryState & summaryState()
Returns the summary state.
Definition: FlowGenericVanguard.hpp:149
std::shared_ptr< EclipseState > eclState_
Definition: FlowGenericVanguard.hpp:319
void updateOutputDir_(std::string outputDir, bool enableEclCompatFile)
Dune::Communication< MPIComm > Communication
Definition: ParallelCommunication.hpp:30
Definition: BlackoilPhases.hpp:27
Definition: FlowGenericVanguard.hpp:64
std::unique_ptr< UDQState > udqState_
Definition: FlowGenericVanguard.hpp:66
std::shared_ptr< Schedule > eclSchedule_
Definition: FlowGenericVanguard.hpp:71
std::unique_ptr< SummaryState > summaryState_
Definition: FlowGenericVanguard.hpp:68
std::shared_ptr< EclipseState > eclState_
Definition: FlowGenericVanguard.hpp:70
std::shared_ptr< SummaryConfig > eclSummaryConfig_
Definition: FlowGenericVanguard.hpp:72
double setupTime_
Definition: FlowGenericVanguard.hpp:65
std::unique_ptr< WellTestState > wtestState_
Definition: FlowGenericVanguard.hpp:69
std::unique_ptr< Action::State > actionState_
Definition: FlowGenericVanguard.hpp:67