Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ This enables in particular adaptive mesh refinement for that solver-mesh combina
Instead, it is possible to reconstruct in custom variables, if functions `cons2recon` and `recon2cons` are provided to
`VolumeIntegralPureLGLFiniteVolumeO2` and `VolumeIntegralShockCapturingRRG`([#2817]).
- Add Legendre-Gauss basis for DGSEM and implement solver (`VolumeIntegralWeakForm` and `SurfaceIntegralWeakForm` only) support for conforming 1D & 2D `TreeMesh`es ([#1965]).
- Extended 3D support for subcell limiting was added ([#2763], [#2846], [#2844]).
- Extended 3D support for subcell limiting was added ([#2763], [#2846], [#2844], [#2848]).
In the new version, local (minimum and maximum) limiting for conservative variables (using the
keyword `local_twosided_variables_cons` in `SubcellLimiterIDP()`) with `P4estMesh` is supported.
The support was extended to nonperiodic `P4estMesh{3}`es.
Moreover, initial support for `TreeMesh{3}` including positivity limiting on periodic meshes was added.
Moreover, initial support for `TreeMesh{3}` including positivity limiting and local limiting on periodic meshes was added.

## Changes when updating to v0.15 from v0.14.x

Expand Down
209 changes: 0 additions & 209 deletions src/solvers/dgsem_p4est/dg_3d_subcell_limiters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,116 +5,6 @@
@muladd begin
#! format: noindent

function create_cache(mesh::Union{TreeMesh{3}, P4estMesh{3}},
equations, volume_integral::VolumeIntegralSubcellLimiting,
dg::DG, cache_containers, uEltype)
cache = create_cache(mesh, equations,
VolumeIntegralPureLGLFiniteVolume(volume_integral.volume_flux_fv),
dg, cache_containers, uEltype)

fhat1_L_threaded, fhat1_R_threaded,
fhat2_L_threaded, fhat2_R_threaded,
fhat3_L_threaded, fhat3_R_threaded = create_f_threaded(mesh, equations, dg, uEltype)

A4d = Array{uEltype, 4}
flux_temp_threaded = A4d[A4d(undef, nvariables(equations),
nnodes(dg), nnodes(dg), nnodes(dg))
for _ in 1:Threads.maxthreadid()]
fhat_temp_threaded = A4d[A4d(undef, nvariables(equations),
nnodes(dg), nnodes(dg), nnodes(dg))
for _ in 1:Threads.maxthreadid()]

n_elements = nelements(cache_containers.elements)
antidiffusive_fluxes = ContainerAntidiffusiveFlux3D{uEltype}(n_elements,
nvariables(equations),
nnodes(dg))

if have_nonconservative_terms(equations) == true
A5d = Array{uEltype, 5}
# Extract the nonconservative flux as a dispatch argument for `n_nonconservative_terms`
_, volume_flux_noncons = volume_integral.volume_flux_dg

flux_nonconservative_temp_threaded = A5d[A5d(undef, nvariables(equations),
n_nonconservative_terms(volume_flux_noncons),
nnodes(dg), nnodes(dg),
nnodes(dg))
for _ in 1:Threads.maxthreadid()]
fhat_nonconservative_temp_threaded = A5d[A5d(undef, nvariables(equations),
n_nonconservative_terms(volume_flux_noncons),
nnodes(dg), nnodes(dg),
nnodes(dg))
for _ in 1:Threads.maxthreadid()]
phi_threaded = A5d[A5d(undef, nvariables(equations),
n_nonconservative_terms(volume_flux_noncons),
nnodes(dg), nnodes(dg), nnodes(dg))
for _ in 1:Threads.maxthreadid()]
cache = (; cache..., flux_nonconservative_temp_threaded,
fhat_nonconservative_temp_threaded, phi_threaded)
end

return (; cache..., antidiffusive_fluxes,
fhat1_L_threaded, fhat1_R_threaded,
fhat2_L_threaded, fhat2_R_threaded,
fhat3_L_threaded, fhat3_R_threaded,
flux_temp_threaded, fhat_temp_threaded)
end

# Subcell limiting currently only implemented for certain mesh types
@inline function volume_integral_kernel!(du, u, element,
mesh::Union{TreeMesh{3}, P4estMesh{3}},
nonconservative_terms, equations,
volume_integral::VolumeIntegralSubcellLimiting,
dg::DGSEM, cache)
@unpack inverse_weights = dg.basis # Plays role of DG subcell sizes
@unpack volume_flux_dg, volume_flux_fv, limiter = volume_integral

# high-order DG fluxes
@unpack fhat1_L_threaded, fhat1_R_threaded, fhat2_L_threaded, fhat2_R_threaded, fhat3_L_threaded, fhat3_R_threaded = cache

fhat1_L = fhat1_L_threaded[Threads.threadid()]
fhat1_R = fhat1_R_threaded[Threads.threadid()]
fhat2_L = fhat2_L_threaded[Threads.threadid()]
fhat2_R = fhat2_R_threaded[Threads.threadid()]
fhat3_L = fhat3_L_threaded[Threads.threadid()]
fhat3_R = fhat3_R_threaded[Threads.threadid()]
calcflux_fhat!(fhat1_L, fhat1_R, fhat2_L, fhat2_R, fhat3_L, fhat3_R,
u, mesh, nonconservative_terms, equations, volume_flux_dg,
dg, element, cache)

# low-order FV fluxes
@unpack fstar1_L_threaded, fstar1_R_threaded, fstar2_L_threaded, fstar2_R_threaded, fstar3_L_threaded, fstar3_R_threaded = cache

fstar1_L = fstar1_L_threaded[Threads.threadid()]
fstar1_R = fstar1_R_threaded[Threads.threadid()]
fstar2_L = fstar2_L_threaded[Threads.threadid()]
fstar2_R = fstar2_R_threaded[Threads.threadid()]
fstar3_L = fstar3_L_threaded[Threads.threadid()]
fstar3_R = fstar3_R_threaded[Threads.threadid()]
calcflux_fv!(fstar1_L, fstar1_R, fstar2_L, fstar2_R, fstar3_L, fstar3_R,
u, mesh, nonconservative_terms, equations, volume_flux_fv,
dg, element, cache)

# antidiffusive flux
calcflux_antidiffusive!(fhat1_L, fhat1_R, fhat2_L, fhat2_R, fhat3_L, fhat3_R,
fstar1_L, fstar1_R, fstar2_L, fstar2_R, fstar3_L, fstar3_R,
u, mesh, nonconservative_terms, equations, limiter,
dg, element, cache)

# Calculate volume integral contribution of low-order FV flux
for k in eachnode(dg), j in eachnode(dg), i in eachnode(dg)
for v in eachvariable(equations)
du[v, i, j, k, element] += inverse_weights[i] *
(fstar1_L[v, i + 1, j, k] - fstar1_R[v, i, j, k]) +
inverse_weights[j] *
(fstar2_L[v, i, j + 1, k] - fstar2_R[v, i, j, k]) +
inverse_weights[k] *
(fstar3_L[v, i, j, k + 1] - fstar3_R[v, i, j, k])
end
end

return nothing
end

# Calculate the DG staggered volume fluxes `fhat` in subcell FV-form inside the element
# (**without non-conservative terms**).
#
Expand Down Expand Up @@ -543,103 +433,4 @@ end

return nothing
end

# Calculate the antidiffusive flux `antidiffusive_flux` as the subtraction between `fhat` and `fstar` for conservative systems.
@inline function calcflux_antidiffusive!(fhat1_L, fhat1_R,
fhat2_L, fhat2_R,
fhat3_L, fhat3_R,
fstar1_L, fstar1_R,
fstar2_L, fstar2_R,
fstar3_L, fstar3_R,
u, mesh::Union{TreeMesh{3}, P4estMesh{3}},
nonconservative_terms::False, equations,
limiter::SubcellLimiterIDP, dg, element, cache)
@unpack antidiffusive_flux1_L, antidiffusive_flux1_R, antidiffusive_flux2_L, antidiffusive_flux2_R, antidiffusive_flux3_L, antidiffusive_flux3_R = cache.antidiffusive_fluxes

# Due to the use of LGL nodes, the DG staggered fluxes `fhat` and FV fluxes `fstar` are equal
# on the element interfaces. So, they are not computed in the volume integral and set to zero
# in their respective computation.
# The antidiffusive fluxes are therefore zero on the element interfaces and don't need to be
# computed either. They are set to zero directly after resizing the container.
# This applies to the indices `i=1` and `i=nnodes(dg)+1` for `antidiffusive_flux1_L` and
# `antidiffusive_flux1_R` and analogously for the other two directions.

for k in eachnode(dg), j in eachnode(dg), i in 2:nnodes(dg)
for v in eachvariable(equations)
antidiffusive_flux1_L[v, i, j, k, element] = fhat1_L[v, i, j, k] -
fstar1_L[v, i, j, k]
antidiffusive_flux1_R[v, i, j, k, element] = antidiffusive_flux1_L[v,
i, j, k,
element]
end
end
for k in eachnode(dg), j in 2:nnodes(dg), i in eachnode(dg)
for v in eachvariable(equations)
antidiffusive_flux2_L[v, i, j, k, element] = fhat2_L[v, i, j, k] -
fstar2_L[v, i, j, k]
antidiffusive_flux2_R[v, i, j, k, element] = antidiffusive_flux2_L[v,
i, j, k,
element]
end
end
for k in 2:nnodes(dg), j in eachnode(dg), i in eachnode(dg)
for v in eachvariable(equations)
antidiffusive_flux3_L[v, i, j, k, element] = fhat3_L[v, i, j, k] -
fstar3_L[v, i, j, k]
antidiffusive_flux3_R[v, i, j, k, element] = antidiffusive_flux3_L[v,
i, j, k,
element]
end
end

return nothing
end

# Calculate the antidiffusive flux `antidiffusive_flux` as the subtraction between `fhat` and `fstar` for conservative systems.
@inline function calcflux_antidiffusive!(fhat1_L, fhat1_R,
fhat2_L, fhat2_R,
fhat3_L, fhat3_R,
fstar1_L, fstar1_R,
fstar2_L, fstar2_R,
fstar3_L, fstar3_R,
u, mesh::Union{TreeMesh{3}, P4estMesh{3}},
nonconservative_terms::True, equations,
limiter::SubcellLimiterIDP, dg, element, cache)
@unpack antidiffusive_flux1_L, antidiffusive_flux2_L, antidiffusive_flux1_R, antidiffusive_flux2_R, antidiffusive_flux3_L, antidiffusive_flux3_R = cache.antidiffusive_fluxes

# Due to the use of LGL nodes, the DG staggered fluxes `fhat` and FV fluxes `fstar` are equal
# on the element interfaces. So, they are not computed in the volume integral and set to zero
# in their respective computation.
# The antidiffusive fluxes are therefore zero on the element interfaces and don't need to be
# computed either. They are set to zero directly after resizing the container.
# This applies to the indices `i=1` and `i=nnodes(dg)+1` for `antidiffusive_flux1_L` and
# `antidiffusive_flux1_R` and analogously for the other two directions.

for k in eachnode(dg), j in eachnode(dg), i in 2:nnodes(dg)
for v in eachvariable(equations)
antidiffusive_flux1_L[v, i, j, k, element] = fhat1_L[v, i, j, k] -
fstar1_L[v, i, j, k]
antidiffusive_flux1_R[v, i, j, k, element] = fhat1_R[v, i, j, k] -
fstar1_R[v, i, j, k]
end
end
for k in eachnode(dg), j in 2:nnodes(dg), i in eachnode(dg)
for v in eachvariable(equations)
antidiffusive_flux2_L[v, i, j, k, element] = fhat2_L[v, i, j, k] -
fstar2_L[v, i, j, k]
antidiffusive_flux2_R[v, i, j, k, element] = fhat2_R[v, i, j, k] -
fstar2_R[v, i, j, k]
end
end
for k in 2:nnodes(dg), j in eachnode(dg), i in eachnode(dg)
for v in eachvariable(equations)
antidiffusive_flux3_L[v, i, j, k, element] = fhat3_L[v, i, j, k] -
fstar3_L[v, i, j, k]
antidiffusive_flux3_R[v, i, j, k, element] = fhat3_R[v, i, j, k] -
fstar3_R[v, i, j, k]
end
end

return nothing
end
end # @muladd
Loading
Loading