Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid allocations in boundary flux for parabolic RHS #1594

Merged
merged 9 commits into from
Aug 8, 2023
5 changes: 4 additions & 1 deletion examples/tree_2d_dgsem/elixir_navierstokes_convergence.jl
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,10 @@ end
initial_condition = initial_condition_navier_stokes_convergence_test

# BC types
velocity_bc_top_bottom = NoSlip((x, t, equations) -> initial_condition_navier_stokes_convergence_test(x, t, equations)[2:3])
velocity_bc_top_bottom = NoSlip() do x, t, equations
u = initial_condition_navier_stokes_convergence_test(x, t, equations)
return SVector(u[2], u[3])
end
heat_bc_top_bottom = Adiabatic((x, t, equations) -> 0.0)
boundary_condition_top_bottom = BoundaryConditionNavierStokesWall(velocity_bc_top_bottom, heat_bc_top_bottom)

Expand Down
6 changes: 4 additions & 2 deletions examples/tree_2d_dgsem/elixir_navierstokes_shear_layer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ equations_parabolic = CompressibleNavierStokesDiffusion2D(equations, mu=mu(),
Prandtl=prandtl_number())

function initial_condition_shear_layer(x, t, equations::CompressibleEulerEquations2D)
# Shear layer parameters
k = 80
delta = 0.05
u0 = 1.0

Ms = 0.1 # maximum Mach number

rho = 1.0
v1 = x[2] <= 0.5 ? u0*tanh(k*(x[2]*0.5 - 0.25)) : tanh(k*(0.75 -x[2]*0.5))
v2 = u0*delta * sin(2*pi*(x[1]*0.5 + 0.25))
v1 = x[2] <= 0.5 ? u0 * tanh(k*(x[2]*0.5 - 0.25)) : u0 * tanh(k*(0.75 -x[2]*0.5))
jlchan marked this conversation as resolved.
Show resolved Hide resolved
v2 = u0 * delta * sin(2*pi*(x[1]*0.5 + 0.25))
p = (u0 / Ms)^2 * rho / equations.gamma # scaling to get Ms

return prim2cons(SVector(rho, v1, v2, p), equations)
Expand Down
5 changes: 4 additions & 1 deletion examples/tree_3d_dgsem/elixir_navierstokes_convergence.jl
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,10 @@ end
initial_condition = initial_condition_navier_stokes_convergence_test

# BC types
velocity_bc_top_bottom = NoSlip((x, t, equations) -> initial_condition_navier_stokes_convergence_test(x, t, equations)[2:4])
velocity_bc_top_bottom = NoSlip() do x, t, equations
u = initial_condition_navier_stokes_convergence_test(x, t, equations)
return SVector(u[2], u[3], u[4])
end
heat_bc_top_bottom = Adiabatic((x, t, equations) -> 0.0)
boundary_condition_top_bottom = BoundaryConditionNavierStokesWall(velocity_bc_top_bottom, heat_bc_top_bottom)

Expand Down
6 changes: 3 additions & 3 deletions src/solvers/dgsem_tree/containers_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -764,10 +764,10 @@ end

# Container data structure (structure-of-arrays style) for DG MPI interfaces
mutable struct MPIInterfaceContainer2D{uEltype <: Real} <: AbstractContainer
u::Array{uEltype, 4} # [leftright, variables, i, interfaces]
u::Array{uEltype, 4} # [leftright, variables, i, interfaces]
local_neighbor_ids::Vector{Int} # [interfaces]
orientations::Vector{Int} # [interfaces]
remote_sides::Vector{Int} # [interfaces]
orientations::Vector{Int} # [interfaces]
remote_sides::Vector{Int} # [interfaces]
# internal `resize!`able storage
_u::Vector{uEltype}
end
Expand Down
8 changes: 4 additions & 4 deletions src/solvers/dgsem_tree/containers_3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -520,14 +520,14 @@ end
# Left and right are used *both* for the numbering of the mortar faces *and* for the position of the
# elements with respect to the axis orthogonal to the mortar.
mutable struct L2MortarContainer3D{uEltype <: Real} <: AbstractContainer
u_upper_left::Array{uEltype, 5} # [leftright, variables, i, j, mortars]
u_upper_left::Array{uEltype, 5} # [leftright, variables, i, j, mortars]
u_upper_right::Array{uEltype, 5} # [leftright, variables, i, j, mortars]
u_lower_left::Array{uEltype, 5} # [leftright, variables, i, j, mortars]
u_lower_left::Array{uEltype, 5} # [leftright, variables, i, j, mortars]
u_lower_right::Array{uEltype, 5} # [leftright, variables, i, j, mortars]
neighbor_ids::Array{Int, 2} # [position, mortars]
neighbor_ids::Array{Int, 2} # [position, mortars]
# Large sides: left -> 1, right -> 2
large_sides::Vector{Int} # [mortars]
orientations::Vector{Int} # [mortars]
orientations::Vector{Int} # [mortars]
# internal `resize!`able storage
_u_upper_left::Vector{uEltype}
_u_upper_right::Vector{uEltype}
Expand Down
Loading