exprResultDelayed.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-2018 Bernhard Gschaider <bgschaid@hfd-research.com>
9 Copyright (C) 2019-2020 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
27Class
28 Foam::expressions::exprResultDelayed
29
30Description
31 An exprResult with an additional delay before evaluation
32
33 \heading Dictionary parameters
34 \table
35 Property | Description | Required | Default
36 name | The result name | yes |
37 delay | The delay before starting | yes |
38 storeInterval | The storage interval (time) | yes |
39 startupValue | The initial startup value | yes |
40 value | The expression result (dictionary) | no |
41 storedValues | The list of stored values | yes |
42 \endtable
43
44SourceFiles
45 exprResultDelayed.C
46
47\*---------------------------------------------------------------------------*/
48
49#ifndef expressions_exprResultDelayed_H
50#define expressions_exprResultDelayed_H
51
52#include "exprResult.H"
53#include "exprString.H"
54#include "Tuple2.H"
55
56// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57
58namespace Foam
59{
60namespace expressions
61{
62
63/*---------------------------------------------------------------------------*\
64 Class exprResultDelayed Declaration
65\*---------------------------------------------------------------------------*/
66
67class exprResultDelayed
68:
69 public expressions::exprResult
70{
71 // Typedefs
72
73 //- Expression at a given time value.
74 typedef Tuple2<scalar, expressions::exprResult> ValueAtTime;
75
76
77 // Private Data
78
79 //- The name of the expression
80 word name_;
81
82 //- The initial value expression
83 expressions::exprString startExpr_;
84
85 //- The pending result to be set
86 expressions::exprResult settingResult_;
87
88 //- The old results
89 DLList<ValueAtTime> storedValues_;
90
91 //- How often values should be stored
92 scalar storeInterval_;
93
94 //- The size of the delay
95 scalar delay_;
96
97
98protected:
99
100 // Protected Member Functions
102 //- Simulate virtual templated methods
103 inline expressions::exprResult& target() { return settingResult_; }
104
105
106public:
107
108 //- Runtime type information
109 TypeNameNoDebug("exprResultDelayed");
110
111
112 // Constructors
113
114 //- Default construct
116
117 //- Copy construct
119
120 //- Construct from a dictionary
122
123 //- Clone
124 virtual autoPtr<exprResult> clone() const
125 {
127 (
128 new exprResultDelayed(*this)
129 );
130 }
131
132
133 //- Destructor
134 virtual ~exprResultDelayed() = default;
135
136
137 // Member Functions
138
139 //- The expression name
140 const word& name() const
141 {
142 return name_;
144
145 //- The initial value expression
147 {
148 return startExpr_;
149 }
150
151 //- Update the read-value
152 // return true if there was a valid value.
153 // this does not do the work of setReadValue because we have no
154 // access to the Parser
155 bool updateReadValue(const scalar& timeVal);
156
157 //- Set the readValue with a calculated value
158 void setReadValue(const exprResult& val);
159
160 //- Add a stored value
161 void storeValue(const scalar& timeVal);
162
163
164 // Write
165
166 void writeDict(Ostream& os) const;
167
169 // Member Operators
170
171 //- Copy assignment
172 void operator=(const exprResultDelayed& rhs);
173
174 //- Copy assignment
175 void operator=(const exprResult& rhs);
176
177 //- Move assignment
178 void operator=(exprResult&& rhs);
179};
181
182// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183
184} // End namespace expressions
185
186// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187
188inline bool operator!=
189(
192)
193{
194 return false;
195}
196
197// IO Operators
200
201
202// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203
204} // End namespace Foam
205
206// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207
208#endif
209
210// ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
Template class for non-intrusive linked lists.
Definition: LList.H:79
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
Definition: Tuple2.H:58
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
Database for solution data, solver performance and other reduced data.
Definition: data.H:58
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
An exprResult with an additional delay before evaluation.
void storeValue(const scalar &timeVal)
Add a stored value.
expressions::exprResult & target()
Simulate virtual templated methods.
const word & name() const
The expression name.
void operator=(const exprResultDelayed &rhs)
Copy assignment.
bool updateReadValue(const scalar &timeVal)
Update the read-value.
virtual autoPtr< exprResult > clone() const
Clone.
const expressions::exprString & startupValueExpression() const
The initial value expression.
virtual ~exprResultDelayed()=default
Destructor.
TypeNameNoDebug("exprResultDelayed")
Runtime type information.
void setReadValue(const exprResult &val)
Set the readValue with a calculated value.
A polymorphic field/result from evaluating an expression.
Definition: exprResult.H:127
A class for handling words, derived from Foam::string.
Definition: word.H:68
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Istream & operator>>(Istream &, directionInfo &)
dictionary dict
#define TypeNameNoDebug(TypeNameString)
Declare a ClassNameNoDebug() with extra virtual type info.
Definition: typeInfo.H:68