Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / src / finiteVolume / fields / fvPatchFields / derived / movingWallVelocity / movingWallVelocityFvPatchVectorField.C
blob7980cd3305be30e2d6a5895bbe347126b221b3a9
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2004-2010 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
13     the Free Software Foundation, either version 3 of the License, or
14     (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "movingWallVelocityFvPatchVectorField.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "volFields.H"
29 #include "surfaceFields.H"
30 #include "fvcMeshPhi.H"
33 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
35 Foam::movingWallVelocityFvPatchVectorField::
36 movingWallVelocityFvPatchVectorField
38     const fvPatch& p,
39     const DimensionedField<vector, volMesh>& iF
42     fixedValueFvPatchVectorField(p, iF),
43     UName_("U")
47 Foam::movingWallVelocityFvPatchVectorField::
48 movingWallVelocityFvPatchVectorField
50     const movingWallVelocityFvPatchVectorField& ptf,
51     const fvPatch& p,
52     const DimensionedField<vector, volMesh>& iF,
53     const fvPatchFieldMapper& mapper
56     fixedValueFvPatchVectorField(ptf, p, iF, mapper),
57     UName_(ptf.UName_)
61 Foam::movingWallVelocityFvPatchVectorField::
62 movingWallVelocityFvPatchVectorField
64     const fvPatch& p,
65     const DimensionedField<vector, volMesh>& iF,
66     const dictionary& dict
69     fixedValueFvPatchVectorField(p, iF),
70     UName_(dict.lookupOrDefault<word>("U", "U"))
72     fvPatchVectorField::operator=(vectorField("value", dict, p.size()));
76 Foam::movingWallVelocityFvPatchVectorField::
77 movingWallVelocityFvPatchVectorField
79     const movingWallVelocityFvPatchVectorField& mwvpvf
82     fixedValueFvPatchVectorField(mwvpvf),
83     UName_(mwvpvf.UName_)
87 Foam::movingWallVelocityFvPatchVectorField::
88 movingWallVelocityFvPatchVectorField
90     const movingWallVelocityFvPatchVectorField& mwvpvf,
91     const DimensionedField<vector, volMesh>& iF
94     fixedValueFvPatchVectorField(mwvpvf, iF),
95     UName_(mwvpvf.UName_)
99 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
101 void Foam::movingWallVelocityFvPatchVectorField::updateCoeffs()
103     if (updated())
104     {
105         return;
106     }
108     const fvPatch& p = patch();
109     const polyPatch& pp = p.patch();
110     const fvMesh& mesh = dimensionedInternalField().mesh();
111     const pointField& oldPoints = mesh.oldPoints();
113     vectorField oldFc(pp.size());
115     forAll(oldFc, i)
116     {
117         oldFc[i] = pp[i].centre(oldPoints);
118     }
120     const vectorField Up((pp.faceCentres() - oldFc)/mesh.time().deltaTValue());
122     const volVectorField& U = db().lookupObject<volVectorField>(UName_);
123     scalarField phip
124     (
125         p.patchField<surfaceScalarField, scalar>(fvc::meshPhi(U))
126     );
128     const vectorField n(p.nf());
129     const scalarField& magSf = p.magSf();
130     tmp<scalarField> Un = phip/(magSf + VSMALL);
133     vectorField::operator=(Up + n*(Un - (n & Up)));
135     fixedValueFvPatchVectorField::updateCoeffs();
139 void Foam::movingWallVelocityFvPatchVectorField::write(Ostream& os) const
141     fvPatchVectorField::write(os);
142     writeEntryIfDifferent<word>(os, "U", "U", UName_);
143     writeEntry("value", os);
147 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
149 namespace Foam
151     makePatchTypeField
152     (
153         fvPatchVectorField,
154         movingWallVelocityFvPatchVectorField
155     );
158 // ************************************************************************* //