SQP.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2007-2021 PCOpt/NTUA
9  Copyright (C) 2013-2021 FOSS GP
10  Copyright (C) 2019 OpenCFD Ltd.
11 -------------------------------------------------------------------------------
12 License
13  This file is part of OpenFOAM.
14 
15  OpenFOAM is free software: you can redistribute it and/or modify it
16  under the terms of the GNU General Public License as published by
17  the Free Software Foundation, either version 3 of the License, or
18  (at your option) any later version.
19 
20  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
21  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
22  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23  for more details.
24 
25  You should have received a copy of the GNU General Public License
26  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
27 
28 
29 Class
30  Foam::SQP
31 
32 Description
33  The quasi-Newton SQP formula for constrained optimisation
34 
35 SourceFiles
36  SQP.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef SQP_H
41 #define SQP_H
42 
43 #include "quasiNewton.H"
44 #include "SQPBase.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 /*---------------------------------------------------------------------------*\
52  Class SQP Declaration
53 \*---------------------------------------------------------------------------*/
54 
55 class SQP
56 :
57  public quasiNewton,
58  public SQPBase
59 {
60 protected:
61 
62  // Protected data
63 
64  //- Curvature threshold
65  scalar dumpingThreshold_;
66 
67 
68 private:
69 
70  // Private Member Functions
71 
72  //- No copy construct
73  SQP(const SQP&) = delete;
74 
75  //- No copy assignment
76  void operator=(const SQP&) = delete;
77 
78  //- Update the Hessian matrix
79  virtual void updateHessian();
80 
81  //- Compute new lamdas and update correction
82  virtual void update();
83 
84  //- Store old fields needed for the next iter
85  void storeOldFields();
86 
87  //- Get the part the merit function that depends on the constraints
88  virtual scalar meritFunctionConstraintPart() const;
89 
90 
91 public:
92 
93  //- Runtime type information
94  TypeName("SQP");
95 
96 
97  // Constructors
98 
99  //- Construct from components
100  SQP
101  (
102  const fvMesh& mesh,
103  const dictionary& dict,
104  autoPtr<designVariables>& designVars,
105  const label nConstraints,
106  const word& type
107  );
108 
109 
110  //- Destructor
111  virtual ~SQP() = default;
112 
113 
114  // Member Functions
115 
116  //- Compute design variables correction
117  void computeCorrection();
118 
119  //- Compute merit function. Could be different than the objective
120  //- in the presence of constraints
121  virtual scalar computeMeritFunction();
122 
123  //- Derivative of the merit function. Could be different than the
124  //- objective derivative in the presence of constraints
125  virtual scalar meritFunctionDirectionalDerivative();
126 
127  //- Write useful quantities to files
128  virtual bool writeData(Ostream& os) const;
129 
130  //- Write merit function information
131  virtual bool writeAuxiliaryData();
132 };
133 
134 
135 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
136 
137 } // End namespace Foam
138 
139 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
140 
141 #endif
142 
143 // ************************************************************************* //
dictionary dict
label nConstraints() const
Get the number of constraints.
Definition: updateMethod.C:393
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
TypeName("SQP")
Runtime type information.
virtual ~SQP()=default
Destructor.
scalar dumpingThreshold_
Curvature threshold.
Definition: SQP.H:62
void computeCorrection()
Compute design variables correction.
Definition: SQP.C:246
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: POSIX.C:799
dynamicFvMesh & mesh
Base class for quasi-Newton methods.
Definition: quasiNewton.H:49
A class for handling words, derived from Foam::string.
Definition: word.H:63
The quasi-Newton SQP formula for constrained optimisation.
Definition: SQP.H:50
virtual bool writeAuxiliaryData()
Write merit function information.
Definition: SQP.C:289
Base class for Sequantial Quadratic Programming (SQP) methods.
Definition: SQPBase.H:50
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
OBJstream os(runTime.globalPath()/outputName)
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
virtual scalar meritFunctionDirectionalDerivative()
Derivative of the merit function. Could be different than the objective derivative in the presence of...
Definition: SQP.C:273
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
virtual scalar computeMeritFunction()
Compute merit function. Could be different than the objective in the presence of constraints.
Definition: SQP.C:256
Namespace for OpenFOAM.
virtual bool writeData(Ostream &os) const
Write useful quantities to files.
Definition: SQP.C:283