68 directionalDeriv_(
Zero),
74 lineSearchDict_.getOrDefault<scalar>(
"prevMeritDeriv",
Zero)
76 initialStep_(
dict.getOrDefault<scalar>(
"initialStep", 1.)),
77 minStep_(
dict.getOrDefault<scalar>(
"minStep", 0.3)),
79 iter_(lineSearchDict_.getOrDefault<label>(
"iter", 0)),
80 maxIters_(
dict.getOrDefault<label>(
"maxIters", 4)),
81 extrapolateInitialStep_
83 dict.getOrDefault<bool>
85 "extrapolateInitialStep",
105 Info<<
"lineSearch type : " << modelType <<
endl;
107 if (modelType !=
"none")
109 auto* ctorPtr = dictionaryConstructorTable(modelType);
118 *dictionaryConstructorTablePtr_
122 lineSrch.reset((ctorPtr(
dict, time)).ptr());
126 Info<<
"No line search method specified. " 127 <<
"Proceeding with constant step" <<
endl;
138 directionalDeriv_ = deriv;
139 stepUpdate_->setDeriv(deriv);
151 newMeritValue_ = value;
152 stepUpdate_->setNewMeritValue(value);
158 oldMeritValue_ = value;
159 stepUpdate_->setOldMeritValue(value);
165 if (extrapolateInitialStep_ && iter_ != 0)
170 step_ =
max(
min(step_*prevMeritDeriv_/directionalDeriv_, 1.), minStep_);
171 Info<<
"\n------- Computing initial step-------" <<
endl;
172 Info<<
"old dphi(0) " << prevMeritDeriv_ <<
endl;
173 Info<<
"dphi(0) " << directionalDeriv_ <<
endl;
174 Info<<
"Setting initial step value " << step_ <<
endl <<
endl;
178 step_ = initialStep_;
204 prevMeritDeriv_ = directionalDeriv_;
205 lineSearchDict_.add<scalar>(
"prevMeritDeriv", prevMeritDeriv_,
true);
206 lineSearchDict_.add<label>(
"iter", iter_,
true);
207 lineSearchDict_.regIOobject::writeObject
void setDirection(const scalarField &direction)
Set direction.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A list of keyword definitions, which are a keyword followed by a number of values (eg...
virtual void updateStep()=0
Update the line search step based on the specific line search strategy, e.g. bisection, quadratic fit, etc.
const dictionary dict_
Subdict within updateMethod.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
const dictionary & coeffsDict()
Optional coeffs dict.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static autoPtr< lineSearch > New(const dictionary &dict, const Time &time)
Return a reference to the selected turbulence model.
A simple container for options an IOstream can normally have.
void setNewMeritValue(const scalar value)
Set new objective value.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
virtual void setDeriv(const scalar deriv)
Set objective derivative.
const dictionary & optionalSubDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary, otherwise return this dictionary.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
A class for handling words, derived from Foam::string.
void setOldMeritValue(const scalar value)
Set old objective value.
virtual lineSearch & operator++()
Increment iteration number and store merit value corresponding to the previous optimisation cycle...
virtual void reset()
Reset step to initial value.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
defineTypeNameAndDebug(combustionModel, 0)
scalar step() const
Get current step.
Abstract base class for line search methods.
Abstract base class for step update methods used in line search.
messageStream Info
Information stream (stdout output on master, null elsewhere)
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
Defines the attributes of an object for which implicit objectRegistry management is supported...
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
label maxIters() const
Get max number of iterations.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
static constexpr const zero Zero
Global zero (0)