Skip to content

Commit

Permalink
[Thermo] address discussion and review comments
Browse files Browse the repository at this point in the history
* rename C++ object to 'Solution' (from 'SolutionBase')
* remove 'phaseID' from 'Solution' ('id' remains assigned to 'Phase')
* remove 'type' from C++ object (no polymorphism anticipated)
* assign 'name' to 'Solution' (link back from 'Phase' until deprecated)
* clarify 'phase' as 'phase_id' in Python interface
* address various feedback in review comments
  • Loading branch information
Ingmar Schoegl authored and ischoegl committed Oct 9, 2019
1 parent 5932a24 commit 02175a3
Show file tree
Hide file tree
Showing 17 changed files with 272 additions and 378 deletions.
72 changes: 72 additions & 0 deletions include/cantera/base/Solution.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
//! @file Solution.h

// This file is part of Cantera. See License.txt in the top-level directory or
// at https://cantera.org/license.txt for license and copyright information.

#ifndef CT_SOLUTION_H
#define CT_SOLUTION_H

#include "cantera/base/ctexceptions.h"

namespace Cantera
{

class ThermoPhase;
class Kinetics;
class Transport;

//! A container class holding managers for all pieces defining a phase
class Solution : public std::enable_shared_from_this<Solution>
{
private:
Solution();

public:
~Solution() {}
Solution(const Solution&) = delete;
Solution& operator=(const Solution&) = delete;

static shared_ptr<Solution> create() {
return shared_ptr<Solution>( new Solution );
}

//! Return the name of this Solution object
std::string name() const;

//! Set the name of this Solution object
void setName(const std::string& name);

//! Set the ThermoPhase object
void setThermoPhase(shared_ptr<ThermoPhase> thermo);

//! Set the Kinetics object
void setKinetics(shared_ptr<Kinetics> kinetics);

//! Set the Transport object
void setTransport(shared_ptr<Transport> transport);

//! Accessor for the ThermoPhase object
ThermoPhase& thermo() {
return *m_thermo;
}

//! Accessor for the Kinetics object
Kinetics& kinetics() {
return *m_kinetics;
}

//! Accessor for the Transport object
Transport& transport() {
return *m_transport;
}

protected:
shared_ptr<ThermoPhase> m_thermo; //! ThermoPhase manager
shared_ptr<Kinetics> m_kinetics; //! Kinetics manager
shared_ptr<Transport> m_transport; //! Transport manager

std::string m_name; //! name of Solution object
};

}
#endif
104 changes: 0 additions & 104 deletions include/cantera/base/SolutionBase.h

This file was deleted.

10 changes: 5 additions & 5 deletions include/cantera/kinetics/Kinetics.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
namespace Cantera
{

class SolutionBase;
class Solution;

/**
* @defgroup chemkinetics Chemical Kinetics
Expand Down Expand Up @@ -816,8 +816,8 @@ class Kinetics
void selectPhase(const doublereal* data, const thermo_t* phase,
doublereal* phase_data);

//! Set root SolutionBase holding all phase information
virtual void setRoot(std::shared_ptr<SolutionBase> root) {
//! Set root Solution holding all phase information
virtual void setRoot(std::shared_ptr<Solution> root) {
m_root = root;
}

Expand Down Expand Up @@ -943,8 +943,8 @@ class Kinetics
//! @see skipUndeclaredThirdBodies()
bool m_skipUndeclaredThirdBodies;

//! reference to SolutionBase
std::weak_ptr<SolutionBase> m_root;
//! reference to Solution
std::weak_ptr<Solution> m_root;
};

}
Expand Down
10 changes: 5 additions & 5 deletions include/cantera/thermo/Phase.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace Cantera
* support thermodynamic calculations (see \ref thermoprops).
*/

class SolutionBase;
class Solution;

//! Class Phase is the base class for phases of matter, managing the species and
//! elements in a phase, as well as the independent variables of temperature,
Expand Down Expand Up @@ -760,8 +760,8 @@ class Phase
m_caseSensitiveSpecies = cflag;
}

