A class encapsulating functionality neccessary to perform an optimisation loop, such as updating the design variables, checking the sufficient reduction/adhetion of objective and constraint values in each optimisation cycle by performing a line-search and checking the overall convergence of the optimisation loop, if the corresponding criteria are provided. More...
Public Member Functions | |
TypeName ("designVariablesUpdate") | |
Runtime type information. More... | |
designVariablesUpdate (fvMesh &mesh, const dictionary &dict, PtrList< adjointSolverManager > &adjointSolverManagers, autoPtr< designVariables > &designVars) | |
Construct from components. More... | |
virtual | ~designVariablesUpdate ()=default |
Destructor. More... | |
void | update () |
Update design variables. More... | |
void | update (const scalarField &correction) |
Update design variables based on a given correction. More... | |
tmp< scalarField > | computeDirection () |
Compute update direction. More... | |
void | updateGradientsAndValues () |
Compute cumulative objective and constraint gradients. More... | |
scalar | computeObjectiveValue () |
Sum objective values from all adjointSolverManagers. More... | |
void | setOldObjectiveValue () |
Set the old objective value known by the updateMethod. More... | |
scalar | computeMeritFunction () |
Compute the merit function of the optimisation problem. More... | |
scalar | meritFunctionDirectionalDerivative () |
Derivative of the merit function. More... | |
void | updateOldCorrection (const scalarField &) |
Update old correction. Needed for quasi-Newton Methods. More... | |
void | write () |
Write useful quantities to files. More... | |
void | postUpdate (const scalarField &oldCorrection) |
Steps to be executed after the susccessfull update of the design varibles, i.e. the last step of line search or the simple update in the fixedStep approach. More... | |
autoPtr< designVariables > & | getDesignVariables () |
Get access to design variables. More... | |
autoPtr< lineSearch > & | getLineSearch () |
Get a reference to the line search object. More... | |
Protected Member Functions | |
label | nConstraints (PtrList< adjointSolverManager > &adjointSolverManagers) const |
Get the number of adjoint solvers that correspond to constraints. More... | |
label | nAdjointSolvers () const |
Get total number of adjoint solvers. More... | |
void | writeCPUcostHeader () |
Write CPU cost header. More... | |
void | writeToCostFile (bool zeroAdjointSolns=false) |
Write to cost file. More... | |
void | checkConvergence (const scalarField &oldCorrection) |
Check if the optimisation loop has converged based on the provided criteria. More... | |
Protected Attributes | |
fvMesh & | mesh_ |
const dictionary | dict_ |
PtrList< adjointSolverManager > & | adjointSolvManagers_ |
autoPtr< designVariables > & | designVars_ |
autoPtr< updateMethod > | updateMethod_ |
Method to update the design variables based on the provided sensitivity derivatives. More... | |
autoPtr< lineSearch > | lineSearch_ |
Line search mechanism to approximate the update step length. More... | |
OFstream | CPUcostFile_ |
Output file. More... | |
label | nPrimalsPerCycle_ |
Primal solutions per optimisation cycle. More... | |
label | nAdjointsPerCycle_ |
Adjoint solutions per optimisation cycle. More... | |
label | nPrimalSolutions_ |
Primal evaluations performed so far. More... | |
label | nAdjointSolutions_ |
Adjoint evaluations performed so far. More... | |
scalar | CPUcost_ |
CPU cost (in seconds) More... | |
autoPtr< scalar > | designVarsThreshold_ |
The maximum of the correction/designVariables values must be lower that this threshold to consider the run converged. More... | |
autoPtr< scalar > | objectiveThreshold_ |
The relative update of the objective value w.r.t. to its last value should be smaller than this value to considered the run converged. More... | |
bool | convergenceCriteriaDefined_ |
Is at least a single convergence criterion defined. More... | |
scalar | feasibilityThreshold_ |
In case of a constrained optimisation, the sum of positive constraints should be lower than this value to consider the run converged (i.e. this tolerates some deviation from satisfying all constraints) More... | |
A class encapsulating functionality neccessary to perform an optimisation loop, such as updating the design variables, checking the sufficient reduction/adhetion of objective and constraint values in each optimisation cycle by performing a line-search and checking the overall convergence of the optimisation loop, if the corresponding criteria are provided.
Kept separate from optimisationManager to isolate functionality required only when the update of the design variables is performed.
Definition at line 60 of file designVariablesUpdate.H.
designVariablesUpdate | ( | fvMesh & | mesh, |
const dictionary & | dict, | ||
PtrList< adjointSolverManager > & | adjointSolverManagers, | ||
autoPtr< designVariables > & | designVars | ||
) |
Construct from components.
Definition at line 211 of file designVariablesUpdate.C.
References dict, Foam::endl(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, dictionary::found(), dictionary::get(), Foam::Info, Foam::nl, dictionary::subOrEmptyDict(), and WarningInFunction.
|
virtualdefault |
Destructor.
|
protected |
Get the number of adjoint solvers that correspond to constraints.
Definition at line 41 of file designVariablesUpdate.C.
|
protected |
Get total number of adjoint solvers.
Definition at line 62 of file designVariablesUpdate.C.
References designVariablesUpdate::adjointSolvManagers_, and n.
|
protected |
Write CPU cost header.
Definition at line 79 of file designVariablesUpdate.C.
References IOstream::defaultPrecision(), Foam::endl(), and Foam::setw().
|
protected |
Write to cost file.
Definition at line 94 of file designVariablesUpdate.C.
References IOstream::defaultPrecision(), Foam::endl(), and Foam::setw().
|
protected |
Check if the optimisation loop has converged based on the provided criteria.
May terminate the program
Definition at line 133 of file designVariablesUpdate.C.
References Foam::correction(), DebugInfo, Foam::endl(), Foam::exit(), UPstream::exit(), Foam::gMax(), Foam::Info, Foam::mag(), Foam::nl, UPstream::parRun(), Foam::pos(), Foam::sum(), and Foam::tab.
TypeName | ( | "designVariablesUpdate" | ) |
Runtime type information.
void update | ( | ) |
Update design variables.
Definition at line 346 of file designVariablesUpdate.C.
References Foam::correction(), and tmp< T >::ref().
void update | ( | const scalarField & | correction | ) |
Update design variables based on a given correction.
Definition at line 364 of file designVariablesUpdate.C.
References Foam::correction().
Foam::tmp< Foam::scalarField > computeDirection | ( | ) |
Compute update direction.
Definition at line 378 of file designVariablesUpdate.C.
References Foam::correction(), and tmp< T >::New().
void updateGradientsAndValues | ( | ) |
Compute cumulative objective and constraint gradients.
Definition at line 397 of file designVariablesUpdate.C.
References UList< T >::empty(), Foam::endl(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, forAll, PtrList< T >::push_back(), DynamicList< T, SizeMin >::push_back(), tmp< T >::ref(), PtrList< T >::set(), List< T >::setSize(), UPtrList< T >::size(), and Foam::Zero.
Foam::scalar computeObjectiveValue | ( | ) |
Sum objective values from all adjointSolverManagers.
Definition at line 472 of file designVariablesUpdate.C.
References Foam::Zero.
void setOldObjectiveValue | ( | ) |
Set the old objective value known by the updateMethod.
Used to check convergence of the optimisation loop
Definition at line 484 of file designVariablesUpdate.C.
Foam::scalar computeMeritFunction | ( | ) |
Compute the merit function of the optimisation problem.
Could be different than the objective function in case of constraint optimisation
Definition at line 490 of file designVariablesUpdate.C.
References DynamicList< T, SizeMin >::push_back(), and Foam::Zero.
Foam::scalar meritFunctionDirectionalDerivative | ( | ) |
Derivative of the merit function.
Definition at line 519 of file designVariablesUpdate.C.
void updateOldCorrection | ( | const scalarField & | oldCorrection | ) |
Update old correction. Needed for quasi-Newton Methods.
Definition at line 526 of file designVariablesUpdate.C.
void write | ( | ) |
Write useful quantities to files.
Definition at line 534 of file designVariablesUpdate.C.
void postUpdate | ( | const scalarField & | oldCorrection | ) |
Steps to be executed after the susccessfull update of the design varibles, i.e. the last step of line search or the simple update in the fixedStep approach.
Definition at line 542 of file designVariablesUpdate.C.
References Foam::vtk::write().
|
inline |
Get access to design variables.
Definition at line 286 of file designVariablesUpdate.H.
References designVariablesUpdate::designVars_.
|
inline |
Get a reference to the line search object.
Definition at line 294 of file designVariablesUpdate.H.
References designVariablesUpdate::lineSearch_.
|
protected |
Definition at line 66 of file designVariablesUpdate.H.
|
protected |
Definition at line 67 of file designVariablesUpdate.H.
|
protected |
Definition at line 68 of file designVariablesUpdate.H.
Referenced by designVariablesUpdate::nAdjointSolvers().
|
protected |
Definition at line 69 of file designVariablesUpdate.H.
Referenced by designVariablesUpdate::getDesignVariables().
|
protected |
Method to update the design variables based on the provided sensitivity derivatives.
Definition at line 75 of file designVariablesUpdate.H.
|
protected |
Line search mechanism to approximate the update step length.
Definition at line 80 of file designVariablesUpdate.H.
Referenced by designVariablesUpdate::getLineSearch().
|
protected |
Output file.
Definition at line 87 of file designVariablesUpdate.H.
|
protected |
Primal solutions per optimisation cycle.
Definition at line 92 of file designVariablesUpdate.H.
|
protected |
Adjoint solutions per optimisation cycle.
Definition at line 97 of file designVariablesUpdate.H.
|
protected |
Primal evaluations performed so far.
Definition at line 102 of file designVariablesUpdate.H.
|
protected |
Adjoint evaluations performed so far.
Definition at line 107 of file designVariablesUpdate.H.
|
protected |
CPU cost (in seconds)
Definition at line 112 of file designVariablesUpdate.H.
|
protected |
The maximum of the correction/designVariables values must be lower that this threshold to consider the run converged.
Definition at line 120 of file designVariablesUpdate.H.
|
protected |
The relative update of the objective value w.r.t. to its last value should be smaller than this value to considered the run converged.
Definition at line 127 of file designVariablesUpdate.H.
|
protected |
Is at least a single convergence criterion defined.
Definition at line 132 of file designVariablesUpdate.H.
|
protected |
In case of a constrained optimisation, the sum of positive constraints should be lower than this value to consider the run converged (i.e. this tolerates some deviation from satisfying all constraints)
Definition at line 140 of file designVariablesUpdate.H.