Replace std::copy with simpler direct assignment where possible

This commit is contained in:
Ray Speth 2015-11-12 17:33:43 -05:00
parent 69eeb20283
commit f5ff849b47
16 changed files with 27 additions and 39 deletions

View file

@ -668,7 +668,7 @@ int ChemEquil::equilibrate(thermo_t& s, const char* XYstr,
}
}
copy(x.begin(), x.end(), oldx.begin());
oldx = x;
oldf = f;
scale(res_trial.begin(), res_trial.end(), res_trial.begin(), -1.0);
@ -913,12 +913,11 @@ int ChemEquil::estimateEP_Brinkley(thermo_t& s, vector_fp& x,
vector_fp n_i(m_kk,0.0);
vector_fp n_i_calc(m_kk,0.0);
vector_fp actCoeff(m_kk, 1.0);
vector_fp Xmol_i_calc(m_kk,0.0);
double beta = 1.0;
s.getMoleFractions(n_i.data());
double pressureConst = s.pressure();
copy(n_i.begin(), n_i.end(), Xmol_i_calc.begin());
vector_fp Xmol_i_calc = n_i;
vector_fp x_old(m_mm+1, 0.0);
vector_fp resid(m_mm+1, 0.0);

View file

@ -408,7 +408,7 @@ void MultiPhaseEquil::getComponents(const std::vector<size_t>& order)
void MultiPhaseEquil::unsort(vector_fp& x)
{
copy(x.begin(), x.end(), m_work2.begin());
m_work2 = x;
size_t k;
for (k = 0; k < m_nsp; k++) {
x[m_order[k]] = m_work2[k];

View file

@ -102,13 +102,13 @@ void AqueousKinetics::updateROP()
}
// copy rate coefficients into ropf
copy(m_rfn.begin(), m_rfn.end(), m_ropf.begin());
m_ropf = m_rfn;
// multiply by perturbation factor
multiply_each(m_ropf.begin(), m_ropf.end(), m_perturb.begin());
// copy the forward rates to the reverse rates
copy(m_ropf.begin(), m_ropf.end(), m_ropr.begin());
m_ropr = m_ropf;
// for reverse rates computed from thermochemistry, multiply the forward
// rates copied into m_ropr by the reciprocals of the equilibrium constants
@ -133,7 +133,7 @@ void AqueousKinetics::getFwdRateConstants(doublereal* kfwd)
_update_rates_C();
// copy rate coefficients into ropf
copy(m_rfn.begin(), m_rfn.end(), m_ropf.begin());
m_ropf = m_rfn;
// multiply by perturbation factor
multiply_each(m_ropf.begin(), m_ropf.end(), m_perturb.begin());

View file

@ -168,7 +168,7 @@ void GasKinetics::updateROP()
}
// copy rate coefficients into ropf
copy(m_rfn.begin(), m_rfn.end(), m_ropf.begin());
m_ropf = m_rfn;
// multiply ropf by enhanced 3b conc for all 3b rxns
if (!concm_3b_values.empty()) {
@ -183,7 +183,7 @@ void GasKinetics::updateROP()
multiply_each(m_ropf.begin(), m_ropf.end(), m_perturb.begin());
// copy the forward rates to the reverse rates
copy(m_ropf.begin(), m_ropf.end(), m_ropr.begin());
m_ropr = m_ropf;
// for reverse rates computed from thermochemistry, multiply the forward
// rates copied into m_ropr by the reciprocals of the equilibrium constants
@ -216,7 +216,7 @@ void GasKinetics::getFwdRateConstants(doublereal* kfwd)
update_rates_T();
// copy rate coefficients into ropf
copy(m_rfn.begin(), m_rfn.end(), m_ropf.begin());
m_ropf = m_rfn;
// multiply ropf by enhanced 3b conc for all 3b rxns
if (!concm_3b_values.empty()) {

View file

@ -224,13 +224,13 @@ void ImplicitSurfChem::solvePseudoSteadyStateProblem(int ifuncOverride,
m_surfSolver->m_ioflag = m_ioFlag;
// Save the current solution
copy(m_concSpecies.begin(), m_concSpecies.end(), m_concSpeciesSave.begin());
m_concSpeciesSave = m_concSpecies;
int retn = m_surfSolver->solveSurfProb(ifunc, time_scale, TKelvin, PGas,
reltol, atol);
if (retn != 1) {
// reset the concentrations
copy(m_concSpeciesSave.begin(), m_concSpeciesSave.end(), m_concSpecies.begin());
m_concSpecies = m_concSpeciesSave;
setConcSpecies(m_concSpeciesSave.data());
ifunc = SFLUX_INITIALIZE;
retn = m_surfSolver->solveSurfProb(ifunc, time_scale, TKelvin, PGas,

View file

@ -441,13 +441,13 @@ void InterfaceKinetics::updateROP()
}
// Copy the reaction rate coefficients, m_rfn, into m_ropf
copy(m_rfn.begin(), m_rfn.end(), m_ropf.begin());
m_ropf = m_rfn;
// Multiply by the perturbation factor
multiply_each(m_ropf.begin(), m_ropf.end(), m_perturb.begin());
// Copy the forward rate constants to the reverse rate constants
copy(m_ropf.begin(), m_ropf.end(), m_ropr.begin());
m_ropr = m_ropf;
// For reverse rates computed from thermochemistry, multiply
// the forward rates copied into m_ropr by the reciprocals of

View file

@ -158,7 +158,7 @@ int solveSP::solveSurfProb(int ifunc, doublereal time_scale, doublereal TKelvin,
}
}
std::copy(m_CSolnSP.begin(), m_CSolnSP.end(), m_CSolnSPInit.begin());
m_CSolnSPInit = m_CSolnSP;
// Calculate the largest species in each phase
evalSurfLarge(m_CSolnSP.data());
@ -177,7 +177,7 @@ int solveSP::solveSurfProb(int ifunc, doublereal time_scale, doublereal TKelvin,
while (not_converged && iter < iter_max) {
iter++;
// Store previous iteration's solution in the old solution vector
std::copy(m_CSolnSP.begin(), m_CSolnSP.end(), m_CSolnSPOld.begin());
m_CSolnSPOld = m_CSolnSP;
// Evaluate the largest surface species for each surface phase every
// 5 iterations.

View file

@ -229,7 +229,7 @@ void BandMatrix::leftMult(const doublereal* const b, doublereal* const prod) con
int BandMatrix::factor()
{
int info=0;
copy(data.begin(), data.end(), ludata.begin());
ludata = data;
ct_dgbtrf(nRows(), nColumns(), nSubDiagonals(), nSuperDiagonals(),
ludata.data(), ldim(), ipiv().data(), info);

View file

@ -194,7 +194,7 @@ int Sim1D::newtonSolve(int loglevel)
{
int m = OneDim::solve(m_x.data(), m_xnew.data(), loglevel);
if (m >= 0) {
copy(m_xnew.begin(), m_xnew.end(), m_x.begin());
m_x = m_xnew;
return 0;
} else if (m > -10) {
return -1;
@ -385,8 +385,7 @@ int Sim1D::refine(int loglevel)
}
// Replace the current solution vector with the new one
m_x.resize(xnew.size());
copy(xnew.begin(), xnew.end(), m_x.begin());
m_x = xnew;
// resize the work array
m_xnew.resize(xnew.size());
@ -478,12 +477,10 @@ int Sim1D::setFixedTemperature(doublereal t)
}
// Replace the current solution vector with the new one
m_x.resize(xnew.size());
copy(xnew.begin(), xnew.end(), m_x.begin());
m_x = xnew;
// resize the work array
m_xnew.resize(xnew.size());
copy(xnew.begin(), xnew.end(), m_xnew.begin());
m_xnew = xnew;
resize();
finalize();
return np;

View file

@ -498,11 +498,7 @@ doublereal Phase::molecularWeight(size_t k) const
void Phase::getMolecularWeights(vector_fp& weights) const
{
const vector_fp& mw = molecularWeights();
if (weights.size() < mw.size()) {
weights.resize(mw.size());
}
copy(mw.begin(), mw.end(), weights.begin());
weights = molecularWeights();
}
void Phase::getMolecularWeights(doublereal* weights) const

View file

@ -125,8 +125,7 @@ static SpeciesThermoInterpType* newNasaThermoFromXML(vector<XML_Node*> nodes)
getFloatArray(nodes[1]->child("floatArray"), c1, false);
} else {
// if there is no higher range data, then copy c0 to c1.
c1.resize(7,0.0);
copy(c0.begin(), c0.end(), c1.begin());
c1 = c0;
}
} else if (fabs(tmax1 - tmin0) < 0.01) {
// f1 has the lower T data, and f0 the higher T data

View file

@ -96,8 +96,7 @@ void DustyGasTransport::initialize(ThermoPhase* phase, Transport* gastr)
}
// make a local copy of the molecular weights
m_mw.resize(m_nsp);
copy(m_thermo->molecularWeights().begin(), m_thermo->molecularWeights().end(), m_mw.begin());
m_mw = m_thermo->molecularWeights();
m_multidiff.resize(m_nsp, m_nsp);
m_d.resize(m_nsp, m_nsp);

View file

@ -351,8 +351,7 @@ void GasTransport::init(thermo_t* thermo, int mode, int log_level)
m_bdiff.resize(m_nsp, m_nsp);
// make a local copy of the molecular weights
m_mw.assign(m_thermo->molecularWeights().begin(),
m_thermo->molecularWeights().end());
m_mw = m_thermo->molecularWeights();
m_wratjk.resize(m_nsp, m_nsp, 0.0);
m_wratkj1.resize(m_nsp, m_nsp, 0.0);

View file

@ -244,7 +244,7 @@ bool LiquidTransport::initLiquid(LiquidTransportParams& tr)
m_radiusTempDep_Ns.resize(m_nsp, 0);
// Make a local copy of the molecular weights
copy(m_thermo->molecularWeights().begin(), m_thermo->molecularWeights().end(), m_mw.begin());
m_mw = m_thermo->molecularWeights();
// First populate mixing rules and indices (NOTE, we transfer pointers of
// malloced quantities. We zero out pointers so that we only have one copy

View file

@ -156,7 +156,7 @@ void MultiTransport::solveLMatrixEquation()
// Solve it using GMRES or LU decomposition. The last solution in m_a should
// provide a good starting guess, so convergence should be fast.
copy(m_b.begin(), m_b.end(), m_a.begin());
m_a = m_b;
try {
solve(m_Lmatrix, m_a.data());
} catch (CanteraError& err) {

View file

@ -170,8 +170,7 @@ bool SimpleTransport::initLiquid(LiquidTransportParams& tr)
}
// make a local copy of the molecular weights
m_mw.resize(m_nsp);
copy(m_thermo->molecularWeights().begin(), m_thermo->molecularWeights().end(), m_mw.begin());
m_mw = m_thermo->molecularWeights();
// Get the input Viscosities
m_viscSpecies.resize(m_nsp);