Skip to content

Commit

Permalink
Relocate checks and goal functions
Browse files Browse the repository at this point in the history
  • Loading branch information
bennibolm committed Oct 12, 2023
1 parent 2eac4cf commit 651b716
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions src/solvers/dgsem_tree/subcell_limiters_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,6 @@ end
return nothing
end

function initial_check_entropy_spec(bound, goal, newton_abstol)
goal <= max(newton_abstol, abs(bound) * newton_abstol)
end

@inline function idp_math_entropy!(alpha, limiter, u, t, dt, semi, elements)
mesh, equations, dg, cache = mesh_equations_solver_cache(semi)
(; variable_bounds) = limiter.cache.subcell_limiter_coefficients
Expand All @@ -443,10 +439,6 @@ end
return nothing
end

function initial_check_entropy_math(bound, goal, newton_abstol)
goal >= -max(newton_abstol, abs(bound) * newton_abstol)
end

@inline function idp_positivity!(alpha, limiter, u, dt, semi, elements)
# Conservative variables
for variable in limiter.positivity_variables_cons
Expand Down Expand Up @@ -555,16 +547,6 @@ end
return nothing
end

goal_function(variable, bound, u, equations) = bound - variable(u, equations)
function dgoal_function(variable, u, dt, antidiffusive_flux, equations)
-dot(variable(u, equations, True()), dt * antidiffusive_flux)
end

initial_check_nonnegative(bound, goal, newton_abstol) = goal <= 0
function final_check_nonnegative(bound, goal, newton_abstol)
(goal <= eps()) && (goal > -max(newton_abstol, abs(bound) * newton_abstol))
end

@inline function newton_loops_alpha!(alpha, bound, u, i, j, element, variable,
initial_check, final_check, dt, mesh, equations,
dg, cache, limiter)
Expand Down Expand Up @@ -703,6 +685,27 @@ end
return nothing
end

# Initial checks
function initial_check_entropy_spec(bound, goal, newton_abstol)
goal <= max(newton_abstol, abs(bound) * newton_abstol)
end

function initial_check_entropy_math(bound, goal, newton_abstol)
goal >= -max(newton_abstol, abs(bound) * newton_abstol)
end

initial_check_nonnegative(bound, goal, newton_abstol) = goal <= 0
function final_check_nonnegative(bound, goal, newton_abstol)
(goal <= eps()) && (goal > -max(newton_abstol, abs(bound) * newton_abstol))
end

# Goal and d(Goal)d(u) function
goal_function(variable, bound, u, equations) = bound - variable(u, equations)
function dgoal_function(variable, u, dt, antidiffusive_flux, equations)
-dot(variable(u, equations, True()), dt * antidiffusive_flux)
end

# Final check
function final_check_standard(bound, goal, newton_abstol)
abs(goal) < max(newton_abstol, abs(bound) * newton_abstol)
end
Expand Down

0 comments on commit 651b716

Please sign in to comment.