Discretizations and results¶
Use LocalApproximation for named functional maps and matrix-first algorithms.
Global collocation retains coefficient-based assembly. RBFFD and LHI remain
convenience/compatibility entry points for their supported PDE paths.
See functional operators and LHI from matrices.
rbflab.Samples
dataclass
¶
Points carrying values or differential-functional samples.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
object
|
A point cloud or Nx2/Nx3 array. Geometry is Float64. |
required |
operator
|
object
|
One differential operator, or one per point; None is value. |
None
|
size
|
int | None
|
Neighbors per target; None uses all eligible samples. |
None
|
target
|
str
|
'allow', 'exclude', or 'require' geometric target coincidence. |
'allow'
|
indices
|
object
|
Explicit group-local memberships, one integer row per target. Cannot be combined with size or a selection policy. |
None
|
policy
|
object
|
Optional geometric neighbor-selection policy for this group. Kernel scaling belongs to LocalApproximation instead. |
None
|
normals
|
object
|
Normals for normal-dependent boundary operators. |
None
|
within
|
str | SharedStencil | None
|
SharedStencil or name of a source group whose physical sites restrict this group. Uses exact coordinate matching, then target filtering; does not refill excluded sites. Cannot combine with size, indices or policy. The referenced group may appear later in the mapping. |
None
|
Groups may overlap geometrically when their functionals differ. No PDE role, forcing, boundary data, or unknown values are stored here.
select(target, row, policy, degree)
¶
Return group-local membership; functionals are rank-checked jointly.
rbflab.LocalApproximation
dataclass
¶
Construct functional interpolation weights and named sparse maps.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
object
|
Named Samples groups, a Samples object, or raw points. |
required |
trial
|
object
|
space.representers(groups) or space.translates(points). Mixed-functional sources require an explicit trial description. |
None
|
space
|
object
|
Shortcut for ordinary value interpolation; omit with trial. |
None
|
stencil_size
|
int | None
|
Neighbor count for a raw point source (default 15). Named Samples own their sizes; None means all eligible points. |
15
|
backend
|
object
|
PythonBackend, CppBackend or TorchBackend. |
PythonBackend()
|
precision
|
Precision
|
Local arithmetic and sparse storage policy. |
Precision()
|
stencil_policy
|
StencilPolicy | None
|
Compatibility selection/scaling policy. Its scaling is used when kernel_scaling is omitted; explicit conflicts are errors. |
None
|
kernel_scaling
|
str | None
|
"physical" (default, also None) or "local". This only selects the existing kernel-coordinate scaling convention; it does not rescale parameters automatically with global mesh spacing. |
_DEFAULT_SCALING
|
local_solver
|
LocalSolver
|
Local factorization (currently LU). |
LocalSolver()
|
execution
|
object
|
Optional LocalExecution for mixed native jobs (serial/MPI scheduling and exact request reuse). Other routes reject it. |
None
|
This object has no forcing or PDE solve. Use operators() or weights(), then assemble your own equations. Full MP sparse maps preserve precision; Torch results stay tensors. Geometry and membership are nondifferentiable Float64 data, and kernel parameter autograd is not advertised here.
preflight()
¶
Validate configuration before kernel compilation or matrix assembly.
weights(*, target, operator)
¶
Build one target row using configured sample memberships.
Use Samples(size=None) for an explicit stencil containing all supplied centers. Returned data expose weights, multipliers, groups, and a zero-argument reconstruct_local().
operators(*, targets, operators)
¶
Build named source-block maps, sharing one factorization per target.
operators maps user names to differential operators. Normal-dependent target operators require targets to carry matching normals. Members are chosen once per target and shared by every requested operator.
rbflab.interpolate(kernel=_UNSET, centers=_UNSET, data=_UNSET, precision=None, polynomial_degree=None, *, backend=None, space=_UNSET, patches=None)
¶
Fit scalar, componentwise or divergence-free global interpolants.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kernel
|
object
|
Built-in radial kernel, bound symbolic kernel, or ScalarSpace specifying its polynomial augmentation. DivergenceFreeSpace selects a coupled solenoidal vector interpolant in 2D/3D. |
_UNSET
|
space
|
object
|
Alias for kernel; specify only one spelling. |
_UNSET
|
centers
|
ndarray
|
Finite coordinate array of shape (N, 2) or (N, 3). |
_UNSET
|
data
|
ndarray or callable
|
Scalar samples of shape (N,), independent outputs of shape (N, C), or a scalar callback evaluated at centers. DivergenceFreeSpace takes (N, dimension) samples or a tuple of dimension scalar data callbacks/expressions. Row i corresponds to centers[i]. Extended callbacks require PrecisionData. |
_UNSET
|
precision
|
Precision or None
|
Optional Precision(global_digits=...) for dense arithmetic. |
None
|
polynomial_degree
|
int, None, or "auto"
|
Highest total polynomial degree.
|
None
|
backend
|
CppGlobalBackend or None
|
Optional native global assembly, factorization and evaluation. Native interpolants own a live worker; close them explicitly or use a context manager. |
None
|
patches
|
PatchCover or None
|
Explicit compact-support balls for partition-of-unity interpolation. Local factors persist for refit. Scalar and independent outputs support derivatives through order two. Planar DivergenceFreeSpace uses aligned local streamfunctions and supports velocity and first derivatives. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
result |
object
|
Fitted expansion with coefficients, diagnostics, and evaluate(points, operator=None). Scalar output is (M,); independent outputs are (M, C); solenoidal outputs are (M, dimension). An operator differentiates each component. evaluate_mp retains extended arithmetic. |
Scalar and global vector fits interpolate nodes exactly. The planar divergence-free partition-of-unity fit is an approximant and generally differs at nodes because the blended potential has weight derivatives. Coefficients are expansion coefficients, not the input nodal values. Assembly is dense.
rbflab.PatchCover
dataclass
¶
Fixed ball supports for partition-of-unity interpolation.
centers has shape (J, 2) or (J, 3); radii has J positive entries.
The compact C2 weight is (1-t)^4 (4t+1) for t<1.
Support membership uses strict distance less than radius.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
centers
|
object
|
Finite patch-center coordinates of shape (J, 2) or (J, 3). |
required |
radii
|
object
|
One finite positive support radius per patch. |
required |
from_points(points, *, n_patches=None, points_per_patch=32, overlap=0.25, min_points=None, seed=0)
classmethod
¶
Build reproducible ball supports for a finite 2D or 3D point cloud.
Every input point has strictly positive support. points_per_patch
controls the target clustering size before overlap; final membership
counts can be larger. This does not certify coverage between samples.
min_points checks support occupancy, not polynomial rank.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
array - like
|
Distinct finite coordinates with shape (N, 2) or (N, 3). |
required |
n_patches
|
int or None
|
Exact number of patches, or |
None
|
points_per_patch
|
int
|
Target clustering size when inferring patch count. |
32
|
overlap
|
float
|
Nonnegative radius expansion fraction, less than one. |
0.25
|
min_points
|
int or None
|
Minimum samples inside every support. Defaults to dimension plus one. |
None
|
seed
|
int
|
Nonnegative integer for reproducible center initialization. |
0
|
from_mesh(mesh, *, n_patches=None, points_per_patch=32, overlap=0.25, min_points=None, seed=0)
classmethod
¶
Cover every triangle of a :class:TriangleMesh2D with open balls.
Each triangle is fully inside at least one patch ball, including its edges and vertices. This guarantees coverage of the mesh's geometric domain, including disconnected components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
TriangleMesh2D
|
Validated :class: |
required |
n_patches
|
int or None
|
Exact number of patches, or |
None
|
points_per_patch
|
int
|
Target clustering size when inferring patch count. |
32
|
overlap
|
float
|
Nonnegative radius expansion fraction, less than one. |
0.25
|
min_points
|
int or None
|
Minimum mesh vertices inside every support. Defaults to three. This does not guarantee polynomial rank. |
None
|
seed
|
int
|
Nonnegative integer for reproducible center initialization. |
0
|
rbflab.RBFFD.weights(*, centers, target, operator, space=None)
¶
Compute one explicit stencil, preserving the supplied center order.
Returns local weights (source DOFs, output components), multipliers, diagnostics, and reconstruct_local(). Uses the operators backend path.
rbflab.GlobalCollocation
dataclass
¶
Bases: MethodContract
Dense scalar or field collocation using radial kernels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kernel
|
object
|
Scalar radial kernel or bound symbolic kernel. |
_UNSET
|
precision
|
Precision
|
Arithmetic policy for assembly and solve. |
_UNSET
|
scheme
|
str
|
|
_UNSET
|
polynomial_degree
|
int, None, or "auto"
|
|
None
|
space
|
ScalarSpace
|
Optional ScalarSpace shorthand for scalar problems. |
_UNSET
|
collocation_scheme
|
str
|
Alias for scheme; specify only one spelling. |
_UNSET
|
spaces
|
dict or None
|
Optional field-to-space mapping for coupled Stokes problems. |
_UNSET
|
backend
|
object
|
Optional CppGlobalBackend for native stationary/unsteady scalar or steady/unsteady symmetric divergence-free Stokes solves in 2D/3D. |
None
|
Use assemble(problem, cloud) to obtain a system with a matrix and RHS;
then call system.solve(), or system.solve(dt=..., steps=...) for evolution.
prepare(problem, *, dimension=2, cache_dir=None)
¶
Prepare and cache required derivatives of a symbolic kernel.
Returns a method with compiled kernel support. With CppGlobalBackend, this warms the native worker executable and retains the bound kernel.
assemble(problem, cloud)
¶
Build a dense global collocation system.
Symmetric assembly applies functionals to both kernel arguments; asymmetric assembly uses ordinary kernel translates as its trial basis. Both solve for expansion coefficients, not nodal values. Coupled spaces and evolution problems dispatch to their systems.
rbflab.LHI
dataclass
¶
Bases: MethodContract
Sparse local Hermite interpolation for scalar PDEs or Stokes spaces.
Local systems mix solution, boundary, and PDE functionals. By default a stencil excludes its target from PDE centers; explicit groups select this rule. The sparse solve returns nodal values; off-node evaluation uses a nearby local stencil.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kernel
|
object
|
Radial kernel used in each local Hermite system. |
None
|
stencil_size
|
int
|
Number of nearby solution/boundary candidates. |
15
|
precision
|
Precision
|
Local and sparse-solve arithmetic policy. |
Precision()
|
centers
|
dict | None
|
Optional named CenterGroup mapping for independent scalar stationary data layouts. None preserves combined-neighbor selection. |
None
|
pde_stencil_size
|
int | None
|
Optional number of additional PDE centers in the default layout. |
None
|
polynomial_degree
|
int | None
|
Optional polynomial reproduction degree. |
None
|
stencil_policy
|
StencilPolicy
|
Neighbor selection and local scaling policy. |
StencilPolicy()
|
spaces
|
dict | None
|
Optional field-to-space mapping for divergence-free Stokes. |
None
|
local_backend
|
object
|
Optional supported local-weight backend. |
None
|
local_solver
|
LocalSolver
|
Backend-independent local factorization configuration. |
LocalSolver()
|
execution
|
object
|
Optional LocalExecution scheduling of LU Stokes weights. MPI requires CppBackend; global sparse solves remain separate. |
None
|
prepare(problem, *, dimension=2, cache_dir=None)
¶
Prepare and cache required derivatives of a symbolic kernel.
Returns a method using the prepared kernel. Native compilation needs an optional source build and is not part of core pip install.
assemble(problem, cloud)
¶
Construct local Hermite weights and the global sparse PDE system.
rbflab.RBFFD
dataclass
¶
Bases: MethodContract
Polynomial-augmented local finite differences on a point cloud.
The standard scheme uses value-based local ansatz functions. Alternative schemes and supported backends can be selected through constructor fields.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kernel
|
object
|
Radial basis function used for stencil weights. |
None
|
stencil_size
|
int
|
Number of points in each local stencil. |
15
|
polynomial_degree
|
object
|
Highest total polynomial degree, or |
None
|
precision
|
Precision
|
Local-weight and sparse-solve arithmetic policy. |
Precision()
|
stencil_policy
|
StencilPolicy
|
Selection and scaling of local points. |
StencilPolicy()
|
scheme
|
str
|
Local ansatz scheme; |
'standard'
|
local_backend
|
object
|
Optional local-weight implementation. |
None
|
local_solver
|
LocalSolver
|
Backend-independent factorization selection (currently LU). |
LocalSolver()
|
spaces
|
object
|
Optional source/target approximation-space mapping. |
None
|
Use operators(...) for reusable discrete matrices or assemble(...)
for a scalar PDE system.
weights(*, centers, target, operator, space=None)
¶
Compute one explicit stencil, preserving the supplied center order.
Returns local weights (source DOFs, output components), multipliers, diagnostics, and reconstruct_local(). Uses the operators backend path.
operators(*, source, targets=None, operators, space=None)
¶
Return reusable named sparse differentiation operators.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
PointCloud or ndarray
|
Finite (N, 2) or (N, 3) nodes. |
required |
targets
|
PointCloud or ndarray
|
Targets; defaults to source. |
None
|
operators
|
Mapping[str, Operator]
|
Named differential operators. |
required |
space
|
str
|
Field when multiple spaces are declared. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
OperatorSet |
OperatorSet
|
Entries expose matrix, local(i), and reconstruct_local(i). Only standard nodal RBF-FD is supported. |
prepare(problem, *, dimension=2, cache_dir=None)
¶
Prepare supported symbolic kernel derivatives for a problem.
May compile and cache native derivative code when the selected backend and kernel require it. Numeric kernel parameters remain runtime inputs; compilation is an optional source workflow.
assemble(problem, cloud)
¶
Assemble scalar PDE/boundary rows or dispatch an evolution system.
Stationary scalar rows apply PDE or boundary functionals to local value-interpolation bases and form a sparse nodal FDSystem. Evolution, space-based, and optional-backend configurations dispatch to their corresponding assemblers.
rbflab.DiscreteOperator
¶
Sparse map from source values to target operator values.
The matrix has one row per scalar target or per target component. Vector degrees of freedom are node-major: components of source node zero precede those of source node one. The @ operator accepts either a flattened vector or an (N, dimension) array for vector spaces. Local interpolation matrices are reconstructed only when requested.
local(i)
¶
Return indices, weights, multipliers, and diagnostics for target i.
Weight shape is (stencil DOFs, output components). Polynomial multipliers enforce local reproduction and do not enter the global sparse matrix. Raises IndexError for an invalid target index.
reconstruct_local(i)
¶
Rebuild the augmented local weight system at target i.
Returns a namespace with matrix, rhs, scaled_matrix, scaled_rhs, scale, backend, and local_digits. Append the multipliers from local(i) to its nodal weights to check matrix.T @ weights = rhs. Scaling equilibrates the same local equation.
rbflab.OperatorSet
¶
Bases: Mapping
Named operators assembled with shared local factorizations.
Access an operator by item (ops["lap"]) or attribute (ops.lap). diagnostics reports backend, factorization count, component ordering, and assembled matrix arithmetic.