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-2021 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  <name>
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  <name>
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  <name>
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& dict);
162 
163 
164 public:
165 
166  // Runtime type information
167  TypeName("scale");
168 
169 
170  // Constructors
171 
172  //- Construct from name and functions
173  Scale
174  (
175  const word& name,
176  const Function1<scalar>& scale,
177  const Function1<scalar>& xScale,
178  const Function1<Type>& value
179  );
180 
181  //- Construct from name and dictionary
182  Scale
183  (
184  const word& name,
185  const dictionary& dict
186  );
187 
188  //- Copy constructor
189  Scale(const Scale<Type>& se);
190 
191 
192  //- Destructor
193  virtual ~Scale();
194 
195 
196  // Member Functions
197 
198  //- Return value
199  virtual inline Type value(const scalar x) const;
200 
201  //- Integrate between two values
202  virtual inline Type integral(const scalar x1, const scalar x2) const;
203 
204  //- Write data to dictionary stream
205  virtual void write(Ostream& os) const;
206 
207 
208  // Member Operators
209 
210  //- Disallow default bitwise assignment
211  void operator=(const Scale<Type>&) = delete;
212 };
213 
214 
215 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
216 
217 } // End namespace Function1s
218 } // End namespace Foam
219 
220 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
221 
222 #include "ScaleI.H"
223 
224 #ifdef NoRepository
225  #include "Scale.C"
226 #endif
227 
228 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
229 
230 #endif
231 
232 // ************************************************************************* //
const word const dictionary & dict
Definition: Function1.H:84
virtual ~Scale()
Destructor.
Definition: Scale.C:106
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
const word & name() const
Return the name of the entry.
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
virtual Type integral(const scalar x1, const scalar x2) const
Integrate between two values.
Definition: ScaleI.H:40
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
Scale(const word &name, const Function1< scalar > &scale, const Function1< scalar > &xScale, const Function1< Type > &value)
Construct from name and functions.
Definition: Scale.C:54
virtual void write(Ostream &os) const
Write data to dictionary stream.
Definition: Scale.C:113
void operator=(const Scale< Type > &)=delete
Disallow default bitwise assignment.
Namespace for OpenFOAM.