rotatingWallVelocityFvPatchVectorField.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) 2011-2021 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 #include "volFields.H"
29 #include "surfaceFields.H"
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
35 (
36  const fvPatch& p,
38 )
39 :
41  origin_(),
42  axis_(Zero),
43  omega_(0)
44 {}
45 
46 
49 (
50  const fvPatch& p,
52  const dictionary& dict
53 )
54 :
56  origin_(dict.lookup("origin")),
57  axis_(dict.lookup("axis")),
58  omega_(Function1<scalar>::New("omega", dict))
59 {
60  if (dict.found("value"))
61  {
63  (
64  vectorField("value", dict, p.size())
65  );
66  }
67  else
68  {
69  // Evaluate the wall velocity
70  updateCoeffs();
71  }
72 }
73 
74 
77 (
79  const fvPatch& p,
81  const fvPatchFieldMapper& mapper
82 )
83 :
84  fixedValueFvPatchField<vector>(ptf, p, iF, mapper),
85  origin_(ptf.origin_),
86  axis_(ptf.axis_),
87  omega_(ptf.omega_, false)
88 {}
89 
90 
93 (
96 )
97 :
99  origin_(rwvpvf.origin_),
100  axis_(rwvpvf.axis_),
101  omega_(rwvpvf.omega_, false)
102 {}
103 
104 
105 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
106 
108 {
109  if (updated())
110  {
111  return;
112  }
113 
114  const scalar t = this->db().time().userTimeValue();
115  scalar om = omega_->value(t);
116 
117  // Calculate the rotating wall velocity from the specification of the motion
118  const vectorField Up
119  (
120  (-om)*((patch().Cf() - origin_) ^ (axis_/mag(axis_)))
121  );
122 
123  // Remove the component of Up normal to the wall
124  // just in case it is not exactly circular
125  const vectorField n(patch().nf());
126  vectorField::operator=(Up - n*(n & Up));
127 
128  fixedValueFvPatchVectorField::updateCoeffs();
129 }
130 
131 
133 {
135  writeEntry(os, "origin", origin_);
136  writeEntry(os, "axis", axis_);
137  writeEntry(os, omega_());
138  writeEntry(os, "value", *this);
139 }
140 
141 
142 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
143 
144 namespace Foam
145 {
147  (
150  );
151 }
152 
153 // ************************************************************************* //
Foam::surfaceFields.
Run-time selectable general function of one variable.
Definition: Function1.H:52
This boundary condition supplies a fixed value constraint, and is the base class for a number of othe...
dictionary dict
rotatingWallVelocityFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &)
Construct from patch and internal field.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:63
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:66
volVectorField vectorField(fieldObject, mesh)
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:243
Macros for easy insertion into run-time selection tables.
Condition on velocity for a boundary consisting of a rotating solid of revolution, e.g. cylinder. Calculates a tangential component of velocity from the angular velocity and rotational axis and ensures a zero normal component.
Foam::fvPatchFieldMapper.
static const zero Zero
Definition: zero.H:97
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
void operator=(const Field< vector > &)
Definition: Field.C:526
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
dimensioned< scalar > mag(const dimensioned< Type > &)
label n
volScalarField & p
makePatchTypeField(fvPatchScalarField, atmBoundaryLayerInletEpsilonFvPatchScalarField)
Namespace for OpenFOAM.