Fix tutorials: coupled/conjugateHeatFoam/conjugateCavity: fix Allrun file
[OpenFOAM-1.6-ext.git] / src / finiteVolume / fields / fvPatchFields / derived / movingRotatingWallVelocity / movingRotatingWallVelocityFvPatchVectorField.C
blobdea609d9441b139b2ce9955fcd1ca75a8e044c36
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
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 "movingRotatingWallVelocityFvPatchVectorField.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "volFields.H"
30 #include "surfaceFields.H"
31 #include "fvcMeshPhi.H"
32 #include "mathematicalConstants.H"
34 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
36 Foam::movingRotatingWallVelocityFvPatchVectorField::
37 movingRotatingWallVelocityFvPatchVectorField
39     const fvPatch& p,
40     const DimensionedField<vector, volMesh>& iF
43     fixedValueFvPatchVectorField(p, iF),
44     centre_(0, 0, 0),
45     axis_(1, 0, 0),
46     rpm_(0)
50 Foam::movingRotatingWallVelocityFvPatchVectorField::
51 movingRotatingWallVelocityFvPatchVectorField
53     const fvPatch& p,
54     const DimensionedField<vector, volMesh>& iF,
55     const point& centre,
56     const vector& axis,
57     const scalar rpm
60     fixedValueFvPatchVectorField(p, iF),
61     centre_(centre),
62     axis_(axis),
63     rpm_(rpm)
65     if (mag(axis_) < SMALL)
66     {
67         FatalErrorIn
68         (
69             "movingRotatingWallVelocityFvPatchVectorField::"
70             "movingRotatingWallVelocityFvPatchVectorField\n"
71             "(\n"
72             "    const fvPatch& p,\n"
73             "    const DimensionedField<vector, volMesh>& iF,\n"
74             "    const point& centre,\n"
75             "    const vector& axis,\n"
76             "    const scalar rpm\n"
77             ")"
78         )   << "Badly defined axis: zero magnitude: " << axis_
79             << " for patch " << patch().name()
80             << abort(FatalError);
81     }
83     axis_ /= mag(axis_);
87 Foam::movingRotatingWallVelocityFvPatchVectorField::
88 movingRotatingWallVelocityFvPatchVectorField
90     const fvPatch& p,
91     const DimensionedField<vector, volMesh>& iF,
92     const dictionary& dict
95     fixedValueFvPatchVectorField(p, iF),
96     centre_(dict.lookup("centre")),
97     axis_(dict.lookup("axis")),
98     rpm_(readScalar(dict.lookup("rpm")))
101     fvPatchVectorField::operator=(vectorField("value", dict, p.size()));
103     if (mag(axis_) < SMALL)
104     {
105         FatalErrorIn
106         (
107             "movingRotatingWallVelocityFvPatchVectorField::"
108             "movingRotatingWallVelocityFvPatchVectorField\n"
109             "(\n"
110             "    const fvPatch& p,\n"
111             "    const DimensionedField<vector, volMesh>& iF,\n"
112             "    const dictionary& dict\n"
113             ")"
114         )   << "Badly defined axis: zero magnitude: " << axis_
115             << " for patch " << patch().name()
116             << abort(FatalError);
117     }
119     axis_ /= mag(axis_);
123 Foam::movingRotatingWallVelocityFvPatchVectorField::
124 movingRotatingWallVelocityFvPatchVectorField
126     const movingRotatingWallVelocityFvPatchVectorField& ptf,
127     const fvPatch& p,
128     const DimensionedField<vector, volMesh>& iF,
129     const fvPatchFieldMapper& mapper
132     fixedValueFvPatchVectorField(ptf, p, iF, mapper),
133     centre_(ptf.centre_),
134     axis_(ptf.axis_),
135     rpm_(ptf.rpm_)
139 Foam::movingRotatingWallVelocityFvPatchVectorField::
140 movingRotatingWallVelocityFvPatchVectorField
142     const movingRotatingWallVelocityFvPatchVectorField& pivpvf
145     fixedValueFvPatchVectorField(pivpvf),
146     centre_(pivpvf.centre_),
147     axis_(pivpvf.axis_),
148     rpm_(pivpvf.rpm_)
152 Foam::movingRotatingWallVelocityFvPatchVectorField::
153 movingRotatingWallVelocityFvPatchVectorField
155     const movingRotatingWallVelocityFvPatchVectorField& pivpvf,
156     const DimensionedField<vector, volMesh>& iF
159     fixedValueFvPatchVectorField(pivpvf, iF),
160     centre_(pivpvf.centre_),
161     axis_(pivpvf.axis_),
162     rpm_(pivpvf.rpm_)
166 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
168 void Foam::movingRotatingWallVelocityFvPatchVectorField::updateCoeffs()
170     if (updated())
171     {
172         return;
173     }
175     const fvPatch& p = patch();
177     const volVectorField& U =
178         db().lookupObject<volVectorField>(dimensionedInternalField().name());
179     scalarField phip = 
180         p.patchField<surfaceScalarField, scalar>(fvc::meshPhi(U));
182     vectorField n = p.nf();
183     const scalarField& magSf = p.magSf();
184     scalarField Un = phip/(magSf + VSMALL);
186     vectorField Urot =
187         (axis_ ^ (patch().Cf() - centre_))*rpm_*2*mathematicalConstant::pi/60;
189     vectorField::operator=(Urot + n*(Un - (n & Urot)));
191     fixedValueFvPatchVectorField::updateCoeffs();
195 void Foam::movingRotatingWallVelocityFvPatchVectorField::write
197     Ostream& os
198 ) const
200     fvPatchVectorField::write(os);
201     os.writeKeyword("centre") << centre_ << token::END_STATEMENT << nl;
202     os.writeKeyword("axis") << axis_ << token::END_STATEMENT << endl;
203     os.writeKeyword("rpm") << rpm_ << token::END_STATEMENT << endl;
204     writeEntry("value", os);
208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
210 namespace Foam
212     makePatchTypeField
213     (
214         fvPatchVectorField,
215         movingRotatingWallVelocityFvPatchVectorField
216     );
217 } // End namespace Foam
219 // ************************************************************************* //