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

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