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...
#include <designVariablesUpdate.H>

Public Member Functions | |
| TypeName ("designVariablesUpdate") | |
| Runtime type information. | |
| designVariablesUpdate (fvMesh &mesh, const dictionary &dict, PtrList< adjointSolverManager > &adjointSolverManagers, autoPtr< designVariables > &designVars) | |
| Construct from components. | |
| virtual | ~designVariablesUpdate ()=default |
| Destructor. | |
| void | update () |
| Update design variables. | |
| void | update (const scalarField &correction) |
| Update design variables based on a given correction. | |
| tmp< scalarField > | computeDirection () |
| Compute update direction. | |
| void | updateGradientsAndValues () |
| Compute cumulative objective and constraint gradients. | |
| scalar | computeObjectiveValue () |
| Sum objective values from all adjointSolverManagers. | |
| void | setOldObjectiveValue () |
| Set the old objective value known by the updateMethod. | |
| scalar | computeMeritFunction () |
| Compute the merit function of the optimisation problem. | |
| scalar | meritFunctionDirectionalDerivative () |
| Derivative of the merit function. | |
| void | updateOldCorrection (const scalarField &) |
| Update old correction. Needed for quasi-Newton Methods. | |
| void | write () |
| Write useful quantities to files. | |
| 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. | |
| void | checkConvergence () |
| Check if the optimisation loop has converged based on the provided criteria. | |
| autoPtr< designVariables > & | getDesignVariables () |
| Get access to design variables. | |
| autoPtr< lineSearch > & | getLineSearch () |
| Get a reference to the line search object. | |
Protected Member Functions | |
| label | nConstraints (PtrList< adjointSolverManager > &adjointSolverManagers) const |
| Get the number of adjoint solvers that correspond to constraints. | |
| label | nAdjointSolvers () const |
| Get total number of adjoint solvers. | |
| void | writeCPUcostHeader () |
| Write CPU cost header. | |
| void | writeToCostFile (bool zeroAdjointSolns=false) |
| Write to cost file. | |
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. | |
| autoPtr< lineSearch > | lineSearch_ |
| Line search mechanism to approximate the update step length. | |
| OFstream | CPUcostFile_ |
| Output file. | |
| label | nPrimalsPerCycle_ |
| Primal solutions per optimisation cycle. | |
| label | nAdjointsPerCycle_ |
| Adjoint solutions per optimisation cycle. | |
| label | nPrimalSolutions_ |
| Primal evaluations performed so far. | |
| label | nAdjointSolutions_ |
| Adjoint evaluations performed so far. | |
| scalar | CPUcost_ |
| CPU cost (in seconds). | |
| autoPtr< scalar > | designVarsThreshold_ |
| The maximum of the correction/designVariables values must be lower that this threshold to consider the run converged. | |
| 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. | |
| bool | convergenceCriteriaDefined_ |
| Is at least a single convergence criterion defined. | |
| 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). | |
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 134 of file designVariablesUpdate.C.
References adjointSolverManagers, adjointSolvManagers_, convergenceCriteriaDefined_, CPUcost_, CPUcostFile_, designVars_, designVarsThreshold_, dict, dict_, Foam::endl(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, feasibilityThreshold_, dictionary::found(), if(), Foam::Info, Foam::isA(), lineSearch_, mesh, mesh_, nAdjointSolutions_, nAdjointSolvers(), nAdjointsPerCycle_, nConstraints(), Foam::New(), Foam::nl, nPrimalSolutions_, nPrimalsPerCycle_, objectiveThreshold_, ref(), updateMethod_, WarningInFunction, and writeCPUcostHeader().

|
virtualdefault |
|
protected |
Get the number of adjoint solvers that correspond to constraints.
Definition at line 40 of file designVariablesUpdate.C.
References adjointSolverManagers, adjointSolvManagers_, designVars_, and nConstraints().
Referenced by designVariablesUpdate(), and nConstraints().


|
protected |
Get total number of adjoint solvers.
Definition at line 62 of file designVariablesUpdate.C.
References adjointSolvManagers_, Foam::isA(), and n.
Referenced by designVariablesUpdate().


|
protected |
Write CPU cost header.
Definition at line 79 of file designVariablesUpdate.C.
References CPUcostFile_, IOstream::defaultPrecision(), Foam::endl(), and Foam::setw().
Referenced by designVariablesUpdate().


|
protected |
Write to cost file.
Definition at line 94 of file designVariablesUpdate.C.
References CPUcost_, CPUcostFile_, IOstream::defaultPrecision(), Foam::endl(), lineSearch_, mesh_, nAdjointSolutions_, nAdjointsPerCycle_, nPrimalSolutions_, nPrimalsPerCycle_, and Foam::setw().
Referenced by checkConvergence(), and write().


| TypeName | ( | "designVariablesUpdate" | ) |
Runtime type information.
References adjointSolverManagers, dict, and mesh.
| void update | ( | ) |
Update design variables.
Definition at line 270 of file designVariablesUpdate.C.
References computeDirection(), Foam::correction(), designVars_, postUpdate(), tmp< T >::ref(), and setOldObjectiveValue().

| void update | ( | const scalarField & | correction | ) |
Update design variables based on a given correction.
Definition at line 288 of file designVariablesUpdate.C.
References Foam::correction(), designVars_, and lineSearch_.

| Foam::tmp< Foam::scalarField > computeDirection | ( | ) |
Compute update direction.
Definition at line 302 of file designVariablesUpdate.C.
References Foam::correction(), designVars_, tmp< T >::New(), updateGradientsAndValues(), and updateMethod_.
Referenced by update().


| void updateGradientsAndValues | ( | ) |
Compute cumulative objective and constraint gradients.
Definition at line 321 of file designVariablesUpdate.C.
References adjointSolvManagers_, designVars_, UList< T >::empty(), Foam::endl(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, forAll, DynamicList< T, SizeMin >::push_back(), PtrList< T >::push_back(), tmp< T >::ref(), PtrList< T >::set(), List< T >::setSize(), UPtrList< T >::size(), updateMethod_, and Foam::Zero.
Referenced by computeDirection().


| Foam::scalar computeObjectiveValue | ( | ) |
Sum objective values from all adjointSolverManagers.
Definition at line 396 of file designVariablesUpdate.C.
References adjointSolvManagers_, and Foam::Zero.
Referenced by checkConvergence(), and setOldObjectiveValue().

| void setOldObjectiveValue | ( | ) |
Set the old objective value known by the updateMethod.
Used to check convergence of the optimisation loop
Definition at line 408 of file designVariablesUpdate.C.
References computeObjectiveValue(), and updateMethod_.
Referenced by update().


| 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 414 of file designVariablesUpdate.C.
References adjointSolvManagers_, designVars_, DynamicList< T, SizeMin >::push_back(), updateMethod_, and Foam::Zero.

| Foam::scalar meritFunctionDirectionalDerivative | ( | ) |
Derivative of the merit function.
Definition at line 443 of file designVariablesUpdate.C.
References updateMethod_.
| void updateOldCorrection | ( | const scalarField & | oldCorrection | ) |
Update old correction. Needed for quasi-Newton Methods.
Definition at line 449 of file designVariablesUpdate.C.
References updateMethod_.
Referenced by postUpdate().

| void write | ( | ) |
Write useful quantities to files.
Definition at line 458 of file designVariablesUpdate.C.
References designVars_, updateMethod_, and writeToCostFile().

| 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 466 of file designVariablesUpdate.C.
References adjointSolvManagers_, checkConvergence(), designVars_, lineSearch_, updateOldCorrection(), and write().
Referenced by update().


| void checkConvergence | ( | ) |
Check if the optimisation loop has converged based on the provided criteria.
May terminate the program
Definition at line 495 of file designVariablesUpdate.C.
References adjointSolvManagers_, computeObjectiveValue(), convergenceCriteriaDefined_, Foam::correction(), DebugInfo, designVars_, designVarsThreshold_, Foam::endl(), UPstream::exit(), feasibilityThreshold_, Foam::gMax(), Foam::Info, Foam::mag(), Foam::nl, objectiveThreshold_, UPstream::parRun(), Foam::pos(), Foam::sum(), Foam::tab, updateMethod_, and writeToCostFile().
Referenced by postUpdate().


|
inline |
Get access to design variables.
Definition at line 286 of file designVariablesUpdate.H.
References designVars_.
|
inline |
Get a reference to the line search object.
Definition at line 294 of file designVariablesUpdate.H.
References lineSearch_.
|
protected |
Definition at line 66 of file designVariablesUpdate.H.
Referenced by designVariablesUpdate(), and writeToCostFile().
|
protected |
Definition at line 67 of file designVariablesUpdate.H.
Referenced by designVariablesUpdate().
|
protected |
Definition at line 68 of file designVariablesUpdate.H.
Referenced by checkConvergence(), computeMeritFunction(), computeObjectiveValue(), designVariablesUpdate(), nAdjointSolvers(), nConstraints(), postUpdate(), and updateGradientsAndValues().
|
protected |
Definition at line 69 of file designVariablesUpdate.H.
Referenced by checkConvergence(), computeDirection(), computeMeritFunction(), designVariablesUpdate(), getDesignVariables(), nConstraints(), postUpdate(), update(), update(), updateGradientsAndValues(), and write().
|
protected |
Method to update the design variables based on the provided sensitivity derivatives.
Definition at line 75 of file designVariablesUpdate.H.
Referenced by checkConvergence(), computeDirection(), computeMeritFunction(), designVariablesUpdate(), meritFunctionDirectionalDerivative(), setOldObjectiveValue(), updateGradientsAndValues(), updateOldCorrection(), and write().
|
protected |
Line search mechanism to approximate the update step length.
Definition at line 80 of file designVariablesUpdate.H.
Referenced by designVariablesUpdate(), getLineSearch(), postUpdate(), update(), and writeToCostFile().
|
protected |
Output file.
Definition at line 87 of file designVariablesUpdate.H.
Referenced by designVariablesUpdate(), writeCPUcostHeader(), and writeToCostFile().
|
protected |
Primal solutions per optimisation cycle.
Definition at line 92 of file designVariablesUpdate.H.
Referenced by designVariablesUpdate(), and writeToCostFile().
|
protected |
Adjoint solutions per optimisation cycle.
Definition at line 97 of file designVariablesUpdate.H.
Referenced by designVariablesUpdate(), and writeToCostFile().
|
protected |
Primal evaluations performed so far.
Definition at line 102 of file designVariablesUpdate.H.
Referenced by designVariablesUpdate(), and writeToCostFile().
|
protected |
Adjoint evaluations performed so far.
Definition at line 107 of file designVariablesUpdate.H.
Referenced by designVariablesUpdate(), and writeToCostFile().
|
protected |
CPU cost (in seconds).
Definition at line 112 of file designVariablesUpdate.H.
Referenced by designVariablesUpdate(), and writeToCostFile().
|
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.
Referenced by checkConvergence(), and designVariablesUpdate().
|
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.
Referenced by checkConvergence(), and designVariablesUpdate().
|
protected |
Is at least a single convergence criterion defined.
Definition at line 132 of file designVariablesUpdate.H.
Referenced by checkConvergence(), and designVariablesUpdate().
|
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.
Referenced by checkConvergence(), and designVariablesUpdate().