hermit.fenics.assembly ====================== .. py:module:: hermit.fenics.assembly .. autoapi-nested-parse:: Thin PETSc/UFL assembly helpers for DOLFINx (0.9 / 0.11). Slim port of the pieces of ``femo_alpha/fea/utils_dolfinx.py`` that Hermit's custom operations actually need. No CSDL here. .. !! processed by numpydoc !! Functions --------- .. autoapisummary:: hermit.fenics.assembly.assemble_matrix hermit.fenics.assembly.assemble_scalar hermit.fenics.assembly.assemble_vector hermit.fenics.assembly.derivative hermit.fenics.assembly.get_array hermit.fenics.assembly.ksp_mumps hermit.fenics.assembly.matvec hermit.fenics.assembly.owned_entry_mask hermit.fenics.assembly.owning_cell hermit.fenics.assembly.project hermit.fenics.assembly.rmatvec hermit.fenics.assembly.set_array hermit.fenics.assembly.transpose Module Contents --------------- .. py:function:: assemble_matrix(a, bcs=()) -> petsc4py.PETSc.Mat Assemble a 2-form to an assembled PETSc matrix. .. !! processed by numpydoc !! .. py:function:: assemble_scalar(f) -> float Assemble a scalar UFL form to a float. .. !! processed by numpydoc !! .. py:function:: assemble_vector(f) -> numpy.ndarray Assemble a 1-form to a numpy array. .. !! processed by numpydoc !! .. py:function:: derivative(f, u, du=None) d f / d u as a UFL form (or w.r.t. a coefficient / SpatialCoordinate). .. !! processed by numpydoc !! .. py:function:: get_array(f: dolfinx.fem.Function) -> numpy.ndarray Local array of a Function (owned + ghost). .. !! processed by numpydoc !! .. py:function:: ksp_mumps(A: petsc4py.PETSc.Mat) -> petsc4py.PETSc.KSP A preonly + LU(MUMPS) KSP for the (already assembled) operator ``A``. .. !! processed by numpydoc !! .. py:function:: matvec(A: petsc4py.PETSc.Mat, x: dolfinx.fem.Function) -> numpy.ndarray A @ x (x a Function, result a numpy array of A's row layout). .. !! processed by numpydoc !! .. py:function:: owned_entry_mask(dofmap_list, n_scalar_dofs) ``(n_cells, n_local_nodes)`` bool -- True where the cell owns that dof. .. !! processed by numpydoc !! .. py:function:: owning_cell(dofmap_list, n_scalar_dofs) ``scalar dof -> the cell that writes it last`` in ascending cell order. ``Function.interpolate`` scatters a point evaluation per cell, so a shared (continuous) target dof is written once per adjacent cell and the last writer wins. The interpolation *Jacobian* must therefore carry only the owning cell's row -- taking the union of every adjacent cell's contribution (which is what a plain COO scatter does, since each cell contributes on its own source columns) over-counts it. Deduplicating (row, col) pairs is not enough: the columns mostly differ, so the duplicates never collide. Same construction as ``hermit._field._Tabulation.dof_cell``, and a no-op on DG (every dof has exactly one cell). .. !! processed by numpydoc !! .. py:function:: project(expr, target: dolfinx.fem.Function, lump_mass: bool = False) -> None L2-project a UFL expression onto ``target``'s space (used for field outputs). .. !! processed by numpydoc !! .. py:function:: rmatvec(A: petsc4py.PETSc.Mat, x: dolfinx.fem.Function) -> numpy.ndarray A.T @ x. .. !! processed by numpydoc !! .. py:function:: set_array(f: dolfinx.fem.Function, values) -> None Set a Function from a flat array and sync ghosts. .. !! processed by numpydoc !! .. py:function:: transpose(A: petsc4py.PETSc.Mat) -> petsc4py.PETSc.Mat