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

SRFVelocityFvPatchVectorField.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 "SRFVelocityFvPatchVectorField.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 #include "volFields.H"
00030 
00031 #include "SRFModel.H"
00032 
00033 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00034 
00035 namespace Foam
00036 {
00037 
00038 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00039 
00040 SRFVelocityFvPatchVectorField::SRFVelocityFvPatchVectorField
00041 (
00042     const fvPatch& p,
00043     const DimensionedField<vector, volMesh>& iF
00044 )
00045 :
00046     fixedValueFvPatchVectorField(p, iF),
00047     relative_(0),
00048     inletValue_(p.size(), vector::zero)
00049 {}
00050 
00051 
00052 SRFVelocityFvPatchVectorField::SRFVelocityFvPatchVectorField
00053 (
00054     const SRFVelocityFvPatchVectorField& ptf,
00055     const fvPatch& p,
00056     const DimensionedField<vector, volMesh>& iF,
00057     const fvPatchFieldMapper& mapper
00058 )
00059 :
00060     fixedValueFvPatchVectorField(ptf, p, iF, mapper),
00061     relative_(ptf.relative_),
00062     inletValue_(ptf.inletValue_, mapper)
00063 {}
00064 
00065 
00066 SRFVelocityFvPatchVectorField::SRFVelocityFvPatchVectorField
00067 (
00068     const fvPatch& p,
00069     const DimensionedField<vector, volMesh>& iF,
00070     const dictionary& dict
00071 )
00072 :
00073     fixedValueFvPatchVectorField(p, iF),
00074     relative_(dict.lookup("relative")),
00075     inletValue_("inletValue", dict, p.size())
00076 {
00077     fvPatchVectorField::operator=(vectorField("value", dict, p.size()));
00078 }
00079 
00080 
00081 SRFVelocityFvPatchVectorField::SRFVelocityFvPatchVectorField
00082 (
00083     const SRFVelocityFvPatchVectorField& srfvpvf
00084 )
00085 :
00086     fixedValueFvPatchVectorField(srfvpvf),
00087     relative_(srfvpvf.relative_),
00088     inletValue_(srfvpvf.inletValue_)
00089 {}
00090 
00091 
00092 SRFVelocityFvPatchVectorField::SRFVelocityFvPatchVectorField
00093 (
00094     const SRFVelocityFvPatchVectorField& srfvpvf,
00095     const DimensionedField<vector, volMesh>& iF
00096 )
00097 :
00098     fixedValueFvPatchVectorField(srfvpvf, iF),
00099     relative_(srfvpvf.relative_),
00100     inletValue_(srfvpvf.inletValue_)
00101 {}
00102 
00103 
00104 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00105 
00106 void SRFVelocityFvPatchVectorField::autoMap
00107 (
00108     const fvPatchFieldMapper& m
00109 )
00110 {
00111     vectorField::autoMap(m);
00112     inletValue_.autoMap(m);
00113 }
00114 
00115 
00116 void SRFVelocityFvPatchVectorField::rmap
00117 (
00118     const fvPatchVectorField& ptf,
00119     const labelList& addr
00120 )
00121 {
00122     fixedValueFvPatchVectorField::rmap(ptf, addr);
00123 
00124     const SRFVelocityFvPatchVectorField& tiptf =
00125         refCast<const SRFVelocityFvPatchVectorField>(ptf);
00126 
00127     inletValue_.rmap(tiptf.inletValue_, addr);
00128 }
00129 
00130 
00131 void SRFVelocityFvPatchVectorField::updateCoeffs()
00132 {
00133     if (updated())
00134     {
00135         return;
00136     }
00137 
00138     // If relative, include the effect of the SRF
00139     if (relative_)
00140     {
00141         // Get reference to the SRF model
00142         const SRF::SRFModel& srf =
00143             db().lookupObject<SRF::SRFModel>("SRFProperties");
00144 
00145         // Determine patch velocity due to SRF
00146         const vectorField SRFVelocity = srf.velocity(patch().Cf());
00147 
00148         operator==(-SRFVelocity + inletValue_);
00149     }
00150     // If absolute, simply supply the inlet value as a fixed value
00151     else
00152     {
00153         operator==(inletValue_);
00154     }
00155 
00156     fixedValueFvPatchVectorField::updateCoeffs();
00157 }
00158 
00159 
00160 void SRFVelocityFvPatchVectorField::write(Ostream& os) const
00161 {
00162     fvPatchVectorField::write(os);
00163     os.writeKeyword("relative") << relative_ << token::END_STATEMENT << nl;
00164     inletValue_.writeEntry("inletValue", os);
00165     writeEntry("value", os);
00166 }
00167 
00168 
00169 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00170 
00171 makePatchTypeField
00172 (
00173     fvPatchVectorField,
00174     SRFVelocityFvPatchVectorField
00175 );
00176 
00177 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00178 
00179 } // End namespace Foam
00180 
00181 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd