From a82dd5a4836b75ea91eb0fb58ec74bea164cbd9f Mon Sep 17 00:00:00 2001 From: "Bryan W. Weber" Date: Thu, 10 Nov 2016 19:26:41 -0500 Subject: [PATCH] [Cython/1D] Add Cython interface for getting/setting max_grid_points --- interfaces/cython/cantera/_cantera.pxd | 2 ++ interfaces/cython/cantera/onedim.py | 12 ++++++++++++ interfaces/cython/cantera/onedim.pyx | 10 ++++++++++ 3 files changed, 24 insertions(+) diff --git a/interfaces/cython/cantera/_cantera.pxd b/interfaces/cython/cantera/_cantera.pxd index 18ee8eaac..a2d7ba041 100644 --- a/interfaces/cython/cantera/_cantera.pxd +++ b/interfaces/cython/cantera/_cantera.pxd @@ -728,6 +728,8 @@ cdef extern from "cantera/oneD/Sim1D.h": void setTimeStepFactor(double) void setMinTimeStep(double) void setMaxTimeStep(double) + void setMaxGridPoints(int, size_t) except +translate_exception + size_t maxGridPoints(size_t) except +translate_exception void setGridMin(int, double) except +translate_exception void setFixedTemperature(double) void setInterrupt(CxxFunc1*) except +translate_exception diff --git a/interfaces/cython/cantera/onedim.py b/interfaces/cython/cantera/onedim.py index c52ac32ba..e41f6ba19 100644 --- a/interfaces/cython/cantera/onedim.py +++ b/interfaces/cython/cantera/onedim.py @@ -73,6 +73,18 @@ class FlameBase(Sim1D): super(FlameBase, self).set_profile(self.flame, component, locations, values) + @property + def max_grid_points(self): + """ + Get/Set the maximum number of grid points used in the solution of + this flame. + """ + return super(FlameBase, self).get_max_grid_points(self.flame) + + @max_grid_points.setter + def max_grid_points(self, npmax): + super(FlameBase, self).set_max_grid_points(self.flame, npmax) + @property def transport_model(self): """ diff --git a/interfaces/cython/cantera/onedim.pyx b/interfaces/cython/cantera/onedim.pyx index 3da18388b..fe0a57b44 100644 --- a/interfaces/cython/cantera/onedim.pyx +++ b/interfaces/cython/cantera/onedim.pyx @@ -1092,5 +1092,15 @@ cdef class Sim1D: def __get__(self): return self.sim.timeStepStats() + def set_max_grid_points(self, domain, npmax): + """ Set the maximum number of grid points in the specified domain. """ + idom = self.domain_index(domain) + self.sim.setMaxGridPoints(idom, npmax) + + def get_max_grid_points(self, domain): + """ Get the maximum number of grid points in the specified domain. """ + idom = self.domain_index(domain) + return self.sim.maxGridPoints(idom) + def __dealloc__(self): del self.sim