Go to the documentation of this file.
65 if (optMethodIODict_.headerOk())
67 optMethodIODict_.readEntry(
"dxOld", dxOld_);
68 optMethodIODict_.readEntry(
"sOld", sOld_);
69 optMethodIODict_.readEntry(
"counter", counter_);
70 optMethodIODict_.readEntry(
"eta", eta_);
72 label nDVs = optMethodIODict_.get<label>(
"nDVs");
75 if (activeDesignVars_.empty())
85 Foam::conjugateGradient::conjugateGradient
99 coeffsDict().getOrDefault<word>(
"betaType",
"FletcherReeves")
104 !coeffsDict().readIfPresent(
"activeDesignVariables", activeDesignVars_)
109 Info<<
"\t Did not find explicit definition of active design variables. "
110 <<
"Treating all available ones as active " <<
endl;
116 !(betaType_ ==
"FletcherReeves")
117 && !(betaType_ ==
"PolakRibiere")
118 && !(betaType_ ==
"PolakRibiereRestarted")
122 <<
"Invalid betaType " << betaType_ <<
". Valid options are "
123 <<
"FletcherReeves, PolakRibiere, PolakRibiereRestarted"
141 Info<<
"Using steepest descent for the first iteration" <<
endl;
142 correction_ = -eta_*objectiveDerivatives_;
144 dxOld_.map(-objectiveDerivatives_, activeDesignVars_);
150 dx.
map(-objectiveDerivatives_, activeDesignVars_);
153 if (betaType_ ==
"FletcherReeves")
155 beta = globalSum(dx*dx)/globalSum(dxOld_ * dxOld_);
157 else if (betaType_ ==
"PolakRibiere")
159 beta = globalSum(dx*(dx - dxOld_))/globalSum(dxOld_ * dxOld_);
161 else if (betaType_ ==
"PolakRibiereRestarted")
167 globalSum(dx*(dx - dxOld_))/globalSum(dxOld_ * dxOld_)
169 if (
beta == scalar(0))
171 Info<<
"Computed negative beta. Resetting to zero" <<
endl;
178 forAll(activeDesignVars_, varI)
180 correction_[activeDesignVars_[varI]] = eta_*
s[varI];
197 sOld_.map(oldCorrection, activeDesignVars_);
199 correction_ = oldCorrection;
205 optMethodIODict_.add<
scalarField>(
"dxOld", dxOld_,
true);
206 optMethodIODict_.add<
scalarField>(
"sOld", sOld_,
true);
207 optMethodIODict_.add<label>(
"counter", counter_,
true);
208 optMethodIODict_.add<label>(
"nDVs", objectiveDerivatives_.size(),
true);
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
static constexpr const zero Zero
Global zero (0)
virtual void write()
Write old info to dict.
Ostream & endl(Ostream &os)
Add newline and flush stream.
#define forAll(list, i)
Loop across all elements in list.
void map(const UList< Type > &mapF, const labelUList &mapAddressing)
1 to 1 map from the given field
void computeCorrection()
Compute design variables correction.
void readFromDict()
Read old info from dict.
Abstract base class for optimisation methods.
messageStream Info
Information stream (stdout output on master, null elsewhere)
dimensionedScalar beta("beta", dimless/dimTemperature, laminarTransport)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Macros for easy insertion into run-time selection tables.
Mesh data needed to do the Finite Volume discretisation.
errorManipArg< error, int > exit(error &err, const int errNo=1)
virtual void updateOldCorrection(const scalarField &oldCorrection)
Update old correction. For use when eta has been changed externally.
virtual void write()
Write useful quantities to files.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
labelList identity(const label len, label start=0)
Create identity map of the given length with (map[i] == i)
labelList activeDesignVars_
defineTypeNameAndDebug(combustionModel, 0)
void allocateFields()
Allocate matrices in the first optimisation cycle.
scalarField objectiveDerivatives_
Derivatives of the objective functions.