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

SRFModel.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 "SRFModel.H"
00028 #include "SRFVelocityFvPatchVectorField.H"
00029 
00030 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00031 
00032 namespace Foam
00033 {
00034     namespace SRF
00035     {
00036         defineTypeNameAndDebug(SRFModel, 0);
00037         defineRunTimeSelectionTable(SRFModel, dictionary);
00038     }
00039 }
00040 
00041 
00042 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00043 
00044 Foam::SRF::SRFModel::SRFModel
00045 (
00046     const word& type,
00047     const volVectorField& Urel
00048 )
00049 :
00050     IOdictionary
00051     (
00052         IOobject
00053         (
00054             "SRFProperties",
00055             Urel.time().constant(),
00056             Urel.db(),
00057             IOobject::MUST_READ,
00058             IOobject::NO_WRITE
00059         )
00060     ),
00061     Urel_(Urel),
00062     mesh_(Urel_.mesh()),
00063     axis_(lookup("axis")),
00064     SRFModelCoeffs_(subDict(type + "Coeffs")),
00065     omega_(dimensionedVector("omega", dimless/dimTime, vector::zero))
00066 {
00067     // Normalise the axis
00068     axis_ /= mag(axis_);
00069 }
00070 
00071 
00072 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00073 
00074 Foam::SRF::SRFModel::~SRFModel()
00075 {}
00076 
00077 
00078 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00079 
00080 bool Foam::SRF::SRFModel::read()
00081 {
00082     if (regIOobject::read())
00083     {
00084         // Re-read axis
00085         SRFModelCoeffs_.lookup("axis") >> axis_;
00086         axis_ /= mag(axis_);
00087 
00088         // Re-read sub-model coeffs
00089         SRFModelCoeffs_ = subDict(type() + "Coeffs");
00090 
00091         return true;
00092     }
00093     else
00094     {
00095         return false;
00096     }
00097 }
00098 
00099 
00100 const Foam::vector& Foam::SRF::SRFModel::axis() const
00101 {
00102     return axis_;
00103 }
00104 
00105 
00106 const Foam::dimensionedVector& Foam::SRF::SRFModel::omega() const
00107 {
00108     return omega_;
00109 }
00110 
00111 
00112 Foam::tmp<Foam::DimensionedField<Foam::vector, Foam::volMesh> >
00113 Foam::SRF::SRFModel::Fcoriolis() const
00114 {
00115     return tmp<DimensionedField<vector, volMesh> >
00116     (
00117         new DimensionedField<vector, volMesh>
00118         (
00119             IOobject
00120             (
00121                 "Fcoriolis",
00122                 mesh_.time().timeName(),
00123                 mesh_,
00124                 IOobject::NO_READ,
00125                 IOobject::NO_WRITE
00126             ),
00127             2.0*omega_ ^ Urel_
00128         )
00129     );
00130 }
00131 
00132 
00133 Foam::tmp<Foam::DimensionedField<Foam::vector, Foam::volMesh> >
00134 Foam::SRF::SRFModel::Fcentrifugal() const
00135 {
00136     return tmp<DimensionedField<vector, volMesh> >
00137     (
00138         new DimensionedField<vector, volMesh>
00139         (
00140             IOobject
00141             (
00142                 "Fcentrifugal",
00143                 mesh_.time().timeName(),
00144                 mesh_,
00145                 IOobject::NO_READ,
00146                 IOobject::NO_WRITE
00147             ),
00148             omega_ ^ (omega_ ^ mesh_.C())
00149         )
00150     );
00151 }
00152 
00153 
00154 Foam::tmp<Foam::DimensionedField<Foam::vector, Foam::volMesh> >
00155 Foam::SRF::SRFModel::Su() const
00156 {
00157     return Fcoriolis() + Fcentrifugal();
00158 }
00159 
00160 
00161 Foam::vectorField Foam::SRF::SRFModel::velocity
00162 (
00163     const vectorField& positions
00164 ) const
00165 {
00166     return omega_.value() ^ (positions - axis_*(axis_ & positions));
00167 }
00168 
00169 
00170 Foam::tmp<Foam::volVectorField> Foam::SRF::SRFModel::U() const
00171 {
00172     return tmp<volVectorField>
00173     (
00174         new volVectorField
00175         (
00176             IOobject
00177             (
00178                 "Usrf",
00179                 mesh_.time().timeName(),
00180                 mesh_,
00181                 IOobject::NO_READ,
00182                 IOobject::NO_WRITE
00183             ),
00184             omega_ ^ (mesh_.C() - axis_*(axis_ & mesh_.C()))
00185         )
00186     );
00187 }
00188 
00189 
00190 Foam::tmp<Foam::volVectorField> Foam::SRF::SRFModel::Uabs() const
00191 {
00192     const volVectorField Usrf = U();
00193 
00194     tmp<volVectorField> tUabs
00195     (
00196         new volVectorField
00197         (
00198             IOobject
00199             (
00200                 "Uabs",
00201                 mesh_.time().timeName(),
00202                 mesh_,
00203                 IOobject::NO_READ,
00204                 IOobject::NO_WRITE,
00205                 false
00206             ),
00207             Usrf
00208         )
00209     );
00210 
00211     // Add SRF contribution to internal field
00212     tUabs().internalField() += Urel_.internalField();
00213 
00214     // Add Urel boundary contributions
00215     const volVectorField::GeometricBoundaryField& bvf = Urel_.boundaryField();
00216 
00217     forAll(bvf, i)
00218     {
00219         if (isA<SRFVelocityFvPatchVectorField>(bvf[i]))
00220         {
00221             // Only include relative contributions from
00222             // SRFVelocityFvPatchVectorField's
00223             const SRFVelocityFvPatchVectorField& UrelPatch =
00224                 refCast<const SRFVelocityFvPatchVectorField>(bvf[i]);
00225             if (UrelPatch.relative())
00226             {
00227                 tUabs().boundaryField()[i] += Urel_.boundaryField()[i];
00228             }
00229         }
00230         else
00231         {
00232             tUabs().boundaryField()[i] += Urel_.boundaryField()[i];
00233         }
00234     }
00235 
00236     return tUabs;
00237 }
00238 
00239 
00240 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd