optimisationManager.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::optimisationManager
31 
32 Description
33  Abstract base class for optimisation methods
34 
35 SourceFiles
36  optimisationManager.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef optimisationManager_H
41 #define optimisationManager_H
42 
43 #include "runTimeSelectionTables.H"
44 #include "IOdictionary.H"
46 #include "primalSolver.H"
47 #include "adjointSolverManager.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 /*---------------------------------------------------------------------------*\
55  Class optimisationManager Declaration
56 \*---------------------------------------------------------------------------*/
57 
59 :
60  public IOdictionary
61 {
62 protected:
63 
64  // Protected data
65 
67  Time& time_;
70  const word managerType_;
72 
73 
74 private:
75 
76  // Private Member Functions
77 
78  //- No copy construct
80 
81  //- No copy assignment
82  void operator=(const optimisationManager&) = delete;
83 
84 
85 public:
86 
87  //- Runtime type information
88  TypeName("optimisationManager");
89 
90 
91  // Declare run-time constructor selection table
92 
94  (
95  autoPtr,
97  dictionary,
98  (
99  fvMesh& mesh
100  ),
101  (mesh)
102  );
103 
104 
105  // Constructors
106 
107  //- Construct from components
109 
110 
111  // Selectors
112 
113  //- Return a reference to the selected turbulence model
115 
116 
117  //- Destructor
118  virtual ~optimisationManager() = default;
119 
120 
121  // Member Functions
122 
124 
126 
127  virtual bool read();
128 
129  //- Prefix increment,
130  virtual optimisationManager& operator++() = 0;
131 
132  //- Postfix increment, this is identical to the prefix increment
133  virtual optimisationManager& operator++(int) = 0;
134 
135  //- Return true if end of optimisation run.
136  // Also, updates the design variables if needed
137  virtual bool checkEndOfLoopAndUpdate() = 0;
138 
139  //- Return true if end of optimisation run
140  virtual bool end() = 0;
141 
142  //- Whether to update the design variables
143  virtual bool update() = 0;
144 
145  //- Update design variables.
146  // Might employ a line search to find a correction satisfying the step
147  // convergence criteria
148  virtual void updateDesignVariables() = 0;
149 
150  //- Solve all primal equations
151  virtual void solvePrimalEquations();
152 
153  //- Solve all adjoint equations
154  virtual void solveAdjointEquations();
155 
156  //- Compute all adjoint sensitivities
157  virtual void computeSensitivities();
158 
159  //- Solve all primal equations
160  virtual void updatePrimalBasedQuantities();
161 };
162 
163 
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 
166 } // End namespace Foam
167 
168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 
170 #endif
171 
172 // ************************************************************************* //
static autoPtr< optimisationManager > New(fvMesh &mesh)
Return a reference to the selected turbulence model.
virtual bool checkEndOfLoopAndUpdate()=0
Return true if end of optimisation run.
PtrList< adjointSolverManager > adjointSolverManagers_
virtual void updatePrimalBasedQuantities()
Solve all primal equations.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:120
virtual void updateDesignVariables()=0
Update design variables.
Abstract base class for optimisation methods.
autoPtr< incompressible::optimisationType > optType_
declareRunTimeSelectionTable(autoPtr, optimisationManager, dictionary,(fvMesh &mesh),(mesh))
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
PtrList< primalSolver > primalSolvers_
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:50
virtual PtrList< adjointSolverManager > & adjointSolverManagers()
dynamicFvMesh & mesh
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual ~optimisationManager()=default
Destructor.
virtual bool end()=0
Return true if end of optimisation run.
virtual void computeSensitivities()
Compute all adjoint sensitivities.
virtual optimisationManager & operator++()=0
Prefix increment,.
virtual void solveAdjointEquations()
Solve all adjoint equations.
TypeName("optimisationManager")
Runtime type information.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Definition: List.H:55
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:79
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
Macros to ease declaration of run-time selection tables.
virtual bool read()
Read object.
virtual bool update()=0
Whether to update the design variables.
virtual void solvePrimalEquations()
Solve all primal equations.
Namespace for OpenFOAM.
virtual PtrList< primalSolver > & primalSolvers()