33 template<
class ZoneType,
class ZonesType,
class MeshType>
38 readOpt() == IOobject::MUST_READ
39 || readOpt() == IOobject::MUST_READ_IF_MODIFIED
40 || (readOpt() == IOobject::READ_IF_PRESENT && headerOk())
43 if (readOpt() == IOobject::MUST_READ_IF_MODIFIED)
46 <<
"Specified IOobject::MUST_READ_IF_MODIFIED but class"
47 <<
" does not support automatic rereading."
51 PtrListDictionary<ZoneType>& zones = *
this;
54 Istream& is = readStream(ZonesType::typeName);
56 PtrList<entry> patchEntries(is);
57 zones.setSize(patchEntries.size());
64 patchEntries[zi].keyword(),
67 patchEntries[zi].keyword(),
68 patchEntries[zi].
dict(),
69 static_cast<const ZonesType&
>(*
this)
78 "(const IOobject&, const MeshType&)"
95 template<
class ZoneType,
class ZonesType,
class MeshType>
113 template<
class ZoneType,
class ZonesType,
class MeshType>
122 template<
class ZoneType,
class ZonesType,
class MeshType>
125 const label objectIndex
130 if (this->
operator[](zi).localIndex(objectIndex) != -1)
140 template<
class ZoneType,
class ZonesType,
class MeshType>
157 template<
class ZoneType,
class ZonesType,
class MeshType>
160 const label objectIndex
167 if (this->
operator[](zi).localIndex(objectIndex) != -1)
177 template<
class ZoneType,
class ZonesType,
class MeshType>
181 const bool warnNotFound
186 if (zoneNames.
size())
199 else if (warnNotFound)
202 <<
"Cannot find zone " << zoneNames[i]
212 template<
class ZoneType,
class ZonesType,
class MeshType>
221 if (
found(zonePtr->name()))
223 zones[zonePtr->name()] = *zonePtr;
228 zones.PtrListDictionary<ZoneType>::append
241 template<
class ZoneType,
class ZonesType,
class MeshType>
250 if (
found(zone.name()))
252 zones[zone.name()] = zone;
256 zones.PtrListDictionary<ZoneType>::append
269 template<
class ZoneType,
class ZonesType,
class MeshType>
276 zones[zi].clearAddressing();
281 template<
class ZoneType,
class ZonesType,
class MeshType>
289 template<
class ZoneType,
class ZonesType,
class MeshType>
295 bool inError =
false;
301 inError |= zones[zi].checkDefinition(report);
307 template<
class ZoneType,
class ZonesType,
class MeshType>
313 if (!Pstream::parRun())
321 bool hasError =
false;
325 allNames[Pstream::myProcNo()] = this->toc();
326 Pstream::gatherList(allNames);
327 Pstream::scatterList(allNames);
331 for (
label proci = 1; proci < allNames.
size(); proci++)
335 (allNames[proci] != allNames[0])
340 if (debug || (report && Pstream::master()))
342 Info<<
" ***Inconsistent zones across processors, "
343 "processor 0 has zone names:" << allNames[0]
344 <<
" processor " << proci <<
" has zone names:"
356 if (zones[zi].checkParallelSync(
false))
360 if (debug || (report && Pstream::master()))
362 Info<<
" ***Zone " << zones[zi].name()
363 <<
" is not correctly synchronised"
364 <<
" across coupled boundaries."
365 <<
" (coupled faces are either not both"
366 <<
" present in set or have same flipmap)" <<
endl;
376 template<
class ZoneType,
class ZonesType,
class MeshType>
384 if (zonesIndices.
size() != zones.size())
387 <<
"zonesIndices.size() " << zonesIndices.
size()
388 <<
" != number of zones " << zones.size()
392 forAll(zonesIndices, zonei)
394 zones[zonei].
insert(zonesIndices[zonei]);
397 timeIndex_ = time().timeIndex();
401 template<
class ZoneType,
class ZonesType,
class MeshType>
408 if (!zones[zi].topoUpdate())
418 template<
class ZoneType,
class ZonesType,
class MeshType>
428 zones[zi].movePoints(
p);
433 template<
class ZoneType,
class ZonesType,
class MeshType>
443 zones[zi].topoChange(map);
448 const label allSize =
static_cast<const ZonesType&
>(*this).allSize();
449 if (
all().size() != allSize)
453 static_cast<const ZonesType&
>(*this).allSize()
458 timeIndex_ = time().timeIndex();
462 template<
class ZoneType,
class ZonesType,
class MeshType>
472 zones[zi].mapMesh(map);
477 timeIndex_ = time().timeIndex();
481 template<
class ZoneType,
class ZonesType,
class MeshType>
491 zones[zi].distribute(map);
496 timeIndex_ = time().timeIndex();
500 template<
class ZoneType,
class ZonesType,
class MeshType>
504 otherZones.clearAddressing();
512 const label ozi = otherZones.findIndex(zones[zi].
name());
528 otherZones[ozi].
name(),
529 otherZones[ozi].
clone
531 static_cast<const ZonesType&
>(*
this)
534 otherZones.set(ozi, otherZones[ozi].
name(),
nullptr);
538 zones[zi].swap(otherZones[ozi]);
544 otherZones.PtrListDictionary<ZoneType>::append
546 zones[toOtherZone[i]].
name(),
547 zones[toOtherZone[i]].
clone(otherZones)
549 zones.
set(toOtherZone[i], zones[toOtherZone[i]].
name(),
nullptr);
555 timeIndex_ = time().timeIndex();
559 template<
class ZoneType,
class ZonesType,
class MeshType>
562 readOpt() = IOobject::READ_IF_PRESENT;
567 template<
class ZoneType,
class ZonesType,
class MeshType>
575 template<
class ZoneType,
class ZonesType,
class MeshType>
586 return regIOobject::writeObject(fmt, ver, cmp,
write);
595 template<
class ZoneType,
class ZonesType,
class MeshType>
598 const ZonesType& zones =
static_cast<const ZonesType&
>(*this);
616 template<
class ZoneType,
class ZonesType,
class MeshType>
622 const ZoneType* ptr = lookupPtr(
name);
627 <<
"Cannot find " << ZoneType::typeName <<
" " <<
name
635 template<
class ZoneType,
class ZonesType,
class MeshType>
641 ZoneType* ptr = this->lookupPtr(
name);
646 <<
"Cannot find " << ZoneType::typeName <<
" " <<
name
656 template<
class ZoneType,
class ZonesType,
class MeshType>
663 os << zones.size() <<
nl << token::BEGIN_LIST;
667 zones[zi].writeDict(os);
670 os << token::END_LIST;
#define forAll(list, i)
Loop across all elements in list.
void insert(const word &, T *)
Add at head of dictionary.
void clear()
Clear the dictionary.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
bool insert(const Key &key)
Insert a new entry.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
streamFormat
Enumeration for the format of data in the stream.
compressionType
Enumeration for the format of data in the stream.
bool good() const
Return true if next operation might succeed.
void append(const T &)
Append an element at the end of the list.
void size(const label)
Override size to be inconsistent with allocated storage.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
void append(const word &key, T *)
Append an element at the end of the list.
autoPtr< T > set(const label, const word &key, T *)
Set element to pointer provided and return old element.
label timeIndex() const
Return current time index.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
label size() const
Return the number of elements in the UList.
bool checkDefinition(const bool report=false) const
Check zone definition. Return true if in error.
const ZoneType & all() const
Return const reference to the all zone.
void insert(const List< labelHashSet > &zonesIndices)
Insert given indices into zones.
virtual bool writeData(Ostream &) const
writeData member function required by regIOobject
const ZoneType & append(ZoneType *) const
Append or update a zone.
bool found(const label objectIndex) const
Return true if objectIndex is in any zone.
ZoneList(const IOobject &, const MeshType &)
Read constructor given IOobject and a MeshType reference.
bool noTopoUpdate() const
Return true if any of the zones were not updated by zoneGenerators.
bool readIfPresent()
Read zones if the zones file is present.
virtual bool writeObject(IOstream::streamFormat, IOstream::versionNumber, IOstream::compressionType, const bool write) const
Write using given format, version and compression.
labelList whichZones(const label objectIndex) const
Given a global object index, return the list of zones it is in.
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
labelHashSet zoneSet(const UList< wordRe > &zoneNames, const bool warnNotFound=true) const
Return the set of zone indices corresponding to the given names.
void swap(ZonesType &)
Swap zones.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
void clearAddressing()
Clear addressing.
virtual void movePoints(const pointField &)
Correct zones after moving points.
void clear()
Clear the zones.
bool checkParallelSync(const bool report=false) const
Check whether all procs have all zones and in same order. Return.
virtual void topoChange(const polyTopoChangeMap &map)
Update topology using the given map.
const ZoneType * lookupPtr(const word &name) const
Return const reference to ZoneType by name.
const Time & time() const
Return the top-level database.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
A class for handling words, derived from string.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
Template functions to aid in the implementation of demand driven data.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define WarningInFunction
Report a warning using Foam::Warning.
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
errorManipArg< error, int > exit(error &err, const int errNo=1)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
labelList findIndices(const ListType &, typename ListType::const_reference, const label start=0)
Find all occurrences of given element. Linear search.
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
labelList identityMap(const label len)
Create identity map (map[i] == i) of given length.