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-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::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 
70 
71 private:
72 
73  // Private Member Functions
74 
75  //- No copy construct
76  conjugateGradient(const conjugateGradient&) = delete;
77 
78  //- No copy assignment
79  void operator=(const conjugateGradient&) = delete;
80 
81 
82 public:
83 
84  //- Runtime type information
85  TypeName("conjugateGradient");
86 
87 
88  // Constructors
89 
90  //- Construct from components
92  (
93  const fvMesh& mesh,
94  const dictionary& dict,
95  autoPtr<designVariables>& designVars,
96  const label nConstraints,
97  const word& type
98  );
99 
100 
101  //- Destructor
102  virtual ~conjugateGradient() = default;
103 
104 
105  // Member Functions
106 
107  //- Compute design variables correction
108  void computeCorrection();
109 
110  //- Update old correction. For use when eta has been changed externally
111  virtual void updateOldCorrection(const scalarField& oldCorrection);
112 
113  //- Write useful quantities to files
114  virtual bool writeData(Ostream& os) const;
115 };
116 
117 
118 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
119 
120 } // End namespace Foam
121 
122 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
123 
124 #endif
125 
126 // ************************************************************************* //
virtual void updateOldCorrection(const scalarField &oldCorrection)
Update old correction. For use when eta has been changed externally.
dictionary dict
void computeCorrection()
Compute design variables correction.
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
Abstract base class for optimisation methods.
Definition: updateMethod.H:50
The Conjugate Gradient formula.
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
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual bool writeData(Ostream &os) const
Write useful quantities to files.
TypeName("conjugateGradient")
Runtime type information.
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
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
virtual ~conjugateGradient()=default
Destructor.
Namespace for OpenFOAM.