initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / finiteVolume / fields / fvPatchFields / derived / movingWallVelocity / movingWallVelocityFvPatchVectorField.C
blob17742fe879719fb886780c8a71176803ff1d496d
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software; you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "movingWallVelocityFvPatchVectorField.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "volFields.H"
30 #include "surfaceFields.H"
31 #include "fvcMeshPhi.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 namespace Foam
38 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
40 movingWallVelocityFvPatchVectorField::movingWallVelocityFvPatchVectorField
42     const fvPatch& p,
43     const DimensionedField<vector, volMesh>& iF
46     fixedValueFvPatchVectorField(p, iF)
50 movingWallVelocityFvPatchVectorField::movingWallVelocityFvPatchVectorField
52     const movingWallVelocityFvPatchVectorField& ptf,
53     const fvPatch& p,
54     const DimensionedField<vector, volMesh>& iF,
55     const fvPatchFieldMapper& mapper
58     fixedValueFvPatchVectorField(ptf, p, iF, mapper)
62 movingWallVelocityFvPatchVectorField::movingWallVelocityFvPatchVectorField
64     const fvPatch& p,
65     const DimensionedField<vector, volMesh>& iF,
66     const dictionary& dict
69     fixedValueFvPatchVectorField(p, iF)
71     fvPatchVectorField::operator=(vectorField("value", dict, p.size()));
75 movingWallVelocityFvPatchVectorField::movingWallVelocityFvPatchVectorField
77     const movingWallVelocityFvPatchVectorField& pivpvf
80     fixedValueFvPatchVectorField(pivpvf)
84 movingWallVelocityFvPatchVectorField::movingWallVelocityFvPatchVectorField
86     const movingWallVelocityFvPatchVectorField& pivpvf,
87     const DimensionedField<vector, volMesh>& iF
90     fixedValueFvPatchVectorField(pivpvf, iF)
94 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
96 void movingWallVelocityFvPatchVectorField::updateCoeffs()
98     if (updated())
99     {
100         return;
101     }
103     const fvPatch& p = patch();
104     const polyPatch& pp = p.patch();
105     const fvMesh& mesh = dimensionedInternalField().mesh();
106     const pointField& oldPoints = mesh.oldPoints();
108     vectorField oldFc(pp.size());
110     forAll(oldFc, i)
111     {
112         oldFc[i] = pp[i].centre(oldPoints);
113     }
115     vectorField Up = (pp.faceCentres() - oldFc)/mesh.time().deltaT().value();
117     const volVectorField& U = db().lookupObject<volVectorField>("U");
118     scalarField phip =
119         p.patchField<surfaceScalarField, scalar>(fvc::meshPhi(U));
121     vectorField n = p.nf();
122     const scalarField& magSf = p.magSf();
123     scalarField Un = phip/(magSf + VSMALL);
126     vectorField::operator=(Up + n*(Un - (n & Up)));
128     fixedValueFvPatchVectorField::updateCoeffs();
132 void movingWallVelocityFvPatchVectorField::write(Ostream& os) const
134     fvPatchVectorField::write(os);
135     writeEntry("value", os);
139 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
141 makePatchTypeField
143     fvPatchVectorField,
144     movingWallVelocityFvPatchVectorField
147 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
149 } // End namespace Foam
151 // ************************************************************************* //