A templated sine function, with support for offset etc. More...
#include <Sine.H>


Protected Member Functions | |
| scalar | cycle (const scalar t) const |
| The cycle: (freq * time) or (time / period). | |
| scalar | cosForm (const scalar t) const |
| Calculated cos value at time t. | |
| scalar | sinForm (const scalar t) const |
| Calculated sin value at time t. | |
| scalar | squareForm (const scalar t, const scalar posFrac) const |
| Calculated square value at time t. | |
| Type | cosValue (const scalar t) const |
| Return value for time t, using cos form. | |
| Type | sinValue (const scalar t) const |
| Return value for time t, using sin form. | |
| Type | squareValue (const scalar t, const scalar posFrac) const |
| Return value for time t, using square form. | |
| Protected Member Functions inherited from Function1< Type > | |
| void | operator= (const Function1< Type > &)=delete |
| No copy assignment. | |
| Protected Member Functions inherited from function1Base | |
| void | operator= (const function1Base &)=delete |
| No copy assignment. | |
Protected Attributes | |
| scalar | t0_ |
| Start-time for the function. | |
| autoPtr< Function1< scalar > > | amplitude_ |
| Scalar amplitude of the function (optional). | |
| autoPtr< Function1< scalar > > | period_ |
| Period of the function (or specify frequency). | |
| autoPtr< Function1< scalar > > | frequency_ |
| Frequency of the function (or specify period). | |
| autoPtr< Function1< Type > > | scale_ |
| Scaling factor for the function. | |
| autoPtr< Function1< Type > > | level_ |
| Level to add to the scaled function. | |
| Protected Attributes inherited from function1Base | |
| const word | name_ |
| Name of entry. | |
| const objectRegistry * | obrPtr_ |
| Pointer to an object registry. | |
Additional Inherited Members | |
| Public Types inherited from Function1< Type > | |
| typedef Type | returnType |
| The return type. | |
| typedef autoPtr< Function1 >(* | dictionaryConstructorPtr) (const word &entryName, const dictionary &dict, const objectRegistry *obrPtr) |
| Declare runtime constructor selection table. | |
| typedef ::Foam::HashTable< dictionaryConstructorPtr, ::Foam::word, ::Foam::Hash<::Foam::word > > | dictionaryConstructorTableType |
| typedef ::Foam::HashTable< std::pair<::Foam::word, int >, ::Foam::word, ::Foam::Hash<::Foam::word > > | dictionaryConstructorCompatTableType |
| Static Public Member Functions inherited from Function1< Type > | |
| static const char * | typeName_ () |
| Runtime type information. | |
| static dictionaryConstructorCompatTableType & | dictionaryConstructorCompatTable () |
| static void | dictionaryConstructorTablePtr_construct (bool load) |
| static dictionaryConstructorPtr | dictionaryConstructorTable (const ::Foam::word &k) |
| template<class Derived> | |
| static tmp< Function1< Type > > | Clone (const Derived &fun) |
| Clone a Function1. | |
| static autoPtr< Function1< Type > > | New (const word &entryName, const dictionary &dict, const word &redirectType, const objectRegistry *obrPtr=nullptr, const bool mandatory=true) |
| Selector, with fallback redirection. | |
| static autoPtr< Function1< Type > > | NewCompat (const word &entryName, std::initializer_list< std::pair< const char *, int > > compat, const dictionary &dict, const word &redirectType=word::null, const objectRegistry *obrPtr=nullptr, const bool mandatory=true) |
| Compatibility selector, with fallback redirection. | |
| static autoPtr< Function1< Type > > | New (const word &entryName, const dictionary &dict, const objectRegistry *obrPtr=nullptr, const bool mandatory=true) |
| Selector, without fallback redirection. | |
| static autoPtr< Function1< Type > > | NewIfPresent (const word &entryName, const dictionary &dict, const word &redirectType, const objectRegistry *obrPtr=nullptr) |
| An optional selector, with fallback redirection. | |
| static autoPtr< Function1< Type > > | NewIfPresent (const word &entryName, const dictionary &dict, const objectRegistry *obrPtr=nullptr) |
| An optional selector, without fallback redirection. | |
| static refPtr< Function1< Type > > | New (HashPtrTable< Function1< Type > > &cache, const word &entryName, const dictionary &dict, enum keyType::option matchOpt=keyType::LITERAL, const objectRegistry *obrPtr=nullptr, const bool mandatory=true) |
| Selector with external storage of Function1. This also allows wildcard matches in a dictionary. | |
| Static Public Attributes inherited from Function1< Type > | |
| static const ::Foam::word | typeName |
| static int | debug |
| static dictionaryConstructorTableType * | dictionaryConstructorTablePtr_ |
| static std::unique_ptr< dictionaryConstructorCompatTableType > | dictionaryConstructorCompatTablePtr_ |
A templated sine function, with support for offset etc.
The wave period can be specified directly
![\[ a sin(2 \pi (t - t0) / p)) s + l
\]](form_705.png)
Or it can be specified by the frequency
![\[ a sin(2 \pi f (t - t0)) s + l
\]](form_706.png)
where
![]() | = | Description | Units |
![]() | = | Amplitude | - |
![]() | = | Frequency | [1/s] |
![]() | = | Period | [s] |
![]() | = | Type scale factor | - |
![]() | = | Type offset level | - |
![]() | = | Time | [s] |
![]() | = | Start time offset | [s] |
The dictionary specification would typically resemble this:
entry1
{
type sine;
frequency 10;
amplitude 0.1;
// A scalar Function1
scale 2e-6;
level 2e-6;
}
entry2
{
type sine;
frequency 10;
// A vector Function1
scale (1 0.1 0);
level (10 1 0);
}
where the entries mean:
| Property | Description | Type | Reqd | Default |
|---|---|---|---|---|
type | Function type: sine | word | yes | |
amplitude | Amplitude | Function1<scalar> | no | 1 |
frequency | Frequency [1/s] | Function1<scalar> | or period | |
period | Period [s] | Function1<scalar> | or frequency | |
scale | Scale factor (Type) | Function1<Type> | yes | |
level | Offset level (Type) | Function1<Type> | yes | |
t0 | Start time offset | scalar | no | 0 |
| Sine | ( | const word & | entryName, |
| const dictionary & | dict, | ||
| const objectRegistry * | obrPtr = nullptr ) |
Construct from entry name, dictionary and optional registry.
Definition at line 27 of file Sine.C.
References amplitude_, dict, frequency_, Function1< Type >::Function1(), level_, Function1< Type >::NewIfPresent(), period_, scale_, and t0_.
Referenced by Cosine< Type >::Cosine(), Cosine< Type >::Cosine(), operator=(), Sine(), Square< Type >::Square(), and Square< Type >::Square().


