FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

UOprocess.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include <OpenFOAM/error.H>
00027 
00028 #include "UOprocess.H"
00029 #include <randomProcesses/Kmesh.H>
00030 #include <OpenFOAM/dictionary.H>
00031 
00032 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00033 
00034 namespace Foam
00035 {
00036 
00037 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00038 
00039 complexVector UOprocess::WeinerProcess()
00040 {
00041     return RootDeltaT*complexVector
00042     (
00043         complex(GaussGen.GaussNormal(), GaussGen.GaussNormal()),
00044         complex(GaussGen.GaussNormal(), GaussGen.GaussNormal()),
00045         complex(GaussGen.GaussNormal(), GaussGen.GaussNormal())
00046     );
00047 }
00048 
00049 
00050 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00051 
00052 // from components
00053 UOprocess::UOprocess
00054 (
00055     const Kmesh& kmesh,
00056     const scalar deltaT,
00057     const dictionary& UOdict
00058 )
00059 :
00060     GaussGen(label(0)),
00061     Mesh(kmesh),
00062     DeltaT(deltaT),
00063     RootDeltaT(sqrt(DeltaT)),
00064     UOfield(Mesh.size()),
00065 
00066     Alpha(readScalar(UOdict.lookup("UOalpha"))),
00067     Sigma(readScalar(UOdict.lookup("UOsigma"))),
00068     Kupper(readScalar(UOdict.lookup("UOKupper"))),
00069     Klower(readScalar(UOdict.lookup("UOKlower"))),
00070     Scale((Kupper - Klower)*pow(scalar(Mesh.size()), 1.0/vector::dim))
00071 {
00072     const vectorField& K = Mesh;
00073 
00074     scalar sqrKupper = sqr(Kupper);
00075     scalar sqrKlower = sqr(Klower) + SMALL;
00076     scalar sqrK;
00077 
00078     forAll(UOfield, i)
00079     {
00080         if ((sqrK = magSqr(K[i])) < sqrKupper && sqrK > sqrKlower)
00081         {
00082             UOfield[i] = Scale*Sigma*WeinerProcess();
00083         }
00084         else
00085         {
00086             UOfield[i] = complexVector
00087             (
00088                 complex(0, 0),
00089                 complex(0, 0),
00090                 complex(0, 0)
00091             );
00092         }
00093     }
00094 }
00095 
00096 
00097 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00098 
00099 const complexVectorField& UOprocess::newField()
00100 {
00101     const vectorField& K = Mesh;
00102 
00103     label count = 0;
00104     scalar sqrKupper = sqr(Kupper);
00105     scalar sqrKlower = sqr(Klower) + SMALL;
00106     scalar sqrK;
00107 
00108     forAll(UOfield, i)
00109     {
00110         if ((sqrK = magSqr(K[i])) < sqrKupper && sqrK > sqrKlower)
00111         {
00112             count++;
00113             UOfield[i] =
00114                 (1.0 - Alpha*DeltaT)*UOfield[i]
00115               + Scale*Sigma*WeinerProcess();
00116         }
00117     }
00118 
00119     Info<< "    Number of forced K = " << count << nl;
00120 
00121     return UOfield;
00122 }
00123 
00124 
00125 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00126 
00127 } // End namespace Foam
00128 
00129 // ************************ vim: set sw=4 sts=4 et: ************************ //
00130 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines