1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
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
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
40 const DimensionedField<vector, volMesh>& iF
43 fixedValueFvPatchVectorField(p, iF),
50 Foam::movingRotatingWallVelocityFvPatchVectorField::
51 movingRotatingWallVelocityFvPatchVectorField
54 const DimensionedField<vector, volMesh>& iF,
60 fixedValueFvPatchVectorField(p, iF),
65 if (mag(axis_) < SMALL)
69 "movingRotatingWallVelocityFvPatchVectorField::"
70 "movingRotatingWallVelocityFvPatchVectorField\n"
72 " const fvPatch& p,\n"
73 " const DimensionedField<vector, volMesh>& iF,\n"
74 " const point& centre,\n"
75 " const vector& axis,\n"
78 ) << "Badly defined axis: zero magnitude: " << axis_
79 << " for patch " << patch().name()
87 Foam::movingRotatingWallVelocityFvPatchVectorField::
88 movingRotatingWallVelocityFvPatchVectorField
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)
107 "movingRotatingWallVelocityFvPatchVectorField::"
108 "movingRotatingWallVelocityFvPatchVectorField\n"
110 " const fvPatch& p,\n"
111 " const DimensionedField<vector, volMesh>& iF,\n"
112 " const dictionary& dict\n"
114 ) << "Badly defined axis: zero magnitude: " << axis_
115 << " for patch " << patch().name()
116 << abort(FatalError);
123 Foam::movingRotatingWallVelocityFvPatchVectorField::
124 movingRotatingWallVelocityFvPatchVectorField
126 const movingRotatingWallVelocityFvPatchVectorField& ptf,
128 const DimensionedField<vector, volMesh>& iF,
129 const fvPatchFieldMapper& mapper
132 fixedValueFvPatchVectorField(ptf, p, iF, mapper),
133 centre_(ptf.centre_),
139 Foam::movingRotatingWallVelocityFvPatchVectorField::
140 movingRotatingWallVelocityFvPatchVectorField
142 const movingRotatingWallVelocityFvPatchVectorField& pivpvf
145 fixedValueFvPatchVectorField(pivpvf),
146 centre_(pivpvf.centre_),
152 Foam::movingRotatingWallVelocityFvPatchVectorField::
153 movingRotatingWallVelocityFvPatchVectorField
155 const movingRotatingWallVelocityFvPatchVectorField& pivpvf,
156 const DimensionedField<vector, volMesh>& iF
159 fixedValueFvPatchVectorField(pivpvf, iF),
160 centre_(pivpvf.centre_),
166 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
168 void Foam::movingRotatingWallVelocityFvPatchVectorField::updateCoeffs()
175 const fvPatch& p = patch();
177 const volVectorField& U =
178 db().lookupObject<volVectorField>(dimensionedInternalField().name());
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);
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
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215 movingRotatingWallVelocityFvPatchVectorField
217 } // End namespace Foam
219 // ************************************************************************* //