ramp.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-2019 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::Function1Types::ramp
26 
27 Description
28  Ramp function base class for the set of scalar functions starting from 0 and
29  increasing monotonically to 1 from \c start over the \c duration and
30  remaining at 1 thereafter.
31 
32  Usage:
33  \verbatim
34  <entryName> <rampFunction>;
35  <entryName>Coeffs
36  {
37  start 10;
38  duration 20;
39  }
40  \endverbatim
41  or
42  \verbatim
43  <entryName>
44  {
45  type <rampFunction>;
46  start 10;
47  duration 20;
48  }
49  \endverbatim
50 
51  Where:
52  \table
53  Property | Description | Required | Default value
54  start | Start time | no | 0
55  duration | Duration | yes |
56  \endtable
57 
58 See also
59  Foam::Function1
60 
61 SourceFiles
62  ramp.C
63 
64 \*---------------------------------------------------------------------------*/
65 
66 #ifndef ramp_H
67 #define ramp_H
68 
69 #include "Function1.H"
70 
71 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
72 
73 namespace Foam
74 {
75 namespace Function1Types
76 {
77 
78 /*---------------------------------------------------------------------------*\
79  Class ramp Declaration
80 \*---------------------------------------------------------------------------*/
81 
82 class ramp
83 :
84  public Function1<scalar>
85 {
86 protected:
87 
88  // Protected data
89 
90  //- Start-time of the ramp function
91  scalar start_;
92 
93  //- Duration of the ramp function
94  scalar duration_;
95 
96  //- Simple linear ramp function
97  // which form the basis of many more complex ramp functions
98  inline scalar linearRamp(const scalar t) const
99  {
100  return max(min((t - start_)/duration_, 1), 0);
101  }
102 
103 
104 private:
106  // Private Member Functions
107 
108  //- Read the coefficients from the given dictionary
109  void read(const dictionary& coeffs);
110 
111 
112 public:
113 
114  // Constructors
115 
116  //- Construct from entry name and dictionary
117  ramp
118  (
119  const word& entryName,
120  const dictionary& dict
121  );
122 
123 
124  //- Destructor
125  virtual ~ramp();
126 
127 
128  // Member Functions
129 
130  //- Return value for time t
131  virtual scalar value(const scalar t) const = 0;
132 
133  //- Write in dictionary format
134  virtual void writeData(Ostream& os) const;
135 
136 
137  // Member Operators
138 
139  //- Disallow default bitwise assignment
140  void operator=(const ramp&) = delete;
141 };
142 
143 
144 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
145 
146 } // End namespace Function1Types
147 } // End namespace Foam
148 
149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
150 
151 #endif
152 
153 // ************************************************************************* //
const word const dictionary & dict
Definition: Function1.H:85
virtual void writeData(Ostream &os) const
Write in dictionary format.
Definition: ramp.C:57
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
void operator=(const ramp &)=delete
Disallow default bitwise assignment.
Ramp function base class for the set of scalar functions starting from 0 and increasing monotonically...
Definition: ramp.H:96
scalar start_
Start-time of the ramp function.
Definition: ramp.H:105
scalar linearRamp(const scalar t) const
Simple linear ramp function.
Definition: ramp.H:112
const word & entryName
Definition: Function1.H:85
virtual scalar value(const scalar t) const =0
Return value for time t.
A class for handling words, derived from string.
Definition: word.H:59
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
ramp(const word &entryName, const dictionary &dict)
Construct from entry name and dictionary.
Definition: ramp.C:38
virtual ~ramp()
Destructor.
Definition: ramp.C:51
scalar duration_
Duration of the ramp function.
Definition: ramp.H:108
Namespace for OpenFOAM.