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 -------------------------------------------------------------------------------
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::incompressibleAdjointSolver
31 
32 Description
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 
47 namespace Foam
48 {
49 
50 /*---------------------------------------------------------------------------*\
51  Class incompressibleAdjointSolver Declaration
52 \*---------------------------------------------------------------------------*/
53 
55 :
56  public adjointSolver
57 {
58 private:
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 
72 protected:
73 
74  // Protected data
75 
76  //- Primal variable set
78 
79  //- Adjoint Transpose Convection options
81 
82 
83 public:
84 
85 
86  // Static Data Members
87 
88  //- Run-time type information
89  TypeName("incompressible");
90 
91 
92  // Declare run-time constructor selection table
93 
95  (
96  autoPtr,
98  dictionary,
99  (
100  fvMesh& mesh,
101  const word& managerType,
102  const dictionary& dict,
103  const word& primalSolverName
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,
117  const word& primalSolverName
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,
129  const word& primalSolverName
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
183  virtual void additionalSensitivityMapTerms
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 // ************************************************************************* //
virtual bool write(const bool valid=true) const
In case of multi-point runs with turbulent flows, output dummy turbulence fields with the base names...
virtual void additionalSensitivityMapTerms(boundaryVectorField &sensitivityMap, const labelHashSet &patchIDs, const scalar dt)
Terms to be added to the sensitivity map, depending on the adjoint solver.
virtual ~incompressibleAdjointSolver()=default
Destructor.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:120
virtual const incompressibleAdjointVars & getAdjointVars() const
Access to the incompressible adjoint variables set.
const fvMesh & mesh() const
Return the solver mesh.
Definition: solver.C:89
virtual bool readDict(const dictionary &dict)
Read dict if updated.
const incompressibleVars & getPrimalVars() const
Access to the incompressible primal variables set.
autoPtr< ATCModel > ATCModel_
Adjoint Transpose Convection options.
virtual void updatePrimalBasedQuantities()
Update primal based quantities, e.g. the primal fields in adjoint turbulence models.
Base class for adjoint solvers.
Definition: adjointSolver.H:51
declareRunTimeSelectionTable(autoPtr, incompressibleAdjointSolver, dictionary,(fvMesh &mesh, const word &managerType, const dictionary &dict, const word &primalSolverName),(mesh, managerType, dict, primalSolverName))
bool writeTime() const noexcept
True if this is a write time.
Definition: TimeStateI.H:60
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:361
Class including all adjoint fields for incompressible flows.
Base class for incompressibleAdjoint solvers.
Base class for solution control classes.
incompressibleVars & primalVars_
Primal variable set.
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual const dictionary & dict() const
Return the solver dictionary.
Definition: solver.C:106
const autoPtr< ATCModel > & getATCModel() const
Access to the ATC model.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:79
virtual tmp< volTensorField > computeGradDxDbMultiplier()
Compute the multiplier for grad(dxdb)
virtual bool writeNow() const
In case of multi-point runs with turbulent flows, output dummy turbulence fields with the base names...
fvMesh & mesh_
Reference to the mesh database.
Definition: solver.H:56
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
bool write() const
Write dummy turbulent fields to allow for continuation in multi-point, turbulent runs.
A class for managing temporary objects.
Definition: HashPtrTable.H:50
static autoPtr< incompressibleAdjointSolver > New(fvMesh &mesh, const word &managerType, const dictionary &dict, const word &primalSolverName)
Return a reference to the selected incompressible adjoint solver.
const word & primalSolverName() const
Return the primal solver name.
Namespace for OpenFOAM.
TypeName("incompressible")
Run-time type information.
virtual bool useSolverNameForFields() const
Should solver name be appended to fields.