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

fix bug in apply_jacobian_parabolic! for P4estMesh #1668

Merged
merged 6 commits into from
Oct 11, 2023
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
20 changes: 19 additions & 1 deletion src/solvers/dgsem_tree/dg_2d_parabolic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ end
# This is because the parabolic fluxes are assumed to be of the form
# `du/dt + df/dx = dg/dx + source(x,t)`,
# where f(u) is the inviscid flux and g(u) is the viscous flux.
function apply_jacobian_parabolic!(du, mesh::Union{TreeMesh{2}, P4estMesh{2}},
function apply_jacobian_parabolic!(du, mesh::TreeMesh{2},
equations::AbstractEquationsParabolic, dg::DG, cache)
@unpack inverse_jacobian = cache.elements

Expand All @@ -951,4 +951,22 @@ function apply_jacobian_parabolic!(du, mesh::Union{TreeMesh{2}, P4estMesh{2}},

return nothing
end

function apply_jacobian_parabolic!(du, mesh::P4estMesh{2},
equations::AbstractEquationsParabolic,
dg::DG, cache)
@unpack inverse_jacobian = cache.elements

@threaded for element in eachelement(dg, cache)
for j in eachnode(dg), i in eachnode(dg)
factor = inverse_jacobian[i, j, element]

for v in eachvariable(equations)
du[v, i, j, element] *= factor
end
end
end

return nothing
end
end # @muladd
23 changes: 21 additions & 2 deletions src/solvers/dgsem_tree/dg_3d_parabolic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1125,8 +1125,9 @@ end
# This is because the parabolic fluxes are assumed to be of the form
# `du/dt + df/dx = dg/dx + source(x,t)`,
# where f(u) is the inviscid flux and g(u) is the viscous flux.
function apply_jacobian_parabolic!(du, mesh::Union{TreeMesh{3}, P4estMesh{3}},
equations::AbstractEquationsParabolic, dg::DG, cache)
function apply_jacobian_parabolic!(du, mesh::TreeMesh{3},
equations::AbstractEquationsParabolic,
dg::DG, cache)
@unpack inverse_jacobian = cache.elements

@threaded for element in eachelement(dg, cache)
Expand All @@ -1141,4 +1142,22 @@ function apply_jacobian_parabolic!(du, mesh::Union{TreeMesh{3}, P4estMesh{3}},

return nothing
end

function apply_jacobian_parabolic!(du, mesh::P4estMesh{3},
equations::AbstractEquationsParabolic,
dg::DG, cache)
@unpack inverse_jacobian = cache.elements

@threaded for element in eachelement(dg, cache)
for k in eachnode(dg), j in eachnode(dg), i in eachnode(dg)
factor = inverse_jacobian[i, j, k, element]

for v in eachvariable(equations)
du[v, i, j, k, element] *= factor
end
end
end

return nothing
end
end # @muladd
16 changes: 4 additions & 12 deletions test/test_parabolic_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -260,24 +260,16 @@ isdir(outdir) && rm(outdir, recursive=true)
@trixi_testset "P4estMesh2D: elixir_advection_diffusion_periodic_curved.jl" begin
@test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem", "elixir_advection_diffusion_periodic_curved.jl"),
trees_per_dimension = (1, 1), initial_refinement_level = 2, tspan=(0.0, 0.5),
l2 = [0.012380458938507371],
linf = [0.10860506906472567]
)
end

@trixi_testset "P4estMesh2D: elixir_advection_diffusion_periodic_curved.jl" begin
@test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem", "elixir_advection_diffusion_periodic_curved.jl"),
trees_per_dimension = (1, 1), initial_refinement_level = 2, tspan=(0.0, 0.5),
l2 = [0.012380458938507371],
linf = [0.10860506906472567]
l2 = [0.006708147442490916],
linf = [0.04807038397976693]
)
end

@trixi_testset "P4estMesh2D: elixir_advection_diffusion_nonperiodic_curved.jl" begin
@test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem", "elixir_advection_diffusion_nonperiodic_curved.jl"),
trees_per_dimension = (1, 1), initial_refinement_level = 2, tspan=(0.0, 0.5),
l2 = [0.04933902988507035],
linf = [0.2550261714590271]
l2 = [0.00919917034843865],
linf = [0.14186297438393505]
)
end

Expand Down
Loading