oscillatingFixedValueFvPatchField.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2014 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::oscillatingFixedValueFvPatchField
26 
27 Group
28  grpGenericBoundaryConditions
29 
30 Description
31  This boundary condition provides an oscillating condition in terms of
32  amplitude and frequency.
33 
34  \f[
35  x_p = (1 + a sin(2 \pi f t))x_{ref} + x_o
36  \f]
37 
38  where
39 
40  \vartable
41  x_p | patch values
42  x_{ref} | patch reference values
43  x_o | patch offset values
44  a | amplitude
45  f | frequency [1/s]
46  t | time [s]
47  \endvartable
48 
49  \heading Patch usage
50 
51  \table
52  Property | Description | Required | Default value
53  refValue | reference value | yes |
54  offset | offset value | no | 0.0
55  amplitude | oscillation amplitude | yes |
56  frequency | oscillation frequency | yes |
57  \endtable
58 
59  Example of the boundary condition specification:
60  \verbatim
61  myPatch
62  {
63  type oscillatingFixedValue;
64  refValue uniform 5.0;
65  offset 0.0;
66  amplitude constant 0.5;
67  frequency constant 10;
68  }
69  \endverbatim
70 
71 Note
72  The amplitude and frequency entries are DataEntry types, able to describe
73  time varying functions. The example above gives the usage for supplying
74  constant values.
75 
76 SeeAlso
77  Foam::DataEntry
78 
79 SourceFiles
80  oscillatingFixedValueFvPatchField.C
81 
82 \*---------------------------------------------------------------------------*/
83 
84 #ifndef oscillatingFixedValueFvPatchField_H
85 #define oscillatingFixedValueFvPatchField_H
86 
87 #include "Random.H"
89 #include "DataEntry.H"
90 
91 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
92 
93 namespace Foam
94 {
95 
96 /*---------------------------------------------------------------------------*\
97  Class oscillatingFixedValueFvPatchField Declaration
98 \*---------------------------------------------------------------------------*/
99 
100 template<class Type>
101 class oscillatingFixedValueFvPatchField
102 :
103  public fixedValueFvPatchField<Type>
104 {
105  // Private data
106 
107  //- Reference value
108  Field<Type> refValue_;
109 
110  //- Offset
111  Type offset_;
112 
113  //- Amplitude
114  autoPtr<DataEntry<scalar> > amplitude_;
115 
116  //- Frequency
117  autoPtr<DataEntry<scalar> > frequency_;
118 
119  //- Current time index
120  label curTimeIndex_;
121 
122 
123  // Private Member Functions
124 
125  //- Return current scale
126  scalar currentScale() const;
127 
128 
129 public:
130 
131  //- Runtime type information
132  TypeName("oscillatingFixedValue");
133 
134 
135  // Constructors
136 
137  //- Construct from patch and internal field
139  (
140  const fvPatch&,
141  const DimensionedField<Type, volMesh>&
142  );
143 
144  //- Construct from patch, internal field and dictionary
146  (
147  const fvPatch&,
148  const DimensionedField<Type, volMesh>&,
149  const dictionary&
150  );
151 
152  //- Construct by mapping given oscillatingFixedValueFvPatchField
153  // onto a new patch
155  (
157  const fvPatch&,
159  const fvPatchFieldMapper&
160  );
161 
162  //- Construct as copy
164  (
166  );
167 
168  //- Construct and return a clone
169  virtual tmp<fvPatchField<Type> > clone() const
170  {
171  return tmp<fvPatchField<Type> >
172  (
174  );
175  }
176 
177  //- Construct as copy setting internal field reference
179  (
182  );
183 
184  //- Construct and return a clone setting internal field reference
185  virtual tmp<fvPatchField<Type> > clone
186  (
188  ) const
189  {
190  return tmp<fvPatchField<Type> >
191  (
193  );
194  }
195 
196 
197  // Member functions
198 
199  // Access
200 
201  //- Return the ref value
202  const Field<Type>& refValue() const
203  {
204  return refValue_;
205  }
206 
207  //- Return reference to the ref value to allow adjustment
208  Field<Type>& refValue()
209  {
210  return refValue_;
211  }
212 
213  //- Return amplitude
214  scalar amplitude() const
215  {
216  return amplitude_;
217  }
219  scalar& amplitude()
220  {
221  return amplitude_;
222  }
223 
224  //- Return frequency
225  scalar frequency() const
226  {
227  return frequency_;
228  }
229 
230  scalar& frequency()
231  {
232  return frequency_;
233  }
234 
236  // Mapping functions
237 
238  //- Map (and resize as needed) from self given a mapping object
239  virtual void autoMap
240  (
241  const fvPatchFieldMapper&
242  );
243 
244  //- Reverse map the given fvPatchField onto this fvPatchField
245  virtual void rmap
246  (
247  const fvPatchField<Type>&,
248  const labelList&
249  );
250 
252  // Evaluation functions
253 
254  //- Update the coefficients associated with the patch field
255  virtual void updateCoeffs();
256 
258  //- Write
259  virtual void write(Ostream&) const;
260 };
261 
262 
263 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
264 
265 } // End namespace Foam
266 
267 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
269 #ifdef NoRepository
271 #endif
272 
273 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
275 #endif
276 
277 // ************************************************************************* //
virtual tmp< fvPatchField< Type > > clone() const
Construct and return a clone.
A class for managing temporary objects.
Definition: PtrList.H:90
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
oscillatingFixedValueFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
List< label > labelList
A List of labels.
Definition: labelList.H:56
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:66
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
This boundary condition provides an oscillating condition in terms of amplitude and frequency...
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:62
TypeName("oscillatingFixedValue")
Runtime type information.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
virtual void rmap(const fvPatchField< Type > &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
const Field< Type > & refValue() const
Return the ref value.
Foam::fvPatchFieldMapper.