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<Field0Type>::storeOldTimesInner();
55 tfield0_.ref() = field();
56 tfield0_.ref().OldTimeField<Field0Type>::timeIndex_ = timeIndex_;
60 if (tfield0_().OldTimeField<Field0Type>::tfield0_.
valid())
62 tfield0_.ref().writeOpt() = field().writeOpt();
74 template<
class FieldType>
77 if (tfield0_.valid() &&
notNull(tfield0_()))
79 if (tfield0_().OldTimeField<Field0Type>::tfield0_.
valid())
81 tfield0_.ref().OldTimeField<Field0Type>::nullOldestTimeInner();
85 tfield0_ = tmp<Field0Type>(NullObjectRef<FieldType>());
91 template<
class FieldType>
92 template<
class OldTimeBaseField>
95 if (!tfield0_.valid())
97 otbf.tfield0_ = tmp<typename Field0Type::Base>();
101 otbf.tfield0_ = tmp<typename Field0Type::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 Field0Type(io0, field().
mesh());
142 tfield0_.ref().OldTimeField<Field0Type>::timeIndex_ = timeIndex_ - 1;
143 tfield0_.ref().OldTimeField<Field0Type>::setBase();
145 if (!tfield0_.ref().OldTimeField<Field0Type>::readOldTimeIfPresent())
147 tfield0_.ref().OldTimeField<Field0Type>::oldTime();
159 template<
class FieldType>
160 template<
template<
class>
class OtherPrimitiveField>
167 copyOldTimes(io.
name(), otf);
171 template<
class FieldType>
172 template<
template<
class>
class OtherPrimitiveField>
179 if (otf.tfield0_.valid() &&
notNull(otf.tfield0_()))
181 tfield0_ =
new Field0Type(newName +
"_0", otf.tfield0_());
189 template<
class FieldType>
197 template<
class FieldType>
200 timeIndex_(otf.timeIndex_),
205 tfield0_ =
new Field0Type(otf.tfield0_());
211 template<
class FieldType>
214 timeIndex_(otf.timeIndex_),
217 if (otf.tfield0_.valid() &&
notNull(otf.tfield0_()))
227 template<
class FieldType>
230 if (tfield0_.valid() &&
notNull(tfield0_()))
240 template<
class FieldType>
244 field().name().size() > 2
245 && field().name()(field().name().size() - 2, 2) ==
"_0";
249 template<
class FieldType>
252 return timeIndex_ == field().time().timeIndex();
256 template<
class FieldType>
260 if (!hasStoredOldTimes())
265 storeOldTimesInner();
269 timeIndex_ = field().time().timeIndex();
275 template<
class FieldType>
278 if (tfield0_.valid())
286 template<
class FieldType>
291 nullOldestTimeInner();
296 template<
class FieldType>
299 const bool includeNull
302 if (tfield0_.valid())
310 return tfield0_().nOldTimes(includeNull) + 1;
320 template<
class FieldType>
321 const typename Foam::OldTimeField<FieldType>::Field0Type&
324 if (!tfield0_.valid() ||
isNull(tfield0_()))
339 field().
name() +
"_0",
340 field().time().
name(),
344 field().registerObject()
360 template<
class FieldType>
361 typename Foam::OldTimeField<FieldType>::Field0Type&
369 return const_cast<Field0Type&
>(tfield0_());
373 template<
class FieldType>
374 const typename Foam::OldTimeField<FieldType>::Field0Type&
380 return n == 0 ? field() : oldTime().oldTime(
n - 1);
384 template<
class FieldType>
385 typename Foam::OldTimeField<FieldType>::Field0Type&
391 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.
void copyOldTimes(const IOobject &io, const OtherOldTime< OtherPrimitiveField > &)
Copy the old-times from the given field.
label nOldTimes(const bool includeNull=true) const
Return the number of old-time fields stored.
const Field0Type & oldTime() const
Return the old-time field.
Field0Type & oldTimeRef()
Return a non-const reference to the old-time field.
bool hasStoredOldTimes() const
Return whether old-time fields have been stored yet.
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,.
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.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
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.
bool notNull(const T &t)
Return true if t is not a reference to the nullObject of type T.
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
bool isNull(const T &t)
Return true if t is a reference to the nullObject of type T.