Skip to content

Commit 02175a3

Browse files
Ingmar Schoeglischoegl
Ingmar Schoegl
authored andcommitted
[Thermo] address discussion and review comments
* 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
1 parent 5932a24 commit 02175a3

File tree

17 files changed

+272
-378
lines changed

17 files changed

+272
-378
lines changed

include/cantera/base/Solution.h

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
//! @file Solution.h
2+
3+
// This file is part of Cantera. See License.txt in the top-level directory or
4+
// at https://cantera.org/license.txt for license and copyright information.
5+
6+
#ifndef CT_SOLUTION_H
7+
#define CT_SOLUTION_H
8+
9+
#include "cantera/base/ctexceptions.h"
10+
11+
namespace Cantera
12+
{
13+
14+
class ThermoPhase;
15+
class Kinetics;
16+
class Transport;
17+
18+
//! A container class holding managers for all pieces defining a phase
19+
class Solution : public std::enable_shared_from_this<Solution>
20+
{
21+
private:
22+
Solution();
23+
24+
public:
25+
~Solution() {}
26+
Solution(const Solution&) = delete;
27+
Solution& operator=(const Solution&) = delete;
28+
29+
static shared_ptr<Solution> create() {
30+
return shared_ptr<Solution>( new Solution );
31+
}
32+
33+
//! Return the name of this Solution object
34+
std::string name() const;
35+
36+
//! Set the name of this Solution object
37+
void setName(const std::string& name);
38+
39+
//! Set the ThermoPhase object
40+
void setThermoPhase(shared_ptr<ThermoPhase> thermo);
41+
42+
//! Set the Kinetics object
43+
void setKinetics(shared_ptr<Kinetics> kinetics);
44+
45+
//! Set the Transport object
46+
void setTransport(shared_ptr<Transport> transport);
47+
48+
//! Accessor for the ThermoPhase object
49+
ThermoPhase& thermo() {
50+
return *m_thermo;
51+
}
52+
53+
//! Accessor for the Kinetics object
54+
Kinetics& kinetics() {
55+
return *m_kinetics;
56+
}
57+
58+
//! Accessor for the Transport object
59+
Transport& transport() {
60+
return *m_transport;
61+
}
62+
63+
protected:
64+
shared_ptr<ThermoPhase> m_thermo; //! ThermoPhase manager
65+
shared_ptr<Kinetics> m_kinetics; //! Kinetics manager
66+
shared_ptr<Transport> m_transport; //! Transport manager
67+
68+
std::string m_name; //! name of Solution object
69+
};
70+
71+
}
72+
#endif

include/cantera/base/SolutionBase.h

Lines changed: 0 additions & 104 deletions
This file was deleted.

include/cantera/kinetics/Kinetics.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
namespace Cantera
2020
{
2121

22-
class SolutionBase;
22+
class Solution;
2323

2424
/**
2525
* @defgroup chemkinetics Chemical Kinetics
@@ -816,8 +816,8 @@ class Kinetics
816816
void selectPhase(const doublereal* data, const thermo_t* phase,
817817
doublereal* phase_data);
818818

819-
//! Set root SolutionBase holding all phase information
820-
virtual void setRoot(std::shared_ptr<SolutionBase> root) {
819+
//! Set root Solution holding all phase information
820+
virtual void setRoot(std::shared_ptr<Solution> root) {
821821
m_root = root;
822822
}
823823

@@ -943,8 +943,8 @@ class Kinetics
943943
//! @see skipUndeclaredThirdBodies()
944944
bool m_skipUndeclaredThirdBodies;
945945

946-
//! reference to SolutionBase
947-
std::weak_ptr<SolutionBase> m_root;
946+
//! reference to Solution
947+
std::weak_ptr<Solution> m_root;
948948
};
949949

950950
}

include/cantera/thermo/Phase.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace Cantera
2929
* support thermodynamic calculations (see \ref thermoprops).
3030
*/
3131

32-
class SolutionBase;
32+
class Solution;
3333

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

763-
//! Set root SolutionBase holding all phase information
764-
virtual void setRoot(std::shared_ptr<SolutionBase> root) {
763+
//! Set root Solution holding all phase information
764+
virtual void setRoot(std::shared_ptr<Solution> root) {
765765
m_root = root;
766766
}
767767

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

881-
//! reference to SolutionBase
882-
std::weak_ptr<SolutionBase> m_root;
881+
//! reference to Solution
882+
std::weak_ptr<Solution> m_root;
883883
};
884884

885885
}

