49 const word& adjointSolverName,
50 const word& primalSolverName
57 "objectiveManager" + adjointSolverName,
67 adjointSolverName_(adjointSolverName),
68 primalSolverName_(primalSolverName),
70 weigthedObjectiveFile_(nullptr)
74 Info <<
"Constructing objective functions " <<
nl <<
endl;
77 wordList objectiveNames(objectiveNamesDict.toc());
80 forAll(objectiveNames, objectivei)
82 const word& objectiveName = objectiveNames[objectivei];
90 objectiveNamesDict.
subDict(objectiveName),
101 <<
"No objectives have been set - cannot perform an optimisation"
121 <<
setw(4) <<
"#" <<
" "
122 <<
setw(width) <<
"weightedObjective" <<
" ";
126 <<
setw(width) << objI.objectiveName() <<
" ";
141 const word& adjointSolverName,
142 const word& primalSolverName
147 const word managerType(
"objectiveManager" & objectiveType);
149 auto* ctorPtr = dictionaryConstructorTable(managerType);
156 "objectiveManagerType",
158 *dictionaryConstructorTablePtr_
192 obj.updateNormalizationFactor();
213 if (obj.isWithinIntegrationTime())
231 obj.incrementIntegrationTimes(timeSpan);
238 scalar objValue(
Zero);
242 scalar cost = obj.JCycle();
243 scalar weight = obj.weight();
244 objValue += weight*cost;
246 Info<< obj.objectiveName() <<
" : " << cost <<
endl;
249 Info<<
"Weighted objective : " << objValue <<
nl <<
endl;
257 const scalar weightedObjective,
265 obj.writeMeanValue();
273 <<
setw(width) << weightedObjective <<
" ";
278 <<
setw(width) << objI.JCycle() <<
" ";
291 scalar weightedObjective =
print();
324 if (!obj.hasIntegrationStartTime() || !obj.hasIntegrationEndTime())
327 <<
"Objective function " << obj.objectiveName()
328 <<
" does not have a defined integration start or end time "
Istream and Ostream manipulators taking arguments.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
const Time & time() const
Return Time associated with the objectRegistry.
static unsigned int defaultPrecision() noexcept
Return the default precision.
Output to file stream, using an OSstream.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
fileName globalPath() const
Return global path for the case.
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.
static word timeName(const scalar t, const int precision=precision_)
void size(const label n)
Older name for setAddressableSize.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
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.
const Time & time() const
Return the top-level database.
class for managing incompressible objective functions.
autoPtr< OFstream > weigthedObjectiveFile_
virtual bool writeObjectives(const scalar weightedObjective, const bool valid=true)
Write objective function history.
PtrList< objective > & getObjectiveFunctions()
Return reference to objective functions.
const word & adjointSolverName() const
Return name of the adjointSolver.
scalar print()
Print to screen.
void checkIntegrationTimes() const
Check integration times for unsteady runs.
PtrList< objective > objectives_
void updateOrNullify()
Update contributions to adjoint if true, otherwise return nulls.
void incrementIntegrationTimes(const scalar timeSpan)
Increment integration times by the optimisation cycle time-span.
void update()
Update objective function related values.
const word primalSolverName_
void updateNormalizationFactor()
Update objective function related values.
const word adjointSolverName_
const word & primalSolverName() const
Return name of the primalSolver.
Abstract base class for objective functions. No point in making this runTime selectable since its chi...
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
splitCell * master() const
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.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
int system(const std::string &command, const bool bg=false)
Execute the specified command via the shell.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Omanip< int > setw(const int i)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static constexpr const zero Zero
Global zero (0)
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.
#define forAll(list, i)
Loop across all elements in list.