Loading...
Searching...
No Matches
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-2021 PCOpt/NTUA
9 Copyright (C) 2013-2021 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\*---------------------------------------------------------------------------*/
29
31
32// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33
34namespace Foam
35{
37// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38
39defineTypeNameAndDebug(incompressibleAdjointMeanFlowVars, 0);
40
41// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
42
44{
48 (
50 mesh_,
51 UaInst(),
52 "phia",
55 );
56
57 mesh_.setFluxRequired(paPtr_->name());
58}
59
60
62{
63 // Allocate mean fields
64 // Only mean flow here since turbulent quantities
65 // are allocated automatically in RASModelVariables
67 {
68 Info<< "Allocating Mean Adjoint Fields" << endl;
69 paMeanPtr_.reset
70 (
72 (
74 (
75 paInst().name() + "Mean",
77 mesh_,
81 ),
82 paInst()
83 )
84 );
85 UaMeanPtr_.reset
86 (
88 (
90 (
91 UaInst().name() + "Mean",
93 mesh_,
97 ),
98 UaInst()
99 )
100 );
101 phiaMeanPtr_.reset
102 (
104 (
106 (
107 phiaInst().name() + "Mean",
108 mesh_.time().timeName(),
109 mesh_,
113 ),
114 phiaInst()
116 );
117 }
118}
119
120// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
121
122incompressibleAdjointMeanFlowVars::incompressibleAdjointMeanFlowVars
123(
124 fvMesh& mesh,
125 solverControl& SolverControl,
126 incompressibleVars& primalVars
127)
128:
129 variablesSet(mesh, SolverControl.solverDict()),
130 solverControl_(SolverControl),
131 primalVars_(primalVars),
132 paPtr_(nullptr),
133 UaPtr_(nullptr),
134 phiaPtr_(nullptr),
135 paMeanPtr_(nullptr),
136 UaMeanPtr_(nullptr),
137 phiaMeanPtr_(nullptr)
138{
141}
142
143
144// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
145
147{
148 return primalVars_;
149}
150
152{
154 {
155 return paMeanPtr_();
156 }
157 else
158 {
159 return paPtr_();
160 }
161}
162
163
165{
167 {
168 return paMeanPtr_();
169 }
170 else
171 {
172 return paPtr_();
173 }
174}
175
176
178{
180 {
181 return UaMeanPtr_();
182 }
183 else
184 {
185 return UaPtr_();
186 }
187}
188
189
191{
193 {
194 return UaMeanPtr_();
195 }
196 else
197 {
198 return UaPtr_();
199 }
200}
201
202
204{
206 {
207 return phiaMeanPtr_();
208 }
209 else
210 {
211 return phiaPtr_();
212 }
213}
214
215
217{
219 {
220 return phiaMeanPtr_();
221 }
222 else
223 {
224 return phiaPtr_();
225 }
226}
227
232}
233
240
242{
246}
247
248
249// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
250
251} // End namespace Foam
252
253// ************************************************************************* //
@ REGISTER
Request registration (bool: true).
@ READ_IF_PRESENT
Reading is optional [identical to LAZY_READ].
@ AUTO_WRITE
Automatically write from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
static word timeName(const scalar t, const int precision=precision_)
Return a time name for the given scalar time value formatted with the given precision.
Definition Time.C:714
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
const Time & time() const
Return the top-level database.
Definition fvMesh.H:360
Manages the adjoint mean flow fields and their mean values.
solverControl & solverControl_
Reference to the solverControl of the solver allocating the fields.
const volScalarField & pa() const
Return const reference to pressure.
const volVectorField & Ua() const
Return const reference to velocity.
const volVectorField & UaInst() const
Return const reference to velocity.
const surfaceScalarField & phia() const
Return const reference to volume flux.
const solverControl & getSolverControl() const
Return const reference to solverControl.
virtual void nullify()
Nullify all adjoint fields.
autoPtr< volScalarField > paMeanPtr_
Mean Adjoint Fields. Actual averaging is done in the incompressibleAdjointVars class to take care of ...
autoPtr< volScalarField > paPtr_
Fields involved in the solution of the incompressible adjoint NS equations.
const surfaceScalarField & phiaInst() const
Return const reference to volume flux.
bool computeMeanFields() const
Return computeMeanFields bool.
const volScalarField & paInst() const
Return const reference to pressure.
void setMeanFields()
Read mean fields, if necessary.
incompressibleVars & primalVars_
Reference to primal variables.
Base class for solution control classes.
Base class for solver control classes.
bool useAveragedFields() const
Use averaged fields? For solving the adjoint equations or computing sensitivities based on averaged f...
bool average() const
Whether averaging is enabled or not.
bool useSolverNameForFields_
Append the solver name to the variables names?
static void setField(autoPtr< GeometricField< Type, fvPatchField, volMesh > > &fieldPtr, const fvMesh &mesh, const word &baseName, const word &solverName, const bool useSolverNameForFields)
Read vol fields.
word solverName_
Solver name owning the variables set.
fvMesh & mesh_
Reference to the mesh database.
static void setFluxField(autoPtr< surfaceScalarField > &fieldPtr, const fvMesh &mesh, const volVectorField &velocity, const word &baseName, const word &solverName, const bool useSolverNameForFields)
Set flux field.
static void nullifyField(GeometricField< Type, PatchField, GeoMesh > &fieldPtr)
Nullify field and old times, if present.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
dynamicFvMesh & mesh
auto & name
Namespace for OpenFOAM.
GeometricField< vector, fvPatchField, volMesh > volVectorField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
messageStream Info
Information stream (stdout output on master, null elsewhere).
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519