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

angularOscillatingDisplacementPointPatchVectorField.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 "angularOscillatingDisplacementPointPatchVectorField.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 angularOscillatingDisplacementPointPatchVectorField::
00040 angularOscillatingDisplacementPointPatchVectorField
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 angularOscillatingDisplacementPointPatchVectorField::
00057 angularOscillatingDisplacementPointPatchVectorField
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 angularOscillatingDisplacementPointPatchVectorField::
00088 angularOscillatingDisplacementPointPatchVectorField
00089 (
00090     const angularOscillatingDisplacementPointPatchVectorField& 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_, mapper)
00103 {}
00104 
00105 
00106 angularOscillatingDisplacementPointPatchVectorField::
00107 angularOscillatingDisplacementPointPatchVectorField
00108 (
00109     const angularOscillatingDisplacementPointPatchVectorField& 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 angularOscillatingDisplacementPointPatchVectorField::autoMap
00126 (
00127     const pointPatchFieldMapper& m
00128 )
00129 {
00130     fixedValuePointPatchField<vector>::autoMap(m);
00131 
00132     p0_.autoMap(m);
00133 }
00134 
00135 
00136 void angularOscillatingDisplacementPointPatchVectorField::rmap
00137 (
00138     const pointPatchField<vector>& ptf,
00139     const labelList& addr
00140 )
00141 {
00142     const angularOscillatingDisplacementPointPatchVectorField& aODptf =
00143         refCast<const angularOscillatingDisplacementPointPatchVectorField>(ptf);
00144 
00145     fixedValuePointPatchField<vector>::rmap(aODptf, addr);
00146 
00147     p0_.rmap(aODptf.p0_, addr);
00148 }
00149 
00150 
00151 void angularOscillatingDisplacementPointPatchVectorField::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 
00161     scalar angle = angle0_ + amplitude_*sin(omega_*t.value());
00162     vector axisHat = axis_/mag(axis_);
00163     vectorField p0Rel = p0_ - origin_;
00164 
00165     vectorField::operator=
00166     (
00167         p0Rel*(cos(angle) - 1)
00168       + (axisHat ^ p0Rel*sin(angle))
00169       + (axisHat & p0Rel)*(1 - cos(angle))*axisHat
00170     );
00171 
00172     fixedValuePointPatchField<vector>::updateCoeffs();
00173 }
00174 
00175 
00176 void angularOscillatingDisplacementPointPatchVectorField::write
00177 (
00178     Ostream& os
00179 ) const
00180 {
00181     pointPatchField<vector>::write(os);
00182     os.writeKeyword("axis")
00183         << axis_ << token::END_STATEMENT << nl;
00184     os.writeKeyword("origin")
00185         << origin_ << token::END_STATEMENT << nl;
00186     os.writeKeyword("angle0")
00187         << angle0_ << token::END_STATEMENT << nl;
00188     os.writeKeyword("amplitude")
00189         << amplitude_ << token::END_STATEMENT << nl;
00190     os.writeKeyword("omega")
00191         << omega_ << token::END_STATEMENT << nl;
00192     p0_.writeEntry("p0", os);
00193     writeEntry("value", os);
00194 }
00195 
00196 
00197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00198 
00199 makePointPatchTypeField
00200 (
00201     pointPatchVectorField,
00202     angularOscillatingDisplacementPointPatchVectorField
00203 );
00204 
00205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00206 
00207 } // End namespace Foam
00208 
00209 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines