ReservoirCouplingTimeStepper.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_TIME_STEPPER_HPP
21#define OPM_RESERVOIR_COUPLING_TIME_STEPPER_HPP
22
24#include <opm/input/eclipse/Schedule/Schedule.hpp>
26#include <opm/common/OpmLog/OpmLog.hpp>
27
28#include <mpi.h>
29
30#include <vector>
31
32namespace Opm {
33
34// Avoid including the complete definition of ReservoirCouplingMaster here to avoid circular dependency.
35template <class Scalar> class ReservoirCouplingMaster;
36
56template <class Scalar>
58public:
62
67 );
68
71 const Parallel::Communication &comm() const { return this->master_.getComm(); }
72
76 MPI_Comm getSlaveComm(int index) const { return this->master_.getSlaveComm(index); }
77
80 std::size_t numSlaves() const { return this->master_.numSlavesStarted(); }
81
84 ReservoirCoupling::Logger& logger() const { return this->master_.getLogger(); }
85
98 double maybeChopSubStep(double suggested_timestep_original, double elapsed_time) const;
99
109
112 void resizeNextReportDates(int size) { this->slave_next_report_time_offsets_.resize(size); }
113
116 const Schedule& schedule() const { return this->master_.schedule(); }
117
121 bool slaveIsActivated(int index) const { return this->master_.slaveIsActivated(index); }
122
126 const std::string &slaveName(int index) const { return this->master_.getSlaveName(index); }
127
131 double slaveStartDate(int index) const { return this->master_.getSlaveStartDate(index); }
132
136 double slaveActivationDate(int index) const { return this->master_.getSlaveActivationDate(index); }
137
147 void sendNextTimeStepToSlaves(double timestep);
148
152 void setSlaveNextReportTimeOffset(int index, double offset) {
153 this->slave_next_report_time_offsets_[index] = offset;
154 }
155
156private:
159
161 std::vector<double> slave_next_report_time_offsets_;
162
165 std::map<std::string, std::vector<Potentials>> slave_group_potentials_;
166};
167} // namespace Opm
168#endif // OPM_RESERVOIR_COUPLING_TIME_STEPPER_HPP
Definition: ReservoirCoupling.hpp:36
Definition: ReservoirCouplingMaster.hpp:38
Manages time stepping coordination between master and slave processes.
Definition: ReservoirCouplingTimeStepper.hpp:57
MPI_Comm getSlaveComm(int index) const
Get the MPI communicator for a specific slave process.
Definition: ReservoirCouplingTimeStepper.hpp:76
const std::string & slaveName(int index) const
Get the name of a specific slave process.
Definition: ReservoirCouplingTimeStepper.hpp:126
void sendNextTimeStepToSlaves(double timestep)
Send the next time step size to all active slave processes.
std::size_t numSlaves() const
Get the total number of active slave processes.
Definition: ReservoirCouplingTimeStepper.hpp:80
void resizeNextReportDates(int size)
Resize the internal storage for slave next report times.
Definition: ReservoirCouplingTimeStepper.hpp:112
const Parallel::Communication & comm() const
Get the MPI communicator for master-to-master communication.
Definition: ReservoirCouplingTimeStepper.hpp:71
double slaveStartDate(int index) const
Get the simulation start date for a specific slave.
Definition: ReservoirCouplingTimeStepper.hpp:131
ReservoirCoupling::Logger & logger() const
Get the logger for reservoir coupling operations.
Definition: ReservoirCouplingTimeStepper.hpp:84
double slaveActivationDate(int index) const
Get the activation date for a specific slave.
Definition: ReservoirCouplingTimeStepper.hpp:136
void setSlaveNextReportTimeOffset(int index, double offset)
Set the next report time offset for a specific slave.
Definition: ReservoirCouplingTimeStepper.hpp:152
bool slaveIsActivated(int index) const
Check if a specific slave process has been activated.
Definition: ReservoirCouplingTimeStepper.hpp:121
ReservoirCouplingTimeStepper(ReservoirCouplingMaster< Scalar > &master)
Construct a time stepper for coordinating master-slave time stepping.
void receiveNextReportDateFromSlaves()
Receive next report dates from all active slave processes.
const Schedule & schedule() const
Get the simulation schedule.
Definition: ReservoirCouplingTimeStepper.hpp:116
double maybeChopSubStep(double suggested_timestep_original, double elapsed_time) const
Potentially adjust time step to align with slave report boundaries.
Dune::Communication< MPIComm > Communication
Definition: ParallelCommunication.hpp:30
MessageTag
Definition: ReservoirCoupling.hpp:121
Definition: blackoilbioeffectsmodules.hh:43
Definition: ReservoirCoupling.hpp:160
Utility class for comparing double values representing epoch dates or elapsed time.
Definition: ReservoirCoupling.hpp:226