mirror of
https://github.com/Cantera/cantera.git
synced 2025-02-25 18:55:29 -06:00
[Python] Outline of a strategy for wrapping classes which extend Transport
This commit is contained in:
@@ -61,7 +61,6 @@ cdef extern from "cantera/transport/DustyGasTransport.h" namespace "Cantera":
|
||||
cdef cppclass CxxDustyGasTransport "Cantera::DustyGasTransport":
|
||||
void setPorosity(double) except +
|
||||
|
||||
|
||||
cdef extern from "cantera/equil/MultiPhase.h" namespace "Cantera":
|
||||
cdef cppclass CxxMultiPhase "Cantera::MultiPhase":
|
||||
CxxMultiPhase()
|
||||
|
||||
@@ -30,11 +30,12 @@ cdef class _SolutionBase:
|
||||
else:
|
||||
self.kinetics = NULL
|
||||
|
||||
# Transport
|
||||
# Initialization of transport is deferred to Transport.__init__
|
||||
self.transport = NULL
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
if isinstance(self, Transport):
|
||||
self.transport = newDefaultTransportMgr(self.thermo)
|
||||
else:
|
||||
self.transport = NULL
|
||||
assert self.transport is not NULL
|
||||
|
||||
def __dealloc__(self):
|
||||
del self.thermo
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
class Solution(ThermoPhase, Kinetics, Transport):
|
||||
def __init__(self, *args, **kwars):
|
||||
pass
|
||||
pass
|
||||
|
||||
class Interface(InterfacePhase, Kinetics):
|
||||
pass
|
||||
|
||||
class DustyGas(ThermoPhase, Kinetics, DustyGasTransport):
|
||||
pass
|
||||
|
||||
@@ -9,3 +9,9 @@ class TestTransport(utilities.CanteraTest):
|
||||
|
||||
def test_viscosity(self):
|
||||
self.assertTrue(self.phase.viscosity > 0.0)
|
||||
|
||||
class TestDustyGas(utilities.CanteraTest):
|
||||
def test_methods(self):
|
||||
self.phase = ct.DustyGas('h2o2.xml')
|
||||
|
||||
self.phase.setPorosity(0.2)
|
||||
|
||||
@@ -1,4 +1,17 @@
|
||||
cdef class Transport(_SolutionBase):
|
||||
def __init__(self, *args, **kwargs):
|
||||
if self.transport == NULL:
|
||||
self.transport = newDefaultTransportMgr(self.thermo)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
property viscosity:
|
||||
def __get__(self):
|
||||
return self.transport.viscosity()
|
||||
|
||||
cdef class DustyGasTransport(Transport):
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.transport = newTransportMgr(stringify("DustyGas"), self.thermo)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def setPorosity(self, value):
|
||||
(<CxxDustyGasTransport*>self.transport).setPorosity(value)
|
||||
|
||||
Reference in New Issue
Block a user