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-2022 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
36  For a vector:
37  \verbatim
38  <name>
39  {
40  type scale;
41 
42  scale
43  {
44  type linearRamp;
45 
46  start 0;
47  duration 10;
48  }
49 
50  value
51  {
52  type sine;
53 
54  frequency 10;
55  amplitude 1;
56  scale (1 0.1 0);
57  level (10 1 0);
58  }
59  }
60  \endverbatim
61 
62  Simplified usage to scale by a constant factor, e.g. 2:
63  \verbatim
64  <name>
65  {
66  type scale;
67 
68  scale 2;
69 
70  value
71  {
72  type sine;
73 
74  frequency 10;
75  amplitude 1;
76  scale (1 0.1 0);
77  level (10 1 0);
78  }
79  }
80  \endverbatim
81 
82  Including the optional 'xScale' function:
83  \verbatim
84  <name>
85  {
86  type scale;
87 
88  xScale 0.5;
89  scale 2;
90 
91  value
92  {
93  type sine;
94 
95  frequency 10;
96  amplitude 1;
97  scale (1 0.1 0);
98  level (10 1 0);
99  }
100  }
101  \endverbatim
102 
103  Where:
104  \table
105  Property | Description | Required
106  value | Function of type Function1<Type> | yes
107  scale | Scaling function of type Function1<scalar> | yes
108  xScale | 'x' scaling function of type Function1<scalar> | no
109  \endtable
110 
111 See also
112  Foam::Function1s::ramp
113  Foam::Function1s::reverseRamp
114 
115 SourceFiles
116  Scale.C
117 
118 \*---------------------------------------------------------------------------*/
119 
120 #ifndef Scale_H
121 #define Scale_H
122 
123 #include "Function1.H"
124 
125 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
126 
127 namespace Foam
128 {
129 namespace Function1s
130 {
131 
132 /*---------------------------------------------------------------------------*\
133  Class Scale Declaration
134 \*---------------------------------------------------------------------------*/
135 
136 template<class Type>
137 class Scale
138 :
139  public FieldFunction1<Type, Scale<Type>>
140 {
141  // Private Data
142 
143  //- Scalar scaling function
144  autoPtr<Function1<scalar>> scale_;
145 
146  //- Argument scaling function
147  autoPtr<Function1<scalar>> xScale_;
148 
149  //- Value function
150  autoPtr<Function1<Type>> value_;
151 
152  //- Is this function integrable?
153  bool integrableScale_;
154 
155  //- Is this function integrable?
156  bool integrableValue_;
157 
158 
159  // Private Member Functions
160 
161  //- Read the coefficients from the given dictionary
162  void read(const dictionary& dict);
163 
164 
165 public:
166 
167  // Runtime type information
168  TypeName("scale");
169 
170 
171  // Constructors
172 
173  //- Construct from name and functions
174  Scale
175  (
176  const word& name,
177  const Function1<scalar>& scale,
178  const Function1<scalar>& xScale,
179  const Function1<Type>& value
180  );
181 
182  //- Construct from name and dictionary
183  Scale
184  (
185  const word& name,
186  const dictionary& dict
187  );
188 
189  //- Copy constructor
190  Scale(const Scale<Type>& se);
191 
192 
193  //- Destructor
194  virtual ~Scale();
195 
196 
197  // Member Functions
198 
199  //- Return value
200  virtual inline Type value(const scalar x) const;
201 
202  //- Integrate between two values
203  virtual inline Type integral(const scalar x1, const scalar x2) const;
204 
205  //- Write data to dictionary stream
206  virtual void write(Ostream& os) const;
207 
208 
209  // Member Operators
210 
211  //- Disallow default bitwise assignment
212  void operator=(const Scale<Type>&) = delete;
213 };
214 
215 
216 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217 
218 } // End namespace Function1s
219 } // End namespace Foam
220 
221 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
222 
223 #include "ScaleI.H"
224 
225 #ifdef NoRepository
226  #include "Scale.C"
227 #endif
228 
229 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
230 
231 #endif
232 
233 // ************************************************************************* //
dictionary dict
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.
Definition: Function1.C:82
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:152
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.