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

WIP: Non-Conservative BCs update #64

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,17 @@
initial_condition = initial_condition_three_mounds

function boundary_condition_outflow(u_inner, normal_direction::AbstractVector, x, t,
surface_flux_function,
surface_flux_functions,
equations::ShallowWaterEquationsWetDry2D)
surface_flux_function, nonconservative_flux_function = surface_flux_functions

Check warning on line 58 in examples/unstructured_2d_dgsem/elixir_shallowwater_three_mound_dam_break.jl

View check run for this annotation

Codecov / codecov/patch

examples/unstructured_2d_dgsem/elixir_shallowwater_three_mound_dam_break.jl#L58

Added line #L58 was not covered by tests
# Impulse and bottom from inside, height from external state
u_outer = SVector(equations.threshold_wet, u_inner[2], u_inner[3], u_inner[4])

# calculate the boundary flux
flux = surface_flux_function(u_inner, u_outer, normal_direction, equations)

return flux
noncons_flux = nonconservative_flux_function(u_inner, u_outer, normal_direction,

Check warning on line 64 in examples/unstructured_2d_dgsem/elixir_shallowwater_three_mound_dam_break.jl

View check run for this annotation

Codecov / codecov/patch

examples/unstructured_2d_dgsem/elixir_shallowwater_three_mound_dam_break.jl#L64

Added line #L64 was not covered by tests
equations)
return flux, noncons_flux

Check warning on line 66 in examples/unstructured_2d_dgsem/elixir_shallowwater_three_mound_dam_break.jl

View check run for this annotation

Codecov / codecov/patch

examples/unstructured_2d_dgsem/elixir_shallowwater_three_mound_dam_break.jl#L66

Added line #L66 was not covered by tests
end

