warp.fem.interpolate#
- warp.fem.interpolate(
- integrand,
- dest=None,
- at=None,
- dest_space=None,
- dim=None,
- fields=None,
- values=None,
- reduction='weighted_average',
- device=None,
- kernel_options=None,
- temporary_store=None,
- bsr_options=None,
Interpolates a function at a finite set of sample points and optionally assigns the result to a discrete field, raw warp array, or sparse matrix.
Interpolation can be performed either at nodes of a function space (or a restriction of), typically used to set values of a discrete field, or at arbitrary points in a domain, for instance using a quadrature formula.
- Parameters:
integrand (Integrand | FieldLike) – Function to be interpolated: either a function with
warp.fem.integrand()decorator or a fielddest (DiscreteField | FieldRestriction | array | BsrMatrix | None) –
Where to store the interpolation result. Can be either
a
DiscreteField, or restriction of a discrete field to a domain (frommake_restriction());a normal warp
array;- a sparse matrix (
warp.sparse.BsrMatrix). This will compute the Jacobian of integrand, assuming one of the passed fields is a trial field, and that the result is a linear function of the trial field;
- a sparse matrix (
None, meaning the integrand will be evaluated at the interpolation sample points, but the result will be discarded.
at (Quadrature | SpaceRestriction | GeometryDomain | None) –
Location of the interpolation samples. Can be either
a
SpaceRestriction, in which case interpolation will be performed at each node of dest_space in the restriction’s domain.a
Quadrature, in which case interpolation will be performed at each quadrature point.a
GeometryDomain. In this case, interpolation will be performed:at each of the domain’s nodes, if dest is a field or dest_space is provided;
at an arbitrary number of samples, in the domain if dim is provided;
at each of the domain’s elements, otherwise).
None, in which case it will be inferred from dest or dest_space, when possible.
dest_space (FunctionSpace | None) – When interpolating at nodes, the function space that defines the degree of freedom basis. If dest is a
DiscreteField, or aFieldRestriction, this will be inferred from the space of the field.dim (int | None) – If dest is an array or
None, and at is aGeometryDomain, the number of arbitrary samples at which to interpolate. In this case, theSamplepassed to the integrand will be invalid, but the sample point indexs.qp_indexcan be used to define custom interpolation logic.fields (dict[str, FieldLike] | None) – Discrete fields to be passed to the integrand. Keys in the dictionary must match integrand parameters names.
values (dict[str, Any] | None) – Additional variable values to be passed to the integrand, can be of any type accepted by warp kernel launches. Keys in the dictionary must match integrand parameter names.
reduction (str) – Reduction method to be used for interpolation at nodes shared by several elements. Can be one of “weighted_average”, “mean”, “sum”, “max”, “min”, “first”. Default to “weighted_average”, meaning measure-weighted average over neighboring elements. If the interpolated field is continuous, meaning that the returned value is identical regardless of the element used for evaluation, all reduction methods should be equivalent but “first” will have the lowest computational cost.
device – Device on which to perform the interpolation
kernel_options (dict[str, Any] | None) – Overloaded options to be passed to the kernel builder (e.g,
{"enable_backward": True})temporary_store (TemporaryStore | None) – shared pool from which to allocate temporary arrays
bsr_options (dict[str, Any] | None) – Additional options to be passed to the sparse matrix construction algorithm. See
warp.sparse.bsr_set_from_triplets()andwarp.sparse.bsr_compress(). In addition to sparse options,capacity="auto"allows FEM to grow sparse storage as needed, whilecapacity="reuse"requires existingdestarrays to be large enough and does not grow them. Omittingconstructionuses"triplets".construction="auto"opts into automatic selection of a suitable construction method, whose choices may change in future releases; currently it uses row compression when supported and falls back to triplets for unsupported interpolation cases.construction="triplets"forces temporary COO triplet construction, whileconstruction="row_compress"forces row-ordered candidate writes followed bywarp.sparse.bsr_compress(). Non-differentiable outputs use in-place compression for the lowest memory overhead. Row compression for quadrature interpolation requires matching evaluation and indexed point counts.