diff --git a/src/equations/equations.jl b/src/equations/equations.jl index 2faec6892d5..63041e103a6 100644 --- a/src/equations/equations.jl +++ b/src/equations/equations.jl @@ -239,11 +239,10 @@ The return value will be `True()` or `False()` to allow dispatching on the retur """ have_nonconservative_terms(::AbstractEquations) = False() """ - nnoncons(equations) -Number of nonconservative terms for a particular equation. The default is 0 and -it must be defined for each nonconservative equation independently. + n_nonconservative_terms(equations) +Number of nonconservative terms in the form local * symmetric for a particular equation. """ -nnoncons(::AbstractEquations) = 0 +function n_nonconservative_terms(::AbstractEquations) end have_constant_speed(::AbstractEquations) = False() default_analysis_errors(::AbstractEquations) = (:l2_error, :linf_error) diff --git a/src/equations/ideal_glm_mhd_2d.jl b/src/equations/ideal_glm_mhd_2d.jl index 54a6c17b9d8..9e0f9357420 100644 --- a/src/equations/ideal_glm_mhd_2d.jl +++ b/src/equations/ideal_glm_mhd_2d.jl @@ -29,7 +29,7 @@ function IdealGlmMhdEquations2D(gamma; initial_c_h = convert(typeof(gamma), NaN) end have_nonconservative_terms(::IdealGlmMhdEquations2D) = True() -nnoncons(::IdealGlmMhdEquations2D) = 2 +n_nonconservative_terms(::IdealGlmMhdEquations2D) = 2 function varnames(::typeof(cons2cons), ::IdealGlmMhdEquations2D) ("rho", "rho_v1", "rho_v2", "rho_v3", "rho_e", "B1", "B2", "B3", "psi") diff --git a/src/solvers/dgsem_tree/dg_2d_subcell_limiters.jl b/src/solvers/dgsem_tree/dg_2d_subcell_limiters.jl index 1d7e4f1f326..18b2f2097dc 100644 --- a/src/solvers/dgsem_tree/dg_2d_subcell_limiters.jl +++ b/src/solvers/dgsem_tree/dg_2d_subcell_limiters.jl @@ -27,19 +27,19 @@ function create_cache(mesh::TreeMesh{2}, equations, flux_temp_threaded = A3d[A3d(undef, nvariables(equations), nnodes(dg), nnodes(dg)) for _ in 1:Threads.nthreads()] flux_nonconservative_temp_threaded = A4d[A4d(undef, nvariables(equations), - nnoncons(equations), + n_nonconservative_terms(equations), nnodes(dg), nnodes(dg)) for _ in 1:Threads.nthreads()] fhat_temp_threaded = A3d[A3d(undef, nvariables(equations), nnodes(dg), nnodes(dg)) for _ in 1:Threads.nthreads()] fhat_nonconservative_temp_threaded = A4d[A4d(undef, nvariables(equations), - nnoncons(equations), + n_nonconservative_terms(equations), nnodes(dg), nnodes(dg)) for _ in 1:Threads.nthreads()] phi_threaded = A4d[A4d(undef, nvariables(equations), - nnoncons(equations), + n_nonconservative_terms(equations), nnodes(dg), nnodes(dg)) for _ in 1:Threads.nthreads()] @@ -253,7 +253,7 @@ end equations, dg, i, j) multiply_add_to_node_vars!(flux_temp, derivative_split[ii, i], flux1, equations, dg, ii, j) - for noncons in 1:nnoncons(equations) + for noncons in 1:n_nonconservative_terms(equations) # We multiply by 0.5 because that is done in other parts of Trixi flux1_noncons = volume_flux_noncons(u_node, u_node_ii, 1, equations, NonConservativeSymmetric(), noncons) @@ -281,7 +281,7 @@ end # Compute local contribution to non-conservative flux for j in eachnode(dg), i in eachnode(dg) u_local = get_node_vars(u, equations, dg, i, j, element) - for noncons in 1:nnoncons(equations) + for noncons in 1:n_nonconservative_terms(equations) set_node_vars!(phi, volume_flux_noncons(u_local, 1, equations, NonConservativeLocal(), noncons), @@ -298,7 +298,7 @@ end fhat1_R[v, i + 1, j] = value end # Nonconservative part - for noncons in 1:nnoncons(equations), v in eachvariable(equations) + for noncons in 1:n_nonconservative_terms(equations), v in eachvariable(equations) value = fhat_noncons_temp[v, noncons, i, j] + weights[i] * flux_noncons_temp[v, noncons, i, j] fhat_noncons_temp[v, noncons, i + 1, j] = value @@ -322,7 +322,7 @@ end equations, dg, i, j) multiply_add_to_node_vars!(flux_temp, derivative_split[jj, j], flux2, equations, dg, i, jj) - for noncons in 1:nnoncons(equations) + for noncons in 1:n_nonconservative_terms(equations) # We multiply by 0.5 because that is done in other parts of Trixi flux2_noncons = volume_flux_noncons(u_node, u_node_jj, 2, equations, NonConservativeSymmetric(), noncons) @@ -350,7 +350,7 @@ end # Compute local contribution to non-conservative flux for j in eachnode(dg), i in eachnode(dg) u_local = get_node_vars(u, equations, dg, i, j, element) - for noncons in 1:nnoncons(equations) + for noncons in 1:n_nonconservative_terms(equations) set_node_vars!(phi, volume_flux_noncons(u_local, 2, equations, NonConservativeLocal(), noncons), @@ -367,7 +367,7 @@ end fhat2_R[v, i, j + 1] = value end # Nonconservative part - for noncons in 1:nnoncons(equations), v in eachvariable(equations) + for noncons in 1:n_nonconservative_terms(equations), v in eachvariable(equations) value = fhat_noncons_temp[v, noncons, i, j] + weights[j] * flux_noncons_temp[v, noncons, i, j] fhat_noncons_temp[v, noncons, i, j + 1] = value