Go to the documentation of this file.
65 temp[i][i] = scalar(1);
80 y.map(objectiveDerivatives_ - derivativesOld_, activeDesignVars_);
81 s.map(correctionOld_, activeDesignVars_);
86 scalar tempMag =
sqrt(globalSum(
sqr(temp)));
87 scalar yMag =
sqrt(globalSum(
sqr(
y)));
88 scalar HessYMag =
sqrt(globalSum(
sqr(rightMult(HessianInvOld_,
y))));
91 if (tempMag > ratioThreshold_ * yMag * HessYMag)
95 + (scalar(1)/(globalSum(temp*
y)))*outerProd(temp, temp);
100 <<
"Denominator of update too small. Keeping old Hessian" <<
endl;
101 HessianInv_ = HessianInvOld_;
110 if (counter_ < nSteepestDescent_)
112 Info<<
"Using steepest descent to update design variables ... " <<
endl;
113 correction_ = -eta_*objectiveDerivatives_;
118 activeDerivs.
map(objectiveDerivatives_, activeDesignVars_);
121 -etaHessian_*rightMult(HessianInv_, activeDerivs)
126 forAll(activeDesignVars_, varI)
128 correction_[activeDesignVars_[varI]] = activeCorrection[varI];
133 derivativesOld_ = objectiveDerivatives_;
134 correctionOld_ = correction_;
135 HessianInvOld_ = HessianInv_;
141 if (optMethodIODict_.headerOk())
143 optMethodIODict_.readEntry(
"HessianInvOld", HessianInvOld_);
144 optMethodIODict_.readEntry(
"derivativesOld", derivativesOld_);
145 optMethodIODict_.readEntry(
"correctionOld", correctionOld_);
146 optMethodIODict_.readEntry(
"counter", counter_);
147 optMethodIODict_.readEntry(
"eta", eta_);
149 label n = HessianInvOld_.n();
165 coeffsDict().lookupOrDefault<scalar>(
"etaHessian", 1)
169 coeffsDict().lookupOrDefault<
label>(
"nSteepestDescent", 1)
173 coeffsDict().lookupOrDefault<scalar>(
"ratioThreshold", 1
e-08)
175 activeDesignVars_(0),
189 Info<<
"\t Didn't find explicit definition of active design variables. "
190 <<
"Treating all available ones as active " <<
endl;
219 correctionOld_ = oldCorrection;
231 optMethodIODict_.add<
scalarField>(
"derivativesOld", derivativesOld_,
true);
232 optMethodIODict_.add<
scalarField>(
"correctionOld", correctionOld_,
true);
233 optMethodIODict_.add<
label>(
"counter", counter_,
true);
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
static constexpr const zero Zero
Global zero.
Ostream & endl(Ostream &os)
Add newline and flush stream.
labelList activeDesignVars_
Map to active design variables.
void computeCorrection()
Compute design variables correction.
void allocateMatrices()
Allocate matrices in the first optimisation cycle.
#define forAll(list, i)
Loop across all elements in list.
void map(const UList< Type > &mapF, const labelUList &mapAddressing)
1 to 1 map from the given field
void readFromDict()
Read old info from dict.
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)
Abstract base class for optimisation methods.
messageStream Info
Information stream (uses stdout - output is on the master only)
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
scalarField correction_
Design variables correction.
Macros for easy insertion into run-time selection tables.
Mesh data needed to do the Finite Volume discretisation.
dictionary coeffsDict()
Return optional dictionary with parameters specific to each method.
virtual void write()
Write usefull quantities to files.
virtual void write()
Write old info to dict.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
SquareMatrix< scalar > HessianInv_
dimensionedScalar sqrt(const dimensionedScalar &ds)
void update()
Update design variables.
const dimensionedScalar e
Elementary charge.
SquareMatrix< scalar > HessianInvOld_
The previous Hessian inverse.
void setSize(const label newSize)
Alias for resize(const label)
defineTypeNameAndDebug(combustionModel, 0)
#define WarningInFunction
Report a warning using Foam::Warning.
void updateHessian()
Update approximation of the inverse Hessian.
virtual void updateOldCorrection(const scalarField &oldCorrection)