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 -------------------------------------------------------------------------------
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 Class
29  Foam::incompressible::shapeSensitivitiesBase
30 
31 Description
32  Base class supporting shape sensitivity derivatives
33 
34 SourceFiles
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"
45 #include "volPointInterpolation.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 
57 namespace Foam
58 {
59 
60 /*---------------------------------------------------------------------------*\
61  Class shapeSensitivitiesBase Declaration
62 \*---------------------------------------------------------------------------*/
63 
65 {
66 protected:
67 
68  // Protected data
69 
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 
142 private:
143 
144  // Private Member Functions
145 
146  //- No copy construct
148 
149  //- No copy assignment
150  void operator=(const shapeSensitivitiesBase&) = delete;
151 
152 
153 public:
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 // ************************************************************************* //
Foam::shapeSensitivitiesBase::writePointBasedSens
void writePointBasedSens() const
Write point-based sensitivities, if present.
Definition: shapeSensitivitiesBase.C:80
Foam::shapeSensitivitiesBase::getWallFaceSensNormalVecBoundary
virtual const boundaryVectorField & getWallFaceSensNormalVecBoundary() const
Get wall face normal sens as vectors field.
Definition: shapeSensitivitiesBase.C:367
Foam::shapeSensitivitiesBase::sensitivityPatchIDs
const labelHashSet & sensitivityPatchIDs() const
Get patch IDs on which sensitivities are computed.
Definition: shapeSensitivitiesBase.C:160
Foam::shapeSensitivitiesBase::getWallFaceSensVec
tmp< volVectorField > getWallFaceSensVec()
Get wall face sensitivity vectors field.
Definition: shapeSensitivitiesBase.C:230
volFields.H
Foam::shapeSensitivitiesBase::wallFaceSensVecPtr_
autoPtr< boundaryVectorField > wallFaceSensVecPtr_
Wall face sens w.r.t. (x,y.z)
Definition: shapeSensitivitiesBase.H:83
Foam::shapeSensitivitiesBase::sensitivityPatchIDs_
labelHashSet sensitivityPatchIDs_
Definition: shapeSensitivitiesBase.H:74
Foam::shapeSensitivitiesBase::constructAndWriteSensitivityField
void constructAndWriteSensitivityField(const autoPtr< typename GeometricField< Type, fvPatchField, volMesh >::Boundary > &sensFieldPtr, const word &name) const
Constructs volField based on boundaryField and writes it.
Definition: shapeSensitivitiesBaseTemplates.C:41
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::shapeSensitivitiesBase::wallPointSensVecPtr_
autoPtr< pointBoundaryVectorField > wallPointSensVecPtr_
Wall point sens w.r.t. (x,y.z)
Definition: shapeSensitivitiesBase.H:95
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::shapeSensitivitiesBase::getWallPointSensNormalVec
tmp< pointVectorField > getWallPointSensNormalVec()
Get wall point sens as vectors field.
Definition: shapeSensitivitiesBase.C:343
pointPatchField.H
Foam::shapeSensitivitiesBase::wallFaceSensNormalPtr_
autoPtr< boundaryScalarField > wallFaceSensNormalPtr_
Wall face sens projected to normal.
Definition: shapeSensitivitiesBase.H:86
Foam::shapeSensitivitiesBase::getWallPointSensNormal
tmp< pointScalarField > getWallPointSensNormal()
Get wall point sensitivity projected to normal field.
Definition: shapeSensitivitiesBase.C:333
Foam::shapeSensitivitiesBase::getWallFaceSensNormalVec
tmp< volVectorField > getWallFaceSensNormalVec()
Get wall face normal sens as vectors field.
Definition: shapeSensitivitiesBase.C:291
surfaceFields.H
Foam::surfaceFields.
Foam::shapeSensitivitiesBase::getWallFaceSensVecBoundary
virtual const boundaryVectorField & getWallFaceSensVecBoundary() const
Get wall face sensitivity vectors field.
Definition: shapeSensitivitiesBase.C:353
Foam::shapeSensitivitiesBase::wallFaceSensNormalVecPtr_
autoPtr< boundaryVectorField > wallFaceSensNormalVecPtr_
Normal sens as vectors.
Definition: shapeSensitivitiesBase.H:89
Foam::HashSet< label, Hash< label > >
Foam::shapeSensitivitiesBase::TypeName
TypeName("shapeSensitivitiesBase")
Runtime type information.
pointPatchFieldsFwd.H
Foam::shapeSensitivitiesBase::writeAllSurfaceFiles_
bool writeAllSurfaceFiles_
Definition: shapeSensitivitiesBase.H:71
Foam::shapeSensitivitiesBase
Definition: shapeSensitivitiesBase.H:63
Foam::shapeSensitivitiesBase::wallPointSensNormalPtr_
autoPtr< pointBoundaryScalarField > wallPointSensNormalPtr_
Wall point sens projected to normal.
Definition: shapeSensitivitiesBase.H:98
shapeSensitivitiesBaseTemplates.C
Foam::shapeSensitivitiesBase::getWallFaceSensNormal
tmp< volScalarField > getWallFaceSensNormal()
Get wall face sensitivity projected to normal field.
Definition: shapeSensitivitiesBase.C:261
Foam::shapeSensitivitiesBase::write
void write()
Write sensitivity fields.
Definition: shapeSensitivitiesBase.C:216
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::shapeSensitivitiesBase::wallPointSensNormalVecPtr_
autoPtr< pointBoundaryVectorField > wallPointSensNormalVecPtr_
Normal sens as vectors.
Definition: shapeSensitivitiesBase.H:101
createZeroField.H
Foam::shapeSensitivitiesBase::surfaceFieldSuffix_
word surfaceFieldSuffix_
Definition: shapeSensitivitiesBase.H:70
Foam::shapeSensitivitiesBase::constructAndWriteSensitivtyPointField
void constructAndWriteSensitivtyPointField(const autoPtr< List< Field< Type >>> &sensFieldPtr, const word &name) const
Constructs pointField based on boundaryField and writes it.
Definition: shapeSensitivitiesBaseTemplates.C:74
fixedValuePointPatchField.H
Foam::shapeSensitivitiesBase::constructVolSensitivtyField
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.
Definition: shapeSensitivitiesBaseTemplates.C:113
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:123
Foam::shapeSensitivitiesBase::setSensitivityPatchIDs
void setSensitivityPatchIDs(const labelHashSet &sensPatchIDs)
Overwrite sensitivityPatchIDs.
Definition: shapeSensitivitiesBase.C:167
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::shapeSensitivitiesBase::meshShape_
const fvMesh & meshShape_
Definition: shapeSensitivitiesBase.H:69
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
volPointInterpolation.H
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::GeometricField::Boundary
The boundary fields.
Definition: GeometricField.H:115
boundaryFieldsFwd.H
Useful typenames for fields defined only at the boundaries.
Foam::shapeSensitivitiesBase::~shapeSensitivitiesBase
virtual ~shapeSensitivitiesBase()=default
Destructor.
Foam::shapeSensitivitiesBase::getWallFaceSensNormalBoundary
virtual const boundaryScalarField & getWallFaceSensNormalBoundary() const
Get wall face sensitivity projected to normal field.
Definition: shapeSensitivitiesBase.C:360
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::shapeSensitivitiesBase::clearSensitivities
void clearSensitivities()
Zero sensitivity fields and their constituents.
Definition: shapeSensitivitiesBase.C:175
dictionary.H
Foam::shapeSensitivitiesBase::writeFaceBasedSens
void writeFaceBasedSens() const
Write face-based sensitivities, if present.
Definition: shapeSensitivitiesBase.C:43
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::shapeSensitivitiesBase::setSuffix
void setSuffix(const word &suffix)
Set suffix.
Definition: shapeSensitivitiesBase.C:223
Foam::GeometricField
Generic GeometricField class.
Definition: areaFieldsFwd.H:53
pointMesh.H
Foam::shapeSensitivitiesBase::getWallPointSensVec
tmp< pointVectorField > getWallPointSensVec()
Get wall point sensitivity vectors field.
Definition: shapeSensitivitiesBase.C:323