initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / applications / utilities / preProcessing / engineSwirl / engineSwirl.C
blobe9171c330cc9d0b1de233c100273347e5f57bb4e
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Application
26     engineSwirl
28 Description
29     Generates a swirling flow for engine calulations
31 \*---------------------------------------------------------------------------*/
33 #include "fvCFD.H"
34 #include "mathematicalConstants.H"
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 int main(int argc, char *argv[])
41 #   include "setRootCase.H"
42 #   include "createTime.H"
43 #   include "createMesh.H"
44 #   include "createFields.H"
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48     scalar Vphi = (mathematicalConstant::pi*swirlRPMRatio*rpm/30).value();
49     scalar b1 = j1(swirlProfile).value();
50     scalar b2 = 2.0*b1/swirlProfile.value() - j0(swirlProfile).value();
52     scalar omega = 0.125*(Vphi*bore*swirlProfile/b2).value();
54     scalar cylinderRadius = 0.5*bore.value();
56     scalar Umax = 0.0;
57     forAll(mesh.C(), celli)
58     {
59         vector c = mesh.C()[celli] - swirlCenter;
60         scalar r = ::pow(sqr(c & xT) + sqr(c & yT), 0.5);
62         if (r <= cylinderRadius)
63         {
64             scalar b = j1(swirlProfile*r/cylinderRadius).value();
65             scalar vEff = omega*b;
66             r = max(r, SMALL);
67             U[celli] = ((vEff/r)*(c & yT))*xT + (-(vEff/r)*(c & xT))*yT;
68             Umax = max(Umax, mag(U[celli]));
69         }
70     }
72     Info << "Umax = " << Umax << endl;
74     U.write();
76     Info << "\n end\n";
78     return 0;
82 // ************************************************************************* //