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

Collaboration diagram for designVariablesUpdate:

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

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

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

Here is the call graph for this function:

◆ ~designVariablesUpdate()

virtual ~designVariablesUpdate ( )
virtualdefault

Destructor.

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 41 of file designVariablesUpdate.C.

◆ nAdjointSolvers()

Foam::label nAdjointSolvers ( ) const
protected

Get total number of adjoint solvers.

Definition at line 62 of file designVariablesUpdate.C.

References designVariablesUpdate::adjointSolvManagers_, and n.

◆ writeCPUcostHeader()

void writeCPUcostHeader ( )
protected

Write CPU cost header.

Definition at line 79 of file designVariablesUpdate.C.

References IOstream::defaultPrecision(), Foam::endl(), and Foam::setw().

Here is the call graph for this function:

◆ writeToCostFile()

void writeToCostFile ( bool  zeroAdjointSolns = false)
protected

Write to cost file.

Definition at line 94 of file designVariablesUpdate.C.

References IOstream::defaultPrecision(), Foam::endl(), and Foam::setw().

Here is the call graph for this function:

◆ checkConvergence()

void checkConvergence ( const scalarField oldCorrection)
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.

Here is the call graph for this function:

◆ TypeName()

TypeName ( "designVariablesUpdate"  )

Runtime type information.

◆ update() [1/2]

void update ( )

Update design variables.

Definition at line 346 of file designVariablesUpdate.C.

References Foam::correction(), and tmp< T >::ref().

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 364 of file designVariablesUpdate.C.

References Foam::correction().

Here is the call graph for this function:

◆ computeDirection()

Foam::tmp< Foam::scalarField > computeDirection ( )

Compute update direction.

Definition at line 378 of file designVariablesUpdate.C.

References Foam::correction(), and tmp< T >::New().

Here is the call graph for this function:

◆ updateGradientsAndValues()

void updateGradientsAndValues ( )

◆ computeObjectiveValue()

Foam::scalar computeObjectiveValue ( )

Sum objective values from all adjointSolverManagers.

Definition at line 472 of file designVariablesUpdate.C.

References Foam::Zero.

◆ setOldObjectiveValue()

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.

◆ 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 490 of file designVariablesUpdate.C.

References DynamicList< T, SizeMin >::push_back(), and Foam::Zero.

Here is the call graph for this function:

◆ meritFunctionDirectionalDerivative()

Foam::scalar meritFunctionDirectionalDerivative ( )

Derivative of the merit function.

Definition at line 519 of file designVariablesUpdate.C.

◆ updateOldCorrection()

void updateOldCorrection ( const scalarField oldCorrection)

Update old correction. Needed for quasi-Newton Methods.

Definition at line 526 of file designVariablesUpdate.C.

◆ write()

void write ( )

Write useful quantities to files.

Definition at line 534 of file designVariablesUpdate.C.

◆ 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 542 of file designVariablesUpdate.C.

References Foam::vtk::write().

Here is the call graph for this function:

◆ getDesignVariables()

autoPtr<designVariables>& getDesignVariables ( )
inline

Get access to design variables.

Definition at line 286 of file designVariablesUpdate.H.

References designVariablesUpdate::designVars_.

◆ getLineSearch()

autoPtr<lineSearch>& getLineSearch ( )
inline

Get a reference to the line search object.

Definition at line 294 of file designVariablesUpdate.H.

References designVariablesUpdate::lineSearch_.

Member Data Documentation

◆ mesh_

fvMesh& mesh_
protected

Definition at line 66 of file designVariablesUpdate.H.

◆ dict_

const dictionary dict_
protected

Definition at line 67 of file designVariablesUpdate.H.

◆ adjointSolvManagers_

PtrList<adjointSolverManager>& adjointSolvManagers_
protected

Definition at line 68 of file designVariablesUpdate.H.

Referenced by designVariablesUpdate::nAdjointSolvers().

◆ designVars_

autoPtr<designVariables>& designVars_
protected

Definition at line 69 of file designVariablesUpdate.H.

Referenced by designVariablesUpdate::getDesignVariables().

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

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

◆ CPUcostFile_

OFstream CPUcostFile_
protected

Output file.

Definition at line 87 of file designVariablesUpdate.H.

◆ nPrimalsPerCycle_

label nPrimalsPerCycle_
protected

Primal solutions per optimisation cycle.

Definition at line 92 of file designVariablesUpdate.H.

◆ nAdjointsPerCycle_

label nAdjointsPerCycle_
protected

Adjoint solutions per optimisation cycle.

Definition at line 97 of file designVariablesUpdate.H.

◆ nPrimalSolutions_

label nPrimalSolutions_
protected

Primal evaluations performed so far.

Definition at line 102 of file designVariablesUpdate.H.

◆ nAdjointSolutions_

label nAdjointSolutions_
protected

Adjoint evaluations performed so far.

Definition at line 107 of file designVariablesUpdate.H.

◆ CPUcost_

scalar CPUcost_
protected

CPU cost (in seconds)

Definition at line 112 of file designVariablesUpdate.H.

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

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

◆ convergenceCriteriaDefined_

bool convergenceCriteriaDefined_
protected

Is at least a single convergence criterion defined.

Definition at line 132 of file designVariablesUpdate.H.

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


The documentation for this class was generated from the following files: