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  Copyright (C) 2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
30 #include "volFields.H"
32 #include "fvPatchFieldMapper.H"
33 #include "surfaceFields.H"
34 #include "unitConversion.H"
35 
36 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
37 
40 (
41  const fvPatch& p,
43 )
44 :
46  origin_(Zero),
47  axis_(Zero),
48  axialVelocity_(),
49  radialVelocity_(),
50  rpm_()
51 {}
52 
53 
56 (
58  const fvPatch& p,
60  const fvPatchFieldMapper& mapper
61 )
62 :
63  fixedValueFvPatchField<vector>(ptf, p, iF, mapper),
64  origin_(ptf.origin_),
65  axis_(ptf.axis_),
66  axialVelocity_(ptf.axialVelocity_.clone()),
67  radialVelocity_(ptf.radialVelocity_.clone()),
68  rpm_(ptf.rpm_.clone())
69 {}
70 
71 
74 (
75  const fvPatch& p,
77  const dictionary& dict
78 )
79 :
81  origin_(dict.getCompat<vector>("origin", {{"centre", 1712}})),
82  axis_(dict.lookup("axis")),
83  axialVelocity_(Function1<scalar>::New("axialVelocity", dict, &db())),
84  radialVelocity_
85  (
86  Function1<scalar>::New("radialVelocity", dict, &db())
87  ),
88  rpm_(Function1<scalar>::New("rpm", dict, &db()))
89 {}
90 
91 
94 (
96 )
97 :
99  origin_(ptf.origin_),
100  axis_(ptf.axis_),
101  axialVelocity_(ptf.axialVelocity_.clone()),
102  radialVelocity_(ptf.radialVelocity_.clone()),
103  rpm_(ptf.rpm_.clone())
104 {}
105 
106 
109 (
112 )
113 :
115  origin_(ptf.origin_),
116  axis_(ptf.axis_),
117  axialVelocity_(ptf.axialVelocity_.clone()),
118  radialVelocity_(ptf.radialVelocity_.clone()),
119  rpm_(ptf.rpm_.clone())
120 {}
121 
122 
123 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
124 
126 {
127  if (updated())
128  {
129  return;
130  }
131 
132  const scalar t = this->db().time().timeOutputValue();
133  const scalar axialVelocity = axialVelocity_->value(t);
134  const scalar radialVelocity = radialVelocity_->value(t);
135  const scalar omega = rpmToRads(rpm_->value(t));
136 
137  const vector axisHat = axis_/mag(axis_);
138 
139  const vectorField r(patch().Cf() - origin_);
140  const vectorField d(r - (axisHat & r)*axisHat);
141 
142  tmp<vectorField> tangVel
143  (
144  (omega * axisHat) ^ d
145  );
146 
147  operator==(tangVel + axisHat*axialVelocity + radialVelocity*d/mag(d));
148 
150 }
151 
152 
154 {
156  os.writeEntry("origin", origin_);
157  os.writeEntry("axis", axis_);
158  axialVelocity_->writeData(os);
159  radialVelocity_->writeData(os);
160  rpm_->writeData(os);
161  writeEntry("value", os);
162 }
163 
164 
165 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
166 
167 namespace Foam
168 {
170  (
173  );
174 }
175 
176 
177 // ************************************************************************* //
Foam::fvPatchField< vector >
volFields.H
Foam::fvPatchField::write
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:384
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: propellerInfo.H:291
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:40
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:123
Foam::cylindricalInletVelocityFvPatchVectorField
This boundary condition describes an inlet vector boundary condition in cylindrical coordinates given...
Definition: cylindricalInletVelocityFvPatchVectorField.H:117
os
OBJstream os(runTime.globalPath()/outputName)
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:321
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:236
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:125
Foam::cylindricalInletVelocityFvPatchVectorField::write
virtual void write(Ostream &) const
Write.
Definition: cylindricalInletVelocityFvPatchVectorField.C:153
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54