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-2018 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 
64 protected:
65 
66  // Protected data
67 
68  //- Reference to the time database
69  const Time& time_;
70 
71  //- Name of the data entry
72  const word name_;
73 
74  //- The underlying Function1
76 
77 
78 public:
79 
80  // Constructor
81 
82  //- Construct from entry name
84  (
85  const Time& t,
86  const word& name,
87  const dictionary& dict
88  );
89 
90  //- Construct null from entry name
92  (
93  const Time& t,
94  const word& entryName
95  );
96 
97  //- Copy constructor
99 
100 
101  //- Destructor
102  virtual ~TimeFunction1();
103 
104 
105  // Member Functions
106 
107  // Access
108 
109  //- Reset entry by re-reading from dictionary
110  void reset(const dictionary& dict);
111 
112  //- Return the name of the entry
113  const word& name() const;
114 
115 
116  // Evaluation
117 
118  //- Return value as a function of (scalar) independent variable
119  virtual Type value(const scalar x) const;
120 
121  //- Integrate between two (scalar) values
122  virtual Type integrate(const scalar x1, const scalar x2) const;
123 
124 
125  // I/O
126 
127  //- Ostream Operator
128  friend Ostream& operator<< <Type>
129  (
130  Ostream& os,
131  const TimeFunction1<Type>& de
132  );
133 
134  //- Write in dictionary format
135  virtual void writeData(Ostream& os) const;
136 };
137 
138 
139 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
140 
141 } // End namespace Foam
142 
143 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
144 
145 #ifdef NoRepository
146  #include "TimeFunction1.C"
147 #endif
148 
149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
150 
151 #endif
152 
153 // ************************************************************************* //
autoPtr< Function1< Type > > entry_
The underlying Function1.
Definition: TimeFunction1.H:74
dictionary dict
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
TimeFunction1(const Time &t, const word &name, const dictionary &dict)
Construct from entry name.
Definition: TimeFunction1.C:32
virtual Type integrate(const scalar x1, const scalar x2) const
Integrate between two (scalar) values.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
virtual ~TimeFunction1()
Destructor.
Definition: TimeFunction1.C:75
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:82
const word & name() const
Return the name of the entry.
Definition: TimeFunction1.C:98
virtual Type value(const scalar x) const
Return value as a function of (scalar) independent variable.
virtual void writeData(Ostream &os) const
Write in dictionary format.
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:71
Namespace for OpenFOAM.
const Time & time_
Reference to the time database.
Definition: TimeFunction1.H:68