varyingVelocityInletOutletFvPatchVectorField.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2 
3  DAFoam : Discrete Adjoint with OpenFOAM
4  Version : v4
5 
6  This file is modified from OpenFOAM's source code
7  src/finiteVolume/fields/fvPatchFields/derived/inletOutlet
8 
9  OpenFOAM: The Open Source CFD Toolbox
10 
11  Copyright (C): 2011-2016 OpenFOAM Foundation
12 
13  OpenFOAM License:
14 
15  OpenFOAM is free software: you can redistribute it and/or modify it
16  under the terms of the GNU General Public License as published by
17  the Free Software Foundation, either version 3 of the License, or
18  (at your option) any later version.
19 
20  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
21  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
22  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23  for more details.
24 
25  You should have received a copy of the GNU General Public License
26  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
27 
28  Description:
29 
30  This boundary condition provides a varying velocity for the patch
31 
32  U[flowComponent] = U * cos(alpha)
33  U[normalComponent] = U * sin(alpha)
34  alpha = alpha0 + alphaRate * t
35  U = U0 + URate * t
36 
37  where
38 
39  flowComponent : velocity component parallel to the flow. Options are: 0, 1, or 2, which corresponds to x, y, and z
40  normalComponent : velocity component normal to the flow. Options are: 0, 1, or 2, which corresponds to x, y, and z
41  U0 : initial velocity magnitude [m/s]
42  URate : rate of change for the velocity magnitude
43  alpha0 : initial flow angle [rad]
44  alphaRate : rate of change for the flow angle [rad/s]
45 
46  Example of the boundary condition specification:
47  myPatch
48  {
49  type varyingVelocityInletOutlet;
50  U0 10;
51  URate -0.2;
52  flowComponent 0;
53  normalComponent 1;
54  alpha0 0;
55  alphaRate 0.1;
56  }
57 
58  This will change the flow direction with a rate of 0.1 rad/s starting from 0 rad
59  U[0] = (10-0.2*t)*cos(0+0.1*t)
60  U[1] = (10-0.2*t)*sin(0+0.1*t)
61 
62 \*---------------------------------------------------------------------------*/
63 
64 #ifndef varyingVelocityInletOutletFvPatchVectorField_H
65 #define varyingVelocityInletOutletFvPatchVectorField_H
66 
67 #include "mixedFvPatchField.H"
68 #include "volFields.H"
69 #include "surfaceFields.H"
70 #include "addToRunTimeSelectionTable.H"
71 #include "fieldTypes.H"
72 
73 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
74 
75 namespace Foam
76 {
77 
78 /*---------------------------------------------------------------------------*\
79  Class varyingVelocityInletOutletFvPatchVectorField Declaration
80 \*---------------------------------------------------------------------------*/
81 
83  : public mixedFvPatchField<vector>
84 {
85  // Private data
86 
87  //- Name of flux field
88  word phiName_;
89 
90  scalar U0_;
91  scalar URate_;
92  label flowComponent_;
93  label normalComponent_;
94  scalar alpha0_;
95  scalar alphaRate_;
96 
97 public:
98  //- Runtime type information
99  TypeName("varyingVelocityInletOutlet");
100 
101  // Constructors
102 
103  //- Construct from patch and internal field
105  const fvPatch&,
106  const DimensionedField<vector, volMesh>&);
107 
108  //- Construct from patch, internal field and dictionary
110  const fvPatch&,
111  const DimensionedField<vector, volMesh>&,
112  const dictionary&);
113 
114  //- Construct by mapping given
115  // varyingVelocityInletOutletFvPatchVectorField onto a new patch
118  const fvPatch&,
119  const DimensionedField<vector, volMesh>&,
120  const fvPatchFieldMapper&);
121 
122  //- Construct as copy
125 
126  //- Construct and return a clone
127  virtual tmp<fvPatchVectorField> clone() const
128  {
129  return tmp<fvPatchVectorField>(
131  }
132 
133  //- Construct as copy setting internal field reference
136  const DimensionedField<vector, volMesh>&);
137 
138  //- Construct and return a clone setting internal field reference
139  virtual tmp<fvPatchVectorField> clone(
140  const DimensionedField<vector, volMesh>& iF) const
141  {
142  return tmp<fvPatchVectorField>(
144  }
145 
146  // Member functions
147 
148  // Access
149 
150  // Evaluation functions
151 
152  //- Return true: this patch field is altered by assignment
153  virtual bool assignable() const
154  {
155  return true;
156  }
157 
158  //- Update the coefficients associated with the patch field
159  virtual void updateCoeffs();
160 
161  //- Write
162  virtual void write(Ostream&) const;
163 
164  virtual void operator=(const fvPatchVectorField& pvf);
165 };
166 
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168 
169 } // End namespace Foam
170 
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 
173 #endif
174 
175 // ************************************************************************* //
Foam::varyingVelocityInletOutletFvPatchVectorField::operator=
virtual void operator=(const fvPatchVectorField &pvf)
Definition: varyingVelocityInletOutletFvPatchVectorField.C:178
Foam::varyingVelocityInletOutletFvPatchVectorField::write
virtual void write(Ostream &) const
Definition: varyingVelocityInletOutletFvPatchVectorField.C:162
Foam::varyingVelocityInletOutletFvPatchVectorField::TypeName
TypeName("varyingVelocityInletOutlet")
Foam::varyingVelocityInletOutletFvPatchVectorField::varyingVelocityInletOutletFvPatchVectorField
varyingVelocityInletOutletFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &)
Definition: varyingVelocityInletOutletFvPatchVectorField.C:31
Foam::varyingVelocityInletOutletFvPatchVectorField
Definition: varyingVelocityInletOutletFvPatchVectorField.H:82
Foam::varyingVelocityInletOutletFvPatchVectorField::clone
virtual tmp< fvPatchVectorField > clone(const DimensionedField< vector, volMesh > &iF) const
Definition: varyingVelocityInletOutletFvPatchVectorField.H:139
Foam
Definition: checkGeometry.C:32
Foam::varyingVelocityInletOutletFvPatchVectorField::assignable
virtual bool assignable() const
Definition: varyingVelocityInletOutletFvPatchVectorField.H:153
Foam::varyingVelocityInletOutletFvPatchVectorField::clone
virtual tmp< fvPatchVectorField > clone() const
Definition: varyingVelocityInletOutletFvPatchVectorField.H:127
Foam::varyingVelocityInletOutletFvPatchVectorField::updateCoeffs
virtual void updateCoeffs()
Definition: varyingVelocityInletOutletFvPatchVectorField.C:137