Loading...
Searching...
No Matches
quasiNewton.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) 2021-2023 PCOpt/NTUA
9 Copyright (C) 2021-2023 FOSS GP
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27
28Class
29 Foam::quasiNewton
30
31Description
32 Base class for quasi-Newton methods
33
34SourceFiles
35 quasiNewton.C
36
37\*---------------------------------------------------------------------------*/
38
39#ifndef quasiNewton_H
40#define quasiNewton_H
41
42#include "updateMethod.H"
43#include "scalarMatrices.H"
44
45// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46
47namespace Foam
48{
50/*---------------------------------------------------------------------------*\
51 Class quasiNewton Declaration
52\*---------------------------------------------------------------------------*/
53
54class quasiNewton
55:
56 public updateMethod
57{
58protected:
59
60 // Protected data
61
62 //- Step for the Newton method
63 scalar etaHessian_;
64
65 //- Number of first steepest descent steps
67
68 //- Scale the initial unitary Hessian approximation
71 //- The Hessian or its inverse, depending on the deriving class.
72 // Has the size of the active design variables.
73 // autoPtr to avoid allocation by limited memory variants
75
76 //- The previous derivatives
79 //- The previous correction
81
82
83 // Protected Member Functions
84
85 //- Update approximation of the inverse Hessian
86 virtual void updateHessian() = 0;
87
88 //- Update design variables
89 virtual void update() = 0;
90
91 //- Allocate the Hessian matrix
92 void allocateHessian();
93
94
95private:
97 // Private Member Functions
98
99 //- No copy construct
100 quasiNewton(const quasiNewton&) = delete;
102 //- No copy assignment
103 void operator=(const quasiNewton&) = delete;
104
105
106public:
107
108 //- Runtime type information
109 TypeName("quasiNewton");
110
111
112 // Constructors
113
114 //- Construct from components
115 quasiNewton
116 (
117 const fvMesh& mesh,
118 const dictionary& dict,
119 autoPtr<designVariables>& designVars,
120 const label nConstraints,
121 const word& type
122 );
123
124
125 //- Destructor
126 virtual ~quasiNewton() = default;
127
128
129 // Member Functions
130
131 //- Compute design variables correction
132 void computeCorrection();
133
134 //- Update old correction. Useful for quasi-Newton methods coupled with
135 //- line search
136 virtual void updateOldCorrection(const scalarField& oldCorrection);
137
138 //- Write useful quantities to files
139 virtual bool writeData(Ostream& os) const;
140};
141
142
143// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
144
145} // End namespace Foam
146
147// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
148
149#endif
151// ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
void computeCorrection()
Compute design variables correction.
Definition quasiNewton.C:83
scalarField correctionOld_
The previous correction.
Definition quasiNewton.H:88
autoPtr< SquareMatrix< scalar > > Hessian_
The Hessian or its inverse, depending on the deriving class.
Definition quasiNewton.H:78
virtual bool writeData(Ostream &os) const
Write useful quantities to files.
virtual ~quasiNewton()=default
Destructor.
label nSteepestDescent_
Number of first steepest descent steps.
Definition quasiNewton.H:65
virtual void updateHessian()=0
Update approximation of the inverse Hessian.
scalar etaHessian_
Step for the Newton method.
Definition quasiNewton.H:60
virtual void update()=0
Update design variables.
bool scaleFirstHessian_
Scale the initial unitary Hessian approximation.
Definition quasiNewton.H:70
scalarField derivativesOld_
The previous derivatives.
Definition quasiNewton.H:83
TypeName("quasiNewton")
Runtime type information.
virtual void updateOldCorrection(const scalarField &oldCorrection)
Update old correction. Useful for quasi-Newton methods coupled with line search.
Definition quasiNewton.C:96
void allocateHessian()
Allocate the Hessian matrix.
Definition quasiNewton.C:35
label nConstraints() const
Get the number of constraints.
A class for handling words, derived from Foam::string.
Definition word.H:66
dynamicFvMesh & mesh
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68