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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2016-2017 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::Function1Types::Sine
28 
29 Description
30  Templated sine function with support for an offset level.
31 
32  \f[
33  a sin(2 \pi f (t - t_0)) s + l
34  \f]
35 
36  where
37 
38  \vartable
39  symbol | Description | Data type
40  a | Amplitude | Function1<scalar>
41  f | Frequency [1/s] | Function1<scalar>
42  s | Type scale factor | Function1<Type>
43  l | Type offset level | Function1<Type>
44  t_0 | Start time [s] | scalar
45  t | Time [s] | scalar
46  \endvartable
47 
48  Example for a scalar:
49  \verbatim
50  <entryName> sine;
51  <entryName>Coeffs
52  {
53  frequency 10;
54  amplitude 0.1;
55  scale 2e-6;
56  level 2e-6;
57  }
58  \endverbatim
59 
60  Example for a vector:
61  \verbatim
62  <entryName> sine;
63  <entryName>Coeffs
64  {
65  frequency 10;
66  amplitude 1;
67  scale (1 0.1 0);
68  level (10 1 0);
69  }
70  \endverbatim
71 
72 SourceFiles
73  Sine.C
74 
75 \*---------------------------------------------------------------------------*/
76 
77 #ifndef Sine_H
78 #define Sine_H
79 
80 #include "Function1.H"
81 
82 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
83 
84 namespace Foam
85 {
86 namespace Function1Types
87 {
88 
89 /*---------------------------------------------------------------------------*\
90  Class Sine Declaration
91 \*---------------------------------------------------------------------------*/
92 
93 template<class Type>
94 class Sine
95 :
96  public Function1<Type>
97 {
98  // Private data
99 
100  //- Start-time for the sin function
101  scalar t0_;
102 
103  //- Scalar amplitude of the sin function
104  autoPtr<Function1<scalar>> amplitude_;
105 
106  //- Frequency of the sin function
107  autoPtr<Function1<scalar>> frequency_;
108 
109  //- Scaling factor of the sin function
110  autoPtr<Function1<Type>> scale_;
111 
112  //- Level to which the sin function is added
113  autoPtr<Function1<Type>> level_;
114 
115 
116  // Private Member Functions
117 
118  //- Read the coefficients from the given dictionary
119  void read(const dictionary& coeffs);
120 
121  //- No copy assignment
122  void operator=(const Sine<Type>&) = delete;
123 
124 
125 public:
126 
127  // Runtime type information
128  TypeName("sine");
129 
130 
131  // Constructors
132 
133  //- Construct from entry name and dictionary
134  Sine
135  (
136  const word& entryName,
137  const dictionary& dict
138  );
139 
140  //- Copy constructor
141  explicit Sine(const Sine<Type>& se);
142 
143 
144  //- Destructor
145  virtual ~Sine() = default;
146 
147 
148  // Member Functions
149 
150  //- Return value for time t
151  virtual inline Type value(const scalar t) const;
152 
153  //- Write in dictionary format
154  virtual void writeData(Ostream& os) const;
155 };
156 
157 
158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
159 
160 } // End namespace Function1Types
161 } // End namespace Foam
162 
163 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
164 
165 #include "SineI.H"
166 
167 #ifdef NoRepository
168  #include "Sine.C"
169 #endif
170 
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 
173 #endif
174 
175 // ************************************************************************* //
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::Function1::dictionary
dictionary
Definition: Function1.H:123
Sine.C
Foam::Function1::entryName
const word & entryName
Definition: Function1.H:125
Foam::Function1Types::Sine::Sine
Sine(const word &entryName, const dictionary &dict)
Construct from entry name and dictionary.
Definition: Sine.C:46
Function1.H
Foam::Function1Types::Sine
Templated sine function with support for an offset level.
Definition: Sine.H:128
Foam::Function1::dict
const word const dictionary & dict
Definition: Function1.H:127
Foam::Function1
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: Function1.H:86
SineI.H
Foam::Function1Types::Sine::~Sine
virtual ~Sine()=default
Destructor.
Foam::Function1Types::Sine::value
virtual Type value(const scalar t) const
Return value for time t.
Definition: SineI.H:34
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::Function1Types::Sine::TypeName
TypeName("sine")
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::Function1Types::Sine::writeData
virtual void writeData(Ostream &os) const
Write in dictionary format.
Definition: Sine.C:72