Commit c77afff4 authored by Mark Olesen's avatar Mark Olesen

COMP: fix sloppy (and now ambiguous) use of PtrList::set()

- constructs such as the following will no longer worked, but that is
  also a good thing.

     ptrlist.set(i, scalarField(nFaces, Zero));

  this called set(.., const tmp<scalarField>&), which meant under
  the hood:

     - create local temporary const scalarField&
     - wrap as const tmp&
     - use tmp::ptr(), to clone the const-ref

  This implies an additional allocation (for the const scalarField&)
  which is immediately discarded. Doubtful that compiler optimization
  would do anything.
parent dc52e5ae
......@@ -58,8 +58,8 @@ void Foam::LBFGS::allocateMatrices()
label nVars(activeDesignVars_.size());
for (label i = 0; i < nPrevSteps_; i++)
{
y_.set(i, scalarField(nVars, Zero));
s_.set(i, scalarField(nVars, Zero));
y_.set(i, new scalarField(nVars, Zero));
s_.set(i, new scalarField(nVars, Zero));
}
}
......@@ -120,8 +120,8 @@ void Foam::LBFGS::LBFGSUpdate()
label nSteps(min(counter_, nPrevSteps_));
label nLast(nSteps - 1);
scalarField q(objectiveDerivatives_, activeDesignVars_);
scalarField a(nSteps, 0.);
scalarField r(nSteps, 0.);
scalarField a(nSteps, Zero);
scalarField r(nSteps, Zero);
for (label i = nLast; i > -1; --i)
{
r[i] = 1./globalSum(y_[i]*s_[i]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment