Skip to content

Commit d7425ab

Browse files
committed
Use GeometryCollection and fix Pylint
1 parent b38d46c commit d7425ab

4 files changed

Lines changed: 18 additions & 19 deletions

File tree

examples/off-surface-eval.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import numpy as np
2424
import functools
2525
import pytential
26+
from pytential.collection import GeometryCollection
2627
import matplotlib.pyplot as plt
2728
from mpi4py import MPI
2829

@@ -35,9 +36,10 @@ def main():
3536
queue = cl.CommandQueue(cl_context)
3637
actx = PyOpenCLArrayContext(queue)
3738

38-
sigma = None
3939
places = None
4040
op = None
41+
sigma = None
42+
4143
if mpi_rank == 0:
4244
nelements = 30
4345
target_order = 8
@@ -57,7 +59,6 @@ def main():
5759
discretization = Discretization(
5860
actx, mesh, InterpolatoryQuadratureSimplexGroupFactory(target_order))
5961

60-
# FIXME: Use GeometryCollection instead of DistributedQBXLayerPotentialSource
6162
from pytential.qbx.distributed import DistributedQBXLayerPotentialSource
6263
layer_pot_source = DistributedQBXLayerPotentialSource(
6364
comm,
@@ -78,7 +79,7 @@ def main():
7879
fplot = FieldPlotter(np.zeros(2), extent=0.54, npoints=30)
7980
targets = PointsTarget(fplot.points)
8081

81-
places = (layer_pot_source, targets)
82+
places = GeometryCollection((layer_pot_source, targets))
8283

8384
from pytential.symbolic.execution import bind_distributed
8485
bound_op = bind_distributed(comm, places, op)

pytential/qbx/__init__.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -548,11 +548,6 @@ def _tree_indep_data_for_wrangler(self, source_kernels, target_kernels):
548548
fmm_local_factory = partial(local_expn_class, base_kernel)
549549
qbx_local_factory = partial(qbx_local_expn_class, base_kernel)
550550

551-
from pytential.qbx.distributed import DistributedQBXLayerPotentialSource
552-
use_distributed = False
553-
if isinstance(self, DistributedQBXLayerPotentialSource):
554-
use_distributed = True
555-
556551
if self.fmm_backend == "sumpy":
557552
from pytential.qbx.fmm import \
558553
QBXSumpyTreeIndependentDataForWrangler
@@ -575,8 +570,7 @@ def _tree_indep_data_for_wrangler(self, source_kernels, target_kernels):
575570
local_expansion_factory=fmm_local_factory,
576571
qbx_local_expansion_factory=qbx_local_factory,
577572
target_kernels=target_kernels_new,
578-
_use_target_specific_qbx=self._use_target_specific_qbx,
579-
use_distributed=use_distributed)
573+
_use_target_specific_qbx=self._use_target_specific_qbx)
580574

581575
else:
582576
raise ValueError(f"invalid FMM backend: {self.fmm_backend}")

pytential/qbx/distributed.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -742,15 +742,24 @@ def exec_compute_potential_insn_fmm(self, actx: PyOpenCLArrayContext,
742742
output_and_expansion_dtype = self.comm.bcast(
743743
output_and_expansion_dtype, root=0)
744744

745-
wrangler = tree_indep.wrangler_cls(
745+
from pytential.qbx.fmmlib import (
746+
QBXFMMLibExpansionWrangler, DistributedQBXFMMLibExpansionWrangler)
747+
748+
wrangler_cls = None
749+
if tree_indep.wrangler_cls == QBXFMMLibExpansionWrangler:
750+
wrangler_cls = DistributedQBXFMMLibExpansionWrangler
751+
else:
752+
raise NotImplementedError
753+
754+
wrangler = wrangler_cls(
746755
self._cl_context, self.comm, tree_indep,
747756
local_geo_data, global_geo_data,
748757
output_and_expansion_dtype,
749758
self.qbx_order,
750759
self.fmm_level_to_order,
751760
source_extra_kwargs,
752761
kernel_extra_kwargs,
753-
_use_target_specific_qbx=self._use_target_specific_qbx)
762+
self._use_target_specific_qbx)
754763

755764
if self.comm.Get_rank() == 0:
756765
from pytential.qbx.geometry import target_state

pytential/qbx/fmmlib.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,11 @@ class QBXFMMLibTreeIndependentDataForWrangler(FMMLibTreeIndependentDataForWrangl
4848
def __init__(self, cl_context, *,
4949
multipole_expansion_factory, local_expansion_factory,
5050
qbx_local_expansion_factory, target_kernels,
51-
_use_target_specific_qbx,
52-
use_distributed):
51+
_use_target_specific_qbx):
5352
self.cl_context = cl_context
5453
self.multipole_expansion_factory = multipole_expansion_factory
5554
self.local_expansion_factory = local_expansion_factory
5655
self.qbx_local_expansion_factory = qbx_local_expansion_factory
57-
self.use_distributed = use_distributed
5856

5957
kernel = target_kernels[0].get_base_kernel()
6058
self.target_kernels = target_kernels
@@ -145,10 +143,7 @@ def is_supported_helmknl_for_tsqbx(knl):
145143

146144
@property
147145
def wrangler_cls(self):
148-
if self.use_distributed:
149-
return DistributedQBXFMMLibExpansionWrangler
150-
else:
151-
return QBXFMMLibExpansionWrangler
146+
return QBXFMMLibExpansionWrangler
152147

153148
# }}}
154149

0 commit comments

Comments
 (0)