Skip to content

Commit aba4ce8

Browse files
committed
shallow-water: exclude jit compilation from timing
1 parent 048f1c6 commit aba4ce8

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

examples/shallow_water.py

+12-8
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,6 @@ def bathymetry(x_t_2d, y_t_2d, lx, ly):
204204
bath = 1.0
205205
return bath * create_full(T_shape, 1.0, dtype)
206206

207-
# inital elevation
208-
u0, v0, e0 = exact_solution(
209-
0, x_t_2d, y_t_2d, x_u_2d, y_u_2d, x_v_2d, y_v_2d
210-
)
211-
e[:, :] = e0
212-
u[:, :] = u0
213-
v[:, :] = v0
214-
215207
# set bathymetry
216208
h[:, :] = bathymetry(x_t_2d, y_t_2d, lx, ly)
217209
# steady state potential energy
@@ -328,6 +320,18 @@ def step(u, v, e, u1, v1, e1, u2, v2, e2):
328320
v[:, 1:-1] = v[:, 1:-1] / 3.0 + 2.0 / 3.0 * (v2[:, 1:-1] + dt * dvdt)
329321
e[:, :] = e[:, :] / 3.0 + 2.0 / 3.0 * (e2[:, :] + dt * dedt)
330322

323+
# warm up jit cache
324+
step(u, v, e, u1, v1, e1, u2, v2, e2)
325+
sync()
326+
327+
# initial solution
328+
u0, v0, e0 = exact_solution(
329+
0, x_t_2d, y_t_2d, x_u_2d, y_u_2d, x_v_2d, y_v_2d
330+
)
331+
e[:, :] = e0
332+
u[:, :] = u0
333+
v[:, :] = v0
334+
331335
t = 0
332336
i_export = 0
333337
next_t_export = 0

0 commit comments

Comments
 (0)