def __init__(self, ctx, expansion, kernels=None, name=None, device=None, strength_usage=None): """ :arg expansion: a subclass of :class:`sympy.expansion.ExpansionBase` :arg strength_usage: A list of integers indicating which expression uses which source strength indicator. This implicitly specifies the number of strength arrays that need to be passed. Default: all kernels use the same strength. """ if kernels is None: kernels = [expansion.kernel] KernelComputation.__init__(self, ctx=ctx, kernels=kernels, strength_usage=strength_usage, value_dtypes=None, name=name, device=device) from sumpy.kernel import TargetDerivativeRemover expansion = expansion.with_kernel(TargetDerivativeRemover()( expansion.kernel)) self.expansion = expansion self.dim = expansion.dim
def __init__(self, ctx, expansion, kernels, options=[], name=None, device=None): """ :arg expansion: a subclass of :class:`sympy.expansion.ExpansionBase` :arg strength_usage: A list of integers indicating which expression uses which source strength indicator. This implicitly specifies the number of strength arrays that need to be passed. Default: all kernels use the same strength. """ if device is None: device = ctx.devices[0] from sumpy.kernel import SourceDerivativeRemover, TargetDerivativeRemover sdr = SourceDerivativeRemover() tdr = TargetDerivativeRemover() expansion = expansion.with_kernel(sdr(expansion.kernel)) for knl in kernels: assert sdr(tdr(knl)) == expansion.kernel self.ctx = ctx self.expansion = expansion self.kernels = kernels self.options = options self.name = name or self.default_name self.device = device self.dim = expansion.dim
def __init__(self, ctx, src_expansion, tgt_expansion, options=[], name=None, device=None): """ :arg expansion: a subclass of :class:`sympy.expansion.ExpansionBase` :arg strength_usage: A list of integers indicating which expression uses which source strength indicator. This implicitly specifies the number of strength arrays that need to be passed. Default: all kernels use the same strength. """ if device is None: device = ctx.devices[0] if src_expansion is tgt_expansion: from sumpy.kernel import TargetDerivativeRemover, SourceDerivativeRemover tgt_expansion = src_expansion = src_expansion.with_kernel( SourceDerivativeRemover()(TargetDerivativeRemover()( src_expansion.kernel))) else: from sumpy.kernel import TargetDerivativeRemover, SourceDerivativeRemover src_expansion = src_expansion.with_kernel( SourceDerivativeRemover()(TargetDerivativeRemover()( src_expansion.kernel))) tgt_expansion = tgt_expansion.with_kernel( SourceDerivativeRemover()(TargetDerivativeRemover()( tgt_expansion.kernel))) self.ctx = ctx self.src_expansion = src_expansion self.tgt_expansion = tgt_expansion self.options = options self.name = name or self.default_name self.device = device if src_expansion.dim != tgt_expansion.dim: raise ValueError("source and target expansions must have " "same dimensionality") self.dim = src_expansion.dim
def get_expansion_for_qbx_direct_eval(self, base_kernel, target_kernels): from sumpy.expansion.local import LineTaylorLocalExpansion from sumpy.kernel import TargetDerivativeRemover # line Taylor cannot support target derivatives txr = TargetDerivativeRemover() if any(knl != txr(knl) for knl in target_kernels): return self.expansion_factory.get_local_expansion_class( base_kernel)(base_kernel, self.qbx_order) else: return LineTaylorLocalExpansion(base_kernel, self.qbx_order)
def __init__(self, cl_context, kernel, mpole_expn_class=None, local_expn_class=None, expansion_factory=None, extra_source_kwargs=None, extra_kernel_kwargs=None): self.cl_context = cl_context self.queue = cl.CommandQueue(self.cl_context) self.kernel = kernel self.no_target_deriv_kernel = TargetDerivativeRemover()(kernel) if expansion_factory is None: from sumpy.expansion import DefaultExpansionFactory expansion_factory = DefaultExpansionFactory() if mpole_expn_class is None: mpole_expn_class = \ expansion_factory.get_multipole_expansion_class(kernel) if local_expn_class is None: local_expn_class = \ expansion_factory.get_local_expansion_class(kernel) self.mpole_expn_class = mpole_expn_class self.local_expn_class = local_expn_class if extra_source_kwargs is None: extra_source_kwargs = {} if extra_kernel_kwargs is None: extra_kernel_kwargs = {} self.extra_source_kwargs = extra_source_kwargs self.extra_kernel_kwargs = extra_kernel_kwargs extra_source_and_kernel_kwargs = extra_source_kwargs.copy() extra_source_and_kernel_kwargs.update(extra_kernel_kwargs) self.extra_source_and_kernel_kwargs = extra_source_and_kernel_kwargs