Skip to content

Commit 3ab62ac

Browse files
committed
WIP
1 parent 5d50490 commit 3ab62ac

File tree

2 files changed

+86
-28
lines changed

2 files changed

+86
-28
lines changed

src/equations/hyperbolic_sainte_marie_1d.jl

Lines changed: 51 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,21 @@ function initial_condition_manufactured(x, t,
159159
equations::HyperbolicSainteMarieEquations1D,
160160
mesh)
161161
eta = 2 + cospi(2 * (x - 2 * t))
162-
b = -5 - 2 * cospi(2 * x)
163-
# h = eta - b = 7 + 2 * cospi(2 * x) + cospi(2 * (x - 2 * t))
164162
v = sinpi(2 * (x - t / 2))
165-
D = equations.eta0 - b
166-
# w = -h v_x / 2 + v b_x
167-
w = -pi * cospi(t - 2 * x) * (7 + 2 * cospi(2 * x) + cospi(2 * (x - 2 * t))) -
168-
4 * pi * sinpi(t - 2 * x) * sinpi(2 * x)
163+
if equations.bathymetry_type isa BathymetryFlat
164+
b = -5
165+
# h = eta - b = 7 + cospi(2 * (x - 2 * t))
166+
D = equations.eta0 - b
167+
# w = -h v_x / 2 + v b_x
168+
w = -pi * cospi(t - 2 * x) * (7 + 2 * cospi(2 * x) + cospi(2 * (x - 2 * t))) -
169+
4 * pi * sinpi(t - 2 * x) * sinpi(2 * x)
170+
else
171+
b = -5 - 2 * cospi(2 * x)
172+
# h = eta - b = 7 + 2 * cospi(2 * x) + cospi(2 * (x - 2 * t))
173+
D = equations.eta0 - b
174+
# w = -h v_x / 2 + v b_x
175+
w = -pi * cospi(t - 2 * x) * (7 + cospi(2 * (x - 2 * t)))
176+
end
169177
p = cospi(2 * x - 3 * t)
170178
return SVector(eta, v, D, w, p)
171179
end
@@ -181,28 +189,43 @@ function source_terms_manufactured(q, x, t,
181189
g = gravity(equations)
182190
pi_2 = pi^2
183191

184-
a1 = cospi(t - 4 * x)
185-
a2 = cospi(t - 2 * x)
186-
a3 = cospi(5 * t - 4 * x)
187-
a4 = sinpi(4 * t - 2 * x)
188-
a5 = cospi(3 * t - 2 * x)
189-
a6 = sinpi(2 * x)
190-
a7 = cospi(2 * x)
191-
a8 = sinpi(t - 2 * x)
192-
a9 = sinpi(3 * t - 2 * x)
193-
a10 = cospi(4 * t - 2 * x)
194-
a11 = sinpi(4 * x - 2 * t)
195-
a12 = sinpi(t - 4 * x)
196-
a13 = sinpi(5 * t - 4 * x)
197-
a14 = (7 + 2 * a7 + a10)
198-
199-
# Source terms for variable bathymetry
200-
s1 = 2 * pi * (2 * a1 + 7 * a2 + a3 - 2 * a4)
201-
s2 = pi * (-a2 + a5 * (4 * a6 + 2 * a4) / a14 + 2 * g * a4 + a11 + 2 * a9)
202-
s3 = zero(s1)
203-
s4 = -2 * a5 / a14 +
204-
pi_2 * (14 * a8^2 - 4 * a2 * (a6 - a4) + a8 * (a14 + 12 * a12 + 2 * a13))
205-
s5 = -pi * (3 + 2 * a8) * a9
192+
if equations.bathymetry_type isa BathymetryFlat
193+
# Source terms for flat bathymetry
194+
s1 = 2*Pi*(7*Cos(Pi*(t - 2*x)) + Cos(5*Pi*t - 4*Pi*x) + 2*Sin(2*Pi*(-2*t + x)))
195+
s2 = -0.5*(Pi*(Cos(3*Pi*t) + 14*Cos(Pi*(t - 2*x)) + Cos(5*Pi*t - 4*Pi*x) +
196+
14*Sin(2*Pi*(t - 2*x)) + 28*g*Sin(2*Pi*(-2*t + x)) + 2*g*Sin(4*Pi*(-2*t + x)) -
197+
Sin(6*Pi*(-t + x)) - Sin(2*Pi*(t + x)) + 28*Sin(Pi*(-3*t + 2*x)) -
198+
4*Sin(7*Pi*t - 4*Pi*x)))/(7 + Cos(2*Pi*(-2*t + x)))
199+
s3 = zero(s1)
200+
s4 = (-2*Cos(3*Pi*t - 2*Pi*x))/(7 + Cos(2*Pi*(-2*t + x))) +
201+
Power(Pi,2)*(14*Power(Sin(Pi*(t - 2*x)),2) -
202+
4*Cos(Pi*(t - 2*x))*Sin(2*Pi*(-2*t + x)) +
203+
Sin(Pi*(t - 2*x))*(7 + Cos(2*Pi*(-2*t + x)) + 2*Sin(5*Pi*t - 4*Pi*x)))
204+
s5 = Pi*(3 + 2*Sin(Pi*(t - 2*x)))*Sin(Pi*(-3*t + 2*x))
205+
else
206+
# Source terms for variable bathymetry
207+
a1 = cospi(t - 4 * x)
208+
a2 = cospi(t - 2 * x)
209+
a3 = cospi(5 * t - 4 * x)
210+
a4 = sinpi(4 * t - 2 * x)
211+
a5 = cospi(3 * t - 2 * x)
212+
a6 = sinpi(2 * x)
213+
a7 = cospi(2 * x)
214+
a8 = sinpi(t - 2 * x)
215+
a9 = sinpi(3 * t - 2 * x)
216+
a10 = cospi(4 * t - 2 * x)
217+
a11 = sinpi(4 * x - 2 * t)
218+
a12 = sinpi(t - 4 * x)
219+
a13 = sinpi(5 * t - 4 * x)
220+
a14 = (7 + 2 * a7 + a10)
221+
222+
s1 = 2 * pi * (2 * a1 + 7 * a2 + a3 - 2 * a4)
223+
s2 = pi * (-a2 + a5 * (4 * a6 + 2 * a4) / a14 + 2 * g * a4 + a11 + 2 * a9)
224+
s3 = zero(s1)
225+
s4 = -2 * a5 / a14 +
226+
pi_2 * (14 * a8^2 - 4 * a2 * (a6 - a4) + a8 * (a14 + 12 * a12 + 2 * a13))
227+
s5 = -pi * (3 + 2 * a8) * a9
228+
end
206229

207230
return SVector(s1, s2, s3, s4, s5)
208231
end

test/test_hyperbolic_sainte_marie_1d.jl

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,38 @@ end
147147

148148
@test_allocations(DispersiveShallowWater.rhs!, semi, sol, allocs=1_000)
149149
end
150+
151+
@testitem "hyperbolic_sainte_marie_manufactured.jl with bathymetry_flat" setup=[
152+
Setup,
153+
HyperbolicSainteMarieEquations1D
154+
] begin
155+
@test_trixi_include(joinpath(EXAMPLES_DIR,
156+
"hyperbolic_sainte_marie_manufactured.jl"),
157+
bathymetry_type=bathymetry_flat,
158+
tspan=(0.0, 0.1),
159+
abstol=1.0e-12,
160+
reltol=1.0e-12,
161+
l2=[
162+
0.00019537168346170865,
163+
3.453172345767322e-5,
164+
0.0,
165+
0.002547202021354868,
166+
0.001859407766133216
167+
],
168+
linf=[
169+
0.0003058377491629294,
170+
6.150206698318783e-5,
171+
0.0,
172+
0.004072090053441002,
173+
0.0030164198069354553
174+
],
175+
cons_error=[
176+
4.440892098500626e-16,
177+
1.4747533280490277e-5,
178+
0.0,
179+
0.4936130523192781,
180+
0.0001957021433037043
181+
])
182+
183+
@test_allocations(DispersiveShallowWater.rhs!, semi, sol, allocs=1_000)
184+
end

0 commit comments

Comments
 (0)