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-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::Function1Types::Scale
29
30Description
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
70SourceFiles
71 Scale.C
72
73\*---------------------------------------------------------------------------*/
74
75#ifndef Function1Types_Scale_H
76#define Function1Types_Scale_H
77
78#include "Function1.H"
79
80// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
81
82namespace Foam
83{
84namespace Function1Types
85{
86
87/*---------------------------------------------------------------------------*\
88 Class Scale Declaration
89\*---------------------------------------------------------------------------*/
90
91template<class Type>
92class 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_;
104
105 // Private Member Functions
106
107 //- Read the coefficients from the given dictionary
108 void read(const dictionary& coeffs);
109
110
111public:
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
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// ************************************************************************* //
Function1 which scales a given 'value' function by a scalar 'scale' function.
Definition: Scale.H:106
TypeName("scale")
Runtime type information.
virtual tmp< Function1< Type > > clone() const
Construct and return a clone.
Definition: Scale.H:148
virtual ~Scale()=default
Destructor.
virtual void writeData(Ostream &os) const
Write in dictionary format.
Definition: Scale.C:77
virtual void writeEntries(Ostream &os) const
Write coefficient entries in dictionary format.
Definition: Scale.C:69
virtual Type value(const scalar t) const
Return value for time t.
Definition: ScaleI.H:33
void operator=(const Scale< Type > &)=delete
No copy assignment.
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: Function1.H:96
const word const dictionary & dict
Definition: Function1.H:134
const word const dictionary const objectRegistry * obrPtr
Definition: Function1.H:136
const word & entryName
Definition: Function1.H:133
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Registry of regIOobjects.
A class for managing temporary objects.
Definition: tmp.H:65
A class for handling words, derived from Foam::string.
Definition: word.H:68
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73