swirlInletVelocityFvPatchVectorField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2017-2024 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
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
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
33 (
34  const fvPatch& p,
36  const dictionary& dict
37 )
38 :
39  fixedValueFvPatchField<vector>(p, iF, dict, false),
40  origin_
41  (
42  dict.lookupOrDefault
43  (
44  "origin",
45  dimLength,
46  returnReduce(patch().size(), sumOp<label>())
47  ? gSum(patch().Cf()*patch().magSf())/gSum(patch().magSf())
48  : Zero
49  )
50  ),
51  axis_
52  (
53  dict.lookupOrDefault
54  (
55  "axis",
56  dimless,
57  returnReduce(patch().size(), sumOp<label>())
58  ? -gSum(patch().Sf())/gSum(patch().magSf())
59  : Zero
60  )
61  ),
62  axialVelocity_
63  (
64  Function2<scalar>::New
65  (
66  "axialVelocity",
67  db().time().userUnits(),
68  dimLength,
70  dict
71  )
72  ),
73  radialVelocity_
74  (
75  Function2<scalar>::New
76  (
77  "radialVelocity",
78  db().time().userUnits(),
79  dimLength,
81  dict
82  )
83  ),
84  omega_(nullptr),
85  tangentialVelocity_(nullptr)
86 {
87  if (dict.found("omega") || dict.found("rpm"))
88  {
89  omega_ = new Function1s::omega(db().time(), dict);
90  }
91  else if (dict.found("tangentialVelocity"))
92  {
93  tangentialVelocity_ =
95  (
96  "tangentialVelocity",
97  db().time().userUnits(),
98  dimLength,
100  dict
101  );
102  }
103  else
104  {
106  << "Please supply either 'omega' or 'rpm' or"
107  << " 'tangentialVelocity'" << exit(FatalIOError);
108  }
109 
110  if (dict.found("value"))
111  {
113  (
114  vectorField("value", iF.dimensions(), dict, p.size())
115  );
116  }
117  else
118  {
120  }
121 }
122 
123 
126 (
128  const fvPatch& p,
130  const fieldMapper& mapper
131 )
132 :
133  fixedValueFvPatchField<vector>(ptf, p, iF, mapper),
134  origin_(ptf.origin_),
135  axis_(ptf.axis_),
136  axialVelocity_(ptf.axialVelocity_, false),
137  radialVelocity_(ptf.radialVelocity_, false),
138  omega_(ptf.omega_, false),
139  tangentialVelocity_(ptf.tangentialVelocity_, false)
140 {}
141 
142 
145 (
148 )
149 :
150  fixedValueFvPatchField<vector>(ptf, iF),
151  origin_(ptf.origin_),
152  axis_(ptf.axis_),
153  axialVelocity_(ptf.axialVelocity_, false),
154  radialVelocity_(ptf.radialVelocity_, false),
155  omega_(ptf.omega_, false),
156  tangentialVelocity_(ptf.tangentialVelocity_, false)
157 {}
158 
159 
160 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
161 
163 {
164  if (updated())
165  {
166  return;
167  }
168 
169  const scalar t = this->db().time().value();
170  const scalarField ts(size(), t);
171 
172  // Compute geometry
173  const vector axisHat = normalised(axis_);
174  const vectorField d(patch().Cf() - origin_);
175  const vectorField r(d - (axisHat & d)*axisHat);
176  const scalarField magR(mag(r));
177  const vectorField rHat(normalised(r));
178 
179  // Evaluate individual velocity components
180  const scalarField axialVelocity(axialVelocity_->value(ts, magR));
181  const scalarField radialVelocity(radialVelocity_->value(ts, magR));
182  tmp<scalarField> tangentialVelocity;
183  if (omega_.valid())
184  {
185  tangentialVelocity = omega_->value(t)*magR;
186  }
187  else
188  {
189  tangentialVelocity = tangentialVelocity_->value(ts, magR);
190  }
191 
192  // Combine components the complete vector velocity
193  operator==
194  (
195  axialVelocity*axisHat
196  + radialVelocity*rHat
197  + tangentialVelocity*(axisHat ^ rHat)
198  );
199 
201 }
202 
203 
205 {
207  writeEntry(os, "origin", origin_);
208  writeEntry(os, "axis", axis_);
209  writeEntry
210  (
211  os,
212  db().time().userUnits(),
213  dimLength,
214  dimVelocity,
215  axialVelocity_()
216  );
217  writeEntry
218  (
219  os,
220  db().time().userUnits(),
221  dimLength,
222  dimVelocity,
223  radialVelocity_()
224  );
225  if (omega_.valid())
226  {
227  writeEntry(os, omega_());
228  }
229  else
230  {
231  writeEntry
232  (
233  os,
234  db().time().userUnits(),
235  dimLength,
236  dimVelocity,
237  tangentialVelocity_()
238  );
239  }
240  writeEntry(os, "value", *this);
241 }
242 
243 
244 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
245 
246 namespace Foam
247 {
249  (
252  );
253 }
254 
255 
256 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const dimensionSet & dimensions() const
Return dimensions.
Run-time selectable function of two variables.
Definition: Function2.H:98
static autoPtr< Function2< Type > > New(const word &name, const Function2s::unitConversions &units, const dictionary &dict)
Select from dictionary.
Definition: Function2New.C:32
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Abstract base class for field mapping.
Definition: fieldMapper.H:48
This boundary condition supplies a fixed value constraint, and is the base class for a number of othe...
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:88
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:229
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: fvPatchField.C:202
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:64
Velocity inlet boundary condition creating axial, radial and tangential velocity fields specified by ...
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
swirlInletVelocityFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &, const dictionary &)
Construct from patch, internal field and dictionary.
A class for managing temporary objects.
Definition: tmp.H:55
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:346
const scalar omega
autoPtr< CompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const viscosity &viscosity)
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
static const zero Zero
Definition: zero.H:97
Type gSum(const FieldField< Field, Type > &f)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
const dimensionSet dimless
const dimensionSet dimLength
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
dimensionSet normalised(const dimensionSet &)
Definition: dimensionSet.C:510
dimensioned< scalar > mag(const dimensioned< Type > &)
Field< vector > vectorField
Specialisation of Field<T> for vector.
IOerror FatalIOError
const dimensionSet dimVelocity
void evaluate(GeometricField< Type, PatchField, GeoMesh > &result, const Function1< Type > &func, const GeometricField< Type, PatchField, GeoMesh > &x)
makePatchTypeField(fvPatchScalarField, atmBoundaryLayerInletEpsilonFvPatchScalarField)
dictionary dict
volScalarField & p