incompressibleVars.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-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 Class
29  Foam::incompressibleVars
30 
31 Description
32  Base class for solution control classes
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef incompressibleVars_H
37 #define incompressibleVars_H
38 
39 #include "variablesSet.H"
40 #include "fvMesh.H"
43 #include "RASModelVariables.H"
44 #include "solverControl.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 /*---------------------------------------------------------------------------*\
52  Class incompressibleVars Declaration
53 \*---------------------------------------------------------------------------*/
54 
56 :
57  public variablesSet
58 {
59 protected:
60 
61  // Protected data
62 
63  //- Reference to the solverControl of the solver allocating the fields
65 
66  //- Fields involved in the solution of the incompressible NS equations
73  //autoPtr<volScalarField> TPtr_;
74 
75  //- Keep a copy of the initial field values if necessary
79 
80  //- Manage mean fields. Turbulent mean fields are managed
81  //- in RASModelVariables
85 
86  //- Update boundary conditions upon construction.
87  // Useful for cases in which information has been lost on boundary
88  // (e.g. averaging, redistribution)
90 
91 
92  // Protected Member Functions
93 
94  //- Read fields and set turbulence
95  void setFields();
96 
97  //- Set initial fields if necessary
98  void setInitFields();
99 
100  //- Set mean fields if necessary
101  void setMeanFields();
102 
103  //- Rename turbulence fields if necessary
104  void renameTurbulenceFields();
105 
106  //- Update boundary conditions of mean-flow
108 
109  //- Update boundary conditions of turbulent fields
111 
112  //- No copy assignment
113  void operator=(const incompressibleVars&);
114 
115 
116 public:
117 
118  // Static Data Members
119 
120  //- Run-time type information
121  TypeName("incompressibleVars");
122 
123 
124  // Constructors
125 
126  //- Construct from mesh
128  (
129  fvMesh& mesh,
130  solverControl& SolverControl
131  );
132 
133  //- Copy constructor
134  // turbulence_ and laminarTransport_ are uninitialized since there is
135  // no clear way (and possibly no usage) of cloning them.
136  // The resulting incompressibleVars is hence incomplete.
137  // Additionally, copied fields have the original name, appended with
138  // the timeName, to avoid database collisions.
139  // To be used as storing space during the solutiuon of the unsteady
140  // adjoint equations
142 
143  //- Clone the incompressibleVars
144  virtual autoPtr<variablesSet> clone() const;
145 
146 
147 
148  //- Destructor
149  virtual ~incompressibleVars() = default;
150 
151 
152  // Member Functions
153 
154  // Access
155 
156  // Access to fields that will be later used for the solution of
157  // the adjoint equations. Might be averaged or not, depending on
158  // the corresponding switch
159  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
160 
161  //- Return const reference to pressure
162  const volScalarField& p() const;
163 
164  //- Return reference to pressure
165  volScalarField& p();
166 
167  //- Return const reference to velocity
168  const volVectorField& U() const;
169 
170  //- Return reference to velocity
171  volVectorField& U();
172 
173  //- Return const reference to volume flux
174  const surfaceScalarField& phi() const;
175 
176  //- Return reference to volume flux
178 
179 
180  // Access to instantaneous fields. Solvers should use these fields
181  // to execute a solver iteration
182  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
183 
184  //- Return const reference to pressure
185  const volScalarField& pInst() const;
186 
187  //- Return reference to pressure
189 
190  //- Return const reference to velocity
191  const volVectorField& UInst() const;
192 
193  //- Return reference to velocity
195 
196  //- Return const reference to volume flux
197  const surfaceScalarField& phiInst() const;
198 
199  //- Return reference to volume flux
201 
202 
203  //- Return const reference to transport model
205 
206  //- Return reference to transport model
208 
209  //- Return const reference to the turbulence model
211 
212  //- Return reference to the turbulence model
214 
215  //- Return const reference to the turbulence model variables
217  RASModelVariables() const;
218 
219  //- Return reference to the turbulence model variables
221 
222  //- Restore field values to the initial ones
223  void restoreInitValues();
224 
225  //- Reset mean fields to zero
226  void resetMeanFields();
227 
228  //- Compute mean fields on the fly
229  void computeMeanFields();
230 
231  //- correct boundaryconditions for all volFields
233 
234  //- Return storeInitValues bool
235  bool storeInitValues() const;
236 
237  //- Return computeMeanFields bool
238  bool computeMeanFields() const;
239 
240  /*
241  //- Return const reference to the temperature
242  const volScalarField& T() const;
243 
244  //- Return reference to the temperature
245  volScalarField& T();
246  */
247 
248  //- Transfer the fields of another variablesSet to this
249  virtual void transfer(variablesSet& vars);
250 
251  //- Write dummy turbulent fields to allow for continuation in
252  //- multi-point, turbulent runs
253  bool write() const;
254 };
255 
256 
257 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
258 
259 } // End namespace Foam
260 
261 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
262 
263 #endif
264 
265 // ************************************************************************* //
Foam::incompressibleVars::phiPtr_
autoPtr< surfaceScalarField > phiPtr_
Definition: incompressibleVars.H:68
Foam::incompressibleVars::phiInst
const surfaceScalarField & phiInst() const
Return const reference to volume flux.
Definition: incompressibleVars.C:406
Foam::incompressibleVars::storeInitValues
bool storeInitValues() const
Return storeInitValues bool.
Definition: incompressibleVars.C:513
Foam::incompressibleVars::renameTurbulenceFields
void renameTurbulenceFields()
Rename turbulence fields if necessary.
Definition: incompressibleVars.C:180
Foam::incompressibleVars::UPtr_
autoPtr< volVectorField > UPtr_
Definition: incompressibleVars.H:67
Foam::incompressibleVars::operator=
void operator=(const incompressibleVars &)
No copy assignment.
singlePhaseTransportModel.H
Foam::incompressibleVars::transfer
virtual void transfer(variablesSet &vars)
Transfer the fields of another variablesSet to this.
Definition: incompressibleVars.C:525
Foam::incompressibleVars::phiMeanPtr_
autoPtr< surfaceScalarField > phiMeanPtr_
Definition: incompressibleVars.H:83
Foam::incompressibleVars::setInitFields
void setInitFields()
Set initial fields if necessary.
Definition: incompressibleVars.C:99
turbulentTransportModel.H
Foam::incompressibleVars::laminarTransportPtr_
autoPtr< singlePhaseTransportModel > laminarTransportPtr_
Definition: incompressibleVars.H:69
Foam::incompressibleVars::computeMeanFields
void computeMeanFields()
Compute mean fields on the fly.
Definition: incompressibleVars.C:488
Foam::incompressibleVars::phi
const surfaceScalarField & phi() const
Return const reference to volume flux.
Definition: incompressibleVars.C:357
Foam::solverControl
Base class for solver control classes.
Definition: solverControl.H:51
Foam::singlePhaseTransportModel
A simple single-phase transport model based on viscosityModel.
Definition: singlePhaseTransportModel.H:57
Foam::incompressibleVars::UInst
const volVectorField & UInst() const
Return const reference to velocity.
Definition: incompressibleVars.C:394
Foam::incompressibleVars::p
const volScalarField & p() const
Return const reference to pressure.
Definition: incompressibleVars.C:305
Foam::incompressibleVars::setFields
void setFields()
Read fields and set turbulence.
Definition: incompressibleVars.C:44
Foam::incompressibleVars::clone
virtual autoPtr< variablesSet > clone() const
Clone the incompressibleVars.
Definition: incompressibleVars.C:294
Foam::incompressibleVars::RASModelVariables
const autoPtr< incompressible::RASModelVariables > & RASModelVariables() const
Return const reference to the turbulence model variables.
Definition: incompressibleVars.C:444
Foam::incompressibleVars::setMeanFields
void setMeanFields()
Set mean fields if necessary.
Definition: incompressibleVars.C:116
Foam::incompressibleVars::solverControl_
solverControl & solverControl_
Reference to the solverControl of the solver allocating the fields.
Definition: incompressibleVars.H:63
Foam::variablesSet
Base class for creating a set of variables.
Definition: variablesSet.H:49
RASModelVariables.H
Foam::incompressibleVars::correctTurbulentBoundaryConditions
void correctTurbulentBoundaryConditions()
Update boundary conditions of turbulent fields.
Definition: incompressibleVars.C:218
Foam::incompressibleVars::phiInitPtr_
autoPtr< surfaceScalarField > phiInitPtr_
Definition: incompressibleVars.H:77
Foam::incompressibleVars::UInitPtr_
autoPtr< volVectorField > UInitPtr_
Definition: incompressibleVars.H:76
Foam::incompressibleVars::laminarTransport
const singlePhaseTransportModel & laminarTransport() const
Return const reference to transport model.
Definition: incompressibleVars.C:418
Foam::incompressibleVars::RASModelVariables_
autoPtr< incompressible::RASModelVariables > RASModelVariables_
Definition: incompressibleVars.H:71
Foam::incompressibleVars::U
const volVectorField & U() const
Return const reference to velocity.
Definition: incompressibleVars.C:331
Foam::incompressibleVars::write
bool write() const
Definition: incompressibleVars.C:539
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::incompressibleVars::UMeanPtr_
autoPtr< volVectorField > UMeanPtr_
Definition: incompressibleVars.H:82
Foam::incompressibleVars::turbulence
const autoPtr< incompressible::turbulenceModel > & turbulence() const
Return const reference to the turbulence model.
Definition: incompressibleVars.C:431
Foam::incompressibleVars::correctBoundaryConditions_
bool correctBoundaryConditions_
Update boundary conditions upon construction.
Definition: incompressibleVars.H:88
Foam::incompressibleVars::correctNonTurbulentBoundaryConditions
void correctNonTurbulentBoundaryConditions()
Update boundary conditions of mean-flow.
Definition: incompressibleVars.C:205
Foam::incompressibleVars::turbulence_
autoPtr< incompressible::turbulenceModel > turbulence_
Definition: incompressibleVars.H:70
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::incompressibleVars::pMeanPtr_
autoPtr< volScalarField > pMeanPtr_
Definition: incompressibleVars.H:81
Foam::incompressibleVars::pInitPtr_
autoPtr< volScalarField > pInitPtr_
Keep a copy of the initial field values if necessary.
Definition: incompressibleVars.H:75
Foam::incompressibleVars::TypeName
TypeName("incompressibleVars")
Run-time type information.
Foam::incompressibleVars::pPtr_
autoPtr< volScalarField > pPtr_
Fields involved in the solution of the incompressible NS equations.
Definition: incompressibleVars.H:66
Foam::incompressibleVars::~incompressibleVars
virtual ~incompressibleVars()=default
Destructor.
Foam::incompressibleVars::correctBoundaryConditions
void correctBoundaryConditions()
correct boundaryconditions for all volFields
Definition: incompressibleVars.C:506
Foam::incompressibleVars::incompressibleVars
incompressibleVars(fvMesh &mesh, solverControl &SolverControl)
Construct from mesh.
Definition: incompressibleVars.C:231
Foam::incompressibleVars::restoreInitValues
void restoreInitValues()
Restore field values to the initial ones.
Definition: incompressibleVars.C:457
Foam::GeometricField< scalar, fvPatchField, volMesh >
variablesSet.H
Foam::incompressibleVars
Base class for solution control classes.
Definition: incompressibleVars.H:54
solverControl.H
Foam::incompressibleVars::pInst
const volScalarField & pInst() const
Return const reference to pressure.
Definition: incompressibleVars.C:382
Foam::incompressibleVars::resetMeanFields
void resetMeanFields()
Reset mean fields to zero.
Definition: incompressibleVars.C:470