Skip to content

Commit

Permalink
Add verified changes from P4estMesh PR
Browse files Browse the repository at this point in the history
  • Loading branch information
bennibolm committed Dec 3, 2023
1 parent 7d9e867 commit 66476eb
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 67 deletions.
13 changes: 9 additions & 4 deletions examples/structured_2d_dgsem/elixir_euler_double_mach.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,12 @@ boundary_condition_inflow_outflow = BoundaryConditionCharacteristic(initial_cond
direction, x, t,
equations)
# Calculate boundary flux
flux = surface_flux_function(u_boundary, u_inner, normal_direction, equations)
if iseven(direction) # u_inner is "left" of boundary, u_boundary is "right" of boundary
flux = surface_flux_function(u_inner, u_boundary, orientation_or_normal,
equations)
else
flux = surface_flux_function(u_boundary, u_inner, normal_direction, equations)
end
else # x[1] >= 1 / 6
# Use the free slip wall BC otherwise
flux = boundary_condition_slip_wall(u_inner, normal_direction, direction, x, t,
Expand All @@ -77,14 +82,14 @@ end
@inline function Trixi.get_boundary_outer_state(u_inner, cache, t,
boundary_condition::typeof(boundary_condition_mixed_characteristic_wall),
normal_direction::AbstractVector, direction,
mesh::StructuredMesh{2},
equations::CompressibleEulerEquations2D,
dg, indices...)
x = Trixi.get_node_coords(cache.elements.node_coordinates, equations, dg, indices...)
if x[1] < 1 / 6 # BoundaryConditionCharacteristic
u_outer = Trixi.characteristic_boundary_value_function(initial_condition_double_mach_reflection,
u_inner,
normal_direction /
norm(normal_direction),
normal_direction,
direction, x, t, equations)

else # if x[1] >= 1 / 6 # boundary_condition_slip_wall
Expand Down Expand Up @@ -120,7 +125,7 @@ volume_integral = VolumeIntegralSubcellLimiting(limiter_idp;
volume_flux_fv = surface_flux)
solver = DGSEM(basis, surface_flux, volume_integral)

initial_refinement_level = 6
initial_refinement_level = 4
cells_per_dimension = (4 * 2^initial_refinement_level, 2^initial_refinement_level)
coordinates_min = (0.0, 0.0)
coordinates_max = (4.0, 1.0)
Expand Down
13 changes: 9 additions & 4 deletions examples/structured_2d_dgsem/elixir_euler_double_mach_MCL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,12 @@ boundary_condition_inflow_outflow = BoundaryConditionCharacteristic(initial_cond
direction, x, t,
equations)
# Calculate boundary flux
flux = surface_flux_function(u_boundary, u_inner, normal_direction, equations)
if iseven(direction) # u_inner is "left" of boundary, u_boundary is "right" of boundary
flux = surface_flux_function(u_inner, u_boundary, orientation_or_normal,
equations)
else
flux = surface_flux_function(u_boundary, u_inner, normal_direction, equations)
end
else # x[1] >= 1 / 6
# Use the free slip wall BC otherwise
flux = boundary_condition_slip_wall(u_inner, normal_direction, direction, x, t,
Expand All @@ -77,14 +82,14 @@ end
@inline function Trixi.get_boundary_outer_state(u_inner, cache, t,
boundary_condition::typeof(boundary_condition_mixed_characteristic_wall),
normal_direction::AbstractVector, direction,
mesh::StructuredMesh{2},
equations::CompressibleEulerEquations2D,
dg, indices...)
x = Trixi.get_node_coords(cache.elements.node_coordinates, equations, dg, indices...)
if x[1] < 1 / 6 # BoundaryConditionCharacteristic
u_outer = Trixi.characteristic_boundary_value_function(initial_condition_double_mach_reflection,
u_inner,
normal_direction /
norm(normal_direction),
normal_direction,
direction, x, t, equations)

else # if x[1] >= 1 / 6 # boundary_condition_slip_wall
Expand Down Expand Up @@ -123,7 +128,7 @@ volume_integral = VolumeIntegralSubcellLimiting(limiter_mcl;
volume_flux_fv = surface_flux)
solver = DGSEM(basis, surface_flux, volume_integral)

initial_refinement_level = 6
initial_refinement_level = 4
cells_per_dimension = (4 * 2^initial_refinement_level, 2^initial_refinement_level)
coordinates_min = (0.0, 0.0)
coordinates_max = (4.0, 1.0)
Expand Down
7 changes: 4 additions & 3 deletions src/equations/equations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,10 @@ end
x, t,
surface_flux_function,
equations)
u_boundary = characteristic_boundary_value_function(boundary_condition.outer_boundary_value_function,
u_inner, orientation_or_normal,
direction, x, t, equations)
u_boundary = boundary_condition.boundary_value_function(boundary_condition.outer_boundary_value_function,
u_inner,
orientation_or_normal,
direction, x, t, equations)

# Calculate boundary flux
if iseven(direction) # u_inner is "left" of boundary, u_boundary is "right" of boundary
Expand Down
14 changes: 8 additions & 6 deletions src/solvers/dgsem_structured/dg_2d_subcell_limiters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ end
u_inner = get_node_vars(u, equations, dg, 1, j, element)
u_outer = get_boundary_outer_state(u_inner, cache, t,
boundary_conditions[1], Ja1, 1,
equations, dg, 1, j, element)
mesh, equations, dg,
1, j, element)
lambda1[1, j, element] = max_abs_speed_naive(u_inner, u_outer, Ja1,
equations)

