TimeDataEntry.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 | Copyright (C) 2012-2013 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 \*---------------------------------------------------------------------------*/
25 
26 #include "TimeDataEntry.H"
27 
28 // * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * //
29 
30 template<class Type>
32 (
33  const Time& t,
34  const word& name,
35  const dictionary& dict
36 )
37 :
38  time_(t),
39  name_(name),
41 {
42  entry_->convertTimeBase(t);
43 }
44 
45 
46 template<class Type>
48 :
49  time_(t),
50  name_(name),
51  entry_(NULL)
52 {}
53 
54 
55 template<class Type>
57 (
58  const TimeDataEntry<Type>& tde
59 )
60 :
61  time_(tde.time_),
62  name_(tde.name_),
63  entry_()
64 {
65  if (tde.entry_.valid())
66  {
67  entry_.reset(tde.entry_->clone().ptr());
68  }
69 }
70 
71 
72 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
73 
74 template<class Type>
76 {}
77 
78 
79 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
80 
81 template<class Type>
83 {
84  entry_.reset
85  (
87  (
88  name_,
89  dict
90  ).ptr()
91  );
92 
93  entry_->convertTimeBase(time_);
94 }
95 
96 
97 template<class Type>
99 {
100  return entry_->name();
101 }
102 
103 
104 template<class Type>
105 Type Foam::TimeDataEntry<Type>::value(const scalar x) const
106 {
107  return entry_->value(x);
108 }
109 
110 
111 template<class Type>
113 (
114  const scalar x1,
115  const scalar x2
116 ) const
117 {
118  return entry_->integrate(x1, x2);
119 }
120 
121 
122 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
123 
124 template<class Type>
125 Foam::Ostream& Foam::operator<<
126 (
127  Ostream& os,
128  const TimeDataEntry<Type>& de
129 )
130 {
131  return de.entry_->operator<<(os, de);
132 }
133 
134 
135 template<class Type>
137 {
138  entry_->writeData(os);
139 }
140 
141 
142 // ************************************************************************* //
Foam::TimeDataEntry::TimeDataEntry
TimeDataEntry(const Time &t, const word &name, const dictionary &dict)
Construct from entry name.
Definition: TimeDataEntry.C:32
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
Foam::TimeDataEntry::reset
void reset(const dictionary &dict)
Reset entry by re-reading from dictionary.
Definition: TimeDataEntry.C:82
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::TimeDataEntry::time_
const Time & time_
Reference to the time database.
Definition: TimeDataEntry.H:68
Foam::TimeDataEntry::writeData
virtual void writeData(Ostream &os) const
Write in dictionary format.
Definition: TimeDataEntry.C:136
Foam::TimeDataEntry::value
virtual Type value(const scalar x) const
Return value as a function of (scalar) independent variable.
Definition: TimeDataEntry.C:105
Foam::TimeDataEntry::integrate
virtual Type integrate(const scalar x1, const scalar x2) const
Integrate between two (scalar) values.
Definition: TimeDataEntry.C:113
Foam::TimeDataEntry
Light wrapper around DataEntry to provide a mechanism to update time-based entries.
Definition: ConeNozzleInjection.H:64
Foam::TimeDataEntry::entry_
autoPtr< DataEntry< Type > > entry_
The underlying DataEntry.
Definition: TimeDataEntry.H:74
TimeDataEntry.H
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::TimeDataEntry::~TimeDataEntry
virtual ~TimeDataEntry()
Destructor.
Definition: TimeDataEntry.C:75
Foam::TimeDataEntry::name_
const word name_
Name of the data entry.
Definition: TimeDataEntry.H:71
Foam::TimeDataEntry::name
const word & name() const
Return the name of the entry.
Definition: TimeDataEntry.C:98
x
x
Definition: LISASMDCalcMethod2.H:52
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::DataEntry
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: DataEntry.H:52
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47