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

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-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 "SRFVelocityFvPatchVectorField.H"
00027 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00028 #include <finiteVolume/volFields.H>
00029 
00030 #include <finiteVolume/SRFModel.H>
00031 
00032 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00033 
00034 namespace Foam
00035 {
00036 
00037 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00038 
00039 SRFVelocityFvPatchVectorField::SRFVelocityFvPatchVectorField
00040 (
00041     const fvPatch& p,
00042     const DimensionedField<vector, volMesh>& iF
00043 )
00044 :
00045     fixedValueFvPatchVectorField(p, iF),
00046     relative_(0),
00047     inletValue_(p.size(), vector::zero)
00048 {}
00049 
00050 
00051 SRFVelocityFvPatchVectorField::SRFVelocityFvPatchVectorField
00052 (
00053     const SRFVelocityFvPatchVectorField& ptf,
00054     const fvPatch& p,
00055     const DimensionedField<vector, volMesh>& iF,
00056     const fvPatchFieldMapper& mapper
00057 )
00058 :
00059     fixedValueFvPatchVectorField(ptf, p, iF, mapper),
00060     relative_(ptf.relative_),
00061     inletValue_(ptf.inletValue_, mapper)
00062 {}
00063 
00064 
00065 SRFVelocityFvPatchVectorField::SRFVelocityFvPatchVectorField
00066 (
00067     const fvPatch& p,
00068     const DimensionedField<vector, volMesh>& iF,
00069     const dictionary& dict
00070 )
00071 :
00072     fixedValueFvPatchVectorField(p, iF),
00073     relative_(dict.lookup("relative")),
00074     inletValue_("inletValue", dict, p.size())
00075 {
00076     fvPatchVectorField::operator=(vectorField("value", dict, p.size()));
00077 }
00078 
00079 
00080 SRFVelocityFvPatchVectorField::SRFVelocityFvPatchVectorField
00081 (
00082     const SRFVelocityFvPatchVectorField& srfvpvf
00083 )
00084 :
00085     fixedValueFvPatchVectorField(srfvpvf),
00086     relative_(srfvpvf.relative_),
00087     inletValue_(srfvpvf.inletValue_)
00088 {}
00089 
00090 
00091 SRFVelocityFvPatchVectorField::SRFVelocityFvPatchVectorField
00092 (
00093     const SRFVelocityFvPatchVectorField& srfvpvf,
00094     const DimensionedField<vector, volMesh>& iF
00095 )
00096 :
00097     fixedValueFvPatchVectorField(srfvpvf, iF),
00098     relative_(srfvpvf.relative_),
00099     inletValue_(srfvpvf.inletValue_)
00100 {}
00101 
00102 
00103 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00104 
00105 void SRFVelocityFvPatchVectorField::autoMap
00106 (
00107     const fvPatchFieldMapper& m
00108 )
00109 {
00110     vectorField::autoMap(m);
00111     inletValue_.autoMap(m);
00112 }
00113 
00114 
00115 void SRFVelocityFvPatchVectorField::rmap
00116 (
00117     const fvPatchVectorField& ptf,
00118     const labelList& addr
00119 )
00120 {
00121     fixedValueFvPatchVectorField::rmap(ptf, addr);
00122 
00123     const SRFVelocityFvPatchVectorField& tiptf =
00124         refCast<const SRFVelocityFvPatchVectorField>(ptf);
00125 
00126     inletValue_.rmap(tiptf.inletValue_, addr);
00127 }
00128 
00129 
00130 void SRFVelocityFvPatchVectorField::updateCoeffs()
00131 {
00132     if (updated())
00133     {
00134         return;
00135     }
00136 
00137     // If not relative to the SRF include the effect of the SRF
00138     if (!relative_)
00139     {
00140         // Get reference to the SRF model
00141         const SRF::SRFModel& srf =
00142             db().lookupObject<SRF::SRFModel>("SRFProperties");
00143 
00144         // Determine patch velocity due to SRF
00145         const vectorField SRFVelocity = srf.velocity(patch().Cf());
00146 
00147         operator==(-SRFVelocity + inletValue_);
00148     }
00149     // If already relative to the SRF simply supply the inlet value as a fixed
00150     // 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 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines