UOprocess.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "error.H"
29 
30 #include "UOprocess.H"
31 #include "Kmesh.H"
32 #include "dictionary.H"
33 
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38 
39 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
40 
41 complexVector UOprocess::WeinerProcess()
42 {
43  return RootDeltaT*complexVector
44  (
45  complex(GaussGen.GaussNormal<scalar>(), GaussGen.GaussNormal<scalar>()),
46  complex(GaussGen.GaussNormal<scalar>(), GaussGen.GaussNormal<scalar>()),
47  complex(GaussGen.GaussNormal<scalar>(), GaussGen.GaussNormal<scalar>())
48  );
49 }
50 
51 
52 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
53 
55 (
56  const Kmesh& kmesh,
57  const scalar deltaT,
58  const dictionary& UOdict
59 )
60 :
61  GaussGen(),
62  Mesh(kmesh),
63  DeltaT(deltaT),
64  RootDeltaT(sqrt(DeltaT)),
65  UOfield(Mesh.size()),
66 
67  Alpha(UOdict.get<scalar>("UOalpha")),
68  Sigma(UOdict.get<scalar>("UOsigma")),
69  Kupper(UOdict.get<scalar>("UOKupper")),
70  Klower(UOdict.get<scalar>("UOKlower")),
71  Scale((Kupper - Klower)*pow(scalar(Mesh.size()), 1.0/vector::dim))
72 {
73  const vectorField& K = Mesh;
74 
75  scalar sqrKupper = sqr(Kupper);
76  scalar sqrKlower = sqr(Klower) + SMALL;
77  scalar sqrK;
78 
79  forAll(UOfield, i)
80  {
81  if ((sqrK = magSqr(K[i])) < sqrKupper && sqrK > sqrKlower)
82  {
83  UOfield[i] = Scale*Sigma*WeinerProcess();
84  }
85  else
86  {
87  UOfield[i] = complexVector::zero;
88  }
89  }
90 }
91 
92 
93 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
94 
96 {
97  const vectorField& K = Mesh;
98 
99  label count = 0;
100  scalar sqrKupper = sqr(Kupper);
101  scalar sqrKlower = sqr(Klower) + SMALL;
102  scalar sqrK;
103 
104  forAll(UOfield, i)
105  {
106  if ((sqrK = magSqr(K[i])) < sqrKupper && sqrK > sqrKlower)
107  {
108  count++;
109  UOfield[i] =
110  (1.0 - Alpha*DeltaT)*UOfield[i]
111  + Scale*Sigma*WeinerProcess();
112  }
113  }
114 
115  Info<< " Number of forced K = " << count << nl;
116 
117  return UOfield;
118 }
119 
120 
121 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
122 
123 } // End namespace Foam
124 
125 // ************************************************************************* //
Kmesh.H
Foam::complexVector
Vector< complex > complexVector
A Vector of complex values with 'scalar' precision.
Definition: complexVector.H:49
Foam::UOprocess::newField
const complexVectorField & newField()
Definition: UOprocess.C:95
Foam::roots::complex
Definition: Roots.H:57
Foam::Random::GaussNormal
Type GaussNormal()
Definition: RandomTemplates.C:49
Foam::dictionary::get
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:107
Foam::Kmesh
Calculate the wavenumber vector field corresponding to the space vector field of a finite volume mesh...
Definition: Kmesh.H:51
UOprocess.H
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::magSqr
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
K
CGAL::Exact_predicates_exact_constructions_kernel K
Definition: CGALTriangulation3DKernel.H:58
Foam::Field< vector >
error.H
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
Foam::pow
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Definition: dimensionedScalar.C:75
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:51
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::UOprocess::UOprocess
UOprocess(const Kmesh &kmesh, const scalar deltaT, const dictionary &)
Construct from wavenumber mesh and timestep.
Definition: UOprocess.C:55
Foam::BitOps::count
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
Definition: BitOps.H:77
Foam::sqrt
dimensionedScalar sqrt(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:144
dictionary.H
Foam::VectorSpace< Vector< Cmpt >, Cmpt, 3 >::zero
static const Vector< Cmpt > zero
Definition: VectorSpace.H:115
Foam::VectorSpace< Vector< scalar >, scalar, 3 >::dim
static constexpr direction dim
Dimensionality of space.
Definition: VectorSpace.H:98