cylindricalInletVelocityFvPatchVectorField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
29 #include "volFields.H"
31 #include "fvPatchFieldMapper.H"
32 #include "surfaceFields.H"
33 #include "unitConversion.H"
34 
35 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
36 
39 (
40  const fvPatch& p,
42 )
43 :
45  origin_(Zero),
46  axis_(Zero),
47  axialVelocity_(),
48  radialVelocity_(),
49  rpm_()
50 {}
51 
52 
55 (
57  const fvPatch& p,
59  const fvPatchFieldMapper& mapper
60 )
61 :
62  fixedValueFvPatchField<vector>(ptf, p, iF, mapper),
63  origin_(ptf.origin_),
64  axis_(ptf.axis_),
65  axialVelocity_(ptf.axialVelocity_.clone()),
66  radialVelocity_(ptf.radialVelocity_.clone()),
67  rpm_(ptf.rpm_.clone())
68 {}
69 
70 
73 (
74  const fvPatch& p,
76  const dictionary& dict
77 )
78 :
80  origin_(dict.getCompat<vector>("origin", {{"centre", 1712}})),
81  axis_(dict.lookup("axis")),
82  axialVelocity_(Function1<scalar>::New("axialVelocity", dict)),
83  radialVelocity_(Function1<scalar>::New("radialVelocity", dict)),
84  rpm_(Function1<scalar>::New("rpm", dict))
85 {}
86 
87 
90 (
92 )
93 :
95  origin_(ptf.origin_),
96  axis_(ptf.axis_),
97  axialVelocity_(ptf.axialVelocity_.clone()),
98  radialVelocity_(ptf.radialVelocity_.clone()),
99  rpm_(ptf.rpm_.clone())
100 {}
101 
102 
105 (
108 )
109 :
111  origin_(ptf.origin_),
112  axis_(ptf.axis_),
113  axialVelocity_(ptf.axialVelocity_.clone()),
114  radialVelocity_(ptf.radialVelocity_.clone()),
115  rpm_(ptf.rpm_.clone())
116 {}
117 
118 
119 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
120 
122 {
123  if (updated())
124  {
125  return;
126  }
127 
128  const scalar t = this->db().time().timeOutputValue();
129  const scalar axialVelocity = axialVelocity_->value(t);
130  const scalar radialVelocity = radialVelocity_->value(t);
131  const scalar omega = rpmToRads(rpm_->value(t));
132 
133  const vector axisHat = axis_/mag(axis_);
134 
135  const vectorField r(patch().Cf() - origin_);
136  const vectorField d(r - (axisHat & r)*axisHat);
137 
138  tmp<vectorField> tangVel
139  (
140  (omega * axisHat) ^ d
141  );
142 
143  operator==(tangVel + axisHat*axialVelocity + radialVelocity*d/mag(d));
144 
146 }
147 
148 
150 {
152  os.writeEntry("origin", origin_);
153  os.writeEntry("axis", axis_);
154  axialVelocity_->writeData(os);
155  radialVelocity_->writeData(os);
156  rpm_->writeData(os);
157  writeEntry("value", os);
158 }
159 
160 
161 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
162 
163 namespace Foam
164 {
166  (
169  );
170 }
171 
172 
173 // ************************************************************************* //
Foam::fvPatchField< vector >
volFields.H
Foam::fvPatchField::write
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:364
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
unitConversion.H
Unit conversion functions.
surfaceFields.H
Foam::surfaceFields.
fvPatchFieldMapper.H
cylindricalInletVelocityFvPatchVectorField.H
Foam::Function1
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: Function1.H:86
Foam::fixedValueFvPatchField
This boundary condition supplies a fixed value constraint, and is the base class for a number of othe...
Definition: fixedValueFvPatchField.H:80
Foam::Field< vector >
Foam::operator==
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
Foam::cylindricalInletVelocityFvPatchVectorField::cylindricalInletVelocityFvPatchVectorField
cylindricalInletVelocityFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &)
Construct from patch and internal field.
Definition: cylindricalInletVelocityFvPatchVectorField.C:39
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::cylindricalInletVelocityFvPatchVectorField
This boundary condition describes an inlet vector boundary condition in cylindrical coordinates given...
Definition: cylindricalInletVelocityFvPatchVectorField.H:117
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::fvPatchField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: fvPatchField.C:313
Foam::rpmToRads
constexpr scalar rpmToRads(const scalar rpm) noexcept
Conversion from revolutions/minute to radians/sec.
Definition: unitConversion.H:73
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::Vector< scalar >
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::Ostream::writeEntry
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:232
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:47
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::makePatchTypeField
makePatchTypeField(fvPatchScalarField, atmBoundaryLayerInletEpsilonFvPatchScalarField)
Foam::cylindricalInletVelocityFvPatchVectorField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: cylindricalInletVelocityFvPatchVectorField.C:121
Foam::cylindricalInletVelocityFvPatchVectorField::write
virtual void write(Ostream &) const
Write.
Definition: cylindricalInletVelocityFvPatchVectorField.C:149
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54