TimeFunction1.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) 2012-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::TimeFunction1
26 
27 Description
28  Light wrapper around Function1 to provide a mechanism to update time-based
29  entries.
30 
31 SourceFiles
32  TimeFunction1.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef TimeFunction1_H
37 #define TimeFunction1_H
38 
39 #include "Function1.H"
40 #include "Time.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 template<class Type>
47 class TimeFunction1;
48 
49 template<class Type>
50 Ostream& operator<<
51 (
52  Ostream&,
53  const TimeFunction1<Type>&
54 );
55 
56 /*---------------------------------------------------------------------------*\
57  Class TimeFunction1 Declaration
58 \*---------------------------------------------------------------------------*/
59 
60 template<class Type>
61 class TimeFunction1
62 {
63 protected:
64 
65  // Protected data
66 
67  //- Reference to the time database
68  const Time& time_;
69 
70  //- Name of the data entry
71  const word name_;
72 
73  //- The function
75 
76 
77 public:
78 
79  // Constructor
80 
81  //- Construct from time, entry name and dictionary
83  (
84  const Time& time,
85  const word& entryName,
86  const dictionary& dict
87  );
88 
89  //- Construct null from time and entry name
91  (
92  const Time& time,
93  const word& entryName
94  );
95 
96  //- Copy constructor
98 
99 
100  //- Destructor
101  virtual ~TimeFunction1();
102 
103 
104  // Member Functions
105 
106  // Access
107 
108  //- Reset entry by re-reading from dictionary
109  void reset(const dictionary& dict);
110 
111 
112  // Evaluation
113 
114  //- Return value as a function of (scalar) independent variable
115  virtual Type value(const scalar x) const;
116 
117  //- Integrate between two (scalar) values
118  virtual Type integrate(const scalar x1, const scalar x2) const;
119 
120 
121  // I/O
122 
123  //- Ostream Operator
124  friend Ostream& operator<< <Type>
125  (
126  Ostream& os,
127  const TimeFunction1<Type>& de
128  );
129 
130  //- Write in dictionary format
131  virtual void writeData(Ostream& os) const;
132 };
133 
134 
135 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
136 
137 } // End namespace Foam
138 
139 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
140 
141 #ifdef NoRepository
142  #include "TimeFunction1.C"
143 #endif
144 
145 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
146 
147 #endif
148 
149 // ************************************************************************* //
dictionary dict
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
virtual Type integrate(const scalar x1, const scalar x2) const
Integrate between two (scalar) values.
Definition: TimeFunction1.C:94
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
virtual ~TimeFunction1()
Destructor.
Definition: TimeFunction1.C:72
A class for handling words, derived from string.
Definition: word.H:59
Light wrapper around Function1 to provide a mechanism to update time-based entries.
void reset(const dictionary &dict)
Reset entry by re-reading from dictionary.
Definition: TimeFunction1.C:79
autoPtr< Function1< Type > > function_
The function.
Definition: TimeFunction1.H:73
virtual Type value(const scalar x) const
Return value as a function of (scalar) independent variable.
Definition: TimeFunction1.C:86
virtual void writeData(Ostream &os) const
Write in dictionary format.
TimeFunction1(const Time &time, const word &entryName, const dictionary &dict)
Construct from time, entry name and dictionary.
Definition: TimeFunction1.C:32
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
const word name_
Name of the data entry.
Definition: TimeFunction1.H:70
Namespace for OpenFOAM.
const Time & time_
Reference to the time database.
Definition: TimeFunction1.H:67