Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed a bug in bc and kbc (Warp) that emerged after merging 2d and 3d… #83

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 21 additions & 23 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,30 @@
from setuptools import setup, find_packages

setup(
name='xlb',
version='0.2.1',
description='XLB: Accelerated Lattice Boltzmann (XLB) for Physics-based ML',
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
author='Mehdi Ataei',
url='https://github.com/Autodesk/XLB',
license='Apache License 2.0',
name="xlb",
version="0.2.1",
description="XLB: Accelerated Lattice Boltzmann (XLB) for Physics-based ML",
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
author="XLB Team",
url="https://github.com/Autodesk/XLB",
license="Apache License 2.0",
packages=find_packages(),
install_requires=[
'matplotlib>=3.9.2',
'numpy>=2.1.2',
'pyvista>=0.44.1',
'trimesh>=4.4.9',
'warp-lang>=1.4.0',
'numpy-stl>=3.1.2',
'pydantic>=2.9.1',
'ruff>=0.6.5',
'jax>=0.4.34' # Base JAX CPU-only requirement
"matplotlib>=3.9.2",
"numpy>=2.1.2",
"pyvista>=0.44.1",
"trimesh>=4.4.9",
"warp-lang>=1.4.0",
"numpy-stl>=3.1.2",
"pydantic>=2.9.1",
"ruff>=0.6.5",
"jax>=0.4.34", # Base JAX CPU-only requirement
],
extras_require={
'cuda': ['jax[cuda12]>=0.4.34'], # For CUDA installations
'tpu': ['jax[tpu]>=0.4.34'], # For TPU installations
"cuda": ["jax[cuda12]>=0.4.34"], # For CUDA installations
"tpu": ["jax[tpu]>=0.4.34"], # For TPU installations
},
python_requires='>=3.10',
dependency_links=[
'https://storage.googleapis.com/jax-releases/libtpu_releases.html'
],
python_requires=">=3.10",
dependency_links=["https://storage.googleapis.com/jax-releases/libtpu_releases.html"],

Check notice on line 29 in setup.py

View check run for this annotation

Autodesk Chorus / privacy/bearer

external_service.third_party: Google Cloud APIs

This check is currently in beta. - Personal Data at Autodesk: https://share.autodesk.com/:b:/r/sites/LegalTopicsToolkits/Shared%20Documents/Personal%20Data%20at%20Autodesk.pdf - Data Privacy & Governance Policies at Autodesk: https://share.autodesk.com/sites/DPG/SitePages/Policies-%26-Guidelines.aspx
)
10 changes: 6 additions & 4 deletions tests/boundary_conditions/mask/test_bc_indices_masker_warp.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ def test_indices_masker_warp(dim, velocity_set, grid_shape):
[test_bc],
bc_mask,
missing_mask,
start_index=(0, 0, 0) if dim == 3 else (0, 0),
)
assert missing_mask.dtype == xlb.Precision.BOOL.wp_dtype

Expand All @@ -69,9 +68,12 @@ def test_indices_masker_warp(dim, velocity_set, grid_shape):
bc_mask = bc_mask.numpy()
missing_mask = missing_mask.numpy()

assert bc_mask.shape == (1,) + grid_shape

assert missing_mask.shape == (velocity_set.q,) + grid_shape
if len(grid_shape) == 2:
assert bc_mask.shape == (1,) + grid_shape + (1,), "bc_mask shape is incorrect got {}".format(bc_mask.shape)
assert missing_mask.shape == (velocity_set.q,) + grid_shape + (1,), "missing_mask shape is incorrect got {}".format(missing_mask.shape)
else:
assert bc_mask.shape == (1,) + grid_shape, "bc_mask shape is incorrect got {}".format(bc_mask.shape)
assert missing_mask.shape == (velocity_set.q,) + grid_shape, "missing_mask shape is incorrect got {}".format(missing_mask.shape)

if dim == 2:
assert np.all(bc_mask[0, indices[0], indices[1]] == test_bc.id)
Expand Down
2 changes: 1 addition & 1 deletion xlb/operator/boundary_condition/bc_do_nothing.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ def warp_implementation(self, f_pre, f_post, bc_mask, missing_mask):
inputs=[f_pre, f_post, bc_mask, missing_mask],
dim=f_pre.shape[1:],
)
return f_post
return f_post
2 changes: 1 addition & 1 deletion xlb/operator/boundary_condition/bc_equilibrium.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,4 @@ def warp_implementation(self, f_pre, f_post, bc_mask, missing_mask):
inputs=[f_pre, f_post, bc_mask, missing_mask],
dim=f_pre.shape[1:],
)
return f_post
return f_post
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,4 @@ def warp_implementation(self, f_pre, f_post, bc_mask, missing_mask):
inputs=[f_pre, f_post, bc_mask, missing_mask],
dim=f_pre.shape[1:],
)
return f_post
return f_post
2 changes: 1 addition & 1 deletion xlb/operator/boundary_condition/bc_fullway_bounce_back.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@ def warp_implementation(self, f_pre, f_post, bc_mask, missing_mask):
inputs=[f_pre, f_post, bc_mask, missing_mask],
dim=f_pre.shape[1:],
)
return f_post
return f_post
2 changes: 1 addition & 1 deletion xlb/operator/boundary_condition/bc_grads_approximation.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,4 +321,4 @@ def warp_implementation(self, f_pre, f_post, bc_mask, missing_mask):
inputs=[f_pre, f_post, bc_mask, missing_mask],
dim=f_pre.shape[1:],
)
return f_post
return f_post
11 changes: 8 additions & 3 deletions xlb/operator/boundary_condition/bc_regularized.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,14 @@ def _get_fsum(
def get_normal_vectors(
missing_mask: Any,
):
for l in range(_q):
if missing_mask[l] == wp.uint8(1) and wp.abs(_c[0, l]) + wp.abs(_c[1, l]) + wp.abs(_c[2, l]) == 1:
return -_u_vec(_c_float[0, l], _c_float[1, l], _c_float[2, l])
if wp.static(_d == 3):
for l in range(_q):
if missing_mask[l] == wp.uint8(1) and wp.abs(_c[0, l]) + wp.abs(_c[1, l]) + wp.abs(_c[2, l]) == 1:
return -_u_vec(_c_float[0, l], _c_float[1, l], _c_float[2, l])
else:
for l in range(_q):
if missing_mask[l] == wp.uint8(1) and wp.abs(_c[0, l]) + wp.abs(_c[1, l]) == 1:
return -_u_vec(_c_float[0, l], _c_float[1, l])

@wp.func
def bounceback_nonequilibrium(
Expand Down
5 changes: 4 additions & 1 deletion xlb/operator/collision/kbc.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,10 @@ def functional(
):
# Compute shear and delta_s
fneq = f - feq
shear = decompose_shear_d3q27(fneq)
if wp.static(self.velocity_set.d == 3):
shear = decompose_shear_d3q27(fneq)
else:
shear = decompose_shear_d2q9(fneq)
delta_s = shear * rho # TODO: Check this

# Perform collision
Expand Down
Loading