adjointSolverManager.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::adjointSolverManager
31 
32 Description
33  Class for managing adjoint solvers, which may be more than one per
34  operating point
35 
36 SourceFiles
37  adjointSolverManager.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef adjointSolverManager_H
42 #define adjointSolverManager_H
43 
44 #include "adjointSolver.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 /*---------------------------------------------------------------------------*\
52  Class adjointSolverManager Declaration
53 \*---------------------------------------------------------------------------*/
54 
56 :
57  public regIOobject
58 {
59 private:
60 
61  // Private Member Functions
62 
63  //- No copy construct
65 
66  //- No copy assignment
67  void operator=(const adjointSolverManager&) = delete;
68 
69 
70 protected:
71 
72  // Protected Data
73 
74  fvMesh& mesh_;
75 
77 
78  const word managerName_;
79 
80  const word primalSolverName_;
81 
83 
85 
87 
88  scalar operatingPointWeight_;
89 
90 
91 public:
92 
93  TypeName("adjointSolverManager");
94 
95 
96  // Constructors
97 
98  //- Construct from components
100  (
101  fvMesh& mesh,
102  const word& managerType,
103  const dictionary& dict
104  );
105 
106 
107  //- Destructor
108  virtual ~adjointSolverManager() = default;
109 
110 
111  // Member Functions
112 
113  virtual bool readDict(const dictionary& dict);
114 
115 
116  // Access
117 
118  //- Const access to the manager name
119  const word& managerName() const;
120 
121  //- Const access to the primal solver name
122  const word& primalSolverName() const;
123 
124  //- Const access to the construction dictionary
125  const dictionary& dict() const;
126 
127  //- Const access to adjoint solvers
128  const PtrList<adjointSolver>& adjointSolvers() const;
129 
130  //- Non-const access to adjoint solvers
132 
133  //- Const access to adjoint solvers
134  scalar operatingPointWeight() const;
135 
136  //- Number of adjoint solvers corresponding to constraints
137  label nConstraints() const;
138 
139  //- Number of adjoint solvers corresponding to objectives
140  label nObjectives() const;
141 
142  //- Total number of adjoint solvers
143  label nAdjointSolvers() const;
144 
145 
146  // Evolution
147 
148  //- Update objective function-related values and solve adjoint
149  //- equations
150  virtual void solveAdjointEquations();
151 
152  //- Aggregate sensitivities from various adjoint solvers
154 
155  //- Get constraint sensitivities. One scalarField per constraint
157 
158  //- Compute sensitivities for all adjoint solvers
159  //- (both objective- and constraint-related ones)
161 
162  //- Clear sensitivity fields from all adjoint solvers
163  void clearSensitivities();
164 
165  //- Get objective value
166  scalar objectiveValue();
167 
168  //- Get constraint values
170 
171  //- Update fields related to primal solution.
172  // For instance, primal fields of adjoint turbulence models
174 
175 
176  // IO
177 
178  virtual bool writeData(Ostream&) const
179  {
180  return true;
181  }
182 };
183 
184 
185 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
186 
187 } // End namespace Foam
188 
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 
191 #endif
192 
193 // ************************************************************************* //
Foam::adjointSolverManager::adjointSolvers_
PtrList< adjointSolver > adjointSolvers_
Definition: adjointSolverManager.H:81
Foam::adjointSolverManager::nConstraints
label nConstraints() const
Number of adjoint solvers corresponding to constraints.
Definition: adjointSolverManager.C:178
Foam::adjointSolverManager::nObjectives
label nObjectives() const
Number of adjoint solvers corresponding to objectives.
Definition: adjointSolverManager.C:184
Foam::adjointSolverManager::operatingPointWeight
scalar operatingPointWeight() const
Const access to adjoint solvers.
Definition: adjointSolverManager.C:172
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::adjointSolverManager::constraintSensitivities
virtual PtrList< scalarField > constraintSensitivities()
Get constraint sensitivities. One scalarField per constraint.
Definition: adjointSolverManager.C:232
Foam::adjointSolverManager::clearSensitivities
void clearSensitivities()
Clear sensitivity fields from all adjoint solvers.
Definition: adjointSolverManager.C:258
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::adjointSolverManager::primalSolverName_
const word primalSolverName_
Definition: adjointSolverManager.H:79
Foam::adjointSolverManager::nAdjointSolvers
label nAdjointSolvers() const
Total number of adjoint solvers.
Definition: adjointSolverManager.C:190
Foam::adjointSolverManager::aggregateSensitivities
virtual tmp< scalarField > aggregateSensitivities()
Aggregate sensitivities from various adjoint solvers.
Definition: adjointSolverManager.C:208
Foam::adjointSolverManager::readDict
virtual bool readDict(const dictionary &dict)
Definition: adjointSolverManager.C:124
Foam::adjointSolverManager::constraintValues
virtual tmp< scalarField > constraintValues()
Get constraint values.
Definition: adjointSolverManager.C:281
adjointSolver.H
Foam::adjointSolverManager::TypeName
TypeName("adjointSolverManager")
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:59
Foam::adjointSolverManager::~adjointSolverManager
virtual ~adjointSolverManager()=default
Destructor.
Foam::adjointSolverManager::computeAllSensitivities
void computeAllSensitivities()
Definition: adjointSolverManager.C:249
Foam::adjointSolverManager
Class for managing adjoint solvers, which may be more than one per operating point.
Definition: adjointSolverManager.H:54
Foam::adjointSolverManager::dict
const dictionary & dict() const
Const access to the construction dictionary.
Definition: adjointSolverManager.C:152
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::adjointSolverManager::dict_
dictionary dict_
Definition: adjointSolverManager.H:75
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam::adjointSolverManager::adjointSolvers
const PtrList< adjointSolver > & adjointSolvers() const
Const access to adjoint solvers.
Definition: adjointSolverManager.C:159
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::adjointSolverManager::managerName
const word & managerName() const
Const access to the manager name.
Definition: adjointSolverManager.C:140
Foam::adjointSolverManager::objectiveValue
scalar objectiveValue()
Get objective value.
Definition: adjointSolverManager.C:267
Foam::adjointSolverManager::solveAdjointEquations
virtual void solveAdjointEquations()
Definition: adjointSolverManager.C:196
Foam::adjointSolverManager::managerName_
const word managerName_
Definition: adjointSolverManager.H:77
Foam::IOobject::name
const word & name() const noexcept
Return name.
Definition: IOobjectI.H:65
Foam::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:73
Foam::adjointSolverManager::constraintSolverIDs_
labelList constraintSolverIDs_
Definition: adjointSolverManager.H:85
Foam::adjointSolverManager::primalSolverName
const word & primalSolverName() const
Const access to the primal solver name.
Definition: adjointSolverManager.C:146
Foam::List< label >
Foam::adjointSolverManager::updatePrimalBasedQuantities
void updatePrimalBasedQuantities(const word &name)
Update fields related to primal solution.
Definition: adjointSolverManager.C:299
Foam::adjointSolverManager::mesh_
fvMesh & mesh_
Definition: adjointSolverManager.H:73
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::adjointSolverManager::writeData
virtual bool writeData(Ostream &) const
Pure virtual writeData function.
Definition: adjointSolverManager.H:177
Foam::adjointSolverManager::objectiveSolverIDs_
labelList objectiveSolverIDs_
Definition: adjointSolverManager.H:83
Foam::adjointSolverManager::operatingPointWeight_
scalar operatingPointWeight_
Definition: adjointSolverManager.H:87