Skip to content

Commit f931a43

Browse files
committed
Pack data for new boundary on children elements
1 parent 0a41e91 commit f931a43

File tree

3 files changed

+80
-69
lines changed

3 files changed

+80
-69
lines changed

include/mesh/boundary_info.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,15 +472,15 @@ class BoundaryInfo : public ParallelObject
472472
* side of element \p elem.
473473
*/
474474
unsigned int n_boundary_ids (const Elem * const elem,
475-
const unsigned short int side) const;
475+
const unsigned short int side, const bool traverse = true) const;
476476

477477
/**
478478
* \returns The list of boundary ids associated with the \p side side of
479479
* element \p elem.
480480
*/
481481
void boundary_ids (const Elem * const elem,
482482
const unsigned short int side,
483-
std::vector<boundary_id_type> & vec_to_fill) const;
483+
std::vector<boundary_id_type> & vec_to_fill, const bool traverse = true) const;
484484

485485
/**
486486
* \returns The list of raw boundary ids associated with the \p side

src/mesh/boundary_info.C

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,7 +1228,7 @@ bool BoundaryInfo::has_boundary_id(const Elem * const elem,
12281228

12291229
void BoundaryInfo::boundary_ids (const Elem * const elem,
12301230
const unsigned short int side,
1231-
std::vector<boundary_id_type> & vec_to_fill) const
1231+
std::vector<boundary_id_type> & vec_to_fill, const bool traverse) const
12321232
{
12331233
libmesh_assert(elem);
12341234

@@ -1241,7 +1241,7 @@ void BoundaryInfo::boundary_ids (const Elem * const elem,
12411241
if (_children_on_boundary || elem->level() == 0)
12421242
searched_elems.push_back(elem);
12431243

1244-
if (elem->level() != 0)
1244+
if (elem->level() != 0 && traverse)
12451245
{
12461246
if (elem->neighbor_ptr(side) == nullptr)
12471247
searched_elems.push_back(elem->top_parent());
@@ -1273,10 +1273,10 @@ void BoundaryInfo::boundary_ids (const Elem * const elem,
12731273

12741274

12751275
unsigned int BoundaryInfo::n_boundary_ids (const Elem * const elem,
1276-
const unsigned short int side) const
1276+
const unsigned short int side, const bool traverse) const
12771277
{
12781278
std::vector<boundary_id_type> ids;
1279-
this->boundary_ids(elem, side, ids);
1279+
this->boundary_ids(elem, side, ids, traverse);
12801280
return cast_int<unsigned int>(ids.size());
12811281
}
12821282

src/parallel/parallel_elem.C

Lines changed: 74 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Packing<const Elem *>::packed_size (std::vector<largest_id_type>::const_iterator
8989
DofObject::unpackable_indexing_size(in+pre_indexing_size);
9090

9191
unsigned int total_packed_bc_data = 0;
92-
if (level == 0)
92+
// if (level == 0)
9393
{
9494
for (unsigned int s = 0; s != n_sides; ++s)
9595
{
@@ -100,23 +100,26 @@ Packing<const Elem *>::packed_size (std::vector<largest_id_type>::const_iterator
100100
total_packed_bc_data += n_bcs;
101101
}
102102

103-
for (unsigned int e = 0; e != n_edges; ++e)
104-
{
105-
const int n_bcs = cast_int<int>
106-
(*(in + pre_indexing_size + indexing_size +
107-
total_packed_bc_data++));
108-
libmesh_assert_greater_equal (n_bcs, 0);
109-
total_packed_bc_data += n_bcs;
110-
}
103+
if (level == 0)
104+
{
105+
for (unsigned int e = 0; e != n_edges; ++e)
106+
{
107+
const int n_bcs = cast_int<int>
108+
(*(in + pre_indexing_size + indexing_size +
109+
total_packed_bc_data++));
110+
libmesh_assert_greater_equal (n_bcs, 0);
111+
total_packed_bc_data += n_bcs;
112+
}
111113

112-
for (unsigned short sf=0; sf != 2; ++sf)
113-
{
114-
const int n_bcs = cast_int<int>
115-
(*(in + pre_indexing_size + indexing_size +
116-
total_packed_bc_data++));
117-
libmesh_assert_greater_equal (n_bcs, 0);
118-
total_packed_bc_data += n_bcs;
119-
}
114+
for (unsigned short sf=0; sf != 2; ++sf)
115+
{
116+
const int n_bcs = cast_int<int>
117+
(*(in + pre_indexing_size + indexing_size +
118+
total_packed_bc_data++));
119+
libmesh_assert_greater_equal (n_bcs, 0);
120+
total_packed_bc_data += n_bcs;
121+
}
122+
}
120123
}
121124

122125
return
@@ -145,23 +148,26 @@ Packing<const Elem *>::packable_size (const Elem * const & elem,
145148
unsigned int total_packed_bcs = 0;
146149
const unsigned short n_sides = elem->n_sides();
147150

148-
if (elem->level() == 0)
151+
//if (elem->level() == 0)
149152
{
150153
total_packed_bcs += n_sides;
151154
for (unsigned short s = 0; s != n_sides; ++s)
152155
total_packed_bcs +=
153-
mesh->get_boundary_info().n_boundary_ids(elem,s);
154-
155-
const unsigned short n_edges = elem->n_edges();
156-
total_packed_bcs += n_edges;
157-
for (unsigned short e = 0; e != n_edges; ++e)
158-
total_packed_bcs +=
159-
mesh->get_boundary_info().n_edge_boundary_ids(elem,e);
156+
mesh->get_boundary_info().n_boundary_ids(elem,s,false);
160157

161-
total_packed_bcs += 2; // shellfaces
162-
for (unsigned short sf=0; sf != 2; ++sf)
163-
total_packed_bcs +=
164-
mesh->get_boundary_info().n_shellface_boundary_ids(elem,sf);
158+
if (elem->level() == 0)
159+
{
160+
const unsigned short n_edges = elem->n_edges();
161+
total_packed_bcs += n_edges;
162+
for (unsigned short e = 0; e != n_edges; ++e)
163+
total_packed_bcs +=
164+
mesh->get_boundary_info().n_edge_boundary_ids(elem,e);
165+
166+
total_packed_bcs += 2; // shellfaces
167+
for (unsigned short sf=0; sf != 2; ++sf)
168+
total_packed_bcs +=
169+
mesh->get_boundary_info().n_shellface_boundary_ids(elem,sf);
170+
}
165171
}
166172

167173
return
@@ -290,38 +296,40 @@ Packing<const Elem *>::pack (const Elem * const & elem,
290296

291297
// If this is a coarse element,
292298
// Add any element side boundary condition ids
293-
if (elem->level() == 0)
299+
// if (elem->level() == 0)
294300
{
295301
std::vector<boundary_id_type> bcs;
296302
for (auto s : elem->side_index_range())
297303
{
298-
mesh->get_boundary_info().boundary_ids(elem, s, bcs);
304+
mesh->get_boundary_info().boundary_ids(elem, s, bcs,false);
299305

300306
*data_out++ =(bcs.size());
301307

302308
for (const auto & bid : bcs)
303309
*data_out++ = bid;
304310
}
311+
if (elem->level() == 0)
312+
{
313+
for (auto e : elem->edge_index_range())
314+
{
315+
mesh->get_boundary_info().edge_boundary_ids(elem, e, bcs);
305316

306-
for (auto e : elem->edge_index_range())
307-
{
308-
mesh->get_boundary_info().edge_boundary_ids(elem, e, bcs);
309-
310-
*data_out++ =(bcs.size());
317+
*data_out++ =(bcs.size());
311318

312-
for (const auto & bid : bcs)
313-
*data_out++ = bid;
314-
}
319+
for (const auto & bid : bcs)
320+
*data_out++ = bid;
321+
}
315322

316-
for (unsigned short sf=0; sf != 2; ++sf)
317-
{
318-
mesh->get_boundary_info().shellface_boundary_ids(elem, sf, bcs);
323+
for (unsigned short sf=0; sf != 2; ++sf)
324+
{
325+
mesh->get_boundary_info().shellface_boundary_ids(elem, sf, bcs);
319326

320-
*data_out++ =(bcs.size());
327+
*data_out++ =(bcs.size());
321328

322-
for (const auto & bid : bcs)
323-
*data_out++ = bid;
324-
}
329+
for (const auto & bid : bcs)
330+
*data_out++ = bid;
331+
}
332+
}
325333
}
326334
}
327335

@@ -776,7 +784,7 @@ Packing<Elem *>::unpack (std::vector<largest_id_type>::const_iterator in,
776784

777785
// If this is a coarse element,
778786
// add any element side or edge boundary condition ids
779-
if (level == 0)
787+
//if (level == 0)
780788
{
781789
for (auto s : elem->side_index_range())
782790
{
@@ -788,25 +796,28 @@ Packing<Elem *>::unpack (std::vector<largest_id_type>::const_iterator in,
788796
(elem, s, cast_int<boundary_id_type>(*in++));
789797
}
790798

791-
for (auto e : elem->edge_index_range())
792-
{
793-
const boundary_id_type num_bcs =
794-
cast_int<boundary_id_type>(*in++);
799+
if (level == 0)
800+
{
801+
for (auto e : elem->edge_index_range())
802+
{
803+
const boundary_id_type num_bcs =
804+
cast_int<boundary_id_type>(*in++);
795805

796-
for (boundary_id_type bc_it=0; bc_it < num_bcs; bc_it++)
797-
mesh->get_boundary_info().add_edge
798-
(elem, e, cast_int<boundary_id_type>(*in++));
799-
}
806+
for (boundary_id_type bc_it=0; bc_it < num_bcs; bc_it++)
807+
mesh->get_boundary_info().add_edge
808+
(elem, e, cast_int<boundary_id_type>(*in++));
809+
}
800810

801-
for (unsigned short sf=0; sf != 2; ++sf)
802-
{
803-
const boundary_id_type num_bcs =
804-
cast_int<boundary_id_type>(*in++);
811+
for (unsigned short sf=0; sf != 2; ++sf)
812+
{
813+
const boundary_id_type num_bcs =
814+
cast_int<boundary_id_type>(*in++);
805815

806-
for (boundary_id_type bc_it=0; bc_it < num_bcs; bc_it++)
807-
mesh->get_boundary_info().add_shellface
808-
(elem, sf, cast_int<boundary_id_type>(*in++));
809-
}
816+
for (boundary_id_type bc_it=0; bc_it < num_bcs; bc_it++)
817+
mesh->get_boundary_info().add_shellface
818+
(elem, sf, cast_int<boundary_id_type>(*in++));
819+
}
820+
}
810821
}
811822

812823
// Return the new element

0 commit comments

Comments
 (0)