Replacing use of MPI_COMM_WORLD with a variable communicator.

This commit is contained in:
Elyes Ahmed
2021-05-25 12:57:11 +02:00
committed by Atgeirr Flø Rasmussen
parent 61ef539bf5
commit f53c597f90
48 changed files with 584 additions and 420 deletions

View File

@@ -27,7 +27,14 @@ namespace Opm {
ParallelFieldPropsManager::ParallelFieldPropsManager(FieldPropsManager& manager)
: m_manager(manager)
, m_comm(Dune::MPIHelper::getCollectiveCommunication())
, m_comm(Parallel::Communication())
{
}
// EXPERIMENTAL FUNCTION TO ADD COMM AS INPUT
ParallelFieldPropsManager::ParallelFieldPropsManager(FieldPropsManager& manager, Parallel::Communication comm)
: m_manager(manager)
, m_comm(comm)
{
}
@@ -208,8 +215,9 @@ bool ParallelFieldPropsManager::has_double(const std::string& keyword) const
}
ParallelEclipseState::ParallelEclipseState()
: m_fieldProps(field_props)
ParallelEclipseState::ParallelEclipseState(Parallel::Communication comm)
: m_fieldProps(field_props, comm)
, m_comm(comm)
{
}
@@ -220,13 +228,19 @@ ParallelEclipseState::ParallelEclipseState(const Deck& deck)
{
}
ParallelEclipseState::ParallelEclipseState(const Deck& deck, Parallel::Communication comm)
: EclipseState(deck)
, m_fieldProps(field_props, comm)
, m_comm(comm)
{
}
const FieldPropsManager& ParallelEclipseState::fieldProps() const
{
if (!m_parProps && Dune::MPIHelper::getCollectiveCommunication().rank() != 0)
if (!m_parProps && m_comm.rank() != 0)
OPM_THROW(std::runtime_error, "Attempt to access field properties on no-root process before switch to parallel properties");
if (!m_parProps || Dune::MPIHelper::getCollectiveCommunication().size() == 1)
if (!m_parProps || m_comm.size() == 1)
return this->EclipseState::fieldProps();
return m_fieldProps;
@@ -235,7 +249,7 @@ const FieldPropsManager& ParallelEclipseState::fieldProps() const
const FieldPropsManager& ParallelEclipseState::globalFieldProps() const
{
if (Dune::MPIHelper::getCollectiveCommunication().rank() != 0)
if (m_comm.rank() != 0)
OPM_THROW(std::runtime_error, "Attempt to access global field properties on non-root process");
return this->EclipseState::globalFieldProps();
}
@@ -243,7 +257,7 @@ const FieldPropsManager& ParallelEclipseState::globalFieldProps() const
const EclipseGrid& ParallelEclipseState::getInputGrid() const
{
if (Dune::MPIHelper::getCollectiveCommunication().rank() != 0)
if (m_comm.rank() != 0)
OPM_THROW(std::runtime_error, "Attempt to access eclipse grid on non-root process");
return this->EclipseState::getInputGrid();
}
@@ -257,8 +271,7 @@ void ParallelEclipseState::switchToGlobalProps()
void ParallelEclipseState::switchToDistributedProps()
{
const auto& comm = Dune::MPIHelper::getCollectiveCommunication();
if (comm.size() == 1) // No need for the parallel frontend
if (m_comm.size() == 1) // No need for the parallel frontend
return;
m_parProps = true;