Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
0e5c171
Make volume integrals dimension agnostic
DanielDoehring Jul 21, 2025
889ed35
clean up indicators
DanielDoehring Jul 21, 2025
3df4766
bring back dim spec version
DanielDoehring Jul 21, 2025
22dff42
bring back indicators
DanielDoehring Jul 21, 2025
5f7c747
Apply suggestions from code review
DanielDoehring Jul 21, 2025
b840a20
remove create cahce
DanielDoehring Jul 21, 2025
a58364b
Merge branch 'CleanUpVolumeIntegrals' of github.com:DanielDoehring/Tr…
DanielDoehring Jul 21, 2025
660bb44
Merge branch 'main' into CleanUpVolumeIntegrals
DanielDoehring Jul 22, 2025
06b5d99
Merge branch 'main' into CleanUpVolumeIntegrals
DanielDoehring Jul 24, 2025
059d325
remove 3d
DanielDoehring Jul 24, 2025
263c5a9
Merge branch 'CleanUpVolumeIntegrals' of github.com:DanielDoehring/Tr…
DanielDoehring Jul 24, 2025
6de9ecc
Merge remote-tracking branch 'origin/main' into CleanUpVolumeIntegrals
DanielDoehring Aug 10, 2025
0349c35
move functions
DanielDoehring Aug 10, 2025
6b4edd5
Merge branch 'CleanUpVolumeIntegrals' of github.com:DanielDoehring/Tr…
DanielDoehring Aug 10, 2025
965446a
restructure
DanielDoehring Aug 11, 2025
d117a72
comment
DanielDoehring Aug 11, 2025
5b3f81e
Merge branch 'main' into CleanUpVolumeIntegrals
DanielDoehring Aug 12, 2025
5331203
Merge branch 'main' into CleanUpVolumeIntegrals
DanielDoehring Aug 19, 2025
df683ba
Merge branch 'main' into CleanUpVolumeIntegrals
DanielDoehring Aug 28, 2025
a16fb30
comments
DanielDoehring Aug 28, 2025
e0e2938
Merge branch 'CleanUpVolumeIntegrals' of github.com:DanielDoehring/Tr…
DanielDoehring Aug 28, 2025
84cf10b
Merge branch 'main' into CleanUpVolumeIntegrals
DanielDoehring Aug 28, 2025
756fd4f
Merge branch 'main' into CleanUpVolumeIntegrals
DanielDoehring Sep 2, 2025
c06b534
Merge branch 'main' into CleanUpVolumeIntegrals
DanielDoehring Sep 2, 2025
e7922ce
Merge branch 'main' into CleanUpVolumeIntegrals
DanielDoehring Sep 3, 2025
27dca5f
rename
DanielDoehring Sep 3, 2025
3ceeed2
fmt
DanielDoehring Sep 4, 2025
cf6d461
Merge branch 'main' into CleanUpVolumeIntegrals
DanielDoehring Sep 4, 2025
e4dac0c
Merge branch 'main' into CleanUpVolumeIntegrals
DanielDoehring Sep 10, 2025
d407967
Merge branch 'main' into CleanUpVolumeIntegrals
DanielDoehring Sep 10, 2025
fdddd11
Merge branch 'main' into CleanUpVolumeIntegrals
DanielDoehring Sep 12, 2025
e74b3fb
comment
DanielDoehring Sep 12, 2025
133f77c
Merge branch 'main' into CleanUpVolumeIntegrals
DanielDoehring Sep 12, 2025
17d6913
move
DanielDoehring Sep 12, 2025
4c8d510
Merge branch 'CleanUpVolumeIntegrals' of https://github.com/DanielDoe…
DanielDoehring Sep 12, 2025
b02cf44
Merge branch 'main' into CleanUpVolumeIntegrals
DanielDoehring Sep 18, 2025
635fe09
Merge branch 'main' into CleanUpVolumeIntegrals
DanielDoehring Sep 22, 2025
62d4c09
Merge branch 'main' into CleanUpVolumeIntegrals
DanielDoehring Sep 23, 2025
330dc22
Merge branch 'main' into CleanUpVolumeIntegrals
DanielDoehring Sep 25, 2025
9b568ad
Merge branch 'main' into CleanUpVolumeIntegrals
DanielDoehring Sep 28, 2025
a509dc7
test vals
DanielDoehring Sep 28, 2025
fc26c10
Merge branch 'main' into CleanUpVolumeIntegrals
DanielDoehring Sep 29, 2025
6fb3f08
specify solver
DanielDoehring Sep 29, 2025
249b32a
fmt
DanielDoehring Sep 29, 2025
32db41d
Merge branch 'main' into CleanUpVolumeIntegrals
DanielDoehring Sep 30, 2025
996e364
comments
DanielDoehring Sep 30, 2025
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 src/solvers/dgsem_structured/dg_1d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ function calc_interface_flux!(cache, u, mesh::StructuredMesh{1},
return nothing
end

# TODO: Taal dimension agnostic
# Dimension agnostic, i.e., valid for all 1D, 2D, and 3D structured meshes
function calc_boundary_flux!(cache, u, t, boundary_condition::BoundaryConditionPeriodic,
mesh::StructuredMesh{1}, equations, surface_integral,
mesh::StructuredMesh, equations, surface_integral,
dg::DG)
@assert isperiodic(mesh)
end
Expand Down
7 changes: 0 additions & 7 deletions src/solvers/dgsem_structured/dg_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -550,13 +550,6 @@ end
return nothing
end

# TODO: Taal dimension agnostic
function calc_boundary_flux!(cache, u, t, boundary_condition::BoundaryConditionPeriodic,
mesh::Union{StructuredMesh{2}, StructuredMeshView{2}},
equations, surface_integral, dg::DG)
@assert isperiodic(mesh)
end

function calc_boundary_flux!(cache, u, t, boundary_conditions::NamedTuple,
mesh::Union{StructuredMesh{2}, StructuredMeshView{2}},
equations, surface_integral,
Expand Down
7 changes: 0 additions & 7 deletions src/solvers/dgsem_structured/dg_3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -686,13 +686,6 @@ end
return nothing
end

# TODO: Taal dimension agnostic
function calc_boundary_flux!(cache, u, t, boundary_condition::BoundaryConditionPeriodic,
mesh::StructuredMesh{3}, equations, surface_integral,
dg::DG)
@assert isperiodic(mesh)
end

function calc_boundary_flux!(cache, u, t, boundary_conditions::NamedTuple,
mesh::StructuredMesh{3}, equations, surface_integral,
dg::DG)
Expand Down
29 changes: 15 additions & 14 deletions src/solvers/dgsem_tree/dg_1d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ end

# The methods below are specialized on the volume integral type
# and called from the basic `create_cache` method at the top.
function create_cache(mesh::Union{TreeMesh{1}, StructuredMesh{1}}, equations,
# Dimension agnostic, i.e., valid for all 1D, 2D, and 3D meshes
function create_cache(mesh, equations,
volume_integral::VolumeIntegralFluxDifferencing, dg::DG, uEltype)
NamedTuple()
end
Expand Down Expand Up @@ -122,8 +123,8 @@ function rhs!(du, u, t,
return nothing
end

function calc_volume_integral!(du, u,
mesh::Union{TreeMesh{1}, StructuredMesh{1}},
# Dimension agnostic, i.e., valid for all 1D, 2D, and 3D meshes
function calc_volume_integral!(du, u, mesh,
nonconservative_terms, equations,
volume_integral::VolumeIntegralWeakForm,
dg::DGSEM, cache)
Expand Down Expand Up @@ -164,8 +165,10 @@ See also https://github.com/trixi-framework/Trixi.jl/issues/1671#issuecomment-17
return nothing
end

function calc_volume_integral!(du, u,
mesh::Union{TreeMesh{1}, StructuredMesh{1}},
# Dimension agnostic, i.e., valid for all 1D, 2D, and 3D meshes.
# For curved meshes averaging of the mapping terms, stored in `cache.elements.contravariant_vectors`,
# is peeled apart from the evaluation of the physical fluxes in each Cartesian direction.
function calc_volume_integral!(du, u, mesh,
nonconservative_terms, equations,
volume_integral::VolumeIntegralFluxDifferencing,
dg::DGSEM, cache)
Expand Down Expand Up @@ -242,9 +245,8 @@ end
end
end

# TODO: Taal dimension agnostic
function calc_volume_integral!(du, u,
mesh::Union{TreeMesh{1}, StructuredMesh{1}},
# Dimension agnostic, i.e., valid for all 1D, 2D, and 3D meshes
function calc_volume_integral!(du, u, mesh,
nonconservative_terms, equations,
volume_integral::VolumeIntegralShockCapturingHG,
dg::DGSEM, cache)
Expand Down Expand Up @@ -282,9 +284,8 @@ function calc_volume_integral!(du, u,
return nothing
end

# TODO: Taal dimension agnostic
function calc_volume_integral!(du, u,
mesh::Union{TreeMesh{1}, StructuredMesh{1}},
# Dimension agnostic, i.e., valid for all 1D, 2D, and 3D meshes
function calc_volume_integral!(du, u, mesh,
nonconservative_terms, equations,
volume_integral::VolumeIntegralPureLGLFiniteVolume,
dg::DGSEM, cache)
Expand Down Expand Up @@ -492,9 +493,9 @@ function prolong2boundaries!(cache, u,
return nothing
end

# TODO: Taal dimension agnostic
# Dimension agnostic, i.e., valid for all 1D, 2D, and 3D meshes
function calc_boundary_flux!(cache, t, boundary_condition::BoundaryConditionPeriodic,
mesh::TreeMesh{1}, equations, surface_integral, dg::DG)
mesh::TreeMesh, equations, surface_integral, dg::DG)
@assert isempty(eachboundary(dg, cache))
end

Expand Down Expand Up @@ -630,7 +631,7 @@ function apply_jacobian!(du, mesh::Union{TreeMesh{1}, StructuredMesh{1}},
return nothing
end

# TODO: Taal dimension agnostic
# Need dimension specific version to avoid error at dispatching
function calc_sources!(du, u, t, source_terms::Nothing,
equations::AbstractEquations{1}, dg::DG, cache)
return nothing
Expand Down
114 changes: 1 addition & 113 deletions src/solvers/dgsem_tree/dg_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,6 @@ function create_cache(mesh::TreeMesh{2}, equations,
return cache
end

# The methods below are specialized on the volume integral type
# and called from the basic `create_cache` method at the top.
function create_cache(mesh::Union{TreeMesh{2}, StructuredMesh{2}, StructuredMeshView{2},
UnstructuredMesh2D,
P4estMesh{2}, T8codeMesh{2}},
equations, volume_integral::VolumeIntegralFluxDifferencing,
dg::DG, uEltype)
NamedTuple()
end

function create_cache(mesh::Union{TreeMesh{2}, StructuredMesh{2}, UnstructuredMesh2D,
P4estMesh{2}, T8codeMesh{2}}, equations,
volume_integral::VolumeIntegralShockCapturingHG, dg::DG, uEltype)
Expand Down Expand Up @@ -179,23 +169,6 @@ function rhs!(du, u, t,
return nothing
end

function calc_volume_integral!(du, u,
mesh::Union{TreeMesh{2}, StructuredMesh{2},
StructuredMeshView{2}, UnstructuredMesh2D,
P4estMesh{2}, P4estMeshView{2},
T8codeMesh{2}},
nonconservative_terms, equations,
volume_integral::VolumeIntegralWeakForm,
dg::DGSEM, cache)
@threaded for element in eachelement(dg, cache)
weak_form_kernel!(du, u, element, mesh,
nonconservative_terms, equations,
dg, cache)
end

return nothing
end

#=
`weak_form_kernel!` is only implemented for conserved terms as
non-conservative terms should always be discretized in conjunction with a flux-splitting scheme,
Expand Down Expand Up @@ -231,24 +204,6 @@ See also https://github.com/trixi-framework/Trixi.jl/issues/1671#issuecomment-17
return nothing
end

# flux differencing volume integral. For curved meshes averaging of the
# mapping terms, stored in `cache.elements.contravariant_vectors`, is peeled apart
# from the evaluation of the physical fluxes in each Cartesian direction
function calc_volume_integral!(du, u,
mesh::Union{TreeMesh{2}, StructuredMesh{2},
StructuredMeshView{2},
UnstructuredMesh2D, P4estMesh{2},
T8codeMesh{2}},
nonconservative_terms, equations,
volume_integral::VolumeIntegralFluxDifferencing,
dg::DGSEM, cache)
@threaded for element in eachelement(dg, cache)
flux_differencing_kernel!(du, u, element, mesh,
nonconservative_terms, equations,
volume_integral.volume_flux, dg, cache)
end
end

@inline function flux_differencing_kernel!(du, u,
element, mesh::TreeMesh{2},
nonconservative_terms::False, equations,
Expand Down Expand Up @@ -331,67 +286,6 @@ end
end
end

# TODO: Taal dimension agnostic
function calc_volume_integral!(du, u,
mesh::Union{TreeMesh{2}, StructuredMesh{2},
UnstructuredMesh2D, P4estMesh{2},
T8codeMesh{2}},
nonconservative_terms, equations,
volume_integral::VolumeIntegralShockCapturingHG,
dg::DGSEM, cache)
@unpack volume_flux_dg, volume_flux_fv, indicator = volume_integral

# Calculate blending factors α: u = u_DG * (1 - α) + u_FV * α
alpha = @trixi_timeit timer() "blending factors" indicator(u, mesh, equations, dg,
cache)

# For `Float64`, this gives 1.8189894035458565e-12
# For `Float32`, this gives 1.1920929f-5
RealT = eltype(alpha)
atol = max(100 * eps(RealT), eps(RealT)^convert(RealT, 0.75f0))
@threaded for element in eachelement(dg, cache)
alpha_element = alpha[element]
# Clip blending factor for values close to zero (-> pure DG)
dg_only = isapprox(alpha_element, 0, atol = atol)

if dg_only
flux_differencing_kernel!(du, u, element, mesh,
nonconservative_terms, equations,
volume_flux_dg, dg, cache)
else
# Calculate DG volume integral contribution
flux_differencing_kernel!(du, u, element, mesh,
nonconservative_terms, equations,
volume_flux_dg, dg, cache, 1 - alpha_element)

# Calculate FV volume integral contribution
fv_kernel!(du, u, mesh, nonconservative_terms, equations, volume_flux_fv,
dg, cache, element, alpha_element)
end
end

return nothing
end

# TODO: Taal dimension agnostic
function calc_volume_integral!(du, u,
mesh::Union{TreeMesh{2}, StructuredMesh{2},
UnstructuredMesh2D, P4estMesh{2},
T8codeMesh{2}},
nonconservative_terms, equations,
volume_integral::VolumeIntegralPureLGLFiniteVolume,
dg::DGSEM, cache)
@unpack volume_flux_fv = volume_integral

# Calculate LGL FV volume integral
@threaded for element in eachelement(dg, cache)
fv_kernel!(du, u, mesh, nonconservative_terms, equations, volume_flux_fv,
dg, cache, element, true)
end

return nothing
end

@inline function fv_kernel!(du, u,
mesh::Union{TreeMesh{2}, StructuredMesh{2},
UnstructuredMesh2D, P4estMesh{2},
Expand Down Expand Up @@ -686,12 +580,6 @@ function prolong2boundaries!(cache, u,
return nothing
end

# TODO: Taal dimension agnostic
function calc_boundary_flux!(cache, t, boundary_condition::BoundaryConditionPeriodic,
mesh::TreeMesh{2}, equations, surface_integral, dg::DG)
@assert isempty(eachboundary(dg, cache))
end

function calc_boundary_flux!(cache, t, boundary_conditions::NamedTuple,
mesh::TreeMesh{2}, equations, surface_integral, dg::DG)
@unpack surface_flux_values = cache.elements
Expand Down Expand Up @@ -1187,7 +1075,7 @@ function apply_jacobian!(du, mesh::TreeMesh{2},
return nothing
end

# TODO: Taal dimension agnostic
# Need dimension specific version to avoid error at dispatching
function calc_sources!(du, u, t, source_terms::Nothing,
equations::AbstractEquations{2}, dg::DG, cache)
return nothing
Expand Down
1 change: 1 addition & 0 deletions src/solvers/dgsem_tree/dg_2d_subcell_limiters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ function create_cache(mesh::Union{TreeMesh{2}, StructuredMesh{2}, P4estMesh{2}},
flux_temp_threaded, fhat_temp_threaded)
end

# Subcell limiting currently only implemented for certain mesh types
function calc_volume_integral!(du, u,
mesh::Union{TreeMesh{2}, StructuredMesh{2},
P4estMesh{2}},
Expand Down
Loading
Loading