Loading...
Searching...
No Matches
morphingBoxConstraint.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) 2021-2023 PCOpt/NTUA
9 Copyright (C) 2021-2023 FOSS GP
10-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::morphingBoxConstraint
29
30Description
31 Abstract base class for defining constraints for the control points of
32 volumetric B-Splines morphing boxes
33
34SourceFiles
35 morphingBoxConstraint.C
36
37\*---------------------------------------------------------------------------*/
38
39#ifndef morphingBoxConstraint_H
40#define morphingBoxConstraint_H
41
42#include "volBSplinesBase.H"
44
45// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46
47namespace Foam
48{
49
50// Forward declaration
53/*---------------------------------------------------------------------------*\
54 Class morphingBoxConstraint Declaration
55\*---------------------------------------------------------------------------*/
56
57class morphingBoxConstraint
58{
59protected:
60
61 // Protected data
62
63 //- Mesh reference
64 const fvMesh& mesh_;
65
66 //- Volumetric B-Splines variables dict
67 const dictionary dict_;
68
69 //- Reference to underlaying volumetric B-Splines morpher
72 //- Easy access to the volBSplinesBase resting in the designVariables_
74
75 //- Initial CPs stored in scalarField
77
78 //- Initialise the design variables
79 bool initialiseVars_;
80
81 //- Folder holding the twist sensitivities
83
84
85 // Protected Member Functions
87 //- Compute sensitivities wrt the design variables (chain rule)
88 void virtual computeDVsSensitivities
89 (
90 scalarField& dvSens,
91 const scalarField& cpSens
92 ) = 0;
93
94 //- Write sensitivities w.r.t. the design variables
95 void virtual writeDVSensitivities
96 (
97 const scalarField& sens,
98 const word& name
99 );
100
101
102private:
103
104 // Private Member Functions
105
106 //- Disallow default bitwise copy construct
107 morphingBoxConstraint(const morphingBoxConstraint&) = delete;
108
109 //- Disallow default bitwise assignment
110 void operator=(const morphingBoxConstraint&) = delete;
111
112
113public:
114
115 //- Runtime type information
116 TypeName("morphingBoxConstraint");
117
118
119 // Declare run-time constructor selection table
120
122 (
123 autoPtr,
124 morphingBoxConstraint,
126 (
127 const fvMesh& mesh,
128 const dictionary& dict,
130 ),
132 );
133
134
135 // Constructors
136
137 //- Construct from components
138 morphingBoxConstraint
139 (
140 const fvMesh& mesh,
141 const dictionary& dict,
143 );
144
145
146 // Selectors
147
148 //- Construct and return the selected morphingBoxConstraint
150 (
151 const fvMesh& mesh,
152 const dictionary& dict,
154 );
155
156
157 //- Destructor
158 virtual ~morphingBoxConstraint() = default;
159
160
161 // Member Functions
162
163 //- Compute the active design variables based on the IDs of the
164 //- active control point coordinates
166 (
167 const labelList& activeCPCoors
168 ) = 0;
169
170 //- Transform bounds from control points to design variables
171 // WIP
172 virtual void computeBounds
173 (
174 autoPtr<scalarField>& lowerBounds,
175 autoPtr<scalarField>& upperBounds
176 );
177
178 //- Update the bounds of the design variables
179 // WIP
180 virtual void updateBounds
181 (
182 autoPtr<scalarField>& lowerBounds,
184 );
185
186 //- Convert design variables to control points, stored in a scalarField
188 (
190 ) = 0;
191
192 //- Return the design variables corresponding to the given control
193 //- points
195 (
196 const scalarField& cps
197 ) = 0;
198
199 //- Convert the correction of the design variables to the correction of
200 //- the control points
202 (
204 ) = 0;
205
206 //- Chain rule from control points to design variables
208 (
209 const scalarField& controlPointSens,
210 const word& adjointSolverName
211 );
212
213 //- Compute eta if not set in the first step
214 virtual scalar computeEta
215 (
217 const scalar maxInitChange
218 );
219
220 //- Initialise the design variables?
221 inline bool initialiseVars() const
223 return initialiseVars_;
224 }
225
226 //- Append useful information to the design variables IOdictionary
227 virtual bool writeData(Ostream& os) const;
228};
229
230
231// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
232
233} // End namespace Foam
234
235// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
236
237#endif
238
239// ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
Abstract base class for defining design variables.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
A class for handling file names.
Definition fileName.H:75
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
virtual tmp< scalarField > controlPointsToDesignVariables(const scalarField &cps)=0
Return the design variables corresponding to the given control points.
TypeName("morphingBoxConstraint")
Runtime type information.
virtual tmp< scalarField > designVariablesToControlPoints(const scalarField &designVariables)=0
Convert design variables to control points, stored in a scalarField.
virtual tmp< scalarField > postProcessSens(const scalarField &controlPointSens, const word &adjointSolverName)
Chain rule from control points to design variables.
volumetricBSplinesDesignVariables & designVariables_
Reference to underlaying volumetric B-Splines morpher.
bool initialiseVars() const
Initialise the design variables?
virtual void computeDVsSensitivities(scalarField &dvSens, const scalarField &cpSens)=0
Compute sensitivities wrt the design variables (chain rule).
const fvMesh & mesh_
Mesh reference.
virtual scalar computeEta(scalarField &correction, const scalar maxInitChange)
Compute eta if not set in the first step.
virtual void computeBounds(autoPtr< scalarField > &lowerBounds, autoPtr< scalarField > &upperBounds)
Transform bounds from control points to design variables.
static autoPtr< morphingBoxConstraint > New(const fvMesh &mesh, const dictionary &dict, volumetricBSplinesDesignVariables &designVariables)
Construct and return the selected morphingBoxConstraint.
virtual bool writeData(Ostream &os) const
Append useful information to the design variables IOdictionary.
fileName derivativesFolder_
Folder holding the twist sensitivities.
virtual labelList computeActiveDesignVariables(const labelList &activeCPCoors)=0
Compute the active design variables based on the IDs of the active control point coordinates.
virtual tmp< scalarField > correctionCPs(const scalarField &correction)=0
Convert the correction of the design variables to the correction of the control points.
scalarField initialCPs_
Initial CPs stored in scalarField.
declareRunTimeSelectionTable(autoPtr, morphingBoxConstraint, dictionary,(const fvMesh &mesh, const dictionary &dict, volumetricBSplinesDesignVariables &designVariables),(mesh, dict, designVariables))
virtual void updateBounds(autoPtr< scalarField > &lowerBounds, autoPtr< scalarField > &upperBounds)
Update the bounds of the design variables.
bool initialiseVars_
Initialise the design variables.
const dictionary dict_
Volumetric B-Splines variables dict.
virtual void writeDVSensitivities(const scalarField &sens, const word &name)
Write sensitivities w.r.t. the design variables.
virtual ~morphingBoxConstraint()=default
Destructor.
volBSplinesBase & volBSplinesBase_
Easy access to the volBSplinesBase resting in the designVariables_.
A class for managing temporary objects.
Definition tmp.H:75
Class constructing a number of volumetric B-Splines boxes, read from dynamicMeshDict....
Volumetric B-Splines design variables for shape optimisation.
A class for handling words, derived from Foam::string.
Definition word.H:66
dynamicFvMesh & mesh
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition List.H:62
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
tmp< fvMatrix< Type > > correction(const fvMatrix< Type > &)
Return the correction form of the given matrix by subtracting the matrix multiplied by the current fi...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
Macros to ease declaration of run-time selection tables.
#define declareRunTimeSelectionTable(ptrWrapper, baseType, argNames, argList, parList)
Declare a run-time selection (variables and adder classes).
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68