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::Function1s::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 See also
111  Foam::Function1s::ramp
112  Foam::Function1s::reverseRamp
113 
114 SourceFiles
115  Scale.C
116 
117 \*---------------------------------------------------------------------------*/
118 
119 #ifndef Scale_H
120 #define Scale_H
121 
122 #include "Function1.H"
123 
124 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
125 
126 namespace Foam
127 {
128 namespace Function1s
129 {
130 
131 /*---------------------------------------------------------------------------*\
132  Class Scale Declaration
133 \*---------------------------------------------------------------------------*/
134 
135 template<class Type>
136 class Scale
137 :
138  public FieldFunction1<Type, Scale<Type>>
139 {
140  // Private Data
141 
142  //- Scalar scaling function
143  autoPtr<Function1<scalar>> scale_;
144 
145  //- Argument scaling function
146  autoPtr<Function1<scalar>> xScale_;
147 
148  //- Value function
149  autoPtr<Function1<Type>> value_;
150 
151  //- Is this function integrable?
152  bool integrableScale_;
153 
154  //- Is this function integrable?
155  bool integrableValue_;
156 
157 
158  // Private Member Functions
159 
160  //- Read the coefficients from the given dictionary
161  void read(const dictionary& coeffs);
162 
163 
164 public:
165 
166  // Runtime type information
167  TypeName("scale");
168 
169 
170  // Constructors
171 
172  //- Construct from entry name and dictionary
173  Scale
174  (
175  const word& entryName,
176  const dictionary& dict
177  );
178 
179  //- Copy constructor
180  Scale(const Scale<Type>& se);
181 
182 
183  //- Destructor
184  virtual ~Scale();
185 
186 
187  // Member Functions
188 
189  //- Write in dictionary format
190  virtual void writeData(Ostream& os) const;
191 
192  //- Return value
193  virtual inline Type value(const scalar x) const;
194 
195  //- Integrate between two values
196  virtual inline Type integrate(const scalar x1, const scalar x2) const;
197 
198 
199  // Member Operators
200 
201  //- Disallow default bitwise assignment
202  void operator=(const Scale<Type>&) = delete;
203 };
204 
205 
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 
208 } // End namespace Function1s
209 } // End namespace Foam
210 
211 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
212 
213 #include "ScaleI.H"
214 
215 #ifdef NoRepository
216  #include "Scale.C"
217 #endif
218 
219 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
220 
221 #endif
222 
223 // ************************************************************************* //
const word const dictionary & dict
Definition: Function1.H:84
virtual ~Scale()
Destructor.
Definition: Scale.C:80
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:84
virtual Type integrate(const scalar x1, const scalar x2) const
Integrate between two values.
Definition: ScaleI.H:40
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:151
A class for handling words, derived from string.
Definition: word.H:59
Scale(const word &entryName, const dictionary &dict)
Construct from entry name and dictionary.
Definition: Scale.C:54
virtual Type value(const scalar x) const
Return value.
Definition: ScaleI.H:31
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
virtual void writeData(Ostream &os) const
Write in dictionary format.
Definition: Scale.C:87
void operator=(const Scale< Type > &)=delete
Disallow default bitwise assignment.
Namespace for OpenFOAM.