Loading...
Searching...
No Matches
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
9 Copyright (C) 2019-2023 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 Foam_expressions_exprResultDelayed_H
50#define Foam_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
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
98protected:
99
100 // Protected Member Functions
101
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 noexcept
141 {
142 return name_;
143 }
144
145 //- The initial value expression
146 const expressions::exprString& startupValueExpression() const noexcept
147 {
148 return startExpr_;
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
168
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
180 //- Compare for inequality (need by Ulist)
181 bool operator!=(const exprResultDelayed& rhs) const noexcept
182 {
183 return (this != &rhs);
184 }
185};
186
187
188// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
189
190} // End namespace expressions
191
192// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
193
194
195// IO Operators
198
199
200// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201
202} // End namespace Foam
203
204// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
205
206#endif
207
208// ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
Definition Tuple2.H:51
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
An exprResult with an additional delay before evaluation.
void storeValue(const scalar &timeVal)
Add a stored value.
expressions::exprResult & target()
Simulate virtual templated methods.
bool operator!=(const exprResultDelayed &rhs) const noexcept
Compare for inequality (need by Ulist).
void operator=(const exprResultDelayed &rhs)
Copy assignment.
bool updateReadValue(const scalar &timeVal)
Update the read-value.
virtual autoPtr< exprResult > clone() const
Clone.
virtual ~exprResultDelayed()=default
Destructor.
const word & name() const noexcept
The expression name.
TypeNameNoDebug("exprResultDelayed")
Runtime type information.
void setReadValue(const exprResult &val)
Set the readValue with a calculated value.
const expressions::exprString & startupValueExpression() const noexcept
The initial value expression.
A polymorphic field/result from evaluating an expression.
Definition exprResult.H:122
exprResult()
Default construct.
Definition exprResult.C:173
A variant of Foam::string with expansion of dictionary variables into a comma-separated form.
Definition exprString.H:58
A class for handling words, derived from Foam::string.
Definition word.H:66
OBJstream os(runTime.globalPath()/outputName)
A namespace for expression-related classes/traits etc.
Namespace for OpenFOAM.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
Istream & operator>>(Istream &, directionInfo &)
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
const direction noexcept
Definition scalarImpl.H:265
LList< DLListBase, T > DLList
Definition DLList.H:39
dictionary dict
#define TypeNameNoDebug(TypeNameString)
Declare a ClassNameNoDebug() with extra virtual type info.
Definition typeInfo.H:61