Skip to content

Commit

Permalink
added missing ruff formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
hsalehipour committed Aug 2, 2024
1 parent 9375832 commit d55a438
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 20 deletions.
29 changes: 11 additions & 18 deletions xlb/operator/stepper/nse_stepper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 0 additions & 2 deletions xlb/operator/stepper/stepper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -55,7 +54,6 @@ def __init__(self, operators, boundary_conditions):
elif not hasattr(self, attr_name):
setattr(self, attr_name, bc_fallback)


############################################

# Initialize operator
Expand Down

0 comments on commit d55a438

Please sign in to comment.