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

SRFFreestreamVelocityFvPatchVectorField.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-2011 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 "SRFFreestreamVelocityFvPatchVectorField.H"
00027 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00028 #include <finiteVolume/volFields.H>
00029 #include <finiteVolume/surfaceFields.H>
00030 
00031 #include <finiteVolume/SRFModel.H>
00032 
00033 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00034 
00035 namespace Foam
00036 {
00037 
00038 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00039 
00040 SRFFreestreamVelocityFvPatchVectorField::SRFFreestreamVelocityFvPatchVectorField
00041 (
00042     const fvPatch& p,
00043     const DimensionedField<vector, volMesh>& iF
00044 )
00045 :
00046     inletOutletFvPatchVectorField(p, iF),
00047     UInf_(vector::zero)
00048 {}
00049 
00050 
00051 SRFFreestreamVelocityFvPatchVectorField::SRFFreestreamVelocityFvPatchVectorField
00052 (
00053     const SRFFreestreamVelocityFvPatchVectorField& ptf,
00054     const fvPatch& p,
00055     const DimensionedField<vector, volMesh>& iF,
00056     const fvPatchFieldMapper& mapper
00057 )
00058 :
00059     inletOutletFvPatchVectorField(ptf, p, iF, mapper),
00060     UInf_(ptf.UInf_)
00061 {}
00062 
00063 
00064 SRFFreestreamVelocityFvPatchVectorField::SRFFreestreamVelocityFvPatchVectorField
00065 (
00066     const fvPatch& p,
00067     const DimensionedField<vector, volMesh>& iF,
00068     const dictionary& dict
00069 )
00070 :
00071     inletOutletFvPatchVectorField(p, iF),
00072     UInf_(dict.lookup("UInf"))
00073 {
00074     fvPatchVectorField::operator=(vectorField("value", dict, p.size()));
00075 }
00076 
00077 
00078 SRFFreestreamVelocityFvPatchVectorField::SRFFreestreamVelocityFvPatchVectorField
00079 (
00080     const SRFFreestreamVelocityFvPatchVectorField& srfvpvf
00081 )
00082 :
00083     inletOutletFvPatchVectorField(srfvpvf),
00084     UInf_(srfvpvf.UInf_)
00085 {}
00086 
00087 
00088 SRFFreestreamVelocityFvPatchVectorField::SRFFreestreamVelocityFvPatchVectorField
00089 (
00090     const SRFFreestreamVelocityFvPatchVectorField& srfvpvf,
00091     const DimensionedField<vector, volMesh>& iF
00092 )
00093 :
00094     inletOutletFvPatchVectorField(srfvpvf, iF),
00095     UInf_(srfvpvf.UInf_)
00096 {}
00097 
00098 
00099 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00100 
00101 void SRFFreestreamVelocityFvPatchVectorField::updateCoeffs()
00102 {
00103     if (updated())
00104     {
00105         return;
00106     }
00107 
00108     // Get reference to the SRF model
00109     const SRF::SRFModel& srf =
00110         db().lookupObject<SRF::SRFModel>("SRFProperties");
00111 
00112     scalar time = this->db().time().value();
00113     scalar theta = time*mag(srf.omega().value());
00114 
00115     refValue() =
00116         cos(theta)*UInf_ + sin(theta)*(srf.axis() ^ UInf_)
00117       - srf.velocity(patch().Cf());
00118 
00119     // Set the inlet-outlet choice based on the direction of the freestream
00120     valueFraction() = 1.0 - pos(refValue() & patch().Sf());
00121 
00122     mixedFvPatchField<vector>::updateCoeffs();
00123 }
00124 
00125 
00126 void SRFFreestreamVelocityFvPatchVectorField::write(Ostream& os) const
00127 {
00128     fvPatchVectorField::write(os);
00129     os.writeKeyword("UInf") << UInf_ << token::END_STATEMENT << nl;
00130     writeEntry("value", os);
00131 }
00132 
00133 
00134 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00135 
00136 makePatchTypeField
00137 (
00138     fvPatchVectorField,
00139     SRFFreestreamVelocityFvPatchVectorField
00140 );
00141 
00142 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00143 
00144 } // End namespace Foam
00145 
00146 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines