Skip to content
Merged
16 changes: 12 additions & 4 deletions firedrake/cython/patchimpl.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ from libc.stdint cimport uintptr_t

include "petschdr.pxi"

def set_patch_residual(patch, function, ctx, is_snes=False, interior_facets=False):
def set_patch_residual(patch, function, ctx, is_snes=False, interior_facets=False, exterior_facets=False):
if is_snes:
if interior_facets:
if interior_facets or exterior_facets:
raise NotImplementedError
CHKERR(SNESPatchSetComputeFunction((<PETSc.SNES?>patch).snes,
<PetscPCPatchComputeFunction><uintptr_t>function,
Expand All @@ -14,15 +14,19 @@ def set_patch_residual(patch, function, ctx, is_snes=False, interior_facets=Fals
CHKERR(PCPatchSetComputeFunctionInteriorFacets((<PETSc.PC?>patch).pc,
<PetscPCPatchComputeFunction><uintptr_t>function,
<void *><uintptr_t>ctx))
elif exterior_facets:
CHKERR(PCPatchSetComputeFunctionExteriorFacets((<PETSc.PC?>patch).pc,
<PetscPCPatchComputeFunction><uintptr_t>function,
<void *><uintptr_t>ctx))
else:
CHKERR(PCPatchSetComputeFunction((<PETSc.PC?>patch).pc,
<PetscPCPatchComputeFunction><uintptr_t>function,
<void *><uintptr_t>ctx))


def set_patch_jacobian(patch, function, ctx, is_snes=False, interior_facets=False):
def set_patch_jacobian(patch, function, ctx, is_snes=False, interior_facets=False, exterior_facets=False):
if is_snes:
if interior_facets:
if interior_facets or exterior_facets:
raise NotImplementedError
CHKERR(SNESPatchSetComputeOperator((<PETSc.SNES?>patch).snes,
<PetscPCPatchComputeOperator><uintptr_t>function,
Expand All @@ -32,6 +36,10 @@ def set_patch_jacobian(patch, function, ctx, is_snes=False, interior_facets=Fals
CHKERR(PCPatchSetComputeOperatorInteriorFacets((<PETSc.PC?>patch).pc,
<PetscPCPatchComputeOperator><uintptr_t>function,
<void *><uintptr_t>ctx))
elif exterior_facets:
CHKERR(PCPatchSetComputeOperatorExteriorFacets((<PETSc.PC?>patch).pc,
<PetscPCPatchComputeOperator><uintptr_t>function,
<void *><uintptr_t>ctx))
else:
CHKERR(PCPatchSetComputeOperator((<PETSc.PC?>patch).pc,
<PetscPCPatchComputeOperator><uintptr_t>function,
Expand Down
2 changes: 2 additions & 0 deletions firedrake/cython/petschdr.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ cdef extern from "petscpc.h" nogil:
PetscErrorCode PCPatchSetComputeFunctionInteriorFacets(PETSc.PetscPC, PetscPCPatchComputeFunction, void *)
PetscErrorCode PCPatchSetComputeOperator(PETSc.PetscPC, PetscPCPatchComputeOperator, void *)
PetscErrorCode PCPatchSetComputeOperatorInteriorFacets(PETSc.PetscPC, PetscPCPatchComputeOperator, void *)
PetscErrorCode PCPatchSetComputeOperatorExteriorFacets(PETSc.PetscPC, PetscPCPatchComputeOperator, void *)
PetscErrorCode PCPatchSetComputeFunctionExteriorFacets(PETSc.PetscPC, PetscPCPatchComputeFunction, void *)

cdef extern from "petscbt.h" nogil:
ctypedef char * PetscBT
Expand Down
3 changes: 2 additions & 1 deletion firedrake/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -1331,7 +1331,8 @@ def merge_ids(x, y, datatype):
self._cell_numbering,
self.cell_closure)

point2facetnumber = np.full(facets.max(initial=0)+1, -1, dtype=IntType)
_, pEnd = dm.getChart()
point2facetnumber = np.full(pEnd, -1, dtype=IntType)
point2facetnumber[facets] = np.arange(len(facets), dtype=IntType)
obj = _Facets(self, facets, classes, set_, kind,
facet_cell, local_facet_number,
Expand Down
Loading
Loading