Skip to content

Commit

Permalink
Fix nonperiodic bounds calculation; Adapt elixir and test
Browse files Browse the repository at this point in the history
  • Loading branch information
bennibolm committed Nov 16, 2023
1 parent 6162128 commit d708fd4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ equations = CompressibleEulerEquations2D(1.4)

initial_condition = initial_condition_constant

boundary_condition = BoundaryConditionDirichlet(initial_condition)
boundary_conditions = (x_neg = boundary_condition_periodic,
x_pos = boundary_condition_periodic,
y_neg = boundary_condition,
y_pos = boundary_condition)

surface_flux = flux_lax_friedrichs
volume_flux = flux_ranocha
polydeg = 3
Expand Down Expand Up @@ -45,9 +51,10 @@ function mapping(xi_, eta_)
end

cells_per_dimension = (16, 16)
mesh = StructuredMesh(cells_per_dimension, mapping, periodicity = true)
mesh = StructuredMesh(cells_per_dimension, mapping, periodicity = (true, false))

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
boundary_conditions = boundary_conditions)

###############################################################################
# ODE solvers, callbacks etc.
Expand Down
37 changes: 12 additions & 25 deletions src/solvers/dgsem_structured/subcell_limiters_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ function calc_bounds_twosided_interface!(var_min, var_max, variable, u, t, semi,
mesh::StructuredMesh{2})
_, equations, dg, cache = mesh_equations_solver_cache(semi)
(; boundary_conditions) = semi
(; contravariant_vectors) = cache.elements

# Calc bounds at interfaces and periodic boundaries
for element in eachelement(dg, cache)
Expand Down Expand Up @@ -57,11 +56,9 @@ function calc_bounds_twosided_interface!(var_min, var_max, variable, u, t, semi,
for cell_y in axes(mesh, 2)
element = linear_indices[begin, cell_y]
for j in eachnode(dg)
Ja1 = get_contravariant_vector(1, contravariant_vectors, 1, j, element)
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)
u_outer = get_boundary_outer_state(boundary_conditions[1],
cache, t, 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 @@ -72,13 +69,9 @@ function calc_bounds_twosided_interface!(var_min, var_max, variable, u, t, semi,
for cell_y in axes(mesh, 2)
element = linear_indices[end, cell_y]
for j in eachnode(dg)
Ja1 = get_contravariant_vector(1, contravariant_vectors, nnodes(dg), j,
element)
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)
u_outer = get_boundary_outer_state(boundary_conditions[2],
cache, t, 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 @@ -93,11 +86,9 @@ function calc_bounds_twosided_interface!(var_min, var_max, variable, u, t, semi,
for cell_x in axes(mesh, 1)
element = linear_indices[cell_x, begin]
for i in eachnode(dg)
Ja2 = get_contravariant_vector(2, contravariant_vectors, i, 1, element)
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)
u_outer = get_boundary_outer_state(boundary_conditions[3],
cache, t, 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 @@ -108,13 +99,9 @@ function calc_bounds_twosided_interface!(var_min, var_max, variable, u, t, semi,
for cell_x in axes(mesh, 1)
element = linear_indices[cell_x, end]
for i in eachnode(dg)
Ja2 = get_contravariant_vector(2, contravariant_vectors, i, nnodes(dg),
element)
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)
u_outer = get_boundary_outer_state(boundary_conditions[4],
cache, t, 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
16 changes: 8 additions & 8 deletions test/test_structured_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -452,16 +452,16 @@ end
@test_trixi_include(joinpath(EXAMPLES_DIR,
"elixir_euler_free_stream_sc_subcell.jl"),
l2=[
9.032004415047197e-17,
7.468471908193906e-16,
6.518326029493845e-16,
1.753322836364184e-15,
8.679465418313328e-17,
7.45128559275597e-16,
6.526610493700283e-16,
1.6923968530609196e-15,
],
linf=[
1.1102230246251565e-15,
8.81239525796218e-15,
1.04638520070921e-14,
1.5987211554602254e-14,
8.881784197001252e-16,
9.478529072737274e-15,
7.188694084447889e-15,
1.4210854715202004e-14,
],
atol=1.0e-13,
cells_per_dimension=(8, 8))
Expand Down

0 comments on commit d708fd4

Please sign in to comment.