avoid deck usage on non-root processes setting up FluidSystem

This commit is contained in:
Arne Morten Kvarving 2020-01-20 10:35:59 +01:00
parent c18f06e155
commit c3ecedadb1
2 changed files with 32 additions and 1 deletions

View File

@ -2475,8 +2475,32 @@ private:
const auto& simulator = this->simulator();
const auto& deck = simulator.vanguard().deck();
const auto& eclState = simulator.vanguard().eclState();
const auto& comm = simulator.gridView().comm();
FluidSystem::initFromDeck(deck, eclState);
if (comm.rank() == 0)
FluidSystem::initFromDeck(deck, eclState);
#if HAVE_MPI
if (comm.size() > 1) {
if (comm.rank() == 0) {
EclMpiSerializer ser(comm);
size_t size = FluidSystem::packSize(ser);
std::vector<char> buffer(size);
int position = 0;
FluidSystem::pack(buffer, position, ser);
comm.broadcast(&position, 1, 0);
comm.broadcast(buffer.data(), position, 0);
} else {
int size;
comm.broadcast(&size, 1, 0);
std::vector<char> buffer(size);
comm.broadcast(buffer.data(), size, 0);
int position = 0;
EclMpiSerializer ser(comm);
FluidSystem::unpack(buffer, position, ser);
}
}
#endif
}
void readInitialCondition_()

View File

@ -6475,6 +6475,7 @@ INSTANTIATE_PACK_VECTOR(std::vector<double>)
INSTANTIATE_PACK_VECTOR(bool)
INSTANTIATE_PACK_VECTOR(char)
INSTANTIATE_PACK_VECTOR(Opm::Tabulated1DFunction<double>)
INSTANTIATE_PACK_VECTOR(std::array<double, 3>)
#undef INSTANTIATE_PACK_VECTOR
#define INSTANTIATE_PACK_SHARED_PTR(...) \
@ -6487,6 +6488,9 @@ template void unpack(std::shared_ptr<__VA_ARGS__>& data, \
std::vector<char>& buffer, int& position, \
Dune::MPIHelper::MPICommunicator comm);
INSTANTIATE_PACK_SHARED_PTR(Opm::GasPvtMultiplexer<double, true>)
INSTANTIATE_PACK_SHARED_PTR(Opm::OilPvtMultiplexer<double, true>)
INSTANTIATE_PACK_SHARED_PTR(Opm::WaterPvtMultiplexer<double, true>)
INSTANTIATE_PACK_SHARED_PTR(SpiralICD)
#undef INSTANTIATE_PACK_SHARED_PTR
@ -6504,6 +6508,9 @@ INSTANTIATE_PACK(double)
INSTANTIATE_PACK(std::size_t)
INSTANTIATE_PACK(bool)
INSTANTIATE_PACK(int)
INSTANTIATE_PACK(std::array<short,3>)
INSTANTIATE_PACK(std::array<bool,3>)
INSTANTIATE_PACK(unsigned char)
#undef INSTANTIATE_PACK
} // end namespace Mpi