Skip to content

Commit 1fb0445

Browse files
committed
note on method derived by Marco
1 parent e2ca9df commit 1fb0445

File tree

2 files changed

+88
-76
lines changed

2 files changed

+88
-76
lines changed

src/equations/hyperbolic_sainte_marie_1d.jl

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ References for the Sainte-Marie system and its hyperbolization can be found in
6666
The energy-conserving semidiscretization is basically taken from the
6767
following reference, but adapted to the standard style of
6868
DispersiveShallowWater.jl to use the primitive variables `q = (η, v, D, w, p)`.
69+
The semidiscretization implemented here is derived from their method with parameters ``\alpha_1 = 2``, ``\alpha_2 = 0``, ``\alpha_3 = 0``, and ``\alpha_4 = 0``.
6970
- Artiano and Ranocha (2026)
7071
On Affordable High-Order Entropy-Conservative/Stable and
7172
Well-Balanced Methods for Nonconservative Hyperbolic Systems
@@ -227,14 +228,15 @@ function create_cache(mesh, equations::HyperbolicSainteMarieEquations1D,
227228
v2_x = DiffCache(zero(template), N)
228229
h_hpb_x = DiffCache(zero(template), N)
229230
w_x = DiffCache(zero(template), N)
230-
hvw_x = DiffCache(zero(template), N)
231+
hw_x = DiffCache(zero(template), N)
232+
vw_x = DiffCache(zero(template), N)
231233
p_x = DiffCache(zero(template), N)
232234
hp_x = DiffCache(zero(template), N)
233-
hvp_x = DiffCache(zero(template), N)
235+
vp_x = DiffCache(zero(template), N)
234236
tmp = DiffCache(zero(template), N)
235237

236238
cache = (; h, b, b_x, h_x, v_x, hv_x, v2_x, h_hpb_x,
237-
w_x, hvw_x, p_x, hp_x, hvp_x, tmp)
239+
w_x, hw_x, vw_x, p_x, hp_x, vp_x, tmp)
238240
return cache
239241
end
240242

