From fc2185369d1db538c1afdd7f3bb2dbd21e16da4e Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Mon, 14 Aug 2023 16:38:08 -0400 Subject: [PATCH] Use override on various utility classes --- include/cantera/base/AnyMap.h | 2 +- include/cantera/base/Array.h | 2 +- .../cantera/base/ExtensionManagerFactory.h | 2 +- include/cantera/base/NoExitLogger.h | 4 +- include/cantera/base/ctexceptions.h | 14 +- include/cantera/cython/funcWrapper.h | 6 +- include/cantera/cython/utils_utils.h | 8 +- .../extensions/PythonExtensionManager.h | 2 +- include/cantera/kinetics/KineticsFactory.h | 4 +- .../cantera/kinetics/ReactionRateFactory.h | 2 +- .../cantera/numerics/AdaptivePreconditioner.h | 4 +- include/cantera/numerics/BandMatrix.h | 34 +-- include/cantera/numerics/CVodesIntegrator.h | 58 ++-- include/cantera/numerics/DenseMatrix.h | 2 +- include/cantera/numerics/Func1.h | 254 +++++++++--------- include/cantera/numerics/Func1Factory.h | 6 +- .../cantera/numerics/PreconditionerFactory.h | 2 +- include/cantera/numerics/ResidJacEval.h | 9 +- include/cantera/oneD/DomainFactory.h | 2 +- include/cantera/thermo/PDSSFactory.h | 4 +- include/cantera/thermo/SurfPhase.h | 2 +- include/cantera/thermo/ThermoFactory.h | 4 +- include/cantera/transport/TransportFactory.h | 7 +- include/cantera/zeroD/FlowDeviceFactory.h | 4 +- include/cantera/zeroD/ReactorFactory.h | 4 +- include/cantera/zeroD/WallFactory.h | 4 +- src/matlab/mllogger.h | 8 +- test_problems/shared/fileLog.h | 4 +- 28 files changed, 227 insertions(+), 231 deletions(-) diff --git a/include/cantera/base/AnyMap.h b/include/cantera/base/AnyMap.h index 2718ac1a1a..81ac0071a7 100644 --- a/include/cantera/base/AnyMap.h +++ b/include/cantera/base/AnyMap.h @@ -767,7 +767,7 @@ class InputFileError : public CanteraError { } - virtual string getClass() const { + string getClass() const override { return "InputFileError"; } protected: diff --git a/include/cantera/base/Array.h b/include/cantera/base/Array.h index 30ca425b01..2964315e2b 100644 --- a/include/cantera/base/Array.h +++ b/include/cantera/base/Array.h @@ -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 /*! diff --git a/include/cantera/base/ExtensionManagerFactory.h b/include/cantera/base/ExtensionManagerFactory.h index 30384381e4..59cb97d9ba 100644 --- a/include/cantera/base/ExtensionManagerFactory.h +++ b/include/cantera/base/ExtensionManagerFactory.h @@ -24,7 +24,7 @@ class ExtensionManagerFactory : public Factory } //! 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. diff --git a/include/cantera/base/NoExitLogger.h b/include/cantera/base/NoExitLogger.h index 9a6051227c..d6d72a743b 100644 --- a/include/cantera/base/NoExitLogger.h +++ b/include/cantera/base/NoExitLogger.h @@ -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; } }; diff --git a/include/cantera/base/ctexceptions.h b/include/cantera/base/ctexceptions.h index e13c1b4eab..a9d78fd733 100644 --- a/include/cantera/base/ctexceptions.h +++ b/include/cantera/base/ctexceptions.h @@ -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; @@ -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"; } @@ -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"; } @@ -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"; } }; diff --git a/include/cantera/cython/funcWrapper.h b/include/cantera/cython/funcWrapper.h index 77d090c96d..670691b187 100644 --- a/include/cantera/cython/funcWrapper.h +++ b/include/cantera/cython/funcWrapper.h @@ -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__"); @@ -130,7 +130,7 @@ class CallbackError : public Cantera::CanteraError return msg; } - virtual std::string getClass() const { + std::string getClass() const override { return "Exception"; } @@ -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]) { diff --git a/include/cantera/cython/utils_utils.h b/include/cantera/cython/utils_utils.h index 70d3c01cf4..218860e222 100644 --- a/include/cantera/cython/utils_utils.h +++ b/include/cantera/cython/utils_utils.h @@ -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) { @@ -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 { @@ -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()); } }; diff --git a/include/cantera/extensions/PythonExtensionManager.h b/include/cantera/extensions/PythonExtensionManager.h index 1ac61baa10..2e733d57c4 100644 --- a/include/cantera/extensions/PythonExtensionManager.h +++ b/include/cantera/extensions/PythonExtensionManager.h @@ -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; diff --git a/include/cantera/kinetics/KineticsFactory.h b/include/cantera/kinetics/KineticsFactory.h index a0fbd8c138..0b206b68eb 100644 --- a/include/cantera/kinetics/KineticsFactory.h +++ b/include/cantera/kinetics/KineticsFactory.h @@ -23,12 +23,12 @@ class KineticsFactory : public Factory 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; diff --git a/include/cantera/kinetics/ReactionRateFactory.h b/include/cantera/kinetics/ReactionRateFactory.h index bf21617bde..ba50eeddcb 100644 --- a/include/cantera/kinetics/ReactionRateFactory.h +++ b/include/cantera/kinetics/ReactionRateFactory.h @@ -64,7 +64,7 @@ class ReactionRateFactory */ static ReactionRateFactory* factory(); - virtual void deleteFactory(); + void deleteFactory() override; private: //! Pointer to the single instance of the factory diff --git a/include/cantera/numerics/AdaptivePreconditioner.h b/include/cantera/numerics/AdaptivePreconditioner.h index a4f3a440d3..84891c4050 100644 --- a/include/cantera/numerics/AdaptivePreconditioner.h +++ b/include/cantera/numerics/AdaptivePreconditioner.h @@ -41,9 +41,9 @@ class AdaptivePreconditioner : public PreconditionerBase void setValue(size_t row, size_t col, double value) override; - virtual void stateAdjustment(vector& state) override; + void stateAdjustment(vector& state) override; - virtual void updatePreconditioner() override; + void updatePreconditioner() override; //! Prune preconditioner elements void prunePreconditioner(); diff --git a/include/cantera/numerics/BandMatrix.h b/include/cantera/numerics/BandMatrix.h index 0dc14fb2aa..d696246c93 100644 --- a/include/cantera/numerics/BandMatrix.h +++ b/include/cantera/numerics/BandMatrix.h @@ -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). /*! @@ -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; @@ -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. /*! @@ -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 /*! @@ -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::iterator begin(); + vector::iterator begin() override; //! Returns an iterator for the end of the band storage data /*! @@ -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::const_iterator begin() const; + vector::const_iterator begin() const override; //! Returns a const iterator for the end of the band storage data /*! @@ -192,7 +192,7 @@ class BandMatrix : public GeneralMatrix */ vector::const_iterator end() const; - virtual void zero(); + void zero() override; //! Returns an estimate of the inverse of the condition number for the matrix /*! @@ -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 /*! @@ -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 /*! @@ -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 /*! @@ -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 /*! @@ -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; }; diff --git a/include/cantera/numerics/CVodesIntegrator.h b/include/cantera/numerics/CVodesIntegrator.h index 7d7a2f854f..e586743426 100644 --- a/include/cantera/numerics/CVodesIntegrator.h +++ b/include/cantera/numerics/CVodesIntegrator.h @@ -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(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(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; diff --git a/include/cantera/numerics/DenseMatrix.h b/include/cantera/numerics/DenseMatrix.h index ca10ddf854..fb90a72ea3 100644 --- a/include/cantera/numerics/DenseMatrix.h +++ b/include/cantera/numerics/DenseMatrix.h @@ -78,7 +78,7 @@ class DenseMatrix : public Array2D * @param m New number of columns * @param v Default fill value. defaults to zero. */ - void resize(size_t n, size_t m, double v = 0.0); + void resize(size_t n, size_t m, double v=0.0) override; virtual double* const* colPts(); diff --git a/include/cantera/numerics/Func1.h b/include/cantera/numerics/Func1.h index 14e53d8c41..4b1f27fbad 100644 --- a/include/cantera/numerics/Func1.h +++ b/include/cantera/numerics/Func1.h @@ -293,23 +293,23 @@ class Sin1 : public Func1 return *this; } - virtual string write(const string& arg) const; + string write(const string& arg) const override; - virtual int ID() const { + int ID() const override { return SinFuncType; } - virtual string type() const { + string type() const override { return "sin"; } - virtual double eval(double t) const { + double eval(double t) const override{ return sin(m_c*t); } - virtual Func1& duplicate() const; - virtual Func1& derivative() const; - virtual shared_ptr derivative3() const; + Func1& duplicate() const override; + Func1& derivative() const override; + shared_ptr derivative3() const override; }; @@ -342,20 +342,20 @@ class Cos1 : public Func1 return *this; } - virtual Func1& duplicate() const; - virtual string write(const string& arg) const; - virtual int ID() const { + Func1& duplicate() const override; + string write(const string& arg) const override; + int ID() const override { return CosFuncType; } - virtual string type() const { + string type() const override { return "cos"; } - virtual double eval(double t) const { + double eval(double t) const override { return cos(m_c * t); } - virtual Func1& derivative() const; - virtual shared_ptr derivative3() const; + Func1& derivative() const override; + shared_ptr derivative3() const override; }; @@ -385,21 +385,21 @@ class Exp1 : public Func1 Func1::operator=(right); return *this; } - virtual string write(const string& arg) const; - virtual int ID() const { + string write(const string& arg) const override; + int ID() const override { return ExpFuncType; } - virtual string type() const { + string type() const override { return "exp"; } - virtual double eval(double t) const { + double eval(double t) const override { return exp(m_c*t); } - virtual Func1& duplicate() const; - virtual Func1& derivative() const; - virtual shared_ptr derivative3() const; + Func1& duplicate() const override; + Func1& derivative() const override; + shared_ptr derivative3() const override; }; @@ -420,17 +420,17 @@ class Log1 : public Func1 //! Constructor uses single parameter (factor) Log1(const vector& params); - virtual string type() const { + string type() const override { return "log"; } - virtual double eval(double t) const { + double eval(double t) const override { return log(m_c * t); } - virtual shared_ptr derivative3() const; + shared_ptr derivative3() const override; - virtual string write(const string& arg) const; + string write(const string& arg) const override; }; //! Implements the @c pow() (power) function. @@ -459,20 +459,20 @@ class Pow1 : public Func1 Func1::operator=(right); return *this; } - virtual string write(const string& arg) const; - virtual int ID() const { + string write(const string& arg) const override; + int ID() const override { return PowFuncType; } - virtual string type() const { + string type() const override { return "pow"; } - virtual double eval(double t) const { + double eval(double t) const override { return pow(t, m_c); } - virtual Func1& duplicate() const; - virtual Func1& derivative() const; - virtual shared_ptr derivative3() const; + Func1& duplicate() const override; + Func1& derivative() const override; + shared_ptr derivative3() const override; }; //! Implements a tabulated function. @@ -509,21 +509,21 @@ class Tabulated1 : public Func1 //! @since New in %Cantera 3.0 void setMethod(const string& method); - virtual string write(const string& arg) const; - virtual int ID() const { + string write(const string& arg) const override; + int ID() const override { return TabulatedFuncType; } - virtual string type() const { + string type() const override { if (m_isLinear) { return "tabulated-linear"; } return "tabulated-previous"; } - virtual double eval(double t) const; - virtual Func1& duplicate() const; - virtual Func1& derivative() const; - virtual shared_ptr derivative3() const; + double eval(double t) const override; + Func1& duplicate() const override; + Func1& derivative() const override; + shared_ptr derivative3() const override; private: vector m_tvec; //!< Vector of time values vector m_fvec; //!< Vector of function values @@ -559,20 +559,20 @@ class Const1 : public Func1 return *this; } - virtual string write(const string& arg) const; - virtual int ID() const { + string write(const string& arg) const override; + int ID() const override { return ConstFuncType; } - virtual string type() const { + string type() const override { return "constant"; } - virtual double eval(double t) const { + double eval(double t) const override { return m_c; } - virtual Func1& duplicate() const; - virtual Func1& derivative() const; - virtual shared_ptr derivative3() const { + Func1& duplicate() const override; + Func1& derivative() const override; + shared_ptr derivative3() const override { return make_shared(0.0); } }; @@ -597,7 +597,7 @@ class Sum1 : public Func1 Sum1(shared_ptr f1, shared_ptr f2) : Func1(f1, f2) {} - virtual ~Sum1() { + ~Sum1() override { if (!m_f1_shared) { delete m_f1; } @@ -624,29 +624,29 @@ class Sum1 : public Func1 return *this; } - virtual int ID() const { + int ID() const override { return SumFuncType; } - virtual string type() const { + string type() const override { return "sum"; } - virtual double eval(double t) const { + double eval(double t) const override { return m_f1->eval(t) + m_f2->eval(t); } - virtual Func1& duplicate() const; - virtual Func1& derivative() const; + Func1& duplicate() const override; + Func1& derivative() const override; - virtual shared_ptr derivative3() const { + shared_ptr derivative3() const override { return newSumFunction(m_f1_shared->derivative3(), m_f2_shared->derivative3()); } - virtual int order() const { + int order() const override { return 0; } - virtual string write(const string& arg) const; + string write(const string& arg) const override; }; /** @@ -668,7 +668,7 @@ class Diff1 : public Func1 Diff1(shared_ptr f1, shared_ptr f2) : Func1(f1, f2) {} - virtual ~Diff1() { + ~Diff1() override { if (!m_f1_shared) { delete m_f1; } @@ -695,30 +695,30 @@ class Diff1 : public Func1 return *this; } - virtual int ID() const { + int ID() const override { return DiffFuncType; } - virtual string type() const { + string type() const override { return "diff"; } - virtual double eval(double t) const { + double eval(double t) const override { return m_f1->eval(t) - m_f2->eval(t); } - virtual Func1& duplicate() const; - virtual Func1& derivative() const; + Func1& duplicate() const override; + Func1& derivative() const override; - virtual shared_ptr derivative3() const { + shared_ptr derivative3() const override { return newDiffFunction(m_f1_shared->derivative3(), m_f2_shared->derivative3()); } - virtual int order() const { + int order() const override { return 0; } - virtual string write(const string& arg) const; + string write(const string& arg) const override; }; @@ -741,7 +741,7 @@ class Product1 : public Func1 Product1(shared_ptr f1, shared_ptr f2) : Func1(f1, f2) {} - virtual ~Product1() { + ~Product1() override { if (!m_f1_shared) { delete m_f1; } @@ -768,26 +768,26 @@ class Product1 : public Func1 return *this; } - virtual int ID() const { + int ID() const override { return ProdFuncType; } - virtual string type() const { + string type() const override { return "product"; } - virtual string write(const string& arg) const; + string write(const string& arg) const override; - virtual double eval(double t) const { + double eval(double t) const override { return m_f1->eval(t) * m_f2->eval(t); } - virtual Func1& duplicate() const; - virtual Func1& derivative() const; + Func1& duplicate() const override; + Func1& derivative() const override; - virtual shared_ptr derivative3() const; + shared_ptr derivative3() const override; - virtual int order() const { + int order() const override { return 1; } }; @@ -810,7 +810,7 @@ class TimesConstant1 : public Func1 TimesConstant1(shared_ptr f1, double a) : Func1(f1, a) {} - virtual ~TimesConstant1() { + ~TimesConstant1() override { if (!m_f1_shared) { delete m_f1; } @@ -831,14 +831,14 @@ class TimesConstant1 : public Func1 m_parent = 0; return *this; } - virtual int ID() const { + int ID() const override { return TimesConstantFuncType; } - virtual string type() const { + string type() const override { return "times-constant"; } - virtual double isProportional(TimesConstant1& other) { + double isProportional(TimesConstant1& other) override { if (func1().isIdentical(other.func1())) { return (other.c()/c()); } else { @@ -846,7 +846,7 @@ class TimesConstant1 : public Func1 } } - virtual double isProportional(Func1& other) { + double isProportional(Func1& other) override { if (func1().isIdentical(other)) { return 1.0/c(); } else { @@ -854,20 +854,20 @@ class TimesConstant1 : public Func1 } } - virtual double eval(double t) const { + double eval(double t) const override { return m_f1->eval(t) * m_c; } - virtual Func1& duplicate() const; - virtual Func1& derivative() const; + Func1& duplicate() const override; + Func1& derivative() const override; - virtual shared_ptr derivative3() const { + shared_ptr derivative3() const override { return newTimesConstFunction(m_f1_shared->derivative3(), m_c); } - virtual string write(const string& arg) const; + string write(const string& arg) const override; - virtual int order() const { + int order() const override { return 0; } }; @@ -890,7 +890,7 @@ class PlusConstant1 : public Func1 PlusConstant1(shared_ptr f1, double a) : Func1(f1, a) {} - virtual ~PlusConstant1() { + ~PlusConstant1() override { if (!m_f1_shared) { delete m_f1; } @@ -912,27 +912,27 @@ class PlusConstant1 : public Func1 return *this; } - virtual int ID() const { + int ID() const override { return PlusConstantFuncType; } - virtual string type() const { + string type() const override { return "plus-constant"; } - virtual double eval(double t) const { + double eval(double t) const override { return m_f1->eval(t) + m_c; } - virtual Func1& duplicate() const; - virtual Func1& derivative() const; + Func1& duplicate() const override; + Func1& derivative() const override; - virtual shared_ptr derivative3() const { + shared_ptr derivative3() const override { return m_f1_shared->derivative3(); } - virtual string write(const string& arg) const; + string write(const string& arg) const override; - virtual int order() const { + int order() const override { return 0; } }; @@ -957,7 +957,7 @@ class Ratio1 : public Func1 Ratio1(shared_ptr f1, shared_ptr f2) : Func1(f1, f2) {} - virtual ~Ratio1() { + ~Ratio1() override { if (!m_f1_shared) { delete m_f1; } @@ -984,25 +984,25 @@ class Ratio1 : public Func1 return *this; } - virtual int ID() const { + int ID() const override { return RatioFuncType; } - virtual string type() const { + string type() const override { return "ratio"; } - virtual double eval(double t) const { + double eval(double t) const override { return m_f1->eval(t) / m_f2->eval(t); } - virtual Func1& duplicate() const; - virtual Func1& derivative() const; + Func1& duplicate() const override; + Func1& derivative() const override; - virtual shared_ptr derivative3() const; + shared_ptr derivative3() const override; - virtual string write(const string& arg) const; + string write(const string& arg) const override; - virtual int order() const { + int order() const override { return 1; } }; @@ -1026,7 +1026,7 @@ class Composite1 : public Func1 Composite1(shared_ptr f1, shared_ptr f2) : Func1(f1, f2) {} - virtual ~Composite1() { + ~Composite1() override { if (!m_f1_shared) { delete m_f1; } @@ -1053,25 +1053,25 @@ class Composite1 : public Func1 return *this; } - virtual int ID() const { + int ID() const override { return CompositeFuncType; } - virtual string type() const { + string type() const override { return "composite"; } - virtual double eval(double t) const { + double eval(double t) const override { return m_f1->eval(m_f2->eval(t)); } - virtual Func1& duplicate() const; - virtual Func1& derivative() const; + Func1& duplicate() const override; + Func1& derivative() const override; - virtual shared_ptr derivative3() const; + shared_ptr derivative3() const override; - virtual string write(const string& arg) const; + string write(const string& arg) const override; - virtual int order() const { + int order() const override { return 2; } }; @@ -1122,11 +1122,11 @@ class Gaussian1 : public Func1 return *this; } - virtual string type() const { + string type() const override { return "Gaussian"; } - virtual double eval(double t) const { + double eval(double t) const override { double x = (t - m_t0)/m_tau; return m_A * std::exp(-x*x); } @@ -1154,7 +1154,7 @@ class Gaussian : public Gaussian1 Gaussian(const Gaussian& b); - virtual Func1& duplicate() const; + Func1& duplicate() const override; }; @@ -1193,13 +1193,13 @@ class Poly1 : public Func1 return *this; } - virtual string type() const { + string type() const override { return "polynomial"; } - virtual Func1& duplicate() const; + Func1& duplicate() const override; - virtual double eval(double t) const { + double eval(double t) const override { double r = m_cpoly[m_cpoly.size()-1]; for (size_t n = 1; n < m_cpoly.size(); n++) { r *= t; @@ -1256,13 +1256,13 @@ class Fourier1 : public Func1 return *this; } - virtual string type() const { + string type() const override { return "Fourier"; } - virtual Func1& duplicate() const; + Func1& duplicate() const override; - virtual double eval(double t) const { + double eval(double t) const override { size_t n, nn; double sum = m_a0_2; for (n = 0; n < m_ccos.size(); n++) { @@ -1323,13 +1323,13 @@ class Arrhenius1 : public Func1 return *this; } - virtual string type() const { + string type() const override { return "Arrhenius"; } - virtual Func1& duplicate() const; + Func1& duplicate() const override; - virtual double eval(double t) const { + double eval(double t) const override { double sum = 0.0; for (size_t n = 0; n < m_A.size(); n++) { sum += m_A[n]*std::pow(t,m_b[n])*std::exp(-m_E[n]/t); @@ -1371,19 +1371,19 @@ class Periodic1 : public Func1 return *this; } - virtual string type() const { + string type() const override { return "periodic"; } - virtual Func1& duplicate() const; + Func1& duplicate() const override; - virtual ~Periodic1() { + ~Periodic1() override { if (!m_f1_shared) { delete m_f1; } } - virtual double eval(double t) const { + double eval(double t) const override { int np = int(t/m_c); double time = t - np*m_c; return m_f1->eval(time); diff --git a/include/cantera/numerics/Func1Factory.h b/include/cantera/numerics/Func1Factory.h index 0b54167e88..675cfecc3d 100644 --- a/include/cantera/numerics/Func1Factory.h +++ b/include/cantera/numerics/Func1Factory.h @@ -30,7 +30,7 @@ class Func1Factory : public Factory&> */ static Func1Factory* factory(); - virtual void deleteFactory(); + void deleteFactory() override; private: //! Pointer to the single instance of the factory @@ -64,7 +64,7 @@ class Math1FactoryA */ static Math1FactoryA* factory(); - virtual void deleteFactory(); + void deleteFactory() override; private: //! Pointer to the single instance of the factory @@ -97,7 +97,7 @@ class Math1FactoryB : public Factory, double> */ static Math1FactoryB* factory(); - virtual void deleteFactory(); + void deleteFactory() override; private: //! Pointer to the single instance of the factory diff --git a/include/cantera/numerics/PreconditionerFactory.h b/include/cantera/numerics/PreconditionerFactory.h index ae84223805..d8c1b2ac61 100644 --- a/include/cantera/numerics/PreconditionerFactory.h +++ b/include/cantera/numerics/PreconditionerFactory.h @@ -20,7 +20,7 @@ class PreconditionerFactory : public Factory static PreconditionerFactory* factory(); //! Delete preconditioner factory - virtual void deleteFactory(); + void deleteFactory() override; private: static PreconditionerFactory* s_factory; diff --git a/include/cantera/numerics/ResidJacEval.h b/include/cantera/numerics/ResidJacEval.h index 4bcd0dc969..bd39691b29 100644 --- a/include/cantera/numerics/ResidJacEval.h +++ b/include/cantera/numerics/ResidJacEval.h @@ -69,7 +69,7 @@ class ResidJacEval : public ResidEval ResidJacEval(double atol = 1.0e-13); //! Return the number of equations in the equation system - virtual int nEquations() const; + int nEquations() const override; //! Evaluate the residual function /*! @@ -96,11 +96,10 @@ class ResidJacEval : public ResidEval const int id_x = -1, const double delta_x = 0.0); - virtual int eval(const double t, const double* const y, - const double* const ydot, - double* const r); + int eval(const double t, const double* const y, const double* const ydot, + double* const r) override; - virtual int getInitialConditions(const double t0, double* const y, double* const ydot); + int getInitialConditions(const double t0, double* const y, double* const ydot) override; //! Filter the solution predictions /*! diff --git a/include/cantera/oneD/DomainFactory.h b/include/cantera/oneD/DomainFactory.h index 5cb6690a3f..747c2f7a71 100644 --- a/include/cantera/oneD/DomainFactory.h +++ b/include/cantera/oneD/DomainFactory.h @@ -29,7 +29,7 @@ class DomainFactory : public Factory, const strin */ static DomainFactory* factory(); - virtual void deleteFactory(); + void deleteFactory() override; private: //! Pointer to the single instance of the factory diff --git a/include/cantera/thermo/PDSSFactory.h b/include/cantera/thermo/PDSSFactory.h index 324b5a1505..b533fef33f 100644 --- a/include/cantera/thermo/PDSSFactory.h +++ b/include/cantera/thermo/PDSSFactory.h @@ -20,7 +20,7 @@ class PDSSFactory : public Factory static PDSSFactory* factory(); //! delete the static instance of this factory - virtual void deleteFactory(); + void deleteFactory() override; //! Create a new thermodynamic property manager. /*! @@ -29,7 +29,7 @@ class PDSSFactory : public Factory * Returns NULL if something went wrong. Throws an exception if the string * wasn't matched. */ - virtual PDSS* newPDSS(const string& model); + PDSS* newPDSS(const string& model); private: //! static member of a single instance diff --git a/include/cantera/thermo/SurfPhase.h b/include/cantera/thermo/SurfPhase.h index 46ee6444d3..2926d05ad6 100644 --- a/include/cantera/thermo/SurfPhase.h +++ b/include/cantera/thermo/SurfPhase.h @@ -205,7 +205,7 @@ class SurfPhase : public ThermoPhase bool addSpecies(shared_ptr spec) override; //! Since interface phases have no volume, this returns 0.0. - virtual double molarVolume() const override { + double molarVolume() const override { return 0.0; } diff --git a/include/cantera/thermo/ThermoFactory.h b/include/cantera/thermo/ThermoFactory.h index 2f1ff2bcf9..860091f487 100644 --- a/include/cantera/thermo/ThermoFactory.h +++ b/include/cantera/thermo/ThermoFactory.h @@ -34,7 +34,7 @@ class ThermoFactory : public Factory static ThermoFactory* factory(); //! delete the static instance of this factory - virtual void deleteFactory(); + void deleteFactory() override; //! Create a new thermodynamic property manager. /*! @@ -43,7 +43,7 @@ class ThermoFactory : public Factory * CanteraError if the named model isn't registered with ThermoFactory. * @deprecated To be removed after %Cantera 3.0; superseded by newThermo() */ - virtual ThermoPhase* newThermoPhase(const string& model); + ThermoPhase* newThermoPhase(const string& model); private: //! static member of a single instance diff --git a/include/cantera/transport/TransportFactory.h b/include/cantera/transport/TransportFactory.h index f8d8bf7563..01eb5535a9 100644 --- a/include/cantera/transport/TransportFactory.h +++ b/include/cantera/transport/TransportFactory.h @@ -45,7 +45,7 @@ class TransportFactory : public Factory static TransportFactory* factory(); //! Deletes the statically allocated factory instance. - virtual void deleteFactory(); + void deleteFactory() override; //! Build a new transport manager using a transport manager //! that may not be the same as in the phase description @@ -55,8 +55,7 @@ class TransportFactory : public Factory * @param thermo ThermoPhase object * @param log_level log level */ - virtual Transport* newTransport(const string& model, ThermoPhase* thermo, - int log_level=0); + Transport* newTransport(const string& model, ThermoPhase* thermo, int log_level=0); //! Build a new transport manager using the default transport manager //! in the phase description and return a base class pointer to it @@ -64,7 +63,7 @@ class TransportFactory : public Factory * @param thermo ThermoPhase object * @param log_level log level */ - virtual Transport* newTransport(ThermoPhase* thermo, int log_level=0); + Transport* newTransport(ThermoPhase* thermo, int log_level=0); private: //! Static instance of the factor -> This is the only instance of this diff --git a/include/cantera/zeroD/FlowDeviceFactory.h b/include/cantera/zeroD/FlowDeviceFactory.h index 8e9aa22764..1d7a7b3671 100644 --- a/include/cantera/zeroD/FlowDeviceFactory.h +++ b/include/cantera/zeroD/FlowDeviceFactory.h @@ -24,14 +24,14 @@ class FlowDeviceFactory : public Factory public: static FlowDeviceFactory* factory(); - virtual void deleteFactory(); + void deleteFactory() override; //! Create a new flow device by type name. /*! * @param flowDeviceType the type to be created. * @deprecated To be removed after %Cantera 3.0; replaceable by newFlowDevice3. */ - virtual FlowDevice* newFlowDevice(const string& flowDeviceType); + FlowDevice* newFlowDevice(const string& flowDeviceType); private: static FlowDeviceFactory* s_factory; diff --git a/include/cantera/zeroD/ReactorFactory.h b/include/cantera/zeroD/ReactorFactory.h index 78eb4e71ee..6ecafe6703 100644 --- a/include/cantera/zeroD/ReactorFactory.h +++ b/include/cantera/zeroD/ReactorFactory.h @@ -24,14 +24,14 @@ class ReactorFactory : public Factory public: static ReactorFactory* factory(); - virtual void deleteFactory(); + void deleteFactory() override; //! Create a new reactor by type name. /*! * @param reactorType the type to be created. * @deprecated To be removed after %Cantera 3.0; replaceable by newReactor3. */ - virtual ReactorBase* newReactor(const string& reactorType); + ReactorBase* newReactor(const string& reactorType); private: static ReactorFactory* s_factory; diff --git a/include/cantera/zeroD/WallFactory.h b/include/cantera/zeroD/WallFactory.h index cf3e65faa9..74aec6d4ba 100644 --- a/include/cantera/zeroD/WallFactory.h +++ b/include/cantera/zeroD/WallFactory.h @@ -24,14 +24,14 @@ class WallFactory : public Factory public: static WallFactory* factory(); - virtual void deleteFactory(); + void deleteFactory() override; //! Create a new wall by type name. /*! * @param wallType the type to be created. * @deprecated To be removed after %Cantera 3.0; replaceable by newWall3. */ - virtual WallBase* newWall(const string& wallType); + WallBase* newWall(const string& wallType); private: static WallFactory* s_factory; diff --git a/src/matlab/mllogger.h b/src/matlab/mllogger.h index cc07686c19..4191f59f8f 100644 --- a/src/matlab/mllogger.h +++ b/src/matlab/mllogger.h @@ -18,17 +18,17 @@ class ML_Logger : public Logger { public: ML_Logger() {} - virtual ~ML_Logger() {} + ~ML_Logger() override {} - virtual void write(const string& s) { + void write(const string& s) override { mexPrintf("%s", s.c_str()); } - virtual void writeendl() { + void writeendl() override { mexPrintf("\n"); } - virtual void error(const string& msg) { + void error(const string& msg) override { mexErrMsgTxt(msg.c_str()); } }; diff --git a/test_problems/shared/fileLog.h b/test_problems/shared/fileLog.h index 2596acebc0..40c90eaa83 100644 --- a/test_problems/shared/fileLog.h +++ b/test_problems/shared/fileLog.h @@ -10,11 +10,11 @@ class fileLog: public Cantera::Logger m_fs.open(fName, std::ios::out); } - virtual void write(const std::string& msg) { + void write(const std::string& msg) override { m_fs << msg; } - virtual void writeendl() { + void writeendl() override { m_fs << std::endl; }