Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clear up old moving boundary
Browse files Browse the repository at this point in the history
fdkong committed Jan 13, 2022
1 parent 72a1a76 commit 6eb40b1
Showing 2 changed files with 32 additions and 0 deletions.
3 changes: 3 additions & 0 deletions framework/include/userobject/ElementSubdomainModifier.h
Original file line number Diff line number Diff line change
@@ -90,6 +90,9 @@ class ElementSubdomainModifier : public ElementUserObject
// Change the subdomain ID of all ancestor elements
void setAncestorsSubdomainIDs(const SubdomainID & subdomain_id, const dof_id_type & elem_id);

// Clear old moving boundaries
void clearOldMovingBoundary(MooseMesh & mesh);

// Elements on the undisplaced mesh whose subdomain IDs have changed
std::vector<const Elem *> _moved_elems;

29 changes: 29 additions & 0 deletions framework/src/userobject/ElementSubdomainModifier.C
Original file line number Diff line number Diff line change
@@ -136,6 +136,11 @@ ElementSubdomainModifier::finalize()
updateBoundaryInfo(_displaced_problem->mesh(), _moved_displaced_elems);
}

clearOldMovingBoundary(_mesh);

if (_displaced_problem)
clearOldMovingBoundary(_displaced_problem->mesh());

// Reinit equation systems
_fe_problem.meshChanged();

@@ -159,6 +164,30 @@ ElementSubdomainModifier::finalize()
_fe_problem.initElementStatefulProps(movedElemsRange());
}

void
ElementSubdomainModifier::clearOldMovingBoundary(MooseMesh & mesh)
{
std::vector<std::pair<Elem *, unsigned int>> to_be_cleared;
//auto & elem_side_bnd_ids = _mesh.getMesh().get_sideset_map();
BoundaryInfo & bnd_info = mesh.getMesh().get_boundary_info();
auto & elem_side_bnd_ids = bnd_info.get_sideset_map();
for (const auto & pr : elem_side_bnd_ids)
{
if (pr.second.second == _moving_boundary_id)
{
Elem * elem = _mesh.elemPtr(pr.first->id());
const Elem * neighbor = elem->neighbor_ptr(pr.second.first);
if (elem->subdomain_id() == neighbor->subdomain_id())
to_be_cleared.emplace_back(elem, pr.second.first);
}
}

for (auto & elem_side: to_be_cleared)
{
bnd_info.remove_side(elem_side.first, elem_side.second);
}
}

void
ElementSubdomainModifier::updateBoundaryInfo(MooseMesh & mesh,
const std::vector<const Elem *> & moved_elems)

0 comments on commit 6eb40b1

Please sign in to comment.