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

rotatingWallVelocityFvPatchVectorField.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 "rotatingWallVelocityFvPatchVectorField.H"
00027 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00028 #include <finiteVolume/volFields.H>
00029 #include <finiteVolume/surfaceFields.H>
00030 
00031 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00032 
00033 namespace Foam
00034 {
00035 
00036 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00037 
00038 rotatingWallVelocityFvPatchVectorField::rotatingWallVelocityFvPatchVectorField
00039 (
00040     const fvPatch& p,
00041     const DimensionedField<vector, volMesh>& iF
00042 )
00043 :
00044     fixedValueFvPatchField<vector>(p, iF),
00045     origin_(vector::zero),
00046     axis_(vector::zero),
00047     omega_(0)
00048 {}
00049 
00050 
00051 rotatingWallVelocityFvPatchVectorField::rotatingWallVelocityFvPatchVectorField
00052 (
00053     const rotatingWallVelocityFvPatchVectorField& ptf,
00054     const fvPatch& p,
00055     const DimensionedField<vector, volMesh>& iF,
00056     const fvPatchFieldMapper& mapper
00057 )
00058 :
00059     fixedValueFvPatchField<vector>(ptf, p, iF, mapper),
00060     origin_(ptf.origin_),
00061     axis_(ptf.axis_),
00062     omega_(ptf.omega_)
00063 {}
00064 
00065 
00066 rotatingWallVelocityFvPatchVectorField::rotatingWallVelocityFvPatchVectorField
00067 (
00068     const fvPatch& p,
00069     const DimensionedField<vector, volMesh>& iF,
00070     const dictionary& dict
00071 )
00072 :
00073     fixedValueFvPatchField<vector>(p, iF),
00074     origin_(dict.lookup("origin")),
00075     axis_(dict.lookup("axis")),
00076     omega_(readScalar(dict.lookup("omega")))
00077 {
00078     // Evaluate the wall velocity
00079     updateCoeffs();
00080 }
00081 
00082 
00083 rotatingWallVelocityFvPatchVectorField::rotatingWallVelocityFvPatchVectorField
00084 (
00085     const rotatingWallVelocityFvPatchVectorField& pivpvf
00086 )
00087 :
00088     fixedValueFvPatchField<vector>(pivpvf),
00089     origin_(pivpvf.origin_),
00090     axis_(pivpvf.axis_),
00091     omega_(pivpvf.omega_)
00092 {}
00093 
00094 
00095 rotatingWallVelocityFvPatchVectorField::rotatingWallVelocityFvPatchVectorField
00096 (
00097     const rotatingWallVelocityFvPatchVectorField& pivpvf,
00098     const DimensionedField<vector, volMesh>& iF
00099 )
00100 :
00101     fixedValueFvPatchField<vector>(pivpvf, iF),
00102     origin_(pivpvf.origin_),
00103     axis_(pivpvf.axis_),
00104     omega_(pivpvf.omega_)
00105 {}
00106 
00107 
00108 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00109 
00110 void rotatingWallVelocityFvPatchVectorField::updateCoeffs()
00111 {
00112     if (updated())
00113     {
00114         return;
00115     }
00116 
00117     // Calculate the rotating wall velocity from the specification of the motion
00118     vectorField Up = (-omega_)*((patch().Cf() - origin_) ^ (axis_/mag(axis_)));
00119 
00120     // Remove the component of Up normal to the wall
00121     // just in case it is not exactly circular
00122     vectorField n = patch().nf();
00123     vectorField::operator=(Up - n*(n & Up));
00124 
00125     fixedValueFvPatchVectorField::updateCoeffs();
00126 }
00127 
00128 
00129 void rotatingWallVelocityFvPatchVectorField::write(Ostream& os) const
00130 {
00131     fvPatchVectorField::write(os);
00132     os.writeKeyword("origin") << origin_ << token::END_STATEMENT << nl;
00133     os.writeKeyword("axis") << axis_ << token::END_STATEMENT << nl;
00134     os.writeKeyword("omega") << omega_ << token::END_STATEMENT << nl;
00135     writeEntry("value", os);
00136 }
00137 
00138 
00139 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00140 
00141 makePatchTypeField
00142 (
00143     fvPatchVectorField,
00144     rotatingWallVelocityFvPatchVectorField
00145 );
00146 
00147 
00148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00149 
00150 } // End namespace Foam
00151 
00152 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines