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-2021 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  scale | Scaling function of type Function1<scalar> | yes
67  value | Function of type Function1<Type> | yes
68  \endtable
69 
70 SourceFiles
71  Scale.C
72 
73 \*---------------------------------------------------------------------------*/
74 
75 #ifndef Function1Types_Scale_H
76 #define Function1Types_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
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, dictionary and optional registry
126  Scale
127  (
128  const word& entryName,
129  const dictionary& dict,
130  const objectRegistry* obrPtr = nullptr
131  );
132 
133  //- Copy construct
134  explicit Scale(const Scale<Type>& rhs);
135 
136  //- Construct and return a clone
137  virtual tmp<Function1<Type>> clone() const
138  {
139  return tmp<Function1<Type>>(new Scale<Type>(*this));
140  }
141 
142 
143  //- Destructor
144  virtual ~Scale() = default;
145 
146 
147  // Member Functions
148 
149  //- Return value for time t
150  virtual inline Type value(const scalar t) const;
151 
152  //- Write in dictionary format
153  virtual void writeData(Ostream& os) const;
154 
155  //- Write coefficient entries in dictionary format
156  virtual void writeEntries(Ostream& os) const;
157 };
158 
159 
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 
162 } // End namespace Function1Types
163 } // End namespace Foam
164 
165 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
166 
167 #include "ScaleI.H"
168 
169 #ifdef NoRepository
170  #include "Scale.C"
171 #endif
172 
173 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174 
175 #endif
176 
177 // ************************************************************************* //
const word const dictionary & dict
Definition: Function1.H:140
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
virtual void writeEntries(Ostream &os) const
Write coefficient entries in dictionary format.
Definition: Scale.C:62
const word & entryName
Definition: Function1.H:140
virtual void writeData(Ostream &os) const
Write in dictionary format.
Definition: Scale.C:70
virtual Type value(const scalar t) const
Return value for time t.
Definition: ScaleI.H:26
A class for handling words, derived from Foam::string.
Definition: word.H:63
TypeName("scale")
Runtime type information.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
virtual ~Scale()=default
Destructor.
OBJstream os(runTime.globalPath()/outputName)
const word const dictionary const objectRegistry * obrPtr
Definition: Function1.H:140
virtual tmp< Function1< Type > > clone() const
Construct and return a clone.
Definition: Scale.H:160
void operator=(const Scale< Type > &)=delete
No copy assignment.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Registry of regIOobjects.
Function1 which scales a given &#39;value&#39; function by a scalar &#39;scale&#39; function.
Definition: Scale.H:99
Namespace for OpenFOAM.
Scale(const word &entryName, const dictionary &dict, const objectRegistry *obrPtr=nullptr)
Construct from entry name, dictionary and optional registry.
Definition: Scale.C:38