waveVelocityFvPatchVectorField.H
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-2018 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 Class
25  Foam::waveVelocityFvPatchVectorField
26 
27 Description
28  This boundary condition provides a waveVelocity condition. This sets the
29  velocity to that specified by a superposition of wave models. The
30  corresponding phase fraction and pressure conditions look this condition up
31  and re-use the wave modelling.
32 
33  Flow reversal will occur in the event that the amplitude of the velocity
34  oscillation is greater than the mean flow. This triggers special handling,
35  the form of which depends on the inletOutlet flag and whether a wave
36  pressure condition is being used.
37 
38  If a wave pressure condition is not being used, and inletOutlet is false,
39  then this is a standard fixed value condition, with the value supplied by
40  the wave model. If flow reversal occurs this state may be unstable. The
41  corresponding pressure condition should be fixedFluxPressure.
42 
43  If a wave pressure condition is not being used, and inletOutlet is true or
44  not specified then the proportion of the patch over which the flow is
45  reversed functions in a manner similar to the flowRateOutletVelocity
46  condition; i.e., the velocity is extrapolated and then scaled to match the
47  required outlet flow rate. Numerically, this is still a fixedValue
48  constraint on the normal velocity, just one which tends to avoid
49  instability. Again, the corresponding pressure condition should be
50  fixedFluxPressure.
51 
52  If a wave pressure condition is being used, then the normal velocity
53  condition becomes fixedGradient on outlet faces. This gradient is
54  calculated numerically by evaluating the wave model on both the patch face
55  and the adjacent cell. The pressure boundary in this case should be a
56  wavePressure condition. This will do the opposite; it will fix the pressure
57  value on outlet faces, and the gradient otherwise.
58 
59 Usage
60  \table
61  Property | Description | Req'd? | Default
62  phi | Name of the flux field | no | phi
63  p | Name of the pressure field | no | p
64  inletOutlet | does the condition behave like inletOutlet | no | true
65  origin | origin of the wave coordinate system | yes |
66  direction | direction of the mean flow | yes |
67  speed | speed of the mean flow | yes |
68  waves | list of wave models to superimpose | yes |
69  ramp | ramping function for the mean flow speed | no | None
70  scale | scale factor along the mean flow direction | no | None
71  crossScale | scale factor across the mean flow direction | no | None
72  heightAboveWave | use with the height above the wave | no | false
73  \endtable
74 
75  Example of the boundary condition specification:
76  \verbatim
77  <patchName>
78  {
79  type waveVelocity;
80  origin (0 25 0);
81  direction (1 0 0);
82  speed 2;
83  waves
84  (
85  Airy
86  {
87  length 40;
88  amplitude 0.5;
89  phase 0;
90  angle 0;
91  }
92  Airy
93  {
94  length 20;
95  amplitude 0.25;
96  phase 1.5708;
97  angle 0;
98  }
99  );
100  ramp constant 1;
101  scale table ((100 1) (200 0));
102  crossScale constant 1;
103  }
104  \endverbatim
105 
106 SourceFiles
107  waveVelocityFvPatchVectorField.C
108 
109 \*---------------------------------------------------------------------------*/
110 
111 #ifndef waveVelocityFvPatchVectorField_H
112 #define waveVelocityFvPatchVectorField_H
113 
115 #include "waveSuperposition.H"
116 
117 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
118 
119 namespace Foam
120 {
121 
122 class fvMeshSubset;
123 
124 /*---------------------------------------------------------------------------*\
125  Class waveVelocityFvPatchVectorField Declaration
126 \*---------------------------------------------------------------------------*/
127 
128 class waveVelocityFvPatchVectorField
129 :
130  public directionMixedFvPatchVectorField
131 {
132  // Private data
133 
134  //- Name of the flux field
135  const word phiName_;
136 
137  //- Name of the pressure field
138  const word pName_;
139 
140  //- Act as an inlet/outlet patch?
141  const Switch inletOutlet_;
142 
143  //- Wave superposition
144  const waveSuperposition waves_;
145 
146  //- Mesh subset corresponding to the patch adjacent cells
147  mutable autoPtr<fvMeshSubset> faceCellSubset_;
148 
149  //- Time index for keeping the subset up to date
150  mutable label faceCellSubsetTimeIndex_;
151 
152 
153 public:
154 
155  //- Runtime type information
156  TypeName("waveVelocity");
157 
158 
159  // Constructors
160 
161  //- Construct from patch and internal field
163  (
164  const fvPatch&,
165  const DimensionedField<vector, volMesh>&
166  );
167 
168  //- Construct from patch, internal field and dictionary
170  (
171  const fvPatch&,
172  const DimensionedField<vector, volMesh>&,
173  const dictionary&
174  );
175 
176  //- Construct by mapping given mixedTypeFvPatchField onto a new patch
178  (
180  const fvPatch&,
181  const DimensionedField<vector, volMesh>&,
182  const fvPatchFieldMapper&
183  );
184 
185  //- Construct as copy
187  (
189  );
190 
191  //- Construct and return a clone
192  virtual tmp<fvPatchVectorField> clone() const
193  {
195  (
197  );
198  }
199 
200  //- Construct as copy setting internal field reference
202  (
205  );
206 
207  //- Construct and return a clone setting internal field reference
209  (
211  ) const
212  {
214  (
215  new waveVelocityFvPatchVectorField(*this, iF)
216  );
217  }
218 
219 
220  // Member functions
221 
222  // Access
223 
224  //- Access the name of the pressure field
225  const word& pName() const
226  {
227  return pName_;
228  }
229 
230  //- Access the wave models
231  const waveSuperposition& waves() const
232  {
233  return waves_;
234  }
235 
236  //- Access the face-cell subset
237  const fvMeshSubset& faceCellSubset() const;
238 
239 
240  // Evaluation functions
241 
242  //- Return the current modelled velocity field on the patch faces
243  tmp<vectorField> U() const;
244 
245  //- Return the current modelled velocity field in the neighbour cell
246  tmp<vectorField> Un() const;
247 
248  //- Update the coefficients associated with the patch field
249  virtual void updateCoeffs();
250 
252  //- Write
253  virtual void write(Ostream&) const;
254 };
255 
256 
257 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
258 
259 } // End namespace Foam
260 
261 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
262 
263 
264 #endif
265 
266 // ************************************************************************* //
A wrapper around a list of wave models. Superimposes the modelled values of elevation and velocity...
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
waveVelocityFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &)
Construct from patch and internal field.
const fvMeshSubset & faceCellSubset() const
Access the face-cell subset.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
virtual void write(Ostream &) const
Write.
virtual tmp< fvPatchVectorField > clone() const
Construct and return a clone.
const word & pName() const
Access the name of the pressure field.
A class for handling words, derived from string.
Definition: word.H:59
TypeName("waveVelocity")
Runtime type information.
This boundary condition provides a waveVelocity condition. This sets the velocity to that specified b...
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
Post-processing mesh subset tool. Given the original mesh and the list of selected cells...
Definition: fvMeshSubset.H:73
tmp< vectorField > Un() const
Return the current modelled velocity field in the neighbour cell.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const waveSuperposition & waves() const
Access the wave models.
A class for managing temporary objects.
Definition: PtrList.H:53
Namespace for OpenFOAM.
tmp< vectorField > U() const
Return the current modelled velocity field on the patch faces.