mirror of
https://github.com/OPM/opm-simulators.git
synced 2024-11-29 20:43:49 -06:00
Merge pull request #4081 from akva2/eclwriter_serializer
changed: use EclMpiSerializer in eclwriter
This commit is contained in:
commit
c24796e7f5
@ -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>
|
||||
|
@ -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
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user