Skip to content

Commit

Permalink
Use override in C++ samples
Browse files Browse the repository at this point in the history
  • Loading branch information
speth committed Aug 15, 2023
1 parent 03e19b8 commit fcf1864
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion samples/cxx/bvp/BoundaryValueProblem.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class BoundaryValueProblem : public Cantera::Domain1D
* grid points. Overload in derived classes to specify other
* choices for initial values.
*/
virtual double initialValue(size_t n, size_t j) {
double initialValue(size_t n, size_t j) override {
return 0.0;
}

Expand Down
7 changes: 2 additions & 5 deletions samples/cxx/bvp/blasius.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,9 @@ class Blasius : public BVP::BoundaryValueProblem
setComponent(1, B); // u will be component 1
}

// destructor
virtual ~Blasius() {}

// specify guesses for the initial values. These can be anything
// that leads to a converged solution.
virtual double initialValue(size_t n, size_t j) {
double initialValue(size_t n, size_t j) override {
switch (n) {
case 0:
return 0.1*z(j);
Expand All @@ -77,7 +74,7 @@ class Blasius : public BVP::BoundaryValueProblem
// Specify the residual function. This is where the ODE system and boundary
// conditions are specified. The solver will attempt to find a solution
// x so that rsd is zero.
void eval(size_t jg, double* x, double* rsd, int* diag, double rdt) {
void eval(size_t jg, double* x, double* rsd, int* diag, double rdt) override {
size_t jpt = jg - firstPoint();
size_t jmin, jmax;
if (jg == npos) { // evaluate all points
Expand Down
6 changes: 3 additions & 3 deletions samples/cxx/custom/custom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class ReactorODEs : public FuncEval {
* @param[in] p sensitivity parameter vector, length nparams()
* - note: sensitivity analysis isn't implemented in this example
*/
void eval(double t, double* y, double* ydot, double* p) {
void eval(double t, double* y, double* ydot, double* p) override {
// the solution vector *y* is [T, Y_1, Y_2, ... Y_K], where T is the
// system temperature, and Y_k is the mass fraction of species k.
// similarly, the time derivative of the solution vector, *ydot*, is
Expand Down Expand Up @@ -113,7 +113,7 @@ class ReactorODEs : public FuncEval {
* Number of equations in the ODE system.
* - overridden from FuncEval, called by the integrator during initialization.
*/
size_t neq() const {
size_t neq() const override {
return m_nEqs;
}

Expand All @@ -122,7 +122,7 @@ class ReactorODEs : public FuncEval {
* - overridden from FuncEval, called by the integrator during initialization.
* @param[out] y solution vector, length neq()
*/
void getState(double* y) {
void getState(double* y) override {
// the solution vector *y* is [T, Y_1, Y_2, ... Y_K], where T is the
// system temperature, and Y_k is the mass fraction of species k.
y[0] = m_gas->temperature();
Expand Down

0 comments on commit fcf1864

Please sign in to comment.