Skip to content

Commit ae809f3

Browse files
authored
Merge pull request #4616 from firedrakeproject/stefanozampini/chkerr-from-petsc4py
Improved traceback from PETSc errors
2 parents ec54928 + 79458cd commit ae809f3

File tree

6 files changed

+122
-168
lines changed

6 files changed

+122
-168
lines changed

firedrake/cython/dmcommon.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3480,7 +3480,7 @@ cdef int DMPlexGetAdjacency_Facet_Support(PETSc.PetscDM dm,
34803480
numAdj += 1
34813481
# Too many adjacent points for the provided output array.
34823482
if numAdj > maxAdjSize:
3483-
SETERR(77)
3483+
CHKERR(PETSC_ERR_LIB)
34843484
CHKERR(DMPlexRestoreTransitiveClosure(dm, point, PETSC_TRUE, &closureSize, &closure))
34853485
adjSize[0] = numAdj
34863486
return 0
@@ -3565,7 +3565,7 @@ cdef int DMPlexGetAdjacency_Closure_Star_Ridge(
35653565
numAdj += 1
35663566
# Too many adjacent points for the provided output array.
35673567
if numAdj > maxAdjSize:
3568-
SETERR(77)
3568+
CHKERR(PETSC_ERR_LIB)
35693569
CHKERR(DMPlexRestoreTransitiveClosure(dm, point, PETSC_TRUE, &closureSize, &closure))
35703570
CHKERR(DMPlexRestoreTransitiveClosure(dm, p, PETSC_FALSE, &starSize, &star))
35713571
adjSize[0] = numAdj

firedrake/cython/extrusion_numbering.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ def layer_extents(PETSc.DM dm, PETSc.Section cell_numbering,
291291

292292
tmp = numpy.copy(layer_extents)
293293
# To get owned points correct, we do a reduction over the SF.
294-
CHKERR(MPI_Op_create(<MPI_User_function *>extents_reduce, 4, &EXTENTS_REDUCER))
294+
CHKERRMPI(MPI_Op_create(<MPI_User_function *>extents_reduce, 4, &EXTENTS_REDUCER))
295295
CHKERR(PetscSFReduceBegin(sf.sf, contig.ob_mpi,
296296
<const void*>layer_extents.data,
297297
<void *>tmp.data,
@@ -300,7 +300,7 @@ def layer_extents(PETSc.DM dm, PETSc.Section cell_numbering,
300300
<const void*>layer_extents.data,
301301
<void *>tmp.data,
302302
EXTENTS_REDUCER))
303-
CHKERR(MPI_Op_free(&EXTENTS_REDUCER))
303+
CHKERRMPI(MPI_Op_free(&EXTENTS_REDUCER))
304304
layer_extents[:] = tmp[:]
305305
# OK, now we have the correct extents for owned points, but
306306
# potentially incorrect extents for ghost points, so do a SF Bcast

firedrake/cython/petschdr.pxi

Lines changed: 102 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
cimport petsc4py.PETSc as PETSc
2+
from petsc4py.PETSc cimport CHKERR, CHKERRMPI
23
cimport mpi4py.MPI as MPI
34
cimport numpy as np
45

@@ -21,13 +22,16 @@ cdef extern from "petsc.h":
2122
PETSC_SCALAR,
2223
PETSC_COMPLEX,
2324
PETSC_DATATYPE_UNKNOWN
25+
ctypedef enum PetscErrorCode:
26+
PETSC_SUCCESS
27+
PETSC_ERR_LIB
2428

2529
cdef extern from "petscsys.h" nogil:
26-
int PetscMalloc1(PetscInt,void*)
27-
int PetscMalloc2(PetscInt,void*,PetscInt,void*)
28-
int PetscFree(void*)
29-
int PetscFree2(void*,void*)
30-
int PetscSortIntWithArray(PetscInt,PetscInt[],PetscInt[])
30+
PetscErrorCode PetscMalloc1(PetscInt,void*)
31+
PetscErrorCode PetscMalloc2(PetscInt,void*,PetscInt,void*)
32+
PetscErrorCode PetscFree(void*)
33+
PetscErrorCode PetscFree2(void*,void*)
34+
PetscErrorCode PetscSortIntWithArray(PetscInt,PetscInt[],PetscInt[])
3135

3236
cdef extern from "petscdmtypes.h" nogil:
3337
ctypedef enum PetscDMPolytopeType "DMPolytopeType":
@@ -51,105 +55,105 @@ cdef extern from "petscdmtypes.h" nogil:
5155
DM_NUM_POLYTOPES
5256

5357
cdef extern from "petscdmplex.h" nogil:
54-
int DMPlexGetHeightStratum(PETSc.PetscDM,PetscInt,PetscInt*,PetscInt*)
55-
int DMPlexGetDepthStratum(PETSc.PetscDM,PetscInt,PetscInt*,PetscInt*)
56-
int DMPlexGetPointHeight(PETSc.PetscDM,PetscInt,PetscInt*)
57-
int DMPlexGetPointDepth(PETSc.PetscDM,PetscInt,PetscInt*)
58-
59-
int DMPlexGetChart(PETSc.PetscDM,PetscInt*,PetscInt*)
60-
int DMPlexGetConeSize(PETSc.PetscDM,PetscInt,PetscInt*)
61-
int DMPlexGetCone(PETSc.PetscDM,PetscInt,PetscInt*[])
62-
int DMPlexGetConeOrientation(PETSc.PetscDM,PetscInt,PetscInt*[])
63-
int DMPlexGetSupportSize(PETSc.PetscDM,PetscInt,PetscInt*)
64-
int DMPlexGetSupport(PETSc.PetscDM,PetscInt,PetscInt*[])
65-
int DMPlexGetMaxSizes(PETSc.PetscDM,PetscInt*,PetscInt*)
66-
67-
int DMPlexGetTransitiveClosure(PETSc.PetscDM,PetscInt,PetscBool,PetscInt *,PetscInt *[])
68-
int DMPlexRestoreTransitiveClosure(PETSc.PetscDM,PetscInt,PetscBool,PetscInt *,PetscInt *[])
69-
int DMPlexDistributeData(PETSc.PetscDM,PETSc.PetscSF,PETSc.PetscSection,MPI.MPI_Datatype,void*,PETSc.PetscSection,void**)
70-
int DMPlexSetAdjacencyUser(PETSc.PetscDM,int(*)(PETSc.PetscDM,PetscInt,PetscInt*,PetscInt[],void*),void*)
71-
int DMPlexCreatePointNumbering(PETSc.PetscDM,PETSc.PetscIS*)
72-
int DMPlexLabelComplete(PETSc.PetscDM, PETSc.PetscDMLabel)
73-
int DMPlexDistributeOverlap(PETSc.PetscDM,PetscInt,PETSc.PetscSF*,PETSc.PetscDM*)
74-
75-
int DMPlexFilter(PETSc.PetscDM,PETSc.PetscDMLabel,PetscInt,PetscBool,PetscBool,PETSc.PetscSF*,PETSc.PetscDM*)
76-
int DMPlexGetSubpointIS(PETSc.PetscDM,PETSc.PetscIS*)
77-
int DMPlexGetSubpointMap(PETSc.PetscDM,PETSc.PetscDMLabel*)
78-
int DMPlexSetSubpointMap(PETSc.PetscDM,PETSc.PetscDMLabel)
79-
80-
int DMPlexSetCellType(PETSc.PetscDM,PetscInt,PetscDMPolytopeType)
81-
int DMPlexGetCellType(PETSc.PetscDM,PetscInt,PetscDMPolytopeType*)
58+
PetscErrorCode DMPlexGetHeightStratum(PETSc.PetscDM,PetscInt,PetscInt*,PetscInt*)
59+
PetscErrorCode DMPlexGetDepthStratum(PETSc.PetscDM,PetscInt,PetscInt*,PetscInt*)
60+
PetscErrorCode DMPlexGetPointHeight(PETSc.PetscDM,PetscInt,PetscInt*)
61+
PetscErrorCode DMPlexGetPointDepth(PETSc.PetscDM,PetscInt,PetscInt*)
62+
63+
PetscErrorCode DMPlexGetChart(PETSc.PetscDM,PetscInt*,PetscInt*)
64+
PetscErrorCode DMPlexGetConeSize(PETSc.PetscDM,PetscInt,PetscInt*)
65+
PetscErrorCode DMPlexGetCone(PETSc.PetscDM,PetscInt,PetscInt*[])
66+
PetscErrorCode DMPlexGetConeOrientation(PETSc.PetscDM,PetscInt,PetscInt*[])
67+
PetscErrorCode DMPlexGetSupportSize(PETSc.PetscDM,PetscInt,PetscInt*)
68+
PetscErrorCode DMPlexGetSupport(PETSc.PetscDM,PetscInt,PetscInt*[])
69+
PetscErrorCode DMPlexGetMaxSizes(PETSc.PetscDM,PetscInt*,PetscInt*)
70+
71+
PetscErrorCode DMPlexGetTransitiveClosure(PETSc.PetscDM,PetscInt,PetscBool,PetscInt *,PetscInt *[])
72+
PetscErrorCode DMPlexRestoreTransitiveClosure(PETSc.PetscDM,PetscInt,PetscBool,PetscInt *,PetscInt *[])
73+
PetscErrorCode DMPlexDistributeData(PETSc.PetscDM,PETSc.PetscSF,PETSc.PetscSection,MPI.MPI_Datatype,void*,PETSc.PetscSection,void**)
74+
PetscErrorCode DMPlexSetAdjacencyUser(PETSc.PetscDM,int(*)(PETSc.PetscDM,PetscInt,PetscInt*,PetscInt[],void*),void*)
75+
PetscErrorCode DMPlexCreatePointNumbering(PETSc.PetscDM,PETSc.PetscIS*)
76+
PetscErrorCode DMPlexLabelComplete(PETSc.PetscDM, PETSc.PetscDMLabel)
77+
PetscErrorCode DMPlexDistributeOverlap(PETSc.PetscDM,PetscInt,PETSc.PetscSF*,PETSc.PetscDM*)
78+
79+
PetscErrorCode DMPlexFilter(PETSc.PetscDM,PETSc.PetscDMLabel,PetscInt,PetscBool,PetscBool,PETSc.PetscSF*,PETSc.PetscDM*)
80+
PetscErrorCode DMPlexGetSubpointIS(PETSc.PetscDM,PETSc.PetscIS*)
81+
PetscErrorCode DMPlexGetSubpointMap(PETSc.PetscDM,PETSc.PetscDMLabel*)
82+
PetscErrorCode DMPlexSetSubpointMap(PETSc.PetscDM,PETSc.PetscDMLabel)
83+
84+
PetscErrorCode DMPlexSetCellType(PETSc.PetscDM,PetscInt,PetscDMPolytopeType)
85+
PetscErrorCode DMPlexGetCellType(PETSc.PetscDM,PetscInt,PetscDMPolytopeType*)
8286

8387
cdef extern from "petscdmlabel.h" nogil:
8488
struct _n_DMLabel
8589
ctypedef _n_DMLabel* DMLabel "DMLabel"
86-
int DMLabelCreateIndex(DMLabel, PetscInt, PetscInt)
87-
int DMLabelDestroyIndex(DMLabel)
88-
int DMLabelDestroy(DMLabel*)
89-
int DMLabelHasPoint(DMLabel, PetscInt, PetscBool*)
90-
int DMLabelSetValue(DMLabel, PetscInt, PetscInt)
91-
int DMLabelGetValue(DMLabel, PetscInt, PetscInt*)
92-
int DMLabelClearValue(DMLabel, PetscInt, PetscInt)
93-
int DMLabelGetStratumSize(DMLabel, PetscInt, PetscInt*)
94-
int DMLabelGetStratumIS(DMLabel, PetscInt, PETSc.PetscIS*)
90+
PetscErrorCode DMLabelCreateIndex(DMLabel, PetscInt, PetscInt)
91+
PetscErrorCode DMLabelDestroyIndex(DMLabel)
92+
PetscErrorCode DMLabelDestroy(DMLabel*)
93+
PetscErrorCode DMLabelHasPoint(DMLabel, PetscInt, PetscBool*)
94+
PetscErrorCode DMLabelSetValue(DMLabel, PetscInt, PetscInt)
95+
PetscErrorCode DMLabelGetValue(DMLabel, PetscInt, PetscInt*)
96+
PetscErrorCode DMLabelClearValue(DMLabel, PetscInt, PetscInt)
97+
PetscErrorCode DMLabelGetStratumSize(DMLabel, PetscInt, PetscInt*)
98+
PetscErrorCode DMLabelGetStratumIS(DMLabel, PetscInt, PETSc.PetscIS*)
9599

96100
cdef extern from "petscdm.h" nogil:
97-
int DMCreateLabel(PETSc.PetscDM,char[])
98-
int DMGetLabel(PETSc.PetscDM,char[],DMLabel*)
99-
int DMGetPointSF(PETSc.PetscDM,PETSc.PetscSF*)
100-
int DMSetLabelValue(PETSc.PetscDM,char[],PetscInt,PetscInt)
101-
int DMGetLabelValue(PETSc.PetscDM,char[],PetscInt,PetscInt*)
101+
PetscErrorCode DMCreateLabel(PETSc.PetscDM,char[])
102+
PetscErrorCode DMGetLabel(PETSc.PetscDM,char[],DMLabel*)
103+
PetscErrorCode DMGetPointSF(PETSc.PetscDM,PETSc.PetscSF*)
104+
PetscErrorCode DMSetLabelValue(PETSc.PetscDM,char[],PetscInt,PetscInt)
105+
PetscErrorCode DMGetLabelValue(PETSc.PetscDM,char[],PetscInt,PetscInt*)
102106

103107
cdef extern from "petscdmswarm.h" nogil:
104-
int DMSwarmGetLocalSize(PETSc.PetscDM,PetscInt*)
105-
int DMSwarmGetCellDM(PETSc.PetscDM, PETSc.PetscDM*)
106-
int DMSwarmGetCellDMActive(PETSc.PetscDM, PETSc.PetscDMSwarmCellDM*)
107-
int DMSwarmCellDMGetCellID(PETSc.PetscDMSwarmCellDM, const char *[])
108-
int DMSwarmGetField(PETSc.PetscDM,const char[],PetscInt*,PetscDataType*,void**)
109-
int DMSwarmRestoreField(PETSc.PetscDM,const char[],PetscInt*,PetscDataType*,void**)
108+
PetscErrorCode DMSwarmGetLocalSize(PETSc.PetscDM,PetscInt*)
109+
PetscErrorCode DMSwarmGetCellDM(PETSc.PetscDM, PETSc.PetscDM*)
110+
PetscErrorCode DMSwarmGetCellDMActive(PETSc.PetscDM, PETSc.PetscDMSwarmCellDM*)
111+
PetscErrorCode DMSwarmCellDMGetCellID(PETSc.PetscDMSwarmCellDM, const char *[])
112+
PetscErrorCode DMSwarmGetField(PETSc.PetscDM,const char[],PetscInt*,PetscDataType*,void**)
113+
PetscErrorCode DMSwarmRestoreField(PETSc.PetscDM,const char[],PetscInt*,PetscDataType*,void**)
110114

111115
cdef extern from "petscvec.h" nogil:
112-
int VecGetArray(PETSc.PetscVec,PetscScalar**)
113-
int VecRestoreArray(PETSc.PetscVec,PetscScalar**)
114-
int VecGetArrayRead(PETSc.PetscVec,const PetscScalar**)
115-
int VecRestoreArrayRead(PETSc.PetscVec,const PetscScalar**)
116+
PetscErrorCode VecGetArray(PETSc.PetscVec,PetscScalar**)
117+
PetscErrorCode VecRestoreArray(PETSc.PetscVec,PetscScalar**)
118+
PetscErrorCode VecGetArrayRead(PETSc.PetscVec,const PetscScalar**)
119+
PetscErrorCode VecRestoreArrayRead(PETSc.PetscVec,const PetscScalar**)
116120

117121
cdef extern from "petscis.h" nogil:
118-
int PetscSectionGetOffset(PETSc.PetscSection,PetscInt,PetscInt*)
119-
int PetscSectionGetDof(PETSc.PetscSection,PetscInt,PetscInt*)
120-
int PetscSectionSetDof(PETSc.PetscSection,PetscInt,PetscInt)
121-
int PetscSectionSetFieldDof(PETSc.PetscSection,PetscInt,PetscInt,PetscInt)
122-
int PetscSectionGetFieldDof(PETSc.PetscSection,PetscInt,PetscInt,PetscInt*)
123-
int PetscSectionGetConstraintDof(PETSc.PetscSection,PetscInt,PetscInt*)
124-
int PetscSectionSetConstraintDof(PETSc.PetscSection,PetscInt,PetscInt)
125-
int PetscSectionSetConstraintIndices(PETSc.PetscSection,PetscInt, PetscInt[])
126-
int PetscSectionGetConstraintIndices(PETSc.PetscSection,PetscInt, const PetscInt**)
127-
int PetscSectionGetMaxDof(PETSc.PetscSection,PetscInt*)
128-
int PetscSectionSetPermutation(PETSc.PetscSection,PETSc.PetscIS)
129-
int ISGetIndices(PETSc.PetscIS,PetscInt*[])
130-
int ISGetSize(PETSc.PetscIS,PetscInt*)
131-
int ISRestoreIndices(PETSc.PetscIS,PetscInt*[])
132-
int ISGeneralSetIndices(PETSc.PetscIS,PetscInt,PetscInt[],PetscCopyMode)
133-
int ISLocalToGlobalMappingCreateIS(PETSc.PetscIS,PETSc.PetscLGMap*)
134-
int ISLocalToGlobalMappingGetSize(PETSc.PetscLGMap,PetscInt*)
135-
int ISLocalToGlobalMappingGetBlockIndices(PETSc.PetscLGMap, const PetscInt**)
136-
int ISLocalToGlobalMappingRestoreBlockIndices(PETSc.PetscLGMap, const PetscInt**)
137-
int ISDestroy(PETSc.PetscIS*)
122+
PetscErrorCode PetscSectionGetOffset(PETSc.PetscSection,PetscInt,PetscInt*)
123+
PetscErrorCode PetscSectionGetDof(PETSc.PetscSection,PetscInt,PetscInt*)
124+
PetscErrorCode PetscSectionSetDof(PETSc.PetscSection,PetscInt,PetscInt)
125+
PetscErrorCode PetscSectionSetFieldDof(PETSc.PetscSection,PetscInt,PetscInt,PetscInt)
126+
PetscErrorCode PetscSectionGetFieldDof(PETSc.PetscSection,PetscInt,PetscInt,PetscInt*)
127+
PetscErrorCode PetscSectionGetConstraintDof(PETSc.PetscSection,PetscInt,PetscInt*)
128+
PetscErrorCode PetscSectionSetConstraintDof(PETSc.PetscSection,PetscInt,PetscInt)
129+
PetscErrorCode PetscSectionSetConstraintIndices(PETSc.PetscSection,PetscInt, PetscInt[])
130+
PetscErrorCode PetscSectionGetConstraintIndices(PETSc.PetscSection,PetscInt, const PetscInt**)
131+
PetscErrorCode PetscSectionGetMaxDof(PETSc.PetscSection,PetscInt*)
132+
PetscErrorCode PetscSectionSetPermutation(PETSc.PetscSection,PETSc.PetscIS)
133+
PetscErrorCode ISGetIndices(PETSc.PetscIS,PetscInt*[])
134+
PetscErrorCode ISGetSize(PETSc.PetscIS,PetscInt*)
135+
PetscErrorCode ISRestoreIndices(PETSc.PetscIS,PetscInt*[])
136+
PetscErrorCode ISGeneralSetIndices(PETSc.PetscIS,PetscInt,PetscInt[],PetscCopyMode)
137+
PetscErrorCode ISLocalToGlobalMappingCreateIS(PETSc.PetscIS,PETSc.PetscLGMap*)
138+
PetscErrorCode ISLocalToGlobalMappingGetSize(PETSc.PetscLGMap,PetscInt*)
139+
PetscErrorCode ISLocalToGlobalMappingGetBlockIndices(PETSc.PetscLGMap, const PetscInt**)
140+
PetscErrorCode ISLocalToGlobalMappingRestoreBlockIndices(PETSc.PetscLGMap, const PetscInt**)
141+
PetscErrorCode ISDestroy(PETSc.PetscIS*)
138142

139143
cdef extern from "petscsf.h" nogil:
140144
struct PetscSFNode_:
141145
PetscInt rank
142146
PetscInt index
143147
ctypedef PetscSFNode_ PetscSFNode "PetscSFNode"
144148

145-
int PetscSFGetGraph(PETSc.PetscSF,PetscInt*,PetscInt*,PetscInt**,PetscSFNode**)
146-
int PetscSFSetGraph(PETSc.PetscSF,PetscInt,PetscInt,PetscInt*,PetscCopyMode,PetscSFNode*,PetscCopyMode)
147-
int PetscSFBcastBegin(PETSc.PetscSF,MPI.MPI_Datatype,const void*, void*,)
148-
int PetscSFBcastEnd(PETSc.PetscSF,MPI.MPI_Datatype,const void*, void*)
149-
int PetscSFReduceBegin(PETSc.PetscSF,MPI.MPI_Datatype,const void*, void*,MPI.MPI_Op)
150-
int PetscSFReduceEnd(PETSc.PetscSF,MPI.MPI_Datatype,const void*, void*,MPI.MPI_Op)
149+
PetscErrorCode PetscSFGetGraph(PETSc.PetscSF,PetscInt*,PetscInt*,PetscInt**,PetscSFNode**)
150+
PetscErrorCode PetscSFSetGraph(PETSc.PetscSF,PetscInt,PetscInt,PetscInt*,PetscCopyMode,PetscSFNode*,PetscCopyMode)
151+
PetscErrorCode PetscSFBcastBegin(PETSc.PetscSF,MPI.MPI_Datatype,const void*, void*,)
152+
PetscErrorCode PetscSFBcastEnd(PETSc.PetscSF,MPI.MPI_Datatype,const void*, void*)
153+
PetscErrorCode PetscSFReduceBegin(PETSc.PetscSF,MPI.MPI_Datatype,const void*, void*,MPI.MPI_Op)
154+
PetscErrorCode PetscSFReduceEnd(PETSc.PetscSF,MPI.MPI_Datatype,const void*, void*,MPI.MPI_Op)
151155

152-
ctypedef int (*PetscPCPatchComputeFunction)(PETSc.PetscPC,
156+
ctypedef PetscErrorCode (*PetscPCPatchComputeFunction)(PETSc.PetscPC,
153157
PetscInt,
154158
PETSc.PetscVec,
155159
PETSc.PetscVec,
@@ -158,7 +162,7 @@ ctypedef int (*PetscPCPatchComputeFunction)(PETSc.PetscPC,
158162
const PetscInt*,
159163
const PetscInt*,
160164
void*)
161-
ctypedef int (*PetscPCPatchComputeOperator)(PETSc.PetscPC,
165+
ctypedef PetscErrorCode (*PetscPCPatchComputeOperator)(PETSc.PetscPC,
162166
PetscInt,
163167
PETSc.PetscVec,
164168
PETSc.PetscMat,
@@ -168,52 +172,28 @@ ctypedef int (*PetscPCPatchComputeOperator)(PETSc.PetscPC,
168172
const PetscInt*,
169173
void*)
170174
cdef extern from "petscsnes.h" nogil:
171-
int SNESPatchSetComputeFunction(PETSc.PetscSNES, PetscPCPatchComputeFunction, void *)
172-
int SNESPatchSetComputeOperator(PETSc.PetscSNES, PetscPCPatchComputeOperator, void *)
175+
PetscErrorCode SNESPatchSetComputeFunction(PETSc.PetscSNES, PetscPCPatchComputeFunction, void *)
176+
PetscErrorCode SNESPatchSetComputeOperator(PETSc.PetscSNES, PetscPCPatchComputeOperator, void *)
173177

174178
cdef extern from "petscpc.h" nogil:
175-
int PCPatchSetComputeFunction(PETSc.PetscPC, PetscPCPatchComputeFunction, void *)
176-
int PCPatchSetComputeFunctionInteriorFacets(PETSc.PetscPC, PetscPCPatchComputeFunction, void *)
177-
int PCPatchSetComputeOperator(PETSc.PetscPC, PetscPCPatchComputeOperator, void *)
178-
int PCPatchSetComputeOperatorInteriorFacets(PETSc.PetscPC, PetscPCPatchComputeOperator, void *)
179+
PetscErrorCode PCPatchSetComputeFunction(PETSc.PetscPC, PetscPCPatchComputeFunction, void *)
180+
PetscErrorCode PCPatchSetComputeFunctionInteriorFacets(PETSc.PetscPC, PetscPCPatchComputeFunction, void *)
181+
PetscErrorCode PCPatchSetComputeOperator(PETSc.PetscPC, PetscPCPatchComputeOperator, void *)
182+
PetscErrorCode PCPatchSetComputeOperatorInteriorFacets(PETSc.PetscPC, PetscPCPatchComputeOperator, void *)
179183

180184
cdef extern from "petscbt.h" nogil:
181185
ctypedef char * PetscBT
182-
int PetscBTCreate(PetscInt,PetscBT*)
183-
int PetscBTDestroy(PetscBT*)
186+
PetscErrorCode PetscBTCreate(PetscInt,PetscBT*)
187+
PetscErrorCode PetscBTDestroy(PetscBT*)
184188
char PetscBTLookup(PetscBT,PetscInt)
185-
int PetscBTSet(PetscBT,PetscInt)
189+
PetscErrorCode PetscBTSet(PetscBT,PetscInt)
186190

187191
cdef extern from "petscmat.h" nogil:
188-
int MatSetValuesLocal(PETSc.PetscMat, PetscInt, const PetscInt[], PetscInt, const PetscInt[],
192+
PetscErrorCode MatSetValuesLocal(PETSc.PetscMat, PetscInt, const PetscInt[], PetscInt, const PetscInt[],
189193
const PetscScalar[], PetscInt)
190-
int MatAssemblyBegin(PETSc.PetscMat, PetscInt)
191-
int MatAssemblyEnd(PETSc.PetscMat, PetscInt)
194+
PetscErrorCode MatAssemblyBegin(PETSc.PetscMat, PetscInt)
195+
PetscErrorCode MatAssemblyEnd(PETSc.PetscMat, PetscInt)
192196
PetscInt MAT_FINAL_ASSEMBLY = 0
193197

194198
cdef extern from * nogil:
195-
int PetscObjectTypeCompare(PETSc.PetscObject, char[], PetscBool*)
196-
197-
# --- Error handling taken from petsc4py (src/PETSc.pyx) -------------
198-
199-
cdef extern from *:
200-
void PyErr_SetObject(object, object)
201-
void *PyExc_RuntimeError
202-
203-
cdef object PetscError = <object>PyExc_RuntimeError
204-
205-
cdef inline int SETERR(int ierr) with gil:
206-
if (<void*>PetscError) != NULL:
207-
PyErr_SetObject(PetscError, <long>ierr)
208-
else:
209-
PyErr_SetObject(<object>PyExc_RuntimeError, <long>ierr)
210-
return ierr
211-
212-
cdef inline int CHKERR(int ierr) except -1 nogil:
213-
if ierr == 0:
214-
return 0 # no error
215-
else:
216-
SETERR(ierr)
217-
return -1
218-
219-
# --------------------------------------------------------------------
199+
PetscErrorCode PetscObjectTypeCompare(PETSc.PetscObject, char[], PetscBool*)

0 commit comments

Comments
 (0)