Skip to content

Commit 0a9d2b4

Browse files
committed
[Python] Fix derived pointer initialization for Jacobians
1 parent f943043 commit 0a9d2b4

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

interfaces/cython/cantera/jacobians.pxd

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,16 @@ cdef extern from "cantera/numerics/SystemJacobianFactory.h" namespace "Cantera":
4646
cdef class SystemJacobian:
4747
@staticmethod
4848
cdef wrap(shared_ptr[CxxSystemJacobian])
49-
cdef set_cxx_object(self)
5049
cdef shared_ptr[CxxSystemJacobian] _base
5150

5251
cdef class EigenSparseJacobian(SystemJacobian):
53-
cdef set_cxx_object(self)
5452
cdef CxxEigenSparseJacobian* sparse_jac
5553

5654
cdef class EigenSparseDirectJacobian(EigenSparseJacobian):
5755
pass
5856

5957
cdef class AdaptivePreconditioner(EigenSparseJacobian):
60-
cdef set_cxx_object(self)
6158
cdef CxxAdaptivePreconditioner* adaptive
6259

6360
cdef class BandedJacobian(SystemJacobian):
64-
cdef set_cxx_object(self)
6561
cdef CxxMultiJac* band_jac

interfaces/cython/cantera/jacobians.pyx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ cdef class SystemJacobian:
4848
jac.set_cxx_object()
4949
return jac
5050

51-
cdef set_cxx_object(self):
51+
def set_cxx_object(self):
5252
pass
5353

5454
property side:
@@ -67,10 +67,10 @@ cdef class SystemJacobian:
6767
""" Get/Set the value of gamma used in the expression P = (I - gamma * J).
6868
"""
6969
def __get__(self):
70-
return self.pbase.get().gamma()
70+
return self._base.get().gamma()
7171

7272
def __set__(self, value):
73-
self.pbase.get().setGamma(value)
73+
self._base.get().setGamma(value)
7474

7575

7676
cdef class EigenSparseJacobian(SystemJacobian):
@@ -81,7 +81,8 @@ cdef class EigenSparseJacobian(SystemJacobian):
8181

8282
_type = "eigen-sparse"
8383

84-
cdef set_cxx_object(self):
84+
def set_cxx_object(self):
85+
super().set_cxx_object()
8586
self.sparse_jac = <CxxEigenSparseJacobian*>self._base.get()
8687

8788
def print_contents(self):
@@ -117,7 +118,8 @@ cdef class AdaptivePreconditioner(EigenSparseJacobian):
117118
_type = "Adaptive"
118119
linear_solver_type = "GMRES"
119120

120-
cdef set_cxx_object(self):
121+
def set_cxx_object(self):
122+
super().set_cxx_object()
121123
self.adaptive = <CxxAdaptivePreconditioner*>self._base.get()
122124

123125
property threshold:
@@ -188,5 +190,6 @@ cdef class BandedJacobian(SystemJacobian):
188190
_type = "banded-direct"
189191
linear_solver_type = "direct"
190192

191-
cdef set_cxx_object(self):
193+
def set_cxx_object(self):
194+
super().set_cxx_object()
192195
self.band_jac = <CxxMultiJac*>self._base.get()

0 commit comments

Comments
 (0)