Go to the documentation of this file.
73 if (counter_ > nPrevSteps_)
77 newOrder[0] = nPrevSteps_ - 1;
78 for (
label i = 1; i < nPrevSteps_; ++i)
82 list.reorder(newOrder);
85 list[nPrevSteps_ - 1] =
f;
89 list[counter_ - 1] =
f;
99 (objectiveDerivatives_ - derivativesOld_, activeDesignVars_);
100 pivotFields(y_, yRecent);
103 scalarField sActive(correctionOld_, activeDesignVars_);
104 pivotFields(s_, sActive);
107 <<
"y fields" <<
nl << y_ <<
endl;
109 <<
"s fields" <<
nl << s_ <<
endl;
115 Info<<
"Using steepest descent to update design variables" <<
endl;
116 correction_ = -eta_*objectiveDerivatives_;
124 label nSteps(
min(counter_, nPrevSteps_));
125 label nLast(nSteps - 1);
126 scalarField q(objectiveDerivatives_, activeDesignVars_);
129 for (
label i = nLast; i > -1; --i)
131 r[i] = 1./globalSum(y_[i]*s_[i]);
132 a[i] = r[i]*globalSum(s_[i]*q);
137 globalSum(y_[nLast]*s_[nLast])/globalSum(y_[nLast]*y_[nLast]);
141 for (
label i = 0; i < nSteps; ++i)
143 b = r[i]*globalSum(y_[i]*q);
144 q += s_[i]*(a[i] -
b);
148 forAll(activeDesignVars_, varI)
150 correction_[activeDesignVars_[varI]] = -etaHessian_*q[varI];
159 if (counter_ < nSteepestDescent_)
161 steepestDescentUpdate();
170 derivativesOld_ = objectiveDerivatives_;
171 correctionOld_ = correction_;
177 if (optMethodIODict_.headerOk())
179 optMethodIODict_.readEntry(
"y", y_);
180 optMethodIODict_.readEntry(
"s", s_);
181 optMethodIODict_.readEntry(
"derivativesOld", derivativesOld_);
182 optMethodIODict_.readEntry(
"counter", counter_);
183 optMethodIODict_.readEntry(
"eta", eta_);
184 optMethodIODict_.readEntry(
"correctionOld", correctionOld_);
204 coeffsDict().lookupOrDefault<scalar>(
"etaHessian", 1)
208 coeffsDict().lookupOrDefault<label>(
"nSteepestDescent", 1)
210 activeDesignVars_(0),
213 coeffsDict().lookupOrDefault<label>(
"nPrevSteps", 10)
222 !coeffsDict().readIfPresent(
"activeDesignVariables", activeDesignVars_)
227 Info<<
"\t Did not find explicit definition of active design variables. "
228 <<
"Treating all available ones as active " <<
endl;
257 correctionOld_ = oldCorrection;
265 optMethodIODict_.add<
scalarField>(
"derivativesOld", derivativesOld_,
true);
266 optMethodIODict_.add<
scalarField>(
"correctionOld", correctionOld_,
true);
267 optMethodIODict_.add<
label>(
"counter", counter_,
true);
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
void readFromDict()
Read old info from dict.
static constexpr const zero Zero
Global zero.
void allocateMatrices()
Allocate matrices in the first optimisation cycle.
void update()
Update design variables.
Ostream & endl(Ostream &os)
Add newline and flush stream.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
#define forAll(list, i)
Loop across all elements in list.
PtrList< scalarField > y_
The previous differences of derivatives. Holds nPrevSteps_ fields.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
virtual void updateOldCorrection(const scalarField &oldCorrection)
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Abstract base class for optimisation methods.
messageStream Info
Information stream (uses stdout - output is on the master only)
virtual void updateOldCorrection(const scalarField &oldCorrection)
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Macros for easy insertion into run-time selection tables.
Mesh data needed to do the Finite Volume discretisation.
label nPrevSteps_
Number of old corrections and grad differences kept.
void steepestDescentUpdate()
Update based on steepest descent.
virtual void write()
Write old info to dict.
virtual void write()
Write usefull quantities to files.
#define DebugInfo
Report an information message using Foam::Info.
labelList activeDesignVars_
Map to active design variables.
PtrList< scalarField > s_
The previous correction. Holds nPrevSteps_ fields.
void LBFGSUpdate()
Update based on LBFGS.
void setSize(const label newSize)
Alias for resize(const label)
defineTypeNameAndDebug(combustionModel, 0)
void pivotFields(PtrList< scalarField > &list, const scalarField &f)
scalarField objectiveDerivatives_
Derivatives of the objective functions.
void computeCorrection()
Compute design variables correction.
void updateVectors()
Update y and s vectors.