63 Info<<
"Scaling Hessian with factor " << scaleFactor <<
endl;
66 Hessian_()[varI][varI] /= scaleFactor;
72 <<
"y*s is negative. Skipping the scaling of the first Hessian"
84 <<
" y*s is below threshold. Using damped form" <<
endl;
85 theta = (scalar(1)-
gamma_)*sBs/(sBs - ys);
89 <<
"Hessian curvature index " << ys <<
endl;
106 if (counter_ < nSteepestDescent_)
108 Info<<
"Using steepest descent to update design variables" <<
endl;
109 for (
const label varI : activeDesignVars_)
111 correction_[varI] = -eta_*objectiveDerivatives_[varI];
119 activeDerivs.map(objectiveDerivatives_, activeDesignVars_);
122 -etaHessian_*rightMult(HessianInv, activeDerivs)
127 forAll(activeDesignVars_, varI)
129 correction_[activeDesignVars_[varI]] = activeCorrection[varI];
146 const label nConstraints,
153 coeffsDict(
type).getOrDefault<scalar>(
"curvatureThreshold", 1
e-10)
155 gamma_(coeffsDict(
type).getOrDefault<scalar>(
"gamma", 0.2))
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
The quasi-Newton BFGS formula with the dampening proposed by Powell.
scalar curvatureThreshold_
Curvature threshold.
scalar gamma_
Threshold for damping.
void update()
Update design variables.
void updateHessian()
Update approximation of the inverse Hessian.
void map(const UList< Type > &mapF, const labelUList &mapAddressing)
1 to 1 map from the given field
A templated (N x N) square matrix of objects of <Type>, containing N*N elements, derived from Matrix.
void size(const label n)
Older name for setAddressableSize.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
Mesh data needed to do the Finite Volume discretisation.
Base class for quasi-Newton methods.
scalarField correctionOld_
The previous correction.
autoPtr< SquareMatrix< scalar > > Hessian_
The Hessian or its inverse, depending on the deriving class.
label nSteepestDescent_
Number of first steepest descent steps.
scalar etaHessian_
Step for the Newton method.
bool scaleFirstHessian_
Scale the initial unitary Hessian approximation.
scalarField derivativesOld_
The previous derivatives.
void allocateHessian()
Allocate the Hessian matrix.
Abstract base class for optimisation methods.
scalarField objectiveDerivatives_
Derivatives of the objective functions.
scalarField correction_
Design variables correction.
dictionary coeffsDict(const word &type) const
Return optional dictionary with parameters specific to each method.
scalar globalSum(const scalarField &field)
Compute either global or local sum, based on globalSum flag.
const scalarField leftMult(const scalarField &, const SquareMatrix< scalar > &)
const labelList & activeDesignVars_
Map to active design variables.
const scalarField rightMult(const SquareMatrix< scalar > &, const scalarField &)
label counter_
Optimisation cycle count.
label nConstraints() const
Get the number of constraints.
scalar eta_
Step multiplying the correction.
SquareMatrix< scalar > outerProd(const scalarField &, const scalarField &)
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
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))
#define DebugInfo
Report an information message using Foam::Info.
#define WarningInFunction
Report a warning using Foam::Warning.
messageStream Info
Information stream (stdout output on master, null elsewhere).
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static constexpr const zero Zero
Global zero (0).
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
#define forAll(list, i)
Loop across all elements in list.