Skip to content

Commit

Permalink
Use override in C++ samples and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
speth committed Aug 15, 2023
1 parent fc21853 commit b35ef59
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 11 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
2 changes: 1 addition & 1 deletion test/kinetics/pdep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class PdepTest : public testing::Test
soln_.reset();
}

void SetUp() {
void SetUp() override {
string Xref = "H:1.0, R1A:1.0, R1B:1.0, R2:1.0, R3:1.0, R4:1.0, R5:1.0, R6:1.0";

soln_->thermo()->setState_TPX(900.0, 101325 * 8.0, Xref);
Expand Down
2 changes: 1 addition & 1 deletion test/thermo_consistency/consistency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class TestConsistency : public testing::TestWithParam<std::tuple<AnyMap, AnyMap>
make_deprecation_warnings_fatal();
}

void SetUp() {
void SetUp() override {
// See if we should skip this test specific test case
if (setup.hasKey("known-failures")) {
auto current = testing::UnitTest::GetInstance()->current_test_info()->name();
Expand Down

0 comments on commit b35ef59

Please sign in to comment.