|
explicit |
Copy construct.
Definition at line 56 of file Sine.C.
References amplitude_, clone(), frequency_, Function1< Type >::Function1(), level_, period_, Foam::rhs(), scale_, Sine(), and t0_.

|
virtualdefault |
Destructor.
|
inlineprotected |
The cycle: (freq * time) or (time / period).
Definition at line 27 of file SineI.H.
References frequency_, period_, and t0_.
Referenced by cosForm(), sinForm(), and squareForm().

|
inlineprotected |
Calculated cos value at time t.
Definition at line 44 of file SineI.H.
References amplitude_, Foam::cos(), cycle(), and Foam::constant::mathematical::twoPi().
Referenced by cosValue().


|
inlineprotected |
Calculated sin value at time t.
Definition at line 56 of file SineI.H.
References amplitude_, cycle(), Foam::sin(), and Foam::constant::mathematical::twoPi().
Referenced by sinValue().


|
inlineprotected |
Calculated square value at time t.
The positive fraction is 0-1
Definition at line 68 of file SineI.H.
References amplitude_, and cycle().
Referenced by squareValue().


|
inlineprotected |
Return value for time t, using cos form.
Definition at line 86 of file SineI.H.
References cosForm(), level_, and scale_.
Referenced by integrate(), and Cosine< Type >::value().