@@ -276,10 +278,11 @@ function rhs!(dq, q, t, mesh,
276278
v2_x = get_tmp(cache.v2_x, eta)
277279
h_hpb_x = get_tmp(cache.h_hpb_x, eta)
278280
w_x = get_tmp(cache.w_x, eta)
279-
hvw_x = get_tmp(cache.hvw_x, eta)
281+
hw_x = get_tmp(cache.hw_x, eta)
282+
vw_x = get_tmp(cache.vw_x, eta)
280283
p_x = get_tmp(cache.p_x, eta)
281284
hp_x = get_tmp(cache.hp_x, eta)
282-
hvp_x = get_tmp(cache.hvp_x, eta)
285+
vp_x = get_tmp(cache.vp_x, eta)
283286
tmp = get_tmp(cache.tmp, eta)
284287

285288
@.. b = equations.eta0 - D
@@ -309,9 +312,13 @@ function rhs!(dq, q, t, mesh,
309312
# w_x = D1 * w
310313
mul!(w_x, D1, w)
311314

312-
# hvw_x = D1 * (h * v * w)
313-
@.. tmp = h * v * w
314-
mul!(hvw_x, D1, tmp)
315+
# hw_x = D1 * (h * w)
316+
@.. tmp = h * w
317+
mul!(hw_x, D1, tmp)
318+
319+
# vw_x = D1 * (v * w)
320+
@.. tmp = v * w
321+
mul!(vw_x, D1, tmp)
315322

316323
# p_x = D1 * p
317324
mul!(p_x, D1, p)
@@ -320,9 +327,9 @@ function rhs!(dq, q, t, mesh,
320327
@.. tmp = h * p
321328
mul!(hp_x, D1, tmp)
322329

323-
# hvp_x = D1 * (h * v * p)
324-
@.. tmp = h * v * p
325-
mul!(hvp_x, D1, tmp)
330+
# vp_x = D1 * (v * p)
331+
@.. tmp = v * p
332+
mul!(vp_x, D1, tmp)
326333

327334
# Plain: h_t + (h v)_x = 0
328335
#
@@ -351,18 +358,18 @@ function rhs!(dq, q, t, mesh,
351358
# Plain: h w_t + h v w_x = 2 p
352359
#
353360
# Split form for energy conservation:
354-
# h w_t + 1/2 (h v w)_x + 1/2 h v w_x
355-
# - 1/2 h_x v w - 1/2 h w v_x = 2 p
356-
@.. dw = (-0.5 * (hvw_x + h * v * w_x + dh * w) + 2 * p) / h
361+
# h w_t + 1/2 h (v w)_x + 1/2 v (h w)_x
362+
# - 1/2 h_x v w - 1/2 h v_x w = 2 p
363+
@.. dw = (-0.5 * (h * vw_x + v * hw_x + dh * w) + 2 * p) / h
357364

358365
# Plain: h p_t + ...
359366
#
360367
# Split form for energy conservation:
361-
# h p_t + 1/2 (h v p)_x + 1/2 h v p_x
368+
# h p_t + 1/2 h (v p)_x + 1/2 v (h p)_x
362369
# - 1/2 h_x v p - 1/2 h v_x p
363370
# + c^2 h v_x + 2 c^2 w
364371
# - 2 c^2 v b_x = 0
365-
@.. dp = (-0.5 * (hvp_x + h * v * p_x + dh * p)
372+
@.. dp = (-0.5 * (h * vp_x + v * hp_x + dh * p)
366373
-
367374
c_squared * h * v_x - 2 * c_squared * w
368375
+

test/test_hyperbolic_sainte_marie_1d.jl

Lines changed: 65 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,33 @@ end
88
] begin
99
@test_trixi_include(joinpath(EXAMPLES_DIR,
1010
"hyperbolic_sainte_marie_conservation.jl"),
11+
tol=1.0e-12,
12+
tspan=(0.0, 1.0),
1113
l2=[
12-
1.3572594173842452,
13-
2.3633832882065207,
14-
3.565537895102537e-14,
15-
0.4622560613787918,
16-
0.6144540736230862
14+
1.423280412274356,
15+
2.3685775546329264,
16+
7.26695561732344e-15,
17+
0.7778533080445147,
18+
3.4060674733738088
1719
],
1820
linf=[
19-
1.001198219224467,
20-
0.877550505633545,
21-
9.325873406851315e-15,
22-
0.16699894605274684,
23-
0.27183886706644345
21+
1.1050866054400976,
22+
1.150984157070933,
23+
2.1371793224034263e-15,
24+
0.47878548301312557,
25+
1.8555275982418526
2426
],
2527
cons_error=[
26-
5.0874859880423173e-11,
27-
0.00044041183843157583,
28-
4.547473508864641e-13,
29-
0.021403100433988752,
30-
0.028407093718690702
28+
8.560050446249079e-10,
29+
2.8723044393164088e-5,
30+
1.6986412276764894e-15,
31+
0.4680239632418549,
32+
8.59621928160862
3133
],
32-
change_entropy=-0.2400751754171324,
33-
change_entropy_modified=-0.12689501571117034,
34-
atol=1e-8) # to make CI pass
34+
change_waterheight=-8.560050446249079e-10,
35+
change_momentum=-0.000768001258112605,
36+
change_entropy=-0.36374450470134434,
37+
change_entropy_modified=-8.867345968610607e-9)
3538

3639
@test_allocations(DispersiveShallowWater.rhs!, semi, sol, allocs=1_000)
3740
end
@@ -47,30 +50,30 @@ end
4750
tol=1.0e-12,
4851
tspan=(0.0, 1.0),
4952
l2=[
50-
1.4883751342392053,
51-
2.0240715489993337,
52-
5.384295521873979e-14,
53-
0.851823022172266,
54-
4.021158410315962
53+
1.488406724541389,
54+
2.024017579537045,
55+
0.0,
56+
0.8522342446876735,
57+
4.0229842125125765
5558
],
5659
linf=[
57-
1.1622352722043399,
58-
0.996970504640431,
59-
3.1086244689504383e-15,
60-
0.3985082548812433,
61-
1.798277246494875
60+
1.1623280008399592,
61+
0.9969234037889885,
62+
0.0,
63+
0.3984623461616125,
64+
1.799637261193249
6265
],
6366
cons_error=[
6467
8.105871529551223e-11,
65-
2.036050215359353e-5,
66-
1.7053025658242404e-13,
67-
1.1013360423538034,
68-
7.893957675920978
68+
2.0319512388233818e-5,
69+
0.0,
70+
1.1009759246326063,
71+
7.8970857389160445
6972
],
7073
change_waterheight=-8.105871529551223e-11,
71-
change_momentum=-1.730615650785694e-12,
72-
change_entropy=-0.5373666791674623,
73-
change_entropy_modified=-1.317857822868973e-9)
74+
change_momentum=-1.7186252421197423e-12,
75+
change_entropy=-0.5378173222520672,
76+
change_entropy_modified=-1.3169483281672e-9)
7477

7578
@test_allocations(DispersiveShallowWater.rhs!, semi, sol, allocs=1_000)
7679
end
@@ -83,28 +86,30 @@ end
8386
"hyperbolic_sainte_marie_dingemans.jl"),
8487
tspan=(0.0, 1.0),
8588
l2=[
86-
0.2664324191809125,
87-
0.8758998976555538,
89+
0.26643241429880193,
90+
0.8758998593861568,
8891
5.277989040277512e-15,
89-
0.29779046756774213,
90-
0.13247677055242074
92+
0.2977904521550398,
93+
0.1324767069050882
9194
],
9295
linf=[
93-
0.036527826201786406,
94-
0.1194334643284359,
96+
0.03652784253085728,
97+
0.11943351601871774,
9598
5.662137425588298e-15,
96-
0.0401503049607073,
97-
0.03575050307041049
99+
0.04015026702892366,
100+
0.03575062143105756
98101
],
99102
cons_error=[
100103
3.126388037344441e-12,
101-
0.00028199575312887545,
104+
0.00028199582134299866,
102105
0.0,
103-
0.016515613345694284,
104-
0.15898674767011647
106+
0.01651557336722678,
107+
0.15898659132614137
105108
],
106-
change_entropy=-0.0007378821217116638,
107-
change_entropy_modified=-7.357332378887804e-7)
109+
change_waterheight=-3.126388037344441e-12,
110+
change_momentum=-3.527300661276822e-8,
111+
change_entropy=-0.0007378805827329415,
112+
change_entropy_modified=-7.357333515756181e-7)
108113

109114
@test_allocations(DispersiveShallowWater.rhs!, semi, sol, allocs=1_000)
110115
end
@@ -119,25 +124,25 @@ end
119124
abstol=1.0e-12,
120125
reltol=1.0e-12,
121126
l2=[
122-
0.0002526491112439893,
123-
4.265020844341071e-5,
127+
0.00019537168346170865,
128+
3.453172345767322e-5,
124129
0.0,
125-
0.003292453459222419,
126-
0.00241787560897696
130+
0.002547202021354868,
131+
0.001859407766133216
127132
],
128133
linf=[
129-
0.00041358127213175777,
130-
8.13234414983599e-5,
134+
0.0003058377491629294,
135+
6.150206698318783e-5,
131136
0.0,
132-
0.005705816045885159,
133-
0.003909190784468386
137+
0.004072090053441002,
138+
0.0030164198069354553
134139
],
135140
cons_error=[
141+
4.440892098500626e-16,
142+
1.4747533280490277e-5,
136143
0.0,
137-
1.1119366118657048e-5,
138-
0.0,
139-
0.49366652485721385,
140-
4.926381115504918e-5
144+
0.4936130523192781,
145+
0.0001957021433037043
141146
])
142147

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

0 commit comments

Comments
 (0)