Skip to content

Commit

Permalink
Use override on various utility classes
Browse files Browse the repository at this point in the history
  • Loading branch information
speth committed Aug 15, 2023
1 parent cef19a9 commit fc21853
Show file tree
Hide file tree
Showing 28 changed files with 227 additions and 231 deletions.
2 changes: 1 addition & 1 deletion include/cantera/base/AnyMap.h
Expand Up @@ -767,7 +767,7 @@ class InputFileError : public CanteraError
{
}

virtual string getClass() const {
string getClass() const override {
return "InputFileError";
}
protected:
Expand Down
2 changes: 1 addition & 1 deletion include/cantera/base/Array.h
Expand Up @@ -86,7 +86,7 @@ class Array2D
* @param m This is the number of columns in the new matrix
* @param v Default fill value -> defaults to zero.
*/
void resize(size_t n, size_t m, double v=0.0);
virtual void resize(size_t n, size_t m, double v=0.0);

//! Append a column to the existing matrix using a std vector
/*!
Expand Down
2 changes: 1 addition & 1 deletion include/cantera/base/ExtensionManagerFactory.h
Expand Up @@ -24,7 +24,7 @@ class ExtensionManagerFactory : public Factory<ExtensionManager>
}

//! Delete the static instance of this factory
virtual void deleteFactory();
void deleteFactory() override;

//! Static function that returns the static instance of the factory, creating it
//! if necessary.
Expand Down
4 changes: 1 addition & 3 deletions include/cantera/base/NoExitLogger.h
Expand Up @@ -14,10 +14,8 @@ namespace Cantera {
class NoExitLogger : public Logger {
public:
NoExitLogger() {}
virtual ~NoExitLogger() {}

virtual void error(const string& msg)
{
void error(const string& msg) override {
std::cerr << msg << std::endl;
}
};
Expand Down
14 changes: 7 additions & 7 deletions include/cantera/base/ctexceptions.h
Expand Up @@ -94,7 +94,7 @@ class CanteraError : public std::exception
virtual ~CanteraError() throw() {};

//! Get a description of the error
const char* what() const throw();
const char* what() const throw() override;

//! Method overridden by derived classes to format the error message
virtual string getMessage() const;
Expand Down Expand Up @@ -147,8 +147,8 @@ class ArraySizeError : public CanteraError
ArraySizeError(const string& procedure, size_t sz, size_t reqd) :
CanteraError(procedure), sz_(sz), reqd_(reqd) {}

virtual string getMessage() const;
virtual string getClass() const {
string getMessage() const override;
string getClass() const override {
return "ArraySizeError";
}

Expand Down Expand Up @@ -178,9 +178,9 @@ class IndexError : public CanteraError
IndexError(const string& func, const string& arrayName, size_t m, size_t mmax) :
CanteraError(func), arrayName_(arrayName), m_(m), mmax_(mmax) {}

virtual ~IndexError() throw() {};
virtual string getMessage() const;
virtual string getClass() const {
~IndexError() throw() override {};
string getMessage() const override;
string getClass() const override {
return "IndexError";
}

Expand All @@ -204,7 +204,7 @@ class NotImplementedError : public CanteraError
NotImplementedError(const string& func, const string& msg, const Args&... args) :
CanteraError(func, msg, args...) {}

virtual string getClass() const {
string getClass() const override {
return "NotImplementedError";
}
};
Expand Down
6 changes: 3 additions & 3 deletions include/cantera/cython/funcWrapper.h
Expand Up @@ -100,7 +100,7 @@ class CallbackError : public Cantera::CanteraError
Py_XDECREF(m_value);
}

std::string getMessage() const {
std::string getMessage() const override {
std::string msg;

PyObject* name = PyObject_GetAttrString(m_type, "__name__");
Expand Down Expand Up @@ -130,7 +130,7 @@ class CallbackError : public Cantera::CanteraError
return msg;
}

virtual std::string getClass() const {
std::string getClass() const override {
return "Exception";
}

Expand All @@ -148,7 +148,7 @@ class Func1Py : public Cantera::Func1
m_pyobj(pyobj) {
}

double eval(double t) const {
double eval(double t) const override {
void* err[2] = {0, 0};
double y = m_callback(t, m_pyobj, err);
if (err[0]) {
Expand Down
8 changes: 4 additions & 4 deletions include/cantera/cython/utils_utils.h
Expand Up @@ -50,7 +50,7 @@ inline int get_sundials_version()
class PythonLogger : public Cantera::Logger
{
public:
virtual void write(const std::string& s) {
void write(const std::string& s) override {
// 1000 bytes is the maximum size permitted by PySys_WriteStdout
static const size_t N = 999;
for (size_t i = 0; i < s.size(); i+=N) {
Expand All @@ -59,12 +59,12 @@ class PythonLogger : public Cantera::Logger
std::cout.flush();
}

virtual void writeendl() {
void writeendl() override {
PySys_WriteStdout("%s", "\n");
std::cout.flush();
}

virtual void warn(const std::string& warning, const std::string& msg) {
void warn(const std::string& warning, const std::string& msg) override {
if (mapped_PyWarnings.find(warning) != mapped_PyWarnings.end()) {
PyErr_WarnEx(mapped_PyWarnings[warning], msg.c_str(), 1);
} else {
Expand All @@ -73,7 +73,7 @@ class PythonLogger : public Cantera::Logger
}
}

virtual void error(const std::string& msg) {
void error(const std::string& msg) override {
PyErr_SetString(PyExc_RuntimeError, msg.c_str());
}
};
Expand Down
2 changes: 1 addition & 1 deletion include/cantera/extensions/PythonExtensionManager.h
Expand Up @@ -25,7 +25,7 @@ namespace Cantera
class PythonExtensionManager : public ExtensionManager
{
public:
virtual void registerRateBuilders(const string& extensionName) override;
void registerRateBuilders(const string& extensionName) override;

void registerRateBuilder(const string& moduleName,
const string& className, const string& rateName) override;
Expand Down
4 changes: 2 additions & 2 deletions include/cantera/kinetics/KineticsFactory.h
Expand Up @@ -23,12 +23,12 @@ class KineticsFactory : public Factory<Kinetics>
public:
static KineticsFactory* factory();

virtual void deleteFactory();
void deleteFactory() override;

/**
* Return a new, empty kinetics manager.
*/
virtual Kinetics* newKinetics(const string& model);
Kinetics* newKinetics(const string& model);

private:
static KineticsFactory* s_factory;
Expand Down
2 changes: 1 addition & 1 deletion include/cantera/kinetics/ReactionRateFactory.h
Expand Up @@ -64,7 +64,7 @@ class ReactionRateFactory
*/
static ReactionRateFactory* factory();

virtual void deleteFactory();
void deleteFactory() override;

private:
//! Pointer to the single instance of the factory
Expand Down
4 changes: 2 additions & 2 deletions include/cantera/numerics/AdaptivePreconditioner.h
Expand Up @@ -41,9 +41,9 @@ class AdaptivePreconditioner : public PreconditionerBase

void setValue(size_t row, size_t col, double value) override;

virtual void stateAdjustment(vector<double>& state) override;
void stateAdjustment(vector<double>& state) override;

virtual void updatePreconditioner() override;
void updatePreconditioner() override;

//! Prune preconditioner elements
void prunePreconditioner();
Expand Down
34 changes: 17 additions & 17 deletions include/cantera/numerics/BandMatrix.h
Expand Up @@ -74,8 +74,8 @@ class BandMatrix : public GeneralMatrix
*/
void bfill(double v = 0.0);

double& operator()(size_t i, size_t j);
double operator()(size_t i, size_t j) const;
double& operator()(size_t i, size_t j) override;
double operator()(size_t i, size_t j) const override;

//! Return a changeable reference to element (i,j).
/*!
Expand Down Expand Up @@ -117,7 +117,7 @@ class BandMatrix : public GeneralMatrix
*/
double _value(size_t i, size_t j) const;

virtual size_t nRows() const;
size_t nRows() const override;

//! Number of columns
size_t nColumns() const;
Expand All @@ -132,8 +132,8 @@ class BandMatrix : public GeneralMatrix
size_t ldim() const;

//! Multiply A*b and write result to @c prod.
virtual void mult(const double* b, double* prod) const;
virtual void leftMult(const double* const b, double* const prod) const;
void mult(const double* b, double* prod) const override;
void leftMult(const double* const b, double* const prod) const override;

//! Perform an LU decomposition, the LAPACK routine DGBTRF is used.
/*!
Expand All @@ -142,7 +142,7 @@ class BandMatrix : public GeneralMatrix
* @returns a success flag. 0 indicates a success; ~0 indicates some
* error occurred, see the LAPACK documentation
*/
int factor();
int factor() override;

//! Solve the matrix problem Ax = b
/*!
Expand All @@ -162,14 +162,14 @@ class BandMatrix : public GeneralMatrix
* @returns a success flag. 0 indicates a success; ~0 indicates some error
* occurred, see the LAPACK documentation
*/
int solve(double* b, size_t nrhs=1, size_t ldb=0);
int solve(double* b, size_t nrhs=1, size_t ldb=0) override;

//! Returns an iterator for the start of the band storage data
/*!
* Iterator points to the beginning of the data, and it is changeable.
* @deprecated Unused. To be removed after %Cantera 3.0.
*/
virtual vector<double>::iterator begin();
vector<double>::iterator begin() override;

//! Returns an iterator for the end of the band storage data
/*!
Expand All @@ -183,7 +183,7 @@ class BandMatrix : public GeneralMatrix
* Iterator points to the beginning of the data, and it is not changeable.
* @deprecated Unused. To be removed after %Cantera 3.0.
*/
vector<double>::const_iterator begin() const;
vector<double>::const_iterator begin() const override;

//! Returns a const iterator for the end of the band storage data
/*!
Expand All @@ -192,7 +192,7 @@ class BandMatrix : public GeneralMatrix
*/
vector<double>::const_iterator end() const;

virtual void zero();
void zero() override;

//! Returns an estimate of the inverse of the condition number for the matrix
/*!
Expand All @@ -201,14 +201,14 @@ class BandMatrix : public GeneralMatrix
* @param a1norm Norm of the matrix
* @returns the inverse of the condition number
*/
virtual double rcond(double a1norm);
double rcond(double a1norm) override;

//! Returns the factor algorithm used. This method will always return 0
//! (LU) for band matrices.
virtual int factorAlgorithm() const;
int factorAlgorithm() const override;

//! Returns the one norm of the matrix
virtual double oneNorm() const;
double oneNorm() const override;

//! Return a pointer to the top of column j
/*!
Expand All @@ -232,7 +232,7 @@ class BandMatrix : public GeneralMatrix
* @param j Value of the column
* @returns a pointer to the top of the column
*/
virtual double* ptrColumn(size_t j);
double* ptrColumn(size_t j) override;

//! Return a vector of const pointers to the columns
/*!
Expand All @@ -241,7 +241,7 @@ class BandMatrix : public GeneralMatrix
*
* @returns a vector of pointers to the top of the columns of the matrices.
*/
virtual double* const* colPts();
double* const* colPts() override;

//! Check to see if we have any zero rows in the Jacobian
/*!
Expand All @@ -251,7 +251,7 @@ class BandMatrix : public GeneralMatrix
* @param valueSmall OUTPUT value of the largest coefficient in the smallest row
* @return index of the row that is most nearly zero
*/
virtual size_t checkRows(double& valueSmall) const;
size_t checkRows(double& valueSmall) const override;

//! Check to see if we have any zero columns in the Jacobian
/*!
Expand All @@ -261,7 +261,7 @@ class BandMatrix : public GeneralMatrix
* @param valueSmall OUTPUT value of the largest coefficient in the smallest column
* @return index of the column that is most nearly zero
*/
virtual size_t checkColumns(double& valueSmall) const;
size_t checkColumns(double& valueSmall) const override;

//! LAPACK "info" flag after last factor/solve operation
int info() const { return m_info; };
Expand Down
58 changes: 29 additions & 29 deletions include/cantera/numerics/CVodesIntegrator.h
Expand Up @@ -31,53 +31,53 @@ class CVodesIntegrator : public Integrator
* Jacobian function, Newton iteration.
*/
CVodesIntegrator();
virtual ~CVodesIntegrator();
virtual void setTolerances(double reltol, size_t n, double* abstol);
virtual void setTolerances(double reltol, double abstol);
virtual void setSensitivityTolerances(double reltol, double abstol);
virtual void initialize(double t0, FuncEval& func);
virtual void reinitialize(double t0, FuncEval& func);
virtual void integrate(double tout);
virtual double step(double tout);
virtual double& solution(size_t k);
virtual double* solution();
virtual double* derivative(double tout, int n);
virtual int lastOrder() const;
virtual int nEquations() const {
~CVodesIntegrator() override;
void setTolerances(double reltol, size_t n, double* abstol) override;
void setTolerances(double reltol, double abstol) override;
void setSensitivityTolerances(double reltol, double abstol) override;
void initialize(double t0, FuncEval& func) override;
void reinitialize(double t0, FuncEval& func) override;
void integrate(double tout) override;
double step(double tout) override;
double& solution(size_t k) override;
double* solution() override;
double* derivative(double tout, int n) override;
int lastOrder() const override;
int nEquations() const override{
return static_cast<int>(m_neq);
}
virtual int nEvals() const;
virtual void setMaxOrder(int n) {
int nEvals() const override;
void setMaxOrder(int n) override {
m_maxord = n;
}
virtual void setMethod(MethodType t);
virtual void setMaxStepSize(double hmax);
virtual void setMinStepSize(double hmin);
virtual void setMaxSteps(int nmax);
virtual int maxSteps();
virtual void setMaxErrTestFails(int n);
virtual AnyMap solverStats() const;
void setLinearSolverType(const string& linSolverType) {
void setMethod(MethodType t) override;
void setMaxStepSize(double hmax) override;
void setMinStepSize(double hmin) override;
void setMaxSteps(int nmax) override;
int maxSteps() override;
void setMaxErrTestFails(int n) override;
AnyMap solverStats() const override;
void setLinearSolverType(const string& linSolverType) override {
m_type = linSolverType;
}
virtual string linearSolverType() const {
string linearSolverType() const override {
return m_type;
}
virtual void setBandwidth(int N_Upper, int N_Lower) {
void setBandwidth(int N_Upper, int N_Lower) override {
m_mupper = N_Upper;
m_mlower = N_Lower;
}
virtual int nSensParams() {
int nSensParams() override {
return static_cast<int>(m_np);
}
virtual double sensitivity(size_t k, size_t p);
virtual void setProblemType(int probtype);
double sensitivity(size_t k, size_t p) override;
void setProblemType(int probtype) override;

//! Returns a string listing the weighted error estimates associated
//! with each solution component.
//! This information can be used to identify which variables are
//! responsible for integrator failures or unexpected small timesteps.
virtual string getErrorInfo(int N);
string getErrorInfo(int N);

//! Error message information provide by CVodes
string m_error_message;
Expand Down

0 comments on commit fc21853

Please sign in to comment.