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-2018 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 
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 int main(int argc, char *argv[])
44 {
45  argList::noParallel();
46  #include "setRootCase.H"
47 
48  #include "createTime.H"
49  #include "createMesh.H"
50  #include "createFields.H"
51  #include "readBoxTurbDict.H"
52 
53 
54  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 
56  Kmesh K(mesh);
57 
58  turbGen Ugen(K, Ea, k0);
59 
60  U.primitiveFieldRef() = Ugen.U();
61  U.correctBoundaryConditions();
62 
63  Info<< "k("
64  << runTime.timeName()
65  << ") = "
66  << 3.0/2.0*average(magSqr(U)).value() << endl;
67 
68  U.write();
69 
70  calcEk(U, K).write
71  (
72  runTime.path()/"graphs"/runTime.timeName(),
73  "Ek",
74  runTime.graphFormat()
75  );
76 
77  Info<< "end" << endl;
78 
79  return 0;
80 }
81 
82 
83 // ************************************************************************* //
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:256
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