diff --git a/ebos/eclproblem.hh b/ebos/eclproblem.hh index 554123bbe..3aed9b975 100644 --- a/ebos/eclproblem.hh +++ b/ebos/eclproblem.hh @@ -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 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 buffer(size); + comm.broadcast(buffer.data(), size, 0); + int position = 0; + EclMpiSerializer ser(comm); + FluidSystem::unpack(buffer, position, ser); + } + } +#endif } void readInitialCondition_() diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index 4aec9ca06..274ae764c 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -1323,9 +1323,6 @@ std::size_t packSize(const std::shared_ptr& data, return size; } -template std::size_t packSize(const std::shared_ptr& data, - Dune::MPIHelper::MPICommunicator comm); - template std::size_t packSize(const std::unique_ptr& data, Dune::MPIHelper::MPICommunicator comm) @@ -3143,9 +3140,6 @@ void pack(const std::unique_ptr& data, std::vector& buffer, int& positi pack(*data, buffer, position, comm); } -template void pack(const std::shared_ptr& data, std::vector& buffer, - int& position, Dune::MPIHelper::MPICommunicator comm); - void pack(const Dimension& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm) @@ -4670,11 +4664,11 @@ void unpack(GasPvtMultiplexer& data, DryGasPvt* realPvt = new DryGasPvt; unpack(*realPvt, buffer, position, comm); pvt = realPvt; - } else if (data.gasPvtApproach() == PvtApproach::WetGasPvt) { + } else if (approach == PvtApproach::WetGasPvt) { WetGasPvt* realPvt = new WetGasPvt; unpack(*realPvt, buffer, position, comm); pvt = realPvt; - } else if (data.gasPvtApproach() == PvtApproach::ThermalGasPvt) { + } else if (approach == PvtApproach::ThermalGasPvt) { GasPvtThermal* realPvt = new GasPvtThermal; unpack(*realPvt, buffer, position, comm); pvt = realPvt; @@ -4958,7 +4952,7 @@ void unpack(WaterPvtMultiplexer& data, auto* realPvt = new ConstantCompressibilityWaterPvt; unpack(*realPvt, buffer, position, comm); pvt = realPvt; - } else if (data.approach() == PvtApproach::ThermalWaterPvt) { + } else if (approach == PvtApproach::ThermalWaterPvt) { auto* realPvt = new WaterPvtThermal; unpack(*realPvt, buffer, position, comm); pvt = realPvt; @@ -5474,10 +5468,6 @@ void unpack(std::unique_ptr& data, std::vector& buffer, int& position, } } -template void unpack(std::shared_ptr& data, - std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm); - void unpack(Dimension& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm) @@ -6470,37 +6460,57 @@ void unpack(GuideRateConfig::GroupTarget& data, unpack(data.target, buffer, position, comm); } -#define INSTANTIATE_PACK_VECTOR(T) \ -template std::size_t packSize(const std::vector& data, \ +#define INSTANTIATE_PACK_VECTOR(...) \ +template std::size_t packSize(const std::vector<__VA_ARGS__>& data, \ Dune::MPIHelper::MPICommunicator comm); \ -template void pack(const std::vector& data, \ +template void pack(const std::vector<__VA_ARGS__>& data, \ std::vector& buffer, int& position, \ Dune::MPIHelper::MPICommunicator comm); \ -template void unpack(std::vector& data, \ +template void unpack(std::vector<__VA_ARGS__>& data, \ std::vector& buffer, int& position, \ Dune::MPIHelper::MPICommunicator comm); -INSTANTIATE_PACK_VECTOR(double); -INSTANTIATE_PACK_VECTOR(std::vector); -INSTANTIATE_PACK_VECTOR(bool); -INSTANTIATE_PACK_VECTOR(char); -INSTANTIATE_PACK_VECTOR(Opm::Tabulated1DFunction); +INSTANTIATE_PACK_VECTOR(double) +INSTANTIATE_PACK_VECTOR(std::vector) +INSTANTIATE_PACK_VECTOR(bool) +INSTANTIATE_PACK_VECTOR(char) +INSTANTIATE_PACK_VECTOR(Opm::Tabulated1DFunction) +INSTANTIATE_PACK_VECTOR(std::array) #undef INSTANTIATE_PACK_VECTOR -#define INSTANTIATE_PACK(T) \ -template std::size_t packSize(const T& data, \ +#define INSTANTIATE_PACK_SHARED_PTR(...) \ +template std::size_t packSize(const std::shared_ptr<__VA_ARGS__>& data, \ Dune::MPIHelper::MPICommunicator comm); \ -template void pack(const T& data, \ +template void pack(const std::shared_ptr<__VA_ARGS__>& data, \ std::vector& buffer, int& position, \ Dune::MPIHelper::MPICommunicator comm); \ -template void unpack(T& data, \ +template void unpack(std::shared_ptr<__VA_ARGS__>& data, \ std::vector& buffer, int& position, \ Dune::MPIHelper::MPICommunicator comm); -INSTANTIATE_PACK(double); -INSTANTIATE_PACK(std::size_t); -INSTANTIATE_PACK(bool); -INSTANTIATE_PACK(int); +INSTANTIATE_PACK_SHARED_PTR(Opm::GasPvtMultiplexer) +INSTANTIATE_PACK_SHARED_PTR(Opm::OilPvtMultiplexer) +INSTANTIATE_PACK_SHARED_PTR(Opm::WaterPvtMultiplexer) +INSTANTIATE_PACK_SHARED_PTR(SpiralICD) +#undef INSTANTIATE_PACK_SHARED_PTR + +#define INSTANTIATE_PACK(...) \ +template std::size_t packSize(const __VA_ARGS__& data, \ + Dune::MPIHelper::MPICommunicator comm); \ +template void pack(const __VA_ARGS__& data, \ + std::vector& buffer, int& position, \ + Dune::MPIHelper::MPICommunicator comm); \ +template void unpack(__VA_ARGS__& data, \ + std::vector& buffer, int& position, \ + Dune::MPIHelper::MPICommunicator comm); + +INSTANTIATE_PACK(double) +INSTANTIATE_PACK(std::size_t) +INSTANTIATE_PACK(bool) +INSTANTIATE_PACK(int) +INSTANTIATE_PACK(std::array) +INSTANTIATE_PACK(std::array) +INSTANTIATE_PACK(unsigned char) #undef INSTANTIATE_PACK } // end namespace Mpi