From c6a7bec9d1e63fab0be2cd8175f18cd14d0f7b12 Mon Sep 17 00:00:00 2001 From: Natalie Beams Date: Wed, 30 Mar 2016 13:26:48 -0500 Subject: [PATCH 1/3] Fix behavior if CACHING_ENABLED is false --- sumpy/tools.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sumpy/tools.py b/sumpy/tools.py index f6c293be..bb58fd83 100644 --- a/sumpy/tools.py +++ b/sumpy/tools.py @@ -227,8 +227,9 @@ class KernelCacheWrapper(object): pass logger.info("%s: kernel cache miss" % self.name) - logger.info("%s: missed cache key: %s" % ( - self.name, cache_key)) + if CACHING_ENABLED: + logger.info("%s: missed cache key: %s" % ( + self.name, cache_key)) knl = self.get_optimized_kernel(**kwargs) -- GitLab From 8e4e5d6ad98bcd012f671f0fbc4b0f1adb989bad Mon Sep 17 00:00:00 2001 From: Natalie Beams Date: Wed, 30 Mar 2016 13:33:15 -0500 Subject: [PATCH 2/3] Add 2D Stokeslet --- sumpy/kernel.py | 57 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/sumpy/kernel.py b/sumpy/kernel.py index b29e6237..3f745b70 100644 --- a/sumpy/kernel.py +++ b/sumpy/kernel.py @@ -370,6 +370,63 @@ class HelmholtzKernel(ExpressionKernel): mapper_method = "map_helmholtz_kernel" + +class StokesletKernel(ExpressionKernel): + init_arg_names = ("dim", "icomp", "jcomp", "viscosity_mu_name") + + def __init__(self, dim, icomp, jcomp, viscosity_mu_name="mu"): + """ + :arg viscosity_mu_name: The argument name to use for + dynamic viscosity :math:`\mu` the then generating functions to + evaluate this kernel. + """ + mu = var(viscosity_mu_name) + + if dim == 2: + d = make_sym_vector("d", dim) + r = pymbolic_real_norm_2(d) + expr = ( + -var("log")(r)*(1 if icomp == jcomp else 0) + + + d[icomp]*d[jcomp]/r**2 + ) + scaling = 1/(4*var("pi")*mu) + + elif dim is None: + expr = None + scaling = None + else: + raise RuntimeError("unsupported dimensionality") + + self.viscosity_mu_name = viscosity_mu_name + self.icomp = icomp + self.jcomp = jcomp + + ExpressionKernel.__init__( + self, + dim, + expression=expr, + scaling=scaling, + is_complex_valued=False) + + def __getinitargs__(self): + return (self._dim, self.icomp, self.jcomp, self.viscosity_mu_name) + + def update_persistent_hash(self, key_hash, key_builder): + key_hash.update(type(self).__name__.encode()) + key_builder.rec(key_hash, (self.dim, self.icomp, self.jcomp, self.viscosity_mu_name)) + + def __repr__(self): + return "StokesletKnl%dD_%d%d" % (self.dim, self.icomp, self.jcomp) + + def get_args(self): + return [ + KernelArgument( + loopy_arg=lp.ValueArg(self.viscosity_mu_name, np.float64), + )] + + mapper_method = "map_stokeslet_kernel" + # }}} -- GitLab From dbe64407dad171b73f55224716db3af08473a31c Mon Sep 17 00:00:00 2001 From: Natalie Beams Date: Wed, 30 Mar 2016 13:40:17 -0500 Subject: [PATCH 3/3] sum to simul_reduce --- sumpy/p2p.py | 9 ++++----- sumpy/qbx.py | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/sumpy/p2p.py b/sumpy/p2p.py index 47557760..c640d3e0 100644 --- a/sumpy/p2p.py +++ b/sumpy/p2p.py @@ -1,7 +1,4 @@ -from __future__ import division -from __future__ import absolute_import -import six -from six.moves import range +from __future__ import division, absolute_import __copyright__ = "Copyright (C) 2012 Andreas Kloeckner" @@ -25,6 +22,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ +import six +from six.moves import range import numpy as np import loopy as lp @@ -127,7 +126,7 @@ class P2P(P2PBase): for i, expr in enumerate(exprs) ]+[ "result[${KNLIDX}, itgt] = knl_${KNLIDX}_scaling \ - * sum(isrc, pair_result_${KNLIDX})" + * simul_reduce(sum, isrc, pair_result_${KNLIDX})" ], [ lp.GlobalArg("sources", None, diff --git a/sumpy/qbx.py b/sumpy/qbx.py index 5e1d8387..be83ae44 100644 --- a/sumpy/qbx.py +++ b/sumpy/qbx.py @@ -210,7 +210,7 @@ class LayerPotential(LayerPotentialBase): def get_result_store_instructions(self): return [ "result_${KNLIDX}[itgt] = \ - knl_${KNLIDX}_scaling*sum(isrc, pair_result_${KNLIDX})" + knl_${KNLIDX}_scaling*simul_reduce(sum, isrc, pair_result_${KNLIDX})" ] def __call__(self, queue, targets, sources, centers, strengths, **kwargs): -- GitLab