66 mesh_.time().globalPath()/
"system",
78 Foam::adjointSolver::adjointSolver
81 const word& managerType,
83 const word& primalSolverName,
84 const word& solverName
88 primalSolverName_(primalSolverName),
92 dict.subDict(
"objectives"),
96 sensitivities_(nullptr),
99 dict.getOrDefault<bool>(
"computeSensitivities", true)
101 isConstraint_(
dict.getOrDefault<bool>(
"isConstraint", false)),
102 isDoubleSidedConstraint_
103 (
dict.getOrDefault<bool>(
"isDoubleSidedConstraint", false)),
104 adjointSensitivity_(nullptr)
123 const word& managerType,
125 const word& primalSolverName,
126 const word& solverName
131 auto* ctorPtr = adjointSolverConstructorTable(solverType);
140 *adjointSolverConstructorTablePtr_
144 return autoPtr<adjointSolver>
146 ctorPtr(
mesh, managerType,
dict, primalSolverName, solverName)
157 computeSensitivities_ =
160 objectiveManager_.readDict(
dict.
subDict(
"objectives"));
162 if (adjointSensitivity_)
164 adjointSensitivity_().readDict(designVarsDict());
211 if (computeSensitivities_)
213 preCalculateSensitivities();
215 adjointSensitivity_->calculateSensitivities(designVars);
220 sensitivities_.ref() = sens;
231 autoPtr<designVariables>& designVars
243 (
"sensitivities", *
this, designVars().size());
247 computeObjectiveSensitivities(designVars);
251 return sensitivities_();
257 if (computeSensitivities_)
259 adjointSensitivity_->clearSensitivities();
260 sensitivities_.clear();
273 if (sensitivities_.good())
275 sensitivities_().writeEntry(
"sensitivities",
os);
bool computeSensitivities_
Are sensitivities computed.
void size(const label n)
Older name for setAddressableSize.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A list of keyword definitions, which are a keyword followed by a number of values (eg...
void allocateSensitivities()
Allocate the sensitivity derivatives.
dictionary designVarsDict() const
Return the dictionary corresponding to the design variables.
Base class for adjoint solvers.
autoPtr< adjointSensitivity > adjointSensitivity_
Sensitivity Derivatives engine.
Ignore writing from objectRegistry::writeObject()
const dimensionSet dimless
Dimensionless.
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T. FatalIOError if not found, or if the number of tokens is incorrect.
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
virtual dimensionSet maDimensions() const
Return the dimensions of the adjoint grid displacement variable.
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry (const access) with the given keyword.
virtual void clearSensitivities()
Clears the sensitivity field known by the adjoint solver.
static autoPtr< adjointSensitivity > New(const fvMesh &mesh, const dictionary &dict, adjointSolver &adjointSolver)
Return a reference to the selected turbulence model.
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
static autoPtr< adjointSolver > New(fvMesh &mesh, const word &managerType, const dictionary &dict, const word &primalSolverName, const word &solverName)
Return a reference to the selected turbulence model.
virtual bool writeData(Ostream &os) const
Write the sensitivity derivatives.
A class for handling words, derived from Foam::string.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
bool isConstraint_
Is the adjoint solver used to tackle a constraint.
virtual dimensionSet daDimensions() const
Return the dimensions of the adjoint distance field.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
virtual bool readDict(const dictionary &dict)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
virtual tmp< volScalarField > adjointEikonalSource()
Return the source the adjoint eikonal equation.
OBJstream os(runTime.globalPath()/outputName)
defineTypeNameAndDebug(combustionModel, 0)
void update()
Update objective function related values.
virtual void computeObjectiveSensitivities(autoPtr< designVariables > &designVars)
Compute sensitivities of the underlaying objectives.
bool isDoubleSidedConstraint_
Is the adjoint solver used to tackle a double-sided constraint.
virtual void updatePrimalBasedQuantities()
Update primal based quantities, e.g. the primal fields in adjoint turbulence models.
Mesh data needed to do the Finite Volume discretisation.
fvMesh & mesh_
Reference to the mesh database.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
virtual bool readDict(const dictionary &dict)
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
A class for managing temporary objects.
virtual tmp< volScalarField > yWall() const
Return the distance field, to be used in the solution of the adjoint eikonal PDE. ...
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
objectiveManager objectiveManager_
Object to manage objective functions.
Do not request registration (bool: false)
virtual const scalarField & getObjectiveSensitivities(autoPtr< designVariables > &designVars)
Grab a reference to the computed sensitivities.
virtual bool includeDistance() const
Does the adjoint to an equation computing distances need to taken into consideration.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
static constexpr const zero Zero
Global zero (0)