Merge pull request #4081 from akva2/eclwriter_serializer

changed: use EclMpiSerializer in eclwriter
This commit is contained in:
Bård Skaflestad 2022-09-07 09:44:52 +02:00 committed by GitHub
commit c24796e7f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 15 deletions

View File

@ -48,6 +48,10 @@
#include <dune/grid/common/mcmgmapper.hh>
#if HAVE_MPI
#include <ebos/eclmpiserializer.hh>
#endif
#if HAVE_DUNE_FEM
#include <dune/fem/gridpart/adaptiveleafgridpart.hh>
#include <dune/fem/gridpart/common/gridpart2gridview.hh>
@ -506,7 +510,6 @@ evalSummary(const int reportStepNum,
SummaryState& summaryState,
UDQState& udqState)
{
std::vector<char> buffer;
if (collectToIORank_.isIORank()) {
const auto& summary = eclIO_->summary();
auto wbp_calculators = summary.wbp_calculators(reportStepNum);
@ -547,23 +550,13 @@ evalSummary(const int reportStepNum,
auto udq_step = reportStepNum - 1;
const auto& udq_config = schedule_.getUDQConfig(udq_step);
udq_config.eval( udq_step, schedule_.wellMatcher(udq_step), summaryState, udqState);
buffer = summaryState.serialize();
}
#if HAVE_MPI
if (collectToIORank_.isParallel()) {
#ifdef HAVE_MPI
unsigned long buffer_size = buffer.size();
grid_.comm().broadcast(&buffer_size, 1, collectToIORank_.ioRank);
if (!collectToIORank_.isIORank())
buffer.resize( buffer_size );
grid_.comm().broadcast(buffer.data(), buffer_size, collectToIORank_.ioRank);
if (!collectToIORank_.isIORank()) {
SummaryState& st = summaryState;
st.deserialize(buffer);
}
#endif
EclMpiSerializer ser(grid_.comm());
ser.append(summaryState);
}
#endif
}
template<class Grid, class EquilGrid, class GridView, class ElementMapper, class Scalar>

View File

@ -386,6 +386,25 @@ public:
}
}
//! \brief Serialize and broadcast on root process, de-serialize and append on
//! others.
//!
//! \tparam T Type of class to broadcast
//! \param data Class to broadcast
template<class T>
void append(T& data)
{
if (m_comm.size() == 1)
return;
T tmp;
T& bcast = m_comm.rank() == 0 ? data : tmp;
broadcast(bcast);
if (m_comm.rank() != 0)
data.append(tmp);
}
//! \brief Returns current position in buffer.
size_t position() const
{