6#ifndef CT_REACTORDELEGATOR_H
7#define CT_REACTORDELEGATOR_H
65 install(
"initialize", m_initialize, [
this](
double t0) { R::initialize(t0); });
66 install(
"syncState", m_syncState, [
this]() { R::syncState(); });
68 [
this](std::array<size_t, 1> sizes,
double* y) { R::getState(y); });
69 install(
"updateState", m_updateState,
70 [
this](std::array<size_t, 1> sizes,
double* y) { R::updateState(y); });
71 install(
"updateSurfaceState", m_updateSurfaceState,
72 [
this](std::array<size_t, 1> sizes,
double* y) { R::updateSurfaceState(y); });
73 install(
"getSurfaceInitialConditions", m_getSurfaceInitialConditions,
74 [
this](std::array<size_t, 1> sizes,
double* y) {
75 R::getSurfaceInitialConditions(y);
78 install(
"updateConnected", m_updateConnected,
79 [
this](
bool updatePressure) { R::updateConnected(updatePressure); });
81 [
this](std::array<size_t, 2> sizes,
double t,
double* LHS,
double* RHS) {
85 install(
"evalWalls", m_evalWalls, [
this](
double t) { R::evalWalls(t); });
86 install(
"evalSurfaces", m_evalSurfaces,
87 [
this](std::array<size_t, 3> sizes,
double* LHS,
double* RHS,
double* sdot) {
88 R::evalSurfaces(LHS, RHS, sdot);
91 install(
"componentName", m_componentName,
92 [
this](
size_t k) {
return R::componentName(k); });
93 install(
"componentIndex", m_componentIndex,
94 [
this](
const string& nm) {
return R::componentIndex(nm); });
95 install(
"speciesIndex", m_speciesIndex,
96 [
this](
const string& nm) {
return R::speciesIndex(nm); });
101 string type()
const override {
102 return fmt::format(
"Extensible{}", R::type());
105 void initialize(
double t0)
override {
109 void syncState()
override {
113 void getState(
double* y)
override {
114 std::array<size_t, 1> sizes{R::neq()};
115 m_getState(sizes, y);
118 void updateState(
double* y)
override {
119 std::array<size_t, 1> sizes{R::neq()};
120 m_updateState(sizes, y);
123 void updateSurfaceState(
double* y)
override {
124 std::array<size_t, 1> sizes{R::m_nv_surf};
125 m_updateSurfaceState(sizes, y);
128 void getSurfaceInitialConditions(
double* y)
override {
129 std::array<size_t, 1> sizes{R::m_nv_surf};
130 m_getSurfaceInitialConditions(sizes, y);
133 void updateConnected(
bool updatePressure)
override {
134 m_updateConnected(updatePressure);
137 void eval(
double t,
double* LHS,
double* RHS)
override {
138 std::array<size_t, 2> sizes{R::neq(), R::neq()};
139 m_eval(sizes, t, LHS, RHS);
142 void evalWalls(
double t)
override {
146 void evalSurfaces(
double* LHS,
double* RHS,
double* sdot)
override {
147 std::array<size_t, 3> sizes{R::m_nv_surf, R::m_nv_surf, R::m_nsp};
148 m_evalSurfaces(sizes, LHS, RHS, sdot);
151 string componentName(
size_t k)
override {
152 return m_componentName(k);
155 size_t componentIndex(
const string& nm)
const override {
156 return m_componentIndex(nm);
159 size_t speciesIndex(
const string& nm)
const override {
160 return m_speciesIndex(nm);
186 R::m_thermo->restoreState(R::m_state);
190 R::m_surfaces.at(n)->syncState();
194 function<void(
double)> m_initialize;
195 function<void()> m_syncState;
196 function<void(std::array<size_t, 1>,
double*)> m_getState;
197 function<void(std::array<size_t, 1>,
double*)> m_updateState;
198 function<void(std::array<size_t, 1>,
double*)> m_updateSurfaceState;
199 function<void(std::array<size_t, 1>,
double*)> m_getSurfaceInitialConditions;
200 function<void(
bool)> m_updateConnected;
201 function<void(std::array<size_t, 2>,
double,
double*,
double*)> m_eval;
202 function<void(
double)> m_evalWalls;
203 function<void(std::array<size_t, 3>,
double*,
double*,
double*)> m_evalSurfaces;
204 function<string(
size_t)> m_componentName;
205 function<size_t(
const string&)> m_componentIndex;
206 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.