Skip to content

Commit

Permalink
fix convergence tests 3
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickersing committed Aug 12, 2024
1 parent a265e6e commit d2be6c5
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 93 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,46 +11,6 @@ equations = ShallowWaterExnerEquations1D(gravity_constant = 10.0, rho_f = 0.5,
friction = ManningFriction(n = 0.0),
sediment_model = GrassModel(A_g = 0.01))

# Smooth initial condition to test convergence
@inline function Trixi.initial_condition_convergence_test(x, t,
equations::ShallowWaterExnerEquations1D)
ω = sqrt(2) * pi

h = 2.0 + cos* x[1]) * cos* t)
v = 0.5
h_b = 2.0 + sin* x[1]) * cos* t)

return SVector(h, h * v, h_b)
end

# Source terms used for convergence tests in combination with [`initial_condition_convergence_test`](@extref)
# when using the the [`GrassModel`](@ref) model.
# To use this source term the equations must be set to:
#
# equations = ShallowWaterExnerEquations1D(gravity_constant = 10.0, rho_f = 0.5,
# rho_s = 1.0, porosity = 0.5,
# friction = ManningFriction(n = 0.0),
# sediment_model = GrassModel(A_g = 0.01)
@inline function Trixi.source_terms_convergence_test(u, x, t,
equations::ShallowWaterExnerEquations1D{T,
S,
GrassModel{T}}) where {
T,
S
}
ω = sqrt(2.0) * pi
A_g = equations.sediment_model.A_g

h = -cos(x[1] * ω) * sin(t * ω) * ω - 0.5 * sin(x[1] * ω) * cos(t * ω) * ω
hv = -0.5 * cos(x[1] * ω) * sin(t * ω) * ω - 0.25 * sin(x[1] * ω) * cos(t * ω) * ω +
10.0 * A_g *
(cos(x[1] * ω) * cos(t * ω) * ω - 0.5 * sin(x[1] * ω) * cos(t * ω) * ω) +
10.0 * (2.0 + cos(x[1] * ω) * cos(t * ω)) *
(cos(x[1] * ω) * cos(t * ω) * ω - sin(x[1] * ω) * cos(t * ω) * ω)
h_b = -sin(x[1] * ω) * sin(t * ω) * ω
return SVector(h, hv, h_b)
end

initial_condition = initial_condition_convergence_test

###############################################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,59 +12,6 @@ equations = ShallowWaterExnerEquations1D(gravity_constant = 10.0, rho_f = 0.5,
sediment_model = MeyerPeterMueller(theta_c = 0.0,
d_s = 1e-3))

# Smooth initial condition to test convergence
@inline function Trixi.initial_condition_convergence_test(x, t,
equations::ShallowWaterExnerEquations1D)
ω = sqrt(2) * pi

h = 2.0 + cos* x[1]) * cos* t)
v = 0.5
h_b = 2.0 + sin* x[1]) * cos* t)

return SVector(h, h * v, h_b)
end

# Source terms used for convergence tests in combination with [`Trixi.initial_condition_convergence_test`](@extref)
# when using the [`MeyerPeterMueller`](@ref) model.
# To use this source term the equations must be set to:
#
# equations = ShallowWaterExnerEquations1D(gravity_constant = 10.0, rho_f = 0.5,
# rho_s = 1.0, porosity = 0.5,
# friction = ManningFriction(n = 0.01),
# sediment_model = MeyerPeterMueller(theta_c = 0.0,
# d_s = 1e-3))
@inline function Trixi.source_terms_convergence_test(u, x, t,
equations::ShallowWaterExnerEquations1D{T,
S,
ShieldsStressModel{T}}) where {
T,
S
}
ω = sqrt(2.0) * pi
(; gravity, porosity_inv, rho_f, rho_s, r) = equations

n = equations.friction.n

# Constant expression from the MPM model
c = sqrt(gravity * (1 / r - 1)) * 8.0 * porosity_inv *
(rho_f / (rho_s - rho_f))^(3 / 2) * n^3

h = -cos(x[1] * ω) * sin(t * ω) * ω - 0.5 * sin(x[1] * ω) * cos(t * ω) * ω

hv = ((5.0 * c *
(cos(x[1] * ω) * cos(t * ω) * ω - 0.5 * sin(x[1] * ω) * cos(t * ω) * ω)) /
((2.0 + cos(x[1] * ω) * cos(t * ω))^0.5) - 0.5 * cos(x[1] * ω) * sin(t * ω) * ω -
0.25 * sin(x[1] * ω) * cos(t * ω) * ω +
10.0 * (2.0 + cos(x[1] * ω) * cos(t * ω)) *
(cos(x[1] * ω) * cos(t * ω) * ω - sin(x[1] * ω) * cos(t * ω) * ω))

h_b = ((0.5 * ((0.125 * c) / (2.0 + cos(x[1] * ω) * cos(t * ω))) * sin(x[1] * ω) *
cos(t * ω) * ω) / ((2.0 + cos(x[1] * ω) * cos(t * ω))^0.5) -
sin(x[1] * ω) * sin(t * ω) * ω)

