32 template<
class ZoneType,
class ZonesType,
class MeshType>
37 readOpt() == IOobject::MUST_READ
38 || readOpt() == IOobject::MUST_READ_IF_MODIFIED
39 || (readOpt() == IOobject::READ_IF_PRESENT && headerOk())
42 if (readOpt() == IOobject::MUST_READ_IF_MODIFIED)
45 <<
"Specified IOobject::MUST_READ_IF_MODIFIED but class"
46 <<
" does not support automatic rereading."
50 PtrListDictionary<ZoneType>& zones = *
this;
53 Istream& is = readStream(ZonesType::typeName);
55 PtrList<entry> patchEntries(is);
56 zones.setSize(patchEntries.size());
63 patchEntries[zi].keyword(),
66 patchEntries[zi].keyword(),
67 patchEntries[zi].
dict(),
68 static_cast<const ZonesType&
>(*
this)
77 "(const IOobject&, const MeshType&)"
94 template<
class ZoneType,
class ZonesType,
class MeshType>
111 template<
class ZoneType,
class ZonesType,
class MeshType>
120 template<
class ZoneType,
class ZonesType,
class MeshType>
128 if (this->
operator[](zi).localIndex(objectIndex) != -1)
138 template<
class ZoneType,
class ZonesType,
class MeshType>
141 const label objectIndex
148 if (this->
operator[](zi).localIndex(objectIndex) != -1)
158 template<
class ZoneType,
class ZonesType,
class MeshType>
167 lst[zi] = zones[zi].type();
174 template<
class ZoneType,
class ZonesType,
class MeshType>
183 if (
found(zonePtr->name()))
185 zones[zonePtr->name()] = *zonePtr;
190 zones.PtrListDictionary<ZoneType>::append
199 template<
class ZoneType,
class ZonesType,
class MeshType>
208 if (
found(zone.name()))
210 zones[zone.name()] = zone;
214 zones.PtrListDictionary<ZoneType>::append
223 template<
class ZoneType,
class ZonesType,
class MeshType>
230 zones[zi].clearAddressing();
235 template<
class ZoneType,
class ZonesType,
class MeshType>
243 template<
class ZoneType,
class ZonesType,
class MeshType>
249 bool inError =
false;
255 inError |= zones[zi].checkDefinition(report);
261 template<
class ZoneType,
class ZonesType,
class MeshType>
267 if (!Pstream::parRun())
275 bool hasError =
false;
279 allNames[Pstream::myProcNo()] = this->toc();
280 Pstream::gatherList(allNames);
281 Pstream::scatterList(allNames);
284 allTypes[Pstream::myProcNo()] = this->types();
285 Pstream::gatherList(allTypes);
286 Pstream::scatterList(allTypes);
290 for (
label proci = 1; proci < allNames.
size(); proci++)
294 (allNames[proci] != allNames[0])
295 || (allTypes[proci] != allTypes[0])
300 if (debug || (report && Pstream::master()))
302 Info<<
" ***Inconsistent zones across processors, "
303 "processor 0 has zone names:" << allNames[0]
304 <<
" zone types:" << allTypes[0]
305 <<
" processor " << proci <<
" has zone names:"
307 <<
" zone types:" << allTypes[proci]
318 if (zones[zi].checkParallelSync(
false))
322 if (debug || (report && Pstream::master()))
324 Info<<
" ***Zone " << zones[zi].name()
325 <<
" of type " << zones[zi].type()
326 <<
" is not correctly synchronised"
327 <<
" across coupled boundaries."
328 <<
" (coupled faces are either not both"
329 <<
" present in set or have same flipmap)" <<
endl;
339 template<
class ZoneType,
class ZonesType,
class MeshType>
347 if (zonesIndices.
size() != zones.size())
350 <<
"zonesIndices.size() " << zonesIndices.
size()
351 <<
" != number of zones " << zones.size()
355 forAll(zonesIndices, zonei)
357 zones[zonei].
insert(zonesIndices[zonei]);
362 template<
class ZoneType,
class ZonesType,
class MeshType>
372 zones[zi].movePoints(
p);
377 template<
class ZoneType,
class ZonesType,
class MeshType>
387 zones[zi].topoChange(map);
392 template<
class ZoneType,
class ZonesType,
class MeshType>
402 zones[zi].mapMesh(map);
407 template<
class ZoneType,
class ZonesType,
class MeshType>
417 zones[zi].distribute(map);
422 template<
class ZoneType,
class ZonesType,
class MeshType>
426 otherZones.clearAddressing();
434 const label ozi = otherZones.findIndex(zones[zi].
name());
450 otherZones[ozi].
name(),
451 otherZones[ozi].
clone
453 static_cast<const ZonesType&
>(*
this)
456 otherZones.set(ozi, otherZones[ozi].
name(),
nullptr);
460 zones[zi].swap(otherZones[ozi]);
466 otherZones.PtrListDictionary<ZoneType>::append
468 zones[toOtherZone[i]].
name(),
469 zones[toOtherZone[i]].
clone(otherZones)
471 zones.
set(toOtherZone[i], zones[toOtherZone[i]].
name(),
nullptr);
479 template<
class ZoneType,
class ZonesType,
class MeshType>
482 readOpt() = IOobject::READ_IF_PRESENT;
487 template<
class ZoneType,
class ZonesType,
class MeshType>
495 template<
class ZoneType,
class ZonesType,
class MeshType>
506 return regIOobject::writeObject(fmt, ver, cmp,
write);
517 template<
class ZoneType,
class ZonesType,
class MeshType>
524 os << zones.size() <<
nl << token::BEGIN_LIST;
528 zones[zi].writeDict(os);
531 os << token::END_LIST;
#define forAll(list, i)
Loop across all elements in list.
void insert(const word &, T *)
Add at head of dictionary.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
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,...
Template dictionary class which manages the storage associated with it.
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.
void append(ZoneType *) const
Append or update a zone.
bool checkDefinition(const bool report=false) const
Check zone definition. Return true if in error.
void insert(const List< labelHashSet > &zonesIndices)
Insert given indices into zones.
virtual bool writeData(Ostream &) const
writeData member function required by regIOobject
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.
wordList types() const
Return a list of zone types.
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.
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.
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...
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.
autoPtr< CompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const viscosity &viscosity)
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.
word name(const bool)
Return a word representation of a bool.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.