TimeFunction1.C
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 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "TimeFunction1.H"
29 
30 // * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * //
31 
32 template<class Type>
34 (
35  const Time& t,
36  const word& name,
37  const dictionary& dict
38 )
39 :
40  time_(t),
41  name_(name),
43 {
44  entry_->convertTimeBase(t);
45 }
46 
47 
48 template<class Type>
50 :
51  time_(t),
52  name_(name),
53  entry_(nullptr)
54 {}
55 
56 
57 template<class Type>
59 (
60  const TimeFunction1<Type>& tde
61 )
62 :
63  time_(tde.time_),
64  name_(tde.name_),
65  entry_()
66 {
67  if (tde.entry_.valid())
68  {
69  entry_.reset(tde.entry_->clone().ptr());
70  }
71 }
72 
73 
74 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
75 
76 template<class Type>
78 {}
79 
80 
81 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
82 
83 template<class Type>
85 {
86  entry_.reset
87  (
89  (
90  name_,
91  dict
92  ).ptr()
93  );
94 
95  entry_->convertTimeBase(time_);
96 }
97 
98 
99 template<class Type>
101 {
102  return entry_->name();
103 }
104 
105 
106 template<class Type>
107 Type Foam::TimeFunction1<Type>::value(const scalar x) const
108 {
109  return entry_->value(x);
110 }
111 
112 
113 template<class Type>
115 (
116  const scalar x1,
117  const scalar x2
118 ) const
119 {
120  return entry_->integrate(x1, x2);
121 }
122 
123 
124 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
125 
126 template<class Type>
127 Foam::Ostream& Foam::operator<<
128 (
129  Ostream& os,
130  const TimeFunction1<Type>& de
131 )
132 {
133  return de.entry_->operator<<(os, de);
134 }
135 
136 
137 template<class Type>
139 {
140  entry_->writeData(os);
141 }
142 
143 
144 // ************************************************************************* //
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:62
Foam::TimeFunction1::TimeFunction1
TimeFunction1(const Time &t, const word &name, const dictionary &dict)
Construct from entry name.
Definition: TimeFunction1.C:34
Foam::TimeFunction1
Light wrapper around Function1 to provide a mechanism to update time-based entries.
Definition: ConeNozzleInjection.H:80
Foam::TimeFunction1::name_
const word name_
Name of the data entry.
Definition: TimeFunction1.H:73
Foam::TimeFunction1::integrate
virtual Type integrate(const scalar x1, const scalar x2) const
Integrate between two (scalar) values.
Definition: TimeFunction1.C:115
Foam::Function1
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: Function1.H:56
Foam::TimeFunction1::value
virtual Type value(const scalar x) const
Return value as a function of (scalar) independent variable.
Definition: TimeFunction1.C:107
Foam::TimeFunction1::~TimeFunction1
virtual ~TimeFunction1()
Destructor.
Definition: TimeFunction1.C:77
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
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:121
Foam::TimeFunction1::time_
const Time & time_
Reference to the time database.
Definition: TimeFunction1.H:70
Foam::TimeFunction1::reset
void reset(const dictionary &dict)
Reset entry by re-reading from dictionary.
Definition: TimeFunction1.C:84
Foam::TimeFunction1::name
const word & name() const
Return the name of the entry.
Definition: TimeFunction1.C:100
x
x
Definition: LISASMDCalcMethod2.H:52
Foam::TimeFunction1::writeData
virtual void writeData(Ostream &os) const
Write in dictionary format.
Definition: TimeFunction1.C:138
Foam::TimeFunction1::entry_
autoPtr< Function1< Type > > entry_
The underlying Function1.
Definition: TimeFunction1.H:76
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
TimeFunction1.H