Loading...
Searching...
No Matches
Cosine.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) 2020-2024 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::Function1Types::Cosine
28
29Description
30 A templated cosine function, with support for offset etc.
31
32 The wave period can be specified directly
33
34 \f[
35 a cos(2 \pi (t - t0) / p)) s + l
36 \f]
37
38 Or it can be specified by the frequency
39
40 \f[
41 a cos(2 \pi f (t - t0)) s + l
42 \f]
43
44 where
45 \vartable
46 Symbol | Description | Units
47 a | Amplitude | -
48 f | Frequency | [1/s]
49 p | Period | [s]
50 s | Type scale factor | -
51 l | Type offset level | -
52 t | Time | [s]
53 t0 | Start time offset | [s]
54 \endvartable
55
56 The dictionary specification would typically resemble this:
57 \verbatim
58 entry1
59 {
60 type cosine;
61 frequency 10;
62 amplitude 0.1;
63
64 // A scalar Function1
65 scale 2e-6;
66 level 2e-6;
67 }
68 entry2
69 {
70 type cosine;
71 frequency 10;
72
73 // A vector Function1
74 scale (1 0.1 0);
75 level (10 1 0);
76 }
77 \endverbatim
78
79 where the entries mean:
80 \table
81 Property | Description | Type | Reqd | Default
82 type | Function type: cosine | word | yes |
83 amplitude | Amplitude | Function1<scalar> | no | 1
84 frequency | Frequency [1/s] | Function1<scalar> | or period |
85 period | Period [s] | Function1<scalar> | or frequency |
86 scale | Scale factor (Type) | Function1<Type> | yes |
87 level | Offset level (Type) | Function1<Type> | yes |
88 t0 | Start time offset | scalar | no | 0
89 \endtable
90
91Note
92 For slow oscillations it can be more intuitive to specify the period.
93
94SourceFiles
95 Cosine.C
96
97\*---------------------------------------------------------------------------*/
98
99#ifndef Foam_Function1Types_Cosine_H
100#define Foam_Function1Types_Cosine_H
101
102#include "Sine.H"
103
104// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
105
106namespace Foam
107{
108namespace Function1Types
109{
110
111/*---------------------------------------------------------------------------*\
112 Class Cosine Declaration
113\*---------------------------------------------------------------------------*/
114
115template<class Type>
116class Cosine
117:
118 public Function1Types::Sine<Type>
119{
120public:
121
122 // Runtime type information
123 TypeName("cosine");
124
125
126 // Generated Methods
127
128 //- No copy assignment
129 void operator=(const Cosine<Type>&) = delete;
130
131
132 // Constructors
133
134 //- Construct from entry name, dictionary and optional registry
135 Cosine
136 (
137 const word& entryName,
138 const dictionary& dict,
139 const objectRegistry* obrPtr = nullptr
140 )
141 :
142 Sine<Type>(entryName, dict, obrPtr)
143 {}
144
145 //- Copy construct
146 explicit Cosine(const Cosine<Type>& rhs)
147 :
148 Sine<Type>(rhs)
149 {}
150
151 //- Return a clone
152 virtual tmp<Function1<Type>> clone() const
153 {
154 return Function1<Type>::Clone(*this);
155 }
156
157
158 //- Destructor
159 virtual ~Cosine() = default;
160
161
162 // Member Functions
163
164 //- Return value for time t
165 virtual inline Type value(const scalar t) const
166 {
167 return Sine<Type>::cosValue(t);
168 }
169
170 //- Integrate between two (scalar) values
171 virtual Type integrate(const scalar x1, const scalar x2) const
172 {
174 }
175};
176
177
178// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179
180} // End namespace Function1Types
181} // End namespace Foam
182
183// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184
185#endif
186
187// ************************************************************************* //
A templated cosine function, with support for offset etc.
Definition Cosine.H:202
virtual tmp< Function1< Type > > clone() const
Return a clone.
Definition Cosine.H:243
virtual Type value(const scalar t) const
Return value for time t.
Definition Cosine.H:260
virtual ~Cosine()=default
Destructor.
virtual Type integrate(const scalar x1, const scalar x2) const
Integrate between two (scalar) values.
Definition Cosine.H:268
Cosine(const word &entryName, const dictionary &dict, const objectRegistry *obrPtr=nullptr)
Construct from entry name, dictionary and optional registry.
Definition Cosine.H:223
void operator=(const Cosine< Type > &)=delete
No copy assignment.
Cosine(const Cosine< Type > &rhs)
Copy construct.
Definition Cosine.H:235
A templated sine function, with support for offset etc.
Definition Sine.H:204
Sine(const word &entryName, const dictionary &dict, const objectRegistry *obrPtr=nullptr)
Construct from entry name, dictionary and optional registry.
Definition Sine.C:28
Type cosValue(const scalar t) const
Return value for time t, using cos form.
Definition SineI.H:86
Type sinValue(const scalar t) const
Return value for time t, using sin form.
Definition SineI.H:96
static tmp< Function1< Type > > Clone(const Derived &fun)
Clone a Function1.
Definition Function1.H:190
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Registry of regIOobjects.
A class for managing temporary objects.
Definition tmp.H:75
A class for handling words, derived from Foam::string.
Definition word.H:66
Namespace for OpenFOAM.
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68