conjugateGradient Class Reference

The Conjugate Gradient formula. More...

Inheritance diagram for conjugateGradient:
[legend]
Collaboration diagram for conjugateGradient:
[legend]

Public Member Functions

 TypeName ("conjugateGradient")
 Runtime type information. More...
 
 conjugateGradient (const fvMesh &mesh, const dictionary &dict)
 Construct from components. More...
 
virtual ~conjugateGradient ()=default
 Destructor. More...
 
void computeCorrection ()
 Compute design variables correction. More...
 
virtual void updateOldCorrection (const scalarField &oldCorrection)
 Update old correction. For use when eta has been changed externally. More...
 
virtual void write ()
 Write old info to dict. More...
 
- Public Member Functions inherited from updateMethod
 TypeName ("updateMethod")
 Runtime type information. More...
 
 declareRunTimeSelectionTable (autoPtr, updateMethod, dictionary,(const fvMesh &mesh, const dictionary &dict),(mesh, dict))
 
 updateMethod (const fvMesh &mesh, const dictionary &dict)
 Construct from components. More...
 
virtual ~updateMethod ()=default
 Destructor. More...
 
void setObjectiveDeriv (const scalarField &derivs)
 Set objective derivative. More...
 
void setConstraintDeriv (const PtrList< scalarField > &derivs)
 Set constraints derivative. More...
 
void setObjectiveValue (const scalar value)
 Set constraints derivative. More...
 
void setConstraintValues (const scalarField &values)
 Set constraints derivative. More...
 
void setStep (const scalar eta)
 Set step for optimisation methods. More...
 
void setGlobalSum (const bool useGlobalSum)
 Set globalSum variable. More...
 
virtual void computeCorrection ()=0
 Return the correction of the design variables. More...
 
scalarFieldreturnCorrection ()
 Return the correction of the design variables. More...
 
void writeCorrection ()
 
virtual scalar computeMeritFunction ()
 
virtual scalar meritFunctionDirectionalDerivative ()
 
boolinitialEtaSet ()
 Return whether initial eta was set. More...
 
virtual void updateOldCorrection (const scalarField &oldCorrection)
 
virtual void write ()
 Write useful quantities to files. More...
 

Protected Member Functions

void allocateFields ()
 Allocate matrices in the first optimisation cycle. More...
 
void readFromDict ()
 Read old info from dict. More...
 
- Protected Member Functions inherited from updateMethod
const scalarField leftMult (const scalarField &, const SquareMatrix< scalar > &)
 
const scalarField rightMult (const SquareMatrix< scalar > &, const scalarField &)
 
SquareMatrix< scalar > outerProd (const scalarField &, const scalarField &)
 
SquareMatrix< scalar > inv (SquareMatrix< scalar > A)
 
scalar globalSum (const scalarField &field)
 Compute either global or local sum, based on globalSum flag. More...
 
scalar globalSum (tmp< scalarField > &tfield)
 Compute either global or local sum, based on globalSum flag. More...
 
dictionary coeffsDict ()
 Return optional dictionary with parameters specific to each method. More...
 

Protected Attributes

labelList activeDesignVars_
 
scalarField dxOld_
 
scalarField sOld_
 
label counter_
 
word betaType_
 
- Protected Attributes inherited from updateMethod
const fvMeshmesh_
 
const dictionary dict_
 
IOdictionary optMethodIODict_
 Used to output values useful for continuation runs. More...
 
scalarField objectiveDerivatives_
 Derivatives of the objective functions. More...
 
PtrList< scalarFieldconstraintDerivatives_
 Derivatives of the constraints. More...
 
scalar objectiveValue_
 Objective value. More...
 
scalarField cValues_
 Constraint values. More...
 
scalarField correction_
 Design variables correction. More...
 
scalarField cumulativeCorrection_
 
scalar eta_
 Step multiplying the correction. More...
 
bool initialEtaSet_
 Is initially set? More...
 
word correctionFolder_
 Folder storing the corrections to file. More...
 
bool globalSum_
 Whether to use gSum or sum in the inner products. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from updateMethod
static autoPtr< updateMethodNew (const fvMesh &mesh, const dictionary &dict)
 Return a reference to the selected turbulence model. More...
 

Detailed Description

The Conjugate Gradient formula.

Beta computed from Fletcher-Reeves or Polak-Ribiere approaches. Polak-Ribiere seems to misbehave. Not tested with line search.

Source files

Definition at line 57 of file conjugateGradient.H.

Constructor & Destructor Documentation

◆ conjugateGradient()

conjugateGradient ( const fvMesh mesh,
const dictionary dict 
)

Construct from components.

Definition at line 85 of file conjugateGradient.C.

References conjugateGradient::activeDesignVars_, conjugateGradient::betaType_, updateMethod::coeffsDict(), Foam::endl(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, Foam::Info, Foam::nl, conjugateGradient::readFromDict(), and readIfPresent().

Here is the call graph for this function:

◆ ~conjugateGradient()

virtual ~conjugateGradient ( )
virtualdefault

Destructor.

Member Function Documentation

◆ allocateFields()

void allocateFields ( )
protected

Allocate matrices in the first optimisation cycle.

Definition at line 49 of file conjugateGradient.C.

References conjugateGradient::activeDesignVars_, conjugateGradient::dxOld_, UList< T >::empty(), Foam::identity(), updateMethod::objectiveDerivatives_, UList< T >::size(), conjugateGradient::sOld_, and Foam::Zero.

Here is the call graph for this function:

◆ readFromDict()

void readFromDict ( )
protected

Read old info from dict.

Definition at line 63 of file conjugateGradient.C.

References Foam::identity(), and Foam::Zero.

Referenced by conjugateGradient::conjugateGradient().

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

◆ TypeName()

TypeName ( "conjugateGradient"  )

Runtime type information.

◆ computeCorrection()

void computeCorrection ( )
virtual

Compute design variables correction.

Implements updateMethod.

Definition at line 135 of file conjugateGradient.C.

References beta(), Foam::endl(), forAll, Foam::Info, Field< Type >::map(), Foam::max(), s(), and Foam::Zero.

Here is the call graph for this function:

◆ updateOldCorrection()

void updateOldCorrection ( const scalarField oldCorrection)
virtual

Update old correction. For use when eta has been changed externally.

Reimplemented from updateMethod.

Definition at line 192 of file conjugateGradient.C.

◆ write()

void write ( )
virtual

Write old info to dict.

Reimplemented from updateMethod.

Definition at line 203 of file conjugateGradient.C.

References updateMethod::write().

Here is the call graph for this function:

Member Data Documentation

◆ activeDesignVars_

labelList activeDesignVars_
protected

◆ dxOld_

scalarField dxOld_
protected

Definition at line 66 of file conjugateGradient.H.

Referenced by conjugateGradient::allocateFields().

◆ sOld_

scalarField sOld_
protected

Definition at line 67 of file conjugateGradient.H.

Referenced by conjugateGradient::allocateFields().

◆ counter_

label counter_
protected

Definition at line 68 of file conjugateGradient.H.

◆ betaType_

word betaType_
protected

Definition at line 69 of file conjugateGradient.H.

Referenced by conjugateGradient::conjugateGradient().


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