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