include/cantera/transport/TransportBase.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ const VelocityBasis VB_SPECIES_2 = 2;
7474
const VelocityBasis VB_SPECIES_3 = 3;
7575
//@}
7676

77-
class SolutionBase;
77+
class Solution;
7878

7979
//! Base class for transport property managers.
8080
/*!
@@ -656,8 +656,8 @@ class Transport
656656
*/
657657
virtual void setThermo(thermo_t& thermo);
658658

659-
//! Set root SolutionBase holding all phase information
660-
virtual void setRoot(std::shared_ptr<SolutionBase> root) {
659+
//! Set root Solution holding all phase information
660+
virtual void setRoot(std::shared_ptr<Solution> root) {
661661
m_root = root;
662662
}
663663

@@ -688,8 +688,8 @@ class Transport
688688
//! Defaults to the mass averaged basis = -2
689689
int m_velocityBasis;
690690

691-
//! reference to SolutionBase
692-
std::weak_ptr<SolutionBase> m_root;
691+
//! reference to Solution
692+
std::weak_ptr<Solution> m_root;
693693
};
694694

695695
}

interfaces/cython/cantera/_cantera.pxd

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,20 +121,16 @@ cdef extern from "cantera/thermo/Species.h" namespace "Cantera":
121121
cdef vector[shared_ptr[CxxSpecies]] CxxGetSpecies "getSpecies" (CxxAnyValue&) except +translate_exception
122122

123123

124-
cdef extern from "cantera/base/SolutionBase.h" namespace "Cantera":
125-
cdef cppclass CxxSolutionBase "Cantera::SolutionBase":
126-
CxxSolutionBase()
127-
string type()
128-
string setType(string)
129-
string phase()
130-
void setPhase(string)
124+
cdef extern from "cantera/base/Solution.h" namespace "Cantera":
125+
cdef cppclass CxxSolution "Cantera::Solution":
126+
CxxSolution()
131127
string name()
132128
void setName(string)
133129
void setThermoPhase(shared_ptr[CxxThermoPhase])
134130
void setKinetics(shared_ptr[CxxKinetics])
135131
void setTransport(shared_ptr[CxxTransport])
136132

137-
cdef shared_ptr[CxxSolutionBase] CxxNewSolutionBase "Cantera::SolutionBase::create" ()
133+
cdef shared_ptr[CxxSolution] CxxNewSolution "Cantera::Solution::create" ()
138134

139135

140136
cdef extern from "cantera/thermo/ThermoPhase.h" namespace "Cantera":
@@ -144,6 +140,8 @@ cdef extern from "cantera/thermo/ThermoPhase.h" namespace "Cantera":
144140
# miscellaneous
145141
string type()
146142
string report(cbool, double) except +translate_exception
143+
string id()
144+
void setID(string)
147145
double minTemp() except +translate_exception
148146
double maxTemp() except +translate_exception
149147
double refPressure() except +translate_exception
@@ -941,8 +939,8 @@ cdef class GasTransportData:
941939
cdef _assign(self, shared_ptr[CxxTransportData] other)
942940

943941
cdef class _SolutionBase:
944-
cdef shared_ptr[CxxSolutionBase] _base
945-
cdef CxxSolutionBase* base
942+
cdef shared_ptr[CxxSolution] _base
943+
cdef CxxSolution* base
946944
cdef shared_ptr[CxxThermoPhase] _thermo
947945
cdef CxxThermoPhase* thermo
948946
cdef shared_ptr[CxxKinetics] _kinetics

0 commit comments

Comments
 (0)