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

oscillatingVelocityPointPatchVectorField.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 "oscillatingVelocityPointPatchVectorField.H"
00027 #include <OpenFOAM/pointPatchFields.H>
00028 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00029 #include <OpenFOAM/Time.H>
00030 #include <OpenFOAM/polyMesh.H>
00031 
00032 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00033 
00034 namespace Foam
00035 {
00036 
00037 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00038 
00039 oscillatingVelocityPointPatchVectorField::
00040 oscillatingVelocityPointPatchVectorField
00041 (
00042     const pointPatch& p,
00043     const DimensionedField<vector, pointMesh>& iF
00044 )
00045 :
00046     fixedValuePointPatchField<vector>(p, iF),
00047     amplitude_(vector::zero),
00048     omega_(0.0),
00049     p0_(p.localPoints())
00050 {}
00051 
00052 
00053 oscillatingVelocityPointPatchVectorField::
00054 oscillatingVelocityPointPatchVectorField
00055 (
00056     const pointPatch& p,
00057     const DimensionedField<vector, pointMesh>& iF,
00058     const dictionary& dict
00059 )
00060 :
00061     fixedValuePointPatchField<vector>(p, iF, dict),
00062     amplitude_(dict.lookup("amplitude")),
00063     omega_(readScalar(dict.lookup("omega")))
00064 {
00065     if (!dict.found("value"))
00066     {
00067         updateCoeffs();
00068     }
00069 
00070     if (dict.found("p0"))
00071     {
00072         p0_ = vectorField("p0", dict , p.size());
00073     }
00074     else
00075     {
00076         p0_ = p.localPoints();
00077     }
00078 }
00079 
00080 
00081 oscillatingVelocityPointPatchVectorField::
00082 oscillatingVelocityPointPatchVectorField
00083 (
00084     const oscillatingVelocityPointPatchVectorField& ptf,
00085     const pointPatch& p,
00086     const DimensionedField<vector, pointMesh>& iF,
00087     const pointPatchFieldMapper& mapper
00088 )
00089 :
00090     fixedValuePointPatchField<vector>(ptf, p, iF, mapper),
00091     amplitude_(ptf.amplitude_),
00092     omega_(ptf.omega_),
00093     p0_(ptf.p0_, mapper)
00094 {}
00095 
00096 
00097 oscillatingVelocityPointPatchVectorField::
00098 oscillatingVelocityPointPatchVectorField
00099 (
00100     const oscillatingVelocityPointPatchVectorField& ptf,
00101     const DimensionedField<vector, pointMesh>& iF
00102 )
00103 :
00104     fixedValuePointPatchField<vector>(ptf, iF),
00105     amplitude_(ptf.amplitude_),
00106     omega_(ptf.omega_),
00107     p0_(ptf.p0_)
00108 {}
00109 
00110 
00111 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00112 
00113 void oscillatingVelocityPointPatchVectorField::autoMap
00114 (
00115     const pointPatchFieldMapper& m
00116 )
00117 {
00118     fixedValuePointPatchField<vector>::autoMap(m);
00119 
00120     p0_.autoMap(m);
00121 }
00122 
00123 
00124 void oscillatingVelocityPointPatchVectorField::rmap
00125 (
00126     const pointPatchField<vector>& ptf,
00127     const labelList& addr
00128 )
00129 {
00130     const oscillatingVelocityPointPatchVectorField& oVptf =
00131         refCast<const oscillatingVelocityPointPatchVectorField>(ptf);
00132 
00133     fixedValuePointPatchField<vector>::rmap(oVptf, addr);
00134 
00135     p0_.rmap(oVptf.p0_, addr);
00136 }
00137 
00138 
00139 void oscillatingVelocityPointPatchVectorField::updateCoeffs()
00140 {
00141     if (this->updated())
00142     {
00143         return;
00144     }
00145 
00146     const polyMesh& mesh = this->dimensionedInternalField().mesh()();
00147     const Time& t = mesh.time();
00148     const pointPatch& p = this->patch();
00149 
00150     Field<vector>::operator=
00151     (
00152         (p0_ + amplitude_*sin(omega_*t.value()) - p.localPoints())
00153        /t.deltaTValue()
00154     );
00155 
00156     fixedValuePointPatchField<vector>::updateCoeffs();
00157 }
00158 
00159 
00160 void oscillatingVelocityPointPatchVectorField::write(Ostream& os) const
00161 {
00162     pointPatchField<vector>::write(os);
00163     os.writeKeyword("amplitude")
00164         << amplitude_ << token::END_STATEMENT << nl;
00165     os.writeKeyword("omega")
00166         << omega_ << token::END_STATEMENT << nl;
00167     p0_.writeEntry("p0", os);
00168     writeEntry("value", os);
00169 }
00170 
00171 
00172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00173 
00174 makePointPatchTypeField
00175 (
00176     pointPatchVectorField,
00177     oscillatingVelocityPointPatchVectorField
00178 );
00179 
00180 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00181 
00182 } // End namespace Foam
00183 
00184 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines