49 void Foam::steadyOptimisation::updateOptTypeSource()
58 PtrList<adjointSolver>& adjointSolvers =
63 adjointSolvers[aI].updateOptTypeSource(
optType_->sourcePtr());
74 tmp<scalarField> tdirection = optType_->computeDirection();
78 autoPtr<lineSearch>& lineSrch = optType_->getLineSearch();
81 optType_->storeDesignVariables();
84 scalar meritFunction = optType_->computeMeritFunction();
85 lineSrch->setOldMeritValue(meritFunction);
88 const scalar dirDerivative =
89 optType_->meritFunctionDirectionalDerivative();
90 lineSrch->setDeriv(dirDerivative);
98 for (label iter = 0; iter < lineSrch->maxIters(); ++iter)
100 Info<<
"\n- - - - - - - - - - - - - - -" <<
endl;
101 Info<<
"Line search iteration " << iter <<
endl;
102 Info<<
"- - - - - - - - - - - - - - -\n" <<
endl;
109 solvePrimalEquations();
112 meritFunction = optType_->computeMeritFunction();
113 lineSrch->setNewMeritValue(meritFunction);
115 if (lineSrch->converged())
118 Info<<
"Line search converged in " << iter + 1
119 <<
" iterations." <<
endl;
121 optType_->updateOldCorrection(scaledCorrection);
129 if (iter == lineSrch->maxIters() - 1)
131 Info<<
"Line search reached max. number of iterations.\n" 132 <<
"Proceeding to the next optimisation cycle" <<
endl;
134 optType_->updateOldCorrection(scaledCorrection);
141 optType_->resetDesignVariables();
142 lineSrch->updateStep();
155 solvePrimalEquations();
161 Foam::steadyOptimisation::steadyOptimisation(
fvMesh&
mesh)
177 updateOptTypeSource();
188 Info<<
"\n* * * * * * * * * * * * * * * * *" <<
endl;
189 Info<<
"Optimisation cycle " << time_.value() <<
endl;
190 Info<<
"* * * * * * * * * * * * * * * * *\n" <<
endl;
220 return (time_.timeIndex() != 1 && !
end());
228 if (optType_->getLineSearch())
238 for (adjointSolverManager& adjSolverManager : adjointSolverManagers_)
240 adjSolverManager.clearSensitivities();
virtual bool update()
Whether to update the design variables.
PtrList< adjointSolverManager > adjointSolverManagers_
virtual bool checkEndOfLoopAndUpdate()
Return true if end of optimisation run.
Abstract base class for optimisation methods.
autoPtr< incompressible::optimisationType > optType_
void lineSearchUpdate()
Update design variables using a line-search.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static autoPtr< optimisationType > New(fvMesh &mesh, const dictionary &dict, PtrList< adjointSolverManager > &adjointSolverManagers)
Return a reference to the selected turbulence model.
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Macros for easy insertion into run-time selection tables.
PtrList< primalSolver > primalSolvers_
#define forAll(list, i)
Loop across all elements in list.
virtual optimisationManager & operator++()
Prefix increment.
void fixedStepUpdate()
Update design variables using a fixed step.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
virtual bool end()
Return true if end of optimisation run.
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
defineTypeNameAndDebug(combustionModel, 0)
virtual void updateDesignVariables()
Do a line search to find a correction satisfying the step convergence criteria.
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Mesh data needed to do the Finite Volume discretisation.
messageStream Info
Information stream (stdout output on master, null elsewhere)