R.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 | Copyright (C) 2011-2015 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Application
25  R
26 
27 Description
28  Calculates and writes the Reynolds stress R for the current time step.
29 
30  Compressible modes is automatically selected based on the existence of the
31  "thermophysicalProperties" dictionary required to construct the
32  thermodynamics package.
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #include "fvCFD.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 void calcIncompressibleR
44 (
45  const fvMesh& mesh,
46  const Time& runTime,
47  const volVectorField& U
48 )
49 {
50  #include "createPhi.H"
51 
52  singlePhaseTransportModel laminarTransport(U, phi);
53 
54  autoPtr<incompressible::turbulenceModel> model
55  (
57  );
58 
59  Info<< "Writing R field" << nl << endl;
60 
61  model->R()().write();
62 }
63 
64 
65 void calcCompressibleR
66 (
67  const fvMesh& mesh,
68  const Time& runTime,
69  const volVectorField& U
70 )
71 {
72  IOobject rhoHeader
73  (
74  "rho",
75  runTime.timeName(),
76  mesh,
77  IOobject::MUST_READ,
78  IOobject::NO_WRITE
79  );
80 
81  if (!rhoHeader.headerOk())
82  {
83  Info<< " no " << rhoHeader.name() <<" field" << endl;
84  return;
85  }
86 
87  Info<< "Reading field rho\n" << endl;
88  volScalarField rho(rhoHeader, mesh);
89 
90  #include "compressibleCreatePhi.H"
91 
92  autoPtr<fluidThermo> pThermo(fluidThermo::New(mesh));
93  fluidThermo& thermo = pThermo();
94 
95  autoPtr<compressible::turbulenceModel> model
96  (
98  (
99  rho,
100  U,
101  phi,
102  thermo
103  )
104  );
105 
106  Info<< "Writing R field" << nl << endl;
107 
108  model->R()().write();
109 }
110 
111 
112 int main(int argc, char *argv[])
113 {
114  timeSelector::addOptions();
115  #include "addRegionOption.H"
116  #include "setRootCase.H"
117  #include "createTime.H"
118  instantList timeDirs = timeSelector::select0(runTime, args);
119  #include "createNamedMesh.H"
120 
121  forAll(timeDirs, timeI)
122  {
123  runTime.setTime(timeDirs[timeI], timeI);
124  Info<< "Time = " << runTime.timeName() << endl;
125 
126  IOobject UHeader
127  (
128  "U",
129  runTime.timeName(),
130  mesh,
131  IOobject::MUST_READ,
132  IOobject::NO_WRITE
133  );
134 
135  if (UHeader.headerOk())
136  {
137  Info<< "Reading field " << UHeader.name() << nl << endl;
139 
140  if
141  (
142  IOobject
143  (
145  runTime.constant(),
146  mesh
147  ).headerOk()
148  )
149  {
150  calcCompressibleR(mesh, runTime, U);
151  }
152  else
153  {
154  calcIncompressibleR(mesh, runTime, U);
155  }
156  }
157  else
158  {
159  Info<< " no " << UHeader.name() << " field" << endl;
160  }
161  }
162 
163  Info<< "End\n" << endl;
164 
165  return 0;
166 }
167 
168 
169 // ************************************************************************* //
pThermo
Info<< "Reading thermophysical properties\n"<< endl;autoPtr< psiThermo > pThermo(psiThermo::New(mesh))
Foam::compressible::New
autoPtr< BasicCompressibleTurbulenceModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleTurbulenceModel::transportModel &transport, const word &propertiesName)
Definition: turbulentFluidThermoModel.C:36
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
singlePhaseTransportModel.H
phi
surfaceScalarField & phi
Definition: setRegionFluidFields.H:8
turbulentTransportModel.H
thermo
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::instantList
List< instant > instantList
List of instants.
Definition: instantList.H:42
U
U
Definition: pEqn.H:46
dictName
const word dictName("particleTrackDict")
UHeader
IOobject UHeader("U", runTime.timeName(), mesh, IOobject::MUST_READ)
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
addRegionOption.H
main
int main(int argc, char *argv[])
Definition: postCalc.C:54
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
createNamedMesh.H
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
compressibleCreatePhi.H
Creates and initialises the face-flux field phi.
rho
rho
Definition: pEqn.H:3
Foam::volVectorField
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:55
setRootCase.H
timeDirs
static instantList timeDirs
Definition: globalFoam.H:44
laminarTransport
singlePhaseTransportModel laminarTransport(U, phi)
createTime.H
fvCFD.H
args
Foam::argList args(argc, argv)
write
Tcoeff write()
turbulentFluidThermoModel.H