OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

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-2009 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 the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     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, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "error.H"
00028 
00029 #include "UOprocess.H"
00030 #include "Kmesh.H"
00031 #include "dictionary.H"
00032 
00033 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00034 
00035 namespace Foam
00036 {
00037 
00038 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00039 
00040 complexVector UOprocess::WeinerProcess()
00041 {
00042     return RootDeltaT*complexVector
00043     (
00044         complex(GaussGen.GaussNormal(), GaussGen.GaussNormal()),
00045         complex(GaussGen.GaussNormal(), GaussGen.GaussNormal()),
00046         complex(GaussGen.GaussNormal(), GaussGen.GaussNormal())
00047     );
00048 }
00049 
00050 
00051 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00052 
00053 // from components
00054 UOprocess::UOprocess
00055 (
00056     const Kmesh& kmesh,
00057     const scalar deltaT,
00058     const dictionary& UOdict
00059 )
00060 :
00061     GaussGen(label(0)),
00062     Mesh(kmesh),
00063     DeltaT(deltaT),
00064     RootDeltaT(sqrt(DeltaT)),
00065     UOfield(Mesh.size()),
00066 
00067     Alpha(readScalar(UOdict.lookup("UOalpha"))),
00068     Sigma(readScalar(UOdict.lookup("UOsigma"))),
00069     Kupper(readScalar(UOdict.lookup("UOKupper"))),
00070     Klower(readScalar(UOdict.lookup("UOKlower"))),
00071     Scale((Kupper - Klower)*pow(scalar(Mesh.size()), 1.0/vector::dim))
00072 {
00073     const vectorField& K = Mesh;
00074 
00075     scalar sqrKupper = sqr(Kupper);
00076     scalar sqrKlower = sqr(Klower) + SMALL;
00077     scalar sqrK;
00078 
00079     forAll(UOfield, i)
00080     {
00081         if ((sqrK = magSqr(K[i])) < sqrKupper && sqrK > sqrKlower)
00082         {
00083             UOfield[i] = Scale*Sigma*WeinerProcess();
00084         }
00085         else
00086         {
00087             UOfield[i] = complexVector
00088             (
00089                 complex(0, 0),
00090                 complex(0, 0),
00091                 complex(0, 0)
00092             );
00093         }
00094     }
00095 }
00096 
00097 
00098 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00099 
00100 const complexVectorField& UOprocess::newField()
00101 {
00102     const vectorField& K = Mesh;
00103 
00104     label count = 0;
00105     scalar sqrKupper = sqr(Kupper);
00106     scalar sqrKlower = sqr(Klower) + SMALL;
00107     scalar sqrK;
00108 
00109     forAll(UOfield, i)
00110     {
00111         if ((sqrK = magSqr(K[i])) < sqrKupper && sqrK > sqrKlower)
00112         {
00113             count++;
00114             UOfield[i] =
00115                 (1.0 - Alpha*DeltaT)*UOfield[i]
00116               + Scale*Sigma*WeinerProcess();
00117         }
00118     }
00119 
00120     Info<< "    Number of forced K = " << count << nl;
00121 
00122     return UOfield;
00123 }
00124 
00125 
00126 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00127 
00128 } // End namespace Foam
00129 
00130 // ************************************************************************* //
00131 
Copyright © 2000-2009 OpenCFD Ltd