SR1.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-2019 PCOpt/NTUA
9  Copyright (C) 2013-2019 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::SR1
31 
32 Description
33  The quasi-Newton Symmetric Rank One formula
34 
35 SourceFiles
36  SR1.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef SR1_H
41 #define SR1_H
42 
43 #include "updateMethod.H"
44 #include "scalarMatrices.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 /*---------------------------------------------------------------------------*\
52  Class SR1 Declaration
53 \*---------------------------------------------------------------------------*/
54 
55 class SR1
56 :
57  public updateMethod
58 {
59 protected:
60 
61  // Protected data
62 
63  //- Step for the Newton method
64  scalar etaHessian_;
65 
66  //- Number of first steepest descent steps
67  label nSteepestDescent_;
68 
69  //- For stability check
70  scalar ratioThreshold_;
71 
72  //- Map to active design variables
74 
75  //- The Hessian inverse. Should have the size of the active design
76  //- variables
78 
79  //- The previous Hessian inverse
81 
82  //- The previous derivatives
84 
85  //- The previous correction
87 
88  //- Optimisation counter
89  label counter_;
90 
91 
92  // Protected functions
93 
94  //- Allocate matrices in the first optimisation cycle
95  void allocateMatrices();
96 
97  //- Update approximation of the inverse Hessian
98  void updateHessian();
99 
100  //- Update design variables
101  void update();
102 
103  //- Read old info from dict
104  void readFromDict();
105 
106 
107 private:
108 
109  // Private Member Functions
110 
111  //- No copy construct
112  SR1(const SR1&) = delete;
113 
114  //- No copy assignment
115  void operator=(const SR1&) = delete;
116 
117 
118 public:
119 
120  //- Runtime type information
121  TypeName("SR1");
122 
123 
124  // Constructors
125 
126  //- Construct from components
127  SR1(const fvMesh& mesh, const dictionary& dict);
128 
129 
130  //- Destructor
131  virtual ~SR1() = default;
132 
133 
134  // Member Functions
135 
136  //- Compute design variables correction
137  void computeCorrection();
138 
139  //- Update old correction. Useful for quasi-Newton methods coupled with
140  //- line search
141  virtual void updateOldCorrection(const scalarField& oldCorrection);
142 
143  //- Write old info to dict
144  virtual void write();
145 };
146 
147 
148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
149 
150 } // End namespace Foam
151 
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 
154 #endif
155 
156 // ************************************************************************* //
updateMethod.H
Foam::SR1::etaHessian_
scalar etaHessian_
Step for the Newton method.
Definition: SR1.H:63
Foam::SR1
The quasi-Newton Symmetric Rank One formula.
Definition: SR1.H:54
Foam::SR1::nSteepestDescent_
label nSteepestDescent_
Number of first steepest descent steps.
Definition: SR1.H:66
Foam::SR1::ratioThreshold_
scalar ratioThreshold_
For stability check.
Definition: SR1.H:69
Foam::SR1::derivativesOld_
scalarField derivativesOld_
The previous derivatives.
Definition: SR1.H:82
Foam::SR1::activeDesignVars_
labelList activeDesignVars_
Map to active design variables.
Definition: SR1.H:72
Foam::SR1::computeCorrection
void computeCorrection()
Compute design variables correction.
Definition: SR1.C:201
Foam::SR1::allocateMatrices
void allocateMatrices()
Allocate matrices in the first optimisation cycle.
Definition: SR1.C:49
Foam::SR1::readFromDict
void readFromDict()
Read old info from dict.
Definition: SR1.C:135
Foam::Field< scalar >
Foam::updateMethod
Abstract base class for optimisation methods.
Definition: updateMethod.H:54
Foam::SR1::~SR1
virtual ~SR1()=default
Destructor.
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::SR1::counter_
label counter_
Optimisation counter.
Definition: SR1.H:88
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::SquareMatrix< scalar >
Foam::SR1::write
virtual void write()
Write old info to dict.
Definition: SR1.C:224
Foam::SR1::HessianInv_
SquareMatrix< scalar > HessianInv_
Definition: SR1.H:76
Foam::List< label >
Foam::SR1::update
void update()
Update design variables.
Definition: SR1.C:102
Foam::SR1::correctionOld_
scalarField correctionOld_
The previous correction.
Definition: SR1.H:85
Foam::SR1::HessianInvOld_
SquareMatrix< scalar > HessianInvOld_
The previous Hessian inverse.
Definition: SR1.H:79
Foam::SR1::TypeName
TypeName("SR1")
Runtime type information.
scalarMatrices.H
Foam::SR1::updateHessian
void updateHessian()
Update approximation of the inverse Hessian.
Definition: SR1.C:71
Foam::SR1::updateOldCorrection
virtual void updateOldCorrection(const scalarField &oldCorrection)
Definition: SR1.C:217