ReservoirCouplingMasterReportStep.hpp
Go to the documentation of this file.
1/*
2 Copyright 2025 Equinor ASA
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 3 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
20#ifndef OPM_RESERVOIR_COUPLING_MASTER_REPORT_STEP_HPP
21#define OPM_RESERVOIR_COUPLING_MASTER_REPORT_STEP_HPP
22
25#include <opm/input/eclipse/Schedule/Schedule.hpp>
27#include <opm/common/OpmLog/OpmLog.hpp>
28
29#include <mpi.h>
30
31#include <vector>
32
33namespace Opm {
34
35// Avoid including the complete definition of ReservoirCouplingMaster here to avoid circular dependency.
36template <class Scalar> class ReservoirCouplingMaster;
37
58template <class Scalar>
60public:
65
70 );
71
74 const Parallel::Communication &comm() const { return this->master_.getComm(); }
75
79 const std::vector<std::string>& getMasterGroupNamesForSlave(std::size_t slave_idx) const {
80 return this->master_.getMasterGroupNamesForSlave(slave_idx);
81 }
82
85 const std::map<std::string, std::string>& getMasterGroupToSlaveNameMap() const {
86 return this->master_.getMasterGroupToSlaveNameMap();
87 }
88
94 const std::string &slave_name, const std::string &master_group_name) const;
95
99 MPI_Comm getSlaveComm(int index) const { return this->master_.getSlaveComm(index); }
100
104 const Potentials& getSlaveGroupPotentials(const std::string &master_group_name) const;
105
111
115 std::size_t numSlaveGroups(unsigned int index) const { return this->master_.numSlaveGroups(index); }
116
119 std::size_t numSlaves() const { return this->master_.numSlavesStarted(); }
120
123 ReservoirCoupling::Logger& logger() const { return this->master_.getLogger(); }
124
134
145
148 const Schedule &schedule() const { return this->master_.schedule(); }
149
156 void sendGroupInfoToSlaves(int report_step_idx);
157
163 void setReportStepIdx(int report_step_idx);
164
168 bool slaveIsActivated(int index) const { return this->master_.slaveIsActivated(index); }
169
173 const std::string &slaveName(int index) const { return this->master_.getSlaveName(index); }
174
175private:
178 void receiveGroupInfoFromSlave_(unsigned int slave_idx);
179
183 void sendMasterGroupInjectorProducerInfoToSlave_(unsigned int slave_idx, int report_step_idx);
184
187
189 int report_step_idx_;
190
192 std::map<std::string, std::vector<SlaveGroupProductionData>> slave_group_production_data_;
193
195 std::map<std::string, std::vector<SlaveGroupInjectionData>> slave_group_injection_data_;
196};
197} // namespace Opm
198#endif // OPM_RESERVOIR_COUPLING_MASTER_REPORT_STEP_HPP
Definition: ReservoirCoupling.hpp:36
Definition: ReservoirCouplingMaster.hpp:38
Manages master-side reservoir coupling operations for a single report step.
Definition: ReservoirCouplingMasterReportStep.hpp:59
ReservoirCouplingMasterReportStep(ReservoirCouplingMaster< Scalar > &master)
Construct a report step manager for the master process.
const std::vector< std::string > & getMasterGroupNamesForSlave(std::size_t slave_idx) const
Get the names of master groups associated with a specific slave.
Definition: ReservoirCouplingMasterReportStep.hpp:79
MPI_Comm getSlaveComm(int index) const
Get the MPI communicator for a specific slave process.
Definition: ReservoirCouplingMasterReportStep.hpp:99
void receiveProductionDataFromSlaves()
Receive production data from all active slave processes.
const Parallel::Communication & comm() const
Get the MPI communicator for master-slave communication.
Definition: ReservoirCouplingMasterReportStep.hpp:74
std::size_t getMasterGroupCanonicalIdx(const std::string &slave_name, const std::string &master_group_name) const
Get the canonical index for a master group.
const std::map< std::string, std::string > & getMasterGroupToSlaveNameMap() const
Get the mapping from master group names to slave names.
Definition: ReservoirCouplingMasterReportStep.hpp:85
void maybeReceiveGroupInfoFromSlaves()
Receive group information from slaves if needed.
void setReportStepIdx(int report_step_idx)
Set the current report step index.
ReservoirCoupling::Logger & logger() const
Get the logger for reservoir coupling operations.
Definition: ReservoirCouplingMasterReportStep.hpp:123
const Schedule & schedule() const
Get the simulation schedule.
Definition: ReservoirCouplingMasterReportStep.hpp:148
bool slaveIsActivated(int index) const
Check if a specific slave process has been activated.
Definition: ReservoirCouplingMasterReportStep.hpp:168
const Potentials & getSlaveGroupPotentials(const std::string &master_group_name) const
Get the production potentials for a slave group.
void sendGroupInfoToSlaves(int report_step_idx)
Send group control information to all slaves for a specific report step.
void receiveInjectionDataFromSlaves()
Receive injection data from all active slave processes.
std::size_t numSlaves() const
Get the total number of active slave processes.
Definition: ReservoirCouplingMasterReportStep.hpp:119
std::size_t numSlaveGroups(unsigned int index) const
Get the number of slave groups for a specific slave process.
Definition: ReservoirCouplingMasterReportStep.hpp:115
const std::string & slaveName(int index) const
Get the name of a specific slave process.
Definition: ReservoirCouplingMasterReportStep.hpp:173
Dune::Communication< MPIComm > Communication
Definition: ParallelCommunication.hpp:30
MessageTag
Definition: ReservoirCoupling.hpp:121
Definition: blackoilbioeffectsmodules.hh:43
Definition: ReservoirCoupling.hpp:160
Definition: ReservoirCoupling.hpp:198
Definition: ReservoirCoupling.hpp:184