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

angularOscillatingVelocityPointPatchVectorField.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 "angularOscillatingVelocityPointPatchVectorField.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 angularOscillatingVelocityPointPatchVectorField::
00040 angularOscillatingVelocityPointPatchVectorField
00041 (
00042     const pointPatch& p,
00043     const DimensionedField<vector, pointMesh>& iF
00044 )
00045 :
00046     fixedValuePointPatchField<vector>(p, iF),
00047     axis_(vector::zero),
00048     origin_(vector::zero),
00049     angle0_(0.0),
00050     amplitude_(0.0),
00051     omega_(0.0),
00052     p0_(p.localPoints())
00053 {}
00054 
00055 
00056 angularOscillatingVelocityPointPatchVectorField::
00057 angularOscillatingVelocityPointPatchVectorField
00058 (
00059     const pointPatch& p,
00060     const DimensionedField<vector, pointMesh>& iF,
00061     const dictionary& dict
00062 )
00063 :
00064     fixedValuePointPatchField<vector>(p, iF, dict),
00065     axis_(dict.lookup("axis")),
00066     origin_(dict.lookup("origin")),
00067     angle0_(readScalar(dict.lookup("angle0"))),
00068     amplitude_(readScalar(dict.lookup("amplitude"))),
00069     omega_(readScalar(dict.lookup("omega")))
00070 {
00071     if (!dict.found("value"))
00072     {
00073         updateCoeffs();
00074     }
00075 
00076     if (dict.found("p0"))
00077     {
00078         p0_ = vectorField("p0", dict , p.size());
00079     }
00080     else
00081     {
00082         p0_ = p.localPoints();
00083     }
00084 }
00085 
00086 
00087 angularOscillatingVelocityPointPatchVectorField::
00088 angularOscillatingVelocityPointPatchVectorField
00089 (
00090     const angularOscillatingVelocityPointPatchVectorField& ptf,
00091     const pointPatch& p,
00092     const DimensionedField<vector, pointMesh>& iF,
00093     const pointPatchFieldMapper& mapper
00094 )
00095 :
00096     fixedValuePointPatchField<vector>(ptf, p, iF, mapper),
00097     axis_(ptf.axis_),
00098     origin_(ptf.origin_),
00099     angle0_(ptf.angle0_),
00100     amplitude_(ptf.amplitude_),
00101     omega_(ptf.omega_),
00102     p0_(ptf.p0_)
00103 {}
00104 
00105 
00106 angularOscillatingVelocityPointPatchVectorField::
00107 angularOscillatingVelocityPointPatchVectorField
00108 (
00109     const angularOscillatingVelocityPointPatchVectorField& ptf,
00110     const DimensionedField<vector, pointMesh>& iF
00111 )
00112 :
00113     fixedValuePointPatchField<vector>(ptf, iF),
00114     axis_(ptf.axis_),
00115     origin_(ptf.origin_),
00116     angle0_(ptf.angle0_),
00117     amplitude_(ptf.amplitude_),
00118     omega_(ptf.omega_),
00119     p0_(ptf.p0_)
00120 {}
00121 
00122 
00123 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00124 
00125 void angularOscillatingVelocityPointPatchVectorField::autoMap
00126 (
00127     const pointPatchFieldMapper& m
00128 )
00129 {
00130     fixedValuePointPatchField<vector>::autoMap(m);
00131 
00132     p0_.autoMap(m);
00133 }
00134 
00135 
00136 void angularOscillatingVelocityPointPatchVectorField::rmap
00137 (
00138     const pointPatchField<vector>& ptf,
00139     const labelList& addr
00140 )
00141 {
00142     const angularOscillatingVelocityPointPatchVectorField& aOVptf =
00143         refCast<const angularOscillatingVelocityPointPatchVectorField>(ptf);
00144 
00145     fixedValuePointPatchField<vector>::rmap(aOVptf, addr);
00146 
00147     p0_.rmap(aOVptf.p0_, addr);
00148 }
00149 
00150 
00151 void angularOscillatingVelocityPointPatchVectorField::updateCoeffs()
00152 {
00153     if (this->updated())
00154     {
00155         return;
00156     }
00157 
00158     const polyMesh& mesh = this->dimensionedInternalField().mesh()();
00159     const Time& t = mesh.time();
00160     const pointPatch& p = this->patch();
00161 
00162     scalar angle = angle0_ + amplitude_*sin(omega_*t.value());
00163     vector axisHat = axis_/mag(axis_);
00164     vectorField p0Rel = p0_ - origin_;
00165 
00166     vectorField::operator=
00167     (
00168         (
00169             p0_
00170           + p0Rel*(cos(angle) - 1)
00171           + (axisHat ^ p0Rel*sin(angle))
00172           + (axisHat & p0Rel)*(1 - cos(angle))*axisHat
00173           - p.localPoints()
00174         )/t.deltaTValue()
00175     );
00176 
00177     fixedValuePointPatchField<vector>::updateCoeffs();
00178 }
00179 
00180 
00181 void angularOscillatingVelocityPointPatchVectorField::write
00182 (
00183     Ostream& os
00184 ) const
00185 {
00186     pointPatchField<vector>::write(os);
00187     os.writeKeyword("axis")
00188         << axis_ << token::END_STATEMENT << nl;
00189     os.writeKeyword("origin")
00190         << origin_ << token::END_STATEMENT << nl;
00191     os.writeKeyword("angle0")
00192         << angle0_ << token::END_STATEMENT << nl;
00193     os.writeKeyword("amplitude")
00194         << amplitude_ << token::END_STATEMENT << nl;
00195     os.writeKeyword("omega")
00196         << omega_ << token::END_STATEMENT << nl;
00197     p0_.writeEntry("p0", os);
00198     writeEntry("value", os);
00199 }
00200 
00201 
00202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00203 
00204 makePointPatchTypeField
00205 (
00206     pointPatchVectorField,
00207     angularOscillatingVelocityPointPatchVectorField
00208 );
00209 
00210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00211 
00212 } // End namespace Foam
00213 
00214 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines