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

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