squarePulse.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) 2021 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::Function1s::squarePulse
26 
27 Description
28  Square pulse function. Takes a value of 0 before \c start, then rises
29  instantaneously to 1, remains at 1 for \c duration, then drops
30  instantaneously back to 0.
31 
32  Usage:
33  \verbatim
34  <name> squarePulse;
35  <name>Coeffs
36  {
37  start 10;
38  duration 20;
39  }
40  \endverbatim
41  or
42  \verbatim
43  <name>
44  {
45  type squarePulse;
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  squarePulse.C
63 
64 \*---------------------------------------------------------------------------*/
65 
66 #ifndef squarePulse_H
67 #define squarePulse_H
68 
69 #include "Function1.H"
70 
71 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
72 
73 namespace Foam
74 {
75 namespace Function1s
76 {
77 
78 /*---------------------------------------------------------------------------*\
79  Class squarePulse Declaration
80 \*---------------------------------------------------------------------------*/
81 
82 class squarePulse
83 :
84  public FieldFunction1<scalar, squarePulse>
85 {
86  // Private data
87 
88  //- Start-time of the ramp function
89  scalar start_;
90 
91  //- Duration of the ramp function
92  scalar duration_;
93 
94 
95 private:
96 
97  // Private Member Functions
98 
99  //- Read the coefficients from the given dictionary
100  void read(const dictionary& dict);
101 
102 
103 public:
104 
105  // Runtime type information
106  TypeName("squarePulse");
107 
108 
109  // Constructors
110 
111  //- Construct from name and dictionary
113  (
114  const word& name,
115  const dictionary& dict
116  );
117 
118 
119  //- Destructor
120  virtual ~squarePulse();
121 
122 
123  // Member Functions
124 
125  //- Return value for time t
126  virtual inline scalar value(const scalar t) const;
127 
128  //- Return the integral between times t1 and t2
129  virtual inline scalar integral
130  (
131  const scalar t1,
132  const scalar t2
133  ) const;
134 
135  //- Write data to dictionary stream
136  virtual void write(Ostream& os) const;
137 
138 
139  // Member Operators
140 
141  //- Disallow default bitwise assignment
142  void operator=(const squarePulse&) = delete;
143 };
144 
145 
146 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
147 
148 } // End namespace Function1s
149 } // End namespace Foam
150 
151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152 
153 #ifdef NoRepository
154  #include "squarePulseI.H"
155 #endif
156 
157 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
158 
159 #endif
160 
161 // ************************************************************************* //
const word const dictionary & dict
Definition: Function1.H:84
Square pulse function. Takes a value of 0 before start, then rises instantaneously to 1...
Definition: squarePulse.H:96
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
const word & name() const
Return the name of the entry.
virtual scalar value(const scalar t) const
Return value for time t.
Definition: squarePulseI.H:30
virtual ~squarePulse()
Destructor.
Definition: squarePulse.C:62
virtual scalar integral(const scalar t1, const scalar t2) const
Return the integral between times t1 and t2.
Definition: squarePulseI.H:37
A class for handling words, derived from string.
Definition: word.H:59
virtual void write(Ostream &os) const
Write data to dictionary stream.
Definition: squarePulse.C:68
squarePulse(const word &name, const dictionary &dict)
Construct from name and dictionary.
Definition: squarePulse.C:49
void operator=(const squarePulse &)=delete
Disallow default bitwise assignment.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
Namespace for OpenFOAM.