sensitivity.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::sensitivity
31 
32 Description
33  Abstract base class for adjoint sensitivities
34 
35 SourceFiles
36  sensitivity.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef sensitivity_H
41 #define sensitivity_H
42 
43 #include "volFields.H"
44 #include "surfaceFields.H"
45 #include "dictionary.H"
46 #include "volPointInterpolation.H"
47 
48 #include "pointMesh.H"
49 #include "pointPatchField.H"
50 #include "pointPatchFieldsFwd.H"
52 #include "boundaryFieldsFwd.H"
53 #include "createZeroField.H"
54 
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 
57 namespace Foam
58 {
59 
60 /*---------------------------------------------------------------------------*\
61  Class sensitivity Declaration
62 \*---------------------------------------------------------------------------*/
63 
64 class sensitivity
65 {
66 protected:
67 
68  // Protected data
69 
70  const fvMesh& mesh_;
72 
73  // Field sensitivities. Topology optimisation
74  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
76 
77 
78  // Protected Member Functions
79 
80 private:
81 
82  // Private Member Functions
83 
84  //- No copy construct
85  sensitivity(const sensitivity&) = delete;
86 
87  //- No copy assignment
88  void operator=(const sensitivity&) = delete;
89 
90 
91 public:
92 
93  //- Runtime type information
94  TypeName("sensitivity");
95 
96  // Constructors
97 
98  //- Construct from components
100  (
101  const fvMesh& mesh,
102  const dictionary& dict
103  );
104 
105  //- Destructor
106  virtual ~sensitivity() = default;
107 
108 
109  // Member Functions
110 
111  //- Return the construction dictionary
112  const dictionary& dict() const;
113 
114  //- Read dictionary if changed
115  virtual bool readDict(const dictionary& dict);
116 
117  //- Compute design variables number. Does nothing in the base
118  // Used to get the correct design variables number when
119  // setSensitivityPatchIDs are not set in the constructor
120  virtual void computeDerivativesSize();
121 
122  //- Calculates and returns sensitivity fields.
123  // Used with optimisation libraries
124  virtual const scalarField& calculateSensitivities() = 0;
125 
126  //- Write sensitivity fields.
127  // If valid, copies boundaryFields to volFields and writes them.
128  // Virtual to be reimplemented by control points-based methods
129  // (Bezier, RBF) which do not need to write fields
130  virtual void write(const word& baseName = word::null);
131 
132 };
133 
134 
135 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
136 
137 } // End namespace Foam
138 
139 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
140 
141 //#ifdef NoRepository
142 // #include "sensitivityTemplates.C"
143 //#endif
144 
145 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
146 
147 #endif
148 
149 // ************************************************************************* //
Foam::sensitivity::dict
const dictionary & dict() const
Return the construction dictionary.
Definition: sensitivity.C:57
volFields.H
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
pointPatchField.H
surfaceFields.H
Foam::surfaceFields.
pointPatchFieldsFwd.H
Foam::sensitivity::mesh_
const fvMesh & mesh_
Definition: sensitivity.H:69
Foam::Field< scalar >
createZeroField.H
Foam::sensitivity::readDict
virtual bool readDict(const dictionary &dict)
Read dictionary if changed.
Definition: sensitivity.C:63
Foam::sensitivity::~sensitivity
virtual ~sensitivity()=default
Destructor.
fixedValuePointPatchField.H
Foam::sensitivity::fieldSensPtr_
autoPtr< volScalarField > fieldSensPtr_
Definition: sensitivity.H:74
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
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
volPointInterpolation.H
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::sensitivity::dict_
dictionary dict_
Definition: sensitivity.H:70
Foam::sensitivity::calculateSensitivities
virtual const scalarField & calculateSensitivities()=0
Calculates and returns sensitivity fields.
boundaryFieldsFwd.H
Useful typenames for fields defined only at the boundaries.
Foam::sensitivity::TypeName
TypeName("sensitivity")
Runtime type information.
dictionary.H
Foam::word::null
static const word null
An empty word.
Definition: word.H:77
Foam::sensitivity::write
virtual void write(const word &baseName=word::null)
Write sensitivity fields.
Definition: sensitivity.C:77
Foam::sensitivity
Abstract base class for adjoint sensitivities.
Definition: sensitivity.H:63
Foam::sensitivity::computeDerivativesSize
virtual void computeDerivativesSize()
Compute design variables number. Does nothing in the base.
Definition: sensitivity.C:71
pointMesh.H