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  // IO
172 
173  //- In case of multi-point runs with turbulent flows,
174  //- output dummy turbulence fields with the base names, to allow
175  //- continuation
176  virtual bool write(const bool valid = true) const
177  {
178  if (mesh_.time().writeTime())
179  {
180  return primalVars_.write();
181  }
182 
183  return false;
184  }
185 
186  //- In case of multi-point runs with turbulent flows,
187  //- output dummy turbulence fields with the base names, to allow
188  //- continuation
189  virtual bool writeNow() const
190  {
191  return primalVars_.write();
192  }
193 };
194 
195 
196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
197 
198 } // End namespace Foam
199 
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201 
202 #endif
203 
204 // ************************************************************************* //
Foam::adjointSolver
Base class for adjoint solvers.
Definition: adjointSolver.H:57
Foam::incompressibleAdjointSolver::ATCModel_
autoPtr< ATCModel > ATCModel_
Adjoint Transpose Convection options.
Definition: incompressibleAdjointSolver.H:79
Foam::incompressibleAdjointSolver::New
static autoPtr< incompressibleAdjointSolver > New(fvMesh &mesh, const word &managerType, const dictionary &dict, const word &primalSolverName)
Return a reference to the selected incompressible adjoint solver.
Definition: incompressibleAdjointSolver.C:73
Foam::incompressibleAdjointSolver
Base class for incompressibleAdjoint solvers.
Definition: incompressibleAdjointSolver.H:53
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
ATCModel.H
Foam::adjointSolver::primalSolverName
const word & primalSolverName() const
Return the primal solver name.
Definition: adjointSolver.H:152
Foam::incompressibleAdjointSolver::useSolverNameForFields
virtual bool useSolverNameForFields() const
Should solver name be appended to fields.
Definition: incompressibleAdjointSolver.C:114
incompressibleVars.H
Foam::incompressibleAdjointSolver::getAdjointVars
virtual const incompressibleAdjointVars & getAdjointVars() const
Access to the incompressible adjoint variables set.
Definition: incompressibleAdjointSolver.C:129
Foam::solver::mesh_
fvMesh & mesh_
Reference to the mesh database.
Definition: solver.H:60
Foam::incompressibleAdjointSolver::TypeName
TypeName("incompressible")
Run-time type information.
Foam::incompressibleAdjointVars
Class including all adjoint fields for incompressible flows.
Definition: incompressibleAdjointVars.H:52
Foam::incompressibleAdjointSolver::write
virtual bool write(const bool valid=true) const
Definition: incompressibleAdjointSolver.H:175
adjointSolver.H
Foam::TimeState::writeTime
bool writeTime() const noexcept
True if this is a write time.
Definition: TimeStateI.H:67
Foam::incompressibleVars::write
bool write() const
Definition: incompressibleVars.C:539
Foam::incompressibleAdjointSolver::declareRunTimeSelectionTable
declareRunTimeSelectionTable(autoPtr, incompressibleAdjointSolver, dictionary,(fvMesh &mesh, const word &managerType, const dictionary &dict, const word &primalSolverName),(mesh, managerType, dict, primalSolverName))
Foam::incompressibleAdjointSolver::writeNow
virtual bool writeNow() const
Definition: incompressibleAdjointSolver.H:188
Foam::incompressibleAdjointSolver::updatePrimalBasedQuantities
virtual void updatePrimalBasedQuantities()
Definition: incompressibleAdjointSolver.C:160
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::incompressibleAdjointSolver::getATCModel
const autoPtr< ATCModel > & getATCModel() const
Access to the ATC model.
Definition: incompressibleAdjointSolver.C:148
incompressibleAdjointVars.H
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::solver::mesh
const fvMesh & mesh() const
Return the solver mesh.
Definition: solver.C:96
Foam::incompressibleAdjointSolver::primalVars_
incompressibleVars & primalVars_
Primal variable set.
Definition: incompressibleAdjointSolver.H:76
Foam::fvMesh::time
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:280
Foam::incompressibleAdjointSolver::readDict
virtual bool readDict(const dictionary &dict)
Read dict if updated.
Definition: incompressibleAdjointSolver.C:104
Foam::incompressibleAdjointSolver::getPrimalVars
const incompressibleVars & getPrimalVars() const
Access to the incompressible primal variables set.
Definition: incompressibleAdjointSolver.C:121
Foam::solver::dict
virtual const dictionary & dict() const
Return the solver dictionary.
Definition: solver.C:113
Foam::incompressibleAdjointSolver::~incompressibleAdjointSolver
virtual ~incompressibleAdjointSolver()=default
Destructor.
Foam::incompressibleVars
Base class for solution control classes.
Definition: incompressibleVars.H:54