Merge pull request #2295 from akva2/noecl_flush_matman

Avoid deck usage on non-root processes setting up MaterialLawManager
This commit is contained in:
Joakim Hove
2020-01-22 15:09:57 +01:00
committed by GitHub
5 changed files with 150 additions and 2 deletions

View File

@@ -27,7 +27,7 @@ namespace Opm {
class EclMpiSerializer {
public:
EclMpiSerializer(Dune::CollectiveCommunication<Dune::MPIHelper::MPICommunicator> comm) :
explicit EclMpiSerializer(Dune::CollectiveCommunication<Dune::MPIHelper::MPICommunicator> comm) :
m_comm(comm)
{}
@@ -71,6 +71,31 @@ public:
#endif
}
template<class T>
void broadcast(T& data)
{
if (m_comm.size() == 1)
return;
#if HAVE_MPI
if (m_comm.rank() == 0) {
size_t size = data.packSize(*this);
std::vector<char> buffer(size);
int position = 0;
data.pack(buffer, position, *this);
m_comm.broadcast(&position, 1, 0);
m_comm.broadcast(buffer.data(), position, 0);
} else {
int size;
m_comm.broadcast(&size, 1, 0);
std::vector<char> buffer(size);
m_comm.broadcast(buffer.data(), size, 0);
int position = 0;
data.unpack(buffer, position, *this);
}
#endif
}
protected:
Dune::CollectiveCommunication<Dune::MPIHelper::MPICommunicator> m_comm;
};

View File

@@ -2345,6 +2345,7 @@ private:
const auto& vanguard = simulator.vanguard();
const auto& deck = vanguard.deck();
const auto& eclState = vanguard.eclState();
const auto& comm = vanguard.gridView().comm();
// the PVT and saturation region numbers
updatePvtnum_();
@@ -2369,7 +2370,12 @@ private:
compressedToCartesianElemIdx[elemIdx] = vanguard.cartesianIndex(elemIdx);
materialLawManager_ = std::make_shared<EclMaterialLawManager>();
materialLawManager_->initFromDeck(deck, eclState);
if (comm.rank() == 0)
materialLawManager_->initFromDeck(deck, eclState);
EclMpiSerializer ser(comm);
ser.broadcast(*materialLawManager_);
materialLawManager_->initParamsForElements(eclState, compressedToCartesianElemIdx);
////////////////////////////////
}