From 7637e626d835cc4e66df0b848d266fa356b75ec0 Mon Sep 17 00:00:00 2001 From: dewenyushu Date: Sat, 4 Dec 2021 10:56:53 -0700 Subject: [PATCH 1/2] Fix for boundary info in ElementSubdomainModifier --- .../src/userobject/ElementSubdomainModifier.C | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/framework/src/userobject/ElementSubdomainModifier.C b/framework/src/userobject/ElementSubdomainModifier.C index ef6310c59801..85ea2c6be921 100644 --- a/framework/src/userobject/ElementSubdomainModifier.C +++ b/framework/src/userobject/ElementSubdomainModifier.C @@ -181,18 +181,19 @@ ElementSubdomainModifier::updateBoundaryInfo(MooseMesh & mesh, for (auto side : elem->side_index_range()) { const Elem * neighbor = elem->neighbor_ptr(side); + if (neighbor && neighbor != libMesh::remote_elem) { - // If the neighbor has a different subdomain ID, then this side should be added to - // the moving boundary - if (neighbor->subdomain_id() != elem->subdomain_id()) - bnd_info.add_side(elem, side, _moving_boundary_id); - // Otherwise remove this side and the neighbor side from the boundary. - else + // Add all the sides to the boundary first and remove excessive sides later + bnd_info.add_side(elem, side, _moving_boundary_id); + // If this element and neighbor element are in the same subdomain, remove this side and the + // neighbor side from the boundary. + if (neighbor->subdomain_id() == elem->subdomain_id()) { - bnd_info.remove_side(elem, side); + bnd_info.remove_side(elem, side, _moving_boundary_id); unsigned int neighbor_side = neighbor->which_neighbor_am_i(elem); - bnd_info.remove_side(neighbor, neighbor_side); + // nothing happens if the neighbor side does not exist in the subdomain + bnd_info.remove_side(neighbor, neighbor_side, _moving_boundary_id); if (neighbor->processor_id() != this->processor_id()) ghost_sides_to_remove[neighbor->processor_id()].emplace_back(neighbor->id(), neighbor_side); From 3296609f6abb7a901883b34a92dbdf27bfc78fcb Mon Sep 17 00:00:00 2001 From: dewenyushu Date: Thu, 9 Dec 2021 16:55:35 -0700 Subject: [PATCH 2/2] Add test case --- .../element_subdomain_modifier/adaptivity.i | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 test/tests/userobjects/element_subdomain_modifier/adaptivity.i diff --git a/test/tests/userobjects/element_subdomain_modifier/adaptivity.i b/test/tests/userobjects/element_subdomain_modifier/adaptivity.i new file mode 100644 index 000000000000..e41e0dd33c70 --- /dev/null +++ b/test/tests/userobjects/element_subdomain_modifier/adaptivity.i @@ -0,0 +1,99 @@ +[Problem] + solve = false +[] + +[Mesh] + [gen] + type = GeneratedMeshGenerator + dim = 2 + xmin = -1 + xmax = 1 + ymin = -1 + ymax = 1 + nx = 16 + ny = 16 + [] + [left] + type = SubdomainBoundingBoxGenerator + input = 'gen' + block_id = 1 + bottom_left = '-1 -1 0' + top_right = '0 1 1' + [] + [right] + type = SubdomainBoundingBoxGenerator + input = 'left' + block_id = 2 + bottom_left = '0 -1 0' + top_right = '1 1 1' + [] + [moving_boundary] + type = SideSetsAroundSubdomainGenerator + input = 'right' + block = 1 + new_boundary = 'moving_boundary' + normal = '1 0 0' + [] +[] + +[UserObjects] + [moving_circle] + type = CoupledVarThresholdElementSubdomainModifier + coupled_var = 'phi' + block = 2 + criterion_type = ABOVE + threshold = 0.5 + subdomain_id = 1 + moving_boundary_name = moving_boundary + execute_on = 'TIMESTEP_BEGIN' + [] +[] + +[Functions] + [moving_gauss] + type = ParsedFunction + value = 'exp(-((x+0.5-t)^2+(y)^2)/0.25)' + [] +[] + +[AuxVariables] + [phi] + [] +[] + +[AuxKernels] + [phi] + type = FunctionAux + variable = phi + function = moving_gauss + execute_on = 'INITIAL TIMESTEP_BEGIN TIMESTEP_END' + [] +[] + +[Adaptivity] + steps = 1 + marker = marker + initial_marker = marker + max_h_level = 1 + [Indicators/indicator] + type = GradientJumpIndicator + variable = phi + [] + [Markers/marker] + type = ErrorFractionMarker + indicator = indicator + coarsen = 0.2 + refine = 0.5 + check_subdomain_consistent_for_coarsen = true + [] +[] + +[Executioner] + type = Transient + dt = 0.1 + num_steps = 10 +[] + +[Outputs] + exodus = true +[]