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

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-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 "angularOscillatingDisplacementPointPatchVectorField.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 angularOscillatingDisplacementPointPatchVectorField::
00041 angularOscillatingDisplacementPointPatchVectorField
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 angularOscillatingDisplacementPointPatchVectorField::
00058 angularOscillatingDisplacementPointPatchVectorField
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 angularOscillatingDisplacementPointPatchVectorField::
00089 angularOscillatingDisplacementPointPatchVectorField
00090 (
00091     const angularOscillatingDisplacementPointPatchVectorField& 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 angularOscillatingDisplacementPointPatchVectorField::
00108 angularOscillatingDisplacementPointPatchVectorField
00109 (
00110     const angularOscillatingDisplacementPointPatchVectorField& 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 angularOscillatingDisplacementPointPatchVectorField::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 
00136     scalar angle = angle0_ + amplitude_*sin(omega_*t.value());
00137     vector axisHat = axis_/mag(axis_);
00138     vectorField p0Rel = p0_ - origin_;
00139 
00140     vectorField::operator=
00141     (
00142         p0Rel*(cos(angle) - 1)
00143       + (axisHat ^ p0Rel*sin(angle))
00144       + (axisHat & p0Rel)*(1 - cos(angle))*axisHat
00145     );
00146 
00147     fixedValuePointPatchField<vector>::updateCoeffs();
00148 }
00149 
00150 
00151 void angularOscillatingDisplacementPointPatchVectorField::write
00152 (
00153     Ostream& os
00154 ) const
00155 {
00156     pointPatchField<vector>::write(os);
00157     os.writeKeyword("axis")
00158         << axis_ << token::END_STATEMENT << nl;
00159     os.writeKeyword("origin")
00160         << origin_ << token::END_STATEMENT << nl;
00161     os.writeKeyword("angle0")
00162         << angle0_ << token::END_STATEMENT << nl;
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     angularOscillatingDisplacementPointPatchVectorField
00178 );
00179 
00180 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00181 
00182 } // End namespace Foam
00183 
00184 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd