Skip to content

Commit

Permalink
#95: Wrapper for assemble_mixed_mass_matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
jwallwork23 committed Apr 27, 2024
1 parent d7da6b4 commit 5ac7f4d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion animate/interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
22 changes: 22 additions & 0 deletions animate/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5ac7f4d

Please sign in to comment.