Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / src / finiteVolume / fields / fvPatchFields / derived / movingRotatingWallVelocity / movingRotatingWallVelocityFvPatchVectorField.C
blob62941036d29ba1d1eca996870b90c72ad25b8835
1 /*---------------------------------------------------------------------------*\
2   =========                 |
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 -------------------------------------------------------------------------------
8 License
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
38     const fvPatch& p,
39     const DimensionedField<vector, volMesh>& iF
42     fixedValueFvPatchVectorField(p, iF),
43     centre_(0, 0, 0),
44     axis_(1, 0, 0),
45     rpm_(0)
49 Foam::movingRotatingWallVelocityFvPatchVectorField::
50 movingRotatingWallVelocityFvPatchVectorField
52     const fvPatch& p,
53     const DimensionedField<vector, volMesh>& iF,
54     const point& centre,
55     const vector& axis,
56     const scalar rpm
59     fixedValueFvPatchVectorField(p, iF),
60     centre_(centre),
61     axis_(axis),
62     rpm_(rpm)
64     if (mag(axis_) < SMALL)
65     {
66         FatalErrorIn
67         (
68             "movingRotatingWallVelocityFvPatchVectorField::"
69             "movingRotatingWallVelocityFvPatchVectorField\n"
70             "(\n"
71             "    const fvPatch& p,\n"
72             "    const DimensionedField<vector, volMesh>& iF,\n"
73             "    const point& centre,\n"
74             "    const vector& axis,\n"
75             "    const scalar rpm\n"
76             ")"
77         )   << "Badly defined axis: zero magnitude: " << axis_
78             << " for patch " << patch().name()
79             << abort(FatalError);
80     }
82     axis_ /= mag(axis_);
86 Foam::movingRotatingWallVelocityFvPatchVectorField::
87 movingRotatingWallVelocityFvPatchVectorField
89     const fvPatch& p,
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)
103     {
104         FatalErrorIn
105         (
106             "movingRotatingWallVelocityFvPatchVectorField::"
107             "movingRotatingWallVelocityFvPatchVectorField\n"
108             "(\n"
109             "    const fvPatch& p,\n"
110             "    const DimensionedField<vector, volMesh>& iF,\n"
111             "    const dictionary& dict\n"
112             ")"
113         )   << "Badly defined axis: zero magnitude: " << axis_
114             << " for patch " << patch().name()
115             << abort(FatalError);
116     }
118     axis_ /= mag(axis_);
122 Foam::movingRotatingWallVelocityFvPatchVectorField::
123 movingRotatingWallVelocityFvPatchVectorField
125     const movingRotatingWallVelocityFvPatchVectorField& ptf,
126     const fvPatch& p,
127     const DimensionedField<vector, volMesh>& iF,
128     const fvPatchFieldMapper& mapper
131     fixedValueFvPatchVectorField(ptf, p, iF, mapper),
132     centre_(ptf.centre_),
133     axis_(ptf.axis_),
134     rpm_(ptf.rpm_)
138 Foam::movingRotatingWallVelocityFvPatchVectorField::
139 movingRotatingWallVelocityFvPatchVectorField
141     const movingRotatingWallVelocityFvPatchVectorField& pivpvf
144     fixedValueFvPatchVectorField(pivpvf),
145     centre_(pivpvf.centre_),
146     axis_(pivpvf.axis_),
147     rpm_(pivpvf.rpm_)
151 Foam::movingRotatingWallVelocityFvPatchVectorField::
152 movingRotatingWallVelocityFvPatchVectorField
154     const movingRotatingWallVelocityFvPatchVectorField& pivpvf,
155     const DimensionedField<vector, volMesh>& iF
158     fixedValueFvPatchVectorField(pivpvf, iF),
159     centre_(pivpvf.centre_),
160     axis_(pivpvf.axis_),
161     rpm_(pivpvf.rpm_)
165 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
167 void Foam::movingRotatingWallVelocityFvPatchVectorField::updateCoeffs()
169     if (updated())
170     {
171         return;
172     }
174     const fvPatch& p = patch();
176     const volVectorField& U =
177         db().lookupObject<volVectorField>(dimensionedInternalField().name());
178     scalarField phip =
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);
185     vectorField Urot =
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
196     Ostream& os
197 ) const
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
209 namespace Foam
211     makePatchTypeField
212     (
213         fvPatchVectorField,
214         movingRotatingWallVelocityFvPatchVectorField
215     );
216 } // End namespace Foam
218 // ************************************************************************* //