[Samples] Fix compilation errors and warnings in the C++ examples

This commit is contained in:
Ray Speth 2015-07-16 12:38:34 -04:00
parent e21a7ce7d7
commit 571eaeda24
4 changed files with 9 additions and 8 deletions

View file

@ -6,6 +6,7 @@
#define BVP_H
#include "cantera/onedim.h"
#include <fstream>
/// Namespace for the boundary value problem package.
namespace BVP
@ -113,18 +114,19 @@ public:
* @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 @@ protected:
* 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 @@ protected:
* 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);
}

View file

@ -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<size_t> k_out;

View file

@ -13,6 +13,7 @@
#include "cantera/IdealGasMix.h" // defines class IdealGasMix
#include "cantera/transport.h" // transport properties
#include <cstdio>
// All Cantera kernel names are in namespace Cantera. You can either
// reference everything as Cantera::<name>, or include the following

View file

@ -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