Scale.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) 2017-2019 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::Function1Types::Scale
26 
27 Description
28  Function1 which scales a given 'value' function by a 'scale' scalar function
29  and scales the 'x' argument of the 'value' and 'scale' functions by the
30  optional 'xScale' scalar function.
31 
32  This is particularly useful to ramp a time-varying value by one of the
33  monotonic ramp functions.
34 
35  Usage for a vector:
36  \verbatim
37  <entryName>
38  {
39  type scale;
40 
41  scale
42  {
43  type linearRamp;
44 
45  start 0;
46  duration 10;
47  }
48 
49  value
50  {
51  type sine;
52 
53  frequency 10;
54  amplitude 1;
55  scale (1 0.1 0);
56  level (10 1 0);
57  }
58  }
59  \endverbatim
60 
61  Simplified usage to scale by a constant factor, e.g. 2:
62  \verbatim
63  <entryName>
64  {
65  type scale;
66 
67  scale 2;
68 
69  value
70  {
71  type sine;
72 
73  frequency 10;
74  amplitude 1;
75  scale (1 0.1 0);
76  level (10 1 0);
77  }
78  }
79  \endverbatim
80 
81  Usage including the optional 'xScale' function:
82  \verbatim
83  <entryName>
84  {
85  type scale;
86 
87  xScale 0.5;
88  scale 2;
89 
90  value
91  {
92  type sine;
93 
94  frequency 10;
95  amplitude 1;
96  scale (1 0.1 0);
97  level (10 1 0);
98  }
99  }
100  \endverbatim
101 
102  Where:
103  \table
104  Property | Description | Required
105  value | Function of type Function1<Type> | yes
106  scale | Scaling function of type Function1<scalar> | yes
107  xScale | 'x' scaling function of type Function1<scalar> | no
108  \endtable
109 
110 SourceFiles
111  Scale.C
112 
113 \*---------------------------------------------------------------------------*/
114 
115 #ifndef Scale_H
116 #define Scale_H
117 
118 #include "Function1.H"
119 
120 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
121 
122 namespace Foam
123 {
124 namespace Function1Types
125 {
126 
127 /*---------------------------------------------------------------------------*\
128  Class Scale Declaration
129 \*---------------------------------------------------------------------------*/
130 
131 template<class Type>
132 class Scale
133 :
134  public Function1<Type>
135 {
136  // Private Data
137 
138  //- Argument scaling function
139  autoPtr<Function1<scalar>> xScale_;
140 
141  //- Scalar scaling function
142  autoPtr<Function1<scalar>> scale_;
143 
144  //- Value function
145  autoPtr<Function1<Type>> value_;
146 
148  // Private Member Functions
149 
150  //- Read the coefficients from the given dictionary
151  void read(const dictionary& coeffs);
152 
153 
154 public:
155 
156  // Runtime type information
157  TypeName("scale");
158 
159 
160  // Constructors
161 
162  //- Construct from entry name and dictionary
163  Scale
164  (
165  const word& entryName,
166  const dictionary& dict
167  );
168 
169  //- Copy constructor
170  Scale(const Scale<Type>& se);
171 
172 
173  //- Destructor
174  virtual ~Scale();
175 
176 
177  // Member Functions
178 
179  //- Return value for time t
180  virtual inline Type value(const scalar t) const;
181 
182  //- Write in dictionary format
183  virtual void writeData(Ostream& os) const;
184 
185 
186  // Member Operators
187 
188  //- Disallow default bitwise assignment
189  void operator=(const Scale<Type>&) = delete;
190 };
191 
192 
193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 
195 } // End namespace Function1Types
196 } // End namespace Foam
197 
198 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
199 
200 #include "ScaleI.H"
201 
202 #ifdef NoRepository
203  #include "Scale.C"
204 #endif
205 
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 
208 #endif
209 
210 // ************************************************************************* //
const word const dictionary & dict
Definition: Function1.H:85
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
const word & entryName
Definition: Function1.H:85
virtual void writeData(Ostream &os) const
Write in dictionary format.
Definition: Scale.C:75
virtual Type value(const scalar t) const
Return value for time t.
Definition: ScaleI.H:31
A class for handling words, derived from string.
Definition: word.H:59
virtual ~Scale()
Destructor.
Definition: Scale.C:68
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
Scale(const word &entryName, const dictionary &dict)
Construct from entry name and dictionary.
Definition: Scale.C:44
void operator=(const Scale< Type > &)=delete
Disallow default bitwise assignment.
Function1 which scales a given &#39;value&#39; function by a &#39;scale&#39; scalar function and scales the &#39;x&#39; argum...
Definition: Scale.H:147
Namespace for OpenFOAM.