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  Copyright (C) 2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::Function1Types::Scale
29 
30 Description
31  Function1 which scales a given 'value' function by a scalar 'scale'
32  function.
33 
34  This is particularly useful to ramp a time-varying value by one of the
35  monotonic ramp functions.
36 
37  Usage for a vector:
38  \verbatim
39  <entryName>
40  {
41  type scale;
42 
43  scale
44  {
45  type linearRamp;
46 
47  start 0;
48  duration 10;
49  }
50 
51  value
52  {
53  type sine;
54 
55  frequency 10;
56  amplitude 1;
57  scale (1 0.1 0);
58  level (10 1 0);
59  }
60  }
61  \endverbatim
62 
63  Where:
64  \table
65  Property | Description | Required
66  value | Function of type Function1<Type> | yes
67  scale | Scaling function of type Function1<scalar> | yes
68  \endtable
69 
70 SourceFiles
71  Scale.C
72 
73 \*---------------------------------------------------------------------------*/
74 
75 #ifndef Scale_H
76 #define Scale_H
77 
78 #include "Function1.H"
79 
80 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
81 
82 namespace Foam
83 {
84 namespace Function1Types
85 {
86 
87 /*---------------------------------------------------------------------------*\
88  Class Scale Declaration
89 \*---------------------------------------------------------------------------*/
90 
91 template<class Type>
92 class Scale
93 :
94  public Function1<Type>
95 {
96  // Private Data
97 
98  //- Scalar scaling function
99  autoPtr<Function1<scalar>> scale_;
100 
101  //- Value function
102  autoPtr<Function1<Type>> value_;
103 
104 
105  // Private Member Functions
106 
107  //- Read the coefficients from the given dictionary
108  void read(const dictionary& coeffs);
109 
110 
111 public:
112 
113  //- Runtime type information
114  TypeName("scale");
115 
116 
117  // Generated Methods
118 
119  //- No copy assignment
120  void operator=(const Scale<Type>&) = delete;
121 
122 
123  // Constructors
124 
125  //- Construct from entry name and dictionary
126  Scale
127  (
128  const word& entryName,
129  const dictionary& dict
130  );
131 
132  //- Copy construct
133  explicit Scale(const Scale<Type>& rhs);
134 
135 
136  //- Destructor
137  virtual ~Scale() = default;
138 
139 
140  // Member Functions
141 
142  //- Return value for time t
143  virtual inline Type value(const scalar t) const;
144 
145  //- Write in dictionary format
146  virtual void writeData(Ostream& os) const;
147 
148  //- Write coefficient entries in dictionary format
149  void writeEntries(Ostream& os) const;
150 };
151 
152 
153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154 
155 } // End namespace Function1Types
156 } // End namespace Foam
157 
158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
159 
160 #include "ScaleI.H"
161 
162 #ifdef NoRepository
163  #include "Scale.C"
164 #endif
165 
166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
167 
168 #endif
169 
170 // ************************************************************************* //
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:133
Function1.H
Foam::Function1::dict
const word const dictionary & dict
Definition: Function1.H:135
Foam::Function1Types::Scale::writeData
virtual void writeData(Ostream &os) const
Write in dictionary format.
Definition: Scale.C:74
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:103
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::operator=
void operator=(const Scale< Type > &)=delete
No copy assignment.
Foam::Function1Types::Scale::Scale
Scale(const word &entryName, const dictionary &dict)
Construct from entry name and dictionary.
Definition: Scale.C:43
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::Function1Types::Scale::writeEntries
void writeEntries(Ostream &os) const
Write coefficient entries in dictionary format.
Definition: Scale.C:66
Foam::Function1Types::Scale::~Scale
virtual ~Scale()=default
Destructor.
Scale.C