Sine.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) 2016 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::Function1Types::Sine
26 
27 Description
28  Templated sine function with support for an offset level.
29 
30  \f[
31  a sin(2 \pi f (t - t_0)) s + l
32  \f]
33 
34  where
35 
36  \vartable
37  symbol | Description | Data type
38  a | Amplitude | Function1<scalar>
39  f | Frequency [1/s] | Function1<scalar>
40  s | Type scale factor | Function1<Type>
41  l | Type offset level | Function1<Type>
42  t_0 | Start time [s] | scalar
43  t | Time [s] | scalar
44  \endvartable
45 
46  Example for a scalar:
47  \verbatim
48  <entryName> sine;
49  <entryName>Coeffs
50  {
51  frequency 10;
52  amplitude 0.1;
53  scale 2e-6;
54  level 2e-6;
55  }
56  \endverbatim
57 
58  Example for a vector:
59  \verbatim
60  <entryName> sine;
61  <entryName>Coeffs
62  {
63  frequency 10;
64  amplitude 1;
65  scale (1 0.1 0);
66  level (10 1 0);
67  }
68  \endverbatim
69 
70 SourceFiles
71  Sine.C
72 
73 \*---------------------------------------------------------------------------*/
74 
75 #ifndef Sine_H
76 #define Sine_H
77 
78 #include "Function1.H"
79 
80 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
81 
82 namespace Foam
83 {
84 namespace Function1Types
85 {
86 
87 /*---------------------------------------------------------------------------*\
88  Class Sine Declaration
89 \*---------------------------------------------------------------------------*/
90 
91 template<class Type>
92 class Sine
93 :
94  public Function1<Type>
95 {
96  // Private data
97 
98  //- Start-time for the sin function
99  scalar t0_;
100 
101  //- Scalar amplitude of the sin function
102  autoPtr<Function1<scalar>> amplitude_;
103 
104  //- Frequency of the sin function
105  autoPtr<Function1<scalar>> frequency_;
106 
107  //- Scaling factor of the sin function
108  autoPtr<Function1<Type>> scale_;
109 
110  //- Level to which the sin function is added
111  autoPtr<Function1<Type>> level_;
112 
113 
114  // Private Member Functions
115 
116  //- Read the coefficients from the given dictionary
117  void read(const dictionary& coeffs);
118 
119  //- Disallow default bitwise assignment
120  void operator=(const Sine<Type>&);
121 
122 
123 public:
124 
125  // Runtime type information
126  TypeName("sine");
127 
128 
129  // Constructors
130 
131  //- Construct from entry name and dictionary
132  Sine
133  (
134  const word& entryName,
135  const dictionary& dict,
136  const word& ext = "Coeffs"
137  );
138 
139  //- Copy constructor
140  Sine(const Sine<Type>& se);
141 
142  //- Construct and return a clone
143  virtual tmp<Function1<Type>> clone() const
144  {
145  return tmp<Function1<Type>>(new Sine<Type>(*this));
146  }
147 
148 
149  //- Destructor
150  virtual ~Sine();
151 
152 
153  // Member Functions
154 
155  //- Return value for time t
156  Type value(const scalar t) const;
157 
158  //- Write in dictionary format
159  virtual void writeData(Ostream& os) const;
160 };
161 
162 
163 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
164 
165 } // End namespace Function1Types
166 } // End namespace Foam
167 
168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 
170 #ifdef NoRepository
171  #include "Sine.C"
172 #endif
173 
174 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
175 
176 #endif
178 // ************************************************************************* //
const word const dictionary & dict
Definition: Function1.H:88
Sine(const word &entryName, const dictionary &dict, const word &ext="Coeffs")
Construct from entry name and dictionary.
Definition: Sine.C:44
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
virtual ~Sine()
Destructor.
Definition: Sine.C:71
const word & entryName
Definition: Function1.H:88
Templated sine function with support for an offset level.
Definition: Sine.H:126
Type value(const scalar t) const
Return value for time t.
Definition: Sine.C:78
A class for handling words, derived from string.
Definition: word.H:59
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
virtual tmp< Function1< Type > > clone() const
Construct and return a clone.
Definition: Sine.H:177
virtual void writeData(Ostream &os) const
Write in dictionary format.
Definition: Sine.C:89
A class for managing temporary objects.
Definition: PtrList.H:54
Namespace for OpenFOAM.