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

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-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 "oscillatingVelocityPointPatchVectorField.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 oscillatingVelocityPointPatchVectorField::
00041 oscillatingVelocityPointPatchVectorField
00042 (
00043     const pointPatch& p,
00044     const DimensionedField<vector, pointMesh>& iF
00045 )
00046 :
00047     fixedValuePointPatchField<vector>(p, iF),
00048     amplitude_(vector::zero),
00049     omega_(0.0),
00050     p0_(p.localPoints())
00051 {}
00052 
00053 
00054 oscillatingVelocityPointPatchVectorField::
00055 oscillatingVelocityPointPatchVectorField
00056 (
00057     const pointPatch& p,
00058     const DimensionedField<vector, pointMesh>& iF,
00059     const dictionary& dict
00060 )
00061 :
00062     fixedValuePointPatchField<vector>(p, iF, dict),
00063     amplitude_(dict.lookup("amplitude")),
00064     omega_(readScalar(dict.lookup("omega")))
00065 {
00066     if (!dict.found("value"))
00067     {
00068         updateCoeffs();
00069     }
00070 
00071     if (dict.found("p0"))
00072     {
00073         p0_ = vectorField("p0", dict , p.size());
00074     }
00075     else
00076     {
00077         p0_ = p.localPoints();
00078     }
00079 }
00080 
00081 
00082 oscillatingVelocityPointPatchVectorField::
00083 oscillatingVelocityPointPatchVectorField
00084 (
00085     const oscillatingVelocityPointPatchVectorField& ptf,
00086     const pointPatch& p,
00087     const DimensionedField<vector, pointMesh>& iF,
00088     const pointPatchFieldMapper& mapper
00089 )
00090 :
00091     fixedValuePointPatchField<vector>(ptf, p, iF, mapper),
00092     amplitude_(ptf.amplitude_),
00093     omega_(ptf.omega_),
00094     p0_(ptf.p0_)
00095 {}
00096 
00097 
00098 oscillatingVelocityPointPatchVectorField::
00099 oscillatingVelocityPointPatchVectorField
00100 (
00101     const oscillatingVelocityPointPatchVectorField& ptf,
00102     const DimensionedField<vector, pointMesh>& iF
00103 )
00104 :
00105     fixedValuePointPatchField<vector>(ptf, iF),
00106     amplitude_(ptf.amplitude_),
00107     omega_(ptf.omega_),
00108     p0_(ptf.p0_)
00109 {}
00110 
00111 
00112 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00113 
00114 void oscillatingVelocityPointPatchVectorField::updateCoeffs()
00115 {
00116     if (this->updated())
00117     {
00118         return;
00119     }
00120 
00121     const polyMesh& mesh = this->dimensionedInternalField().mesh()();
00122     const Time& t = mesh.time();
00123     const pointPatch& p = this->patch();
00124 
00125     Field<vector>::operator=
00126     (
00127         (p0_ + amplitude_*sin(omega_*t.value()) - p.localPoints())
00128        /t.deltaT().value()
00129     );
00130 
00131     fixedValuePointPatchField<vector>::updateCoeffs();
00132 }
00133 
00134 
00135 void oscillatingVelocityPointPatchVectorField::write(Ostream& os) const
00136 {
00137     pointPatchField<vector>::write(os);
00138     os.writeKeyword("amplitude")
00139         << amplitude_ << token::END_STATEMENT << nl;
00140     os.writeKeyword("omega")
00141         << omega_ << token::END_STATEMENT << nl;
00142     p0_.writeEntry("p0", os);
00143     writeEntry("value", os);
00144 }
00145 
00146 
00147 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00148 
00149 makePointPatchTypeField
00150 (
00151     pointPatchVectorField,
00152     oscillatingVelocityPointPatchVectorField
00153 );
00154 
00155 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00156 
00157 } // End namespace Foam
00158 
00159 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd