Use override on ZeroD classes

This commit is contained in:
Ray Speth 2023-08-13 22:35:27 -04:00 committed by Ray Speth
parent 2531018553
commit a4be49218b
13 changed files with 116 additions and 119 deletions

View File

@ -22,21 +22,21 @@ class ConstPressureMoleReactor : public MoleReactor
public:
ConstPressureMoleReactor() {}
virtual string type() const {
string type() const override {
return "ConstPressureMoleReactor";
};
virtual size_t componentIndex(const string& nm) const;
size_t componentIndex(const string& nm) const override;
virtual string componentName(size_t k);
string componentName(size_t k) override;
virtual void getState(double* y);
void getState(double* y) override;
virtual void initialize(double t0 = 0.0);
void initialize(double t0=0.0) override;
virtual void eval(double t, double* LHS, double* RHS);
void eval(double t, double* LHS, double* RHS) override;
virtual void updateState(double* y);
void updateState(double* y) override;
protected:
const size_t m_sidx = 1;

View File

@ -25,23 +25,23 @@ class ConstPressureReactor : public Reactor
public:
ConstPressureReactor() {}
virtual string type() const {
string type() const override {
return "ConstPressureReactor";
}
virtual void getState(double* y);
void getState(double* y) override;
virtual void initialize(double t0 = 0.0);
virtual void eval(double t, double* LHS, double* RHS);
void initialize(double t0=0.0) override;
void eval(double t, double* LHS, double* RHS) override;
virtual void updateState(double* y);
void updateState(double* y) override;
//! Return the index in the solution vector for this reactor of the
//! component named *nm*. Possible values for *nm* are "mass", "enthalpy",
//! the name of a homogeneous phase species, or the name of a surface
//! species.
virtual size_t componentIndex(const string& nm) const;
string componentName(size_t k);
size_t componentIndex(const string& nm) const override;
string componentName(size_t k) override;
};
}

View File

