opm-simulators
Loading...
Searching...
No Matches
ReservoirCouplingSlave.hpp
1/*
2 Copyright 2024 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_SLAVE_HPP
21#define OPM_RESERVOIR_COUPLING_SLAVE_HPP
22
23#include <opm/simulators/flow/ReservoirCoupling.hpp>
24#include <opm/input/eclipse/Schedule/Schedule.hpp>
25#include <opm/simulators/utils/ParallelCommunication.hpp>
26#include <opm/simulators/timestepping/SimulatorTimer.hpp>
27#include <opm/common/OpmLog/OpmLog.hpp>
28
29#include <mpi.h>
30
31#include <vector>
32
33namespace Opm {
34
35class ReservoirCouplingSlave {
36public:
37 using MessageTag = ReservoirCoupling::MessageTag;
38 using Potentials = ReservoirCoupling::Potentials;
39
40 ReservoirCouplingSlave(
41 const Parallel::Communication &comm, const Schedule &schedule, const SimulatorTimer &timer
42 );
43 bool activated() const { return activated_; }
44 void clearDeferredLogger() { logger_.clearDeferredLogger(); }
45 const Parallel::Communication& getComm() const { return comm_; }
46 const std::map<std::string, std::string>& getSlaveToMasterGroupNameMap() const {
47 return slave_to_master_group_map_; }
48 void maybeActivate(int report_step);
49 double receiveNextTimeStepFromMaster();
50 void sendAndReceiveInitialData();
51 void sendNextReportDateToMasterProcess() const;
52 void sendPotentialsToMaster(const std::vector<Potentials> &potentials) const;
53 void setDeferredLogger(DeferredLogger *deferred_logger) {
54 this->logger_.setDeferredLogger(deferred_logger);
55 }
56
57private:
58 void checkGrupSlavGroupNames_();
59 double getGrupSlavActivationDate_() const;
60 void receiveMasterGroupNamesFromMasterProcess_();
61 void receiveSlaveNameFromMasterProcess_();
62 void saveMasterGroupNamesAsMap_(const std::vector<char>& group_names);
63 void sendActivationDateToMasterProcess_() const;
64 void sendActivationHandshakeToMasterProcess_() const;
65 void sendSimulationStartDateToMasterProcess_() const;
66
67 const Parallel::Communication &comm_;
68 const Schedule& schedule_;
69 const SimulatorTimer &timer_;
70 // MPI parent communicator for a slave process
71 MPI_Comm slave_master_comm_{MPI_COMM_NULL};
72 std::map<std::string, std::string> slave_to_master_group_map_;
73 bool activated_{false};
74 std::string slave_name_; // This is the slave name as defined in the master process
76};
77
78} // namespace Opm
79#endif // OPM_RESERVOIR_COUPLING_SLAVE_HPP
Definition DeferredLogger.hpp:57
Definition ReservoirCoupling.hpp:35
Definition SimulatorTimer.hpp:39
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilbioeffectsmodules.hh:43
Definition ReservoirCoupling.hpp:63