153 ErrorCode result = MB_SUCCESS;
157 auto add_verts = [&](
Range &sent_ents) {
162 std::pair<Range::const_iterator, Range::const_iterator> set_range =
163 sent_ents.equal_range(MBENTITYSET);
164 ErrorCode result = MB_SUCCESS, tmp_result;
165 for (Range::const_iterator rit = set_range.first; rit != set_range.second;
167 tmp_result = moab_tmp.get_entities_by_type(*rit, MBVERTEX, sent_ents);
173 std::copy(sent_ents.begin(), set_range.first, range_inserter(tmp_ents));
174 result = moab_tmp.get_adjacencies(tmp_ents, 0,
false, sent_ents,
175 moab::Interface::UNION);
176 CHK_MOAB_THROW(result,
"Failed to get vertices adj to ghosted ents");
181 ParallelComm *pcomm = ParallelComm::get_pcomm(&moab_tmp,
MYPCOMM_INDEX);
182 auto &procConfig = pcomm->proc_config();
183 const int MAX_BCAST_SIZE = (1 << 28);
185 ParallelComm::Buffer buff(ParallelComm::INITIAL_BUFF_SIZE);
186 buff.reset_ptr(
sizeof(
int));
187 if ((
int)procConfig.proc_rank() == from_proc) {
189 result = add_verts(entities);
192 buff.reset_ptr(
sizeof(
int));
193 result = pcomm->pack_buffer(entities, adjacencies, tags,
false, -1, &buff);
195 "Failed to compute buffer size in broadcast_entities");
196 buff.set_stored_size();
197 buff_size = buff.buff_ptr - buff.mem_ptr;
201 MPI_Bcast(&buff_size, 1, MPI_INT, from_proc, procConfig.proc_comm());
202 if (MPI_SUCCESS != success) {
209 if ((
int)procConfig.proc_rank() != from_proc)
210 buff.reserve(buff_size);
214 int sz = std::min(buff_size, MAX_BCAST_SIZE);
215 success = MPI_Bcast(buff.mem_ptr + offset, sz, MPI_UNSIGNED_CHAR, from_proc,
216 procConfig.proc_comm());
217 if (MPI_SUCCESS != success) {
225 std::vector<std::vector<EntityHandle>> dum1a, dum1b;
226 std::vector<std::vector<int>> dum1p;
227 std::vector<EntityHandle> dum2, dum4;
228 std::vector<unsigned int> dum3;
229 buff.reset_ptr(
sizeof(
int));
230 if ((
int)procConfig.proc_rank() == from_proc) {
231 ParallelComm *pcomm = ParallelComm::get_pcomm(&moab,
MYPCOMM_INDEX);
232 result = pcomm->unpack_buffer(buff.buff_ptr,
false, from_proc, -1, dum1a,
233 dum1b, dum1p, dum2, dum2, dum3, dum4);
235 result = pcomm->unpack_buffer(buff.buff_ptr,
false, from_proc, -1, dum1a,
236 dum1b, dum1p, dum2, dum2, dum3, dum4);
238 CHK_MOAB_THROW(result,
"Failed to unpack buffer in broadcast_entities");
239 std::copy(dum4.begin(), dum4.end(), range_inserter(entities));