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:
ExpressionKernel
- class sumpy.kernel.BiharmonicKernel(dim: int)[source]¶
Bases:
ExpressionKernel
- class sumpy.kernel.HelmholtzKernel(dim: int, helmholtz_k_name: str = 'k', allow_evanescent: bool = False)[source]¶
Bases:
ExpressionKernel
- class sumpy.kernel.YukawaKernel(dim: int, yukawa_lambda_name: str = 'lam')[source]¶
Bases:
ExpressionKernel
- class sumpy.kernel.StokesletKernel(dim: int, icomp: int, jcomp: int, viscosity_mu: float | str | SpatialConstant = 'mu', poisson_ratio: float | str | SpatialConstant | None = None)[source]¶
Bases:
ElasticityKernel- viscosity_mu: float | SpatialConstant¶
The argument name to use for the dynamic viscosity \(\mu\) when generating functions to evaluate this kernel. Can also be a numeric value.
- class sumpy.kernel.StressletKernel(dim: int, icomp: int, jcomp: int, kcomp: int, viscosity_mu: float | str | SpatialConstant = 'mu')[source]¶
Bases:
ExpressionKernel- viscosity_mu: float | SpatialConstant¶
The argument name to use for the dynamic viscosity \(\mu\) when generating functions to evaluate this kernel. Can also be a numeric value.
- class sumpy.kernel.ElasticityKernel(dim: int, icomp: int, jcomp: int, viscosity_mu: float | str | SpatialConstant = 'mu', poisson_ratio: float | str | SpatialConstant = 'nu')[source]¶
Bases:
ExpressionKernel- viscosity_mu: float | SpatialConstant¶
The argument name to use for the dynamic viscosity \(\mu\) when generating functions to evaluate this kernel. Can also be a numeric value.
- poisson_ratio: float | SpatialConstant¶
The argument name to use for Poisson’s ratio \(\nu\) when generating functions to evaluate this kernel. Can also be a numeric value.
- class sumpy.kernel.LineOfCompressionKernel(dim: int = 3, axis: int = 2, viscosity_mu: float | str | SpatialConstant = 'mu', poisson_ratio: float | str | SpatialConstant = 'nu')[source]¶
Bases:
ExpressionKernelA kernel for the line of compression or dilatation of constant strength along the axis “axis” from zero to negative infinity.
This is used for the explicit solution to half-space 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: float | SpatialConstant¶
The argument name to use for the dynamic viscosity \(\mu\) when generating functions to evaluate this kernel. Can also be a numeric value.
- poisson_ratio: float | SpatialConstant¶
The argument name to use for Poisson’s ratio \(\nu\) when generating functions to evaluate this kernel. Can also be a numeric value.
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.