|
inlineprotected |
|
inlineprotected |
Return value for time t, using square form.
Definition at line 106 of file SineI.H.
References level_, scale_, and squareForm().
Referenced by Square< Type >::value().


| TypeName | ( | "sine" | ) |
|
delete |
No copy assignment.
References dict, Foam::rhs(), and Sine().

Return a clone.
Implements Function1< Type >.
Reimplemented in Cosine< Type >, and Square< Type >.
Definition at line 314 of file Sine.H.
References Function1< Type >::Clone().
Referenced by Sine().


|
virtual |
Convert time.
Reimplemented from function1Base.
Definition at line 71 of file Sine.C.
References t0_, and TimeState::userTimeToTime().

|
inlinevirtual |
Return value for time t.
Reimplemented from Function1< Type >.
Reimplemented in Cosine< Type >, and Square< Type >.
Definition at line 336 of file Sine.H.
References sinValue().

|
inlinevirtual |
Integrate between two (scalar) values.
Reimplemented from Function1< Type >.
Reimplemented in Cosine< Type >.
Definition at line 344 of file Sine.H.
References cosValue().

|
virtual |
Write in dictionary format.
Reimplemented from Function1< Type >.
Reimplemented in Square< Type >.
Definition at line 99 of file Sine.C.
References name, os(), Function1< Type >::writeData(), and writeEntries().

|
virtual |
Write coefficient entries in dictionary format.
Reimplemented from Function1< Type >.
Reimplemented in Square< Type >.
Definition at line 78 of file Sine.C.
References amplitude_, frequency_, level_, os(), period_, scale_, and t0_.
Referenced by writeData(), and Square< Type >::writeEntries().


| const::Foam::word typeName | ( | Function1Types::Sine< scalar > | ::typeName_() | ) |
| int debug | ( | ::Foam::debug::debugSwitch(Function1Types::Sine< scalar >::typeName_(), 0) | ) |
| const::Foam::word typeName | ( | Function1Types::Sine< vector > | ::typeName_() | ) |
| int debug | ( | ::Foam::debug::debugSwitch(Function1Types::Sine< vector >::typeName_(), 0) | ) |
| const::Foam::word typeName | ( | Function1Types::Sine< sphericalTensor > | ::typeName_() | ) |
| int debug | ( | ::Foam::debug::debugSwitch(Function1Types::Sine< sphericalTensor >::typeName_(), 0) | ) |
| const::Foam::word typeName | ( | Function1Types::Sine< symmTensor > | ::typeName_() | ) |
| int debug | ( | ::Foam::debug::debugSwitch(Function1Types::Sine< symmTensor >::typeName_(), 0) | ) |
| const::Foam::word typeName | ( | Function1Types::Sine< tensor > | ::typeName_() | ) |
| int debug | ( | ::Foam::debug::debugSwitch(Function1Types::Sine< tensor >::typeName_(), 0) | ) |
|
protected |
Start-time for the function.
Definition at line 212 of file Sine.H.
Referenced by cycle(), Sine(), Sine(), userTimeToTime(), and writeEntries().
Scalar amplitude of the function (optional).
Definition at line 217 of file Sine.H.
Referenced by cosForm(), Sine(), Sine(), sinForm(), squareForm(), and writeEntries().
Scaling factor for the function.
Definition at line 232 of file Sine.H.
Referenced by cosValue(), Sine(), Sine(), sinValue(), squareValue(), and writeEntries().
Level to add to the scaled function.
Definition at line 237 of file Sine.H.
Referenced by cosValue(), Sine(), Sine(), sinValue(), squareValue(), and writeEntries().