6#ifndef CT_REACTORDELEGATOR_H
7#define CT_REACTORDELEGATOR_H
63 install(
"initialize", m_initialize, [
this](
double t0) { R::initialize(t0); });
64 install(
"syncState", m_syncState, [
this]() { R::syncState(); });
66 [
this](std::array<size_t, 1> sizes,
double* y) { R::getState(y); });
67 install(
"updateState", m_updateState,
68 [
this](std::array<size_t, 1> sizes,
double* y) { R::updateState(y); });
69 install(
"updateSurfaceState", m_updateSurfaceState,
70 [
this](std::array<size_t, 1> sizes,
double* y) { R::updateSurfaceState(y); });
71 install(
"getSurfaceInitialConditions", m_getSurfaceInitialConditions,
72 [
this](std::array<size_t, 1> sizes,
double* y) {
73 R::getSurfaceInitialConditions(y);
76 install(
"updateConnected", m_updateConnected,
77 [
this](
bool updatePressure) { R::updateConnected(updatePressure); });
79 [
this](std::array<size_t, 2> sizes,
double t,
double* LHS,
double* RHS) {
83 install(
"evalWalls", m_evalWalls, [
this](
double t) { R::evalWalls(t); });
84 install(
"evalSurfaces", m_evalSurfaces,
85 [
this](std::array<size_t, 3> sizes,
double* LHS,
double* RHS,
double* sdot) {
86 R::evalSurfaces(LHS, RHS, sdot);
89 install(
"componentName", m_componentName,
90 [
this](
size_t k) {
return R::componentName(k); });
91 install(
"componentIndex", m_componentIndex,
92 [
this](
const string& nm) {
return R::componentIndex(nm); });
93 install(
"speciesIndex", m_speciesIndex,
94 [
this](
const string& nm) {
return R::speciesIndex(nm); });
99 void initialize(
double t0)
override {
103 void syncState()
override {
107 void getState(
double* y)
override {
108 std::array<size_t, 1> sizes{R::neq()};
109 m_getState(sizes, y);
112 void updateState(
double* y)
override {
113 std::array<size_t, 1> sizes{R::neq()};
114 m_updateState(sizes, y);
117 void updateSurfaceState(
double* y)
override {
118 std::array<size_t, 1> sizes{R::m_nv_surf};
119 m_updateSurfaceState(sizes, y);
122 void getSurfaceInitialConditions(
double* y)
override {
123 std::array<size_t, 1> sizes{R::m_nv_surf};
124 m_getSurfaceInitialConditions(sizes, y);
127 void updateConnected(
bool updatePressure)
override {
128 m_updateConnected(updatePressure);
131 void eval(
double t,
double* LHS,
double* RHS)
override {
132 std::array<size_t, 2> sizes{R::neq(), R::neq()};
133 m_eval(sizes, t, LHS, RHS);
136 void evalWalls(
double t)
override {
140 void evalSurfaces(
double* LHS,
double* RHS,
double* sdot)
override {
141 std::array<size_t, 3> sizes{R::m_nv_surf, R::m_nv_surf, R::m_nsp};
142 m_evalSurfaces(sizes, LHS, RHS, sdot);
145 string componentName(
size_t k)
override {
146 return m_componentName(k);
149 size_t componentIndex(
const string& nm)
const override {
150 return m_componentIndex(nm);
153 size_t speciesIndex(
const string& nm)
const override {
154 return m_speciesIndex(nm);
180 R::m_thermo->restoreState(R::m_state);
184 R::m_surfaces.at(n)->syncState();
188 function<void(
double)> m_initialize;
189 function<void()> m_syncState;
190 function<void(std::array<size_t, 1>,
double*)> m_getState;
191 function<void(std::array<size_t, 1>,
double*)> m_updateState;
192 function<void(std::array<size_t, 1>,
double*)> m_updateSurfaceState;
193 function<void(std::array<size_t, 1>,
double*)> m_getSurfaceInitialConditions;
194 function<void(
bool)> m_updateConnected;
195 function<void(std::array<size_t, 2>,
double,
double*,
double*)> m_eval;
196 function<void(
double)> m_evalWalls;
197 function<void(std::array<size_t, 3>,
double*,
double*,
double*)> m_evalSurfaces;
198 function<string(
size_t)> m_componentName;
199 function<size_t(
const string&)> m_componentIndex;
200 function<size_t(
const string&)> m_speciesIndex;
Header file for class ReactorSurface.
Header for a simple thermodynamics model of a surface phase derived from ThermoPhase,...
Delegate member functions of a C++ class to externally-specified functions.
void install(const string &name, function< void()> &target, const function< void()> &func)
Install a function with the signature void() as being delegatable.
An abstract base class for providing access to protected capabilities Reactor objects from delegate m...
virtual void setNEq(size_t n)=0
Set the number of equations represented by this reactor.
virtual void restoreThermoState()=0
Set the state of the thermo object to correspond to the state of the reactor.
virtual void restoreSurfaceState(size_t n)=0
Set the state of the thermo object for surface n to correspond to the state of that surface.
virtual void setHeatRate(double q)=0
Set the net heat transfer rate (for example, through walls) into the reactor [W].
virtual void setExpansionRate(double v)=0
Set the net rate of volume change (for example, from moving walls) [m^3/s].
virtual double heatRate() const =0
Get the net heat transfer rate (for example, through walls) into the reactor [W].
virtual double expansionRate() const =0
Get the net rate of volume change (for example, from moving walls) [m^3/s].
Delegate methods of the Reactor class to external functions.
void setNEq(size_t n) override
Set the number of equations represented by this reactor.
void restoreSurfaceState(size_t n) override
Set the state of the thermo object for surface n to correspond to the state of that surface.
double heatRate() const override
Get the net heat transfer rate (for example, through walls) into the reactor [W].
void restoreThermoState() override
Set the state of the thermo object to correspond to the state of the reactor.
double expansionRate() const override
Get the net rate of volume change (for example, from moving walls) [m^3/s].
void setExpansionRate(double v) override
Set the net rate of volume change (for example, from moving walls) [m^3/s].
void setHeatRate(double q) override
Set the net heat transfer rate (for example, through walls) into the reactor [W].
Namespace for the Cantera kernel.