From 0a6442bde33162195cfc32f99ff6a0d0e53ccc14 Mon Sep 17 00:00:00 2001 From: Ingmar Schoegl Date: Fri, 29 Jul 2022 16:52:50 -0500 Subject: [PATCH 1/4] [zeroD] Fix compilation warnings in MoleReactor --- include/cantera/zeroD/IdealGasConstPressureMoleReactor.h | 2 +- include/cantera/zeroD/MoleReactor.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/cantera/zeroD/IdealGasConstPressureMoleReactor.h b/include/cantera/zeroD/IdealGasConstPressureMoleReactor.h index 752d6e3648..675e923a23 100644 --- a/include/cantera/zeroD/IdealGasConstPressureMoleReactor.h +++ b/include/cantera/zeroD/IdealGasConstPressureMoleReactor.h @@ -43,7 +43,7 @@ class IdealGasConstPressureMoleReactor : public MoleReactor protected: vector_fp m_hk; //!< Species molar enthalpies - const int m_sidx = 1; + const size_t m_sidx = 1; }; } diff --git a/include/cantera/zeroD/MoleReactor.h b/include/cantera/zeroD/MoleReactor.h index 4cec2a5c73..e76e489f8c 100644 --- a/include/cantera/zeroD/MoleReactor.h +++ b/include/cantera/zeroD/MoleReactor.h @@ -47,7 +47,7 @@ class MoleReactor : public Reactor virtual void getSurfaceInitialConditions(double* y); //! const value for the species start index - const int m_sidx = 2; + const size_t m_sidx = 2; }; } From f96f7c47d5ca72b30c035d4866fc72682c98cc3f Mon Sep 17 00:00:00 2001 From: Ingmar Schoegl Date: Fri, 29 Jul 2022 09:12:58 -0500 Subject: [PATCH 2/4] [Thermo] Fix compilation warnings in Elements.cpp --- src/thermo/Elements.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/thermo/Elements.cpp b/src/thermo/Elements.cpp index 9677a64967..ea2bec760c 100644 --- a/src/thermo/Elements.cpp +++ b/src/thermo/Elements.cpp @@ -207,7 +207,7 @@ static vector isotopeWeightTable { // This is implemented as a separate function from elementSymbols() because this pattern // allows elementSymbols() to return a const reference to the data. vector elementVectorsFromSymbols() { - vector values; + vector values; for (const auto& atom : atomicWeightTable) { values.push_back(atom.symbol); } @@ -279,7 +279,7 @@ double getElementWeight(const std::string& ename) double getElementWeight(int atomicNumber) { - size_t num = numElementsDefined(); + int num = numElementsDefined(); if (atomicNumber > num || atomicNumber < 1) { throw IndexError("getElementWeight", "atomicWeightTable", atomicNumber, num); } @@ -309,10 +309,9 @@ string getElementSymbol(const std::string& ename) string getElementSymbol(int atomicNumber) { - size_t num = numElementsDefined(); + int num = numElementsDefined(); if (atomicNumber > num || atomicNumber < 1) { - throw IndexError("getElementSymbol", "atomicWeightTable", atomicNumber, - num); + throw IndexError("getElementSymbol", "atomicWeightTable", atomicNumber, num); } return atomicWeightTable[atomicNumber - 1].symbol; } @@ -335,10 +334,9 @@ string getElementName(const std::string& ename) string getElementName(int atomicNumber) { - size_t num = numElementsDefined(); + int num = numElementsDefined(); if (atomicNumber > num || atomicNumber < 1) { - throw IndexError("getElementName", "atomicWeightTable", atomicNumber, - num); + throw IndexError("getElementName", "atomicWeightTable", atomicNumber, num); } return atomicWeightTable[atomicNumber - 1].fullName; } @@ -349,14 +347,14 @@ int getAtomicNumber(const std::string& ename) size_t numIsotopes = numIsotopesDefined(); string symbol = trimCopy(ename); string name = toLowerCopy(symbol); - for (int i = 0; i < numElements; i++) { + for (size_t i = 0; i < numElements; i++) { if (symbol == atomicWeightTable[i].symbol) { - return i+1; + return i + 1; } else if (name == atomicWeightTable[i].fullName) { - return i+1; + return i + 1; } } - for (int i = 0; i < numIsotopes; i++) { + for (size_t i = 0; i < numIsotopes; i++) { if (symbol == isotopeWeightTable[i].symbol) { return isotopeWeightTable[i].atomicNumber; } else if (name == isotopeWeightTable[i].fullName) { From 67cdb97ac11662339db8181701c9d470233d10be Mon Sep 17 00:00:00 2001 From: Ingmar Schoegl Date: Sun, 31 Jul 2022 06:54:45 -0500 Subject: [PATCH 3/4] [Cython] Suppress deprecated NumPy API warning --- SConstruct | 4 ++++ interfaces/cython/SConscript | 3 +++ 2 files changed, 7 insertions(+) diff --git a/SConstruct b/SConstruct index 2758b2f412..1d91683108 100644 --- a/SConstruct +++ b/SConstruct @@ -1604,6 +1604,10 @@ if env['python_package'] != 'none': f"Cython is an incompatible version: Found {cython_version} but " f"{cython_min_version} or newer is required.") warn_no_full_package = True + elif cython_version < parse_version("3.0.0"): + logger.info( + f"Using Cython version {cython_version} (uses legacy NumPy API)") + env["numpy_1_7_API"] = True else: logger.info(f"Using Cython version {cython_version}") diff --git a/interfaces/cython/SConscript b/interfaces/cython/SConscript index 245dcc9ea4..f5758c6129 100644 --- a/interfaces/cython/SConscript +++ b/interfaces/cython/SConscript @@ -78,6 +78,9 @@ elif localenv['OS'] == 'Cygwin': # extract 'pythonX.Y' from 'libpythonX.Y.dll.a' localenv.Append(LIBS=pylib[3:-6]) +if "numpy_1_7_API" in localenv: + localenv.Append(CPPDEFINES="NPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION") + localenv["module_ext"] = module_ext setup_cfg = localenv.SubstFile("setup.cfg", "setup.cfg.in") readme = localenv.Command("README.rst", "#README.rst", Copy("$TARGET", "$SOURCE")) From 8ed4a6f7e752e2617a8061dd77ae52f9ebf64b16 Mon Sep 17 00:00:00 2001 From: Ingmar Schoegl Date: Sun, 31 Jul 2022 07:13:12 -0500 Subject: [PATCH 4/4] Fix LLVM/Clang warning --- include/cantera/numerics/PreconditionerBase.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/cantera/numerics/PreconditionerBase.h b/include/cantera/numerics/PreconditionerBase.h index 6f433a120a..a1880c723b 100644 --- a/include/cantera/numerics/PreconditionerBase.h +++ b/include/cantera/numerics/PreconditionerBase.h @@ -32,6 +32,8 @@ class PreconditionerBase public: PreconditionerBase() {} + virtual ~PreconditionerBase() {} + //! Set a value at the specified row and column of the jacobian triplet vector //! @param row row in the jacobian matrix //! @param col column in the jacobian matrix