return SVector(h, hv, h_b)
end

initial_condition = initial_condition_convergence_test

###############################################################################
Expand Down
100 changes: 100 additions & 0 deletions src/equations/shallow_water_exner_1d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,106 @@ For details see Section 9.2.5 of the book:
return flux
end

# Set initial conditions at physical location `x` for time `t`
"""
initial_condition_convergence_test(x, t, equations::ShallowWaterExnerEquations1D)
A smooth initial condition used for convergence tests in combination with
[`Trixi.source_terms_convergence_test`](@ref).
"""
@inline function Trixi.initial_condition_convergence_test(x, t,
equations::ShallowWaterExnerEquations1D)
ω = sqrt(2) * pi

h = 2.0 + cos* x[1]) * cos* t)
v = 0.5
h_b = 2.0 + sin* x[1]) * cos* t)

return SVector(h, h * v, h_b)
end

"""
source_terms_convergence_test(u, x, t, equations::ShallowWaterExnerEquations1D{T, S, GrassModel{T}}) where {T, S}
Source terms used for convergence tests in combination with [`Trixi.initial_condition_convergence_test`](@ref)
when using the the [`GrassModel`](@ref) model.
To use this source term the equations must be set to:
```julia
equations = ShallowWaterExnerEquations1D(gravity_constant = 10.0, rho_f = 0.5,
rho_s = 1.0, porosity = 0.5,
friction = ManningFriction(n = 0.0),
sediment_model = GrassModel(A_g = 0.01)
```
"""
@inline function Trixi.source_terms_convergence_test(u, x, t,
equations::ShallowWaterExnerEquations1D{T,
S,
GrassModel{T}}) where {
T,
S
}
ω = sqrt(2.0) * pi
A_g = equations.sediment_model.A_g

h = -cos(x[1] * ω) * sin(t * ω) * ω - 0.5 * sin(x[1] * ω) * cos(t * ω) * ω
hv = -0.5 * cos(x[1] * ω) * sin(t * ω) * ω - 0.25 * sin(x[1] * ω) * cos(t * ω) * ω +
10.0 * A_g *
(cos(x[1] * ω) * cos(t * ω) * ω - 0.5 * sin(x[1] * ω) * cos(t * ω) * ω) +
10.0 * (2.0 + cos(x[1] * ω) * cos(t * ω)) *
(cos(x[1] * ω) * cos(t * ω) * ω - sin(x[1] * ω) * cos(t * ω) * ω)
h_b = -sin(x[1] * ω) * sin(t * ω) * ω
return SVector(h, hv, h_b)
end

"""
source_terms_convergence_test(u, x, t, equations::ShallowWaterExnerEquations1D{T, S, ShieldsStressModel{T}}) where {T, S}
Source terms used for convergence tests in combination with [`Trixi.initial_condition_convergence_test`](@ref)
when using the [`MeyerPeterMueller`](@ref) model.
To use this source term the equations must be set to:
```julia
equations = ShallowWaterExnerEquations1D(gravity_constant = 10.0, rho_f = 0.5,
rho_s = 1.0, porosity = 0.5,
friction = ManningFriction(n = 0.01),
sediment_model = MeyerPeterMueller(theta_c = 0.0,
d_s = 1e-3))
```
"""
@inline function Trixi.source_terms_convergence_test(u, x, t,
equations::ShallowWaterExnerEquations1D{T,
S,
ShieldsStressModel{T}}) where {
T,
S
}
ω = sqrt(2.0) * pi
(; gravity, porosity_inv, rho_f, rho_s, r) = equations

n = equations.friction.n

# Constant expression from the MPM model
c = sqrt(gravity * (1 / r - 1)) * 8.0 * porosity_inv *
(rho_f / (rho_s - rho_f))^(3 / 2) * n^3

h = -cos(x[1] * ω) * sin(t * ω) * ω - 0.5 * sin(x[1] * ω) * cos(t * ω) * ω

hv = ((5.0 * c *
(cos(x[1] * ω) * cos(t * ω) * ω - 0.5 * sin(x[1] * ω) * cos(t * ω) * ω)) /
((2.0 + cos(x[1] * ω) * cos(t * ω))^0.5) -
0.5 * cos(x[1] * ω) * sin(t * ω) * ω -
0.25 * sin(x[1] * ω) * cos(t * ω) * ω +
10.0 * (2.0 + cos(x[1] * ω) * cos(t * ω)) *
(cos(x[1] * ω) * cos(t * ω) * ω - sin(x[1] * ω) * cos(t * ω) * ω))

h_b = ((0.5 * ((0.125 * c) / (2.0 + cos(x[1] * ω) * cos(t * ω))) * sin(x[1] * ω) *
cos(t * ω) * ω) / ((2.0 + cos(x[1] * ω) * cos(t * ω))^0.5) -
sin(x[1] * ω) * sin(t * ω) * ω)

return SVector(h, hv, h_b)
end

"""
source_term_bottom_friction(u, x, t, equations::ShallowWaterExnerEquations1D)
Expand Down

0 comments on commit d2be6c5

Please sign in to comment.