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

movingWallVelocityFvPatchVectorField.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 "movingWallVelocityFvPatchVectorField.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 #include "volFields.H"
00030 #include "surfaceFields.H"
00031 #include "fvcMeshPhi.H"
00032 
00033 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00034 
00035 namespace Foam
00036 {
00037 
00038 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00039 
00040 movingWallVelocityFvPatchVectorField::movingWallVelocityFvPatchVectorField
00041 (
00042     const fvPatch& p,
00043     const DimensionedField<vector, volMesh>& iF
00044 )
00045 :
00046     fixedValueFvPatchVectorField(p, iF)
00047 {}
00048 
00049 
00050 movingWallVelocityFvPatchVectorField::movingWallVelocityFvPatchVectorField
00051 (
00052     const movingWallVelocityFvPatchVectorField& ptf,
00053     const fvPatch& p,
00054     const DimensionedField<vector, volMesh>& iF,
00055     const fvPatchFieldMapper& mapper
00056 )
00057 :
00058     fixedValueFvPatchVectorField(ptf, p, iF, mapper)
00059 {}
00060 
00061 
00062 movingWallVelocityFvPatchVectorField::movingWallVelocityFvPatchVectorField
00063 (
00064     const fvPatch& p,
00065     const DimensionedField<vector, volMesh>& iF,
00066     const dictionary& dict
00067 )
00068 :
00069     fixedValueFvPatchVectorField(p, iF)
00070 {
00071     fvPatchVectorField::operator=(vectorField("value", dict, p.size()));
00072 }
00073 
00074 
00075 movingWallVelocityFvPatchVectorField::movingWallVelocityFvPatchVectorField
00076 (
00077     const movingWallVelocityFvPatchVectorField& pivpvf
00078 )
00079 :
00080     fixedValueFvPatchVectorField(pivpvf)
00081 {}
00082 
00083 
00084 movingWallVelocityFvPatchVectorField::movingWallVelocityFvPatchVectorField
00085 (
00086     const movingWallVelocityFvPatchVectorField& pivpvf,
00087     const DimensionedField<vector, volMesh>& iF
00088 )
00089 :
00090     fixedValueFvPatchVectorField(pivpvf, iF)
00091 {}
00092 
00093 
00094 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00095 
00096 void movingWallVelocityFvPatchVectorField::updateCoeffs()
00097 {
00098     if (updated())
00099     {
00100         return;
00101     }
00102 
00103     const fvPatch& p = patch();
00104     const polyPatch& pp = p.patch();
00105     const fvMesh& mesh = dimensionedInternalField().mesh();
00106     const pointField& oldPoints = mesh.oldPoints();
00107 
00108     vectorField oldFc(pp.size());
00109 
00110     forAll(oldFc, i)
00111     {
00112         oldFc[i] = pp[i].centre(oldPoints);
00113     }
00114 
00115     vectorField Up = (pp.faceCentres() - oldFc)/mesh.time().deltaT().value();
00116 
00117     const volVectorField& U = db().lookupObject<volVectorField>("U");
00118     scalarField phip =
00119         p.patchField<surfaceScalarField, scalar>(fvc::meshPhi(U));
00120 
00121     vectorField n = p.nf();
00122     const scalarField& magSf = p.magSf();
00123     scalarField Un = phip/(magSf + VSMALL);
00124 
00125 
00126     vectorField::operator=(Up + n*(Un - (n & Up)));
00127 
00128     fixedValueFvPatchVectorField::updateCoeffs();
00129 }
00130 
00131 
00132 void movingWallVelocityFvPatchVectorField::write(Ostream& os) const
00133 {
00134     fvPatchVectorField::write(os);
00135     writeEntry("value", os);
00136 }
00137 
00138 
00139 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00140 
00141 makePatchTypeField
00142 (
00143     fvPatchVectorField,
00144     movingWallVelocityFvPatchVectorField
00145 );
00146 
00147 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00148 
00149 } // End namespace Foam
00150 
00151 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd