6#ifndef CT_REACTORDELEGATOR_H
7#define CT_REACTORDELEGATOR_H
58 template <
class... Args>
60 : R(std::forward<Args>(args)...)
62 install(
"initialize", m_initialize, [
this](
double t0) { R::initialize(t0); });
64 [
this](std::array<size_t, 1> sizes,
double* y) { R::getState(y); });
65 install(
"updateState", m_updateState,
66 [
this](std::array<size_t, 1> sizes,
double* y) { R::updateState(y); });
67 install(
"updateConnected", m_updateConnected,
68 [
this](
bool updatePressure) { R::updateConnected(updatePressure); });
70 [
this](std::array<size_t, 2> sizes,
double t,
double* LHS,
double* RHS) {
74 if constexpr (std::is_base_of<Reactor, R>::value) {
75 install(
"evalWalls", m_evalWalls, [
this](
double t) { R::evalWalls(t); });
77 install(
"componentName", m_componentName,
78 [
this](
size_t k) {
return R::componentName(k); });
79 install(
"componentIndex", m_componentIndex,
80 [
this](
const string& nm) {
return R::componentIndex(nm); });
85 string type()
const override {
86 return fmt::format(
"Extensible{}", R::type());
89 void initialize(
double t0)
override {
93 void getState(
double* y)
override {
94 std::array<size_t, 1> sizes{R::neq()};
98 void updateState(
double* y)
override {
99 std::array<size_t, 1> sizes{R::neq()};
100 m_updateState(sizes, y);
103 void updateConnected(
bool updatePressure)
override {
104 m_updateConnected(updatePressure);
107 void eval(
double t,
double* LHS,
double* RHS)
override {
108 std::array<size_t, 2> sizes{R::neq(), R::neq()};
109 m_eval(sizes, t, LHS, RHS);
112 void evalWalls(
double t)
override {
113 if constexpr (std::is_base_of<Reactor, R>::value) {
120 string componentName(
size_t k)
override {
121 return m_componentName(k);
124 size_t componentIndex(
const string& nm)
const override {
125 return m_componentIndex(nm);
135 if constexpr (std::is_base_of<Reactor, R>::value) {
139 "Expansion rate is undefined for reactors of type '{}'.", type());
144 if constexpr (std::is_base_of<Reactor, R>::value) {
148 "Expansion rate is undefined for reactors of type '{}'.", type());
153 if constexpr (std::is_base_of<Reactor, R>::value) {
157 "Heat rate is undefined for reactors of type '{}'.", type());
162 if constexpr (std::is_base_of<Reactor, R>::value) {
166 "Heat rate is undefined for reactors of type '{}'.", type());
175 function<void(
double)> m_initialize;
176 function<void(std::array<size_t, 1>,
double*)> m_getState;
177 function<void(std::array<size_t, 1>,
double*)> m_updateState;
178 function<void(
bool)> m_updateConnected;
179 function<void(std::array<size_t, 2>,
double,
double*,
double*)> m_eval;
180 function<void(
double)> m_evalWalls;
181 function<string(
size_t)> m_componentName;
182 function<size_t(
const string&)> m_componentIndex;
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 error indicating that an unimplemented function has been called.
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 span< double > surfaceProductionRates()=0
Production rates on surfaces.
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].
virtual void evalWalls(double t)
Evaluate contributions from walls connected to this reactor.
Delegate methods of the Reactor class to external functions.
void setNEq(size_t n) override
Set the number of equations represented by this reactor.
double heatRate() const override
Get the net heat transfer rate (for example, through walls) into the reactor [W].
double expansionRate() const override
Get the net rate of volume change (for example, from moving walls) [m^3/s].
span< double > surfaceProductionRates() override
Production rates on surfaces.
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.