Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Zhang-Shu limiter on curved meshes #46

Merged
merged 1 commit into from
May 22, 2024
Merged
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
23 changes: 17 additions & 6 deletions src/callbacks_stage/positivity_shallow_water_dg2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
equations::ShallowWaterEquationsWetDry2D, dg::DGSEM,
cache)
@unpack weights = dg.basis
@unpack inverse_jacobian = cache.elements

Trixi.@threaded for element in eachelement(dg, cache)
# determine minimum value
Expand All @@ -26,12 +27,16 @@

# compute mean value
u_mean = zero(get_node_vars(u, equations, dg, 1, 1, element))
total_volume = zero(eltype(u))
for j in eachnode(dg), i in eachnode(dg)
volume_jacobian = abs(inv(Trixi.get_inverse_jacobian(inverse_jacobian, mesh,
i, j, element)))
u_node = get_node_vars(u, equations, dg, i, j, element)
u_mean += u_node * weights[i] * weights[j]
u_mean += u_node * weights[i] * weights[j] * volume_jacobian
total_volume += weights[i] * weights[j] * volume_jacobian
end
# note that the reference element is [-1,1]^ndims(dg), thus the weights sum to 2
u_mean = u_mean / 2^ndims(mesh)
# normalize with the total volume
u_mean = u_mean / total_volume

# We compute the value directly with the mean values, as we assume that
# Jensen's inequality holds (e.g. pressure for compressible Euler equations).
Expand Down Expand Up @@ -96,6 +101,7 @@
equations::ShallowWaterMultiLayerEquations2D, dg::DGSEM,
cache)
@unpack weights = dg.basis
@unpack inverse_jacobian = cache.elements

Trixi.@threaded for element in eachelement(dg, cache)
# Limit layerwise
Expand All @@ -112,12 +118,17 @@

# compute mean value
u_mean = zero(get_node_vars(u, equations, dg, 1, 1, element))
total_volume = zero(eltype(u))

Check warning on line 121 in src/callbacks_stage/positivity_shallow_water_dg2d.jl

View check run for this annotation

Codecov / codecov/patch

src/callbacks_stage/positivity_shallow_water_dg2d.jl#L121

Added line #L121 was not covered by tests
for j in eachnode(dg), i in eachnode(dg)
volume_jacobian = abs(inv(Trixi.get_inverse_jacobian(inverse_jacobian,

Check warning on line 123 in src/callbacks_stage/positivity_shallow_water_dg2d.jl

View check run for this annotation

Codecov / codecov/patch

src/callbacks_stage/positivity_shallow_water_dg2d.jl#L123

Added line #L123 was not covered by tests
mesh,
i, j, element)))
u_node = get_node_vars(u, equations, dg, i, j, element)
u_mean += u_node * weights[i] * weights[j]
u_mean += u_node * weights[i] * weights[j] * volume_jacobian
total_volume += weights[i] * weights[j] * volume_jacobian

Check warning on line 128 in src/callbacks_stage/positivity_shallow_water_dg2d.jl

View check run for this annotation

Codecov / codecov/patch

src/callbacks_stage/positivity_shallow_water_dg2d.jl#L127-L128

Added lines #L127 - L128 were not covered by tests
end
# note that the reference element is [-1,1]^ndims(dg), thus the weights sum to 2
u_mean = u_mean / 2^ndims(mesh)
# normalize with the total volume
u_mean = u_mean / total_volume

Check warning on line 131 in src/callbacks_stage/positivity_shallow_water_dg2d.jl

View check run for this annotation

Codecov / codecov/patch

src/callbacks_stage/positivity_shallow_water_dg2d.jl#L131

Added line #L131 was not covered by tests

# We compute the value directly with the mean values.
# The waterheight `h` is limited independently in each layer.
Expand Down
Loading