Go to the documentation of this file.
45 void objective::makeFolder()
51 time.globalPath()/
"optimisation"/
type()/time.timeName();
105 const word& adjointSolverName,
106 const word& primalSolverName
111 adjointSolverName_(adjointSolverName),
112 primalSolverName_(primalSolverName),
114 computeMeanFields_(
false),
121 integrationStartTimePtr_(
nullptr),
122 integrationEndTimePtr_(
nullptr),
130 bdSdbMultPtr_(
nullptr),
131 bdndbMultPtr_(
nullptr),
132 bdxdbMultPtr_(
nullptr),
133 bdxdbDirectMultPtr_(
nullptr),
134 bEdgeContribution_(
nullptr),
135 bdJdStressPtr_(
nullptr),
136 divDxDbMultPtr_(
nullptr),
137 gradDxDbMultPtr_(
nullptr),
139 objFunctionFolder_(
"word"),
140 objFunctionFilePtr_(
nullptr),
141 instantValueFilePtr_(
nullptr),
142 meanValueFilePtr_(
nullptr)
149 integrationStartTimePtr_.reset
151 new scalar(
dict.
get<scalar>(
"integrationStartTime"))
156 integrationEndTimePtr_.reset
158 new scalar(
dict.
get<scalar>(
"integrationEndTime"))
165 "objectiveDict" + objectiveName_,
166 mesh_.time().timeName(),
172 if (headObjectiveIODict.typeHeaderOk<
IOdictionary>(
false))
185 const word& objectiveType,
186 const word& adjointSolverName,
187 const word& primalSolverName
190 auto cstrIter = objectiveConstructorTablePtr_->cfind(objectiveType);
192 if (!cstrIter.found())
199 *objectiveConstructorTablePtr_
251 if (iAverageIter == 0)
255 scalar avIter(iAverageIter);
256 scalar oneOverItP1 = 1./(avIter + 1);
257 scalar mult = avIter*oneOverItP1;
272 const scalar denom = elapsedTime + dt;
279 <<
"Unallocated integration start or end time"
305 <<
"Unallocated integration start or end time"
322 <<
"Unallocated integration start or end time"
335 createZeroFieldPtr<scalar>
404 if (bdxdbDirectMultPtr_.empty())
407 <<
"Unallocated boundaryEdgeMultiplier field"
410 return bEdgeContribution_()[patchI][edgeI];
479 <<
"Unallocated boundaryEdgeMultiplier field"
504 createZeroFieldPtr<scalar>
525 createZeroFieldPtr<tensor>
665 objectiveDict.
add<scalar>(
"JMean",
JMean_);
666 objectiveDict.regIOobject::write();
virtual void nullify()
Nullify adjoint contributions.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
autoPtr< boundaryVectorField > bdxdbDirectMultPtr_
Defines the attributes of an object for which implicit objectRegistry management is supported,...
autoPtr< boundaryVectorField > bdJdbPtr_
Term from material derivative.
const vectorField3 & boundaryEdgeMultiplier()
Multiplier located at patch boundary edges.
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Dimensionless.
bool hasBoundaryEdgeContribution() const
bool doAverageIter() const
autoPtr< scalar > integrationStartTimePtr_
autoPtr< volTensorField > gradDxDbMultPtr_
Emerging from volume objectives that include spatial derivatives.
A class for handling words, derived from Foam::string.
autoPtr< boundaryTensorField > bdJdStressPtr_
For use with discrete-like sensitivities.
dimensionedScalar deltaT() const
Return time step.
const word objectiveName_
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
dimensionSet pow2(const dimensionSet &ds)
static constexpr const zero Zero
Global zero.
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search for an entry (const access) with the given keyword.
const boundaryVectorField & dndbMultiplier()
Multiplier of delta(n dS)/delta b for all patches.
const boundaryVectorField & dxdbDirectMultiplier()
Multiplier of delta(x)/delta b for all patches.
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
static autoPtr< objective > New(const fvMesh &mesh, const dictionary &dict, const word &objectiveType, const word &adjointSolverName, const word &primalSolverName)
Return a reference to the selected turbulence model.
void setInstantValueFilePtr() const
Set the output file ptr for the instantaneous value.
static word timeName(const scalar t, const int precision=precision_)
autoPtr< boundaryVectorField > bdxdbMultPtr_
Term multiplying delta(x)/delta b at the boundary.
void setObjectiveFilePtr() const
Set the output file ptr.
Base class for solver control classes.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const Type & value() const
Return const reference to value.
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Dimension set for the base types.
virtual void updateNormalizationFactor()
autoPtr< OFstream > objFunctionFilePtr_
File to keep the objective values after the end of the primal solver.
void setMeanValueFilePtr() const
Set the output file ptr for the mean value.
const word adjointSolverName_
virtual void writeMeanValue() const
Write mean objective function history.
virtual void writeInstantaneousValue() const
Write objective function history at each primal solver iteration.
autoPtr< volScalarField > dJdbPtr_
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
bool hasIntegrationStartTime() const
bool hasIntegrationEndTime() const
bool hasDivDxDbMult() const
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
autoPtr< vectorField3 > bEdgeContribution_
void accumulateJMean()
Accumulate contribution for the mean objective value.
dimensionedScalar pow3(const dimensionedScalar &ds)
const volScalarField & divDxDbMultiplier()
Multiplier of grad( delta(x)/delta b) for volume-based sensitivities.
const volTensorField & gradDxDbMultiplier()
Multiplier of grad( delta(x)/delta b) for volume-based sensitivities.
autoPtr< boundaryVectorField > bdndbMultPtr_
Term multiplying delta(n)/delta b.
const boundaryVectorField & dxdbMultiplier()
Multiplier of delta(x)/delta b for all patches.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
autoPtr< volScalarField > divDxDbMultPtr_
Multiplier of d(Volume)/db.
autoPtr< OFstream > meanValueFilePtr_
label & averageIter()
Return average iteration index reference.
word dictName() const
The local dictionary name (final part of scoped name)
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
autoPtr< scalar > integrationEndTimePtr_
const boundaryTensorField & boundarydJdStress()
Objective partial deriv wrt stress tensor.
autoPtr< OFstream > instantValueFilePtr_
Mesh data needed to do the Finite Volume discretisation.
bool hasBoundarydJdb() const
bool hasBoundarydJdStress() const
autoPtr< boundaryVectorField > bdSdbMultPtr_
Term multiplying delta(n dS)/delta b.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Output to file stream, using an OSstream.
static bool master(const label communicator=0)
Am I the master process.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const boundaryVectorField & dSdbMultiplier()
Multiplier of delta(n dS)/delta b for all patches.
fileName objFunctionFolder_
Output file variables.
bool hasGradDxDbMult() const
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
const boundaryVectorField & boundarydJdb()
Contribution to surface sensitivities for all patches.
const dictionary & dict() const
Return objective dictionary.
const Time & time() const
Return the top-level database.
static const Vector< scalar > zero
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
scalar weight() const
Return the objective function weight.
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
bool hasdxdbDirectMult() const
defineTypeNameAndDebug(combustionModel, 0)
dimensioned< tensor > dimensionedTensor
Dimensioned tensor obtained from generic dimensioned type.
void incrementIntegrationTimes(const scalar timeSpan)
Increment integration times.
virtual bool readDict(const dictionary &dict)
bool isWithinIntegrationTime() const
Check whether this is an objective integration time.
virtual scalar J()=0
Return the instantaneous objective function value.
const volScalarField & dJdb()
Contribution to field sensitivities.
virtual void write() const
Write objective function history.