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-2023 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, name and dictionary
83  (
84  const Time& time,
85  const word& name,
86  const dictionary& dict
87  );
88 
89  //- Construct from time and Function1
91  (
92  const Time& time,
93  const Function1<Type>& function
94  );
95 
96  //- Construct null from time and name
98  (
99  const Time& time,
100  const word& name
101  );
102 
103  //- Copy constructor
105 
106 
107  //- Destructor
108  virtual ~TimeFunction1();
109 
110 
111  // Member Functions
112 
113  // Access
114 
115  //- Reset entry by re-reading from dictionary
116  void reset(const dictionary& dict);
117 
118 
119  // Evaluation
120 
121  //- Return value as a function of scalar x
122  virtual Type value(const scalar x) const;
123 
124  //- Integrate between two scalars
125  virtual Type integral(const scalar x1, const scalar x2) const;
126 
127 
128  // I/O
129 
130  //- Ostream Operator
131  friend Ostream& operator<< <Type>
132  (
133  Ostream& os,
134  const TimeFunction1<Type>& de
135  );
136 
137  //- Write in dictionary format
138  virtual void write(Ostream& os) const;
139 };
140 
141 
142 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
143 
144 } // End namespace Foam
145 
146 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
147 
148 #ifdef NoRepository
149  #include "TimeFunction1.C"
150 #endif
151 
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 
154 #endif
155 
156 // ************************************************************************* //
Run-time selectable general function of one variable.
Definition: Function1.H:64
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Light wrapper around Function1 to provide a mechanism to update time-based entries.
Definition: TimeFunction1.H:61
void reset(const dictionary &dict)
Reset entry by re-reading from dictionary.
Definition: TimeFunction1.C:92
const Time & time_
Reference to the time database.
Definition: TimeFunction1.H:67
virtual ~TimeFunction1()
Destructor.
Definition: TimeFunction1.C:85
autoPtr< Function1< Type > > function_
The function.
Definition: TimeFunction1.H:73
virtual Type integral(const scalar x1, const scalar x2) const
Integrate between two scalars.
virtual void write(Ostream &os) const
Write in dictionary format.
virtual Type value(const scalar x) const
Return value as a function of scalar x.
Definition: TimeFunction1.C:99
TimeFunction1(const Time &time, const word &name, const dictionary &dict)
Construct from time, name and dictionary.
Definition: TimeFunction1.C:32
const word name_
Name of the data entry.
Definition: TimeFunction1.H:70
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
dictionary dict