Go to the documentation of this file.
39 namespace incompressible
49 optimisationType::optimisationType
68 dict_.subDict(
"updateMethod").subOrEmptyDict(
"lineSearch"),
75 label nConstraints(0);
78 nConstraints += adjManagerI.nConstraints();
86 && !isA<constrainedOptimisationMethod>(updateMethod_())
92 constrainedOptimisationMethod::dictionaryConstructorTablePtr_
95 <<
"Found " << nConstraints <<
" adjoint solvers corresponding to "
96 <<
"constraints but the optimisation method used "
97 <<
"(" << updateMethod_().type() <<
") "
98 <<
"is not a constrainedOptimisationMethod. " <<
nl
99 <<
"Available constrainedOptimisationMethods are :" <<
nl
100 << cstTablePtr->sortedToc()
106 && isA<constrainedOptimisationMethod>(updateMethod_())
111 <<
"Did not find any adjoint solvers corresponding to "
112 <<
"constraints but the optimisation method used "
113 <<
"(" << updateMethod_().type() <<
") "
114 <<
"is a constrainedOptimisationMethod. " <<
nl <<
nl
115 <<
"This can cause some constraintOptimisationMethods to misbehave."
117 <<
"Either the isConstraint bool is not set in one of the adjoint "
118 <<
"solvers or you should consider using an updateMethod "
119 <<
"that is not a constrainedOptimisationMethod"
134 const word modelType(
dict.subDict(
"optimisationType").get<
word>(
"type"));
136 Info<<
"optimisationType type : " << modelType <<
endl;
138 auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType);
140 if (!cstrIter.found())
147 *dictionaryConstructorTablePtr_
165 scalar objectiveValue(
Zero);
170 const scalar opWeight = adjSolvManager.operatingPointWeight();
174 adjSolvManager.aggregateSensitivities();
176 if (objectiveSens.empty())
178 objectiveSens.setSize(tadjointSolverManagerSens().size(),
Zero);
181 objectiveSens += opWeight*tadjointSolverManagerSens();
182 objectiveValue += opWeight*adjSolvManager.objectiveValue();
186 adjSolvManager.constraintSensitivities();
190 if (constraintSens.empty())
192 constraintSens.
setSize(adjointSolverManagerConstSens.size());
193 forAll(constraintSens, cI)
200 adjointSolverManagerConstSens[cI].size(),
204 constraintValues.setSize(cValues().size());
205 constraintValues =
Zero;
209 forAll(constraintSens, cI)
211 constraintSens[cI] += opWeight*adjointSolverManagerConstSens[cI];
213 constraintValues += opWeight*cValues();
236 scalar objectiveValue(
Zero);
241 const scalar opWeight = adjSolvManager.operatingPointWeight();
243 objectiveValue += opWeight*adjSolvManager.objectiveValue();
246 if (constraintValues.empty())
248 constraintValues.setSize(cValues().size(),
Zero);
250 constraintValues += opWeight*cValues();
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
autoPtr< lineSearch > & getLineSearch()
Get a reference to the line search object.
A class for handling words, derived from Foam::string.
defineTypeNameAndDebug(adjointEikonalSolver, 0)
virtual scalar meritFunctionDirectionalDerivative()
Derivative of the merit function.
virtual void write()
Write useful quantities to files.
A class for managing temporary objects.
static constexpr const zero Zero
Global zero.
const autoPtr< volScalarField > & sourcePtr()
Get source term.
autoPtr< volScalarField > sourcePtr_
Ostream & endl(Ostream &os)
Add newline and flush stream.
tmp< fvMatrix< Type > > correction(const fvMatrix< Type > &)
Return the correction form of the given matrix.
virtual tmp< scalarField > computeDirection()
Compute update direction.
defineRunTimeSelectionTable(adjointSensitivity, dictionary)
#define forAll(list, i)
Loop across all elements in list.
#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.
messageStream Info
Information stream (uses stdout - output is on the master only)
static autoPtr< lineSearch > New(const dictionary &dict, const Time &time)
Return a reference to the selected turbulence model.
static autoPtr< updateMethod > New(const fvMesh &mesh, const dictionary &dict)
Return a reference to the selected turbulence model.
void setSize(const label newLen)
Same as resize()
PtrList< adjointSolverManager > & adjointSolverManagers
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Class for managing adjoint solvers, which may be more than one per operating point.
PtrList< adjointSolverManager > & adjointSolvManagers_
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Mesh data needed to do the Finite Volume discretisation.
const T * set(const label i) const
Return const pointer to element (if set) or nullptr.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
autoPtr< updateMethod > updateMethod_
Macros to ease declaration of run-time selection tables.
static autoPtr< optimisationType > New(fvMesh &mesh, const dictionary &dict, PtrList< adjointSolverManager > &adjointSolverManagers)
Return a reference to the selected turbulence model.
#define WarningInFunction
Report a warning using Foam::Warning.
virtual void updateOldCorrection(const scalarField &)
Update old correction. Needed for quasi-Newton Methods.
autoPtr< lineSearch > lineSearch_
virtual scalar computeMeritFunction()
Compute the merit function of the optimisation problem.