shapeSensitivitiesBase.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-2020 PCOpt/NTUA
9 Copyright (C) 2013-2020 FOSS GP
10 Copyright (C) 2019 OpenCFD Ltd.
11-------------------------------------------------------------------------------
12License
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
28Class
29 Foam::incompressible::shapeSensitivitiesBase
30
31Description
32 Base class supporting shape sensitivity derivatives
33
34SourceFiles
35 shapeSensitivitiesBase.C
36
37\*---------------------------------------------------------------------------*/
38
39#ifndef shapeSensitivitiesBase_H
40#define shapeSensitivitiesBase_H
41
42#include "volFields.H"
43#include "surfaceFields.H"
44#include "dictionary.H"
46
47#include "pointMesh.H"
48#include "pointPatchField.H"
49#include "pointPatchFieldsFwd.H"
51#include "boundaryFieldsFwd.H"
52#include "createZeroField.H"
53
54
55// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56
57namespace Foam
58{
59
60/*---------------------------------------------------------------------------*\
61 Class shapeSensitivitiesBase Declaration
62\*---------------------------------------------------------------------------*/
65{
66protected:
67
68 // Protected data
73
74 // Patches on which to compute shape sensitivities
76
77 // autoPtrs for fields holding sensitivities.
78 // Not all of them are required for each case
79
80 // Boundary sensitivities at faces. Shape opt & flow control
81 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
82
83 //- Wall face sens w.r.t. (x,y.z)
85
86 //- Wall face sens projected to normal
88
89 //- Normal sens as vectors
91
92 // Boundary sensitivities at points. Shape opt
93 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
94
95 //- Wall point sens w.r.t. (x,y.z)
97
98 //- Wall point sens projected to normal
100
101 //- Normal sens as vectors
103
104 //- Constructs volField based on boundaryField and writes it
105 template<class Type>
107 (
108 const autoPtr
109 <
111 >& sensFieldPtr,
112 const word& name
113 ) const;
114
115 //- Constructs pointField based on boundaryField and writes it
116 template<class Type>
118 (
119 const autoPtr<List<Field<Type>>>& sensFieldPtr,
120 const word& name
121 ) const;
122
123 //- Constructs volField based on boundaryField and writes it
124 template<class Type>
127 (
128 const autoPtr
129 <
131 >& sensFieldPtr,
132 const word& name
133 ) const;
134
135 //- Write face-based sensitivities, if present
136 void writeFaceBasedSens() const;
137
138 //- Write point-based sensitivities, if present
139 void writePointBasedSens() const;
140
141
142private:
143
144 // Private Member Functions
145
146 //- No copy construct
148
149 //- No copy assignment
150 void operator=(const shapeSensitivitiesBase&) = delete;
151
152
153public:
154
155 //- Runtime type information
156 TypeName("shapeSensitivitiesBase");
157
158
159 // Constructors
160
161 //- Construct from components
163 (
164 const fvMesh& mesh,
165 const dictionary& dict
166 );
167
168
169 //- Destructor
170 virtual ~shapeSensitivitiesBase() = default;
171
172
173 // Member Functions
174
175 //- Get patch IDs on which sensitivities are computed
176 const labelHashSet& sensitivityPatchIDs() const;
177
178 //- Overwrite sensitivityPatchIDs
179 void setSensitivityPatchIDs(const labelHashSet& sensPatchIDs);
180
181 //- Zero sensitivity fields and their constituents
182 void clearSensitivities();
183
184 //- Write sensitivity fields.
185 // If valid, copies boundaryFields to volFields and writes them.
186 void write();
187
188 //- Set suffix
189 void setSuffix(const word& suffix);
190
191 //- Get wall face sensitivity vectors field
193
194 //- Get wall face sensitivity projected to normal field
196
197 //- Get wall face normal sens as vectors field
199
200 //- Get wall point sensitivity vectors field
201 // Uses volPointInterpolation
203
204 //- Get wall point sensitivity projected to normal field
205 // Uses volPointInterpolation
207
208 //- Get wall point sens as vectors field
209 // Uses volPointInterpolation
211
212 //- Get wall face sensitivity vectors field
213 virtual const boundaryVectorField& getWallFaceSensVecBoundary() const;
214
215 //- Get wall face sensitivity projected to normal field
216 virtual const boundaryScalarField&
218
219 //- Get wall face normal sens as vectors field
220 virtual const boundaryVectorField&
222};
223
224
225// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
226
227} // End namespace Foam
228
229// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
230
231#ifdef NoRepository
233#endif
234
235// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
236
237#endif
238
239// ************************************************************************* //
Useful typenames for fields defined only at the boundaries.
Generic templated field type.
Definition: Field.H:82
Generic GeometricBoundaryField class.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
tmp< volVectorField > getWallFaceSensVec()
Get wall face sensitivity vectors field.
autoPtr< pointBoundaryVectorField > wallPointSensNormalVecPtr_
Normal sens as vectors.
void clearSensitivities()
Zero sensitivity fields and their constituents.
tmp< volVectorField > getWallFaceSensNormalVec()
Get wall face normal sens as vectors field.
autoPtr< boundaryVectorField > wallFaceSensVecPtr_
Wall face sens w.r.t. (x,y.z)
virtual const boundaryScalarField & getWallFaceSensNormalBoundary() const
Get wall face sensitivity projected to normal field.
void setSuffix(const word &suffix)
Set suffix.
virtual ~shapeSensitivitiesBase()=default
Destructor.
virtual const boundaryVectorField & getWallFaceSensNormalVecBoundary() const
Get wall face normal sens as vectors field.
void writeFaceBasedSens() const
Write face-based sensitivities, if present.
void writePointBasedSens() const
Write point-based sensitivities, if present.
virtual const boundaryVectorField & getWallFaceSensVecBoundary() const
Get wall face sensitivity vectors field.
autoPtr< pointBoundaryVectorField > wallPointSensVecPtr_
Wall point sens w.r.t. (x,y.z)
tmp< pointVectorField > getWallPointSensVec()
Get wall point sensitivity vectors field.
tmp< pointScalarField > getWallPointSensNormal()
Get wall point sensitivity projected to normal field.
tmp< GeometricField< Type, fvPatchField, volMesh > > constructVolSensitivtyField(const autoPtr< typename GeometricField< Type, fvPatchField, volMesh >::Boundary > &sensFieldPtr, const word &name) const
Constructs volField based on boundaryField and writes it.
tmp< pointVectorField > getWallPointSensNormalVec()
Get wall point sens as vectors field.
autoPtr< pointBoundaryScalarField > wallPointSensNormalPtr_
Wall point sens projected to normal.
tmp< volScalarField > getWallFaceSensNormal()
Get wall face sensitivity projected to normal field.
void constructAndWriteSensitivityField(const autoPtr< typename GeometricField< Type, fvPatchField, volMesh >::Boundary > &sensFieldPtr, const word &name) const
Constructs volField based on boundaryField and writes it.
void write()
Write sensitivity fields.
autoPtr< boundaryScalarField > wallFaceSensNormalPtr_
Wall face sens projected to normal.
void setSensitivityPatchIDs(const labelHashSet &sensPatchIDs)
Overwrite sensitivityPatchIDs.
void constructAndWriteSensitivtyPointField(const autoPtr< List< Field< Type > > > &sensFieldPtr, const word &name) const
Constructs pointField based on boundaryField and writes it.
const labelHashSet & sensitivityPatchIDs() const
Get patch IDs on which sensitivities are computed.
autoPtr< boundaryVectorField > wallFaceSensNormalVecPtr_
Normal sens as vectors.
TypeName("shapeSensitivitiesBase")
Runtime type information.
A class for managing temporary objects.
Definition: tmp.H:65
A class for handling words, derived from Foam::string.
Definition: word.H:68
dynamicFvMesh & mesh
Namespace for OpenFOAM.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
dictionary dict
Foam::surfaceFields.
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73