diff --git a/framework/include/userobject/ElementSubdomainModifier.h b/framework/include/userobject/ElementSubdomainModifier.h index aa36f95d0b4a..cd7a62645f4a 100644 --- a/framework/include/userobject/ElementSubdomainModifier.h +++ b/framework/include/userobject/ElementSubdomainModifier.h @@ -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 _moved_elems; diff --git a/framework/src/userobject/ElementSubdomainModifier.C b/framework/src/userobject/ElementSubdomainModifier.C index 85ea2c6be921..85002dd5ef9b 100644 --- a/framework/src/userobject/ElementSubdomainModifier.C +++ b/framework/src/userobject/ElementSubdomainModifier.C @@ -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> 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 & moved_elems)