Kernels¶
Kernel interface¶
- class sumpy.kernel.KernelArgument(loopy_arg: KernelArgument)[source]¶
- loopy_arg: KernelArgument¶
A
loopy.KernelArgumentinstance describing the type, name, and other features of this kernel argument when passed to a generated piece of code.
- class sumpy.kernel.Kernel(dim: int)[source]¶
Bases:
ABCBasic kernel interface.
- is_translation_invariant: ClassVar[bool] = True¶
A boolean flag indicating whether the kernel is translation invariant.
- abstract property is_complex_valued: bool¶
A boolean flag indicating whether this kernel is complex valued.
- replace_base_kernel(new_base_kernel: Kernel) Kernel[source]¶
- Returns:
the base kernel being wrapped by this one, or else new_base_kernel.
- prepare_loopy_kernel(loopy_knl: TranslationUnit) TranslationUnit[source]¶
Apply some changes (such as registering function manglers) to the kernel.
- Returns:
a new
loopykernel with the applied changes.
- get_code_transformer() Callable[[Expression], Expression][source]¶
- Returns:
a function to postprocess the
pymbolicexpression generated from the result ofget_expression()on the way to code generation.
- abstractmethod get_expression(dist_vec: MutableDenseMatrix) Expr[source]¶
- Returns:
a
sympyexpression for the kernel.
- postprocess_at_source(expr: Expr, avec: MutableDenseMatrix) Expr[source]¶
- postprocess_at_source(expr: ExprDerivativeTaker, avec: MutableDenseMatrix) DifferentiatedExprDerivativeTaker
Transform a kernel evaluation or expansion expression in a place where the vector \(a\) (something - source) is known. (“something” may be an expansion center or a target)
The typical use of this function is to apply source-variable derivatives to the kernel.
- postprocess_at_target(expr: Expr, bvec: MutableDenseMatrix) Expr[source]¶
- postprocess_at_target(expr: ExprDerivativeTaker | DifferentiatedExprDerivativeTaker, bvec: MutableDenseMatrix) DifferentiatedExprDerivativeTaker
Transform a kernel evaluation or expansion expression in a place where the vector \(b\) (target - something) is known. (“something” may be an expansion center or a target.)
The typical use of this function is to apply target-variable derivatives to the kernel.
- abstractmethod get_global_scaling_const() Expr[source]¶
A global scaling constant of the kernel.
Typically, this ensures that the kernel is scaled so that \(\mathcal{L}(G)(x) = C \delta(x)\) with a constant of 1, where \(\mathcal{L}\) is the PDE operator associated with the kernel. Not to be confused with rscale, which keeps expansion coefficients benignly scaled.
- get_args() Sequence[KernelArgument][source]¶
- Returns:
list of
KernelArgumentinstances describing extra arguments used by the kernel.
- get_source_args() Sequence[KernelArgument][source]¶
- Returns:
list of
KernelArgumentinstances describing extra arguments used by kernel in picking up contributions from point sources.
- abstractmethod get_pde_as_diff_op() LinearPDESystemOperator[source]¶
- Returns:
the PDE for the kernel as a
sumpy.expansion.diff_op.LinearPDESystemOperatorobject \(\mathcal{L}\), where \(\mathcal{L}(u) = 0\) is the PDE.
Symbolic kernels¶
- class sumpy.kernel.ExpressionKernel(dim: int, expression: Expression, global_scaling_const: Expression)[source]¶
-
- expression: Expression¶
A
pymbolicexpression depending on variables d_1 through d_N where N equals dim. These variables match what is returned frompymbolic.primitives.make_sym_vector()with argument “d”. Any variable that is not d or aSpatialConstantwill be viewed as potentially spatially varying.
- global_scaling_const: Expression¶
A constant
pymbolicexpression for the global scaling of the kernel. Typically, this ensures that the kernel is scaled so that \(\mathcal{L}(G)(x)=C\delta(x)\) with a constant of 1, where \(\mathcal{L}\) is the PDE operator associated with the kernel. Not to be confused with rscale, which keeps expansion coefficients benignly scaled.
PDE kernels¶
- class sumpy.kernel.LaplaceKernel(dim: int)[source]¶
Bases:
ExpressionKernelA kernel for the Laplace equation (see e.g. Theorem 6.2 from [Kress2013]).
\[\Delta K(\mathbf{x}, \mathbf{y}) = \delta(\mathbf{x} - \mathbf{y}).\]
- class sumpy.kernel.BiharmonicKernel(dim: int)[source]¶
Bases:
ExpressionKernelA kernel for the biharmonic equation.
\[\Delta^2 K(\mathbf{x}, \mathbf{y}) = \delta(\mathbf{x} - \mathbf{y}).\]
- class sumpy.kernel.HelmholtzKernel(dim: int, helmholtz_k_name: str = 'k', allow_evanescent: bool = False)[source]¶
Bases:
ExpressionKernelA kernel for the Helmholtz equation (see e.g. Example 12.14 in [Kress2013]).
\[\Delta K(\mathbf{x}, \mathbf{y}) + k^2 K(\mathbf{x}, \mathbf{y}) = \delta(\mathbf{x} - \mathbf{y}).\]
- class sumpy.kernel.YukawaKernel(dim: int, yukawa_lambda_name: str = 'lam')[source]¶
Bases:
ExpressionKernelA kernel for the Yukawa equation.
\[\Delta K(\mathbf{x}, \mathbf{y}) - \lambda^2 K(\mathbf{x}, \mathbf{y}) = \delta(\mathbf{x} - \mathbf{y}).\]
- class sumpy.kernel.StokesletKernel(dim: int, icomp: int, jcomp: int, viscosity_mu_name: str = 'mu')[source]¶
Bases:
ExpressionKernelA kernel for the Stokes equations (see e.g. Chapter 2 in [Pozrikidis1992]).
\[\begin{split}\begin{cases} -\mu \Delta K_{ij}(\mathbf{x}, \mathbf{y}) + \nabla_i P_j(\mathbf{x}, \mathbf{y}) = \delta_{ij} \delta(\mathbf{x} - \mathbf{y}), \\ \nabla_i K_{ij}(\mathbf{x}, \mathbf{y}) = 0, \\ \end{cases}\end{split}\]where pressure kernel \(P_j = \partial_j K\) is the derivative of the Laplace kernel. This kernel is often called the Stokeslet or the Oseen-Burgers tensor and it represents the velocity field.
- class sumpy.kernel.StressletKernel(dim: int, icomp: int, jcomp: int, kcomp: int, viscosity_mu_name: str = 'mu')[source]¶
Bases:
ExpressionKernelA kernel for the Stokes equations (see e.g. Chapter 2 in [Pozrikidis1992]).
\[K_{ijk}(\mathbf{x}, \mathbf{y}) = -P_j \delta_{ik} + \mu (\partial_k K_{ij} + \partial_i K_{kj})\]where the two-index \(K_{ij}\) is the
StokesletKernel. This kernel is often called the Stresslet and it represents the stress tensor.
- class sumpy.kernel.ElasticityKernel(dim: int, icomp: int, jcomp: int, viscosity_mu_name: str = 'mu', poisson_ratio_name: str = 'nu')[source]¶
Bases:
ExpressionKernelA kernel for the linear elasticity (Navier-Cauchy) equations (see e.g. Section 2.2 in [Hsiao2008]).
\[\mu \Delta K_{ij}(\mathbf{x}, \mathbf{y}) + \frac{\mu}{1 - 2 \nu} \nabla (\nabla \cdot K_{ij}(\mathbf{x}, \mathbf{y})) = \delta_{ij} \delta(\mathbf{x} - \mathbf{y}).\]- viscosity_mu_name: str¶
The argument name to use for the dynamic viscosity \(\mu\) when generating functions to evaluate this kernel.
- class sumpy.kernel.LineOfCompressionKernel(dim: int = 3, axis: int = 2, viscosity_mu_name: str = 'mu', poisson_ratio_name: str = 'nu')[source]¶
Bases:
ExpressionKernelA kernel for the line of compression or dilatation of constant strength along an axis from zero to negative infinity.
This is used for the explicit solution to half-space linear elasticity problem. See [Mindlin1936] for details.
[Mindlin1936]R. D. Mindlin (1936). Force at a Point in the Interior of a Semi-Infinite Solid. Physics. 7 (5): 195-202. doi:10.1063/1.1745385.
- viscosity_mu_name: str¶
The argument name to use for the dynamic viscosity \(\mu\) when generating functions to evaluate this kernel.
- class sumpy.kernel.BrinkmanletKernel(dim: int, icomp: int, jcomp: int, viscosity_mu_name: str = 'mu', darcy_impermeability_name: str = 'k')[source]¶
Bases:
ExpressionKernelA kernel for the Brinkman equations.
\[\begin{split}\begin{cases} -\mu (\Delta K_{ij}(\mathbf{x}, \mathbf{y}) - k^2 K_{ij}(\mathbf{x}, \mathbf{y})) + \nabla_i P_j(\mathbf{x}, \mathbf{y}) = \delta_{ij}(\mathbf{x} - \mathbf{y}), \\ \nabla_i K_{ij} = 0, \end{cases}\end{split}\]where \(P_j\) is the pressure kernel.
- class sumpy.kernel.BrinkmanStressKernel(dim: int, icomp: int, jcomp: int, kcomp: int, viscosity_mu_name: str = 'mu', darcy_impermeability_name: str = 'k')[source]¶
Bases:
ExpressionKernelA kernel for the Brinkman equations.
\[K_{ijk} = -p_j \delta_{ik} + \mu (\partial_k K_{ij} + \partial_i K_{jk}),\]where the two-index \(K_{ij}\) is the
BrinkmanletKerneland \(P_j\) is the pressure kernel.
- class sumpy.kernel.HeatKernel(spatial_dims: int, heat_alpha_name: str = 'alpha')[source]¶
Bases:
ExpressionKernelThe Green’s function for the heat equation given by \(e^{-r^2/{4 \alpha t}}/\sqrt{(4 \pi \alpha t)^d}\) where \(d\) is the number of spatial dimensions.
Note
This kernel cannot be used in an FMM yet and can only be used in expansions and evaluations that occur forward in the time dimension.
Derivatives¶
These objects wrap other kernels and take derivatives of them in the process.
- class sumpy.kernel.DerivativeBase(inner_kernel: Kernel)[source]¶
Bases:
Kernel- abstractmethod replace_inner_kernel(new_inner_kernel: Kernel) Kernel[source]¶
Replace the inner kernel of this wrapper.
This is essentially the same as
Kernel.replace_base_kernel(), but it does not recurse.
- class sumpy.kernel.AxisTargetDerivative(axis: int, inner_kernel: Kernel)[source]¶
Bases:
DerivativeBase
- class sumpy.kernel.AxisSourceDerivative(axis: int, inner_kernel: Kernel)[source]¶
Bases:
DerivativeBase
- class sumpy.kernel.DirectionalDerivative(inner_kernel: Kernel, dir_vec_name: str | None = None)[source]¶
Bases:
DerivativeBase
Transforming kernels¶
- class sumpy.kernel.TargetPointMultiplier(axis: int, inner_kernel: Kernel)[source]¶
Bases:
KernelWraps a kernel \(G(x, y)\) and outputs \(x_j G(x, y)\) where \(x, y\) are targets and sources respectively.
- class sumpy.kernel.ResultT¶
alias of TypeVar(‘ResultT’)
- class sumpy.kernel.KernelCombineMapper[source]¶
Bases:
KernelMapper[ResultT],ABC
- class sumpy.kernel.KernelIdentityMapper[source]¶
Bases:
KernelMapper[Kernel]
- class sumpy.kernel.AxisSourceDerivativeRemover[source]¶
Bases:
KernelIdentityMapperRemoves all axis source derivatives from the kernel.
- class sumpy.kernel.AxisTargetDerivativeRemover[source]¶
Bases:
KernelIdentityMapperRemoves all axis target derivatives from the kernel.
- class sumpy.kernel.SourceDerivativeRemover[source]¶
Bases:
AxisSourceDerivativeRemoverRemoves all source derivatives from the kernel.
- class sumpy.kernel.TargetDerivativeRemover[source]¶
Bases:
AxisTargetDerivativeRemoverRemoves all target derivatives from the kernel.
- class sumpy.kernel.TargetTransformationRemover[source]¶
Bases:
TargetDerivativeRemoverRemoves all target transformations from the kernel.
- class sumpy.kernel.DerivativeCounter[source]¶
Bases:
KernelCombineMapper[int]Counts the number of derivatives in the kernel.