Expand All @@ -270,8 +271,8 @@ end
u_inner = get_node_vars(u, equations, dg, nnodes(dg), j, element)
u_outer = get_boundary_outer_state(u_inner, cache, t,
boundary_conditions[2], Ja1, 2,
equations, dg, nnodes(dg), j,
element)
mesh, equations, dg,
nnodes(dg), j, element)
lambda1[nnodes(dg) + 1, j, element] = max_abs_speed_naive(u_inner,
u_outer, Ja1,
equations)
Expand Down Expand Up @@ -301,7 +302,8 @@ end
u_inner = get_node_vars(u, equations, dg, i, 1, element)
u_outer = get_boundary_outer_state(u_inner, cache, t,
boundary_conditions[3], Ja2, 3,
equations, dg, i, 1, element)
mesh, equations, dg,
i, 1, element)
lambda2[i, 1, element] = max_abs_speed_naive(u_inner, u_outer, Ja2,
equations)

Expand All @@ -326,8 +328,8 @@ end
u_inner = get_node_vars(u, equations, dg, i, nnodes(dg), element)
u_outer = get_boundary_outer_state(u_inner, cache, t,
boundary_conditions[4], Ja2, 4,
equations, dg, i, nnodes(dg),
element)
mesh, equations, dg,
i, nnodes(dg), element)
lambda2[i, nnodes(dg) + 1, element] = max_abs_speed_naive(u_inner,
u_outer, Ja2,
equations)
Expand Down
28 changes: 16 additions & 12 deletions src/solvers/dgsem_structured/subcell_limiters_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ function calc_bounds_twosided_interface!(var_min, var_max, variable, u, t, semi,
u_inner = get_node_vars(u, equations, dg, 1, j, element)
u_outer = get_boundary_outer_state(u_inner, cache, t,
boundary_conditions[1], Ja1, 1,
equations, dg, 1, j, element)
mesh, equations, dg,
1, j, element)
var_outer = u_outer[variable]

