diff --git a/animate/interpolation.py b/animate/interpolation.py index 8b2d316..ac9314e 100644 --- a/animate/interpolation.py +++ b/animate/interpolation.py @@ -7,13 +7,13 @@ import ufl from firedrake.functionspaceimpl import FiredrakeDualSpace, WithGeometry from firedrake.petsc import PETSc -from firedrake.supermeshing import assemble_mixed_mass_matrix from petsc4py import PETSc as petsc4py from pyop2 import op2 from animate.quality import QualityMeasure from animate.utility import ( assemble_mass_matrix, + assemble_mixed_mass_matrix, cofunction2function, function2cofunction, ) diff --git a/animate/utility.py b/animate/utility.py index 741ef38..575c99b 100644 --- a/animate/utility.py +++ b/animate/utility.py @@ -6,6 +6,7 @@ import firedrake import firedrake.mesh as fmesh +import firedrake.supermeshing as fsup import ufl from firedrake.__future__ import interpolate from firedrake.petsc import PETSc @@ -268,6 +269,27 @@ def assemble_mass_matrix(space, norm_type="L2"): return firedrake.assemble(lhs).petscmat +@PETSc.Log.EventDecorator() +def assemble_mixed_mass_matrix(source, target, space="L2"): + """ + Assembled a mixed mass matrix associated with two finite element spaces and some + norm. + + :arg source: source finite element space + :type source: :class:`firedrake.functionspaceimpl.functionspace` + :arg target: target finite element space + :type target: :class:`firedrake.functionspaceimpl.functionspace` + :kwarg norm_type: the type norm to build the mass matrix with + :type norm_type: :class:`str` + :returns: the corresponding mass matrix + :rtype: petsc4py.PETSc.Mat + """ + if space != "L2": + raise NotImplementedError("Mixed matrices are only supported in the L2 norm.") + mixed_mass = fsup.assemble_mixed_mass_matrix(source, target) + return mixed_mass + + def cofunction2function(cofunc): """ :arg cofunc: a cofunction