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-2024 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  const autoPtr<Function1<Type>> amplitude_;
98 
99  //- Frequency of the sine function
100  const scalar frequency_;
101 
102  //- Argument offset
103  const scalar start_;
104 
105  //- Level to which the sine function is added
106  const autoPtr<Function1<Type>> level_;
107 
108  //- Is this function integrable?
109  const bool integrable_;
110 
111 
112 public:
113 
114  // Runtime type information
115  TypeName("sine");
116 
117 
118  // Constructors
119 
120  //- Construct from name and dictionary
121  Sine
122  (
123  const word& name,
124  const unitConversions& units,
125  const dictionary& dict
126  );
127 
128  //- Copy constructor
129  Sine(const Sine<Type>& se);
130 
131 
132  //- Destructor
133  virtual ~Sine();
134 
135 
136  // Member Functions
137 
138  //- Return value
139  virtual inline Type value(const scalar x) const;
140 
141  //- Integrate between two values
142  virtual inline Type integral(const scalar x1, const scalar x2) const;
143 
144  //- Write data to dictionary stream
145  virtual void write(Ostream& os, const unitConversions& units) const;
146 
147 
148  // Member Operators
149 
150  //- Disallow default bitwise assignment
151  void operator=(const Sine<Type>&) = delete;
152 };
153 
154 
155 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
156 
157 } // End namespace Function1s
158 } // End namespace Foam
159 
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 
162 #include "SineI.H"
163 
164 #ifdef NoRepository
165  #include "Sine.C"
166 #endif
167 
168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 
170 #endif
171 
172 // ************************************************************************* //
const word & name() const
Return the name of the entry.
Definition: Function1.C:78
Templated sine function with support for an offset level.
Definition: Sine.H:122
virtual ~Sine()
Destructor.
Definition: Sine.C:62
void operator=(const Sine< Type > &)=delete
Disallow default bitwise assignment.
virtual Type integral(const scalar x1, const scalar x2) const
Integrate between two values.
Definition: SineI.H:42
virtual void write(Ostream &os, const unitConversions &units) const
Write data to dictionary stream.
Definition: Sine.C:70
Sine(const word &name, const unitConversions &units, const dictionary &dict)
Construct from name and dictionary.
Definition: Sine.C:32
virtual Type value(const scalar x) const
Return value.
Definition: SineI.H:32
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
const HashTable< unitConversion > & units()
Get the table of unit conversions.
dictionary dict