boxTurb.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 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  boxTurb
26 
27 Description
28  Makes a box of turbulence which conforms to a given energy
29  spectrum and is divergence free.
30 
31 \*---------------------------------------------------------------------------*/
32 
33 #include "fvCFD.H"
34 #include "graph.H"
35 #include "OFstream.H"
36 #include "Kmesh.H"
37 #include "turbGen.H"
38 #include "calcEk.H"
39 #include "writeFile.H"
40 
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 int main(int argc, char *argv[])
45 {
46  argList::noParallel();
47  #include "setRootCase.H"
48 
49  #include "createTime.H"
50  #include "createMesh.H"
51  #include "createFields.H"
52  #include "readBoxTurbDict.H"
53 
54 
55  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 
57  Kmesh K(mesh);
58 
59  turbGen Ugen(K, Ea, k0);
60 
61  U.primitiveFieldRef() = Ugen.U();
62  U.correctBoundaryConditions();
63 
64  Info<< "k("
65  << runTime.timeName()
66  << ") = "
67  << 3.0/2.0*average(magSqr(U)).value() << endl;
68 
69  U.write();
70 
71  calcEk(U, K).write
72  (
73  runTime.path()
74  /functionObjects::writeFile::outputPrefix
75  /"graphs"
76  /runTime.timeName(),
77  "Ek",
78  runTime.graphFormat()
79  );
80 
81  Info<< "end" << endl;
82 
83  return 0;
84 }
85 
86 
87 // ************************************************************************* //
void write(Ostream &, const word &format) const
Write graph to stream in given format.
Definition: graph.C:221
engineTime & runTime
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
graph calcEk(const volVectorField &U, const Kmesh &K)
Definition: calcEk.C:27
CGAL::Exact_predicates_exact_constructions_kernel K
dynamicFvMesh & mesh
dimensioned< scalar > magSqr(const dimensioned< Type > &)
U
Definition: pEqn.H:72
messageStream Info
tmp< GeometricField< Type, fvPatchField, volMesh > > average(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Area-weighted average a surfaceField creating a volField.
Definition: fvcAverage.C:46
scalar Ea(const scalar p, const scalar T) const
Definition: HtoEthermo.H:20