83 startExpr_(rhs.startExpr_),
84 settingResult_(rhs.settingResult_),
85 storedValues_(rhs.storedValues_),
86 storeInterval_(rhs.storeInterval_),
98 startExpr_(
"startupValue",
dict),
99 storeInterval_(
dict.
get<scalar>(
"storeInterval")),
100 delay_(
dict.
get<scalar>(
"delay"))
115 const scalar& timeVal
118 if (storedValues_.empty())
123 if (storedValues_.front().first() > (timeVal-delay_))
129 if (storedValues_.size() <= 1)
132 <<
"Only one stored value at time " << timeVal
133 <<
" for delayedVariable " <<
name() <<
nl 134 <<
"Check the values for the interval " << storeInterval_
135 <<
" and delay " << delay_ <<
nl 136 <<
"Probably the interval is too large" <<
nl <<
endl 140 auto current = storedValues_.cbegin();
145 const scalar newTime = (timeVal - delay_);
147 while (next != storedValues_.end())
149 if (newTime >= current().first() && newTime <= next().first())
160 (newTime - current().first())
161 / (next().first() - current().first())
164 exprResult val((1-
f)*current().second() +
f*next().second());
183 const scalar& currTime
186 bool append = storedValues_.empty();
190 const scalar lastTime = storedValues_.back().first();
192 if (lastTime + SMALL >= currTime)
196 else if ((currTime - lastTime) >= 0.999*storeInterval_)
211 const scalar oldLastTime =
213 storedValues_.empty()
215 : storedValues_.back().first()
218 storedValues_.push_back(ValueAtTime(currTime, settingResult_));
222 storedValues_.size() > 1
223 && (oldLastTime - storedValues_.front().first()) >= delay_
227 storedValues_.pop_front();
234 storedValues_.back().second() = settingResult_;
243 os.writeEntry(
"name", name_);
245 os.writeEntry(
"startupValue", startExpr_);
247 if (!settingResult_.valueType().empty())
249 os.writeEntry(
"settingResult", settingResult_);
252 os.writeEntry(
"storedValues", storedValues_);
253 os.writeEntry(
"storeInterval", storeInterval_);
254 os.writeEntry(
"delay", delay_);
256 os.writeKeyword(
"value");
257 os << static_cast<const exprResult&>(*this);
265 void Foam::expressions::exprResultDelayed::operator=
278 startExpr_ = rhs.startExpr_;
279 settingResult_ = rhs.settingResult_;
280 storedValues_ = rhs.storedValues_;
281 storeInterval_ = rhs.storeInterval_;
286 void Foam::expressions::exprResultDelayed::operator=
291 settingResult_ = rhs;
295 void Foam::expressions::exprResultDelayed::operator=
300 settingResult_ = std::move(rhs);
309 expressions::exprResultDelayed& data
323 const expressions::exprResultDelayed& data
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
void setReadValue(const exprResult &val)
Set the readValue with a calculated value.
bool updateReadValue(const scalar &timeVal)
Update the read-value.
exprResultDelayed()
Default construct.
errorManipArg< error, int > exit(error &err, const int errNo=1)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
A polymorphic field/result from evaluating an expression.
Template class for non-intrusive linked lists.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Macros for easy insertion into run-time selection tables.
void storeValue(const scalar &timeVal)
Add a stored value.
defineTypeName(fvExprDriverWriter)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
A class for handling words, derived from Foam::string.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
void writeDict(Ostream &os) const
OBJstream os(runTime.globalPath()/outputName)
An exprResult with an additional delay before evaluation.
addToRunTimeSelectionTable(exprResult, exprResult, dictionary)
rAUs append(new volScalarField(IOobject::groupName("rAU", phase1.name()), 1.0/(U1Eqn.A()+byDt(max(phase1.residualAlpha() - alpha1, scalar(0)) *rho1))))
virtual bool isStream() const noexcept
True if this entry is a stream.
virtual void operator=(const exprResult &rhs)
Copy assignment.
virtual ITstream & stream() const =0
Return token stream, if entry is a primitive entry.
A keyword and a list of tokens is an 'entry'.