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 -------------------------------------------------------------------------------
11 License
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 Class
28  Foam::expressions::exprResultDelayed
29 
30 Description
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 
44 SourceFiles
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 
58 namespace Foam
59 {
60 namespace expressions
61 {
62 
63 /*---------------------------------------------------------------------------*\
64  Class exprResultDelayed Declaration
65 \*---------------------------------------------------------------------------*/
66 
67 class 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 
98 protected:
99 
100  // Protected Member Functions
101 
102  //- Simulate virtual templated methods
103  inline expressions::exprResult& target() { return settingResult_; }
104 
105 
106 public:
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  {
126  return autoPtr<exprResult>
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_;
143  }
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 
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 
181 
182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183 
184 } // End namespace expressions
185 
186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187 
188 inline 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 // ************************************************************************* //
Foam::expressions::exprResultDelayed::exprResultDelayed
exprResultDelayed()
Default construct.
Definition: exprResultDelayed.C:65
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Tuple2.H
exprString.H
Foam::expressions::exprResultDelayed::setReadValue
void setReadValue(const exprResult &val)
Set the readValue with a calculated value.
Definition: exprResultDelayed.C:175
Foam::operator>>
Istream & operator>>(Istream &, directionInfo &)
Definition: directionInfo.C:230
Foam::expressions::exprResultDelayed::updateReadValue
bool updateReadValue(const scalar &timeVal)
Update the read-value.
Definition: exprResultDelayed.C:114
Foam::expressions::exprResultDelayed::storeValue
void storeValue(const scalar &timeVal)
Add a stored value.
Definition: exprResultDelayed.C:184
Foam::LList
Template class for non-intrusive linked lists.
Definition: LList.H:54
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::expressions::exprResult
A polymorphic field/result from evaluating an expression.
Definition: exprResult.H:124
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::expressions::exprResultDelayed::~exprResultDelayed
virtual ~exprResultDelayed()=default
Destructor.
Foam::expressions::exprResultDelayed::writeDict
void writeDict(Ostream &os) const
Definition: exprResultDelayed.C:241
Foam::expressions::exprResultDelayed
An exprResult with an additional delay before evaluation.
Definition: exprResultDelayed.H:101
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:123
os
OBJstream os(runTime.globalPath()/outputName)
Foam::expressions::exprResultDelayed::target
expressions::exprResult & target()
Simulate virtual templated methods.
Definition: exprResultDelayed.H:137
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::expressions::exprResultDelayed::startupValueExpression
const expressions::exprString & startupValueExpression() const
The initial value expression.
Definition: exprResultDelayed.H:180
Foam::expressions::exprString
Definition: exprString.H:60
Foam::expressions::exprResultDelayed::operator=
void operator=(const exprResultDelayed &rhs)
Copy assignment.
Definition: exprResultDelayed.C:268
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::Tuple2
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
Definition: stringOps.H:60
Foam::expressions::exprResultDelayed::TypeNameNoDebug
TypeNameNoDebug("exprResultDelayed")
Runtime type information.
exprResult.H
Foam::data
Database for solution data, solver performance and other reduced data.
Definition: data.H:55
Foam::expressions::exprResultDelayed::clone
virtual autoPtr< exprResult > clone() const
Clone.
Definition: exprResultDelayed.H:158
Foam::expressions::exprResultDelayed::name
const word & name() const
The expression name.
Definition: exprResultDelayed.H:174