mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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.
This commit is contained in:
@ -58,8 +58,8 @@ void Foam::LBFGS::allocateMatrices()
|
|||||||
label nVars(activeDesignVars_.size());
|
label nVars(activeDesignVars_.size());
|
||||||
for (label i = 0; i < nPrevSteps_; i++)
|
for (label i = 0; i < nPrevSteps_; i++)
|
||||||
{
|
{
|
||||||
y_.set(i, scalarField(nVars, Zero));
|
y_.set(i, new scalarField(nVars, Zero));
|
||||||
s_.set(i, scalarField(nVars, Zero));
|
s_.set(i, new scalarField(nVars, Zero));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,8 +120,8 @@ void Foam::LBFGS::LBFGSUpdate()
|
|||||||
label nSteps(min(counter_, nPrevSteps_));
|
label nSteps(min(counter_, nPrevSteps_));
|
||||||
label nLast(nSteps - 1);
|
label nLast(nSteps - 1);
|
||||||
scalarField q(objectiveDerivatives_, activeDesignVars_);
|
scalarField q(objectiveDerivatives_, activeDesignVars_);
|
||||||
scalarField a(nSteps, 0.);
|
scalarField a(nSteps, Zero);
|
||||||
scalarField r(nSteps, 0.);
|
scalarField r(nSteps, Zero);
|
||||||
for (label i = nLast; i > -1; --i)
|
for (label i = nLast; i > -1; --i)
|
||||||
{
|
{
|
||||||
r[i] = 1./globalSum(y_[i]*s_[i]);
|
r[i] = 1./globalSum(y_[i]*s_[i]);
|
||||||
|
|||||||
Reference in New Issue
Block a user