Skip to content

Commit

Permalink
Use get_node_vars for divB analysis rutines of remaining mesh types
Browse files Browse the repository at this point in the history
  • Loading branch information
amrueda committed Dec 6, 2024
1 parent f14f0a3 commit c8945e8
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 14 deletions.
28 changes: 20 additions & 8 deletions src/callbacks_step/analysis_dg2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,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)
Expand All @@ -310,8 +313,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) +
Expand All @@ -334,8 +340,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)
Expand Down Expand Up @@ -367,8 +376,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) +
Expand Down
20 changes: 14 additions & 6 deletions src/callbacks_step/analysis_dg3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,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]) +
Expand Down Expand Up @@ -422,9 +426,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]) +
Expand Down

0 comments on commit c8945e8

Please sign in to comment.