Skip to content

Commit

Permalink
CI: modernize the freezes on DOFArrays
Browse files Browse the repository at this point in the history
  • Loading branch information
kaushikcfd committed May 13, 2022
1 parent e28071d commit 70d61a2
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions test/test_arraycontext.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
ArrayContext,
dataclass_array_container, with_container_arithmetic,
serialize_container, deserialize_container,
freeze, thaw,
freeze, thaw, with_array_context,
FirstAxisIsElementsTag,
PyOpenCLArrayContext,
PytatoPyOpenCLArrayContext,
Expand Down Expand Up @@ -188,22 +188,9 @@ def _raise_index_inconsistency(i, stream_i):
for i, (stream_i, v) in enumerate(iterable)))


@freeze.register(DOFArray)
def _freeze_dofarray(ary, actx=None):
assert actx is None
return type(ary)(
None,
tuple(ary.array_context.freeze(subary) for subary in ary.data))


@thaw.register(DOFArray)
def _thaw_dofarray(ary, actx):
if ary.array_context is not None:
raise ValueError("cannot thaw DOFArray that already has an array context")

return type(ary)(
actx,
tuple(actx.thaw(subary) for subary in ary.data))
@with_array_context.register(DOFArray)
def _with_actx_dofarray(ary, actx):
return type(ary)(actx, ary.data)

# }}}

Expand Down Expand Up @@ -1200,6 +1187,11 @@ class Velocity2D:
array_context: ArrayContext


@with_array_context.register(Velocity2D)
def _with_actx_velocity_2d(ary, actx):
return type(ary)(ary.u, ary.v, actx)


def scale_and_orthogonalize(alpha, vel):
from arraycontext import rec_map_array_container
actx = vel.array_context
Expand Down

0 comments on commit 70d61a2

Please sign in to comment.