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_
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
Defines the attributes of an object for which implicit objectRegistry management is supported,...
The IOstreamOption is a simple container for options an IOstream can normally have.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
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 & optionalSubDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary, otherwise return this dictionary.
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Abstract base class for line search methods.
label maxIters() const
Get max number of iterations.
const dictionary & coeffsDict()
Optional coeffs dict.
virtual void setDeriv(const scalar deriv)
Set objective derivative.
void setOldMeritValue(const scalar value)
Set old objective value.
scalar step() const
Get current step.
void setNewMeritValue(const scalar value)
Set new objective value.
const dictionary dict_
Subdict within updateMethod.
virtual void updateStep()=0
virtual lineSearch & operator++()
virtual void reset()
Reset step to initial value.
void setDirection(const scalarField &direction)
Set direction.
Abstract base class for step update methods used in line search.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
messageStream Info
Information stream (stdout output on master, null elsewhere)
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Ostream & endl(Ostream &os)
Add newline and flush stream.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
static constexpr const zero Zero
Global zero (0)
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
errorManipArg< error, int > exit(error &err, const int errNo=1)
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.