adjointSensitivityIncompressible.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 Class
29  Foam::incompressible::adjointSensitivity
30 
31 Description
32  Abstract base class for adjoint-based sensitivities in incompressible flows
33 
34  Reference:
35  \verbatim
36  For the FI and ESI formulations
37  Kavvadias, I., Papoutsis-Kiachagias, E., & Giannakoglou, K. (2015).
38  On the proper treatment of grid sensitivities in continuous adjoint
39  methods for shape optimization.
40  Journal of Computational Physics, 301, 1–18.
41  http://doi.org/10.1016/j.jcp.2015.08.012
42 
43  For the SI formulation
44  Papoutsis-Kiachagias, E. M., & Giannakoglou, K. C. (2014).
45  Continuous Adjoint Methods for Turbulent Flows, Applied to Shape
46  and Topology Optimization: Industrial Applications.
47  Archives of Computational Methods in Engineering, 23(2), 255–299.
48  http://doi.org/10.1007/s11831-014-9141-9
49  \endverbatim
50 
51 SourceFiles
52  adjointSensitivity.C
53 
54 \*---------------------------------------------------------------------------*/
55 
56 #ifndef adjointSensitivityIncompressible_H
57 #define adjointSensitivityIncompressible_H
58 
59 #include "sensitivity.H"
60 #include "incompressibleVars.H"
62 #include "fvOptionAdjointList.H"
63 #include "wallFvPatch.H"
64 
65 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
66 
67 namespace Foam
68 {
69 
70 namespace incompressible
71 {
72 
73 /*---------------------------------------------------------------------------*\
74  Class adjointSensitivity Declaration
75 \*---------------------------------------------------------------------------*/
76 
78 :
79  public sensitivity
80 {
81 protected:
82 
83  // Protected data
84 
90 
91 
92 private:
93 
94  // Private Member Functions
95 
96  //- No copy construct
97  adjointSensitivity(const adjointSensitivity&) = delete;
98 
99  //- No copy assignment
100  void operator=(const adjointSensitivity&) = delete;
101 
102 
103 public:
104 
105  //- Runtime type information
106  TypeName("adjointSensitivity");
107 
108 
109  // Declare run-time constructor selection table
110 
112  (
113  autoPtr,
115  dictionary,
116  (
117  const fvMesh& mesh,
118  const dictionary& dict,
119  incompressibleVars& primalVars,
120  incompressibleAdjointVars& adjointVars,
123  ),
124  (
125  mesh,
126  dict,
127  primalVars,
128  adjointVars,
131  )
132  );
133 
134 
135  // Constructors
136 
137  //- Construct from components
139  (
140  const fvMesh& mesh,
141  const dictionary& dict,
142  incompressibleVars& primalVars,
143  incompressibleAdjointVars& adjointVars,
146  );
147 
148  // Selectors
149 
150  //- Return a reference to the selected turbulence model
152  (
153  const fvMesh& mesh,
154  const dictionary& dict,
155  incompressibleVars& primalVars,
156  incompressibleAdjointVars& adjointVars,
159  );
160 
161 
162  //- Destructor
163  virtual ~adjointSensitivity() = default;
164 
165 
166  // Member Functions
167 
168  //- Accumulate sensitivity integrands
169  // Corresponds to the flow and adjoint part of the sensitivities
170  virtual void accumulateIntegrand(const scalar dt) = 0;
171 
172  //- Assemble sensitivities
173  // Adds the geometric part of the sensitivities
174  virtual void assembleSensitivities() = 0;
175 
176  //- Calculates and returns sensitivity fields.
177  // Used with optimisation libraries
178  virtual const scalarField& calculateSensitivities();
179 
180  //- Returns the sensitivity fields
181  // Assumes it has already been updated/computed
182  const scalarField& getSensitivities() const;
183 
184  //- Zero sensitivity fields and their constituents
185  virtual void clearSensitivities();
186 
187  //- Write sensitivity fields.
188  // If valid, copies boundaryFields to volFields and writes them.
189  // Virtual to be reimplemented by control points-based methods
190  // (Bezier, RBF) which do not need to write fields
191  virtual void write(const word& baseName = word::null);
192 
193  //- Compute the volTensorField multiplying grad(dxdb) for
194  //- the volume-based approach to compute shape sensitivity derivatives
196 
197  //- Compute source term for adjoint mesh movement equation
199 };
200 
201 
202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203 
204 } // End namespace incompressible
205 } // End namespace Foam
206 
207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
208 
209 #endif
210 
211 // ************************************************************************* //
Foam::sensitivity::dict
const dictionary & dict() const
Return the construction dictionary.
Definition: sensitivity.C:57
Foam::incompressible::adjointSensitivity::derivatives_
scalarField derivatives_
Definition: adjointSensitivityIncompressible.H:84
Foam::objectiveManager
class for managing incompressible objective functions.
Definition: objectiveManager.H:54
Foam::incompressible::adjointSensitivity::calculateSensitivities
virtual const scalarField & calculateSensitivities()
Calculates and returns sensitivity fields.
Definition: adjointSensitivityIncompressible.C:116
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::incompressible::adjointSensitivity::fvOptionsAdjoint_
fv::optionAdjointList & fvOptionsAdjoint_
Definition: adjointSensitivityIncompressible.H:88
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
incompressibleVars.H
Foam::incompressible::adjointSensitivity::assembleSensitivities
virtual void assembleSensitivities()=0
Assemble sensitivities.
wallFvPatch.H
Foam::incompressibleAdjointVars
Class including all adjoint fields for incompressible flows.
Definition: incompressibleAdjointVars.H:52
Foam::fv::optionAdjointList
Definition: fvOptionAdjointList.H:59
fvOptionAdjointList.H
Foam::incompressible::adjointSensitivity
Abstract base class for adjoint-based sensitivities in incompressible flows.
Definition: adjointSensitivityIncompressible.H:76
Foam::Field< scalar >
Foam::incompressible::adjointSensitivity::New
static autoPtr< adjointSensitivity > New(const fvMesh &mesh, const dictionary &dict, incompressibleVars &primalVars, incompressibleAdjointVars &adjointVars, objectiveManager &objectiveManager, fv::optionAdjointList &fvOptionsAdjoint)
Return a reference to the selected turbulence model.
Definition: adjointSensitivityIncompressible.C:73
Foam::incompressible::adjointSensitivity::clearSensitivities
virtual void clearSensitivities()
Zero sensitivity fields and their constituents.
Definition: adjointSensitivityIncompressible.C:130
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::incompressible::adjointSensitivity::adjointVars_
incompressibleAdjointVars & adjointVars_
Definition: adjointSensitivityIncompressible.H:86
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:84
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::incompressible::adjointSensitivity::primalVars_
incompressibleVars & primalVars_
Definition: adjointSensitivityIncompressible.H:85
incompressibleAdjointVars.H
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::incompressible::adjointSensitivity::TypeName
TypeName("adjointSensitivity")
Runtime type information.
Foam::incompressible::adjointSensitivity::declareRunTimeSelectionTable
declareRunTimeSelectionTable(autoPtr, adjointSensitivity, dictionary,(const fvMesh &mesh, const dictionary &dict, incompressibleVars &primalVars, incompressibleAdjointVars &adjointVars, objectiveManager &objectiveManager, fv::optionAdjointList &fvOptionsAdjoint),(mesh, dict, primalVars, adjointVars, objectiveManager, fvOptionsAdjoint))
Foam::incompressible::adjointSensitivity::adjointMeshMovementSource
tmp< volVectorField > adjointMeshMovementSource()
Compute source term for adjoint mesh movement equation.
Definition: adjointSensitivityIncompressible.C:310
sensitivity.H
Foam::incompressible::adjointSensitivity::getSensitivities
const scalarField & getSensitivities() const
Returns the sensitivity fields.
Definition: adjointSensitivityIncompressible.C:124
Foam::word::null
static const word null
An empty word.
Definition: word.H:77
Foam::incompressible::adjointSensitivity::~adjointSensitivity
virtual ~adjointSensitivity()=default
Destructor.
Foam::sensitivity
Abstract base class for adjoint sensitivities.
Definition: sensitivity.H:63
fvOptionsAdjoint
fv::IOoptionListAdjoint fvOptionsAdjoint(mesh)
Foam::incompressible::adjointSensitivity::computeGradDxDbMultiplier
tmp< volTensorField > computeGradDxDbMultiplier()
Definition: adjointSensitivityIncompressible.C:146
Foam::incompressibleVars
Base class for solution control classes.
Definition: incompressibleVars.H:54
Foam::incompressible::adjointSensitivity::write
virtual void write(const word &baseName=word::null)
Write sensitivity fields.
Definition: adjointSensitivityIncompressible.C:140
Foam::incompressible::adjointSensitivity::objectiveManager_
objectiveManager & objectiveManager_
Definition: adjointSensitivityIncompressible.H:87
Foam::incompressible::adjointSensitivity::accumulateIntegrand
virtual void accumulateIntegrand(const scalar dt)=0
Accumulate sensitivity integrands.