boundary_conditions = Dict(:Bottom => boundary_condition_slip_wall,
Expand Down
12 changes: 10 additions & 2 deletions src/equations/shallow_water_exner_1d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,10 @@
@inline function Trixi.boundary_condition_slip_wall(u_inner, orientation_or_normal,
direction,
x, t,
surface_flux_function,
surface_flux_functions,
equations::ShallowWaterExnerEquations1D)
surface_flux_function, nonconservative_flux_function = surface_flux_functions

Check warning on line 195 in src/equations/shallow_water_exner_1d.jl

View check run for this annotation

Codecov / codecov/patch

src/equations/shallow_water_exner_1d.jl#L195

Added line #L195 was not covered by tests

# create the "external" boundary solution state
u_boundary = SVector(u_inner[1],
-u_inner[2],
Expand All @@ -201,12 +203,18 @@
if iseven(direction) # u_inner is "left" of boundary, u_boundary is "right" of boundary
flux = surface_flux_function(u_inner, u_boundary, orientation_or_normal,
equations)
noncons_flux = nonconservative_flux_function(u_inner, u_boundary,

Check warning on line 206 in src/equations/shallow_water_exner_1d.jl

View check run for this annotation

Codecov / codecov/patch

src/equations/shallow_water_exner_1d.jl#L206

Added line #L206 was not covered by tests
orientation_or_normal,
equations)
else # u_boundary is "left" of boundary, u_inner is "right" of boundary
flux = surface_flux_function(u_boundary, u_inner, orientation_or_normal,
equations)
noncons_flux = nonconservative_flux_function(u_boundary, u_inner,

Check warning on line 212 in src/equations/shallow_water_exner_1d.jl

View check run for this annotation

Codecov / codecov/patch

src/equations/shallow_water_exner_1d.jl#L212

Added line #L212 was not covered by tests
orientation_or_normal,
equations)
end

return flux
return flux, noncons_flux

Check warning on line 217 in src/equations/shallow_water_exner_1d.jl

View check run for this annotation

Codecov / codecov/patch

src/equations/shallow_water_exner_1d.jl#L217

Added line #L217 was not covered by tests
end

# Set initial conditions at physical location `x` for time `t`
Expand Down
18 changes: 14 additions & 4 deletions src/equations/shallow_water_multilayer_1d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,10 @@
"""
@inline function Trixi.boundary_condition_slip_wall(u_inner, orientation_or_normal,
direction,
x, t, surface_flux_function,
x, t, surface_flux_functions,
equations::ShallowWaterMultiLayerEquations1D)
surface_flux_function, nonconservative_flux_function = surface_flux_functions

Check warning on line 261 in src/equations/shallow_water_multilayer_1d.jl

View check run for this annotation

Codecov / codecov/patch

src/equations/shallow_water_multilayer_1d.jl#L261

Added line #L261 was not covered by tests

# Create the "external" boundary solution state
h = waterheight(u_inner, equations)
hv = momentum(u_inner, equations)
Expand All @@ -267,11 +269,19 @@

# Calculate the boundary flux
if iseven(direction) # u_inner is "left" of boundary, u_boundary is "right" of boundary
f = surface_flux_function(u_inner, u_boundary, orientation_or_normal, equations)
flux = surface_flux_function(u_inner, u_boundary, orientation_or_normal,

Check warning on line 272 in src/equations/shallow_water_multilayer_1d.jl

View check run for this annotation

Codecov / codecov/patch

src/equations/shallow_water_multilayer_1d.jl#L272

Added line #L272 was not covered by tests
equations)
noncons_flux = nonconservative_flux_function(u_inner, u_boundary,

Check warning on line 274 in src/equations/shallow_water_multilayer_1d.jl

View check run for this annotation

Codecov / codecov/patch

src/equations/shallow_water_multilayer_1d.jl#L274

Added line #L274 was not covered by tests
orientation_or_normal,
equations)
else # u_boundary is "left" of boundary, u_inner is "right" of boundary
f = surface_flux_function(u_boundary, u_inner, orientation_or_normal, equations)
flux = surface_flux_function(u_boundary, u_inner, orientation_or_normal,

Check warning on line 278 in src/equations/shallow_water_multilayer_1d.jl

View check run for this annotation

Codecov / codecov/patch

src/equations/shallow_water_multilayer_1d.jl#L278

Added line #L278 was not covered by tests
equations)
noncons_flux = nonconservative_flux_function(u_inner, u_boundary,

Check warning on line 280 in src/equations/shallow_water_multilayer_1d.jl

View check run for this annotation

Codecov / codecov/patch

src/equations/shallow_water_multilayer_1d.jl#L280

Added line #L280 was not covered by tests
orientation_or_normal,
equations)
end
return f
return flux, noncons_flux

Check warning on line 284 in src/equations/shallow_water_multilayer_1d.jl

View check run for this annotation

Codecov / codecov/patch

src/equations/shallow_water_multilayer_1d.jl#L284

Added line #L284 was not covered by tests
end

# Calculate 1D advective portion of the flux for a single point
Expand Down
18 changes: 14 additions & 4 deletions src/equations/shallow_water_multilayer_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,10 @@
@inline function Trixi.boundary_condition_slip_wall(u_inner,
normal_direction::AbstractVector,
x, t,
surface_flux_function,
surface_flux_functions,
equations::ShallowWaterMultiLayerEquations2D)
surface_flux_function, nonconservative_flux_function = surface_flux_functions

Check warning on line 336 in src/equations/shallow_water_multilayer_2d.jl

View check run for this annotation

Codecov / codecov/patch

src/equations/shallow_water_multilayer_2d.jl#L336

Added line #L336 was not covered by tests

# normalize the outward pointing direction
normal = normal_direction / norm(normal_direction)

Expand All @@ -352,8 +354,10 @@

# calculate the boundary flux
flux = surface_flux_function(u_inner, u_boundary, normal_direction, equations)
noncons_flux = nonconservative_flux_function(u_inner, u_boundary, normal_direction,

Check warning on line 357 in src/equations/shallow_water_multilayer_2d.jl

View check run for this annotation

Codecov / codecov/patch

src/equations/shallow_water_multilayer_2d.jl#L357

Added line #L357 was not covered by tests
equations)

return flux
return flux, noncons_flux

Check warning on line 360 in src/equations/shallow_water_multilayer_2d.jl

View check run for this annotation

Codecov / codecov/patch

src/equations/shallow_water_multilayer_2d.jl#L360

Added line #L360 was not covered by tests
end

"""
Expand All @@ -364,8 +368,10 @@
"""
@inline function Trixi.boundary_condition_slip_wall(u_inner, orientation,
direction, x, t,
surface_flux_function,
surface_flux_functions,
equations::ShallowWaterMultiLayerEquations2D)
surface_flux_function, nonconservative_flux_function = surface_flux_functions

Check warning on line 373 in src/equations/shallow_water_multilayer_2d.jl

View check run for this annotation

Codecov / codecov/patch

src/equations/shallow_water_multilayer_2d.jl#L373

Added line #L373 was not covered by tests

# Extract internal values
h = waterheight(u_inner, equations)
h_v1, h_v2 = momentum(u_inner, equations)
Expand All @@ -381,11 +387,15 @@
# Calculate boundary flux
if iseven(direction) # u_inner is "left" of boundary, u_boundary is "right" of boundary
flux = surface_flux_function(u_inner, u_boundary, orientation, equations)
noncons_flux = nonconservative_flux_function(u_inner, u_boundary, orientation,

Check warning on line 390 in src/equations/shallow_water_multilayer_2d.jl

View check run for this annotation

Codecov / codecov/patch

src/equations/shallow_water_multilayer_2d.jl#L390

Added line #L390 was not covered by tests
equations)
else # u_boundary is "left" of boundary, u_inner is "right" of boundary
flux = surface_flux_function(u_boundary, u_inner, orientation, equations)
noncons_flux = nonconservative_flux_function(u_boundary, u_inner, orientation,

Check warning on line 394 in src/equations/shallow_water_multilayer_2d.jl

View check run for this annotation

Codecov / codecov/patch

src/equations/shallow_water_multilayer_2d.jl#L394

Added line #L394 was not covered by tests
equations)
end

return flux
return flux, noncons_flux

Check warning on line 398 in src/equations/shallow_water_multilayer_2d.jl

View check run for this annotation

Codecov / codecov/patch

src/equations/shallow_water_multilayer_2d.jl#L398

Added line #L398 was not covered by tests
end

# Calculate 2D advective portion of the flux for a single point
Expand Down
17 changes: 13 additions & 4 deletions src/equations/shallow_water_two_layer_1d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,10 @@
"""
@inline function Trixi.boundary_condition_slip_wall(u_inner, orientation_or_normal,
direction,
x, t, surface_flux_function,
x, t, surface_flux_functions,
equations::ShallowWaterTwoLayerEquations1D)
surface_flux_function, nonconservative_flux_function = surface_flux_functions

Check warning on line 179 in src/equations/shallow_water_two_layer_1d.jl

View check run for this annotation

Codecov / codecov/patch

src/equations/shallow_water_two_layer_1d.jl#L179

Added line #L179 was not covered by tests

# create the "external" boundary solution state
u_boundary = SVector(u_inner[1],
-u_inner[2],
Expand All @@ -185,11 +187,18 @@

# calculate the boundary flux
if iseven(direction) # u_inner is "left" of boundary, u_boundary is "right" of boundary
f = surface_flux_function(u_inner, u_boundary, orientation_or_normal, equations)
flux = surface_flux_function(u_inner, u_boundary, orientation_or_normal,

Check warning on line 190 in src/equations/shallow_water_two_layer_1d.jl

View check run for this annotation

Codecov / codecov/patch

src/equations/shallow_water_two_layer_1d.jl#L190

Added line #L190 was not covered by tests
equations)
noncons_flux = nonconservative_flux_function(u_inner, u_boundary,

Check warning on line 192 in src/equations/shallow_water_two_layer_1d.jl

View check run for this annotation

Codecov / codecov/patch

src/equations/shallow_water_two_layer_1d.jl#L192

Added line #L192 was not covered by tests
orientation_or_normal, equations)
else # u_boundary is "left" of boundary, u_inner is "right" of boundary
f = surface_flux_function(u_boundary, u_inner, orientation_or_normal, equations)
flux = surface_flux_function(u_boundary, u_inner, orientation_or_normal,

Check warning on line 195 in src/equations/shallow_water_two_layer_1d.jl

View check run for this annotation

Codecov / codecov/patch

src/equations/shallow_water_two_layer_1d.jl#L195

Added line #L195 was not covered by tests
equations)
noncons_flux = nonconservative_flux_function(u_boundary, u_inner,

Check warning on line 197 in src/equations/shallow_water_two_layer_1d.jl

View check run for this annotation

Codecov / codecov/patch

src/equations/shallow_water_two_layer_1d.jl#L197

Added line #L197 was not covered by tests
orientation_or_normal, equations)
end
return f

return flux, noncons_flux

Check warning on line 201 in src/equations/shallow_water_two_layer_1d.jl

View check run for this annotation

Codecov / codecov/patch

src/equations/shallow_water_two_layer_1d.jl#L201

Added line #L201 was not covered by tests
end

# Calculate 1D flux for a single point
Expand Down
9 changes: 7 additions & 2 deletions src/equations/shallow_water_two_layer_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,10 @@
"""
@inline function Trixi.boundary_condition_slip_wall(u_inner,
normal_direction::AbstractVector,
x, t, surface_flux_function,
x, t, surface_flux_functions,
equations::ShallowWaterTwoLayerEquations2D)
surface_flux_function, nonconservative_flux_function = surface_flux_functions

Check warning on line 243 in src/equations/shallow_water_two_layer_2d.jl

View check run for this annotation

Codecov / codecov/patch

src/equations/shallow_water_two_layer_2d.jl#L243

Added line #L243 was not covered by tests

# normalize the outward pointing direction
normal = normal_direction / norm(normal_direction)

Expand All @@ -258,7 +260,10 @@

# calculate the boundary flux
flux = surface_flux_function(u_inner, u_boundary, normal_direction, equations)
return flux
noncons_flux = nonconservative_flux_function(u_inner, u_boundary, normal_direction,

Check warning on line 263 in src/equations/shallow_water_two_layer_2d.jl

View check run for this annotation

Codecov / codecov/patch

src/equations/shallow_water_two_layer_2d.jl#L263

Added line #L263 was not covered by tests
equations)

return flux, noncons_flux

Check warning on line 266 in src/equations/shallow_water_two_layer_2d.jl

View check run for this annotation

Codecov / codecov/patch

src/equations/shallow_water_two_layer_2d.jl#L266

Added line #L266 was not covered by tests
end

# Calculate 1D flux for a single point
Expand Down
12 changes: 10 additions & 2 deletions src/equations/shallow_water_wet_dry_1d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,10 @@
@inline function Trixi.boundary_condition_slip_wall(u_inner, orientation_or_normal,
direction,
x, t,
surface_flux_function,
surface_flux_functions,
equations::ShallowWaterEquationsWetDry1D)
surface_flux_function, nonconservative_flux_function = surface_flux_functions

Check warning on line 184 in src/equations/shallow_water_wet_dry_1d.jl

View check run for this annotation

Codecov / codecov/patch

src/equations/shallow_water_wet_dry_1d.jl#L184

Added line #L184 was not covered by tests

# This can not be dispatched, when Flux Hydrostactic reconstruction is used
# create the "external" boundary solution state
u_boundary = SVector(u_inner[1],
Expand All @@ -191,12 +193,18 @@
if iseven(direction) # u_inner is "left" of boundary, u_boundary is "right" of boundary
flux = surface_flux_function(u_inner, u_boundary, orientation_or_normal,
equations)
noncons_flux = nonconservative_flux_function(u_inner, u_boundary,

Check warning on line 196 in src/equations/shallow_water_wet_dry_1d.jl

View check run for this annotation

Codecov / codecov/patch

src/equations/shallow_water_wet_dry_1d.jl#L196

Added line #L196 was not covered by tests
orientation_or_normal,
equations)
else # u_boundary is "left" of boundary, u_inner is "right" of boundary
flux = surface_flux_function(u_boundary, u_inner, orientation_or_normal,
equations)
noncons_flux = nonconservative_flux_function(u_boundary, u_inner,

Check warning on line 202 in src/equations/shallow_water_wet_dry_1d.jl

View check run for this annotation

Codecov / codecov/patch

src/equations/shallow_water_wet_dry_1d.jl#L202

Added line #L202 was not covered by tests
orientation_or_normal,
equations)
end

return flux
return flux, noncons_flux

Check warning on line 207 in src/equations/shallow_water_wet_dry_1d.jl

View check run for this annotation

Codecov / codecov/patch

src/equations/shallow_water_wet_dry_1d.jl#L207

Added line #L207 was not covered by tests
end

# Calculate 1D flux for a single point
Expand Down
19 changes: 14 additions & 5 deletions src/equations/shallow_water_wet_dry_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,10 @@
@inline function Trixi.boundary_condition_slip_wall(u_inner,
normal_direction::AbstractVector,
x, t,
surface_flux_function,
surface_flux_functions,
equations::ShallowWaterEquationsWetDry2D)
surface_flux_function, nonconservative_flux_function = surface_flux_functions

Check warning on line 182 in src/equations/shallow_water_wet_dry_2d.jl

View check run for this annotation

Codecov / codecov/patch

src/equations/shallow_water_wet_dry_2d.jl#L182

Added line #L182 was not covered by tests

# normalize the outward pointing direction
normal = normal_direction / norm(normal_direction)

Expand All @@ -193,8 +195,9 @@

# calculate the boundary flux
flux = surface_flux_function(u_inner, u_boundary, normal_direction, equations)

return flux
noncons_flux = nonconservative_flux_function(u_inner, u_boundary, normal_direction,

Check warning on line 198 in src/equations/shallow_water_wet_dry_2d.jl

View check run for this annotation

Codecov / codecov/patch

src/equations/shallow_water_wet_dry_2d.jl#L198

Added line #L198 was not covered by tests
equations)
return flux, noncons_flux

Check warning on line 200 in src/equations/shallow_water_wet_dry_2d.jl

View check run for this annotation

Codecov / codecov/patch

src/equations/shallow_water_wet_dry_2d.jl#L200

Added line #L200 was not covered by tests
end

"""
Expand All @@ -205,8 +208,10 @@
"""
@inline function Trixi.boundary_condition_slip_wall(u_inner, orientation,
direction, x, t,
surface_flux_function,
surface_flux_functions,
equations::ShallowWaterEquationsWetDry2D)
surface_flux_function, nonconservative_flux_function = surface_flux_functions

Check warning on line 213 in src/equations/shallow_water_wet_dry_2d.jl

View check run for this annotation

Codecov / codecov/patch

src/equations/shallow_water_wet_dry_2d.jl#L213

Added line #L213 was not covered by tests

## get the appropriate normal vector from the orientation
if orientation == 1
u_boundary = SVector(u_inner[1], -u_inner[2], u_inner[3], u_inner[4])
Expand All @@ -217,11 +222,15 @@
# Calculate boundary flux
if iseven(direction) # u_inner is "left" of boundary, u_boundary is "right" of boundary
flux = surface_flux_function(u_inner, u_boundary, orientation, equations)
noncons_flux = nonconservative_flux_function(u_inner, u_boundary, orientation,

Check warning on line 225 in src/equations/shallow_water_wet_dry_2d.jl

View check run for this annotation

Codecov / codecov/patch

src/equations/shallow_water_wet_dry_2d.jl#L225

Added line #L225 was not covered by tests
equations)
else # u_boundary is "left" of boundary, u_inner is "right" of boundary
flux = surface_flux_function(u_boundary, u_inner, orientation, equations)
noncons_flux = nonconservative_flux_function(u_boundary, u_inner, orientation,

Check warning on line 229 in src/equations/shallow_water_wet_dry_2d.jl

View check run for this annotation

Codecov / codecov/patch

src/equations/shallow_water_wet_dry_2d.jl#L229

Added line #L229 was not covered by tests
equations)
end

return flux
return flux, noncons_flux

Check warning on line 233 in src/equations/shallow_water_wet_dry_2d.jl

View check run for this annotation

Codecov / codecov/patch

src/equations/shallow_water_wet_dry_2d.jl#L233

Added line #L233 was not covered by tests
end

# Calculate 1D flux for a single point
Expand Down
Loading