198 objective(
const objective&) =
delete;
201 void operator=(
const objective&) =
delete;
223 const word& adjointSolverName,
224 const word& primalSolverName
237 const word& adjointSolverName,
238 const word& primalSolverName
249 const word& objectiveType,
250 const word& adjointSolverName,
251 const word& primalSolverName
264 virtual scalar
J() = 0;
281 virtual scalar
weight()
const;
351 virtual void update() = 0;
410 virtual bool write(
const bool valid =
true)
const;
477#include "objectiveI.H"
Useful typenames for fields defined only at the boundaries.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
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,...
dictionary()
Default construct, a top-level empty dictionary.
A class for handling file names.
Mesh data needed to do the Finite Volume discretisation.
localIOdictionary(const IOobject &io, const dictionary *fallback=nullptr)
Construct given an IOobject and optional fallback dictionary content.
virtual void writeInstantaneousSeparator() const
Append a blank line after the end of optimisation cycle to the file holding the instantaneous objecti...
bool hasdSdbMult() const noexcept
virtual void writeInstantaneousValue() const
Write objective function history at each primal solver iteration.
virtual void addSource(fvScalarMatrix &matrix)
Manipulate fvVectorMatrix through the objective.
virtual void update_dxdbMultiplier()
Update d (x) / db multiplier. Surface-based sensitivity term.
autoPtr< OFstream > instantValueFilePtr_
File to keep the objective values at each iteration of the primal solver.
virtual void update_gradDxDbMultiplier()
Update grad( dx/db multiplier). Volume-based sensitivity term.
bool hasIntegrationStartTime() const noexcept
autoPtr< boundaryVectorField > bdJdbPtr_
Contribution to field sensitivity derivatives.
virtual void update_dxdbDirectMultiplier()
Update d (x) / db multiplier. Surface and volume-based sensitivity term.
void setComputed(const bool isComputed) noexcept
Set the computed status of the objective.
virtual void accumulateJMean()
Accumulate contribution for the mean objective value.
virtual void update()=0
Update objective function derivatives.
scalar JMean_
Average objective value.
autoPtr< boundaryVectorField > bdSdbMultPtr_
Term multiplying delta(n dS)/delta b.
const boundaryVectorField & dxdbMultiplier() const
Multiplier of delta(x)/delta b for all patches.
const word objectiveName_
virtual void addSource(fvVectorMatrix &matrix)
Manipulate fvVectorMatrix through the objective.
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.
virtual void update_dJdbField()
void setMeanValueFilePtr() const
Set the output file ptr for the mean value.
virtual void writeMeanValue() const
Write mean objective function history.
autoPtr< OFstream > objFunctionFilePtr_
File to keep the objective values after the end of the primal solver.
autoPtr< OFstream > meanValueFilePtr_
File to keep the average objective values after the end of the primal solver.
wordList fieldNames_
List of adjoint fields for which this objective will contribute sources to their equations.
virtual void update_divDxDbMultiplier()
Update div( dx/db multiplier). Volume-based sensitivity term.
virtual void addHeaderColumns() const
Write headers for additional columns.
bool hasGradDxDbMult() const noexcept
bool hasBoundarydJdb() const noexcept
bool hasdJdb() const noexcept
virtual scalar weight() const
Return the objective function weight.
virtual bool writeData(Ostream &os) const
Write averaged objective for continuation.
autoPtr< scalar > targetLeft_
Target on the left hand-side of a double inequality, for double sided constraints.
const boundaryVectorField & dxdbDirectMultiplier() const
Multiplier of delta(x)/delta b for all patches.
autoPtr< boundaryVectorField > bdxdbDirectMultPtr_
Term multiplying delta(x)/delta b at the boundary for objectives that directly depend on x,...
virtual void update_boundarydJdb()
Update objective function derivative term.
declareRunTimeNewSelectionTable(autoPtr, objective, objective,(const fvMesh &mesh, const dictionary &dict, const word &adjointSolverName, const word &primalSolverName),(mesh, dict, adjointSolverName, primalSolverName))
virtual void nullify()
Nullify adjoint contributions.
autoPtr< scalar > integrationStartTimePtr_
Objective integration start and end times (for unsteady flows).
const word & objectiveName() const
Return the objective name.
const scalarField & dJdbField() const
Contribution to sensitivities with a random number of designVars.
bool hasIntegrationEndTime() const noexcept
bool hasdndbMult() const noexcept
void setObjectiveFilePtr() const
Set the output file ptr.
const boundaryVectorField & dSdbMultiplier() const
Multiplier of delta(n dS)/delta b for all patches.
autoPtr< scalar > normFactor_
Normalization factor.
virtual scalar JCycle(bool negate=false) const
Return the objective function of the optimisation cycle.
scalar weight_
Objective weight.
virtual bool readDict(const dictionary &dict)
unsigned int width_
Default width of entries when writing in the objective files.
virtual scalar J()=0
Return the instantaneous objective function value.
autoPtr< scalar > integrationEndTimePtr_
virtual void update_dSdbMultiplier()
Update d (normal dS) / db multiplier. Surface-based sensitivity term.
void setWrite(const bool shouldWrite)
Should the objective be written to file upon calling write()?
const volScalarField & divDxDbMultiplier() const
Multiplier of grad( delta(x)/delta b) for volume-based sensitivities.
virtual void addHeaderInfo() const
Write any information that needs to go the header of the file.
bool hasdJdbField() const noexcept
virtual void update_dndbMultiplier()
Update d (normal) / db multiplier. Surface-based sensitivity term.
autoPtr< volScalarField > divDxDbMultPtr_
Multiplier of d(Volume)/db.
const volScalarField & dJdb() const
Contribution to field sensitivities.
bool hasDivDxDbMult() const noexcept
scalar J_
Objective function value and weight.
virtual ~objective()=default
Destructor.
TypeName("objective")
Runtime type information.
bool hasBoundaryEdgeContribution() const noexcept
void setInstantValueFilePtr() const
Set the output file ptr for the instantaneous value.
virtual void incrementIntegrationTimes(const scalar timeSpan)
Increment integration times.
virtual void doNormalization()
Normalize all fields allocated by the objective.
const boundaryVectorField & dndbMultiplier() const
Multiplier of delta(n dS)/delta b for all patches.
virtual bool normalize() const
Is the objective normalized.
const dictionary & dict() const
Return objective dictionary.
const word primalSolverName_
bool computed_
Whether the objective is computed or not.
virtual void updateNormalizationFactor()
Update normalization factors, for objectives in which the factor is not known a priori.
virtual void update_dJdb()
fileName objFunctionFolder_
Output file variables.
autoPtr< scalar > target_
Target value, in case the objective is used as a constraint.
const boundaryVectorField & boundarydJdb() const
Contribution to surface sensitivities for all patches.
autoPtr< boundaryVectorField > bdndbMultPtr_
Term multiplying delta(n)/delta b.
virtual void update_boundaryEdgeContribution()
Update boundary edge contributions.
autoPtr< boundaryVectorField > bdxdbMultPtr_
Term multiplying delta(x)/delta b at the boundary.
const word adjointSolverName_
virtual void addColumnValues() const
Write information to additional columns.
bool hasdxdbDirectMult() const noexcept
virtual bool isWithinIntegrationTime() const
Check whether this is an objective integration time.
bool shouldWrite() const
Should the objective be written to file upon calling write()?
autoPtr< vectorField3 > bEdgeContribution_
Contribution located in specific parts of a patch. Mainly intended for patch boundary edges contribut...
bool hasdxdbMult() const noexcept
const vectorField3 & boundaryEdgeMultiplier() const
Multiplier located at patch boundary edges.
const volTensorField & gradDxDbMultiplier() const
Multiplier of grad( delta(x)/delta b) for volume-based sensitivities.
autoPtr< volTensorField > gradDxDbMultPtr_
Emerging from volume objectives that include spatial derivatives.
Base class for solver control classes.
A class for handling words, derived from Foam::string.
OBJstream os(runTime.globalPath()/outputName)
Field< Field< vectorField > > vectorField3
List< word > wordList
List of word.
fvMatrix< scalar > fvScalarMatrix
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
GeometricField< tensor, fvPatchField, volMesh > volTensorField
fvMatrix< vector > fvVectorMatrix
Field< vector > vectorField
Specialisation of Field<T> for vector.
void negate(DimensionedField< Type, GeoMesh > &result, const DimensionedField< Type, GeoMesh > &f1)
volVectorField::Boundary boundaryVectorField
fvPatchField< vector > fvPatchVectorField
Macros to ease declaration of run-time selection tables.
#define declareRunTimeNewSelectionTable(ptrWrapper, baseType, argNames, argList, parList)
Declare a run-time selection for derived classes.
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.