Skip to content

Commit

Permalink
[oneD] change thermo type of constructor
Browse files Browse the repository at this point in the history
- allow for 'ThermoPhase`, and cast to 'IdealGasPhase' internally
  • Loading branch information
Ingmar Schoegl committed Nov 5, 2019
1 parent cfb54d4 commit e4d2942
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
7 changes: 6 additions & 1 deletion include/cantera/oneD/StFlow.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ class StFlow : public Domain1D
//! to evaluate all thermodynamic, kinetic, and transport properties.
//! @param nsp Number of species.
//! @param points Initial number of grid points
StFlow(IdealGasPhase* ph = 0, size_t nsp = 1, size_t points = 1);
StFlow(ThermoPhase* ph = 0, size_t nsp = 1, size_t points = 1);

//! Delegating constructor
StFlow(shared_ptr<ThermoPhase> th, size_t nsp = 1, size_t points = 1) :
StFlow(th.get(), nsp, points) {
}

//! @name Problem Specification
//! @{
Expand Down
4 changes: 2 additions & 2 deletions samples/cxx/flamespeed/flamespeed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ int flamespeed(double phi)
{
try {
auto sol = newSolution("gri30.yaml", "gri30", "None");
auto gas = std::dynamic_pointer_cast<IdealGasPhase>(sol->thermo());
auto gas = sol->thermo();
double temp = 300.0; // K
double pressure = 1.0*OneAtm; //atm
double uin = 0.3; //m/sec
Expand Down Expand Up @@ -51,7 +51,7 @@ int flamespeed(double phi)

//-------- step 1: create the flow -------------

StFlow flow(gas.get());
StFlow flow(gas);
flow.setFreeFlow();

// create an initial grid
Expand Down
9 changes: 7 additions & 2 deletions src/oneD/StFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ using namespace std;
namespace Cantera
{

StFlow::StFlow(IdealGasPhase* ph, size_t nsp, size_t points) :
StFlow::StFlow(ThermoPhase* ph, size_t nsp, size_t points) :
Domain1D(nsp+c_offset_Y, points),
m_press(-1.0),
m_nsp(nsp),
Expand All @@ -30,9 +30,14 @@ StFlow::StFlow(IdealGasPhase* ph, size_t nsp, size_t points) :
m_zfixed(Undef),
m_tfixed(Undef)
{
if (ph->type() == "IdealGas") {
m_thermo = (IdealGasPhase*)ph;
} else {
throw CanteraError("StFlow::StFlow",
"Unsupported phase type: need 'IdealGasPhase'");
}
m_type = cFlowType;
m_points = points;
m_thermo = ph;

if (ph == 0) {
return; // used to create a dummy object
Expand Down

0 comments on commit e4d2942

Please sign in to comment.