30 template<
class FieldType>
33 return static_cast<const FieldType&
>(*this);
37 template<
class FieldType>
40 return static_cast<FieldType&
>(*this);
44 template<
class FieldType>
52 tfield0_.ref().OldTimeField<FieldType>::storeOldTimesInner();
55 tfield0_.ref() == field();
56 tfield0_.ref().OldTimeField<FieldType>::timeIndex_ = timeIndex_;
60 if (tfield0_().OldTimeField<FieldType>::tfield0_.
valid())
62 tfield0_.ref().writeOpt() = field().writeOpt();
74 template<
class FieldType>
77 if (tfield0_.valid() &&
notNull(tfield0_()))
79 if (tfield0_().OldTimeField<FieldType>::tfield0_.
valid())
81 tfield0_.ref().OldTimeField<FieldType>::nullOldestTimeInner();
85 tfield0_ = tmp<FieldType>(NullObjectRef<FieldType>());
91 template<
class FieldType>
92 template<
class OldTimeBaseField>
95 if (!tfield0_.valid())
97 otbf.tfield0_.
clear();
101 otbf.tfield0_ = tmp<typename FieldType::Base>(tfield0_());
104 otbf.timeIndex_ = timeIndex_;
110 template<
class FieldType>
115 template<
class FieldType>
118 setBase(OldTimeBaseFieldType<FieldType>()(*
this));
124 template<
class FieldType>
129 field().
name() +
"_0",
130 field().time().
name(),
132 IOobject::READ_IF_PRESENT,
133 IOobject::AUTO_WRITE,
134 field().registerObject()
139 tfield0_ =
new FieldType(io0, field().mesh());
142 tfield0_.ref().OldTimeField<FieldType>::timeIndex_ = timeIndex_ - 1;
143 tfield0_.ref().OldTimeField<FieldType>::setBase();
145 if (!tfield0_.ref().OldTimeField<FieldType>::readOldTimeIfPresent())
147 tfield0_.ref().OldTimeField<FieldType>::oldTime();
159 template<
class FieldType>
166 copyOldTimes(io.
name(), otf);
170 template<
class FieldType>
179 tfield0_ =
new FieldType(newName +
"_0", otf.tfield0_());
187 template<
class FieldType>
195 template<
class FieldType>
198 timeIndex_(otf.timeIndex_),
203 tfield0_ =
new FieldType(otf.tfield0_());
209 template<
class FieldType>
212 timeIndex_(otf.timeIndex_),
225 template<
class FieldType>
228 if (tfield0_.valid() &&
notNull(tfield0_()))
238 template<
class FieldType>
242 field().name().size() > 2
243 && field().name()(field().name().size() - 2, 2) ==
"_0";
247 template<
class FieldType>
254 && timeIndex_ != field().time().
timeIndex()
258 storeOldTimesInner();
262 if (timeIndex_ != field().time().
timeIndex())
264 timeIndex_ = field().time().timeIndex();
270 template<
class FieldType>
273 if (tfield0_.valid() &&
notNull(tfield0_()))
280 template<
class FieldType>
285 nullOldestTimeInner();
290 template<
class FieldType>
293 const bool includeNull
296 if (tfield0_.valid())
304 return tfield0_->nOldTimes(includeNull) + 1;
314 template<
class FieldType>
317 if (!tfield0_.valid() ||
isNull(tfield0_()))
327 tfield0_ =
new FieldType
331 field().
name() +
"_0",
332 field().time().
name(),
336 field().registerObject()
352 template<
class FieldType>
360 return const_cast<FieldType&
>(tfield0_());
364 template<
class FieldType>
367 return n == 0 ? field() : oldTime().oldTime(
n - 1);
371 template<
class FieldType>
374 return n == 0 ? fieldRef() : oldTimeRef().oldTimeRef(
n - 1);
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
const word & name() const
Return name.
Class to add into field types to provide old-time storage and retrieval.
bool readOldTimeIfPresent()
Read old-time field from file if it is present.
friend class OldTimeField
Declare friendship with other old-time fields.
const FieldType & oldTime() const
Return the old time field.
label nOldTimes(const bool includeNull=true) const
Return the number of old time fields stored.
void copyOldTimes(const IOobject &io, const OldTimeField< FieldType > &otf)
Copy the old times from the given field.
FieldType & oldTimeRef()
Return a non-const reference to the old time field.
bool isOldTime() const
Return whether or not this is an old-time field.
void storeOldTimes() const
Store the old-time fields.
~OldTimeField()
Destructor.
void nullOldestTime()
Set the oldest field pointer to nullObjectPtr. This removes the.
void clearOldTimes()
Clear old time fields.
bool valid() const
Is this temporary object valid,.
void clear() const
If object pointer points to valid object:
Templated form of IOobject providing type information for file reading and header type checking.
bool headerOk()
Read header (uses typeGlobalFile to find file) and check.
A class for handling words, derived from string.
bool valid(const PtrList< ModelType > &l)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
word name(const bool)
Return a word representation of a bool.
bool notNull(const T &t)
Return true if t is not a reference to the nullObject of type T.
bool isNull(const T &t)
Return true if t is a reference to the nullObject of type T.