66 mesh_.time().globalPath()/
"system",
78Foam::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>
157 computeSensitivities_ =
158 dict.getOrDefault<
bool>(
"computeSensitivities",
true);
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_)
273 if (sensitivities_.good())
275 sensitivities_().writeEntry(
"sensitivities",
os);
label size() const noexcept
The number of elements in list.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
@ NO_REGISTER
Do not request registration (bool: false).
@ MUST_READ
Reading required.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
void size(const label n)
Older name for setAddressableSize.
static autoPtr< adjointSensitivity > New(const fvMesh &mesh, const dictionary &dict, adjointSolver &adjointSolver)
Return a reference to the selected turbulence model.
Base class for adjoint solvers.
virtual void clearSensitivities()
Clears the sensitivity field known by the adjoint solver.
objectiveManager objectiveManager_
Object to manage objective functions.
virtual tmp< volScalarField > yWall() const
Return the distance field, to be used in the solution of the adjoint eikonal PDE.
tmp< scalarField > sensitivities_
Sensitivities field.
void allocateSensitivities()
Allocate the sensitivity derivatives.
virtual tmp< volScalarField > adjointEikonalSource()
Return the source the adjoint eikonal equation.
virtual const scalarField & getObjectiveSensitivities(autoPtr< designVariables > &designVars)
Grab a reference to the computed sensitivities.
virtual dimensionSet daDimensions() const
Return the dimensions of the adjoint distance field.
virtual bool writeData(Ostream &os) const
Write the sensitivity derivatives.
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.
autoPtr< adjointSensitivity > adjointSensitivity_
Sensitivity Derivatives engine.
virtual bool readDict(const dictionary &dict)
dictionary designVarsDict() const
Return the dictionary corresponding to the design variables.
bool computeSensitivities_
Are sensitivities computed.
virtual bool includeDistance() const
Does the adjoint to an equation computing distances need to taken into consideration.
virtual void updatePrimalBasedQuantities()
Update primal based quantities, e.g. the primal fields in adjoint turbulence models.
const word & primalSolverName() const
Return the primal solver name.
virtual void preCalculateSensitivities()
Actions to be performed before calculating sensitivities.
const word primalSolverName_
Name of primal solver.
bool isDoubleSidedConstraint_
Is the adjoint solver used to tackle a double-sided constraint.
bool isConstraint_
Is the adjoint solver used to tackle a constraint.
virtual dimensionSet maDimensions() const
Return the dimensions of the adjoint grid displacement variable.
virtual void computeObjectiveSensitivities(autoPtr< designVariables > &designVars)
Compute sensitivities of the underlaying objectives.
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,...
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
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...
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry (const access) with the given keyword.
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
Mesh data needed to do the Finite Volume discretisation.
const word & managerType() const
Return the manager type.
virtual bool readDict(const dictionary &dict)
const dictionary & dict() const
Return the solver dictionary.
const word solverName_
Solver name.
const fvMesh & mesh() const
Return the solver mesh.
const word & solverName() const
Return the solver name.
fvMesh & mesh_
Reference to the mesh database.
solver(const solver &)=delete
No copy construct.
A class for managing temporary objects.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
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 NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
OBJstream os(runTime.globalPath()/outputName)
const dimensionSet dimless
Dimensionless.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
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).
errorManipArg< error, int > exit(error &err, const int errNo=1)
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.