Go to the documentation of this file.
44 objectiveManager::objectiveManager
48 const word& adjointSolverName,
49 const word& primalSolverName
56 "objectiveManager" + adjointSolverName,
66 adjointSolverName_(adjointSolverName),
67 primalSolverName_(primalSolverName),
72 Info <<
"Constructing objective functions " <<
nl <<
endl;
75 wordList objectiveNames(objectiveNamesDict.toc());
76 objectives_.
setSize(objectiveNames.size());
78 forAll(objectiveNames, objectivei)
80 const word& objectiveName = objectiveNames[objectivei];
88 objectiveNamesDict.subDict(objectiveName),
96 if (objectives_.empty())
99 <<
"No objectives have been set - cannot perform an optimisation"
111 const word& adjointSolverName,
112 const word& primalSolverName
117 const word managerType(
"objectiveManager" & objectiveType);
119 auto cstrIter = dictionaryConstructorTablePtr_->cfind(managerType);
121 if (!cstrIter.found())
126 "objectiveManagerType",
128 *dictionaryConstructorTablePtr_
134 cstrIter()(
mesh,
dict, adjointSolverName, primalSolverName)
147 dict.subDict(
"objectiveNames").subDict(obj.objectiveName())
162 obj.updateNormalizationFactor();
183 if (obj.isWithinIntegrationTime())
201 obj.incrementIntegrationTimes(timeSpan);
208 scalar objValue(
Zero);
211 scalar cost = obj.JCycle();
212 scalar weight = obj.weight();
213 objValue += weight*cost;
215 Info<< obj.type() <<
" : " << cost <<
endl;
218 Info<<
"Objective function manager" <<
nl
219 <<
" Weighted Lagrangian " <<
" : " << objValue <<
nl <<
endl;
231 obj.writeMeanValue();
275 if (!obj.hasIntegrationStartTime() || !obj.hasIntegrationEndTime())
278 <<
"Objective function " << obj.objectiveName()
279 <<
" does not have a defined integration start or end time "
void updateNormalizationFactor()
Update objective function related values.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
const word & primalSolverName() const
Return name of the primalSolver.
A class for handling words, derived from Foam::string.
static autoPtr< dictionary > New(Istream &is)
Construct top-level dictionary on freestore from Istream.
scalar print()
Print to screen.
static constexpr const zero Zero
Global zero (0)
PtrList< objective > objectives_
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
virtual bool readDict(const dictionary &dict)
void update()
Update objective function related values.
Ostream & endl(Ostream &os)
Add newline and flush stream.
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
#define forAll(list, i)
Loop across all elements in list.
virtual bool write(const bool valid=true) const
Write objective function history.
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
void incrementIntegrationTimes(const scalar timeSpan)
Increment integration times by the optimisation cycle time-span.
messageStream Info
Information stream (uses stdout - output is on the master only)
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
const word primalSolverName_
Mesh data needed to do the Finite Volume discretisation.
errorManipArg< error, int > exit(error &err, const int errNo=1)
const word adjointSolverName_
void checkIntegrationTimes() const
Check integration times for unsteady runs.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
const word & system() const
Return system name.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
static autoPtr< objectiveManager > New(const fvMesh &mesh, const dictionary &dict, const word &adjointSolverName, const word &primalSolverName)
Return a reference to the selected turbulence model.
const Time & time() const
Return the top-level database.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
void updateOrNullify()
Update contributions to adjoint if true, otherwise return nulls.
const word & adjointSolverName() const
Return name of the adjointSolver.
void setSize(const label newSize)
Alias for resize(const label)
Abstract base class for objective functions. No point in making this runTime selectable since its chi...
defineTypeNameAndDebug(combustionModel, 0)
PtrList< objective > & getObjectiveFunctions()
Return reference to objective functions.