@ -22,32 +22,32 @@ class IdealGasConstPressureMoleReactor : public ConstPressureMoleReactor
public:
IdealGasConstPressureMoleReactor() {}
virtual string type() const {
string type() const override {
return "IdealGasConstPressureMoleReactor";
};
virtual size_t componentIndex(const string& nm) const;
size_t componentIndex(const string& nm) const override;
virtual string componentName(size_t k);
string componentName(size_t k) override;
virtual void setThermoMgr(ThermoPhase& thermo);
void setThermoMgr(ThermoPhase& thermo) override;
virtual void getState(double* y);
void getState(double* y) override;
virtual void initialize(double t0 = 0.0);
void initialize(double t0=0.0) override;
virtual void eval(double t, double* LHS, double* RHS);
void eval(double t, double* LHS, double* RHS) override;
virtual void updateState(double* y);
void updateState(double* y) override;
//! Calculate an approximate Jacobian to accelerate preconditioned solvers
//! Neglects derivatives with respect to mole fractions that would generate a
//! fully-dense Jacobian. Currently also neglects terms related to interactions
//! between reactors, for example via inlets and outlets.
virtual Eigen::SparseMatrix<double> jacobian();
Eigen::SparseMatrix<double> jacobian() override;
virtual bool preconditionerSupported() const {return true;};
bool preconditionerSupported() const override { return true; };
protected:
vector<double> m_hk; //!< Species molar enthalpies

View File

@ -24,25 +24,25 @@ class IdealGasConstPressureReactor : public ConstPressureReactor
public:
IdealGasConstPressureReactor() {}
virtual string type() const {
string type() const override {
return "IdealGasConstPressureReactor";
}
virtual void setThermoMgr(ThermoPhase& thermo);
void setThermoMgr(ThermoPhase& thermo) override;
virtual void getState(double* y);
void getState(double* y) override;
virtual void initialize(double t0 = 0.0);
virtual void eval(double t, double* LHS, double* RHS);
void initialize(double t0=0.0) override;
void eval(double t, double* LHS, double* RHS) override;
virtual void updateState(double* y);
void updateState(double* y) override;
//! Return the index in the solution vector for this reactor of the
//! component named *nm*. Possible values for *nm* are "mass",
//! "temperature", the name of a homogeneous phase species, or the name of a
//! surface species.
virtual size_t componentIndex(const string& nm) const;
string componentName(size_t k);
size_t componentIndex(const string& nm) const override;
string componentName(size_t k) override;
protected:
vector<double> m_hk; //!< Species molar enthalpies

View File

@ -22,32 +22,32 @@ class IdealGasMoleReactor : public MoleReactor
public:
IdealGasMoleReactor() {}
virtual string type() const {
string type() const override {
return "IdealGasMoleReactor";
}
virtual size_t componentIndex(const string& nm) const;
size_t componentIndex(const string& nm) const override;
virtual string componentName(size_t k);
string componentName(size_t k) override;
virtual void setThermoMgr(ThermoPhase& thermo);
void setThermoMgr(ThermoPhase& thermo) override;
virtual void getState(double* y);
void getState(double* y) override;
virtual void initialize(double t0 = 0.0);
void initialize(double t0=0.0) override;
virtual void eval(double t, double* LHS, double* RHS);
void eval(double t, double* LHS, double* RHS) override;
virtual void updateState(double* y);
void updateState(double* y) override;
//! Calculate an approximate Jacobian to accelerate preconditioned solvers
//! Neglects derivatives with respect to mole fractions that would generate a
//! fully-dense Jacobian. Currently, also neglects terms related to interactions
//! between reactors, for example via inlets and outlets.
virtual Eigen::SparseMatrix<double> jacobian();
Eigen::SparseMatrix<double> jacobian() override;
virtual bool preconditionerSupported() const {return true;};
bool preconditionerSupported() const override {return true;};
protected:
vector<double> m_uk; //!< Species molar internal energies

View File

@ -22,26 +22,26 @@ class IdealGasReactor : public Reactor
public:
IdealGasReactor() {}
virtual string type() const {
string type() const override {
return "IdealGasReactor";
}
virtual void setThermoMgr(ThermoPhase& thermo);
void setThermoMgr(ThermoPhase& thermo) override;
virtual void getState(double* y);
void getState(double* y) override;
virtual void initialize(double t0 = 0.0);
void initialize(double t0=0.0) override;
virtual void eval(double t, double* LHS, double* RHS);
void eval(double t, double* LHS, double* RHS) override;
virtual void updateState(double* y);
void updateState(double* y) override;
//! Return the index in the solution vector for this reactor of the
//! component named *nm*. Possible values for *nm* are "mass",
//! "volume", "temperature", the name of a homogeneous phase species, or the
//! name of a surface species.
virtual size_t componentIndex(const string& nm) const;
string componentName(size_t k);
size_t componentIndex(const string& nm) const override;
string componentName(size_t k) override;
protected:
vector<double> m_uk; //!< Species molar internal energies

View File

@ -22,21 +22,21 @@ class MoleReactor : public Reactor
public:
MoleReactor() {}
virtual string type() const {
string type() const override {
return "MoleReactor";
}
virtual void initialize(double t0 = 0.0);
void initialize(double t0=0.0) override;
virtual void getState(double* y);
void getState(double* y) override;
virtual void updateState(double* y);
void updateState(double* y) override;
virtual void eval(double t, double* LHS, double* RHS);
void eval(double t, double* LHS, double* RHS) override;
size_t componentIndex(const string& nm) const;
size_t componentIndex(const string& nm) const override;
string componentName(size_t k);
string componentName(size_t k) override;
protected:
//! For each surface in the reactor, update vector of triplets with all relevant
@ -46,17 +46,17 @@ protected:
//! Get moles of the system from mass fractions stored by thermo object
//! @param y vector for moles to be put into
virtual void getMoles(double* y);
void getMoles(double* y);
//! Set internal mass variable based on moles given
//! @param y vector of moles of the system
virtual void setMassFromMoles(double* y);
void setMassFromMoles(double* y);
virtual void evalSurfaces(double* LHS, double* RHS, double* sdot);
void evalSurfaces(double* LHS, double* RHS, double* sdot) override;
virtual void updateSurfaceState(double* y);
void updateSurfaceState(double* y) override;
virtual void getSurfaceInitialConditions(double* y);
void getSurfaceInitialConditions(double* y) override;
//! const value for the species start index
const size_t m_sidx = 2;

View File

@ -45,7 +45,7 @@ class Reactor : public ReactorBase
public:
Reactor() = default;
virtual string type() const {
string type() const override {
return "Reactor";
}
@ -74,9 +74,9 @@ public:
void insert(shared_ptr<Solution> sol);
virtual void setKineticsMgr(Kinetics& kin);
void setKineticsMgr(Kinetics& kin) override;
void setChemistry(bool cflag=true) {
void setChemistry(bool cflag=true) override {
m_chem = cflag;
}
@ -86,7 +86,7 @@ public:
return m_chem;
}
void setEnergy(int eflag=1) {
void setEnergy(int eflag=1) override {
if (eflag > 0) {
m_energy = true;
} else {
@ -123,7 +123,7 @@ public:
throw NotImplementedError("Reactor::getStateDae(y, ydot)");
}
virtual void initialize(double t0 = 0.0);
void initialize(double t0=0.0) override;
//! Evaluate the reactor governing equations. Called by ReactorNet::eval.
//! @param[in] t time.
@ -150,8 +150,7 @@ public:
throw NotImplementedError("Reactor::getConstraints");
}
virtual void syncState();
void syncState() override;
//! Set the state of the reactor to correspond to the state vector *y*.
virtual void updateState(double* y);

View File

@ -96,92 +96,91 @@ public:
// Overrides of Reactor methods
virtual void initialize(double t0) override {
void initialize(double t0) override {
m_initialize(t0);
}
virtual void syncState() override {
void syncState() override {
m_syncState();
}
virtual void getState(double* y) override {
void getState(double* y) override {
std::array<size_t, 1> sizes{R::neq()};
m_getState(sizes, y);
}
virtual void updateState(double* y) override {
void updateState(double* y) override {
std::array<size_t, 1> sizes{R::neq()};
m_updateState(sizes, y);
}
virtual void updateSurfaceState(double* y) override {
void updateSurfaceState(double* y) override {
std::array<size_t, 1> sizes{R::m_nv_surf};
m_updateSurfaceState(sizes, y);
}
virtual void getSurfaceInitialConditions(double* y) override {
void getSurfaceInitialConditions(double* y) override {
std::array<size_t, 1> sizes{R::m_nv_surf};
m_getSurfaceInitialConditions(sizes, y);
}
virtual void updateConnected(bool updatePressure) override {
void updateConnected(bool updatePressure) override {
m_updateConnected(updatePressure);
}
virtual void eval(double t, double* LHS, double* RHS) override {
void eval(double t, double* LHS, double* RHS) override {
std::array<size_t, 2> sizes{R::neq(), R::neq()};
m_eval(sizes, t, LHS, RHS);
}
virtual void evalWalls(double t) override {
void evalWalls(double t) override {
m_evalWalls(t);
}
virtual void evalSurfaces(double* LHS, double* RHS, double* sdot) override
{
void evalSurfaces(double* LHS, double* RHS, double* sdot) override {
std::array<size_t, 3> sizes{R::m_nv_surf, R::m_nv_surf, R::m_nsp};
m_evalSurfaces(sizes, LHS, RHS, sdot);
}
virtual string componentName(size_t k) override {
string componentName(size_t k) override {
return m_componentName(k);
}
virtual size_t componentIndex(const string& nm) const override {
size_t componentIndex(const string& nm) const override {
return m_componentIndex(nm);
}
virtual size_t speciesIndex(const string& nm) const override {
size_t speciesIndex(const string& nm) const override {
return m_speciesIndex(nm);
}
// Public access to protected Reactor variables needed by derived classes
virtual void setNEq(size_t n) override {
void setNEq(size_t n) override {
R::m_nv = n;
}
virtual double expansionRate() const override {
double expansionRate() const override {
return R::m_vdot;
}
virtual void setExpansionRate(double v) override {
void setExpansionRate(double v) override {
R::m_vdot = v;
}
virtual double heatRate() const override {
double heatRate() const override {
return R::m_Qdot;
}
virtual void setHeatRate(double q) override {
void setHeatRate(double q) override {
R::m_Qdot = q;
}
virtual void restoreThermoState() override {
void restoreThermoState() override {
R::m_thermo->restoreState(R::m_state);
}
virtual void restoreSurfaceState(size_t n) override {
void restoreSurfaceState(size_t n) override {
R::m_surfaces.at(n)->syncState();
}

View File

@ -30,7 +30,7 @@ class ReactorNet : public FuncEval
{
public:
ReactorNet();
virtual ~ReactorNet();
~ReactorNet() override;
ReactorNet(const ReactorNet&) = delete;
ReactorNet& operator=(const ReactorNet&) = delete;
@ -205,7 +205,7 @@ public:
double* ydot, double* p, Array2D* j);
// overloaded methods of class FuncEval
virtual size_t neq() const {
size_t neq() const override {
return m_nv;
}
@ -213,21 +213,21 @@ public:
return m_reactors.size();
}
virtual void eval(double t, double* y, double* ydot, double* p);
void eval(double t, double* y, double* ydot, double* p) override;
//! eval coupling for IDA / DAEs
virtual void evalDae(double t, double* y, double* ydot, double* p,
double* residual);
void evalDae(double t, double* y, double* ydot, double* p,
double* residual) override;
virtual void getState(double* y);
virtual void getStateDae(double* y, double* ydot);
void getState(double* y) override;
void getStateDae(double* y, double* ydot) override;
//! Return k-th derivative at the current state of the system
virtual void getDerivative(int k, double* dky);
virtual void getConstraints(double* constraints);
void getConstraints(double* constraints) override;
virtual size_t nparams() const {
size_t nparams() const override {
return m_sens_params.size();
}
@ -288,9 +288,9 @@ public:
//! Retrieve absolute step size limits during advance
bool getAdvanceLimits(double* limits) const;
virtual void preconditionerSetup(double t, double* y, double gamma);
void preconditionerSetup(double t, double* y, double gamma) override;
virtual void preconditionerSolve(double* rhs, double* output);
void preconditionerSolve(double* rhs, double* output) override;
//! Get solver stats from integrator
AnyMap solverStats() const;
@ -303,8 +303,7 @@ protected:
//! Check that preconditioning is supported by all reactors in the network
virtual void checkPreconditionerSupported() const;
//! Update the preconditioner based on the already computed jacobian values
virtual void updatePreconditioner(double gamma);
void updatePreconditioner(double gamma) override;
//! Estimate a future state based on current derivatives.
//! The function is intended for internal use by ReactorNet::advance

View File

@ -20,11 +20,11 @@ class Reservoir : public ReactorBase
public:
Reservoir() {}
virtual string type() const {
string type() const override {
return "Reservoir";
}
virtual void initialize(double t0 = 0.0) {}
void initialize(double t0=0.0) override {}
void insert(ThermoPhase& contents) {
setThermoMgr(contents);

View File

@ -138,7 +138,7 @@ public:
//! String indicating the wall model implemented. Usually
//! corresponds to the name of the derived class.
virtual string type() const {
string type() const override {
return "Wall";
}
@ -166,7 +166,7 @@ public:
* @deprecated Still used by traditional MATLAB toolbox; replaceable by
* expansionRate.
*/
virtual double vdot(double t);
double vdot(double t) override;
//! Rate of volume change (m^3/s) for the adjacent reactors.
/*!
@ -180,7 +180,7 @@ public:
* reactor on left, and decreases in the volume of the reactor on the right.
* @since New in %Cantera 3.0.
*/
virtual double expansionRate();
double expansionRate() override;
//! Heat flux function @f$ q_0(t) @f$ evaluated at current reactor network time.
//! @since New in %Cantera 3.0.
@ -202,7 +202,7 @@ public:
* from left to right.
* @deprecated Still used by traditional MATLAB toolbox; replaceable by heatRate.
*/
virtual double Q(double t);
double Q(double t) override;
//! Heat flow rate through the wall (W).
/*!
@ -215,7 +215,7 @@ public:
* time. Positive values denote a flux from left to right.
* @since New in %Cantera 3.0.
*/
virtual double heatRate();
double heatRate() override;
void setThermalResistance(double Rth) {
m_rrth = 1.0/Rth;

View File

@ -22,7 +22,7 @@ class MassFlowController : public FlowDevice
public:
MassFlowController() = default;
virtual string type() const {
string type() const override {
return "MassFlowController";
}
@ -46,14 +46,14 @@ public:
return m_coeff;
}
virtual void setPressureFunction(Func1* f) {
void setPressureFunction(Func1* f) override {
throw NotImplementedError("MassFlowController::setPressureFunction");
}
//! If a function of time has been specified for mdot, then update the
//! stored mass flow rate. Otherwise, mdot is a constant, and does not
//! need updating.
virtual void updateMassFlowRate(double time);
void updateMassFlowRate(double time) override;
};
/**
@ -67,11 +67,11 @@ class PressureController : public FlowDevice
public:
PressureController() = default;
virtual string type() const {
string type() const override {
return "PressureController";
}
virtual bool ready() {
bool ready() override {
return FlowDevice::ready() && m_primary != 0;
}
@ -86,7 +86,7 @@ public:
//! @deprecated To be removed after %Cantera 3.0; replaced by setPrimary().
void setMaster(FlowDevice* master);
virtual void setTimeFunction(Func1* g) {
void setTimeFunction(Func1* g) override {
throw NotImplementedError("PressureController::setTimeFunction");
}
@ -109,7 +109,7 @@ public:
return m_coeff;
}
virtual void updateMassFlowRate(double time);
void updateMassFlowRate(double time) override;
protected:
FlowDevice* m_primary = nullptr;
@ -128,7 +128,7 @@ class Valve : public FlowDevice
public:
Valve() = default;
virtual string type() const {
string type() const override {
return "Valve";
}
@ -152,7 +152,7 @@ public:
}
//! Compute the current mass flow rate, based on the pressure difference.
virtual void updateMassFlowRate(double time);
void updateMassFlowRate(double time) override;
};
}