Skip to content

Commit f41135f

Browse files
Refactor Gradient Interfaces 3D TreeMesh (#2319)
1 parent 8f94119 commit f41135f

File tree

1 file changed

+37
-28
lines changed

1 file changed

+37
-28
lines changed

src/solvers/dgsem_tree/dg_3d_parabolic.jl

+37-28
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,40 @@ end
870870
return nothing
871871
end
872872

873+
function calc_gradient_interface_flux!(surface_flux_values,
874+
mesh::TreeMesh{3}, equations, dg::DG,
875+
parabolic_scheme::ViscousFormulationBassiRebay1,
876+
cache, cache_parabolic)
877+
@unpack neighbor_ids, orientations = cache_parabolic.interfaces
878+
879+
@threaded for interface in eachinterface(dg, cache_parabolic)
880+
# Get neighboring elements
881+
left_id = neighbor_ids[1, interface]
882+
right_id = neighbor_ids[2, interface]
883+
884+
# Determine interface direction with respect to elements:
885+
# orientation = 1: left -> 2, right -> 1
886+
# orientation = 2: left -> 4, right -> 3
887+
# orientation = 3: left -> 6, right -> 5
888+
left_direction = 2 * orientations[interface]
889+
right_direction = 2 * orientations[interface] - 1
890+
891+
for j in eachnode(dg), i in eachnode(dg)
892+
# Call pointwise Riemann solver
893+
u_ll, u_rr = get_surface_node_vars(cache_parabolic.interfaces.u,
894+
equations, dg, i, j,
895+
interface)
896+
flux = 0.5f0 * (u_ll + u_rr) # Bassi-Rebay 1 (BR1)
897+
898+
# Copy flux to left and right element storage
899+
for v in eachvariable(equations)
900+
surface_flux_values[v, i, j, left_direction, left_id] = flux[v]
901+
surface_flux_values[v, i, j, right_direction, right_id] = flux[v]
902+
end
903+
end
904+
end
905+
end
906+
873907
# Calculate the gradient of the transformed variables
874908
function calc_gradient!(gradients, u_transformed, t,
875909
mesh::TreeMesh{3}, equations_parabolic,
@@ -924,34 +958,9 @@ function calc_gradient!(gradients, u_transformed, t,
924958
# Calculate interface fluxes
925959
@trixi_timeit timer() "interface flux" begin
926960
@unpack surface_flux_values = cache_parabolic.elements
927-
@unpack neighbor_ids, orientations = cache_parabolic.interfaces
928-
929-
@threaded for interface in eachinterface(dg, cache_parabolic)
930-
# Get neighboring elements
931-
left_id = neighbor_ids[1, interface]
932-
right_id = neighbor_ids[2, interface]
933-
934-
# Determine interface direction with respect to elements:
935-
# orientation = 1: left -> 2, right -> 1
936-
# orientation = 2: left -> 4, right -> 3
937-
# orientation = 3: left -> 6, right -> 5
938-
left_direction = 2 * orientations[interface]
939-
right_direction = 2 * orientations[interface] - 1
940-
941-
for j in eachnode(dg), i in eachnode(dg)
942-
# Call pointwise Riemann solver
943-
u_ll, u_rr = get_surface_node_vars(cache_parabolic.interfaces.u,
944-
equations_parabolic, dg, i, j,
945-
interface)
946-
flux = 0.5f0 * (u_ll + u_rr)
947-
948-
# Copy flux to left and right element storage
949-
for v in eachvariable(equations_parabolic)
950-
surface_flux_values[v, i, j, left_direction, left_id] = flux[v]
951-
surface_flux_values[v, i, j, right_direction, right_id] = flux[v]
952-
end
953-
end
954-
end
961+
calc_gradient_interface_flux!(surface_flux_values, mesh, equations_parabolic,
962+
dg, parabolic_scheme,
963+
cache, cache_parabolic)
955964
end
956965

957966
# Prolong solution to boundaries

0 commit comments

Comments
 (0)