Skip to content

Commit 772e2ee

Browse files
authored
Merge pull request #3 from dewenyushu/fix_elem_remove_side
Simple but not ideal fix for remove sides in ElementSubdomainModifier
2 parents 50b39c0 + 3296609 commit 772e2ee

File tree

2 files changed

+108
-8
lines changed

2 files changed

+108
-8
lines changed

framework/src/userobject/ElementSubdomainModifier.C

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -181,18 +181,19 @@ ElementSubdomainModifier::updateBoundaryInfo(MooseMesh & mesh,
181181
for (auto side : elem->side_index_range())
182182
{
183183
const Elem * neighbor = elem->neighbor_ptr(side);
184+
184185
if (neighbor && neighbor != libMesh::remote_elem)
185186
{
186-
// If the neighbor has a different subdomain ID, then this side should be added to
187-
// the moving boundary
188-
if (neighbor->subdomain_id() != elem->subdomain_id())
189-
bnd_info.add_side(elem, side, _moving_boundary_id);
190-
// Otherwise remove this side and the neighbor side from the boundary.
191-
else
187+
// Add all the sides to the boundary first and remove excessive sides later
188+
bnd_info.add_side(elem, side, _moving_boundary_id);
189+
// If this element and neighbor element are in the same subdomain, remove this side and the
190+
// neighbor side from the boundary.
191+
if (neighbor->subdomain_id() == elem->subdomain_id())
192192
{
193-
bnd_info.remove_side(elem, side);
193+
bnd_info.remove_side(elem, side, _moving_boundary_id);
194194
unsigned int neighbor_side = neighbor->which_neighbor_am_i(elem);
195-
bnd_info.remove_side(neighbor, neighbor_side);
195+
// nothing happens if the neighbor side does not exist in the subdomain
196+
bnd_info.remove_side(neighbor, neighbor_side, _moving_boundary_id);
196197
if (neighbor->processor_id() != this->processor_id())
197198
ghost_sides_to_remove[neighbor->processor_id()].emplace_back(neighbor->id(),
198199
neighbor_side);
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
[Problem]
2+
solve = false
3+
[]
4+
5+
[Mesh]
6+
[gen]
7+
type = GeneratedMeshGenerator
8+
dim = 2
9+
xmin = -1
10+
xmax = 1
11+
ymin = -1
12+
ymax = 1
13+
nx = 16
14+
ny = 16
15+
[]
16+
[left]
17+
type = SubdomainBoundingBoxGenerator
18+
input = 'gen'
19+
block_id = 1
20+
bottom_left = '-1 -1 0'
21+
top_right = '0 1 1'
22+
[]
23+
[right]
24+
type = SubdomainBoundingBoxGenerator
25+
input = 'left'
26+
block_id = 2
27+
bottom_left = '0 -1 0'
28+
top_right = '1 1 1'
29+
[]
30+
[moving_boundary]
31+
type = SideSetsAroundSubdomainGenerator
32+
input = 'right'
33+
block = 1
34+
new_boundary = 'moving_boundary'
35+
normal = '1 0 0'
36+
[]
37+
[]
38+
39+
[UserObjects]
40+
[moving_circle]
41+
type = CoupledVarThresholdElementSubdomainModifier
42+
coupled_var = 'phi'
43+
block = 2
44+
criterion_type = ABOVE
45+
threshold = 0.5
46+
subdomain_id = 1
47+
moving_boundary_name = moving_boundary
48+
execute_on = 'TIMESTEP_BEGIN'
49+
[]
50+
[]
51+
52+
[Functions]
53+
[moving_gauss]
54+
type = ParsedFunction
55+
value = 'exp(-((x+0.5-t)^2+(y)^2)/0.25)'
56+
[]
57+
[]
58+
59+
[AuxVariables]
60+
[phi]
61+
[]
62+
[]
63+
64+
[AuxKernels]
65+
[phi]
66+
type = FunctionAux
67+
variable = phi
68+
function = moving_gauss
69+
execute_on = 'INITIAL TIMESTEP_BEGIN TIMESTEP_END'
70+
[]
71+
[]
72+
73+
[Adaptivity]
74+
steps = 1
75+
marker = marker
76+
initial_marker = marker
77+
max_h_level = 1
78+
[Indicators/indicator]
79+
type = GradientJumpIndicator
80+
variable = phi
81+
[]
82+
[Markers/marker]
83+
type = ErrorFractionMarker
84+
indicator = indicator
85+
coarsen = 0.2
86+
refine = 0.5
87+
check_subdomain_consistent_for_coarsen = true
88+
[]
89+
[]
90+
91+
[Executioner]
92+
type = Transient
93+
dt = 0.1
94+
num_steps = 10
95+
[]
96+
97+
[Outputs]
98+
exodus = true
99+
[]

0 commit comments

Comments
 (0)