Skip to content

Commit 0a071f5

Browse files
Modularize calc_boundary_flux! for overset grid method (#71)
1 parent d1aa47a commit 0a071f5

1 file changed

Lines changed: 40 additions & 16 deletions

File tree

src/semidiscretization/semidiscretization_overset_grid.jl

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -138,49 +138,73 @@ function rhs!(du, u, t, mesh::OversetGridMesh, equations, initial_condition,
138138
end
139139
end
140140

141-
function calc_boundary_flux!(surface_flux_values, u, t, boundary_conditions,
142-
mesh::OversetGridMesh, equations,
143-
integral::Tuple, solver, cache)
144-
surface_flux_values_left, surface_flux_values_right = surface_flux_values
141+
function calc_boundary_flux_left!(surface_flux_values_left, u, t, x_neg,
142+
equations, mesh, integral_left, solver,
143+
cache)
145144
u_left, u_right = u
146-
(; x_neg, x_pos) = boundary_conditions
147-
mesh_left, mesh_right = mesh.mesh_left, mesh.mesh_right
148-
integral_left, integral_right = integral
149-
solver_left, solver_right = solver
150-
cache_left, cache_right = cache
151-
l_left, l_right = cache.l_left, cache.l_right
152-
e_M_left, e_M_right = cache.e_M_left, cache.e_M_right
145+
solver_left, _ = solver
146+
mesh_left = mesh.mesh_left
147+
cache_left, _ = cache
148+
l_right = cache.l_right
149+
e_M_right = cache.e_M_right
153150

154-
# Left boundary condition of left mesh
151+
# Left boundary condition of left mesh (at a)
155152
e_left_L = get_projection_operator(cache_left.e_left, solver_left, 1)
156153
u_ll = x_neg(u, xmin(mesh), t, mesh, equations, solver, true, cache)
157154
u_rr = get_multiplied_node_vars(u_left, equations, e_left_L', :, 1)
158155
f = integral_left.surface_flux_boundary(u_ll, u_rr, equations)
159156
set_node_vars!(surface_flux_values_left, f, equations, 1, 1)
160157

161-
# Right boundary condition of left mesh
158+
# Right boundary condition of left mesh (at c)
162159
e_right_L = get_projection_operator(cache_left.e_right, solver_left,
163160
nelements(mesh_left))
164161
u_ll = get_multiplied_node_vars(u_left, equations, e_right_L', :, nelements(mesh_left))
165162
u_rr = get_multiplied_node_vars(u_right, equations, e_M_right', :, l_right)
166163
f = integral_left.surface_flux_boundary(u_ll, u_rr, equations)
167164
set_node_vars!(surface_flux_values_left, f, equations, 2, nelements(mesh_left))
165+
return nothing
166+
end
168167

169-
# Left boundary condition of right mesh
168+
function calc_boundary_flux_right!(surface_flux_values_right, u, t, x_pos,
169+
equations, mesh, integral_right, solver,
170+
cache)
171+
u_left, u_right = u
172+
_, solver_right = solver
173+
mesh_right = mesh.mesh_right
174+
_, cache_right = cache
175+
l_left = cache.l_left
176+
e_M_left = cache.e_M_left
177+
178+
# Left boundary condition of right mesh (at b)
170179
e_left_R = get_projection_operator(cache_right.e_left, solver_right, 1)
171180
u_ll = get_multiplied_node_vars(u_left, equations, e_M_left', :, l_left)
172181
u_rr = get_multiplied_node_vars(u_right, equations, e_left_R', :, 1)
173182
f = integral_right.surface_flux_boundary(u_ll, u_rr, equations)
174183
set_node_vars!(surface_flux_values_right, f, equations, 1, 1)
175184

176-
# Right boundary condition of right mesh
185+
# Right boundary condition of right mesh (at d)
177186
e_right_R = get_projection_operator(cache_right.e_right, solver_right,
178187
nelements(mesh_right))
179188
u_ll = get_multiplied_node_vars(u_right, equations, e_right_R', :,
180189
nelements(mesh_right))
181190
u_rr = x_pos(u, xmax(mesh), t, mesh, equations, solver, false, cache)
182191
f = integral_right.surface_flux_boundary(u_ll, u_rr, equations)
183-
return set_node_vars!(surface_flux_values_right, f, equations, 2, nelements(mesh_right))
192+
set_node_vars!(surface_flux_values_right, f, equations, 2, nelements(mesh_right))
193+
return nothing
194+
end
195+
196+
function calc_boundary_flux!(surface_flux_values, u, t, boundary_conditions,
197+
mesh::OversetGridMesh, equations,
198+
integral::Tuple, solver, cache)
199+
surface_flux_values_left, surface_flux_values_right = surface_flux_values
200+
(; x_neg, x_pos) = boundary_conditions
201+
integral_left, integral_right = integral
202+
203+
calc_boundary_flux_left!(surface_flux_values_left, u, t, x_neg, equations,
204+
mesh, integral_left, solver, cache)
205+
calc_boundary_flux_right!(surface_flux_values_right, u, t, x_pos, equations,
206+
mesh, integral_right, solver, cache)
207+
return nothing
184208
end
185209

186210
# This method is for integrating a vector quantity for all variables over the entire domain,

0 commit comments

Comments
 (0)