Scale.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2017 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::Function1Types::Scale
28 
29 Description
30  Function1 which scales a given 'value' function by a scalar 'scale'
31  function.
32 
33  This is particularly useful to ramp a time-varying value by one of the
34  monotonic ramp functions.
35 
36  Usage for a vector:
37  \verbatim
38  <entryName>
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  Where:
63  \table
64  Property | Description | Required
65  value | Function of type Function1<Type> | yes
66  scale | Scaling function of type Function1<scalar> | yes
67  \endtable
68 
69 SourceFiles
70  Scale.C
71 
72 \*---------------------------------------------------------------------------*/
73 
74 #ifndef Scale_H
75 #define Scale_H
76 
77 #include "Function1.H"
78 
79 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
80 
81 namespace Foam
82 {
83 namespace Function1Types
84 {
85 
86 /*---------------------------------------------------------------------------*\
87  Class Scale Declaration
88 \*---------------------------------------------------------------------------*/
89 
90 template<class Type>
91 class Scale
92 :
93  public Function1<Type>
94 {
95  // Private Data
96 
97  //- Scalar scaling function
98  autoPtr<Function1<scalar>> scale_;
99 
100  //- Value function
101  autoPtr<Function1<Type>> value_;
102 
103 
104  // Private Member Functions
105 
106  //- Read the coefficients from the given dictionary
107  void read(const dictionary& coeffs);
108 
109  //- No copy assignment
110  void operator=(const Scale<Type>&) = delete;
111 
112 
113 public:
114 
115  //- Runtime type information
116  TypeName("scale");
117 
118 
119  // Constructors
120 
121  //- Construct from entry name and dictionary
122  Scale
123  (
124  const word& entryName,
125  const dictionary& dict
126  );
127 
128  //- Copy construct
129  explicit Scale(const Scale<Type>& rhs);
130 
131 
132  //- Destructor
133  virtual ~Scale() = default;
134 
135 
136  // Member Functions
137 
138  //- Return value for time t
139  virtual inline Type value(const scalar t) const;
140 
141  //- Write in dictionary format
142  virtual void writeData(Ostream& os) const;
143 };
144 
145 
146 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
147 
148 } // End namespace Function1Types
149 } // End namespace Foam
150 
151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152 
153 #include "ScaleI.H"
154 
155 #ifdef NoRepository
156  #include "Scale.C"
157 #endif
158 
159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
160 
161 #endif
162 
163 // ************************************************************************* //
Foam::Function1Types::Scale::TypeName
TypeName("scale")
Runtime type information.
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::Function1::entryName
const word & entryName
Definition: Function1.H:125
Function1.H
Foam::Function1::dict
const word const dictionary & dict
Definition: Function1.H:127
Foam::Function1Types::Scale::writeData
virtual void writeData(Ostream &os) const
Write in dictionary format.
Definition: Scale.C:65
Foam::Function1
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: Function1.H:86
ScaleI.H
Foam::Function1Types::Scale
Function1 which scales a given 'value' function by a scalar 'scale' function.
Definition: Scale.H:102
Foam::Function1Types::Scale::value
virtual Type value(const scalar t) const
Return value for time t.
Definition: ScaleI.H:33
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::Function1Types::Scale::Scale
Scale(const word &entryName, const dictionary &dict)
Construct from entry name and dictionary.
Definition: Scale.C:42
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::Function1Types::Scale::~Scale
virtual ~Scale()=default
Destructor.
Scale.C