warp.fem#

Finite Element Method (FEM) toolkit for solving differential equations.

This module provides tools for solving physical systems described as partial differential equations (PDEs) using finite-element-based Galerkin methods. It supports diffusion, convection, fluid flow, and elasticity problems with various FEM formulations and discretization schemes.

The core workflow involves defining geometries (grids, meshes, NanoVDB volumes), function spaces with shape functions, integration domains, and using the integrate() function with integrand()-decorated kernels to build linear and bilinear forms for solving linear systems.

Usage:

This module must be explicitly imported:

import warp.fem

See also

FEM Toolkit for comprehensive documentation and examples.

Submodules#

These modules are automatically available when you import warp.fem.

API#

AdaptiveNanogrid

Adaptive sparse grid.

BasisSpace

Interface class for defining shape functions over a geometry.

BoundarySides

A Domain containing boundary sides of the geometry or geometry partition.

CellBasedGeometryPartition

Geometry partition based on a subset of cells.

Cells

A Domain containing all cells of the geometry or geometry partition.

Coords

alias of vec3f

DiscreteField

Explicitly-valued field defined over a partition of a discrete function space.

DofMapper

Base class for mapping node degrees of freedom to function values.

Domain

Tag for domain-like integrand arguments

Element

Enumeration of reference element types.

ElementBasis

Choice of basis function to equip individual elements.

ElementIndex

alias of int

ElementKind

Type of geometry elements.

ExplicitGeometryPartition

Geometry partition defined by an explicit cell selection mask.

ExplicitQuadrature

Quadrature using explicit per-cell points and weights.

Field

Tag for field-like integrand arguments

FieldLike

Base class for integrable fields.

FrontierSides

A Domain containing frontier sides of the geometry partition (sides shared with at least another partition).

FunctionSpace

Interface class for function spaces, i.e. geometry + interpolation basis.

Geometry

Interface class for discrete geometries

GeometryDomain

Interface class for domains, i.e. (partial) views of elements in a Geometry.

GeometryField

Base class for fields defined over a geometry.

GeometryPartition

Base class for geometry partitions, i.e. subset of cells and sides.

Grid2D

Two-dimensional regular grid geometry.

Grid3D

Three-dimensional regular grid geometry.

Hexmesh

Hexahedral mesh geometry.

ImplicitField

Field defined from an arbitrary function over a domain.

Integrand

An integrand is a device function containing arbitrary expressions over Field and Domain variables.

LinearGeometryPartition

Geometry partition that uniformly divides cells by index range.

Nanogrid

Sparse grid geometry.

NodalQuadrature

Quadrature using space node points as quadrature points

NodeIndex

alias of int

NonconformingField

Field defined as the map of a DiscreteField over a non-conforming geometry.

Operator

Provide syntactic sugar over Field and Domain evaluation functions and arguments.

PicQuadrature

Particle-based quadrature formula, using a global set of points unevenly spread out over geometry elements.

PointBasisSpace

Unstructured basis space with radial basis kernel functions.

Polynomial

Polynomial family defining interpolation nodes over an interval.

Quadmesh2D

Two-dimensional quadrilateral mesh.

Quadmesh3D

Three-dimensional quadrilateral mesh.

Quadrature

Interface class for quadrature rules.

QuadraturePointIndex

alias of int

RegularQuadrature

Regular quadrature formula, using a constant set of quadrature points per element.

Sample

Per-sample point context for evaluating fields and related operators in integrands.

ShapeBasisSpace

Base class for defining shape-function-based basis spaces.

ShapeFunction

Interface class for defining scalar-valued shape functions over a single element.

Sides

A Domain containing all (interior and boundary) sides of the geometry or geometry partition.

SkewSymmetricTensorMapper

Orthonormal isomorphism from R^{n (n-1)} to nxn skew-symmetric tensors, using usual L2 norm for vectors and half Frobenius norm, (tau : tau)/2 for tensors.

SpacePartition

Partition of a function space over a geometry partition.

SpaceRestriction

Restriction of a space partition to a given GeometryDomain.

SpaceTopology

Interface class for defining the topology of a function space.

Subdomain

Restriction of domain to a subset of its elements.

SymmetricTensorMapper

Orthonormal isomorphism from R^{n (n+1)} to nxn symmetric tensors, using usual L2 norm for vectors and half Frobenius norm, (tau : tau)/2 for tensors.

Temporary

alias of array

TemporaryStore

Shared pool of temporary arrays that will be persisted and reused across invocations of warp.fem functions.

Tetmesh

Tetrahedral mesh geometry.

Trimesh2D

2D Triangular mesh geometry

Trimesh3D

3D Triangular mesh geometry

UniformField

Field defined as a constant value over a domain.

D

Symmetric part of the (inner) gradient of the field at s.

adaptive_nanogrid_from_field

Constructs a warp.fem.AdaptiveNanogrid from a coarse grid and a refinement field.

adaptive_nanogrid_from_hierarchy

Constructs a warp.fem.AdaptiveNanogrid from a non-overlapping grid hierarchy.

