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-------------------------------------------------------------------------------
10License
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
36namespace Foam
37{
38
39// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
40
41complexVector 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// ************************************************************************* //
CGAL::Exact_predicates_exact_constructions_kernel K
Calculate the wavenumber vector field corresponding to the space vector field of a finite volume mesh...
Definition: Kmesh.H:54
Type GaussNormal()
Random UO process.
Definition: UOprocess.H:56
const complexVectorField & newField()
Definition: UOprocess.C:95
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
@ complex
Definition: Roots.H:57
Namespace for OpenFOAM.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
messageStream Info
Information stream (stdout output on master, null elsewhere)
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
dimensionedScalar sqrt(const dimensionedScalar &ds)
Vector< complex > complexVector
A Vector of complex values with 'scalar' precision.
Definition: complexVector.H:49
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333
A non-counting (dummy) refCount.
Definition: refCount.H:59