1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "movingRotatingWallVelocityFvPatchVectorField.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "volFields.H"
29 #include "surfaceFields.H"
30 #include "fvcMeshPhi.H"
31 #include "mathematicalConstants.H"
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
35 Foam::movingRotatingWallVelocityFvPatchVectorField::
36 movingRotatingWallVelocityFvPatchVectorField
39 const DimensionedField<vector, volMesh>& iF
42 fixedValueFvPatchVectorField(p, iF),
49 Foam::movingRotatingWallVelocityFvPatchVectorField::
50 movingRotatingWallVelocityFvPatchVectorField
53 const DimensionedField<vector, volMesh>& iF,
59 fixedValueFvPatchVectorField(p, iF),
64 if (mag(axis_) < SMALL)
68 "movingRotatingWallVelocityFvPatchVectorField::"
69 "movingRotatingWallVelocityFvPatchVectorField\n"
71 " const fvPatch& p,\n"
72 " const DimensionedField<vector, volMesh>& iF,\n"
73 " const point& centre,\n"
74 " const vector& axis,\n"
77 ) << "Badly defined axis: zero magnitude: " << axis_
78 << " for patch " << patch().name()
86 Foam::movingRotatingWallVelocityFvPatchVectorField::
87 movingRotatingWallVelocityFvPatchVectorField
90 const DimensionedField<vector, volMesh>& iF,
91 const dictionary& dict
94 fixedValueFvPatchVectorField(p, iF),
95 centre_(dict.lookup("centre")),
96 axis_(dict.lookup("axis")),
97 rpm_(readScalar(dict.lookup("rpm")))
100 fvPatchVectorField::operator=(vectorField("value", dict, p.size()));
102 if (mag(axis_) < SMALL)
106 "movingRotatingWallVelocityFvPatchVectorField::"
107 "movingRotatingWallVelocityFvPatchVectorField\n"
109 " const fvPatch& p,\n"
110 " const DimensionedField<vector, volMesh>& iF,\n"
111 " const dictionary& dict\n"
113 ) << "Badly defined axis: zero magnitude: " << axis_
114 << " for patch " << patch().name()
115 << abort(FatalError);
122 Foam::movingRotatingWallVelocityFvPatchVectorField::
123 movingRotatingWallVelocityFvPatchVectorField
125 const movingRotatingWallVelocityFvPatchVectorField& ptf,
127 const DimensionedField<vector, volMesh>& iF,
128 const fvPatchFieldMapper& mapper
131 fixedValueFvPatchVectorField(ptf, p, iF, mapper),
132 centre_(ptf.centre_),
138 Foam::movingRotatingWallVelocityFvPatchVectorField::
139 movingRotatingWallVelocityFvPatchVectorField
141 const movingRotatingWallVelocityFvPatchVectorField& pivpvf
144 fixedValueFvPatchVectorField(pivpvf),
145 centre_(pivpvf.centre_),
151 Foam::movingRotatingWallVelocityFvPatchVectorField::
152 movingRotatingWallVelocityFvPatchVectorField
154 const movingRotatingWallVelocityFvPatchVectorField& pivpvf,
155 const DimensionedField<vector, volMesh>& iF
158 fixedValueFvPatchVectorField(pivpvf, iF),
159 centre_(pivpvf.centre_),
165 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
167 void Foam::movingRotatingWallVelocityFvPatchVectorField::updateCoeffs()
174 const fvPatch& p = patch();
176 const volVectorField& U =
177 db().lookupObject<volVectorField>(dimensionedInternalField().name());
179 p.patchField<surfaceScalarField, scalar>(fvc::meshPhi(U));
181 vectorField n = p.nf();
182 const scalarField& magSf = p.magSf();
183 scalarField Un = phip/(magSf + VSMALL);
186 (axis_ ^ (patch().Cf() - centre_))*rpm_*2*mathematicalConstant::pi/60;
188 vectorField::operator=(Urot + n*(Un - (n & Urot)));
190 fixedValueFvPatchVectorField::updateCoeffs();
194 void Foam::movingRotatingWallVelocityFvPatchVectorField::write
199 fvPatchVectorField::write(os);
200 os.writeKeyword("centre") << centre_ << token::END_STATEMENT << nl;
201 os.writeKeyword("axis") << axis_ << token::END_STATEMENT << endl;
202 os.writeKeyword("rpm") << rpm_ << token::END_STATEMENT << endl;
203 writeEntry("value", os);
207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 movingRotatingWallVelocityFvPatchVectorField
216 } // End namespace Foam
218 // ************************************************************************* //