var_min[1, j, element] = min(var_min[1, j, element], var_outer)
Expand All @@ -77,8 +78,8 @@ function calc_bounds_twosided_interface!(var_min, var_max, variable, u, t, semi,
u_inner = get_node_vars(u, equations, dg, nnodes(dg), j, element)
u_outer = get_boundary_outer_state(u_inner, cache, t,
boundary_conditions[2], Ja1, 2,
equations, dg, nnodes(dg), j,
element)
mesh, equations, dg,
nnodes(dg), j, element)
var_outer = u_outer[variable]

var_min[nnodes(dg), j, element] = min(var_min[nnodes(dg), j, element],
Expand All @@ -97,7 +98,8 @@ function calc_bounds_twosided_interface!(var_min, var_max, variable, u, t, semi,
u_inner = get_node_vars(u, equations, dg, i, 1, element)
u_outer = get_boundary_outer_state(u_inner, cache, t,
boundary_conditions[3], Ja2, 3,
equations, dg, i, 1, element)
mesh, equations, dg,
i, 1, element)
var_outer = u_outer[variable]

var_min[i, 1, element] = min(var_min[i, 1, element], var_outer)
Expand All @@ -113,8 +115,8 @@ function calc_bounds_twosided_interface!(var_min, var_max, variable, u, t, semi,
u_inner = get_node_vars(u, equations, dg, i, nnodes(dg), element)
u_outer = get_boundary_outer_state(u_inner, cache, t,
boundary_conditions[4], Ja2, 4,
equations, dg, i, nnodes(dg),
element)
mesh, equations, dg,
i, nnodes(dg), element)
var_outer = u_outer[variable]

var_min[i, nnodes(dg), element] = min(var_min[i, nnodes(dg), element],
Expand Down Expand Up @@ -180,7 +182,8 @@ function calc_bounds_onesided_interface!(var_minmax, minmax, variable, u, t, sem
u_inner = get_node_vars(u, equations, dg, 1, j, element)
u_outer = get_boundary_outer_state(u_inner, cache, t,
boundary_conditions[1], Ja1, 1,
equations, dg, 1, j, element)
mesh, equations, dg,
1, j, element)
var_outer = variable(u_outer, equations)

var_minmax[1, j, element] = minmax(var_minmax[1, j, element], var_outer)
Expand All @@ -195,8 +198,8 @@ function calc_bounds_onesided_interface!(var_minmax, minmax, variable, u, t, sem
u_inner = get_node_vars(u, equations, dg, nnodes(dg), j, element)
u_outer = get_boundary_outer_state(u_inner, cache, t,
boundary_conditions[2], Ja1, 2,
equations, dg, nnodes(dg), j,
element)
mesh, equations, dg,
nnodes(dg), j, element)
var_outer = variable(u_outer, equations)

var_minmax[nnodes(dg), j, element] = minmax(var_minmax[nnodes(dg), j,
Expand All @@ -214,7 +217,8 @@ function calc_bounds_onesided_interface!(var_minmax, minmax, variable, u, t, sem
u_inner = get_node_vars(u, equations, dg, i, 1, element)
u_outer = get_boundary_outer_state(u_inner, cache, t,
boundary_conditions[3], Ja2, 3,
equations, dg, i, 1, element)
mesh, equations, dg,
i, 1, element)
var_outer = variable(u_outer, equations)

var_minmax[i, 1, element] = minmax(var_minmax[i, 1, element], var_outer)
Expand All @@ -229,8 +233,8 @@ function calc_bounds_onesided_interface!(var_minmax, minmax, variable, u, t, sem
u_inner = get_node_vars(u, equations, dg, i, nnodes(dg), element)
u_outer = get_boundary_outer_state(u_inner, cache, t,
boundary_conditions[4], Ja2, 4,
equations, dg, i, nnodes(dg),
element)
mesh, equations, dg,
i, nnodes(dg), element)
var_outer = variable(u_outer, equations)

var_minmax[i, nnodes(dg), element] = minmax(var_minmax[i, nnodes(dg),
Expand Down
Loading

0 comments on commit 66476eb

Please sign in to comment.