1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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 3 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 "cylindricalInletVelocityFvPatchVectorField.H"
28 #include "volFields.H"
29 #include "addToRunTimeSelectionTable.H"
30 #include "fvPatchFieldMapper.H"
31 #include "surfaceFields.H"
32 #include "mathematicalConstants.H"
34 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
37 cylindricalInletVelocityFvPatchVectorField::
38 cylindricalInletVelocityFvPatchVectorField
41 const DimensionedField<vector, volMesh>& iF
44 fixedValueFvPatchField<vector>(p, iF),
46 centre_(pTraits<vector>::zero),
47 axis_(pTraits<vector>::zero),
54 cylindricalInletVelocityFvPatchVectorField::
55 cylindricalInletVelocityFvPatchVectorField
57 const cylindricalInletVelocityFvPatchVectorField& ptf,
59 const DimensionedField<vector, volMesh>& iF,
60 const fvPatchFieldMapper& mapper
63 fixedValueFvPatchField<vector>(ptf, p, iF, mapper),
64 axialVelocity_(ptf.axialVelocity_),
68 radialVelocity_(ptf.radialVelocity_)
73 cylindricalInletVelocityFvPatchVectorField::
74 cylindricalInletVelocityFvPatchVectorField
77 const DimensionedField<vector, volMesh>& iF,
78 const dictionary& dict
81 fixedValueFvPatchField<vector>(p, iF, dict),
82 axialVelocity_(readScalar(dict.lookup("axialVelocity"))),
83 centre_(dict.lookup("centre")),
84 axis_(dict.lookup("axis")),
85 rpm_(readScalar(dict.lookup("rpm"))),
86 radialVelocity_(readScalar(dict.lookup("radialVelocity")))
91 cylindricalInletVelocityFvPatchVectorField::
92 cylindricalInletVelocityFvPatchVectorField
94 const cylindricalInletVelocityFvPatchVectorField& ptf
97 fixedValueFvPatchField<vector>(ptf),
98 axialVelocity_(ptf.axialVelocity_),
102 radialVelocity_(ptf.radialVelocity_)
107 cylindricalInletVelocityFvPatchVectorField::
108 cylindricalInletVelocityFvPatchVectorField
110 const cylindricalInletVelocityFvPatchVectorField& ptf,
111 const DimensionedField<vector, volMesh>& iF
114 fixedValueFvPatchField<vector>(ptf, iF),
115 axialVelocity_(ptf.axialVelocity_),
116 centre_(ptf.centre_),
119 radialVelocity_(ptf.radialVelocity_)
123 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
125 void Foam::cylindricalInletVelocityFvPatchVectorField::updateCoeffs()
132 vector hatAxis = axis_/mag(axis_);
134 const vectorField r(patch().Cf() - centre_);
135 tmp<vectorField> d = r - (hatAxis & r)*hatAxis;
137 tmp<vectorField> tangVel =
138 (rpm_*constant::mathematical::pi/30.0)*(hatAxis) ^ d;
140 operator==(tangVel + axis_*axialVelocity_ + radialVelocity_*d);
142 fixedValueFvPatchField<vector>::updateCoeffs();
146 void Foam::cylindricalInletVelocityFvPatchVectorField::write(Ostream& os) const
148 fvPatchField<vector>::write(os);
149 os.writeKeyword("axialVelocity") << axialVelocity_ <<
150 token::END_STATEMENT << nl;
151 os.writeKeyword("centre") << centre_ << token::END_STATEMENT << nl;
152 os.writeKeyword("axis") << axis_ << token::END_STATEMENT << nl;
153 os.writeKeyword("rpm") << rpm_ << token::END_STATEMENT << nl;
154 os.writeKeyword("radialVelocity") << radialVelocity_ <<
155 token::END_STATEMENT << nl;
156 writeEntry("value", os);
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
167 cylindricalInletVelocityFvPatchVectorField
172 // ************************************************************************* //