My Project
Loading...
Searching...
No Matches
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
38#include <opm/simulators/utils/ParallelCommunication.hpp>
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;
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
104 double setupTime_;
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
114 static SimulationModelParams modelParams_;
115
122
128
129 static SimulationModelParams serializationTestParams();
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
154 void defineSimulationModel(SimulationModelParams&& params);
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
172 { return *eclSchedule_; }
173
179 { return *eclSummaryConfig_; }
180
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
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_; }
264 bool serialPartitioning() const
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
298 const ParallelWellStruct& parallelWells() const
299 { return parallelWells_; }
300
302 static void setCommunication(std::unique_ptr<Opm::Parallel::Communication> comm)
303 { comm_ = std::move(comm); }
304
306 static Parallel::Communication& comm()
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,
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
335 double setupTime_;
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
348 bool ownersFirst_;
349#if HAVE_MPI
350 Dune::PartitionMethod partitionMethod_;
352 double imbalanceTol_;
353
355 double zoltanImbalanceTol_;
356 std::string zoltanParams_;
357
358 std::string metisParams_;
359
360 std::string externalPartitionFile_{};
361#endif
362 bool enableDistributedWells_;
363 std::string ignoredKeywords_;
364 std::optional<int> outputInterval_;
365 bool useMultisegmentWell_;
366 bool enableExperiments_;
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
391 ParallelWellStruct parallelWells_;
392};
393
394} // namespace Opm
395
396#endif // OPM_FLOW_GENERIC_VANGUARD_HPP
Definition FlowGenericVanguard.hpp:99
static Parallel::Communication & comm()
Obtain global communicator.
Definition FlowGenericVanguard.hpp:306
int numJacobiBlocks() const
Number of blocks in the Block-Jacobi preconditioner.
Definition FlowGenericVanguard.hpp:239
const Schedule & schedule() const
Return a reference to the object that managages the ECL schedule.
Definition FlowGenericVanguard.hpp:168
double setupTime()
Returns the wall time required to set up the simulator before it was born.
Definition FlowGenericVanguard.hpp:142
static void readDeck(const std::string &filename)
Read a deck.
Definition FlowGenericVanguard.cpp:139
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
ParallelWellStruct parallelWells_
Information about wells in parallel.
Definition FlowGenericVanguard.hpp:391
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
static std::string canonicalDeckPath(const std::string &caseName)
Returns the canonical path to a deck file.
Definition FlowGenericVanguard.cpp:156
~FlowGenericVanguard()
Destructor.
Action::State & actionState()
Returns the action state.
Definition FlowGenericVanguard.hpp:199
const EclipseState & eclState() const
Return a reference to the internalized ECL deck.
Definition FlowGenericVanguard.hpp:159
FlowGenericVanguard()
Constructor.
Definition FlowGenericVanguard.cpp:101
void defineSimulationModel(SimulationModelParams &&params)
Set the simulation configuration objects.
Definition FlowGenericVanguard.cpp:127
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
UDQState & udqState()
Returns the udq state.
Definition FlowGenericVanguard.hpp:210
const ParallelWellStruct & parallelWells() const
Returns vector with name and whether the has local perforated cells for all wells.
Definition FlowGenericVanguard.hpp:298
SummaryState & summaryState()
Returns the summary state.
Definition FlowGenericVanguard.hpp:188
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilboundaryratevector.hh:37
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:242
Definition FlowGenericVanguard.hpp:103
Definition FlowGenericVanguard.hpp:70
Definition FlowGenericVanguard.hpp:50
Definition FlowGenericVanguard.hpp:51
Definition FlowGenericVanguard.hpp:52
Definition FlowGenericVanguard.hpp:53
Definition FlowGenericVanguard.hpp:54
Definition FlowGenericVanguard.hpp:55
Definition FlowGenericVanguard.hpp:60
Definition FlowGenericVanguard.hpp:58
Definition FlowGenericVanguard.hpp:61
Definition FlowGenericVanguard.hpp:62
Definition FlowGenericVanguard.hpp:68
Definition FlowGenericVanguard.hpp:69
Definition FlowGenericVanguard.hpp:73
Definition FlowGenericVanguard.hpp:75
Definition FlowGenericVanguard.hpp:76
Definition FlowGenericVanguard.hpp:79
Definition FlowGenericVanguard.hpp:81