at_node

Return a copy of the Sample s moved to the coordinates of a local node of the field f.

average

Average between inner and outer element values.

borrow_temporary

Borrow and return a temporary array with specified attributes from a shared pool.

borrow_temporary_like

Borrow and return a temporary array with the same attributes as another array or temporary.

cells

Convert a domain defined on geometry sides to a domain defined of cells.

curl

Skew part of the (inner) gradient of the field at s, as a vector such that wp.cross(curl(u), v) = skew(grad(u)) v.

deformation_gradient

Evaluate the gradient of the domain position with respect to the element reference space at the sample point s.

degree

Polynomial degree of a field.

div

Evaluate the field divergence at a sample point s.

div_outer

Evaluate the field divergence at a sample point s.

element_closest_point

Compute the coordinates of the closest point to a world position within a given element.

element_coordinates

Return the coordinates in an element reference system corresponding to a work position.

element_index

Return the index in the geometry of the domain_element_index'th domain element.

element_partition_index

Return the index of the passed cell in the domain's geometry partition, or NULL_ELEMENT_INDEX if not part of the partition.

grad

Evaluate the field gradient at a sample point s.

grad_average

Average between inner and outer element gradients.

grad_jump

Jump between inner and outer element gradients on an interior side.

grad_outer

Evaluate the field gradient at a sample point s.

inner

Evaluate the field at a sample point s.

integrand

Decorator for functions to be integrated (or interpolated) using warp.fem.

integrate

Integrates a constant, linear or bilinear form, and returns a scalar, array, or sparse matrix, respectively.

interpolate

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.

jump

Jump between inner and outer element values on an interior side.

lookup

Look up the sample point corresponding to a world position x, projecting to the closest point on the geometry.

make_collocated_function_space

Constructs a function space from a scalar-valued basis space and a value type, such that all degrees of freedom of the value type are stored at each of the basis nodes.

make_contravariant_function_space

Constructs a contravariant function space from a vector-valued basis space

make_covariant_function_space

Constructs a covariant function space from a vector-valued basis space

make_discrete_field

Constructs a zero-initialized discrete field over a function space or partition

make_element_based_space_topology

Makes a space topology from a geometry and an element-based shape function.

make_element_shape_function

Equip a reference element with a shape function basis.

make_free_sample

Return a Sample that is not associated to any quadrature point or dof.

make_polynomial_basis_space

Equips a geometry with a polynomial basis.

make_polynomial_space

Equips a geometry with a collocated, polynomial function space.

make_restriction

Restricts a discrete field to a subset of elements.

make_space_partition

Compute the subset of nodes from a function space topology that touch a geometry partition

make_space_restriction

Restricts a function space partition to a Domain, i.e. a subset of its elements.

make_test

Constructs a test field over a function space or its restriction

make_trial

Constructs a trial field over a function space or partition

measure

Return the measure (volume, area, or length) determinant of an element at a sample point s.

measure_ratio

Return the maximum ratio between the measure of this element and that of higher-dimensional neighbors.

node_count

Return the number of nodes associated to the field f in the element containing the sample s.

node_index

Return the index in the function space of a local node of the field f.

node_inner_weight

Return the inner element weight associated to a local node of the field f at the sample point s.

node_inner_weight_gradient

Return the gradient (w.r.t world coordinates) of the inner element weight associated to a local node of the field f at the sample point s.

node_outer_weight

Return the outer element weight associated to a local node of the field f at the sample point s.

node_outer_weight_gradient

Return the gradient (w.r.t world coordinates) of the outer element weight associated to a local node of the field f at the sample point s.

node_partition_index

For a NodalField f, returns the index of a given node in the fields's space partition, or NULL_NODE_INDEX if it does not exists.

normal

Evaluate the element normal at the sample point s.

normalize_dirichlet_projector

Scale projector so that it becomes idempotent, and apply the same scaling to fixed_value if provided

outer

Evaluate the field at a sample point s.

partition_lookup

Look up the sample point corresponding to a world position x, projecting to the closest point on the geometry partition.

position

Evaluate the world position of the sample point s.

project_linear_system

Projects both the left-hand-side and right-hand-side of a linear system to enforce Dirichlet boundary conditions

project_system_matrix

Projects the right-hand-side of a linear system to enforce Dirichlet boundary conditions

project_system_rhs

Projects the right-hand-side of a linear system to enforce Dirichlet boundary conditions

set_default_temporary_store

Globally sets the default TemporaryStore instance to use for temporary allocations in warp.fem functions.

to_cell_side

Convert a Sample defined on a cell to a sample defined on one of its side.

to_inner_cell

Convert a Sample defined on a side to a sample defined on the side's inner cell.

to_outer_cell

Convert a Sample defined on a side to a sample defined on the side's outer cell.

NULL_ELEMENT_INDEX

Constant indicating an invalid element index.

NULL_NODE_INDEX

Constant indicating an invalid node index.

NULL_QP_INDEX

Constant indicating an invalid quadrature point index.

OUTSIDE

Constant indicating an invalid element coordinate.