conjugateGradient.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::conjugateGradient
31 
32 Description
33  The Conjugate Gradient formula.
34 
35  Beta computed from Fletcher-Reeves or Polak-Ribiere approaches.
36  Polak-Ribiere seems to misbehave.
37  Not tested with line search.
38 
39 SourceFiles
40  conjugateGradient.C
41 
42 \*---------------------------------------------------------------------------*/
43 
44 #ifndef conjugateGradient_H
45 #define conjugateGradient_H
46 
47 #include "updateMethod.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 /*---------------------------------------------------------------------------*\
55  Class conjugateGradient Declaration
56 \*---------------------------------------------------------------------------*/
57 
59 :
60  public updateMethod
61 {
62 protected:
63 
64  // Protected data
65 
69  label counter_;
71 
72 
73  // Protected Member Functions
74 
75  //- Allocate matrices in the first optimisation cycle
76  void allocateFields();
77 
78  //- Read old info from dict
79  void readFromDict();
80 
81 
82 private:
83 
84  // Private Member Functions
85 
86  //- No copy construct
87  conjugateGradient(const conjugateGradient&) = delete;
88 
89  //- No copy assignment
90  void operator=(const conjugateGradient&) = delete;
91 
92 
93 public:
94 
95  //- Runtime type information
96  TypeName("conjugateGradient");
97 
98 
99  // Constructors
100 
101  //- Construct from components
102  conjugateGradient(const fvMesh& mesh, const dictionary& dict);
103 
104 
105  //- Destructor
106  virtual ~conjugateGradient() = default;
107 
108 
109  // Member Functions
110 
111  //- Compute design variables correction
112  void computeCorrection();
113 
114  //- Update old correction. For use when eta has been changed externally
115  virtual void updateOldCorrection(const scalarField& oldCorrection);
116 
117  //- Write old info to dict
118  virtual void write();
119 };
120 
121 
122 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
123 
124 } // End namespace Foam
125 
126 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
127 
128 #endif
129 
130 // ************************************************************************* //
updateMethod.H
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::conjugateGradient::TypeName
TypeName("conjugateGradient")
Runtime type information.
Foam::conjugateGradient::write
virtual void write()
Write old info to dict.
Definition: conjugateGradient.C:203
Foam::conjugateGradient::computeCorrection
void computeCorrection()
Compute design variables correction.
Definition: conjugateGradient.C:135
Foam::conjugateGradient::readFromDict
void readFromDict()
Read old info from dict.
Definition: conjugateGradient.C:63
Foam::conjugateGradient::~conjugateGradient
virtual ~conjugateGradient()=default
Destructor.
Foam::Field< scalar >
Foam::updateMethod
Abstract base class for optimisation methods.
Definition: updateMethod.H:54
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::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::conjugateGradient
The Conjugate Gradient formula.
Definition: conjugateGradient.H:57
Foam::conjugateGradient::updateOldCorrection
virtual void updateOldCorrection(const scalarField &oldCorrection)
Update old correction. For use when eta has been changed externally.
Definition: conjugateGradient.C:193
Foam::conjugateGradient::dxOld_
scalarField dxOld_
Definition: conjugateGradient.H:66
Foam::List< label >
Foam::conjugateGradient::betaType_
word betaType_
Definition: conjugateGradient.H:69
Foam::conjugateGradient::activeDesignVars_
labelList activeDesignVars_
Definition: conjugateGradient.H:65
Foam::conjugateGradient::sOld_
scalarField sOld_
Definition: conjugateGradient.H:67
Foam::conjugateGradient::allocateFields
void allocateFields()
Allocate matrices in the first optimisation cycle.
Definition: conjugateGradient.C:49
Foam::conjugateGradient::counter_
label counter_
Definition: conjugateGradient.H:68