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

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