Skip to content

Commit

Permalink
Implement suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
bennibolm committed Aug 18, 2023
1 parent 2b88d61 commit 0fca290
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ for human readability.
- Non-uniform `TreeMesh` available for hyperbolic-parabolic equations.
- Capability to set truly discontinuous initial conditions in 1D.
- Wetting and drying feature and examples for 1D and 2D shallow water equations
- Subcell positivity limiting support for conservative variables in 2D for `TreeMesh`

#### Changed

Expand Down
4 changes: 2 additions & 2 deletions src/callbacks_stage/subcell_limiter_idp_correction_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

function perform_idp_correction!(u, dt, mesh::TreeMesh2D, equations, dg, cache)
@unpack inverse_weights = dg.basis
@unpack antidiffusive_flux1, antidiffusive_flux2 = cache.container_antidiffusive_flux
@unpack alpha1, alpha2 = dg.volume_integral.limiter.cache.container_subcell_limiter
@unpack antidiffusive_flux1, antidiffusive_flux2 = cache.antidiffusive_fluxes
@unpack alpha1, alpha2 = dg.volume_integral.limiter.cache.subcell_limiter_coefficients

@threaded for element in eachelement(dg, cache)
# Sign switch as in apply_jacobian!
Expand Down
10 changes: 5 additions & 5 deletions src/solvers/dgsem_tree/dg_2d_subcell_limiters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ function create_cache(mesh::TreeMesh{2}, equations,
flux_temp_threaded = A3d[A3d(undef, nvariables(equations), nnodes(dg), nnodes(dg))
for _ in 1:Threads.nthreads()]

container_antidiffusive_flux = Trixi.ContainerAntidiffusiveFlux2D{uEltype}(0,
nvariables(equations),
nnodes(dg))
antidiffusive_fluxes = Trixi.ContainerAntidiffusiveFlux2D{uEltype}(0,
nvariables(equations),
nnodes(dg))

return (; cache..., container_antidiffusive_flux, fhat1_threaded, fhat2_threaded,
return (; cache..., antidiffusive_fluxes, fhat1_threaded, fhat2_threaded,
flux_temp_threaded)
end

Expand Down Expand Up @@ -169,7 +169,7 @@ end
@inline function calcflux_antidiffusive!(fhat1, fhat2, fstar1, fstar2, u, mesh,
nonconservative_terms, equations,
limiter::SubcellLimiterIDP, dg, element, cache)
@unpack antidiffusive_flux1, antidiffusive_flux2 = cache.container_antidiffusive_flux
@unpack antidiffusive_flux1, antidiffusive_flux2 = cache.antidiffusive_fluxes

for j in eachnode(dg), i in 2:nnodes(dg)
for v in eachvariable(equations)
Expand Down
18 changes: 9 additions & 9 deletions src/solvers/dgsem_tree/subcell_limiters_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@
function create_cache(indicator::Type{SubcellLimiterIDP},
equations::AbstractEquations{2},
basis::LobattoLegendreBasis, number_bounds)
container_subcell_limiter = Trixi.ContainerSubcellLimiterIDP2D{real(basis)
}(0,
nnodes(basis),
number_bounds)
subcell_limiter_coefficients = Trixi.ContainerSubcellLimiterIDP2D{real(basis)
}(0,
nnodes(basis),
number_bounds)

cache = (; container_subcell_limiter)
cache = (; subcell_limiter_coefficients)

return cache
end

function (limiter::SubcellLimiterIDP)(u::AbstractArray{<:Any, 4}, semi, dg::DGSEM, t,
dt;
kwargs...)
@unpack alpha = limiter.cache.container_subcell_limiter
@unpack alpha = limiter.cache.subcell_limiter_coefficients
alpha .= zero(eltype(alpha))

if limiter.positivity
Expand All @@ -31,7 +31,7 @@ function (limiter::SubcellLimiterIDP)(u::AbstractArray{<:Any, 4}, semi, dg::DGSE
end

# Calculate alpha1 and alpha2
@unpack alpha1, alpha2 = limiter.cache.container_subcell_limiter
@unpack alpha1, alpha2 = limiter.cache.subcell_limiter_coefficients
@threaded for element in eachelement(dg, semi.cache)
for j in eachnode(dg), i in 2:nnodes(dg)
alpha1[i, j, element] = max(alpha[i - 1, j, element], alpha[i, j, element])
Expand Down Expand Up @@ -59,11 +59,11 @@ end

@inline function idp_positivity!(alpha, limiter, u, dt, semi, variable, index)
mesh, equations, dg, cache = mesh_equations_solver_cache(semi)
@unpack antidiffusive_flux1, antidiffusive_flux2 = cache.container_antidiffusive_flux
@unpack antidiffusive_flux1, antidiffusive_flux2 = cache.antidiffusive_fluxes
@unpack inverse_weights = dg.basis
@unpack positivity_correction_factor = limiter

@unpack variable_bounds = limiter.cache.container_subcell_limiter
@unpack variable_bounds = limiter.cache.subcell_limiter_coefficients

var_min = variable_bounds[index]

Expand Down
8 changes: 4 additions & 4 deletions src/time_integration/methods_SSP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,11 @@ end
Base.resize!(semi, volume_integral::AbstractVolumeIntegral, new_size) = nothing

function Base.resize!(semi, volume_integral::VolumeIntegralSubcellLimiting, new_size)
# Resize container_antidiffusive_flux
resize!(semi.cache.container_antidiffusive_flux, new_size)
# Resize container antidiffusive_fluxes
resize!(semi.cache.antidiffusive_fluxes, new_size)

# Resize container_subcell_limiter
# Resize container subcell_limiter_coefficients
@unpack limiter = volume_integral
resize!(limiter.cache.container_subcell_limiter, new_size)
resize!(limiter.cache.subcell_limiter_coefficients, new_size)
end
end # @muladd

0 comments on commit 0fca290

Please sign in to comment.