39namespace incompressible
68 dict_.subDict(
"updateMethod").subOrEmptyDict(
"lineSearch"),
75 label nConstraints(0);
78 nConstraints += adjManagerI.nConstraints();
89 const auto& cnstrTable =
90 *(constrainedOptimisationMethod::dictionaryConstructorTablePtr_);
94 <<
"Found " << nConstraints <<
" adjoint solvers corresponding to "
95 <<
"constraints but the optimisation method ("
97 <<
") is not a constrainedOptimisationMethod." <<
nl
98 <<
"Available constrainedOptimisationMethods:" <<
nl
99 << cnstrTable.sortedToc()
110 <<
"Did not find any adjoint solvers corresponding to "
111 <<
"constraints but the optimisation method ("
113 <<
") is a constrainedOptimisationMethod." <<
nl <<
nl
114 <<
"This can cause some constraintOptimisationMethods to misbehave."
116 <<
"Either the isConstraint bool is not set in one of the adjoint "
117 <<
"solvers or you should consider using an updateMethod "
118 <<
"that is not a constrainedOptimisationMethod"
135 Info<<
"optimisationType type : " << modelType <<
endl;
137 auto* ctorPtr = dictionaryConstructorTable(modelType);
146 *dictionaryConstructorTablePtr_
194 scalar objectiveValue(
Zero);
228 scalar& objectiveValue,
234 const scalar opWeight = adjSolvManager.operatingPointWeight();
238 adjSolvManager.aggregateSensitivities();
240 if (objectiveSens.
empty())
242 objectiveSens.
setSize(tadjointSolverManagerSens().size(),
Zero);
245 objectiveSens += opWeight*tadjointSolverManagerSens();
246 objectiveValue += opWeight*adjSolvManager.objectiveValue();
250 adjSolvManager.constraintSensitivities();
254 if (constraintSens.
empty())
256 constraintSens.
setSize(adjointSolverManagerConstSens.
size());
257 forAll(constraintSens, cI)
264 adjointSolverManagerConstSens[cI].size(),
268 constraintValues.
setSize(cValues().size());
269 constraintValues =
Zero;
273 forAll(constraintSens, cI)
275 constraintSens[cI] += opWeight*adjointSolverManagerConstSens[cI];
277 constraintValues += opWeight*cValues();
286 scalar objectiveValue(
Zero);
291 const scalar opWeight = adjSolvManager.operatingPointWeight();
293 objectiveValue += opWeight*adjSolvManager.objectiveValue();
296 if (constraintValues.
empty())
300 constraintValues += opWeight*cValues();
void setSize(const label n)
Alias for resize()
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
const T * set(const label i) const
void setSize(const label newLen)
Same as resize()
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
bool empty() const noexcept
True if the UList is empty (ie, size() is zero)
void size(const label n)
Older name for setAddressableSize.
bool empty() const noexcept
True if the list is empty (ie, size() is zero)
label size() const noexcept
The number of elements in the list.
Class for managing adjoint solvers, which may be more than one per operating point.
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.
Abstract base class for optimisation methods.
virtual void computeEta(scalarField &correction)=0
Compute eta if not set in the first step.
virtual scalar computeMeritFunction()
Compute the merit function of the optimisation problem.
PtrList< adjointSolverManager > & adjointSolvManagers_
const autoPtr< volScalarField > & sourcePtr()
Get source term.
autoPtr< updateMethod > updateMethod_
virtual tmp< scalarField > computeDirection()
Compute update direction.
autoPtr< lineSearch > & getLineSearch()
Get a reference to the line search object.
virtual void updateOldCorrection(const scalarField &)
Update old correction. Needed for quasi-Newton Methods.
virtual void updateGradientsAndValues(scalarField &objectiveSens, PtrList< scalarField > &constraintSens, scalar &objectiveValue, scalarField &constraintValues)
Compute cumulative objective and constraint gradients.
autoPtr< lineSearch > lineSearch_
virtual scalar meritFunctionDirectionalDerivative()
Derivative of the merit function.
virtual void write()
Write useful quantities to files.
virtual void update()
Update design variables.
virtual void updateDesignVariables(scalarField &correction)=0
Update the design variables given their correction.
autoPtr< volScalarField > sourcePtr_
Abstract base class for line search methods.
A class for managing temporary objects.
Abstract base class for optimisation methods.
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 FatalErrorInFunction
Report an error message using Foam::FatalError.
#define WarningInFunction
Report a warning using Foam::Warning.
autoPtr< BasicCompressibleTurbulenceModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &alphaRhoPhi, const surfaceScalarField &phi, const typename BasicCompressibleTurbulenceModel::transportModel &transport, const word &propertiesName)
messageStream Info
Information stream (stdout output on master, null elsewhere)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static constexpr const zero Zero
Global zero (0)
tmp< fvMatrix< Type > > correction(const fvMatrix< Type > &)
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
Macros to ease declaration of run-time selection tables.
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.
#define forAll(list, i)
Loop across all elements in list.
PtrList< adjointSolverManager > & adjointSolverManagers