40 template<
class ZoneType,
class MeshType>
50template<
class ZoneType,
class MeshType>
56 <<
"zone map already calculated"
64 const PtrList<ZoneType>& zones = *
this;
66 for (
const ZoneType& zn : zones)
68 nObjects += zn.
size();
71 zoneMapPtr_.reset(
new Map<label>(2*nObjects));
72 auto& zm = *zoneMapPtr_;
79 for (
const ZoneType& zn : zones)
83 for (
const label idx : labels)
85 zm.insert(idx, zonei);
94template<
class ZoneType,
class MeshType>
100 return !groupIDsPtr_->
empty();
103 const PtrList<ZoneType>& zones = *
this;
105 for (
const ZoneType& zn : zones)
107 if (!zn.inGroups().empty())
117template<
class ZoneType,
class MeshType>
126 auto& groupLookup = *groupIDsPtr_;
132 const wordList& groups = zones[zonei].inGroups();
134 for (
const word& groupName : groups)
143 if (groupLookup.erase(zones[zonei].name()))
146 <<
"Removed group '" << zones[zonei].name()
147 <<
"' which clashes with zone " << zonei
148 <<
" of the same name."
155template<
class ZoneType,
class MeshType>
160 readOpt() == IOobject::MUST_READ
161 || readOpt() == IOobject::MUST_READ_IF_MODIFIED
162 || (readOpt() == IOobject::READ_IF_PRESENT && headerOk())
166 warnNoRereading<ZoneMesh<ZoneType, MeshType>>();
184 patchEntries[zonei].keyword(),
185 patchEntries[zonei].
dict(),
204template<
class ZoneType,
class MeshType>
219template<
class ZoneType,
class MeshType>
236template<
class ZoneType,
class MeshType>
240 const MeshType&
mesh,
256 zones.
set(zonei, pzm[zonei].clone(*
this));
264template<
class ZoneType,
class MeshType>
273template<
class ZoneType,
class MeshType>
286template<
class ZoneType,
class MeshType>
289 const label objectIndex
292 return zoneMap().lookup(objectIndex, -1);
296template<
class ZoneType,
class MeshType>
303template<
class ZoneType,
class MeshType>
310template<
class ZoneType,
class MeshType>
313 return this->groupZoneIDs().sortedToc();
317template<
class ZoneType,
class MeshType>
323 return PtrListOps::names(*
this, matcher);
327template<
class ZoneType,
class MeshType>
334 return PtrListOps::names(*
this, matcher);
338template<
class ZoneType,
class MeshType>
348template<
class ZoneType,
class MeshType>
354 wordList sorted(this->names(matcher));
361template<
class ZoneType,
class MeshType>
368 wordList sorted(this->names(matcher));
375template<
class ZoneType,
class MeshType>
388 const bool checkGroups = (useGroups && this->hasGroupIDs());
394 ids.
resize(2*this->size());
401 const auto& groupLookup = groupZoneIDs();
404 if (matcher.
match(iter.key()))
414 return PtrListOps::findMatching(*
this, matcher);
418 ids.
insert(PtrListOps::findMatching(*
this, matcher));
426 const label zoneId = PtrListOps::firstMatching(*
this, matcher);
432 else if (checkGroups)
434 const auto iter = groupZoneIDs().cfind(matcher);
448template<
class ZoneType,
class MeshType>
459 else if (matcher.
size() == 1)
461 return this->indices(matcher.
first(), useGroups);
467 if (useGroups && this->hasGroupIDs())
469 ids.
resize(2*this->size());
471 const auto& groupLookup = groupZoneIDs();
474 if (matcher.
match(iter.key()))
484 return PtrListOps::findMatching(*
this, matcher);
488 ids.
insert(PtrListOps::findMatching(*
this, matcher));
495template<
class ZoneType,
class MeshType>
505 return PtrListOps::firstMatching(*
this, key);
509template<
class ZoneType,
class MeshType>
519 return PtrListOps::firstMatching(*
this, matcher);
523template<
class ZoneType,
class MeshType>
529 if (zoneName.empty())
534 label zoneId = PtrListOps::firstMatching(*
this, zoneName);
539 <<
"Zone named " << zoneName <<
" not found. "
540 <<
"List of available zone names: " << names() <<
endl;
543 if (disallowGenericZones != 0)
548 Info<<
"Creating dummy zone " << zoneName <<
endl;
549 zm.append(
new ZoneType(zoneName, zoneId, zm));
557template<
class ZoneType,
class MeshType>
563 if (zoneName.empty())
570 for (
auto iter = zones.
begin(); iter != zones.
end(); ++iter)
572 const ZoneType* ptr = iter.
get();
574 if (ptr && zoneName == ptr->name())
581 if (disallowGenericZones != 0)
585 Info<<
"Creating dummy zone " << zoneName <<
endl;
586 zm.append(
new ZoneType(zoneName, zm.size(), zm));
593template<
class ZoneType,
class MeshType>
599 return const_cast<ZoneType*
>(this->cfindZone(zoneName));
603template<
class ZoneType,
class MeshType>
611 for (
const label zonei : zoneIds)
614 if (zonei < 0 || zonei >= this->size())
617 << ZoneType::typeName <<
" "
618 << zonei <<
" out of range [0," << this->size() <<
")"
625 static_cast<const labelList&
>(this->
operator[](zonei))
633template<
class ZoneType,
class MeshType>
641 return this->selection(this->indices(matcher, useGroups));
645template<
class ZoneType,
class MeshType>
653 return this->selection(this->indices(matcher, useGroups));
657template<
class ZoneType,
class MeshType>
666 return *groupIDsPtr_;
670template<
class ZoneType,
class MeshType>
673 const word& groupName,
677 groupIDsPtr_.clear();
684 for (
const label zonei :
zoneIDs)
686 zones[zonei].inGroups().appendUniq(groupName);
687 doneZone[zonei] =
true;
693 if (!doneZone[zonei])
695 wordList& groups = zones[zonei].inGroups();
697 if (groups.
found(groupName))
702 if (groups[i] != groupName)
704 groups[newi++] = groups[i];
714template<
class ZoneType,
class MeshType>
718 groupIDsPtr_.clear();
722 for (ZoneType& zn : zones)
724 zn.clearAddressing();
729template<
class ZoneType,
class MeshType>
737template<
class ZoneType,
class MeshType>
743 bool hasError =
false;
747 for (
const ZoneType& zn : zones)
749 hasError |= zn.checkDefinition(report);
756template<
class ZoneType,
class MeshType>
762 if (!Pstream::parRun())
769 bool hasError =
false;
771 const wordList localNames(this->names());
772 const wordList localTypes(this->types());
779 (Pstream::master() ? 0 : localNames.
size()),
787 for (
const int proci :
procAddr.subProcs())
792 if (procNames != localNames || procTypes != localTypes)
798 Info<<
" ***Inconsistent zones across processors, "
799 "processor 0 has zone names:" << localNames
800 <<
" zone types:" << localTypes
801 <<
" processor " << proci
802 <<
" has zone names:" << procNames
803 <<
" zone types:" << procTypes
809 Pstream::broadcast(hasError);
814 for (
const ZoneType& zn : zones)
816 if (zn.checkParallelSync(
false))
820 if (debug || (report && Pstream::master()))
822 Info<<
" ***Zone " << zn.name()
823 <<
" of type " << zn.type()
824 <<
" is not correctly synchronised"
825 <<
" across coupled boundaries."
826 <<
" (coupled faces are either not both"
827 <<
" present in set or have same flipmap)" <<
endl;
837template<
class ZoneType,
class MeshType>
842 for (ZoneType& zn : zones)
849template<
class ZoneType,
class MeshType>
853 if (zoneNames.
empty())
855 this->removeMetaData();
860 meta.
set(
"names", zoneNames);
865template<
class ZoneType,
class MeshType>
875template<
class ZoneType,
class MeshType>
881 const label zonei = findZoneID(zoneName);
886 <<
"Zone named " << zoneName <<
" not found." <<
nl
887 <<
"Available zone names: " << names() <<
endl
891 return operator[](zonei);
895template<
class ZoneType,
class MeshType>
901 const label zonei = findZoneID(zoneName);
906 <<
"Zone named " << zoneName <<
" not found." <<
nl
907 <<
"Available zone names: " << names() <<
endl
911 return operator[](zonei);
915template<
class ZoneType,
class MeshType>
918 const word& zoneName,
922 ZoneType* ptr = findZone(zoneName);
924 const bool existing =
bool(ptr);
928 ptr =
new ZoneType(zoneName, this->size(), *
this);
934 Info<< ZoneType::typeName <<
' ' << zoneName
935 <<
" (" << (existing ?
"existing" :
"new")
936 <<
" at index " << ptr->index() <<
')'
946template<
class ZoneType,
class MeshType>
953 const label sz = zones.
size();
957 os << sz <<
nl << token::BEGIN_LIST;
959 for (label i=0; i < sz; ++i)
961 zones[i].writeDict(
os);
964 os << token::END_LIST;
968 os << sz << token::BEGIN_LIST << token::END_LIST;
Functions to operate on Pointer Lists.
globalIndex procAddr(aMesh.nFaces())
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
A HashTable similar to std::unordered_map.
List< Key > sortedToc() const
The table of contents (the keys) in sorted order.
bool empty() const noexcept
True if the hash table is empty.
void resize(const label sz)
Resize the hash table for efficiency.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
virtual bool check(const char *operation) const
Check IOstream status for given operation.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
void resize(const label len)
Adjust allocated size of list.
A HashTable to objects of type <T> with a label key.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
const T * set(const label i) const
void append(T *ptr)
Append an element to the end of the list.
void resize(const label newLen)
Adjust size of PtrList.
const labelUList & indices() const noexcept
Return the list of sorted indices (updated every sort).
T & first()
Return the first element of the list.
bool found(const T &val, label pos=0) const
True if the value if found in the list.
bool empty() const noexcept
True if the UList is empty (ie, size() is zero)
SubList< T > slice(const label pos, label len=-1)
Return SubList slice (non-const access) - no range checking.
void size(const label n)
Older name for setAddressableSize.
bool empty() const noexcept
True if the list is empty (ie, size() is zero)
label size() const noexcept
The number of elements in the list.
iterator begin() noexcept
Return an iterator to begin of UPtrList traversal.
iterator end() noexcept
Return iterator beyond end of UPtrList traversal.
label findZoneID(const word &zoneName) const
Find zone index by name, return -1 if not found.
friend Ostream & operator(Ostream &os, const ZoneMesh< ZoneType, MeshType > &zones)
wordList sortedNames() const
Sorted list of the zone names.
void setGroup(const word &groupName, const labelUList &zoneIDs)
Set/add group with zones.
wordList types() const
Return a list of zone types.
ZoneType * findZone(const word &zoneName)
Find zone by name and return pointer, nullptr on error.
const ZoneType * cfindZone(const word &zoneName) const
Find zone by name and return const pointer, nullptr on error.
void updateMetaData()
Update internal meta-data (eg, prior to writing)
const Map< label > & zoneMap() const
Map of zones containing zone index for all zoned elements.
static int disallowGenericZones
Debug switch to disallow the use of generic zones.
void clearAddressing()
Clear addressing.
void clear()
Clear the zones.
wordList groupNames() const
A list of the zone group names (if any)
const HashTable< labelList > & groupZoneIDs() const
The zone indices per zone group.
label whichZone(const label objectIndex) const
Given a global object index, return the zone it is in.
wordList names() const
A list of the zone names.
bool checkParallelSync(const bool report=false) const
Check whether all procs have all zones and in same order.
label findIndex(const wordRe &key) const
Zone index for the first match, return -1 if not found.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
void set(const bitSet &bitset)
Set specified bits from another bitset.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
const List< fieldInfo > & selection() const
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
void movePoints()
Update for new mesh geometry.
A class representing the concept of 1 (one) that can be used to avoid manipulating objects known to b...
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
bool isPattern() const noexcept
The wordRe is a pattern, not a literal string.
bool match(const std::string &text, bool literal=false) const
Smart match as regular expression or as a string.
A List of wordRe with additional matching capabilities.
bool match(const std::string &text, bool literal=false) const
Smart match as literal or regex, stopping on the first match.
A class for handling words, derived from Foam::string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
const labelIOList & zoneIDs
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
#define WarningInFunction
Report a warning using Foam::Warning.
#define DebugInFunction
Report an information message using Foam::Info.
rAUs append(new volScalarField(IOobject::groupName("rAU", phase1.name()), 1.0/(U1Eqn.A()+byDt(max(phase1.residualAlpha() - alpha1, scalar(0)) *rho1))))
int debugSwitch(const char *name, const int deflt=0)
Lookup debug switch or add default value.
List< label > labelList
A List of labels.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
void sort(UList< T > &list)
Sort the list.
errorManip< error > abort(error &err)
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.
Extract name (as a word) from an object, typically using its name() method.
Extract type (as a word) from an object, typically using its type() method.