Skip to content

Commit 4598afe

Browse files
committed
manufactured solution for flat bathymetry
1 parent 3ab62ac commit 4598afe

File tree

2 files changed

+38
-26
lines changed

2 files changed

+38
-26
lines changed

src/equations/hyperbolic_sainte_marie_1d.jl

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,15 @@ function initial_condition_manufactured(x, t,
164164
b = -5
165165
# h = eta - b = 7 + cospi(2 * (x - 2 * t))
166166
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)
167+
# w = -h v_x / 2 + v b_x = -h v_x / 2
168+
w = -pi * cospi(t - 2 * x) * (7 + cospi(2 * (x - 2 * t)))
170169
else
171170
b = -5 - 2 * cospi(2 * x)
172171
# h = eta - b = 7 + 2 * cospi(2 * x) + cospi(2 * (x - 2 * t))
173172
D = equations.eta0 - b
174173
# w = -h v_x / 2 + v b_x
175-
w = -pi * cospi(t - 2 * x) * (7 + cospi(2 * (x - 2 * t)))
174+
w = -pi * cospi(t - 2 * x) * (7 + 2 * cospi(2 * x) + cospi(2 * (x - 2 * t))) -
175+
4 * pi * sinpi(t - 2 * x) * sinpi(2 * x)
176176
end
177177
p = cospi(2 * x - 3 * t)
178178
return SVector(eta, v, D, w, p)
@@ -191,17 +191,29 @@ function source_terms_manufactured(q, x, t,
191191

192192
if equations.bathymetry_type isa BathymetryFlat
193193
# 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)))
194+
a2 = cospi(t - 2 * x)
195+
a3 = cospi(5 * t - 4 * x)
196+
a4 = sinpi(4 * t - 2 * x)
197+
a5 = cospi(3 * t - 2 * x)
198+
a8 = sinpi(t - 2 * x)
199+
a9 = sinpi(3 * t - 2 * x)
200+
a10 = cospi(4 * t - 2 * x)
201+
a13 = sinpi(5 * t - 4 * x)
202+
a15 = 7 + a10
203+
a16 = sinpi(2 * (t - 2 * x))
204+
a17 = sinpi(4 * (x - 2 * t))
205+
a18 = sinpi(6 * (x - t))
206+
a19 = sinpi(2 * (t + x))
207+
a20 = sinpi(7 * t - 4 * x)
208+
a21 = cospi(3 * t)
209+
210+
s1 = 2 * pi * (7 * a2 + a3 - 2 * a4)
211+
s2 = -pi / 2 *
212+
(a21 + 14 * a2 + a3 + 14 * a16 - 28 * g * a4 + 2 * g * a17 - a18 - a19 -
213+
28 * a9 - 4 * a20) / a15
199214
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))
215+
s4 = -2 * a5 / a15 + pi_2 * (14 * a8^2 + 4 * a2 * a4 + a8 * (a15 + 2 * a13))
216+
s5 = -pi * (3 + 2 * a8) * a9
205217
else
206218
# Source terms for variable bathymetry
207219
a1 = cospi(t - 4 * x)

test/test_hyperbolic_sainte_marie_1d.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -159,25 +159,25 @@ end
159159
abstol=1.0e-12,
160160
reltol=1.0e-12,
161161
l2=[
162-
0.00019537168346170865,
163-
3.453172345767322e-5,
162+
5.523682478151583e-5,
163+
2.2904928037377655e-5,
164164
0.0,
165-
0.002547202021354868,
166-
0.001859407766133216
165+
0.0007163282391786536,
166+
0.0005017750313044287
167167
],
168168
linf=[
169-
0.0003058377491629294,
170-
6.150206698318783e-5,
169+
9.87142981752065e-5,
170+
3.7839638703074385e-5,
171171
0.0,
172-
0.004072090053441002,
173-
0.0030164198069354553
172+
0.0013307590180882123,
173+
0.0009464535129504181
174174
],
175175
cons_error=[
176-
4.440892098500626e-16,
177-
1.4747533280490277e-5,
178176
0.0,
179-
0.4936130523192781,
180-
0.0001957021433037043
177+
2.567887582648476e-6,
178+
0.0,
179+
0.6474616401127097,
180+
6.388777581955773e-5
181181
])
182182

183183
@test_allocations(DispersiveShallowWater.rhs!, semi, sol, allocs=1_000)

0 commit comments

Comments
 (0)