Sine.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) 2016-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::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  );
137 
138  //- Copy constructor
139  Sine(const Sine<Type>& se);
140 
141 
142  //- Destructor
143  virtual ~Sine();
144 
145 
146  // Member Functions
147 
148  //- Return value for time t
149  virtual inline Type value(const scalar t) const;
150 
151  //- Write in dictionary format
152  virtual void writeData(Ostream& os) const;
153 };
154 
155 
156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157 
158 } // End namespace Function1Types
159 } // End namespace Foam
160 
161 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
162 
163 #include "SineI.H"
164 
165 #ifdef NoRepository
166  #include "Sine.C"
167 #endif
168 
169 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170 
171 #endif
172 
173 // ************************************************************************* //
const word const dictionary & dict
Definition: Function1.H:90
Sine(const word &entryName, const dictionary &dict)
Construct from entry name and dictionary.
Definition: Sine.C:43
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:69
virtual Type value(const scalar t) const
Return value for time t.
Definition: SineI.H:32
const word & entryName
Definition: Function1.H:90
Templated sine function with support for an offset level.
Definition: Sine.H:126
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 void writeData(Ostream &os) const
Write in dictionary format.
Definition: Sine.C:76
Namespace for OpenFOAM.