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
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&,
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  }
218 
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 
235 
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 
251 
252  // Evaluation functions
253 
254  //- Update the coefficients associated with the patch field
255  virtual void updateCoeffs();
256 
257 
258  //- Write
259  virtual void write(Ostream&) const;
260 };
261 
262 
263 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
264 
265 } // End namespace Foam
266 
267 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
268 
269 #ifdef NoRepository
271 #endif
272 
273 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
274 
275 #endif
276 
277 // ************************************************************************* //
Foam::fvPatchField< Type >
Foam::oscillatingFixedValueFvPatchField::amplitude
scalar & amplitude()
Definition: oscillatingFixedValueFvPatchField.H:267
Foam::oscillatingFixedValueFvPatchField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: oscillatingFixedValueFvPatchField.C:177
oscillatingFixedValueFvPatchField.C
Foam::oscillatingFixedValueFvPatchField::frequency
scalar & frequency()
Definition: oscillatingFixedValueFvPatchField.H:278
Foam::oscillatingFixedValueFvPatchField::refValue
Field< Type > & refValue()
Return reference to the ref value to allow adjustment.
Definition: oscillatingFixedValueFvPatchField.H:256
Foam::oscillatingFixedValueFvPatchField::refValue_
Field< Type > refValue_
Reference value.
Definition: oscillatingFixedValueFvPatchField.H:156
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::fixedValueFvPatchField
This boundary condition supplies a fixed value constraint, and is the base class for a number of othe...
Definition: fixedValueFvPatchField.H:79
Foam::oscillatingFixedValueFvPatchField::amplitude_
autoPtr< DataEntry< scalar > > amplitude_
Amplitude.
Definition: oscillatingFixedValueFvPatchField.H:162
Foam::oscillatingFixedValueFvPatchField::curTimeIndex_
label curTimeIndex_
Current time index.
Definition: oscillatingFixedValueFvPatchField.H:168
Foam::oscillatingFixedValueFvPatchField::clone
virtual tmp< fvPatchField< Type > > clone() const
Construct and return a clone.
Definition: oscillatingFixedValueFvPatchField.H:217
DataEntry.H
Foam::label
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
Foam::Field< Type >
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
Foam::oscillatingFixedValueFvPatchField::refValue
const Field< Type > & refValue() const
Return the ref value.
Definition: oscillatingFixedValueFvPatchField.H:250
Foam::oscillatingFixedValueFvPatchField::autoMap
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: oscillatingFixedValueFvPatchField.C:151
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::oscillatingFixedValueFvPatchField
This boundary condition provides an oscillating condition in terms of amplitude and frequency.
Definition: oscillatingFixedValueFvPatchField.H:149
Random.H
Foam::oscillatingFixedValueFvPatchField::write
virtual void write(Ostream &) const
Write.
Definition: oscillatingFixedValueFvPatchField.C:200
Foam::oscillatingFixedValueFvPatchField::rmap
virtual void rmap(const fvPatchField< Type > &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
Definition: oscillatingFixedValueFvPatchField.C:162
Foam::oscillatingFixedValueFvPatchField::amplitude
scalar amplitude() const
Return amplitude.
Definition: oscillatingFixedValueFvPatchField.H:262
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
Foam::oscillatingFixedValueFvPatchField::offset_
Type offset_
Offset.
Definition: oscillatingFixedValueFvPatchField.H:159
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
fixedValueFvPatchFields.H
Foam::oscillatingFixedValueFvPatchField::currentScale
scalar currentScale() const
Return current scale.
Definition: oscillatingFixedValueFvPatchField.C:37
Foam::oscillatingFixedValueFvPatchField::frequency_
autoPtr< DataEntry< scalar > > frequency_
Frequency.
Definition: oscillatingFixedValueFvPatchField.H:165
Foam::oscillatingFixedValueFvPatchField::frequency
scalar frequency() const
Return frequency.
Definition: oscillatingFixedValueFvPatchField.H:273
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:45
Foam::oscillatingFixedValueFvPatchField::TypeName
TypeName("oscillatingFixedValue")
Runtime type information.
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::oscillatingFixedValueFvPatchField::oscillatingFixedValueFvPatchField
oscillatingFixedValueFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Definition: oscillatingFixedValueFvPatchField.C:51
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:51