Skip to content

Commit

Permalink
[thermo] Make SolutionBase.source exclusive to Python
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl authored and speth committed Jun 5, 2020
1 parent 0cbce97 commit 113bd4b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
8 changes: 0 additions & 8 deletions include/cantera/base/Solution.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ class Solution : public std::enable_shared_from_this<Solution>
//! Set the name of this Solution object
void setName(const std::string& name);

//! Return the source of this Solution object
std::string source() const { return m_source; }

//! Set the source of this Solution object
void setSource(const std::string& source) { m_source = source; }

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

Expand All @@ -68,8 +62,6 @@ class Solution : public std::enable_shared_from_this<Solution>
}

protected:
std::string m_source; //!< Source of Solution (e.g. file name)

shared_ptr<ThermoPhase> m_thermo; //!< ThermoPhase manager
shared_ptr<Kinetics> m_kinetics; //!< Kinetics manager
shared_ptr<Transport> m_transport; //!< Transport manager
Expand Down
3 changes: 1 addition & 2 deletions interfaces/cython/cantera/_cantera.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ cdef extern from "cantera/base/Solution.h" namespace "Cantera":
CxxSolution()
string name()
void setName(string)
string source()
void setSource(string)
void setThermo(shared_ptr[CxxThermoPhase])
void setKinetics(shared_ptr[CxxKinetics])
void setTransport(shared_ptr[CxxTransport])
Expand Down Expand Up @@ -967,6 +965,7 @@ cdef class GasTransportData:
cdef class _SolutionBase:
cdef shared_ptr[CxxSolution] _base
cdef CxxSolution* base
cdef str _source
cdef shared_ptr[CxxThermoPhase] _thermo
cdef CxxThermoPhase* thermo
cdef shared_ptr[CxxKinetics] _kinetics
Expand Down
16 changes: 9 additions & 7 deletions interfaces/cython/cantera/base.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ cdef class _SolutionBase:
self.kinetics = other.kinetics
self.transport = other.transport
self._base = other._base
self._source = other._source
self._thermo = other._thermo
self._kinetics = other._kinetics
self._transport = other._transport
Expand All @@ -45,6 +46,7 @@ cdef class _SolutionBase:

# Assign base and set managers to NULL
self._base = CxxNewSolution()
self._source = None
self.base = self._base.get()
self.thermo = NULL
self.kinetics = NULL
Expand Down Expand Up @@ -87,10 +89,10 @@ cdef class _SolutionBase:

property source:
"""
The source of this object (e.g. a file name)
The source of this object (such as a file name).
"""
def __get__(self):
return pystr(self.base.source())
return self._source

property composite:
"""
Expand All @@ -115,10 +117,10 @@ cdef class _SolutionBase:
cdef CxxAnyMap root
if infile:
root = AnyMapFromYamlFile(stringify(infile))
self.base.setSource(stringify(infile))
self._source = infile
elif source:
root = AnyMapFromYamlString(stringify(source))
self.base.setSource(stringify('custom YAML'))
self._source = 'custom YAML'

phaseNode = root[stringify("phases")].getMapWhere(stringify("name"),
stringify(name))
Expand Down Expand Up @@ -153,10 +155,10 @@ cdef class _SolutionBase:
"""
if infile:
rootNode = CxxGetXmlFile(stringify(infile))
self.base.setSource(stringify(infile))
self._source = infile
elif source:
rootNode = CxxGetXmlFromString(stringify(source))
self.base.setSource(stringify('custom CTI/XML'))
self._source = 'custom CTI/XML'

# Get XML data
cdef XML_Node* phaseNode
Expand Down Expand Up @@ -195,7 +197,7 @@ cdef class _SolutionBase:
Instantiate a set of new Cantera C++ objects based on a string defining
the model type and a list of Species objects.
"""
self.base.setSource(stringify('custom parts'))
self._source = 'custom parts'
self.thermo = newThermoPhase(stringify(thermo))
self._thermo.reset(self.thermo)
self.thermo.addUndefinedElements()
Expand Down

0 comments on commit 113bd4b

Please sign in to comment.