BezierDesignVariables.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-2023 PCOpt/NTUA
9  Copyright (C) 2013-2023 FOSS GP
10 -------------------------------------------------------------------------------
11 License
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 Class
28  Foam::BezierDesignVariables
29 
30 Description
31  Bezier design variables for shape optimisation
32 
33 SourceFiles
34  BezierDesignVariables.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef BezierDesignVariables_H
39 #define BezierDesignVariables_H
40 
41 #include "shapeDesignVariables.H"
42 #include "Bezier.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 /*---------------------------------------------------------------------------*\
50  Class BezierDesignVariables Decleration
51 \*---------------------------------------------------------------------------*/
52 
54 :
56 {
57 protected:
58 
59  // Protected Data Members
60 
61  //- The Bezier control points and auxiliary functions
63 
64  //- Boundary movement due to the change in Bezier control points
66 
67 
68  // Protected Member Functions
69 
70  //- Read bounds for design variables, if present
71  void readBounds
72  (
73  autoPtr<scalar> lowerBoundPtr = nullptr,
74  autoPtr<scalar> upperBoundPtr = nullptr
75  );
76 
77  //- Set uniform bounds for all control points
78  void setBounds(autoPtr<scalarField>& bounds, const vector& cpBounds);
79 
80  //- Transform the correction of design variables to control points'
81  //- movement
83  (
84  const scalarField& correction
85  );
86 
87  //- Decompose varID to cpID and direction
88  void decomposeVarID(label& cpI, label& dir, const label varID) const;
89 
90 
91 private:
92 
93  // Private Member Functions
94 
95  //- No copy construct
97 
98  //- No copy assignment
99  void operator=(const BezierDesignVariables&) = delete;
100 
101 
102 public:
103 
104  //- Runtime type information
105  TypeName("Bezier");
106 
107 
108  // Constructors
109 
110  //- Construct from components
112  (
113  fvMesh& mesh,
114  const dictionary& dict
115  );
116 
117 
118  //- Destructor
119  virtual ~BezierDesignVariables() = default;
120 
121 
122  // Member Functions
123 
124  //- Update design variables based on a given correction
125  virtual void update(scalarField& correction);
126 
127  //- Compute eta if not set in the first step
128  virtual scalar computeEta(scalarField& correction);
129 
130  //- Whether to use global sum when computing matrix-vector products
131  // in update methods
132  virtual bool globalSum() const;
133 
134 
135  // Fields related to sensitivity computations
136 
137  //- Get dxdb for given design variable and patch
138  virtual tmp<vectorField> dxdbFace
139  (
140  const label patchI,
141  const label varID
142  ) const;
143 
144  //- Get dndb for given design variable and patch
145  virtual tmp<vectorField> dndb
146  (
147  const label patchI,
148  const label varID
149  ) const;
150 
151  //- Get dSdb for given design variable and patch
152  virtual tmp<vectorField> dSdb
153  (
154  const label patchI,
155  const label varID
156  ) const;
157 
158  //- Get dCdb for given design variable.
159  // Used for FI-based sensitivities
160  virtual tmp<volVectorField> dCdb(const label varID) const;
161 };
162 
163 
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 
166 } // End namespace Foam
167 
168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 
170 #endif
171 
172 // ************************************************************************* //
tmp< fvMatrix< Type > > correction(const fvMatrix< Type > &)
Return the correction form of the given matrix by subtracting the matrix multiplied by the current fi...
dictionary dict
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
virtual bool globalSum() const
Whether to use global sum when computing matrix-vector products.
virtual scalar computeEta(scalarField &correction)
Compute eta if not set in the first step.
virtual tmp< vectorField > dxdbFace(const label patchI, const label varID) const
Get dxdb for given design variable and patch.
void decomposeVarID(label &cpI, label &dir, const label varID) const
Decompose varID to cpID and direction.
TypeName("Bezier")
Runtime type information.
dynamicFvMesh & mesh
Bezier design variables for shape optimisation.
virtual ~BezierDesignVariables()=default
Destructor.
pointVectorField dx_
Boundary movement due to the change in Bezier control points.
void setBounds(autoPtr< scalarField > &bounds, const vector &cpBounds)
Set uniform bounds for all control points.
tmp< vectorField > computeBoundaryDisplacement(const scalarField &correction)
Transform the correction of design variables to control points&#39; movement.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
virtual tmp< volVectorField > dCdb(const label varID) const
Get dCdb for given design variable.
virtual void update(scalarField &correction)
Update design variables based on a given correction.
Calculation of adjoint based sensitivities for Bezier control points.
Definition: Bezier.H:54
Abstract base class for defining design variables for shape optimisation.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
virtual tmp< vectorField > dndb(const label patchI, const label varID) const
Get dndb for given design variable and patch.
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Bezier bezier_
The Bezier control points and auxiliary functions.
void readBounds(autoPtr< scalar > lowerBoundPtr=nullptr, autoPtr< scalar > upperBoundPtr=nullptr)
Read bounds for design variables, if present.
Namespace for OpenFOAM.
virtual tmp< vectorField > dSdb(const label patchI, const label varID) const
Get dSdb for given design variable and patch.