Repeat.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) 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::Repeat
26 
27 Description
28  Function1 which repeats a given 'value' function with a given period or
29  frequency, and with an optional shift along the x-axis
30 
31 Usage
32  Example:
33  \verbatim
34  <name>
35  {
36  type repeat;
37 
38  period 360 [CAD];
39 
40  //frequency 0.00277778 [CAD^-1]; // <-- alternative to specifying
41  // the period
42 
43  start 10 [CAD]; // <-- optional shift
44 
45  value
46  {
47  type table;
48  file "constant/timeVsFlowRate.foam";
49  units ([ms] [m^3/s]);
50  }
51  }
52  \endverbatim
53 
54  Where:
55  \vartable
56  Symbol | Description | Data type | Default
57  period | Period of repetition | scalar |
58  frequency | Frequency of repetition | scalar |
59  start | Start x coordinate | scalar | 0
60  value | Function to repeat | Function1<Type> |
61  \endvartable
62 
63 SourceFiles
64  Repeat.C
65 
66 \*---------------------------------------------------------------------------*/
67 
68 #ifndef Repeat_H
69 #define Repeat_H
70 
71 #include "Function1.H"
72 
73 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
74 
75 namespace Foam
76 {
77 namespace Function1s
78 {
79 
80 /*---------------------------------------------------------------------------*\
81  Class Repeat Declaration
82 \*---------------------------------------------------------------------------*/
83 
84 template<class Type>
85 class Repeat
86 :
87  public FieldFunction1<Type, Repeat<Type>>
88 {
89  // Private Data
90 
91  //- Period of repetition
92  const scalar period_;
93 
94  //- Argument offset
95  const scalar start_;
96 
97  //- Value function
98  const autoPtr<Function1<Type>> value_;
99 
100 
101  // Private Member Functions
102 
103  //- Read the period
104  static scalar readPeriod
105  (
106  const unitConversions& units,
107  const dictionary& dict
108  );
109 
110 
111 public:
112 
113  // Runtime type information
114  TypeName("repeat");
115 
116 
117  // Constructors
118 
119  //- Construct from name and dictionary
120  Repeat
121  (
122  const word& name,
123  const unitConversions& units,
124  const dictionary& dict
125  );
126 
127  //- Copy constructor
128  Repeat(const Repeat<Type>& se);
129 
130 
131  //- Destructor
132  virtual ~Repeat();
133 
134 
135  // Member Functions
136 
137  //- Return value
138  virtual inline Type value(const scalar x) const;
139 
140  //- Integrate between two values
141  virtual inline Type integral(const scalar x1, const scalar x2) const;
142 
143  //- Write data to dictionary stream
144  virtual void write(Ostream& os, const unitConversions& units) const;
145 
146 
147  // Member Operators
148 
149  //- Disallow default bitwise assignment
150  void operator=(const Repeat<Type>&) = delete;
151 };
152 
153 
154 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
155 
156 } // End namespace Function1s
157 } // End namespace Foam
158 
159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
160 
161 #include "RepeatI.H"
162 
163 #ifdef NoRepository
164  #include "Repeat.C"
165 #endif
166 
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168 
169 #endif
170 
171 // ************************************************************************* //
const word & name() const
Return the name of the entry.
Definition: Function1.C:78
Function1 which repeats a given 'value' function with a given period or frequency,...
Definition: Repeat.H:117
void operator=(const Repeat< Type > &)=delete
Disallow default bitwise assignment.
virtual Type integral(const scalar x1, const scalar x2) const
Integrate between two values.
Definition: RepeatI.H:41
virtual void write(Ostream &os, const unitConversions &units) const
Write data to dictionary stream.
Definition: Repeat.C:94
virtual ~Repeat()
Destructor.
Definition: Repeat.C:86
Repeat(const word &name, const unitConversions &units, const dictionary &dict)
Construct from name and dictionary.
Definition: Repeat.C:60
virtual Type value(const scalar x) const
Return value.
Definition: RepeatI.H:31
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
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