initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / finiteVolume / cfdTools / general / SRF / SRFModel / SRFModel / SRFModel.C
blob18aa01c3e97b195b51c57ee39aad7401f753e6b4
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 \*---------------------------------------------------------------------------*/
27 #include "SRFModel.H"
28 #include "SRFVelocityFvPatchVectorField.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 namespace Foam
34     namespace SRF
35     {
36         defineTypeNameAndDebug(SRFModel, 0);
37         defineRunTimeSelectionTable(SRFModel, dictionary);
38     }
42 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
44 Foam::SRF::SRFModel::SRFModel
46     const word& type,
47     const volVectorField& Urel
50     IOdictionary
51     (
52         IOobject
53         (
54             "SRFProperties",
55             Urel.time().constant(),
56             Urel.db(),
57             IOobject::MUST_READ,
58             IOobject::NO_WRITE
59         )
60     ),
61     Urel_(Urel),
62     mesh_(Urel_.mesh()),
63     axis_(lookup("axis")),
64     SRFModelCoeffs_(subDict(type + "Coeffs")),
65     omega_(dimensionedVector("omega", dimless/dimTime, vector::zero))
67     // Normalise the axis
68     axis_ /= mag(axis_);
72 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
74 Foam::SRF::SRFModel::~SRFModel()
78 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
80 bool Foam::SRF::SRFModel::read()
82     if (regIOobject::read())
83     {
84         // Re-read axis
85         SRFModelCoeffs_.lookup("axis") >> axis_;
86         axis_ /= mag(axis_);
88         // Re-read sub-model coeffs
89         SRFModelCoeffs_ = subDict(type() + "Coeffs");
91         return true;
92     }
93     else
94     {
95         return false;
96     }
100 const Foam::vector& Foam::SRF::SRFModel::axis() const
102     return axis_;
106 const Foam::dimensionedVector& Foam::SRF::SRFModel::omega() const
108     return omega_;
112 Foam::tmp<Foam::DimensionedField<Foam::vector, Foam::volMesh> >
113 Foam::SRF::SRFModel::Fcoriolis() const
115     return tmp<DimensionedField<vector, volMesh> >
116     (
117         new DimensionedField<vector, volMesh>
118         (
119             IOobject
120             (
121                 "Fcoriolis",
122                 mesh_.time().timeName(),
123                 mesh_,
124                 IOobject::NO_READ,
125                 IOobject::NO_WRITE
126             ),
127             2.0*omega_ ^ Urel_
128         )
129     );
133 Foam::tmp<Foam::DimensionedField<Foam::vector, Foam::volMesh> >
134 Foam::SRF::SRFModel::Fcentrifugal() const
136     return tmp<DimensionedField<vector, volMesh> >
137     (
138         new DimensionedField<vector, volMesh>
139         (
140             IOobject
141             (
142                 "Fcentrifugal",
143                 mesh_.time().timeName(),
144                 mesh_,
145                 IOobject::NO_READ,
146                 IOobject::NO_WRITE
147             ),
148             omega_ ^ (omega_ ^ mesh_.C())
149         )
150     );
154 Foam::tmp<Foam::DimensionedField<Foam::vector, Foam::volMesh> >
155 Foam::SRF::SRFModel::Su() const
157     return Fcoriolis() + Fcentrifugal();
161 Foam::vectorField Foam::SRF::SRFModel::velocity
163     const vectorField& positions
164 ) const
166     return omega_.value() ^ (positions - axis_*(axis_ & positions));
170 Foam::tmp<Foam::volVectorField> Foam::SRF::SRFModel::U() const
172     return tmp<volVectorField>
173     (
174         new volVectorField
175         (
176             IOobject
177             (
178                 "Usrf",
179                 mesh_.time().timeName(),
180                 mesh_,
181                 IOobject::NO_READ,
182                 IOobject::NO_WRITE
183             ),
184             omega_ ^ (mesh_.C() - axis_*(axis_ & mesh_.C()))
185         )
186     );
190 Foam::tmp<Foam::volVectorField> Foam::SRF::SRFModel::Uabs() const
192     const volVectorField Usrf = U();
194     tmp<volVectorField> tUabs
195     (
196         new volVectorField
197         (
198             IOobject
199             (
200                 "Uabs",
201                 mesh_.time().timeName(),
202                 mesh_,
203                 IOobject::NO_READ,
204                 IOobject::NO_WRITE,
205                 false
206             ),
207             Usrf
208         )
209     );
211     // Add SRF contribution to internal field
212     tUabs().internalField() += Urel_.internalField();
214     // Add Urel boundary contributions
215     const volVectorField::GeometricBoundaryField& bvf = Urel_.boundaryField();
217     forAll(bvf, i)
218     {
219         if (isA<SRFVelocityFvPatchVectorField>(bvf[i]))
220         {
221             // Only include relative contributions from
222             // SRFVelocityFvPatchVectorField's
223             const SRFVelocityFvPatchVectorField& UrelPatch =
224                 refCast<const SRFVelocityFvPatchVectorField>(bvf[i]);
225             if (UrelPatch.relative())
226             {
227                 tUabs().boundaryField()[i] += Urel_.boundaryField()[i];
228             }
229         }
230         else
231         {
232             tUabs().boundaryField()[i] += Urel_.boundaryField()[i];
233         }
234     }
236     return tUabs;
240 // ************************************************************************* //