From e8025e2597de07d2b2b175bec5a0d0ca75c63521 Mon Sep 17 00:00:00 2001 From: Hesam Salehipour Date: Fri, 25 Oct 2024 10:33:31 -0400 Subject: [PATCH] fixed a bug in bc and kbc (Warp) that emerged after merging 2d and 3d kernels --- xlb/operator/boundary_condition/bc_regularized.py | 11 ++++++++--- xlb/operator/collision/kbc.py | 5 ++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/xlb/operator/boundary_condition/bc_regularized.py b/xlb/operator/boundary_condition/bc_regularized.py index af4c783..5fd71f6 100644 --- a/xlb/operator/boundary_condition/bc_regularized.py +++ b/xlb/operator/boundary_condition/bc_regularized.py @@ -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( diff --git a/xlb/operator/collision/kbc.py b/xlb/operator/collision/kbc.py index 5c5c29e..ec4f4fe 100644 --- a/xlb/operator/collision/kbc.py +++ b/xlb/operator/collision/kbc.py @@ -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