avoid deck usage on non-root processes setting up MaterialLawManager

This commit is contained in:
Arne Morten Kvarving 2020-01-22 11:22:06 +01:00
parent 1354656f8b
commit 60f3fea67a
3 changed files with 37 additions and 1 deletions

View File

@ -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

@ -2346,6 +2346,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_();
@ -2370,7 +2371,12 @@ private:
compressedToCartesianElemIdx[elemIdx] = vanguard.cartesianIndex(elemIdx);
materialLawManager_ = std::make_shared<EclMaterialLawManager>();
if (comm.rank() == 0)
materialLawManager_->initFromDeck(deck, eclState);
EclMpiSerializer ser(comm);
ser.broadcast(*materialLawManager_);
materialLawManager_->initParamsForElements(eclState, compressedToCartesianElemIdx);
////////////////////////////////
}

View File

@ -24,6 +24,8 @@
#include "ParallelRestart.hpp"
#include <opm/common/OpmLog/Location.hpp>
#include <opm/material/fluidmatrixinteractions/EclEpsScalingPoints.hpp>
#include <opm/material/fluidmatrixinteractions/EclTwoPhaseMaterialParams.hpp>
#include <opm/material/fluidmatrixinteractions/EclMultiplexerMaterialParams.hpp>
#include <opm/parser/eclipse/EclipseState/Runspec.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/NNC.hpp>
#include <opm/parser/eclipse/EclipseState/InitConfig/Equil.hpp>
@ -6778,6 +6780,7 @@ INSTANTIATE_PACK_VECTOR(double)
INSTANTIATE_PACK_VECTOR(std::vector<double>)
INSTANTIATE_PACK_VECTOR(bool)
INSTANTIATE_PACK_VECTOR(char)
INSTANTIATE_PACK_VECTOR(int)
INSTANTIATE_PACK_VECTOR(Opm::Tabulated1DFunction<double>)
INSTANTIATE_PACK_VECTOR(std::array<double, 3>)
INSTANTIATE_PACK_VECTOR(EclEpsScalingPointsInfo<double>)
@ -6817,6 +6820,8 @@ INSTANTIATE_PACK(std::array<short,3>)
INSTANTIATE_PACK(std::array<bool,3>)
INSTANTIATE_PACK(unsigned char)
INSTANTIATE_PACK(EclEpsScalingPointsInfo<double>)
INSTANTIATE_PACK(EclTwoPhaseApproach)
INSTANTIATE_PACK(EclMultiplexerApproach)
#undef INSTANTIATE_PACK
} // end namespace Mpi