6#ifndef CT_REACTORDELEGATOR_H
7#define CT_REACTORDELEGATOR_H
32 virtual double vdot()
const = 0;
40 virtual double qdot()
const = 0;
62 install(
"initialize", m_initialize, [
this](
double t0) { R::initialize(t0); });
63 install(
"syncState", m_syncState, [
this]() { R::syncState(); });
65 [
this](std::array<size_t, 1> sizes,
double* y) { R::getState(y); });
66 install(
"updateState", m_updateState,
67 [
this](std::array<size_t, 1> sizes,
double* y) { R::updateState(y); });
68 install(
"updateSurfaceState", m_updateSurfaceState,
69 [
this](std::array<size_t, 1> sizes,
double* y) { R::updateSurfaceState(y); });
70 install(
"getSurfaceInitialConditions", m_getSurfaceInitialConditions,
71 [
this](std::array<size_t, 1> sizes,
double* y) {
72 R::getSurfaceInitialConditions(y);
75 install(
"updateConnected", m_updateConnected,
76 [
this](
bool updatePressure) { R::updateConnected(updatePressure); });
78 [
this](std::array<size_t, 2> sizes,
double t,
double* LHS,
double* RHS) {
82 install(
"evalWalls", m_evalWalls, [
this](
double t) { R::evalWalls(t); });
83 install(
"evalSurfaces", m_evalSurfaces,
84 [
this](std::array<size_t, 3> sizes,
double* LHS,
double* RHS,
double* sdot) {
85 R::evalSurfaces(LHS, RHS, sdot);
88 install(
"componentName", m_componentName,
89 [
this](
size_t k) {
return R::componentName(k); });
90 install(
"componentIndex", m_componentIndex,
91 [
this](
const std::string& nm) {
return R::componentIndex(nm); });
92 install(
"speciesIndex", m_speciesIndex,
93 [
this](
const std::string& nm) {
return R::speciesIndex(nm); });
98 virtual void initialize(
double t0)
override {
102 virtual void syncState()
override {
106 virtual void getState(
double* y)
override {
107 std::array<size_t, 1> sizes{R::neq()};
108 m_getState(sizes, y);
111 virtual void updateState(
double* y)
override {
112 std::array<size_t, 1> sizes{R::neq()};
113 m_updateState(sizes, y);
116 virtual void updateSurfaceState(
double* y)
override {
117 std::array<size_t, 1> sizes{R::m_nv_surf};
118 m_updateSurfaceState(sizes, y);
121 virtual void getSurfaceInitialConditions(
double* y)
override {
122 std::array<size_t, 1> sizes{R::m_nv_surf};
123 m_getSurfaceInitialConditions(sizes, y);
126 virtual void updateConnected(
bool updatePressure)
override {
127 m_updateConnected(updatePressure);
130 virtual void eval(
double t,
double* LHS,
double* RHS)
override {
131 std::array<size_t, 2> sizes{R::neq(), R::neq()};
132 m_eval(sizes, t, LHS, RHS);
135 virtual void evalWalls(
double t)
override {
139 virtual 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 virtual std::string componentName(
size_t k)
override {
146 return m_componentName(k);
149 virtual size_t componentIndex(
const std::string& nm)
const override {
150 return m_componentIndex(nm);
153 virtual size_t speciesIndex(
const std::string& nm)
const override {
154 return m_speciesIndex(nm);
163 virtual double vdot()
const override {
171 virtual double qdot()
const override {
180 R::m_thermo->restoreState(R::m_state);
184 R::m_surfaces.at(n)->syncState();
188 std::function<void(
double)> m_initialize;
189 std::function<void()> m_syncState;
190 std::function<void(std::array<size_t, 1>,
double*)> m_getState;
191 std::function<void(std::array<size_t, 1>,
double*)> m_updateState;
192 std::function<void(std::array<size_t, 1>,
double*)> m_updateSurfaceState;
193 std::function<void(std::array<size_t, 1>,
double*)> m_getSurfaceInitialConditions;
194 std::function<void(
bool)> m_updateConnected;
195 std::function<void(std::array<size_t, 2>,
double,
double*,
double*)> m_eval;
196 std::function<void(
double)> m_evalWalls;
197 std::function<void(std::array<size_t, 3>,
double*,
double*,
double*)> m_evalSurfaces;
198 std::function<std::string(
size_t)> m_componentName;
199 std::function<size_t(
const std::string&)> m_componentIndex;
200 std::function<size_t(
const std::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 std::string &name, std::function< void()> &target, const std::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 double qdot() const =0
Get the net heat transfer rate (for example, through walls) into the reactor [W].
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 double vdot() const =0
Get the net rate of volume change (for example, from moving walls) [m^3/s].
virtual void setQdot(double q)=0
Set the net heat transfer rate (for example, through walls) into the reactor [W].
virtual void setVdot(double v)=0
Set the net rate of volume change (for example, from moving walls) [m^3/s].
Delegate methods of the Reactor class to external functions.
virtual double qdot() const override
Get the net heat transfer rate (for example, through walls) into the reactor [W].
virtual double vdot() const override
Get the net rate of volume change (for example, from moving walls) [m^3/s].
virtual void setVdot(double v) override
Set the net rate of volume change (for example, from moving walls) [m^3/s].
virtual void setQdot(double q) override
Set the net heat transfer rate (for example, through walls) into the reactor [W].
virtual void setNEq(size_t n) override
Set the number of equations represented by this reactor.
virtual void restoreThermoState() override
Set the state of the thermo object to correspond to the state of the reactor.
virtual void restoreSurfaceState(size_t n) override
Set the state of the thermo object for surface n to correspond to the state of that surface.
Namespace for the Cantera kernel.