incompressibleAdjointSolver.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-------------------------------------------------------------------------------
12License
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
29Class
30 Foam::incompressibleAdjointSolver
31
32Description
33 Base class for incompressibleAdjoint solvers
34
35\*---------------------------------------------------------------------------*/
36
37#ifndef incompressibleAdjointSolver_H
38#define incompressibleAdjointSolver_H
39
40#include "adjointSolver.H"
41#include "incompressibleVars.H"
43#include "ATCModel.H"
44
45// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46
47namespace Foam
48{
49
50/*---------------------------------------------------------------------------*\
51 Class incompressibleAdjointSolver Declaration
52\*---------------------------------------------------------------------------*/
55:
56 public adjointSolver
57{
58private:
59
60 // Private Member Functions
61
62 //- No copy construct
64 (
66 ) = delete;
67
68 //- No copy assignment
69 void operator=(const incompressibleAdjointSolver&) = delete;
70
71
72protected:
73
74 // Protected data
75
76 //- Primal variable set
78
79 //- Adjoint Transpose Convection options
81
82
83public:
84
85
86 // Static Data Members
87
88 //- Run-time type information
89 TypeName("incompressible");
90
91
92 // Declare run-time constructor selection table
95 (
96 autoPtr,
99 (
100 fvMesh& mesh,
101 const word& managerType,
102 const dictionary& dict,
104 ),
105 (mesh, managerType, dict, primalSolverName)
106 );
107
108
109 // Constructors
110
111 //- Construct from mesh and dictionary
113 (
114 fvMesh& mesh,
115 const word& managerType,
116 const dictionary& dict,
118 );
119
120
121 // Selectors
122
123 //- Return a reference to the selected incompressible adjoint solver
125 (
126 fvMesh& mesh,
127 const word& managerType,
128 const dictionary& dict,
130 );
131
132
133 //- Destructor
134 virtual ~incompressibleAdjointSolver() = default;
135
136
137 // Member Functions
138
139 //- Read dict if updated
140 virtual bool readDict(const dictionary& dict);
141
142 //- Should solver name be appended to fields
143 virtual bool useSolverNameForFields() const;
144
145
146 // Access
147
148 //- Access to the incompressible primal variables set
149 const incompressibleVars& getPrimalVars() const;
150
151 //- Access to the incompressible adjoint variables set
152 virtual const incompressibleAdjointVars& getAdjointVars() const;
153
154 //- Access to the incompressible adjoint variables set
156
157 //- Access to the ATC model
158 const autoPtr<ATCModel>& getATCModel() const;
159
160 //- Access to the ATC model
162
163
164 // Evolution
165
166 //- Update primal based quantities, e.g. the primal fields
167 //- in adjoint turbulence models
168 virtual void updatePrimalBasedQuantities();
169
170
171 // Sensitivity related functions
172
173 //- Compute the multiplier for grad(dxdb)
174 // Used in shape sensitivity derivatives, computed with the FI
175 // and E-SI approaches
177
178 //- Terms to be added to the sensitivity map, depending
179 //- on the adjoint solver
180 // The typical terms associated with the typical incompressible
181 // flow equations are included in the sensitivity classes.
182 // This is to be used whenever additional physics is added
184 (
185 boundaryVectorField& sensitivityMap,
186 const labelHashSet& patchIDs,
187 const scalar dt
188 );
189
190
191 // IO
192
193 //- In case of multi-point runs with turbulent flows,
194 //- output dummy turbulence fields with the base names, to allow
195 //- continuation
196 virtual bool write(const bool valid = true) const
197 {
198 if (mesh_.time().writeTime())
199 {
200 return primalVars_.write();
201 }
202
203 return false;
204 }
205
206 //- In case of multi-point runs with turbulent flows,
207 //- output dummy turbulence fields with the base names, to allow
208 //- continuation
209 virtual bool writeNow() const
210 {
211 return primalVars_.write();
212 }
213};
214
215
216// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217
218} // End namespace Foam
219
220// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
221
222#endif
223
224// ************************************************************************* //
Generic GeometricBoundaryField class.
bool writeTime() const noexcept
True if this is a write time.
Definition: TimeStateI.H:67
Base class for adjoint solvers.
Definition: adjointSolver.H:60
const word & primalSolverName() const
Return the primal solver name.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:290
Base class for incompressibleAdjoint solvers.
autoPtr< ATCModel > ATCModel_
Adjoint Transpose Convection options.
TypeName("incompressible")
Run-time type information.
const incompressibleVars & getPrimalVars() const
Access to the incompressible primal variables set.
const autoPtr< ATCModel > & getATCModel() const
Access to the ATC model.
virtual ~incompressibleAdjointSolver()=default
Destructor.
virtual void additionalSensitivityMapTerms(boundaryVectorField &sensitivityMap, const labelHashSet &patchIDs, const scalar dt)
virtual bool write(const bool valid=true) const
virtual bool readDict(const dictionary &dict)
Read dict if updated.
virtual const incompressibleAdjointVars & getAdjointVars() const
Access to the incompressible adjoint variables set.
virtual bool useSolverNameForFields() const
Should solver name be appended to fields.
declareRunTimeSelectionTable(autoPtr, incompressibleAdjointSolver, dictionary,(fvMesh &mesh, const word &managerType, const dictionary &dict, const word &primalSolverName),(mesh, managerType, dict, primalSolverName))
virtual tmp< volTensorField > computeGradDxDbMultiplier()
Compute the multiplier for grad(dxdb)
incompressibleVars & primalVars_
Primal variable set.
static autoPtr< incompressibleAdjointSolver > New(fvMesh &mesh, const word &managerType, const dictionary &dict, const word &primalSolverName)
Return a reference to the selected incompressible adjoint solver.
Class including all adjoint fields for incompressible flows.
Base class for solution control classes.
virtual const dictionary & dict() const
Return the solver dictionary.
Definition: solver.C:113
const fvMesh & mesh() const
Return the solver mesh.
Definition: solver.C:96
fvMesh & mesh_
Reference to the mesh database.
Definition: solver.H:60
A class for managing temporary objects.
Definition: tmp.H:65
A class for handling words, derived from Foam::string.
Definition: word.H:68
Namespace for OpenFOAM.
runTime write()
#define declareRunTimeSelectionTable(ptrWrapper, baseType, argNames, argList, parList)
Declare a run-time selection (variables and adder classes)
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73