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-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::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  const autoPtr<Function1<scalar>> scale_;
145 
146  //- Argument scaling function
147  const autoPtr<Function1<scalar>> xScale_;
148 
149  //- Value function
150  const autoPtr<Function1<Type>> value_;
151 
152  //- Is this function integrable?
153  const bool integrableScale_;
154 
155  //- Is this function integrable?
156  const bool integrableValue_;
157 
158 
159 public:
160 
161  // Runtime type information
162  TypeName("scale");
163 
164 
165  // Constructors
166 
167  //- Construct from name and functions
168  Scale
169  (
170  const word& name,
171  const Function1<scalar>& scale,
172  const Function1<scalar>& xScale,
173  const Function1<Type>& value
174  );
175 
176  //- Construct from name and dictionary
178  (
179  const word& name,
180  const unitConversions& units,
181  const dictionary& dict
182  );
183 
184  //- Copy constructor
185  Scale(const Scale<Type>& se);
186 
187 
188  //- Destructor
189  virtual ~Scale();
190 
191 
192  // Member Functions
193 
194  //- Return value
195  virtual inline Type value(const scalar x) const;
196 
197  //- Integrate between two values
198  virtual inline Type integral(const scalar x1, const scalar x2) const;
199 
200  //- Is this function guaranteed to be constant?
201  virtual inline bool constant() const;
202 
203  //- Write data to dictionary stream
204  virtual void write(Ostream& os, const unitConversions& units) const;
205 
206 
207  // Member Operators
208 
209  //- Disallow default bitwise assignment
210  void operator=(const Scale<Type>&) = delete;
211 };
212 
213 
214 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215 
216 } // End namespace Function1s
217 } // End namespace Foam
218 
219 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
220 
221 #include "ScaleI.H"
222 
223 #ifdef NoRepository
224  #include "Scale.C"
225 #endif
226 
227 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
228 
229 #endif
230 
231 // ************************************************************************* //
const word & name() const
Return the name of the entry.
Definition: Function1.C:78
Function1 which scales a given 'value' function by a 'scale' scalar function and scales the 'x' argum...
Definition: Scale.H:155
virtual Type integral(const scalar x1, const scalar x2) const
Integrate between two values.
Definition: ScaleI.H:40
virtual void write(Ostream &os, const unitConversions &units) const
Write data to dictionary stream.
Definition: Scale.C:93
void operator=(const Scale< Type > &)=delete
Disallow default bitwise assignment.
virtual Type value(const scalar x) const
Return value.
Definition: ScaleI.H:31
virtual ~Scale()
Destructor.
Definition: Scale.C:85
virtual bool constant() const
Is this function guaranteed to be constant?
Definition: ScaleI.H:68
Scale(const word &name, const Function1< scalar > &scale, const Function1< scalar > &xScale, const Function1< Type > &value)
Construct from name and functions.
Definition: Scale.C:32
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A list of keyword definitions, which are a keyword followed by any number of values (e....
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