From 60d5c32f0376b2a1678589c1c9c4732ae1392098 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Rueda-Ram=C3=ADrez?= Date: Fri, 6 Dec 2024 17:26:07 +0100 Subject: [PATCH 1/2] Use `get_node_vars` for divB analysis rutines (#2193) * Use get_node_vars for divB analysis rutines of TreeMesh{3} * Use get_node_vars for divB analysis rutines of remaining mesh types --- src/callbacks_step/analysis_dg2d.jl | 28 ++++++++++++++------ src/callbacks_step/analysis_dg3d.jl | 40 ++++++++++++++++++++--------- 2 files changed, 48 insertions(+), 20 deletions(-) diff --git a/src/callbacks_step/analysis_dg2d.jl b/src/callbacks_step/analysis_dg2d.jl index e33533738ec..628c3071cbc 100644 --- a/src/callbacks_step/analysis_dg2d.jl +++ b/src/callbacks_step/analysis_dg2d.jl @@ -286,8 +286,11 @@ function analyze(::Val{:l2_divb}, du, u, t, dg, cache, derivative_matrix divb = zero(eltype(u)) for k in eachnode(dg) - B1_kj, _, _ = magnetic_field(u[:, k, j, element], equations) - _, B2_ik, _ = magnetic_field(u[:, i, k, element], equations) + u_kj = get_node_vars(u, equations, dg, k, j, element) + u_ik = get_node_vars(u, equations, dg, i, k, element) + + B1_kj, _, _ = magnetic_field(u_kj, equations) + _, B2_ik, _ = magnetic_field(u_ik, equations) divb += (derivative_matrix[i, k] * B1_kj + derivative_matrix[j, k] * B2_ik) @@ -311,8 +314,11 @@ function analyze(::Val{:l2_divb}, du, u, t, Ja21, Ja22 = get_contravariant_vector(2, contravariant_vectors, i, j, element) # Compute the transformed divergence for k in eachnode(dg) - B1_kj, B2_kj, _ = magnetic_field(u[:, k, j, element], equations) - B1_ik, B2_ik, _ = magnetic_field(u[:, i, k, element], equations) + u_kj = get_node_vars(u, equations, dg, k, j, element) + u_ik = get_node_vars(u, equations, dg, i, k, element) + + B1_kj, B2_kj, _ = magnetic_field(u_kj, equations) + B1_ik, B2_ik, _ = magnetic_field(u_ik, equations) divb += (derivative_matrix[i, k] * (Ja11 * B1_kj + Ja12 * B2_kj) + @@ -335,8 +341,11 @@ function analyze(::Val{:linf_divb}, du, u, t, for j in eachnode(dg), i in eachnode(dg) divb = zero(eltype(u)) for k in eachnode(dg) - B1_kj, _, _ = magnetic_field(u[:, k, j, element], equations) - _, B2_ik, _ = magnetic_field(u[:, i, k, element], equations) + u_kj = get_node_vars(u, equations, dg, k, j, element) + u_ik = get_node_vars(u, equations, dg, i, k, element) + + B1_kj, _, _ = magnetic_field(u_kj, equations) + _, B2_ik, _ = magnetic_field(u_ik, equations) divb += (derivative_matrix[i, k] * B1_kj + derivative_matrix[j, k] * B2_ik) @@ -368,8 +377,11 @@ function analyze(::Val{:linf_divb}, du, u, t, element) # Compute the transformed divergence for k in eachnode(dg) - B1_kj, B2_kj, _ = magnetic_field(u[:, k, j, element], equations) - B1_ik, B2_ik, _ = magnetic_field(u[:, i, k, element], equations) + u_kj = get_node_vars(u, equations, dg, k, j, element) + u_ik = get_node_vars(u, equations, dg, i, k, element) + + B1_kj, B2_kj, _ = magnetic_field(u_kj, equations) + B1_ik, B2_ik, _ = magnetic_field(u_ik, equations) divb += (derivative_matrix[i, k] * (Ja11 * B1_kj + Ja12 * B2_kj) + diff --git a/src/callbacks_step/analysis_dg3d.jl b/src/callbacks_step/analysis_dg3d.jl index efc1dc3bb3c..dfd5696b5fb 100644 --- a/src/callbacks_step/analysis_dg3d.jl +++ b/src/callbacks_step/analysis_dg3d.jl @@ -315,9 +315,13 @@ function analyze(::Val{:l2_divb}, du, u, t, dg, cache, derivative_matrix divb = zero(eltype(u)) for l in eachnode(dg) - B_ljk = magnetic_field(u[:, l, j, k, element], equations) - B_ilk = magnetic_field(u[:, i, l, k, element], equations) - B_ijl = magnetic_field(u[:, i, j, l, element], equations) + u_ljk = get_node_vars(u, equations, dg, l, j, k, element) + u_ilk = get_node_vars(u, equations, dg, i, l, k, element) + u_ijl = get_node_vars(u, equations, dg, i, j, l, element) + + B_ljk = magnetic_field(u_ljk, equations) + B_ilk = magnetic_field(u_ilk, equations) + B_ijl = magnetic_field(u_ijl, equations) divb += (derivative_matrix[i, l] * B_ljk[1] + derivative_matrix[j, l] * B_ilk[2] + @@ -346,9 +350,13 @@ function analyze(::Val{:l2_divb}, du, u, t, element) # Compute the transformed divergence for l in eachnode(dg) - B_ljk = magnetic_field(u[:, l, j, k, element], equations) - B_ilk = magnetic_field(u[:, i, l, k, element], equations) - B_ijl = magnetic_field(u[:, i, j, l, element], equations) + u_ljk = get_node_vars(u, equations, dg, l, j, k, element) + u_ilk = get_node_vars(u, equations, dg, i, l, k, element) + u_ijl = get_node_vars(u, equations, dg, i, j, l, element) + + B_ljk = magnetic_field(u_ljk, equations) + B_ilk = magnetic_field(u_ilk, equations) + B_ijl = magnetic_field(u_ijl, equations) divb += (derivative_matrix[i, l] * (Ja11 * B_ljk[1] + Ja12 * B_ljk[2] + Ja13 * B_ljk[3]) + @@ -373,9 +381,13 @@ function analyze(::Val{:linf_divb}, du, u, t, for k in eachnode(dg), j in eachnode(dg), i in eachnode(dg) divb = zero(eltype(u)) for l in eachnode(dg) - B_ljk = magnetic_field(u[:, l, j, k, element], equations) - B_ilk = magnetic_field(u[:, i, l, k, element], equations) - B_ijl = magnetic_field(u[:, i, j, l, element], equations) + u_ljk = get_node_vars(u, equations, dg, l, j, k, element) + u_ilk = get_node_vars(u, equations, dg, i, l, k, element) + u_ijl = get_node_vars(u, equations, dg, i, j, l, element) + + B_ljk = magnetic_field(u_ljk, equations) + B_ilk = magnetic_field(u_ilk, equations) + B_ijl = magnetic_field(u_ijl, equations) divb += (derivative_matrix[i, l] * B_ljk[1] + derivative_matrix[j, l] * B_ilk[2] + @@ -415,9 +427,13 @@ function analyze(::Val{:linf_divb}, du, u, t, k, element) # Compute the transformed divergence for l in eachnode(dg) - B_ljk = magnetic_field(u[:, l, j, k, element], equations) - B_ilk = magnetic_field(u[:, i, l, k, element], equations) - B_ijl = magnetic_field(u[:, i, j, l, element], equations) + u_ljk = get_node_vars(u, equations, dg, l, j, k, element) + u_ilk = get_node_vars(u, equations, dg, i, l, k, element) + u_ijl = get_node_vars(u, equations, dg, i, j, l, element) + + B_ljk = magnetic_field(u_ljk, equations) + B_ilk = magnetic_field(u_ilk, equations) + B_ijl = magnetic_field(u_ijl, equations) divb += (derivative_matrix[i, l] * (Ja11 * B_ljk[1] + Ja12 * B_ljk[2] + Ja13 * B_ljk[3]) + From 986b019c3f6ebaa06fa52de25712bb89eae5c89e Mon Sep 17 00:00:00 2001 From: Daniel Doehring Date: Tue, 10 Dec 2024 12:20:46 +0100 Subject: [PATCH 2/2] Update elixir_advection_diffusion_nonperiodic_curved.jl (#2192) --- .../elixir_advection_diffusion_nonperiodic_curved.jl | 3 --- 1 file changed, 3 deletions(-) diff --git a/examples/p4est_2d_dgsem/elixir_advection_diffusion_nonperiodic_curved.jl b/examples/p4est_2d_dgsem/elixir_advection_diffusion_nonperiodic_curved.jl index 0e5f90d192f..b3b0bf962b5 100644 --- a/examples/p4est_2d_dgsem/elixir_advection_diffusion_nonperiodic_curved.jl +++ b/examples/p4est_2d_dgsem/elixir_advection_diffusion_nonperiodic_curved.jl @@ -41,9 +41,6 @@ boundary_conditions_parabolic = Dict(:x_neg => BoundaryConditionDirichlet(initia # Create DG solver with polynomial degree = 3 and (local) Lax-Friedrichs/Rusanov flux as surface flux solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) -coordinates_min = (-1.0, -0.5) -coordinates_max = (0.0, 0.5) - # This maps the domain [-1, 1]^2 to [-1, 0] x [-0.5, 0.5] while also # introducing a curved warping to interior nodes. function mapping(xi, eta)