optimisationTypeIncompressible.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::incompressible::optimisationType
31 
32 Description
33  Abstract base class for optimisation methods
34 
35 SourceFiles
36  optimisationType.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef optimisationTypeIncompressible_H
41 #define optimisationTypeIncompressible_H
42 
43 #include "adjointSolverManager.H"
44 #include "updateMethod.H"
45 #include "lineSearch.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 namespace incompressible
53 {
54 
55 /*---------------------------------------------------------------------------*\
56  Class optimisationType Declaration
57 \*---------------------------------------------------------------------------*/
58 
59 class optimisationType
60 {
61 protected:
62 
63  // Protected data
64 
71 
72  virtual void computeEta(scalarField& correction)=0;
73 
74 
75 private:
76 
77  // Private Member Functions
78 
79  //- No copy construct
80  optimisationType(const optimisationType&) = delete;
81 
82  //- No copy assignment
83  void operator=(const optimisationType&) = delete;
84 
85 
86 public:
87 
88  //- Runtime type information
89  TypeName("optimisationType");
90 
91 
92  // Declare run-time constructor selection table
93 
95  (
96  autoPtr,
98  dictionary,
99  (
100  fvMesh& mesh,
101  const dictionary& dict,
103  ),
105  );
106 
107 
108 
109  // Constructors
110 
111  //- Construct from components
113  (
114  fvMesh& mesh,
115  const dictionary& dict,
117  );
118 
119  // Selectors
120 
121  //- Return a reference to the selected turbulence model
123  (
124  fvMesh& mesh,
125  const dictionary& dict,
127  );
128 
129 
130  // Destructor
131 
132  virtual ~optimisationType() = default;
133 
134  //- Update design variables
135  virtual void update() = 0;
136 
137  //- Update design variables based on a given correction
138  virtual void update(scalarField& correction) = 0;
139 
140  //- Store design variables, as the starting point for line search
141  virtual void storeDesignVariables() = 0;
142 
143  //- Reset to starting point of line search
144  virtual void resetDesignVariables() = 0;
145 
146  //- Compute update direction
148 
149  //- Compute the merit function of the optimisation problem.
150  // Could be different than the objective function in case of
151  // constraint optimisation
152  virtual scalar computeMeritFunction();
153 
154  //- Derivative of the merit function
155  virtual scalar meritFunctionDirectionalDerivative();
156 
157  //- Update old correction. Needed for quasi-Newton Methods
158  virtual void updateOldCorrection(const scalarField&);
159 
160  //- Write useful quantities to files
161  virtual void write();
162 
163  //- Get source term
165 
166  //- Get a reference to the line search object
168 };
169 
170 
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 
173 } // End namespace incompressible
174 } // End namespace Foam
175 
176 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
177 
178 #endif
179 
180 // ************************************************************************* //
updateMethod.H
Foam::incompressible::optimisationType::getLineSearch
autoPtr< lineSearch > & getLineSearch()
Get a reference to the line search object.
Definition: optimisationTypeIncompressible.C:283
Foam::incompressible::optimisationType::meritFunctionDirectionalDerivative
virtual scalar meritFunctionDirectionalDerivative()
Derivative of the merit function.
Definition: optimisationTypeIncompressible.C:259
Foam::incompressible::optimisationType::write
virtual void write()
Write useful quantities to files.
Definition: optimisationTypeIncompressible.C:271
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
Foam::incompressible::optimisationType::sourcePtr
const autoPtr< volScalarField > & sourcePtr()
Get source term.
Definition: optimisationTypeIncompressible.C:277
Foam::incompressible::optimisationType
Abstract base class for optimisation methods.
Definition: optimisationTypeIncompressible.H:58
Foam::incompressible::optimisationType::sourcePtr_
autoPtr< volScalarField > sourcePtr_
Definition: optimisationTypeIncompressible.H:68
Foam::correction
tmp< fvMatrix< Type > > correction(const fvMatrix< Type > &)
Return the correction form of the given matrix.
Foam::incompressible::optimisationType::computeDirection
virtual tmp< scalarField > computeDirection()
Compute update direction.
Definition: optimisationTypeIncompressible.C:160
adjointSolverManager.H
Foam::incompressible::optimisationType::storeDesignVariables
virtual void storeDesignVariables()=0
Store design variables, as the starting point for line search.
Foam::Field< scalar >
Foam::incompressible::optimisationType::TypeName
TypeName("optimisationType")
Runtime type information.
adjointSolverManagers
PtrList< adjointSolverManager > & adjointSolverManagers
Definition: createFields.H:8
Foam::incompressible::optimisationType::update
virtual void update()=0
Update design variables.
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:65
Foam::incompressible::optimisationType::mesh_
fvMesh & mesh_
Definition: optimisationTypeIncompressible.H:64
Foam::incompressible::optimisationType::adjointSolvManagers_
PtrList< adjointSolverManager > & adjointSolvManagers_
Definition: optimisationTypeIncompressible.H:66
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:121
Foam::incompressible::optimisationType::dict_
const dictionary dict_
Definition: optimisationTypeIncompressible.H:65
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:84
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::incompressible::optimisationType::~optimisationType
virtual ~optimisationType()=default
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::incompressible::optimisationType::updateMethod_
autoPtr< updateMethod > updateMethod_
Definition: optimisationTypeIncompressible.H:67
lineSearch.H
Foam::incompressible::optimisationType::computeEta
virtual void computeEta(scalarField &correction)=0
Foam::incompressible::optimisationType::New
static autoPtr< optimisationType > New(fvMesh &mesh, const dictionary &dict, PtrList< adjointSolverManager > &adjointSolverManagers)
Return a reference to the selected turbulence model.
Definition: optimisationTypeIncompressible.C:128
Foam::incompressible::optimisationType::resetDesignVariables
virtual void resetDesignVariables()=0
Reset to starting point of line search.
Foam::incompressible::optimisationType::updateOldCorrection
virtual void updateOldCorrection(const scalarField &)
Update old correction. Needed for quasi-Newton Methods.
Definition: optimisationTypeIncompressible.C:265
Foam::incompressible::optimisationType::lineSearch_
autoPtr< lineSearch > lineSearch_
Definition: optimisationTypeIncompressible.H:69
Foam::incompressible::optimisationType::computeMeritFunction
virtual scalar computeMeritFunction()
Compute the merit function of the optimisation problem.
Definition: optimisationTypeIncompressible.C:232
Foam::incompressible::optimisationType::declareRunTimeSelectionTable
declareRunTimeSelectionTable(autoPtr, optimisationType, dictionary,(fvMesh &mesh, const dictionary &dict, PtrList< adjointSolverManager > &adjointSolverManagers),(mesh, dict, adjointSolverManagers))