Skip to content

Commit

Permalink
Pack data for new boundary on children elements
Browse files Browse the repository at this point in the history
  • Loading branch information
fdkong committed Apr 6, 2022
1 parent 0a41e91 commit c934f9d
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 69 deletions.
4 changes: 2 additions & 2 deletions include/mesh/boundary_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -472,15 +472,15 @@ class BoundaryInfo : public ParallelObject
* side of element \p elem.
*/
unsigned int n_boundary_ids (const Elem * const elem,
const unsigned short int side) const;
const unsigned short int side, const bool traverse = true) const;

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

/**
* \returns The list of raw boundary ids associated with the \p side
Expand Down
9 changes: 5 additions & 4 deletions src/mesh/boundary_info.C
Original file line number Diff line number Diff line change
Expand Up @@ -1228,9 +1228,10 @@ bool BoundaryInfo::has_boundary_id(const Elem * const elem,

void BoundaryInfo::boundary_ids (const Elem * const elem,
const unsigned short int side,
std::vector<boundary_id_type> & vec_to_fill) const
std::vector<boundary_id_type> & vec_to_fill, const bool traverse) const
{
libmesh_assert(elem);
libmesh_assert(_children_on_boundary || elem->level() == 0);

// Clear out any previous contents
vec_to_fill.clear();
Expand All @@ -1241,7 +1242,7 @@ void BoundaryInfo::boundary_ids (const Elem * const elem,
if (_children_on_boundary || elem->level() == 0)
searched_elems.push_back(elem);

if (elem->level() != 0)
if (elem->level() != 0 && traverse)
{
if (elem->neighbor_ptr(side) == nullptr)
searched_elems.push_back(elem->top_parent());
Expand Down Expand Up @@ -1273,10 +1274,10 @@ void BoundaryInfo::boundary_ids (const Elem * const elem,


unsigned int BoundaryInfo::n_boundary_ids (const Elem * const elem,
const unsigned short int side) const
const unsigned short int side, const bool traverse) const
{
std::vector<boundary_id_type> ids;
this->boundary_ids(elem, side, ids);
this->boundary_ids(elem, side, ids, traverse);
return cast_int<unsigned int>(ids.size());
}

Expand Down
137 changes: 74 additions & 63 deletions src/parallel/parallel_elem.C
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Packing<const Elem *>::packed_size (std::vector<largest_id_type>::const_iterator
DofObject::unpackable_indexing_size(in+pre_indexing_size);

unsigned int total_packed_bc_data = 0;
if (level == 0)
// if (level == 0)
{
for (unsigned int s = 0; s != n_sides; ++s)
{
Expand All @@ -100,23 +100,26 @@ Packing<const Elem *>::packed_size (std::vector<largest_id_type>::const_iterator
total_packed_bc_data += n_bcs;
}

for (unsigned int e = 0; e != n_edges; ++e)
{
const int n_bcs = cast_int<int>
(*(in + pre_indexing_size + indexing_size +
total_packed_bc_data++));
libmesh_assert_greater_equal (n_bcs, 0);
total_packed_bc_data += n_bcs;
}
if (level == 0)
{
for (unsigned int e = 0; e != n_edges; ++e)
{
const int n_bcs = cast_int<int>
(*(in + pre_indexing_size + indexing_size +
total_packed_bc_data++));
libmesh_assert_greater_equal (n_bcs, 0);
total_packed_bc_data += n_bcs;
}

for (unsigned short sf=0; sf != 2; ++sf)
{
const int n_bcs = cast_int<int>
(*(in + pre_indexing_size + indexing_size +
total_packed_bc_data++));
libmesh_assert_greater_equal (n_bcs, 0);
total_packed_bc_data += n_bcs;
}
for (unsigned short sf=0; sf != 2; ++sf)
{
const int n_bcs = cast_int<int>
(*(in + pre_indexing_size + indexing_size +
total_packed_bc_data++));
libmesh_assert_greater_equal (n_bcs, 0);
total_packed_bc_data += n_bcs;
}
}
}

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

if (elem->level() == 0)
//if (elem->level() == 0)
{
total_packed_bcs += n_sides;
for (unsigned short s = 0; s != n_sides; ++s)
total_packed_bcs +=
mesh->get_boundary_info().n_boundary_ids(elem,s);

const unsigned short n_edges = elem->n_edges();
total_packed_bcs += n_edges;
for (unsigned short e = 0; e != n_edges; ++e)
total_packed_bcs +=
mesh->get_boundary_info().n_edge_boundary_ids(elem,e);
mesh->get_boundary_info().n_boundary_ids(elem,s,false);

total_packed_bcs += 2; // shellfaces
for (unsigned short sf=0; sf != 2; ++sf)
total_packed_bcs +=
mesh->get_boundary_info().n_shellface_boundary_ids(elem,sf);
if (elem->level() == 0)
{
const unsigned short n_edges = elem->n_edges();
total_packed_bcs += n_edges;
for (unsigned short e = 0; e != n_edges; ++e)
total_packed_bcs +=
mesh->get_boundary_info().n_edge_boundary_ids(elem,e);

total_packed_bcs += 2; // shellfaces
for (unsigned short sf=0; sf != 2; ++sf)
total_packed_bcs +=
mesh->get_boundary_info().n_shellface_boundary_ids(elem,sf);
}
}

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

// If this is a coarse element,
// Add any element side boundary condition ids
if (elem->level() == 0)
// if (elem->level() == 0)
{
std::vector<boundary_id_type> bcs;
for (auto s : elem->side_index_range())
{
mesh->get_boundary_info().boundary_ids(elem, s, bcs);
mesh->get_boundary_info().boundary_ids(elem, s, bcs,false);

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

for (const auto & bid : bcs)
*data_out++ = bid;
}
if (elem->level() == 0)
{
for (auto e : elem->edge_index_range())
{
mesh->get_boundary_info().edge_boundary_ids(elem, e, bcs);

for (auto e : elem->edge_index_range())
{
mesh->get_boundary_info().edge_boundary_ids(elem, e, bcs);

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

for (const auto & bid : bcs)
*data_out++ = bid;
}
for (const auto & bid : bcs)
*data_out++ = bid;
}

for (unsigned short sf=0; sf != 2; ++sf)
{
mesh->get_boundary_info().shellface_boundary_ids(elem, sf, bcs);
for (unsigned short sf=0; sf != 2; ++sf)
{
mesh->get_boundary_info().shellface_boundary_ids(elem, sf, bcs);

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

for (const auto & bid : bcs)
*data_out++ = bid;
}
for (const auto & bid : bcs)
*data_out++ = bid;
}
}
}
}

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

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

for (auto e : elem->edge_index_range())
{
const boundary_id_type num_bcs =
cast_int<boundary_id_type>(*in++);
if (level == 0)
{
for (auto e : elem->edge_index_range())
{
const boundary_id_type num_bcs =
cast_int<boundary_id_type>(*in++);

for (boundary_id_type bc_it=0; bc_it < num_bcs; bc_it++)
mesh->get_boundary_info().add_edge
(elem, e, cast_int<boundary_id_type>(*in++));
}
for (boundary_id_type bc_it=0; bc_it < num_bcs; bc_it++)
mesh->get_boundary_info().add_edge
(elem, e, cast_int<boundary_id_type>(*in++));
}

for (unsigned short sf=0; sf != 2; ++sf)
{
const boundary_id_type num_bcs =
cast_int<boundary_id_type>(*in++);
for (unsigned short sf=0; sf != 2; ++sf)
{
const boundary_id_type num_bcs =
cast_int<boundary_id_type>(*in++);

for (boundary_id_type bc_it=0; bc_it < num_bcs; bc_it++)
mesh->get_boundary_info().add_shellface
(elem, sf, cast_int<boundary_id_type>(*in++));
}
for (boundary_id_type bc_it=0; bc_it < num_bcs; bc_it++)
mesh->get_boundary_info().add_shellface
(elem, sf, cast_int<boundary_id_type>(*in++));
}
}
}

// Return the new element
Expand Down

0 comments on commit c934f9d

Please sign in to comment.