Loading...
Searching...
No Matches
designVariablesUpdate Class Reference

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>

Collaboration diagram for designVariablesUpdate:

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< scalarFieldcomputeDirection ()
 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

fvMeshmesh_
const dictionary dict_
PtrList< adjointSolverManager > & adjointSolvManagers_
autoPtr< designVariables > & designVars_
autoPtr< updateMethodupdateMethod_
 Method to update the design variables based on the provided sensitivity derivatives.
autoPtr< lineSearchlineSearch_
 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).

Detailed Description

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.

Source files

Definition at line 60 of file designVariablesUpdate.H.

Constructor & Destructor Documentation

◆ designVariablesUpdate()

◆ ~designVariablesUpdate()

virtual ~designVariablesUpdate ( )
virtualdefault

Destructor.

References Foam::correction().

Here is the call graph for this function:

Member Function Documentation

◆ nConstraints()

Foam::label nConstraints ( PtrList< adjointSolverManager > & adjointSolverManagers) const
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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nAdjointSolvers()

Foam::label nAdjointSolvers ( ) const
protected

Get total number of adjoint solvers.

Definition at line 62 of file designVariablesUpdate.C.

References adjointSolvManagers_, Foam::isA(), and n.

Referenced by designVariablesUpdate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeCPUcostHeader()

void writeCPUcostHeader ( )
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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeToCostFile()

void writeToCostFile ( bool zeroAdjointSolns = false)
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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TypeName()

TypeName ( "designVariablesUpdate" )

Runtime type information.

References adjointSolverManagers, dict, and mesh.

◆ update() [1/2]

void update ( )

Update design variables.

Definition at line 270 of file designVariablesUpdate.C.

References computeDirection(), Foam::correction(), designVars_, postUpdate(), tmp< T >::ref(), and setOldObjectiveValue().

Here is the call graph for this function:

◆ update() [2/2]

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_.

Here is the call graph for this function:

◆ computeDirection()

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateGradientsAndValues()

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ computeObjectiveValue()

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().

Here is the caller graph for this function:

◆ 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ computeMeritFunction()

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.

Here is the call graph for this function:

◆ meritFunctionDirectionalDerivative()

Foam::scalar meritFunctionDirectionalDerivative ( )

Derivative of the merit function.

Definition at line 443 of file designVariablesUpdate.C.

References updateMethod_.

◆ updateOldCorrection()

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().

Here is the caller graph for this function:

◆ write()

void write ( )

Write useful quantities to files.

Definition at line 458 of file designVariablesUpdate.C.

References designVars_, updateMethod_, and writeToCostFile().

Here is the call graph for this function:

◆ postUpdate()

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkConvergence()

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDesignVariables()

autoPtr< designVariables > & getDesignVariables ( )
inline

Get access to design variables.

Definition at line 286 of file designVariablesUpdate.H.

References designVars_.

◆ getLineSearch()

autoPtr< lineSearch > & getLineSearch ( )
inline

Get a reference to the line search object.

Definition at line 294 of file designVariablesUpdate.H.

References lineSearch_.

Member Data Documentation

◆ mesh_

fvMesh& mesh_
protected

Definition at line 66 of file designVariablesUpdate.H.

Referenced by designVariablesUpdate(), and writeToCostFile().

◆ dict_

const dictionary dict_
protected

Definition at line 67 of file designVariablesUpdate.H.

Referenced by designVariablesUpdate().

◆ adjointSolvManagers_

◆ designVars_

◆ updateMethod_

autoPtr<updateMethod> updateMethod_
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().

◆ lineSearch_

autoPtr<lineSearch> lineSearch_
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().

◆ CPUcostFile_

OFstream CPUcostFile_
protected

Output file.

Definition at line 87 of file designVariablesUpdate.H.

Referenced by designVariablesUpdate(), writeCPUcostHeader(), and writeToCostFile().

◆ nPrimalsPerCycle_

label nPrimalsPerCycle_
protected

Primal solutions per optimisation cycle.

Definition at line 92 of file designVariablesUpdate.H.

Referenced by designVariablesUpdate(), and writeToCostFile().

◆ nAdjointsPerCycle_

label nAdjointsPerCycle_
protected

Adjoint solutions per optimisation cycle.

Definition at line 97 of file designVariablesUpdate.H.

Referenced by designVariablesUpdate(), and writeToCostFile().

◆ nPrimalSolutions_

label nPrimalSolutions_
protected

Primal evaluations performed so far.

Definition at line 102 of file designVariablesUpdate.H.

Referenced by designVariablesUpdate(), and writeToCostFile().

◆ nAdjointSolutions_

label nAdjointSolutions_
protected

Adjoint evaluations performed so far.

Definition at line 107 of file designVariablesUpdate.H.

Referenced by designVariablesUpdate(), and writeToCostFile().

◆ CPUcost_

scalar CPUcost_
protected

CPU cost (in seconds).

Definition at line 112 of file designVariablesUpdate.H.

Referenced by designVariablesUpdate(), and writeToCostFile().

◆ designVarsThreshold_

autoPtr<scalar> designVarsThreshold_
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().

◆ objectiveThreshold_

autoPtr<scalar> objectiveThreshold_
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().

◆ convergenceCriteriaDefined_

bool convergenceCriteriaDefined_
protected

Is at least a single convergence criterion defined.

Definition at line 132 of file designVariablesUpdate.H.

Referenced by checkConvergence(), and designVariablesUpdate().

◆ feasibilityThreshold_

scalar feasibilityThreshold_
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().


The documentation for this class was generated from the following files:
  • src/optimisation/adjointOptimisation/adjoint/optimisation/optimisationManager/optimisationManager/designVariablesUpdate/designVariablesUpdate.H
  • src/optimisation/adjointOptimisation/adjoint/optimisation/optimisationManager/optimisationManager/designVariablesUpdate/designVariablesUpdate.C