Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/solvers/dgsem_structured/containers_1d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#! format: noindent

# Initialize data structures in element container
function init_elements!(elements, mesh::StructuredMesh{1}, basis::LobattoLegendreBasis)
function init_elements!(elements, mesh::StructuredMesh{1}, basis::AbstractBasisSBP)
@unpack node_coordinates, left_neighbors,
jacobian_matrix, contravariant_vectors, inverse_jacobian = elements

Expand All @@ -31,7 +31,7 @@ end
# `mesh.mapping` is passed as an additional argument for type stability (function barrier)
function calc_node_coordinates!(node_coordinates, cell_x, mapping,
mesh::StructuredMesh{1},
basis::LobattoLegendreBasis)
basis::AbstractBasisSBP)
@unpack nodes = basis

# Get cell length in reference mesh
Expand All @@ -51,7 +51,7 @@ end
# Calculate Jacobian matrix of the mapping from the reference element to the element in the physical domain
function calc_jacobian_matrix!(jacobian_matrix, element,
node_coordinates::AbstractArray{<:Any, 3},
basis::LobattoLegendreBasis)
basis::AbstractBasisSBP)
@views mul!(jacobian_matrix[1, 1, :, element], basis.derivative_matrix,
node_coordinates[1, :, element]) # x_ξ

Expand Down
26 changes: 26 additions & 0 deletions src/solvers/dgsem_structured/dg_1d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,32 @@ function prolong2interfaces!(cache, u, mesh::StructuredMesh{1}, equations, dg::D
return nothing
end

function prolong2interfaces!(cache, u, mesh::StructuredMesh{1}, equations,
dg::DGSEM{<:GaussLegendreBasis})
@unpack interfaces_u = cache.elements
@unpack boundary_interpolation = dg.basis

@threaded for element in eachelement(dg, cache)
for v in eachvariable(equations)
interface_u_1 = zero(eltype(interfaces_u))
interface_u_2 = zero(eltype(interfaces_u))
for i in eachnode(dg)
# Left/negative x face
interface_u_1 = interface_u_1 +
u[v, i, element] * boundary_interpolation[i, 1]

# Right/positive x face
interface_u_2 = interface_u_2 +
u[v, i, element] * boundary_interpolation[i, 2]
end
interfaces_u[v, 1, element] = interface_u_1
interfaces_u[v, 2, element] = interface_u_2
end
end

return nothing
end

function calc_interface_flux!(surface_flux_values, mesh::StructuredMesh{1},
nonconservative_terms, # can be True/False
equations, surface_integral, dg::DG, cache)
Expand Down
13 changes: 13 additions & 0 deletions test/test_structured_1d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ isdir(outdir) && rm(outdir, recursive = true)
@test_allocations(Trixi.rhs!, semi, sol, 1000)
end

@trixi_testset "elixir_advection_basic.jl (Gauss-Legendre)" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"),
solver=DGSEM(polydeg = 3, basis_type = GaussLegendreBasis,
surface_flux = flux_godunov),
cfl=0.8,
# Expected errors are exactly the same as with TreeMesh!
l2=[2.515203865524688e-6],
linf=[8.660338936650191e-6])
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
@test_allocations(Trixi.rhs!, semi, sol, 1000)
end

@trixi_testset "elixir_advection_nonperiodic.jl" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_nonperiodic.jl"),
l2=[5.641921365468918e-5],
Expand Down
Loading