Repository navigation
add quadrature to function space - #433
Draft
jacobmerson wants to merge 10 commits into
Draft
jacobmerson wants to merge 10 commits into
jacobmerson wants to merge 10 commits into
Conversation
… 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.