Darcy in three dimensions
Tetrahedral, prismatic and mapped mixed formulations with their explicit geometry and degree contracts.
For primal tetrahedral MHM, TriangularSkeleton(..., continuous=True) selects
continuous piecewise polynomials within each macroface. A boolean sequence
mixes continuous and discontinuous faces. Face degrees and partitions remain
independent of the local finite-element degree. Continuous faces accept every
positive polynomial degree, subject to the
trace compatibility conditions.
User-defined formulations compose these public numerical owners with
LocalEquations and Equation; their editable providers are listed in the
variational guide.
Physical field records provide optional interpretation of the resulting
coefficients. Named FieldDefinition views require no physical solver object.
Basix scalar Pk topology, tabulation and affine tetrahedral operators.
tetrahedron_quadrature(order: int = 5) -> tuple[FloatArray, FloatArray]
Return positive Duffy-product quadrature with weights normalized to unit volume.
tetra_nodal_space(mesh: TetraMesh, degree: int) -> tuple[IntArray, FloatArray]
Enumerate continuous Pk nodes using exact topological identities.
tetra_basis(degree: int, bary: FloatArray) -> tuple[FloatArray, FloatArray]
Return Basix Pk values and canonical four-axis barycentric derivatives.
The extension and unit-sum point convention follow
:func:pymhm.fem.scalar.tetrahedron_topology.tetra_values_gradients for every degree.
tetra_face_basis(degree: int, bary: FloatArray, *, opposite_vertex: int) -> FloatArray
Restrict the executed nodal Pk basis to one exact reference face.
bary has four unit-sum coordinates with coordinate opposite_vertex
exactly zero. Entries whose integer nodal weight on that vertex is nonzero
have identically zero trace and are excluded through the declared topology.
Values on the face support retain the native volume table unchanged. The
volume basis, its coefficients and physical derivative maps are unaffected.
tetra_tabulate(mesh: TetraMesh, degree: int, bary: FloatArray, *, backend: Literal['portable', 'basix'] = 'basix') -> tuple[IntArray, FloatArray, FloatArray, FloatArray]
Return nodal DOFs/coordinates, basis values and physical gradients.
Basix supplies equispaced Pk values/Cartesian derivatives in the literal
:func:tetra_indices node order. Barycentric points must sum to one.
PyMHM supplies the affine cell geometry and continuous DOF topology.
backend='portable' is a compatibility spelling for this same Basix
execution; there is no separate cardinal-polynomial implementation.
tetra_element_tabulate(mesh: TetraMesh, degree: int, bary: FloatArray, *, backend: Literal['portable', 'basix'] = 'basix') -> tuple[IntArray, FloatArray, FloatArray, FloatArray, FloatArray]
Tabulate continuous Pk values, physical gradients and physical Hessians.
backend follows :func:tetra_tabulate. Basix tabulates both
derivative orders to the library before applying the affine Jacobian.
tetra_operators(mesh: TetraMesh, degree: int = 2, *, diffusion: Any = 1.0, source: Any = 0.0, order: int = 5, element_backend: Literal['portable', 'basix'] = 'basix') -> tuple[Any, Any, FloatArray]
Assemble scalar diffusion, consistent mass and source with positive quadrature.
Basix tabulates equispaced Pk in the declared nodal order. Integration and
affine geometry retain their conventions. element_backend='portable'
is a compatibility spelling for this same Basix execution.
Compiled binary64 diffusion integration compensates both Cartesian
contractions and quadrature sums; mass and source retain their formulas.
tetra_boundary_nodes(mesh: TetraMesh, degree: int) -> IntArray
Return sorted continuous-Pk nodal coordinates on the exterior boundary.
Exterior incidence is tested in affine barycentric coordinates against the opposite local vertex, with the existing geometric tolerance 1e-12. This identifies nodes; it neither projects boundary data nor chooses a PDE sign.
Affine mixed-cell H(div) volume and oriented trace forms in three dimensions.
Normal densities are dual to integral face moments; pressure uses the family's cell polynomial convention. Trace degrees and partitions remain caller-chosen.
Mixed3DSkeleton
Pk triangular and Qk rectangular physical flux traces on original macrofaces.
size: int
property
Return the global number of scalar normal-flux moments.
__init__(mesh: AffineMixedMesh, degree: int = 1, subdivisions: int = 1) -> None
Create canonical moment blocks for every face and aligned subdivision.
cell_dofs(cell: int) -> IntArray
Return the concatenated face blocks of one macrocell.
hdiv3d_operators(mesh: AffineMixedMesh, family: HDiv3DFamily, *, permeability: Any = 1.0, source: Any = 0.0, quadrature_order: int = 5) -> tuple[Any, Any, FloatArray, FloatArray]
Assemble conforming mass, divergence, source and physical pressure moments.
hdiv3d_trace_mapping(skeleton: Mixed3DSkeleton, cell: int, fine: AffineMixedMesh, normal_degree: int = 1) -> FloatArray
Integrate canonical fine-face moments of each oriented macro normal density.
hdiv3d_boundary_data(skeleton: Mixed3DSkeleton, dirichlet: Any, neumann: dict[int, Any], order: int) -> tuple[FloatArray, dict[int, float]]
Integrate weak pressure or outward physical normal-flux moments at the boundary.
Affine H(div) families, quadrature and their moment conventions are documented in the finite-element API.
Basix RT spaces with declared tensor moments and contravariant Piola maps.
Normal DOFs are integral tensor-Legendre moments. Scalar Qk pressure uses an ordinary pullback; divergence carries the inverse geometric determinant.
tensor_legendre_values(degree: int, points: FloatArray) -> FloatArray
Evaluate tensor Legendre polynomials, with the last coordinate varying fastest.
mapped_rt_dofs(mesh: HexMesh, degree: int) -> IntArray
Map shared integral normal moments and independent cell-interior bubbles.
mapped_reference_coefficients(degree: int) -> FloatArray
cached
Express declared hexahedral face lifts and bubble coefficients in native RT.
mapped_rt_basis(mesh: HexMesh, degree: int, points: FloatArray) -> tuple[FloatArray, FloatArray, FloatArray]
Tabulate oriented physical RT_k vectors, their exact Piola divergence and scalar Q_k.
Physical scalar trace coordinates and boundary integrals on polygonal macrofaces.
Each original face owns one planar polynomial regardless of its triangulation. Internal triangulation edges do not introduce global trace unknowns.
PolygonalSkeleton3D
Independent P0/P1 Robin-flux densities on original polygonal macrofaces.
A planar P1 trace has exactly three coefficients regardless of the number
of face vertices or triangles. Its basis is (1, s, t) in orthonormal
tangential coordinates centered at the area centroid and scaled by sqrt(area).
Internal triangulation edges introduce no skeletal degrees of freedom.
__init__(mesh: PolyhedralMesh, degree: Any = 1) -> None
Assign one degree or one independently selected P0/P1 degree per face.
dofs(face: int) -> IntArray
Return the coefficients belonging to one original polygonal face.
cell_dofs(cell: int) -> IntArray
Concatenate the cell's complete original-face coefficient blocks.
basis(face: int, points: FloatArray) -> FloatArray
Evaluate the single macroface polynomial in canonical physical coordinates.
polygonal_trace_coupling(mesh: PolyhedralMesh, cell: int, fine: TetraMesh, skeleton: PolygonalSkeleton3D, degree: int) -> FloatArray
Integrate oriented Pk/P0–P1 coupling through the conforming fine boundary triangles.
polygonal_face_quadrature(mesh: PolyhedralMesh, face: int, order: int) -> tuple[FloatArray, FloatArray]
Integrate the polygon by its canonical conforming triangulation with positive weights.
polygonal_boundary_data(skeleton: PolygonalSkeleton3D, dirichlet: Any, natural: dict[int, Any], order: int) -> tuple
Form weak Dirichlet moments or L2-project outward Robin fluxes on original faces.
Oriented triangular-face spaces, coupling and physical scalar boundary moments.
Trace coefficients represent densities in the macroface's canonical normal. Bernstein coefficients are independent or shared within each physical macroface.
TriangularSkeleton
Piecewise Pk flux densities, discontinuous or C0 within each macroface.
subdivisions counts uniform edge divisions, giving its square many
subtriangles by default. Explicit face_partitions instead prescribe a
conforming nonuniform triangulation of each original macroface. Each
subtriangle has (k+1)(k+2)/2 local Bernstein modes. continuous=True shares
vertex and edge coefficients inside a macroface and requires k >= 1.
Sequences select independent face degrees and continuity flags. No degrees
of freedom are shared between macrofaces, including their common edges.
Flux uses the canonical normal of TetraMesh.
__init__(mesh: TetraMesh, subdivisions: Any = 1, *, degree: Any = 0, face_partitions: tuple[FloatArray, ...] | None = None, continuous: Any = False) -> None
Create uniform or explicit conforming triangular partitions with Pk modes.
Explicit vertices use barycentric coordinates in mesh.faces[face]
ordering. Every original face must be covered without holes, overlaps or
hanging internal edges. subdivisions and partitions retain the
uniform-grid configuration; face_partition returns the active geometry.
face_partition(face: int) -> FloatArray
Return active subtriangles in original macroface barycentric coordinates.
face_weights(face: int) -> FloatArray
Return positive subtriangle area fractions summing to one on a macroface.
basis(face: int, barycentric: FloatArray) -> FloatArray
Evaluate the Bernstein Pk density basis on a canonical subtriangle.
Degrees zero and one retain their constant and barycentric coordinate conventions. All modes integrate to the same fraction of subface area, and coefficients equal to one represent a constant density exactly.
subtriangle_dofs(face: int, segment: int) -> IntArray
Return global coefficients in the subtriangle's local Bernstein ordering.
C0 vertex and edge coefficients are shared only within this macroface. The map transports local orientations to the declared canonical numbering.
evaluate(face: int, barycentric: FloatArray) -> FloatArray
Evaluate the complete macroface basis in original barycentric coordinates.
Columns follow dofs(face). At partition interfaces the first incident
subtriangle supplies the DG one-sided value; C0 values agree on both sides.
dofs(face: int) -> IntArray
Return the global coefficients for one validated macroface index.
cell_dofs(cell: int) -> IntArray
Concatenate the four oriented macroface coefficient blocks of a cell.
tetra_trace_coupling(coarse: TetraMesh, cell: int, fine: TetraMesh, skeleton: TriangularSkeleton, degree: int) -> FloatArray
Integrate signed nodal Pk traces against aligned triangular Bernstein modes.
tetra_boundary_data(skeleton: TriangularSkeleton, dirichlet: Any, neumann: dict[int, Any], order: int) -> tuple[FloatArray, dict[int, float]]
Integrate weak pressure moments and project prescribed outward normal fluxes.
The quadrature floor integrates the Bernstein Gram matrix exactly even when the independently selected trace degree exceeds the local degree. Nonpolynomial boundary data can require a higher caller-supplied order.
Continuous pressure traces and physical boundary quadrature on tetrahedra.
PressureTraceSpace3D
dataclass
Continuous nodal Pk functions on a uniformly triangulated tetrahedral skeleton.
Each original triangular face has subdivisions**2 subtriangles. Polynomial degrees and subdivision counts are independent of the broken conormal space. Nodes on shared macroedges and vertices are identified by exact integer barycentric weights, never by rounded physical coordinates. The uniform face degree and subdivisions ensure conforming edge traces.
size: int
property
Return the global continuous pressure-trace dimension before boundary elimination.
__post_init__() -> None
Construct topological node identities on each canonical subtriangle.
cell_dofs(cell: int) -> IntArray
Return the sorted pressure-trace nodes incident to one macrocell.
evaluate(face: int, bary: FloatArray) -> FloatArray
Evaluate all face-local nodal functions at original-face barycentric points.
boundary_rules(coarse: TetraMesh, cell: int, fine: TetraMesh, degree: int, order: int) -> tuple[tuple[int, IntArray, FloatArray, FloatArray, FloatArray, FloatArray], ...]
Tabulate physical fine-boundary facets and their original macroface coordinates.
Each tuple contains macroface index, incident volume DOFs, nodal basis, physical XYZ points, physical weights, and macroface barycentric coordinates. Fine tetrahedra must conform to the macrocell boundary.
broken_face_basis(skeleton: TriangularSkeleton, face: int, bary: Any) -> FloatArray
Evaluate DG or macroface-C0 conormal modes in the skeleton's coefficient order.
Broken tetrahedral pressure and physical gradient flux with conservative trace.
flux evaluates -K grad(p) and is generally not H(div)-conforming.
Macro conservation refers to hybrid.trace, not this raw gradient field.
evaluate(cell: int, bary: FloatArray) -> tuple[FloatArray, FloatArray]
Evaluate pressure and physical flux at common fine-cell barycentric points.
l2_error(exact: Any, order: int = 6) -> float
Integrate the broken pressure error with independently selected positive quadrature.
flux_l2_error(exact: Any, order: int = 6) -> float
Integrate the full physical flux, including P2 gradient and variable diffusion.
conservation_residuals(order: int | None = None) -> FloatArray
Return outward skeletal flux minus integrated source in every macrocell.
Affine H(div) flux and discontinuous pressure with their MHM skeleton.
evaluate(cell: int, points: FloatArray) -> tuple[FloatArray, FloatArray, FloatArray]
Evaluate pressure, physical flux and divergence in every local cell.
errors(pressure: Any, flux: Any, order: int = 6) -> dict[str, float]
Integrate physical pressure/vector-flux L2 errors with positive quadrature.
equilibrium_residuals(order: int = 6) -> tuple[FloatArray, ...]
Return every pressure-tested fine-cell divergence/source defect.