49void Foam::steadyOptimisation::updateOptTypeSource()
58 PtrList<adjointSolver>& adjointSolvers =
63 adjointSolvers[aI].updateOptTypeSource(
optType_->sourcePtr());
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();
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())
240 adjSolverManager.clearSensitivities();
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Class for managing adjoint solvers, which may be more than one per operating point.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
void reset(autoPtr< T > &&other) noexcept
Delete managed object and set to new given pointer.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Mesh data needed to do the Finite Volume discretisation.
Abstract base class for optimisation methods.
autoPtr< incompressible::optimisationType > optType_
PtrList< adjointSolverManager > adjointSolverManagers_
PtrList< primalSolver > primalSolvers_
Iterate the optimisation cycles. For steady state opt, this coinsides with evolving Time.
virtual optimisationManager & operator++()
Prefix increment.
virtual void updateDesignVariables()
virtual bool update()
Whether to update the design variables.
virtual bool checkEndOfLoopAndUpdate()
Return true if end of optimisation run.
void lineSearchUpdate()
Update design variables using a line-search.
virtual bool end()
Return true if end of optimisation run.
void fixedStepUpdate()
Update design variables using a fixed step.
A class for managing temporary objects.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
#define forAll(list, i)
Loop across all elements in list.