diff --git a/examples/cfd/flow_past_sphere_3d.py b/examples/cfd/flow_past_sphere_3d.py index 8b958fc..578caf9 100644 --- a/examples/cfd/flow_past_sphere_3d.py +++ b/examples/cfd/flow_past_sphere_3d.py @@ -49,9 +49,9 @@ def _setup(self, omega): def define_boundary_indices(self): box = self.grid.bounding_box_indices() - box_noedge = self.grid.bounding_box_indices(remove_edges=True) - inlet = box_noedge["left"] - outlet = box_noedge["right"] + box_no_edge = self.grid.bounding_box_indices(remove_edges=True) + inlet = box_no_edge["left"] + outlet = box_no_edge["right"] walls = [box["bottom"][i] + box["top"][i] + box["front"][i] + box["back"][i] for i in range(self.velocity_set.d)] walls = np.unique(np.array(walls), axis=-1).tolist() @@ -101,8 +101,6 @@ def run(self, num_steps, post_process_interval=100): self.f_0, self.f_1 = self.stepper(self.f_0, self.f_1, self.bc_mask, self.missing_mask, i) self.f_0, self.f_1 = self.f_1, self.f_0 - if i == 0: - self.check_boundary_mask() if i % post_process_interval == 0 or i == num_steps - 1: self.post_process(i) end_time = time.time() @@ -134,22 +132,6 @@ def post_process(self, i): save_image(fields["u_magnitude"][:, self.grid_shape[1] // 2, :], timestep=i) return - def check_boundary_mask(self): - # Write the results. We'll use JAX backend for the post-processing - if not isinstance(self.f_0, jnp.ndarray): - bmask = wp.to_jax(self.bc_mask)[0] - else: - bmask = self.bc_mask[0] - - # save_fields_vtk(fields, timestep=i) - save_image(bmask[0, :, :], prefix="00_left") - save_image(bmask[self.grid_shape[0] - 1, :, :], prefix="00_right") - save_image(bmask[:, :, self.grid_shape[2] - 1], prefix="00_top") - save_image(bmask[:, :, 0], prefix="00_bottom") - save_image(bmask[:, 0, :], prefix="00_front") - save_image(bmask[:, self.grid_shape[1] - 1, :], prefix="00_back") - save_image(bmask[:, self.grid_shape[1] // 2, :], prefix="00_middle") - if __name__ == "__main__": # Running the simulation diff --git a/examples/cfd/lid_driven_cavity_2d.py b/examples/cfd/lid_driven_cavity_2d.py index a77cc62..dfb1092 100644 --- a/examples/cfd/lid_driven_cavity_2d.py +++ b/examples/cfd/lid_driven_cavity_2d.py @@ -41,8 +41,8 @@ def _setup(self, omega): def define_boundary_indices(self): box = self.grid.bounding_box_indices() - box_noedge = self.grid.bounding_box_indices(remove_edges=True) - lid = box_noedge["top"] + box_no_edge = self.grid.bounding_box_indices(remove_edges=True) + lid = box_no_edge["top"] walls = [box["bottom"][i] + box["left"][i] + box["right"][i] for i in range(self.velocity_set.d)] walls = np.unique(np.array(walls), axis=-1).tolist() return lid, walls diff --git a/examples/cfd/windtunnel_3d.py b/examples/cfd/windtunnel_3d.py index a7567d0..c83e2c9 100644 --- a/examples/cfd/windtunnel_3d.py +++ b/examples/cfd/windtunnel_3d.py @@ -68,9 +68,9 @@ def voxelize_stl(self, stl_filename, length_lbm_unit): def define_boundary_indices(self): box = self.grid.bounding_box_indices() - box_noedge = self.grid.bounding_box_indices(remove_edges=True) - inlet = box_noedge["left"] - outlet = box_noedge["right"] + box_no_edge = self.grid.bounding_box_indices(remove_edges=True) + inlet = box_no_edge["left"] + outlet = box_no_edge["right"] walls = [box["bottom"][i] + box["top"][i] + box["front"][i] + box["back"][i] for i in range(self.velocity_set.d)] walls = np.unique(np.array(walls), axis=-1).tolist() diff --git a/examples/performance/mlups_3d.py b/examples/performance/mlups_3d.py index 4c337e8..2001fb2 100644 --- a/examples/performance/mlups_3d.py +++ b/examples/performance/mlups_3d.py @@ -49,8 +49,8 @@ def create_grid_and_fields(cube_edge): def define_boundary_indices(grid): box = grid.bounding_box_indices() - box_noedge = grid.bounding_box_indices(remove_edges=True) - lid = box_noedge["top"] + box_no_edge = grid.bounding_box_indices(remove_edges=True) + lid = box_no_edge["top"] walls = [box["bottom"][i] + box["left"][i] + box["right"][i] + box["front"][i] + box["back"][i] for i in range(len(grid.shape))] return lid, walls diff --git a/xlb/distribute/__init__.py b/xlb/distribute/__init__.py index 25fa0af..dd9f33d 100644 --- a/xlb/distribute/__init__.py +++ b/xlb/distribute/__init__.py @@ -1 +1 @@ -from .distribute import distribute as distribute +from .distribute import distribute diff --git a/xlb/experimental/ooc/__init__.py b/xlb/experimental/ooc/__init__.py index 801683d..5206cc1 100644 --- a/xlb/experimental/ooc/__init__.py +++ b/xlb/experimental/ooc/__init__.py @@ -1,2 +1,2 @@ -from xlb.experimental.ooc.out_of_core import OOCmap as OOCmap -from xlb.experimental.ooc.ooc_array import OOCArray as OOCArray +from xlb.experimental.ooc.out_of_core import OOCmap +from xlb.experimental.ooc.ooc_array import OOCArray diff --git a/xlb/helper/__init__.py b/xlb/helper/__init__.py index 4c63aa6..d52f206 100644 --- a/xlb/helper/__init__.py +++ b/xlb/helper/__init__.py @@ -1,3 +1,3 @@ -from xlb.helper.nse_solver import create_nse_fields as create_nse_fields -from xlb.helper.initializers import initialize_eq as initialize_eq -from xlb.helper.check_boundary_overlaps import check_bc_overlaps as check_bc_overlaps +from xlb.helper.nse_solver import create_nse_fields +from xlb.helper.initializers import initialize_eq +from xlb.helper.check_boundary_overlaps import check_bc_overlaps diff --git a/xlb/helper/check_boundary_overlaps.py b/xlb/helper/check_boundary_overlaps.py index 18e17a1..1adceb2 100644 --- a/xlb/helper/check_boundary_overlaps.py +++ b/xlb/helper/check_boundary_overlaps.py @@ -12,6 +12,7 @@ def check_bc_overlaps(bclist, dim, backend): if index_arr.shape[-1] != len(bc.indices[0]): if backend == ComputeBackend.WARP: raise ValueError(f"Boundary condition {bc.__class__.__name__} has duplicate indices!") + print(f"WARNING: there are duplicate indices in {bc.__class__.__name__} and hence the order in bc list matters!") for d in range(dim): index_list[d] += bc.indices[d] @@ -20,3 +21,4 @@ def check_bc_overlaps(bclist, dim, backend): if index_arr.shape[-1] != len(index_list[0]): if backend == ComputeBackend.WARP: raise ValueError("Boundary condition list containes duplicate indices!") + print("WARNING: there are duplicate indices in the boundary condition list and hence the order in this list matters!") diff --git a/xlb/operator/__init__.py b/xlb/operator/__init__.py index c88ef83..02b8a59 100644 --- a/xlb/operator/__init__.py +++ b/xlb/operator/__init__.py @@ -1,2 +1,2 @@ -from xlb.operator.operator import Operator as Operator -from xlb.operator.parallel_operator import ParallelOperator as ParallelOperator +from xlb.operator.operator import Operator +from xlb.operator.parallel_operator import ParallelOperator diff --git a/xlb/operator/boundary_condition/__init__.py b/xlb/operator/boundary_condition/__init__.py index 925dfdc..4782ea0 100644 --- a/xlb/operator/boundary_condition/__init__.py +++ b/xlb/operator/boundary_condition/__init__.py @@ -1,12 +1,10 @@ -from xlb.operator.boundary_condition.boundary_condition import BoundaryCondition as BoundaryCondition -from xlb.operator.boundary_condition.boundary_condition_registry import ( - BoundaryConditionRegistry as BoundaryConditionRegistry, -) -from xlb.operator.boundary_condition.bc_equilibrium import EquilibriumBC as EquilibriumBC -from xlb.operator.boundary_condition.bc_do_nothing import DoNothingBC as DoNothingBC -from xlb.operator.boundary_condition.bc_halfway_bounce_back import HalfwayBounceBackBC as HalfwayBounceBackBC -from xlb.operator.boundary_condition.bc_fullway_bounce_back import FullwayBounceBackBC as FullwayBounceBackBC -from xlb.operator.boundary_condition.bc_zouhe import ZouHeBC as ZouHeBC -from xlb.operator.boundary_condition.bc_regularized import RegularizedBC as RegularizedBC -from xlb.operator.boundary_condition.bc_extrapolation_outflow import ExtrapolationOutflowBC as ExtrapolationOutflowBC -from xlb.operator.boundary_condition.bc_grads_approximation import GradsApproximationBC as GradsApproximationBC +from xlb.operator.boundary_condition.boundary_condition import BoundaryCondition +from xlb.operator.boundary_condition.boundary_condition_registry import BoundaryConditionRegistry +from xlb.operator.boundary_condition.bc_equilibrium import EquilibriumBC +from xlb.operator.boundary_condition.bc_do_nothing import DoNothingBC +from xlb.operator.boundary_condition.bc_halfway_bounce_back import HalfwayBounceBackBC +from xlb.operator.boundary_condition.bc_fullway_bounce_back import FullwayBounceBackBC +from xlb.operator.boundary_condition.bc_zouhe import ZouHeBC +from xlb.operator.boundary_condition.bc_regularized import RegularizedBC +from xlb.operator.boundary_condition.bc_extrapolation_outflow import ExtrapolationOutflowBC +from xlb.operator.boundary_condition.bc_grads_approximation import GradsApproximationBC diff --git a/xlb/operator/boundary_masker/__init__.py b/xlb/operator/boundary_masker/__init__.py index fbe851d..d03636a 100644 --- a/xlb/operator/boundary_masker/__init__.py +++ b/xlb/operator/boundary_masker/__init__.py @@ -1,9 +1,3 @@ -from xlb.operator.boundary_masker.indices_boundary_masker import ( - IndicesBoundaryMasker as IndicesBoundaryMasker, -) -from xlb.operator.boundary_masker.mesh_boundary_masker import ( - MeshBoundaryMasker as MeshBoundaryMasker, -) -from xlb.operator.boundary_masker.mesh_distance_boundary_masker import ( - MeshDistanceBoundaryMasker as MeshDistanceBoundaryMasker, -) +from xlb.operator.boundary_masker.indices_boundary_masker import IndicesBoundaryMasker +from xlb.operator.boundary_masker.mesh_boundary_masker import MeshBoundaryMasker +from xlb.operator.boundary_masker.mesh_distance_boundary_masker import MeshDistanceBoundaryMasker diff --git a/xlb/operator/collision/__init__.py b/xlb/operator/collision/__init__.py index 0526c8a..2f92bb4 100644 --- a/xlb/operator/collision/__init__.py +++ b/xlb/operator/collision/__init__.py @@ -1,4 +1,4 @@ -from xlb.operator.collision.collision import Collision as Collision -from xlb.operator.collision.bgk import BGK as BGK -from xlb.operator.collision.kbc import KBC as KBC -from xlb.operator.collision.forced_collision import ForcedCollision as ForcedCollision +from xlb.operator.collision.collision import Collision +from xlb.operator.collision.bgk import BGK +from xlb.operator.collision.kbc import KBC +from xlb.operator.collision.forced_collision import ForcedCollision diff --git a/xlb/operator/equilibrium/__init__.py b/xlb/operator/equilibrium/__init__.py index b9f9f08..987aa74 100644 --- a/xlb/operator/equilibrium/__init__.py +++ b/xlb/operator/equilibrium/__init__.py @@ -1,4 +1 @@ -from xlb.operator.equilibrium.quadratic_equilibrium import ( - Equilibrium as Equilibrium, - QuadraticEquilibrium as QuadraticEquilibrium, -) +from xlb.operator.equilibrium.quadratic_equilibrium import Equilibrium, QuadraticEquilibrium diff --git a/xlb/operator/force/__init__.py b/xlb/operator/force/__init__.py index 2f3e3da..ba8a13c 100644 --- a/xlb/operator/force/__init__.py +++ b/xlb/operator/force/__init__.py @@ -1,2 +1,2 @@ -from xlb.operator.force.momentum_transfer import MomentumTransfer as MomentumTransfer -from xlb.operator.force.exact_difference_force import ExactDifference as ExactDifference +from xlb.operator.force.momentum_transfer import MomentumTransfer +from xlb.operator.force.exact_difference_force import ExactDifference diff --git a/xlb/operator/precision_caster/__init__.py b/xlb/operator/precision_caster/__init__.py index c333ab7..a027c52 100644 --- a/xlb/operator/precision_caster/__init__.py +++ b/xlb/operator/precision_caster/__init__.py @@ -1 +1 @@ -from xlb.operator.precision_caster.precision_caster import PrecisionCaster as PrecisionCaster +from xlb.operator.precision_caster.precision_caster import PrecisionCaster diff --git a/xlb/operator/stepper/__init__.py b/xlb/operator/stepper/__init__.py index 528375d..e5d159c 100644 --- a/xlb/operator/stepper/__init__.py +++ b/xlb/operator/stepper/__init__.py @@ -1,2 +1,2 @@ -from xlb.operator.stepper.stepper import Stepper as Stepper -from xlb.operator.stepper.nse_stepper import IncompressibleNavierStokesStepper as IncompressibleNavierStokesStepper +from xlb.operator.stepper.stepper import Stepper +from xlb.operator.stepper.nse_stepper import IncompressibleNavierStokesStepper diff --git a/xlb/operator/stream/__init__.py b/xlb/operator/stream/__init__.py index 2f5b2f3..9093da7 100644 --- a/xlb/operator/stream/__init__.py +++ b/xlb/operator/stream/__init__.py @@ -1 +1 @@ -from xlb.operator.stream.stream import Stream as Stream +from xlb.operator.stream.stream import Stream diff --git a/xlb/utils/__init__.py b/xlb/utils/__init__.py index 6f1f61a..3c8032e 100644 --- a/xlb/utils/__init__.py +++ b/xlb/utils/__init__.py @@ -1,9 +1,9 @@ from .utils import ( - downsample_field as downsample_field, - save_image as save_image, - save_fields_vtk as save_fields_vtk, - save_BCs_vtk as save_BCs_vtk, - rotate_geometry as rotate_geometry, - voxelize_stl as voxelize_stl, - axangle2mat as axangle2mat, + downsample_field, + save_image, + save_fields_vtk, + save_BCs_vtk, + rotate_geometry, + voxelize_stl, + axangle2mat, ) diff --git a/xlb/velocity_set/__init__.py b/xlb/velocity_set/__init__.py index c1338db..5b7b737 100644 --- a/xlb/velocity_set/__init__.py +++ b/xlb/velocity_set/__init__.py @@ -1,4 +1,4 @@ -from xlb.velocity_set.velocity_set import VelocitySet as VelocitySet -from xlb.velocity_set.d2q9 import D2Q9 as D2Q9 -from xlb.velocity_set.d3q19 import D3Q19 as D3Q19 -from xlb.velocity_set.d3q27 import D3Q27 as D3Q27 +from xlb.velocity_set.velocity_set import VelocitySet +from xlb.velocity_set.d2q9 import D2Q9 +from xlb.velocity_set.d3q19 import D3Q19 +from xlb.velocity_set.d3q27 import D3Q27