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-2023 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 "argList.H"
34 #include "volFields.H"
35 #include "OFstream.H"
36 #include "Kmesh.H"
37 #include "turbGen.H"
38 #include "writeEk.H"
39 #include "writeFile.H"
40 
41 using namespace Foam;
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 int main(int argc, char *argv[])
46 {
48  #include "setRootCase.H"
49 
50  #include "createTime.H"
51  #include "createMeshNoChangers.H"
52  #include "createFields.H"
53  #include "readBoxTurbDict.H"
54 
55 
56  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57 
58  Kmesh K(mesh);
59 
60  turbGen Ugen(K, Ea, k0);
61 
62  U.primitiveFieldRef() = Ugen.U();
63  U.correctBoundaryConditions();
64 
65  Info<< "k("
66  << runTime.name()
67  << ") = "
68  << 3.0/2.0*average(magSqr(U)).value() << endl;
69 
70  U.write();
71 
72  writeEk(U, K);
73 
74  Info<< "end" << endl;
75 
76  return 0;
77 }
78 
79 
80 // ************************************************************************* //
scalar Ea(const scalar p, const scalar T) const
Definition: HtoEthermo.H:20
Calculate the wavenumber vector field corresponding to the space vector field of a finite volume mesh...
Definition: Kmesh.H:52
static void noParallel()
Remove the parallel options.
Definition: argList.C:175
Generate a turbulent velocity field conforming to a given energy spectrum and being divergence free.
Definition: turbGen.H:54
int main(int argc, char *argv[])
Definition: financialFoam.C:44
K
Definition: pEqn.H:75
U
Definition: pEqn.H:72
Namespace for OpenFOAM.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
messageStream Info
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &df)
void writeEk(const volVectorField &U, const Kmesh &K)
Definition: writeEk.C:41
dimensioned< scalar > magSqr(const dimensioned< Type > &)
This function evaluates q(k) (McComb, p61) by summing all wavevectors in a k-shell....