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/grid/common/GridEnums.hpp>
33
34#include <opm/input/eclipse/Schedule/Well/WellTestState.hpp>
35
36#include <opm/simulators/utils/ParallelCommunication.hpp>
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
75 static SimulationModelParams modelParams_;
76
83
89
90 static SimulationModelParams serializationTestParams();
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
115 void defineSimulationModel(SimulationModelParams&& params);
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
220 bool serialPartitioning() const
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
247 const ParallelWellStruct& parallelWells() const
248 { return parallelWells_; }
249
251 static void setCommunication(std::unique_ptr<Opm::Parallel::Communication> comm)
252 { comm_ = std::move(comm); }
253
255 static Parallel::Communication& comm()
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
279 double setupTime_;
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
292 bool ownersFirst_;
293#if HAVE_MPI
294 bool serialPartitioning_;
295 double zoltanImbalanceTol_;
296 std::string zoltanParams_;
297 std::string externalPartitionFile_{};
298#endif
299 bool enableDistributedWells_;
300 std::string ignoredKeywords_;
301 std::optional<int> outputInterval_;
302 bool useMultisegmentWell_;
303 bool enableExperiments_;
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
328 ParallelWellStruct parallelWells_;
329};
330
331} // namespace Opm
332
333#endif // OPM_FLOW_GENERIC_VANGUARD_HPP
Definition FlowGenericVanguard.hpp:60
static Parallel::Communication & comm()
Obtain global communicator.
Definition FlowGenericVanguard.hpp:255
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
double setupTime()
Returns the wall time required to set up the simulator before it was born.
Definition FlowGenericVanguard.hpp:103
static void readDeck(const std::string &filename)
Read a deck.
Definition FlowGenericVanguard.cpp:126
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
ParallelWellStruct parallelWells_
Information about wells in parallel.
Definition FlowGenericVanguard.hpp:328
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
static std::string canonicalDeckPath(const std::string &caseName)
Returns the canonical path to a deck file.
Definition FlowGenericVanguard.cpp:143
~FlowGenericVanguard()
Destructor.
Action::State & actionState()
Returns the action state.
Definition FlowGenericVanguard.hpp:160
const EclipseState & eclState() const
Return a reference to the internalized ECL deck.
Definition FlowGenericVanguard.hpp:120
FlowGenericVanguard()
Constructor.
Definition FlowGenericVanguard.cpp:90
void defineSimulationModel(SimulationModelParams &&params)
Set the simulation configuration objects.
Definition FlowGenericVanguard.cpp:114
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
UDQState & udqState()
Returns the udq state.
Definition FlowGenericVanguard.hpp:171
const ParallelWellStruct & parallelWells() const
Returns vector with name and whether the has local perforated cells for all wells.
Definition FlowGenericVanguard.hpp:247
SummaryState & summaryState()
Returns the summary state.
Definition FlowGenericVanguard.hpp:149
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition BlackoilPhases.hpp:27
Definition FlowGenericVanguard.hpp:64