Skip to content

Commit

Permalink
Changed rho type
Browse files Browse the repository at this point in the history
  • Loading branch information
mehdiataei committed Sep 20, 2024
1 parent e6de337 commit 448883f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 17 deletions.
8 changes: 6 additions & 2 deletions xlb/operator/macroscopic/first_moment.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from xlb.compute_backend import ComputeBackend
from xlb.operator.operator import Operator


class FirstMoment(Operator):
"""A class to compute the first moment (velocity) of distribution functions."""

Expand All @@ -22,7 +23,10 @@ def _construct_warp(self):
_u_vec = wp.vec(self.velocity_set.d, dtype=self.compute_dtype)

@wp.func
def functional(f: _f_vec, rho: float):
def functional(
f: _f_vec,
rho: Any,
):
u = _u_vec()
for l in range(self.velocity_set.q):
for d in range(self.velocity_set.d):
Expand Down Expand Up @@ -80,4 +84,4 @@ def warp_implementation(self, f, rho, u):
inputs=[f, rho, u],
dim=u.shape[1:],
)
return u
return u
3 changes: 2 additions & 1 deletion xlb/operator/macroscopic/macroscopic.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from xlb.operator.macroscopic.zero_moment import ZeroMoment
from xlb.operator.macroscopic.first_moment import FirstMoment


class Macroscopic(Operator):
"""A class to compute both zero and first moments of distribution functions (rho, u)."""

Expand Down Expand Up @@ -82,4 +83,4 @@ def warp_implementation(self, f, rho, u):
inputs=[f, rho, u],
dim=rho.shape[1:],
)
return rho, u
return rho, u
9 changes: 1 addition & 8 deletions xlb/operator/macroscopic/second_moment.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,5 @@ def kernel2d(
@Operator.register_backend(ComputeBackend.WARP)
def warp_implementation(self, f, pi):
# Launch the warp kernel
wp.launch(
self.warp_kernel,
inputs=[
f,
pi,
],
dim=pi.shape[1:],
)
wp.launch(self.warp_kernel, inputs=[f, pi], dim=pi.shape[1:])
return pi
9 changes: 3 additions & 6 deletions xlb/operator/macroscopic/zero_moment.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from xlb.compute_backend import ComputeBackend
from xlb.operator.operator import Operator


class ZeroMoment(Operator):
"""A class to compute the zeroth moment (density) of distribution functions."""

Expand Down Expand Up @@ -61,9 +62,5 @@ def kernel2d(

@Operator.register_backend(ComputeBackend.WARP)
def warp_implementation(self, f, rho):
wp.launch(
self.warp_kernel,
inputs=[f, rho],
dim=rho.shape[1:],
)
return rho
wp.launch(self.warp_kernel, inputs=[f, rho], dim=rho.shape[1:])
return rho

0 comments on commit 448883f

Please sign in to comment.