Skip to content

Commit

Permalink
Fix norm logging in advection, Maxwell examples for device scalars
Browse files Browse the repository at this point in the history
  • Loading branch information
inducer committed Jul 3, 2021
1 parent 0d66c79 commit 1c44c4b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions examples/advection/surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def rhs(t, u):
dt_stepper = set_up_rk4("u", dt, u0, rhs)
plot = Plotter(actx, dcoll, order, visualize=visualize)

norm_u = op.norm(dcoll, u0, 2)
norm_u = actx.to_numpy(op.norm(dcoll, u0, 2))

step = 0

Expand Down Expand Up @@ -251,7 +251,7 @@ def rhs(t, u):

step += 1
if step % 10 == 0:
norm_u = op.norm(dcoll, event.state_component, 2)
norm_u = actx.to_numpy(op.norm(dcoll, event.state_component, 2))
plot(event, "fld-surface-%04d" % step)

logger.info("[%04d] t = %.5f |u| = %.5e", step, event.t, norm_u)
Expand Down
2 changes: 1 addition & 1 deletion examples/advection/var-velocity.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def rhs(t, u):
continue

if step % 10 == 0:
norm_u = op.norm(dcoll, event.state_component, 2)
norm_u = actx.to_numpy(op.norm(dcoll, event.state_component, 2))
plot(event, "fld-var-velocity-%04d" % step)

step += 1
Expand Down
2 changes: 1 addition & 1 deletion examples/advection/weak.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def rhs(t, u):
continue

if step % 10 == 0:
norm_u = op.norm(dcoll, event.state_component, 2)
norm_u = actx.to_numpy(op.norm(dcoll, event.state_component, 2))
plot(event, "fld-weak-%04d" % step)

step += 1
Expand Down
8 changes: 4 additions & 4 deletions examples/maxwell/cavities.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ def norm(u):
step += 1
e, h = maxwell_operator.split_eh(event.state_component)

norm_e0 = norm(u=e[0])
norm_e1 = norm(u=e[1])
norm_h0 = norm(u=h[0])
norm_h1 = norm(u=h[1])
norm_e0 = actx.to_numpy(norm(u=e[0]))
norm_e1 = actx.to_numpy(norm(u=e[1]))
norm_h0 = actx.to_numpy(norm(u=h[0]))
norm_h1 = actx.to_numpy(norm(u=h[1]))

logger.info(
"[%04d] t = %.5f |e0| = %.5e, |e1| = %.5e, |h0| = %.5e, |h1| = %.5e",
Expand Down

0 comments on commit 1c44c4b

Please sign in to comment.