Skip to content

Commit

Permalink
Fix issues identified by _GLIBCXX_ASSERTIONS macro
Browse files Browse the repository at this point in the history
Resolves #1430
  • Loading branch information
speth committed Feb 25, 2023
1 parent 924bdf3 commit e494c0a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/base/SolutionArray.cpp
Expand Up @@ -240,7 +240,8 @@ void SolutionArray::writeEntry(const std::string& fname, const std::string& id,
std::vector<vector_fp> prop;
for (size_t i = 0; i < m_size; i++) {
size_t first = offset + i * m_stride;
prop.push_back(vector_fp(&m_data[first], &m_data[first + nSpecies]));
prop.emplace_back(m_data.begin() + first,
m_data.begin() + first + nSpecies);
}
file.writeMatrix(id, name, prop);
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/equil/MultiPhase.cpp
Expand Up @@ -818,7 +818,7 @@ void MultiPhase::uploadMoleFractionsFromPhases()
size_t loc = 0;
for (size_t ip = 0; ip < nPhases(); ip++) {
ThermoPhase* p = m_phase[ip];
p->getMoleFractions(&m_moleFractions[loc]);
p->getMoleFractions(m_moleFractions.data() + loc);
loc += p->nSpecies();
}
calcElemAbundances();
Expand All @@ -828,7 +828,7 @@ void MultiPhase::updatePhases() const
{
size_t loc = 0;
for (size_t p = 0; p < nPhases(); p++) {
m_phase[p]->setState_TPX(m_temp, m_press, &m_moleFractions[loc]);
m_phase[p]->setState_TPX(m_temp, m_press, m_moleFractions.data() + loc);
loc += m_phase[p]->nSpecies();
m_temp_OK[p] = true;
if (m_temp < m_phase[p]->minTemp() || m_temp > m_phase[p]->maxTemp()) {
Expand Down
10 changes: 7 additions & 3 deletions src/oneD/Sim1D.cpp
Expand Up @@ -221,8 +221,10 @@ AnyMap legacyH5(shared_ptr<SolutionArray> arr, const AnyMap& header={})
while (profile[ix] <= temp && ix < arr->size()) {
ix++;
}
out["fixed-point"]["location"] = arr->getComponent("grid")[ix - 1];
out["fixed-point"]["temperature"] = temp;
if (ix != 0) {
out["fixed-point"]["location"] = arr->getComponent("grid")[ix - 1];
out["fixed-point"]["temperature"] = temp;
}
}

return out;
Expand Down Expand Up @@ -558,7 +560,9 @@ int Sim1D::refine(int loglevel)
for (size_t n = 0; n < nDomains(); n++) {
Domain1D& d = domain(n);
gridsize = dsize[n];
d.setupGrid(gridsize, &znew[gridstart]);
if (gridsize != 0) {
d.setupGrid(gridsize, &znew[gridstart]);
}
gridstart += gridsize;
}

Expand Down
6 changes: 3 additions & 3 deletions src/transport/IonGasTransport.cpp
Expand Up @@ -36,9 +36,9 @@ void IonGasTransport::init(ThermoPhase* thermo, int mode, int log_level)
// Find the index of electron
size_t nElectronSpecies = 0;
for (size_t k = 0; k < m_nsp; k++) {
if (m_thermo->molecularWeight(k) ==
m_thermo->atomicWeight(m_thermo->elementIndex("E")) &&
m_thermo->charge(k) == -1) {
if (m_thermo->molecularWeight(k) == getElementWeight("E") &&
m_thermo->charge(k) == -1)
{
m_kElectron = k;
nElectronSpecies++;
}
Expand Down
4 changes: 2 additions & 2 deletions test/kinetics/kineticsFromYaml.cpp
Expand Up @@ -316,11 +316,11 @@ TEST(Reaction, FalloffFromYaml2)
EXPECT_DOUBLE_EQ(rate->highRate().preExponentialFactor(), 6e11);
EXPECT_DOUBLE_EQ(rate->lowRate().preExponentialFactor(), 1.04e20);
EXPECT_DOUBLE_EQ(rate->lowRate().activationEnergy(), 1600);
vector_fp params(4);
vector_fp params;
rate->getFalloffCoeffs(params);
ASSERT_EQ(params.size(), (size_t) 3);
EXPECT_DOUBLE_EQ(params[0], 0.562);
EXPECT_DOUBLE_EQ(params[1], 91.0);
EXPECT_DOUBLE_EQ(params[3], 0.0);
EXPECT_EQ(R->input["source"].asString(), "somewhere");
}

Expand Down

0 comments on commit e494c0a

Please sign in to comment.