[1D] Add function to set flow type and make IonFlow inherit from StFlow

This commit is contained in:
bangshiuh 2018-08-03 23:00:15 -04:00 committed by Ray Speth
parent c1067aa6e9
commit a5762ea6b6
7 changed files with 35 additions and 9 deletions

View file

@ -28,7 +28,7 @@ namespace Cantera
* Combustion and Flames 94.4(1993): 433-448.
* @ingroup onedim
*/
class IonFlow : public FreeFlame
class IonFlow : public StFlow
{
public:
IonFlow(IdealGasPhase* ph = 0, size_t nsp = 1, size_t points = 1);

View file

@ -147,6 +147,14 @@ public:
virtual void restore(const XML_Node& dom, doublereal* soln,
int loglevel);
void setFreeFlow() {
m_type = cFreeFlow;
}
void setAxisymmetricFlow() {
m_type = cAxisymmetricStagnationFlow;
}
virtual std::string flowType() {
if (m_type == cFreeFlow) {
return "Free Flame";

View file

@ -687,6 +687,9 @@ cdef extern from "cantera/oneD/StFlow.h":
cbool doEnergy(size_t)
void enableSoret(cbool) except +translate_exception
cbool withSoret()
void setViscosityFlag(bool)
void setFreeFlow()
void setAxisymmetricFlow()
cdef cppclass CxxFreeFlame "Cantera::FreeFlame":
CxxFreeFlame(CxxIdealGasPhase*, int, int)

View file

@ -467,6 +467,15 @@ cdef class _FlowBase(Domain1D):
def __set__(self, do_radiation):
self.flow.enableRadiation(<cbool>do_radiation)
def set_viscosityFlag(self, dovisc):
self.flow.setViscosityFlag(dovisc)
def set_freeFlow(self):
self.flow.setFreeFlow()
def set_axisymmetricFlow(self):
self.flow.setAxisymmetricFlow()
cdef CxxIdealGasPhase* getIdealGasPhase(ThermoPhase phase) except *:
if pystr(phase.thermo.type()) != "IdealGas":
@ -477,7 +486,9 @@ cdef CxxIdealGasPhase* getIdealGasPhase(ThermoPhase phase) except *:
cdef class FreeFlow(_FlowBase):
def __cinit__(self, _SolutionBase thermo, *args, **kwargs):
gas = getIdealGasPhase(thermo)
self.flow = <CxxStFlow*>(new CxxFreeFlame(gas, thermo.n_species, 2))
self.flow = new CxxStFlow(gas, thermo.n_species, 2)
self.set_freeFlow()
self.set_viscosityFlag(False)
cdef class IonFlow(_FlowBase):
@ -489,6 +500,8 @@ cdef class IonFlow(_FlowBase):
def __cinit__(self, _SolutionBase thermo, *args, **kwargs):
gas = getIdealGasPhase(thermo)
self.flow = <CxxStFlow*>(new CxxIonFlow(gas, thermo.n_species, 2))
self.set_freeFlow()
self.set_viscosityFlag(False)
def set_solvingStage(self, stage):
(<CxxIonFlow*>self.flow).setSolvingStage(stage)
@ -538,7 +551,9 @@ cdef class AxisymmetricStagnationFlow(_FlowBase):
"""
def __cinit__(self, _SolutionBase thermo, *args, **kwargs):
gas = getIdealGasPhase(thermo)
self.flow = <CxxStFlow*>(new CxxAxiStagnFlow(gas, thermo.n_species, 2))
self.flow = new CxxStFlow(gas, thermo.n_species, 2)
self.set_axisymmetricFlow()
self.set_viscosityFlag(True)
cdef class Sim1D:

View file

@ -16,7 +16,7 @@ namespace Cantera
{
IonFlow::IonFlow(IdealGasPhase* ph, size_t nsp, size_t points) :
FreeFlame(ph, nsp, points),
StFlow(ph, nsp, points),
m_import_electron_transport(false),
m_stage(1),
m_inletVoltage(0.0),
@ -277,7 +277,7 @@ void IonFlow::setElectronTransport(vector_fp& tfix, vector_fp& diff_e,
void IonFlow::_finalize(const double* x)
{
FreeFlame::_finalize(x);
StFlow::_finalize(x);
bool p = m_do_poisson[0];
for (size_t j = 0; j < m_points; j++) {

View file

@ -440,10 +440,10 @@ int Sim1D::setFixedTemperature(doublereal t)
// loop over points in the current grid to determine where new point is
// needed.
FreeFlame* d_free = dynamic_cast<FreeFlame*>(&domain(n));
StFlow* d_free = dynamic_cast<StFlow*>(&domain(n));
size_t npnow = d.nPoints();
size_t nstart = znew.size();
if (d_free) {
if (d_free && d_free->domainType() == cFreeFlow) {
for (size_t m = 0; m < npnow-1; m++) {
if (value(n,2,m) == t) {
zfixed = d.grid(m);

View file

@ -148,7 +148,7 @@ int Refiner::analyze(size_t n, const doublereal* z,
}
}
FreeFlame* fflame = dynamic_cast<FreeFlame*>(m_domain);
StFlow* fflame = dynamic_cast<StFlow*>(m_domain);
// Refine based on properties of the grid itself
for (size_t j = 1; j < n-1; j++) {
@ -185,7 +185,7 @@ int Refiner::analyze(size_t n, const doublereal* z,
}
// Keep the point where the temperature is fixed
if (fflame && z[j] == fflame->m_zfixed) {
if (fflame->domainType() == cFreeFlow && z[j] == fflame->m_zfixed) {
m_keep[j] = 1;
}
}