incompressibleAdjointMeanFlowVars.C
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 
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 
37 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38 
39 defineTypeNameAndDebug(incompressibleAdjointMeanFlowVars, 0);
40 
41 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
42 
44 {
48  (
49  phiaPtr_,
50  mesh_,
51  UaInst(),
52  "phia",
55  );
56 
57  mesh_.setFluxRequired(paPtr_->name());
58 }
59 
61 {
62  // Allocate mean fields
63  // Only mean flow here since turbulent quantities
64  // are allocated automatically in RASModelVariables
65  if (solverControl_.average())
66  {
67  Info<< "Allocating Mean Adjoint Fields" << endl;
68  paMeanPtr_.reset
69  (
70  new volScalarField
71  (
72  IOobject
73  (
74  paInst().name() + "Mean",
75  mesh_.time().timeName(),
76  mesh_,
79  ),
80  paInst()
81  )
82  );
83  UaMeanPtr_.reset
84  (
85  new volVectorField
86  (
87  IOobject
88  (
89  UaInst().name() + "Mean",
90  mesh_.time().timeName(),
91  mesh_,
94  ),
95  UaInst()
96  )
97  );
98  phiaMeanPtr_.reset
99  (
101  (
102  IOobject
103  (
104  phiaInst().name() + "Mean",
105  mesh_.time().timeName(),
106  mesh_,
109  ),
110  phiaInst()
111  )
112  );
113  }
114 }
115 
116 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
117 
118 incompressibleAdjointMeanFlowVars::incompressibleAdjointMeanFlowVars
119 (
120  fvMesh& mesh,
121  solverControl& SolverControl,
122  incompressibleVars& primalVars
123 )
124 :
125  variablesSet(mesh, SolverControl.solverDict()),
126  solverControl_(SolverControl),
127  primalVars_(primalVars),
128  paPtr_(nullptr),
129  UaPtr_(nullptr),
130  phiaPtr_(nullptr),
131  paMeanPtr_(nullptr),
132  UaMeanPtr_(nullptr),
133  phiaMeanPtr_(nullptr)
134 {
135  setFields();
136  setMeanFields();
137 }
138 
139 
140 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
141 
143 {
144  return primalVars_;
145 }
146 
148 {
150  {
151  return paMeanPtr_();
152  }
153  else
154  {
155  return paPtr_();
156  }
157 }
158 
159 
161 {
163  {
164  return paMeanPtr_();
165  }
166  else
167  {
168  return paPtr_();
169  }
170 }
171 
172 
174 {
176  {
177  return UaMeanPtr_();
178  }
179  else
180  {
181  return UaPtr_();
182  }
183 }
184 
185 
187 {
189  {
190  return UaMeanPtr_();
191  }
192  else
193  {
194  return UaPtr_();
195  }
196 }
197 
198 
200 {
202  {
203  return phiaMeanPtr_();
204  }
205  else
206  {
207  return phiaPtr_();
208  }
209 }
210 
211 
213 {
215  {
216  return phiaMeanPtr_();
217  }
218  else
219  {
220  return phiaPtr_();
221  }
222 }
223 
224 
226 {
227  return paPtr_();
228 }
229 
230 
232 {
233  return paPtr_();
234 }
235 
236 
238 {
239  return UaPtr_();
240 }
241 
242 
244 {
245  return UaPtr_();
246 }
247 
248 
250 {
251  return phiaPtr_();
252 }
253 
254 
256 {
257  return phiaPtr_();
258 }
259 
260 
262 {
263  return solverControl_.average();
264 }
265 
266 
268 {
269  return solverControl_;
270 }
271 
272 
274 {
278 }
279 
280 
281 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
282 
283 } // End namespace Foam
284 
285 // ************************************************************************* //
Foam::incompressibleAdjointMeanFlowVars::setFields
void setFields()
Read fields and set turbulence.
Definition: incompressibleAdjointMeanFlowVars.C:43
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::IOobject::AUTO_WRITE
Definition: IOobject.H:194
Foam::incompressibleAdjointMeanFlowVars::setMeanFields
void setMeanFields()
Read mean fields, if necessary.
Definition: incompressibleAdjointMeanFlowVars.C:60
Foam::incompressibleAdjointMeanFlowVars::nullify
virtual void nullify()
Nullify all adjoint fields.
Definition: incompressibleAdjointMeanFlowVars.C:273
Foam::incompressibleAdjointMeanFlowVars::phiaMeanPtr_
autoPtr< surfaceScalarField > phiaMeanPtr_
Definition: incompressibleAdjointMeanFlowVars.H:90
Foam::Time::timeName
static word timeName(const scalar t, const int precision=precision_)
Definition: Time.C:780
Foam::incompressibleAdjointMeanFlowVars::phiaInst
const surfaceScalarField & phiaInst() const
Return const reference to volume flux.
Definition: incompressibleAdjointMeanFlowVars.C:249
Foam::schemesLookup::setFluxRequired
void setFluxRequired(const word &name) const
Get flux-required for given name, or default.
Definition: schemesLookup.C:241
Foam::variablesSet::setFluxField
static void setFluxField(autoPtr< surfaceScalarField > &fieldPtr, const fvMesh &mesh, const volVectorField &velocity, const word &baseName, const word &solverName, const bool useSolverNameForFields)
Set flux field.
Definition: variablesSet.C:97
Foam::solverControl
Base class for solver control classes.
Definition: solverControl.H:51
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::incompressibleAdjointMeanFlowVars::UaPtr_
autoPtr< volVectorField > UaPtr_
Definition: incompressibleAdjointMeanFlowVars.H:82
Foam::incompressibleAdjointMeanFlowVars::paPtr_
autoPtr< volScalarField > paPtr_
Definition: incompressibleAdjointMeanFlowVars.H:81
Foam::incompressibleAdjointMeanFlowVars::primalVars
const incompressibleVars & primalVars() const
Definition: incompressibleAdjointMeanFlowVars.C:142
Foam::variablesSet
Base class for creating a set of variables.
Definition: variablesSet.H:49
Foam::variablesSet::nullifyField
static void nullifyField(GeometricField< Type, PatchField, GeoMesh > &fieldPtr)
Nullify field and old times, if present.
Definition: variablesSetTemplates.C:347
Foam::incompressibleAdjointMeanFlowVars::primalVars_
incompressibleVars & primalVars_
Reference to primal variables.
Definition: incompressibleAdjointMeanFlowVars.H:77
incompressibleAdjointMeanFlowVars.H
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
Foam::incompressibleAdjointMeanFlowVars::paInst
const volScalarField & paInst() const
Return const reference to pressure.
Definition: incompressibleAdjointMeanFlowVars.C:225
Foam::IOobject::READ_IF_PRESENT
Definition: IOobject.H:187
Foam::solverControl::useAveragedFields
bool useAveragedFields() const
Definition: solverControlI.H:94
Foam::incompressibleAdjointMeanFlowVars::pa
const volScalarField & pa() const
Return const reference to pressure.
Definition: incompressibleAdjointMeanFlowVars.C:147
Foam::incompressibleAdjointMeanFlowVars::Ua
const volVectorField & Ua() const
Return const reference to velocity.
Definition: incompressibleAdjointMeanFlowVars.C:173
Foam::incompressibleAdjointMeanFlowVars::UaMeanPtr_
autoPtr< volVectorField > UaMeanPtr_
Definition: incompressibleAdjointMeanFlowVars.H:89
Foam::variablesSet::solverName_
word solverName_
Solver name owning the variables set.
Definition: variablesSet.H:95
Foam::variablesSet::setField
static void setField(autoPtr< GeometricField< Type, fvPatchField, volMesh >> &fieldPtr, const fvMesh &mesh, const word &baseName, const word &solverName, const bool useSolverNameForFields)
Read vol fields.
Definition: variablesSetTemplates.C:222
Foam::variablesSet::mesh_
fvMesh & mesh_
Reference to the mesh database.
Definition: variablesSet.H:92
Foam::incompressibleAdjointMeanFlowVars::paMeanPtr_
autoPtr< volScalarField > paMeanPtr_
Definition: incompressibleAdjointMeanFlowVars.H:88
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::incompressibleAdjointMeanFlowVars::getSolverControl
const solverControl & getSolverControl() const
Return const reference to solverControl.
Definition: incompressibleAdjointMeanFlowVars.C:267
Foam::incompressibleAdjointMeanFlowVars::computeMeanFields
bool computeMeanFields() const
Return computeMeanFields bool.
Definition: incompressibleAdjointMeanFlowVars.C:261
Foam::incompressibleAdjointMeanFlowVars::solverControl_
solverControl & solverControl_
Reference to the solverControl of the solver allocating the fields.
Definition: incompressibleAdjointMeanFlowVars.H:74
Foam::solverControl::solverDict
virtual const dictionary solverDict() const
Read controls from optimisationDict.
Definition: solverControlI.H:33
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::fvMesh::time
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:280
Foam::incompressibleAdjointMeanFlowVars::phiaPtr_
autoPtr< surfaceScalarField > phiaPtr_
Definition: incompressibleAdjointMeanFlowVars.H:83
Foam::GeometricField< scalar, fvPatchField, volMesh >
Foam::variablesSet::useSolverNameForFields_
bool useSolverNameForFields_
Append the solver name to the variables names?
Definition: variablesSet.H:98
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::incompressibleAdjointMeanFlowVars::phia
const surfaceScalarField & phia() const
Return const reference to volume flux.
Definition: incompressibleAdjointMeanFlowVars.C:199
Foam::solverControl::average
bool average() const
Whether averaging is enabled or not.
Definition: solverControlI.H:107
Foam::incompressibleAdjointMeanFlowVars::UaInst
const volVectorField & UaInst() const
Return const reference to velocity.
Definition: incompressibleAdjointMeanFlowVars.C:237
Foam::incompressibleVars
Base class for solution control classes.
Definition: incompressibleVars.H:54