//! Set root SolutionBase holding all phase information
virtual void setRoot(std::shared_ptr<SolutionBase> root) {
//! Set root Solution holding all phase information
virtual void setRoot(std::shared_ptr<Solution> root) {
m_root = root;
}

Expand Down Expand Up @@ -878,8 +878,8 @@ class Phase
//! Entropy at 298.15 K and 1 bar of stable state pure elements (J kmol-1)
vector_fp m_entropy298;

//! reference to SolutionBase
std::weak_ptr<SolutionBase> m_root;
//! reference to Solution
std::weak_ptr<Solution> m_root;
};

}
Expand Down
10 changes: 5 additions & 5 deletions include/cantera/transport/TransportBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const VelocityBasis VB_SPECIES_2 = 2;
const VelocityBasis VB_SPECIES_3 = 3;
//@}

class SolutionBase;
class Solution;

//! Base class for transport property managers.
/*!
Expand Down Expand Up @@ -656,8 +656,8 @@ class Transport
*/
virtual void setThermo(thermo_t& thermo);

//! Set root SolutionBase holding all phase information
virtual void setRoot(std::shared_ptr<SolutionBase> root) {
//! Set root Solution holding all phase information
virtual void setRoot(std::shared_ptr<Solution> root) {
m_root = root;
}

Expand Down Expand Up @@ -688,8 +688,8 @@ class Transport
//! Defaults to the mass averaged basis = -2
int m_velocityBasis;

//! reference to SolutionBase
std::weak_ptr<SolutionBase> m_root;
//! reference to Solution
std::weak_ptr<Solution> m_root;
};

}
Expand Down
18 changes: 8 additions & 10 deletions interfaces/cython/cantera/_cantera.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -121,20 +121,16 @@ cdef extern from "cantera/thermo/Species.h" namespace "Cantera":
cdef vector[shared_ptr[CxxSpecies]] CxxGetSpecies "getSpecies" (CxxAnyValue&) except +translate_exception


cdef extern from "cantera/base/SolutionBase.h" namespace "Cantera":
cdef cppclass CxxSolutionBase "Cantera::SolutionBase":
CxxSolutionBase()
string type()
string setType(string)
string phase()
void setPhase(string)
cdef extern from "cantera/base/Solution.h" namespace "Cantera":
cdef cppclass CxxSolution "Cantera::Solution":
CxxSolution()
string name()
void setName(string)
void setThermoPhase(shared_ptr[CxxThermoPhase])
void setKinetics(shared_ptr[CxxKinetics])
void setTransport(shared_ptr[CxxTransport])

cdef shared_ptr[CxxSolutionBase] CxxNewSolutionBase "Cantera::SolutionBase::create" ()
cdef shared_ptr[CxxSolution] CxxNewSolution "Cantera::Solution::create" ()


cdef extern from "cantera/thermo/ThermoPhase.h" namespace "Cantera":
Expand All @@ -144,6 +140,8 @@ cdef extern from "cantera/thermo/ThermoPhase.h" namespace "Cantera":
# miscellaneous
string type()
string report(cbool, double) except +translate_exception
string id()
void setID(string)
double minTemp() except +translate_exception
double maxTemp() except +translate_exception
double refPressure() except +translate_exception
Expand Down Expand Up @@ -941,8 +939,8 @@ cdef class GasTransportData:
cdef _assign(self, shared_ptr[CxxTransportData] other)

cdef class _SolutionBase:
cdef shared_ptr[CxxSolutionBase] _base
cdef CxxSolutionBase* base
cdef shared_ptr[CxxSolution] _base
cdef CxxSolution* base
cdef shared_ptr[CxxThermoPhase] _thermo
cdef CxxThermoPhase* thermo
cdef shared_ptr[CxxKinetics] _kinetics
Expand Down
Loading

0 comments on commit 02175a3

Please sign in to comment.