diff --git a/xlb/operator/stepper/nse_stepper.py b/xlb/operator/stepper/nse_stepper.py index 4c9714a..b26c558 100644 --- a/xlb/operator/stepper/nse_stepper.py +++ b/xlb/operator/stepper/nse_stepper.py @@ -124,18 +124,14 @@ def kernel2d( # Apply streaming (pull method) f_post_stream = self.stream.warp_functional(f_0, index) - - # Apply post-streaming type boundary conditions + + # Apply post-streaming type boundary conditions if _boundary_id == bc_struct.id_EquilibriumBC: # Equilibrium boundary condition - f_post_stream = self.equilibrium_bc.warp_functional( - f_0, _missing_mask, index - ) + f_post_stream = self.equilibrium_bc.warp_functional(f_0, _missing_mask, index) elif _boundary_id == bc_struct.id_DoNothingBC: # Do nothing boundary condition - f_post_stream = self.do_nothing_bc.warp_functional( - f_0, _missing_mask, index - ) + f_post_stream = self.do_nothing_bc.warp_functional(f_0, _missing_mask, index) elif _boundary_id == bc_struct.id_HalfwayBounceBackBC: # Half way boundary condition f_post_stream = self.halfway_bounce_back_bc.warp_functional(f_0, _missing_mask, index) @@ -200,9 +196,7 @@ def kernel3d( f_post_stream = self.equilibrium_bc.warp_functional(f_0, _missing_mask, index) elif _boundary_id == bc_struct.id_DoNothingBC: # Do nothing boundary condition - f_post_stream = self.do_nothing_bc.warp_functional( - f_0, _missing_mask, index - ) + f_post_stream = self.do_nothing_bc.warp_functional(f_0, _missing_mask, index) elif _boundary_id == bc_struct.id_HalfwayBounceBackBC: # Half way boundary condition f_post_stream = self.halfway_bounce_back_bc.warp_functional(f_0, _missing_mask, index) @@ -236,27 +230,26 @@ def kernel3d( @Operator.register_backend(ComputeBackend.WARP) def warp_implementation(self, f_0, f_1, boundary_mask, missing_mask, timestep): - # Get the boundary condition ids from xlb.operator.boundary_condition.boundary_condition_registry import boundary_condition_registry + bc_to_id = boundary_condition_registry.bc_to_id - + bc_struct = self.warp_functional() bc_attribute_list = [] for bc in self.boundary_conditions: # Setting the Struct attributes based on the BC class names attribute_str = bc.__class__.__name__ - setattr(bc_struct, 'id_' + attribute_str, bc_to_id[attribute_str]) - bc_attribute_list.append('id_' + attribute_str) + setattr(bc_struct, "id_" + attribute_str, bc_to_id[attribute_str]) + bc_attribute_list.append("id_" + attribute_str) # Unused attributes of the struct are set to inernal (id=0) ll = vars(bc_struct) for var in ll: - if var not in bc_attribute_list and not var.startswith('_'): + if var not in bc_attribute_list and not var.startswith("_"): # set unassigned boundaries to the maximum integer in uint8 attribute_str = bc.__class__.__name__ - setattr(bc_struct, var, 255) - + setattr(bc_struct, var, 255) # Launch the warp kernel wp.launch( diff --git a/xlb/operator/stepper/stepper.py b/xlb/operator/stepper/stepper.py index 3e04e4b..2127ea6 100644 --- a/xlb/operator/stepper/stepper.py +++ b/xlb/operator/stepper/stepper.py @@ -34,7 +34,6 @@ def __init__(self, operators, boundary_conditions): from xlb.operator.boundary_condition.bc_halfway_bounce_back import HalfwayBounceBackBC from xlb.operator.boundary_condition.bc_fullway_bounce_back import FullwayBounceBackBC - # Define a list of tuples with attribute names and their corresponding classes conditions = [ ("equilibrium_bc", EquilibriumBC), @@ -55,7 +54,6 @@ def __init__(self, operators, boundary_conditions): elif not hasattr(self, attr_name): setattr(self, attr_name, bc_fallback) - ############################################ # Initialize operator