From e9baf8bfe9cd22d7ef01684fc33bee7f09b3231f Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Sun, 9 Jan 2022 10:45:52 -0700 Subject: [PATCH] Let the CellData::pack() function return its data. --- .../fe/fe_tools_extrapolate.templates.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/include/deal.II/fe/fe_tools_extrapolate.templates.h b/include/deal.II/fe/fe_tools_extrapolate.templates.h index d6b7fb68d7..6f168e9990 100644 --- a/include/deal.II/fe/fe_tools_extrapolate.templates.h +++ b/include/deal.II/fe/fe_tools_extrapolate.templates.h @@ -122,10 +122,10 @@ namespace FETools operator<(const CellData &rhs) const; /** - * Pack the data of this object into a char[] buffer. + * Pack the data of this object into a buffer. */ - void - pack_data(std::vector &buffer) const; + std::vector + pack_data() const; /** * Unpack the data of the given buffer into the members of this object. @@ -458,9 +458,9 @@ namespace FETools template - void - ExtrapolateImplementation::CellData::pack_data( - std::vector &buffer) const + std::vector + ExtrapolateImplementation::CellData::pack_data() + const { // Compute how much memory we need to pack the data of this // structure into a char[] buffer. @@ -470,8 +470,7 @@ namespace FETools sizeof(unsigned int) + // tree_index sizeof( typename dealii::internal::p4est::types::quadrant)); // quadrant - - buffer.resize(bytes_for_buffer); + std::vector buffer(bytes_for_buffer); char *ptr = buffer.data(); @@ -492,6 +491,8 @@ namespace FETools ptr += sizeof(typename dealii::internal::p4est::types::quadrant); Assert(ptr == buffer.data() + buffer.size(), ExcInternalError()); + + return buffer; } @@ -1189,7 +1190,7 @@ namespace FETools { destinations.push_back(it->receiver); - it->pack_data(*buffer); + *buffer = it->pack_data(); const int ierr = MPI_Isend(buffer->data(), buffer->size(), MPI_BYTE, -- 2.39.5