Skip to content

add quadrature to function space - #433

Draft
jacobmerson wants to merge 10 commits into
developfrom
stack/0.5/01-quadrature
Draft

jacobmerson wants to merge 10 commits into
developfrom
stack/0.5/01-quadrature

Conversation

@jacobmerson

Copy link
Copy Markdown
Collaborator

No description provided.

… validation are virtuals of the kind

FunctionSpace is no longer final. CreateFieldData (what a field of the space
holds) and ValidateFieldData (what CreateFunction(name, data) accepts) become
virtuals of the kind, with defaults that hold the layout's values in a
SimpleFieldData and check the size of the data's DOF values against the
layout.

This replaces the create_field_data std::function in the constructor and the
#ifdef/dynamic_cast chain of function_space.cpp: the Omega_h and MeshFields
Lagrange spaces are kinds that override the two virtuals, the other spaces use
the defaults, and the evaluation-only mock of the tests derives from the class.
CoordinateSystem stays a descriptor (labels and closed forms) and gains
IsOrthogonal, IsNormalized (every scale factor is 1) and Period(axis) in place
of HasOrthogonalBasis and HasUnitScaleFactors, the non-virtual IsOrthonormal
(both) in place of detail::HasIdentityMetric, HasMetric, and Bind(points),
which gives a BoundCoordinateSystem with the closed-form metric g(p, i, j) and
the volume factor as pcms views. A system whose metric is the same at every
point allocates one entry for all of them.

The cylindrical (R, theta, Z) system has the metric diag(1, R^2, 1), volume
factor R and the period 2 pi along theta. The poloidal (R, Z) plane has the
identity metric and the volume factor R: the volume factor is sqrt(det g)
except for a coordinate system reduced by a symmetry, whose factor includes
the ignored direction.

csys::CreateParameterSystem(name, dimension, periods) is a coordinate system
of labels only (logical indices, flux coordinates): HasMetric() is false and
Bind throws, since the metric of a geometry over it is the geometry's. A
parameter system equals only itself.

Breaking: the two flags are renamed (C++, Python is_orthogonal and
is_normalized, with is_orthonormal; MIGRATION.md).
The Jacobian of a geometry belongs to the points it is evaluated at, and the
metric to the geometry, not to a public method taking a BoundPoints:
Geometry::Differential(bound) and DifferentialView are removed. A BoundPoints
gives its geometric factors -- Jacobian() J(p, j, i) = d x_j / d xi_i from the
geometry's parameter coordinates to its coordinate system, and Metric() and
VolumeFactor() in those coordinates -- computed once on first use by the
protected virtual ComputeFactors. The default is the coordinate system's:
J = I and the closed-form metric of the geometry's coordinate system at the
located points.

LocatedPointValues() becomes LocatedPoints(), a CoordinateView of the located
points; the Kokkos view stays a protected accessor of the kinds.

The Omega_h geometry keeps the per-element Jacobian of its affine simplices as
the kind-internal CellJacobian, which its element measures read (its binding
picks no element, so the factors of its points are the coordinate system's).

Breaking for geometry implementations and callers of Differential and
LocatedPointValues (MIGRATION.md).
… for Omega_h meshes

A Quadrature is points bound on the geometry that generated them (no search)
and one weight per point, so that the integral of f is sum_p w_p f(x_p).
CreateGaussQuadrature(geometry, order) and CreateMonteCarloQuadrature(geometry,
samples_per_cell, seed = DefaultQuadratureSeed) ask the geometry's kind for the
rule through the protected virtual Geometry::CreateQuadrature(rule), which
throws by default.

OmegaHGeometry implements it on 2D and 3D simplex meshes: MeshFields' reference
rules of a given order on every element, or uniform random samples per element
(cell measure / samples per cell), drawn from the seed and the element's
global id, so that the samples do not depend on the partition. The weights are
the cell measures from the geometry's cell Jacobians times the volume factor of
the bound points, i.e. physical measures in any system that has a metric.

The reference rules move from the form-integrator utilities of the transfer
library to the Omega_h backend (simplex_quadrature.hpp); the utilities use them
from there.
CreateIntersectionQuadrature(source, target, order) clips every target
element against the source mesh (r3d) and generates the reference rule on the
sub-simplices of the pieces. The points are bound on the target geometry without
a search and Quadrature::other names the source element each lies in, so the
source geometry binds the same points without a search either. Integrating the
product of a source and a target basis function over the pieces is exact when
the rule's order is the sum of their degrees. The weights carry the volume
factor of the target geometry's coordinate system.

It lives in the transfer library because r3d is a dependency of that library
only.
…a sparse matrix

EvaluateTranspose(values, functional) adds E^T values to a functional, E being
the linear map from the DOFs of a field of the evaluator's layout to its values
at the points, so that <E x, y> = <x, E^T y>. The functional is a plain Field of
the layout (dual to the coefficients, not a Function), accumulated into; the
layout, the value basis and the shape of values are checked. A kind that
supports it (SupportsTranspose) sums the contributions to DOF holders other
ranks own into their owners itself, so the result equals the one-rank result,
and leaves the functional consistent.

SupportsMatrix/GetMatrix give the same evaluation as a CSR matrix whose columns
are global DOF-holder ids.

The Omega_h Lagrange evaluator (orders 0 and 1) implements both from a basis
(holders and weights per point) computed once at construction; Evaluate is now
the application of that basis, so the three share it. Ghost contributions are
reduced into their owners with Omega_h's reduce_array.
The space's natural quadrature on its geometry, built once from a virtual of
the kind (CreateQuadrature, throwing by default); it integrates the product of
two functions of the space exactly.
The Omega_h Lagrange spaces take the geometry's Gauss rule of degree 2p for
order p (at least 1), the degree of the product of two functions of order p.
detail::BindQuadrature binds the points of a rule and scales the weights
by the volume factor when the system has a metric, for the Omega_h and
intersection quadratures.
The polynomial degree a quadrature integrates exactly, or -1. The simplex
reference rules and the intersection rule report their order; Monte Carlo
rules report -1.
The device views are LayoutLeft on a GPU, so their host mirrors do not
share the flat order of the LayoutRight host views. Multi-component
cases compared mismatched entries on CUDA.

This branch was successfully deployed

1 active deployment
asics — d8792233 Deployed Nov 26, 2026 by jacobmerson via build_and_test #482
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant