turbGen.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-2024 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 \*---------------------------------------------------------------------------*/
25 
26 #include "fft.H"
27 #include "turbGen.H"
28 #include "Kmesh.H"
29 #include "primitiveFields.H"
30 #include "Ek.H"
31 #include "mathematicalConstants.H"
32 
33 
34 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
35 
36 Foam::turbGen::turbGen(const Kmesh& k, const scalar EA, const scalar K0)
37 :
38  K_(k),
39  Ea_(EA),
40  k0_(K0),
41  rndGen_(label(0))
42 {}
43 
44 
45 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
46 
48 {
49  vectorField s(K_.size());
50  scalarField rndPhases(K_.size());
51 
52  forAll(K_, i)
53  {
54  s[i] = rndGen_.sample01<vector>();
55  rndPhases[i] = rndGen_.scalar01();
56  }
57 
58  s = K_ ^ s;
59  s = s/(mag(s) + 1.0e-20);
60 
61  s = Ek(Ea_, k0_, mag(K_))*s;
62 
64  (
66  (
69  K_.nn()
70  )
71  );
72 
73  return ReImSum(up);
74 }
75 
76 
77 // ************************************************************************* //
label k
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
Calculate the wavenumber vector field corresponding to the space vector field of a finite volume mesh...
Definition: Kmesh.H:52
static tmp< complexField > reverseTransform(const tmp< complexField > &field, const labelList &nn)
Definition: fft.C:203
turbGen(const Kmesh &k, const scalar EA, const scalar K0)
Construct from components.
Definition: turbGen.C:36
vectorField U()
Generate and return a velocity field.
Definition: turbGen.C:47
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
const scalar twoPi(2 *pi)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
dimensionedScalar sin(const dimensionedScalar &ds)
dimensioned< scalar > mag(const dimensioned< Type > &)
complexField ComplexField(const UList< scalar > &re, const UList< scalar > &im)
Definition: complexFields.C:42
tmp< scalarField > Ek(const scalar Ea, const scalar k0, const scalarField &k)
Definition: Ek.H:10
dimensionedScalar cos(const dimensionedScalar &ds)
scalarField ReImSum(const UList< complex > &cf)
Definition: complexFields.C:84
Specialisations of Field<T> for scalar, vector and tensor.