From 2f2ec263fb74918d96a4765540366aef3e88a5b4 Mon Sep 17 00:00:00 2001 From: Jesse Chan Date: Mon, 9 Oct 2023 23:06:51 -0400 Subject: [PATCH 1/3] fix bug in parabolic jacobian computations --- src/solvers/dgsem_tree/dg_2d_parabolic.jl | 22 +++++++++++++++++++- src/solvers/dgsem_tree/dg_3d_parabolic.jl | 25 +++++++++++++++++++++-- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/src/solvers/dgsem_tree/dg_2d_parabolic.jl b/src/solvers/dgsem_tree/dg_2d_parabolic.jl index 3dbc55412ad..5e92202dc59 100644 --- a/src/solvers/dgsem_tree/dg_2d_parabolic.jl +++ b/src/solvers/dgsem_tree/dg_2d_parabolic.jl @@ -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 @@ -951,4 +951,24 @@ 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 diff --git a/src/solvers/dgsem_tree/dg_3d_parabolic.jl b/src/solvers/dgsem_tree/dg_3d_parabolic.jl index 9817e0e5f0e..c6f19b6b27f 100644 --- a/src/solvers/dgsem_tree/dg_3d_parabolic.jl +++ b/src/solvers/dgsem_tree/dg_3d_parabolic.jl @@ -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) @@ -1141,4 +1142,24 @@ 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 From 95c235bfde1626878785cd3147f1c8b3a5bfc018 Mon Sep 17 00:00:00 2001 From: Jesse Chan Date: Mon, 9 Oct 2023 23:36:44 -0400 Subject: [PATCH 2/3] formatting --- src/solvers/dgsem_tree/dg_2d_parabolic.jl | 4 +--- src/solvers/dgsem_tree/dg_3d_parabolic.jl | 6 ++---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/solvers/dgsem_tree/dg_2d_parabolic.jl b/src/solvers/dgsem_tree/dg_2d_parabolic.jl index 5e92202dc59..1c32703c7c3 100644 --- a/src/solvers/dgsem_tree/dg_2d_parabolic.jl +++ b/src/solvers/dgsem_tree/dg_2d_parabolic.jl @@ -953,13 +953,12 @@ function apply_jacobian_parabolic!(du, mesh::TreeMesh{2}, end function apply_jacobian_parabolic!(du, mesh::P4estMesh{2}, - equations::AbstractEquationsParabolic, + 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) @@ -970,5 +969,4 @@ function apply_jacobian_parabolic!(du, mesh::P4estMesh{2}, return nothing end - end # @muladd diff --git a/src/solvers/dgsem_tree/dg_3d_parabolic.jl b/src/solvers/dgsem_tree/dg_3d_parabolic.jl index c6f19b6b27f..37492dbcb91 100644 --- a/src/solvers/dgsem_tree/dg_3d_parabolic.jl +++ b/src/solvers/dgsem_tree/dg_3d_parabolic.jl @@ -1126,7 +1126,7 @@ end # `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::TreeMesh{3}, - equations::AbstractEquationsParabolic, + equations::AbstractEquationsParabolic, dg::DG, cache) @unpack inverse_jacobian = cache.elements @@ -1144,13 +1144,12 @@ function apply_jacobian_parabolic!(du, mesh::TreeMesh{3}, end function apply_jacobian_parabolic!(du, mesh::P4estMesh{3}, - equations::AbstractEquationsParabolic, + 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) @@ -1161,5 +1160,4 @@ function apply_jacobian_parabolic!(du, mesh::P4estMesh{3}, return nothing end - end # @muladd From 854badf7f18014431d4b2370c4efdcb45dbbc8ac Mon Sep 17 00:00:00 2001 From: Jesse Chan Date: Tue, 10 Oct 2023 09:36:17 -0400 Subject: [PATCH 3/3] updating test results and removing duplicate test --- test/test_parabolic_2d.jl | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/test/test_parabolic_2d.jl b/test/test_parabolic_2d.jl index 3fff4382cd1..6498f1891ea 100644 --- a/test/test_parabolic_2d.jl +++ b/test/test_parabolic_2d.jl @@ -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