sensitivityTopO.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 -------------------------------------------------------------------------------
11 License
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 
27 
28 Description
29  Calculation of adjoint based sensitivities for topology optimisation.
30  This returns just the field part, with contributions from regularisation
31  and projection added by topODesignVariables.
32 
33 Class
34  Foam::sensitivityTopO
35 
36 SourceFiles
37  sensitivityTopO.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef sensitivityTopO_H
42 #define sensitivityTopO_H
43 
44 #include "adjointSensitivity.H"
45 #include "fvOptions.H"
46 #include "topOZones.H"
47 #include "adjointEikonalSolver.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 /*---------------------------------------------------------------------------*\
55  Class sensitivityTopO Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 class sensitivityTopO
59 :
60  public adjointSensitivity
61 {
62 
63 protected:
64 
65  // Protected data
66 
67  //- Zones related to topology optimisation
69 
70  //- Name used as the argument for the post-processing of the
71  //- sensitivities through fvOptions
73 
74 
75  // Protected Member Functions
76 
77  //- Zero sensitivities in fixed porous zones
79 
80 
81 private:
82 
83  // Private Member Functions
84 
85  //- No copy construct
87 
88  //- No copy assignment
89  void operator=(const sensitivityTopO&);
90 
91 
92 public:
93 
94  //- Runtime type information
95  TypeName("topO");
96 
97 
98  // Constructors
99 
100  //- Construct from components
102  (
103  const fvMesh& mesh,
104  const dictionary& dict,
106  );
107 
108 
109  //- Destructor
110  virtual ~sensitivityTopO() = default;
111 
112 
113  // Member Functions
114 
115  //- Read dictionary if changed
116  virtual bool readDict(const dictionary& dict);
117 
118  //- Accumulate sensitivity integrands
119  virtual void accumulateIntegrand(const scalar dt);
120 
121  //- Assemble sensitivities
122  virtual void assembleSensitivities
123  (
124  autoPtr<designVariables>& designVars
125  );
126 
127  //- Add part of the sensitivities coming from fvOptions
128  static void postProcessSens
129  (
130  scalarField& sens,
131  scalarField& auxSens,
133  const word& fieldName,
134  const word& designVariablesName
135  );
136 
137  //- Add part of the sensitivities coming from fvOptions
138  void postProcessSens
139  (
140  scalarField& sens,
141  scalarField& auxSens,
142  const word& fieldName
143  );
144 
145  //- Potentially manipulate auxSens within the fvOption before adding
146  //- the part related to the design variables
147  template<class Type, template<class> class PatchField, class GeoMesh>
148  static void postProcessAuxSens
149  (
153  const word& fieldName,
154  scalarField& auxSens
155  );
156 };
157 
158 
159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
160 
161 } // End namespace Foam
162 
163 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
164 
165 #ifdef NoRepository
166  #include "sensitivityTopOTemplates.C"
167 #endif
168 
169 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170 
171 #endif
172 
173 // ************************************************************************* //
TypeName("topO")
Runtime type information.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
Abstract base class for adjoint-based sensitivities.
Base class for adjoint solvers.
Definition: adjointSolver.H:53
Generic GeometricField class.
Definition: areaFieldsFwd.H:50
Finite-volume options.
Definition: fvOptions.H:51
const fvMesh & mesh() const
Return reference to mesh.
Definition: sensitivity.H:121
word designVariablesName_
Name used as the argument for the post-processing of the sensitivities through fvOptions.
virtual bool readDict(const dictionary &dict)
Read dictionary if changed.
static void postProcessAuxSens(const GeometricField< Type, PatchField, GeoMesh > &primal, const GeometricField< Type, PatchField, GeoMesh > &adjoint, fv::options &fvOptions, const word &fieldName, scalarField &auxSens)
Potentially manipulate auxSens within the fvOption before adding the part related to the design varia...
fv::options & fvOptions
virtual void accumulateIntegrand(const scalar dt)
Accumulate sensitivity integrands.
topOZones zones_
Zones related to topology optimisation.
A class for handling words, derived from Foam::string.
Definition: word.H:63
static void postProcessSens(scalarField &sens, scalarField &auxSens, fv::options &fvOptions, const word &fieldName, const word &designVariablesName)
Add part of the sensitivities coming from fvOptions.
const dictionary & dict() const
Return the construction dictionary.
Definition: sensitivity.H:129
virtual ~sensitivityTopO()=default
Destructor.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
void zeroSensInFixedPorousZones(scalarField &sens)
Zero sensitivities in fixed porous zones.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
Generic mesh wrapper used by volMesh, surfaceMesh, pointMesh etc.
Definition: GeoMesh.H:42
virtual void assembleSensitivities(autoPtr< designVariables > &designVars)
Assemble sensitivities.
Namespace for OpenFOAM.