From 571eaeda248fbc320d137bf01077c150e0b53ec5 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Thu, 16 Jul 2015 12:38:34 -0400 Subject: [PATCH] [Samples] Fix compilation errors and warnings in the C++ examples --- samples/cxx/bvp/BoundaryValueProblem.h | 12 +++++++----- samples/cxx/combustor/combustor.cpp | 2 -- samples/cxx/demo.cpp | 1 + samples/cxx/kinetics1/kinetics1.cpp | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/samples/cxx/bvp/BoundaryValueProblem.h b/samples/cxx/bvp/BoundaryValueProblem.h index 80f7263e33..29776d3959 100644 --- a/samples/cxx/bvp/BoundaryValueProblem.h +++ b/samples/cxx/bvp/BoundaryValueProblem.h @@ -6,6 +6,7 @@ #define BVP_H #include "cantera/onedim.h" +#include /// Namespace for the boundary value problem package. namespace BVP @@ -113,18 +114,19 @@ class BoundaryValueProblem : public Cantera::Domain1D * @param n Component number. * @param c Component parameter values */ - void setComponent(int n, Component& c) { + void setComponent(size_t n, Component& c) { if (m_sim == 0) { start(); } - if (n < 0 || n >= m_nv) { + if (n >= m_nv) { throw Cantera::CanteraError("BoundaryValueProblem::setComponent", "Illegal solution component number"); } // set the upper and lower bounds for this component setBounds(n, c.lower, c.upper); // set the error tolerances - setTolerances(n, c.rtol, c.atol); + setSteadyTolerances(c.rtol, c.atol, n); + setTransientTolerances(c.rtol, c.atol, n); // specify whether this component should be considered in // refining the grid m_refiner->setActive(n, c.refine); @@ -209,7 +211,7 @@ class BoundaryValueProblem : public Cantera::Domain1D * True if n is the index of the left-most grid point (zero), * false otherwise. */ - bool isLeft(int n) const { + bool isLeft(size_t n) const { return (n == 0); } @@ -217,7 +219,7 @@ class BoundaryValueProblem : public Cantera::Domain1D * True if \a n is the index of the right-most grid point, false * otherwise. */ - bool isRight(int n) const { + bool isRight(size_t n) const { return (n == nPoints() - 1); } diff --git a/samples/cxx/combustor/combustor.cpp b/samples/cxx/combustor/combustor.cpp index c238d68b8a..531e5543f5 100644 --- a/samples/cxx/combustor/combustor.cpp +++ b/samples/cxx/combustor/combustor.cpp @@ -19,7 +19,6 @@ void runexample() // use reaction mechanism GRI-Mech 3.0 IdealGasMix gas("gri30.cti", "gri30"); - int nsp = gas.nSpecies(); // create a reservoir for the fuel inlet, and set to pure methane. Reservoir fuel_in; @@ -105,7 +104,6 @@ void runexample() double tfinal = 1.0; double tnow = 0.0; double tres; - int k; std::ofstream f("combustor_cxx.csv"); std::vector k_out; diff --git a/samples/cxx/demo.cpp b/samples/cxx/demo.cpp index 44ca9fb3b8..98646a7b5f 100644 --- a/samples/cxx/demo.cpp +++ b/samples/cxx/demo.cpp @@ -13,6 +13,7 @@ #include "cantera/IdealGasMix.h" // defines class IdealGasMix #include "cantera/transport.h" // transport properties +#include // All Cantera kernel names are in namespace Cantera. You can either // reference everything as Cantera::, or include the following diff --git a/samples/cxx/kinetics1/kinetics1.cpp b/samples/cxx/kinetics1/kinetics1.cpp index fd4aad8bf9..c18ca9e702 100644 --- a/samples/cxx/kinetics1/kinetics1.cpp +++ b/samples/cxx/kinetics1/kinetics1.cpp @@ -48,7 +48,7 @@ int kinetics1(int np, void* p) // create a container object to run the simulation // and add the reactor to it ReactorNet sim; - sim.addReactor(&r); + sim.addReactor(r); // main loop clock_t t0 = clock(); // save start time