TimeFunction1.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2012-2016 OpenFOAM Foundation
9  Copyright (C) 2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::TimeFunction1
29 
30 Description
31  Light wrapper around Function1 to provide a mechanism to update time-based
32  entries.
33 
34 SourceFiles
35  TimeFunction1.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef TimeFunction1_H
40 #define TimeFunction1_H
41 
42 #include "Function1.H"
43 #include "Time.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 // Forward Declarations
51 template<class Type> class TimeFunction1;
52 
53 template<class Type>
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 underlying Function1
75 
76 
77 public:
78 
79  // Constructor
80 
81  //- Construct from entry name and dictionary
83  (
84  const Time& runTime,
85  const word& name,
86  const dictionary& dict
87  );
88 
89  //- Construct from entry name
91  (
92  const Time& runTime,
93  const word& entryName
94  );
95 
96  //- Copy construct
98 
99 
100  //- Destructor
101  virtual ~TimeFunction1() = default;
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  //- Return the name of the entry
112  const word& name() const;
113 
114 
115  // Evaluation
116 
117  //- Return value as a function of (scalar) independent variable
118  virtual Type value(const scalar x) const;
119 
120  //- Integrate between two (scalar) values
121  virtual Type integrate(const scalar x1, const scalar x2) const;
122 
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 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::TimeFunction1::TimeFunction1
TimeFunction1(const Time &runTime, const word &name, const dictionary &dict)
Construct from entry name and dictionary.
Definition: TimeFunction1.C:35
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Function1.H
Foam::TimeFunction1
Light wrapper around Function1 to provide a mechanism to update time-based entries.
Definition: TimeFunction1.H:50
Foam::TimeFunction1::name_
const word name_
Name of the data entry.
Definition: TimeFunction1.H:70
Foam::TimeFunction1::integrate
virtual Type integrate(const scalar x1, const scalar x2) const
Integrate between two (scalar) values.
Definition: TimeFunction1.C:106
Foam::TimeFunction1::value
virtual Type value(const scalar x) const
Return value as a function of (scalar) independent variable.
Definition: TimeFunction1.C:98
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::TimeFunction1::~TimeFunction1
virtual ~TimeFunction1()=default
Destructor.
Time.H
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::TimeFunction1::time_
const Time & time_
Reference to the time database.
Definition: TimeFunction1.H:67
Foam::TimeFunction1::reset
void reset(const dictionary &dict)
Reset entry by re-reading from dictionary.
Definition: TimeFunction1.C:83
Foam::TimeFunction1::name
const word & name() const
Return the name of the entry.
Definition: TimeFunction1.C:91
x
x
Definition: LISASMDCalcMethod2.H:52
TimeFunction1.C
Foam::TimeFunction1::writeData
virtual void writeData(Ostream &os) const
Write in dictionary format.
Definition: TimeFunction1.C:133
Foam::TimeFunction1::entry_
autoPtr< Function1< Type > > entry_
The underlying Function1.
Definition: TimeFunction1.H:73
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56