Skip to content

Commit

Permalink
[clib] Fix MSVC compiler warnings
Browse files Browse the repository at this point in the history
Co-authored-by: Ray Speth <speth@mit.edu>
  • Loading branch information
ischoegl and speth committed Jun 29, 2023
1 parent bc92fca commit 745217c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
7 changes: 3 additions & 4 deletions src/clib/Cabinet.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class SharedCabinet
static int add(shared_ptr<M> obj) {
dataRef data = getData();
data.push_back(obj);
int idx = data.size() - 1;
int idx = static_cast<int>(data.size()) - 1;
lookupRef lookup = getLookup();
if (index(*obj) >= 0) {
lookup[obj.get()].insert(idx);
Expand All @@ -77,8 +77,7 @@ class SharedCabinet
* Return cabinet size.
*/
static int size() {
int size = getData().size();
return size;
return static_cast<int>(getData().size());
}

/**
Expand All @@ -87,7 +86,7 @@ class SharedCabinet
static int clear() {
dataRef data = getData();
for (size_t i = 0; i < data.size(); i++) {
del(i);
del(static_cast<int>(i));
}
return 0;
}
Expand Down
19 changes: 10 additions & 9 deletions src/clib/ctfunc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ extern "C" {
{
try {
shared_ptr<Func1> r;
size_t m = lenp;
int m = static_cast<int>(lenp);
int nn = static_cast<int>(n);
if (type == SinFuncType) {
r = newFunc1("sin", params[0]);
} else if (type == CosFuncType) {
Expand All @@ -51,21 +52,21 @@ extern "C" {
vector<double> par(params, params + lenp);
r = newFunc1("Arrhenius", par, n);
} else if (type == PeriodicFuncType) {
r = newFunc1("periodic", FuncCabinet::at(n), params[0]);
r = newFunc1("periodic", FuncCabinet::at(nn), params[0]);
} else if (type == SumFuncType) {
r = newFunc1("sum", FuncCabinet::at(n), FuncCabinet::at(m));
r = newFunc1("sum", FuncCabinet::at(nn), FuncCabinet::at(m));
} else if (type == DiffFuncType) {
r = newFunc1("diff", FuncCabinet::at(n), FuncCabinet::at(m));
r = newFunc1("diff", FuncCabinet::at(nn), FuncCabinet::at(m));
} else if (type == ProdFuncType) {
r = newFunc1("product", FuncCabinet::at(n), FuncCabinet::at(m));
r = newFunc1("product", FuncCabinet::at(nn), FuncCabinet::at(m));
} else if (type == RatioFuncType) {
r = newFunc1("ratio", FuncCabinet::at(n), FuncCabinet::at(m));
r = newFunc1("ratio", FuncCabinet::at(nn), FuncCabinet::at(m));
} else if (type == CompositeFuncType) {
r = newFunc1("composite", FuncCabinet::at(n), FuncCabinet::at(m));
r = newFunc1("composite", FuncCabinet::at(nn), FuncCabinet::at(m));
} else if (type == TimesConstantFuncType) {
r = newFunc1("times-constant", FuncCabinet::at(n), params[0]);
r = newFunc1("times-constant", FuncCabinet::at(nn), params[0]);
} else if (type == PlusConstantFuncType) {
r = newFunc1("plus-constant", FuncCabinet::at(n), params[0]);
r = newFunc1("plus-constant", FuncCabinet::at(nn), params[0]);
} else {
throw CanteraError("func_new", "unknown function type");
}
Expand Down
10 changes: 5 additions & 5 deletions test/clib/test_ctonedim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@ TEST(ctonedim, freeflame_from_parts)
// set up initial guess
vector<double> locs{0.0, 0.3, 0.7, 1.0};
vector<double> value{uin, uin, uout, uout};
int comp = domain_componentIndex(flow, "velocity");
int comp = static_cast<int>(domain_componentIndex(flow, "velocity"));
sim1D_setProfile(flame, dom, comp, 4, locs.data(), 4, value.data());
value = {T, T, Tad, Tad};
comp = domain_componentIndex(flow, "T");
comp = static_cast<int>(domain_componentIndex(flow, "T"));
sim1D_setProfile(flame, dom, comp, 4, locs.data(), 4, value.data());
for (size_t i = 0; i < nsp; i++) {
value = {yin[i], yin[i], yout[i], yout[i]};
Expand All @@ -220,7 +220,7 @@ TEST(ctonedim, freeflame_from_parts)
thermo_getSpeciesName(ph, i, buflen, buf);
string name = buf;
ASSERT_EQ(name, gas->speciesName(i));
comp = domain_componentIndex(flow, buf);
comp = static_cast<int>(domain_componentIndex(flow, buf));
sim1D_setProfile(flame, dom, comp, 4, locs.data(), 4, value.data());
}

Expand All @@ -246,10 +246,10 @@ TEST(ctonedim, freeflame_from_parts)
}

ASSERT_EQ(domain_nPoints(flow), nz + 1);
comp = domain_componentIndex(dom, "T");
comp = static_cast<int>(domain_componentIndex(dom, "T"));
double Tprev = sim1D_value(flame, dom, comp, 0);
for (size_t n = 0; n < domain_nPoints(flow); n++) {
T = sim1D_value(flame, dom, comp, n);
T = sim1D_value(flame, dom, comp, static_cast<int>(n));
ASSERT_GE(T, Tprev);
Tprev = T;
}
Expand Down

0 comments on commit 745217c

Please sign in to comment.