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 Copyright (C) 2020-2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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\*---------------------------------------------------------------------------*/
28
29#include "TimeFunction1.H"
30
31// * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * //
32
33template<class Type>
35(
36 const Time& runTime,
37 const word& entryName,
38 const dictionary& dict
39)
40:
41 time_(runTime),
42 name_(entryName),
43 entry_(Function1<Type>::New(entryName, dict, &runTime))
44{
45 // Time conversion now handled by Function1 directly
46 // entry_->userTimeToTime(runTime);
47}
48
49
50template<class Type>
52(
53 const Time& runTime,
54 const word& entryName
55)
56:
57 time_(runTime),
58 name_(entryName),
59 entry_(nullptr)
60{}
61
62
63template<class Type>
65(
66 const TimeFunction1<Type>& rhs
67)
68:
69 time_(rhs.time_),
70 name_(rhs.name_),
71 entry_(nullptr) // steal/reuse (missing clone!)
72{
73 if (rhs.entry_)
74 {
75 entry_.reset(rhs.entry_->clone().ptr());
76 }
77}
78
79
80// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
81
82template<class Type>
84{
85 entry_ = Function1<Type>::New(name_, dict, &time_);
86 entry_->userTimeToTime(time_);
87}
88
89
90template<class Type>
92{
93 return entry_->name();
94}
95
96
97template<class Type>
98Type Foam::TimeFunction1<Type>::value(const scalar x) const
99{
100 return entry_->value(x);
101}
102
103
104template<class Type>
106(
107 const scalar x1,
108 const scalar x2
109) const
110{
111 return entry_->integrate(x1, x2);
112}
113
114
115// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
116
117template<class Type>
118Foam::Ostream& Foam::operator<<
119(
120 Ostream& os,
121 const TimeFunction1<Type>& rhs
122)
123{
124 if (rhs.entry_)
125 {
126 rhs.entry_->operator<<(os, rhs);
127 }
128 return os;
129}
130
131
132template<class Type>
134{
135 entry_->writeData(os);
136}
137
138
139// ************************************************************************* //
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: Function1.H:96
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
Light wrapper around Function1 to provide a mechanism to update time-based entries.
Definition: TimeFunction1.H:61
virtual void writeData(Ostream &os) const
Write in dictionary format.
autoPtr< Function1< Type > > entry_
The underlying Function1.
Definition: TimeFunction1.H:73
virtual Type value(const scalar x) const
Return value as a function of (scalar) independent variable.
Definition: TimeFunction1.C:98
virtual Type integrate(const scalar x1, const scalar x2) const
Integrate between two (scalar) values.
const word & name() const
Return the name of the entry.
Definition: TimeFunction1.C:91
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
void reset()
Reset to defaults.
A class for handling words, derived from Foam::string.
Definition: word.H:68
engineTime & runTime
OBJstream os(runTime.globalPath()/outputName)
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
dictionary dict