Go to the documentation of this file.
38 template<
class ZoneType,
class MeshType>
48 template<
class ZoneType,
class MeshType>
54 <<
"zone map already calculated"
62 const PtrList<ZoneType>& zones = *
this;
64 for (
const ZoneType& zn : zones)
66 nObjects += zn.size();
69 zoneMapPtr_ =
new Map<label>(2*nObjects);
70 Map<label>& zm = *zoneMapPtr_;
77 for (
const ZoneType& zn : zones)
81 for (
const label idx : labels)
83 zm.insert(idx, zonei);
92 template<
class ZoneType,
class MeshType>
97 readOpt() == IOobject::MUST_READ
98 || readOpt() == IOobject::MUST_READ_IF_MODIFIED
99 || (readOpt() == IOobject::READ_IF_PRESENT && headerOk())
103 warnNoRereading<ZoneMesh<ZoneType, MeshType>>();
105 PtrList<ZoneType>& zones = *
this;
108 Istream& is = readStream(typeName);
110 PtrList<entry> patchEntries(is);
111 zones.resize(patchEntries.size());
120 patchEntries[zonei].keyword(),
121 patchEntries[zonei].
dict(),
142 template<
class ZoneType,
class MeshType>
143 template<
class UnaryMatchPredicate>
147 const UnaryMatchPredicate& matcher,
151 const label len = list.size();
156 for (label i = 0; i < len; ++i)
158 const word& itemName = list[i].name();
160 if (matcher(itemName))
162 output[
count++] = itemName;
177 template<
class ZoneType,
class MeshType>
178 template<
class UnaryMatchPredicate>
182 const UnaryMatchPredicate& matcher
185 const label len = list.size();
190 for (label i = 0; i < len; ++i)
192 if (matcher(list[i].
name()))
204 template<
class ZoneType,
class MeshType>
205 template<
class UnaryMatchPredicate>
209 const UnaryMatchPredicate& matcher
212 const label len = list.size();
214 for (label i = 0; i < len; ++i)
216 if (matcher(list[i].
name()))
228 template<
class ZoneType,
class MeshType>
244 template<
class ZoneType,
class MeshType>
248 const MeshType&
mesh,
262 template<
class ZoneType,
class MeshType>
266 const MeshType&
mesh,
283 zones.
set(zonei, pzm[zonei].clone(*this).ptr());
291 template<
class ZoneType,
class MeshType>
300 template<
class ZoneType,
class MeshType>
313 template<
class ZoneType,
class MeshType>
316 const label objectIndex
319 return zoneMap().lookup(objectIndex, -1);
323 template<
class ZoneType,
class MeshType>
332 list[zonei] = zones[zonei].type();
339 template<
class ZoneType,
class MeshType>
348 list[zonei] = zones[zonei].name();
355 template<
class ZoneType,
class MeshType>
365 template<
class ZoneType,
class MeshType>
376 template<
class ZoneType,
class MeshType>
386 template<
class ZoneType,
class MeshType>
396 template<
class ZoneType,
class MeshType>
407 template<
class ZoneType,
class MeshType>
426 const word& matcher = key;
432 template<
class ZoneType,
class MeshType>
447 template<
class ZoneType,
class MeshType>
466 const word& matcher = key;
472 template<
class ZoneType,
class MeshType>
478 return (matcher.empty() ? -1 :
findIndexImpl(*
this, matcher));
482 template<
class ZoneType,
class MeshType>
497 <<
"Zone named " << zoneName <<
" not found. "
498 <<
"List of available zone names: " << names() <<
endl;
500 if (disallowGenericZones != 0)
504 Info<<
"Creating dummy zone " << zoneName <<
endl;
506 dict.set(
"type", ZoneType::typeName);
516 zm.append(
new ZoneType(zoneName,
dict, zoneId, zm));
523 template<
class ZoneType,
class MeshType>
531 for (
const label zonei : zoneIds)
534 if (zonei < 0 || zonei >= this->size())
537 << ZoneType::typeName <<
" "
538 << zonei <<
" out of range [0," << this->size() <<
")"
545 static_cast<const labelList&
>(this->
operator[](zonei))
553 template<
class ZoneType,
class MeshType>
559 return this->selection(this->indices(key));
563 template<
class ZoneType,
class MeshType>
569 return this->selection(this->indices(matcher));
573 template<
class ZoneType,
class MeshType>
581 for (
auto iter = zones.begin(); iter != zones.end(); ++iter)
583 const ZoneType* ptr = iter.get();
585 if (ptr && zoneName == ptr->name())
595 template<
class ZoneType,
class MeshType>
603 for (
auto iter = zones.begin(); iter != zones.end(); ++iter)
605 ZoneType* ptr = iter.get();
607 if (ptr && zoneName == ptr->name())
617 template<
class ZoneType,
class MeshType>
624 for (ZoneType& zn : zones)
626 zn.clearAddressing();
631 template<
class ZoneType,
class MeshType>
639 template<
class ZoneType,
class MeshType>
645 bool inError =
false;
649 for (
const ZoneType& zn : zones)
651 inError |= zn.checkDefinition(report);
658 template<
class ZoneType,
class MeshType>
664 if (!Pstream::parRun())
671 bool hasError =
false;
675 allNames[Pstream::myProcNo()] = this->names();
676 Pstream::gatherList(allNames);
677 Pstream::scatterList(allNames);
680 allTypes[Pstream::myProcNo()] = this->types();
681 Pstream::gatherList(allTypes);
682 Pstream::scatterList(allTypes);
686 for (label proci = 1; proci < allNames.size(); ++proci)
690 (allNames[proci] != allNames[0])
691 || (allTypes[proci] != allTypes[0])
696 if (
debug || (report && Pstream::master()))
698 Info<<
" ***Inconsistent zones across processors, "
699 "processor 0 has zone names:" << allNames[0]
700 <<
" zone types:" << allTypes[0]
701 <<
" processor " << proci <<
" has zone names:"
703 <<
" zone types:" << allTypes[proci]
712 for (
const ZoneType& zn : zones)
714 if (zn.checkParallelSync(
false))
718 if (
debug || (report && Pstream::master()))
720 Info<<
" ***Zone " << zn.name()
721 <<
" of type " << zn.type()
722 <<
" is not correctly synchronised"
723 <<
" across coupled boundaries."
724 <<
" (coupled faces are either not both"
725 <<
" present in set or have same flipmap)" <<
endl;
735 template<
class ZoneType,
class MeshType>
740 for (ZoneType& zn : zones)
747 template<
class ZoneType,
class MeshType>
757 template<
class ZoneType,
class MeshType>
763 const label zonei = findZoneID(zoneName);
768 <<
"Zone named " << zoneName <<
" not found." <<
nl
769 <<
"Available zone names: " << names() <<
endl
773 return operator[](zonei);
777 template<
class ZoneType,
class MeshType>
783 const label zonei = findZoneID(zoneName);
788 <<
"Zone named " << zoneName <<
" not found." <<
nl
789 <<
"Available zone names: " << names() <<
endl
793 return operator[](zonei);
797 template<
class ZoneType,
class MeshType>
800 const word& zoneName,
806 label zoneId = findZoneID(zoneName);
810 zoneId = zones.size();
812 zones.
set(zoneId,
new ZoneType(zoneName, zoneId, *
this));
816 Info<< ZoneType::typeName <<
" " << zoneName
817 <<
" (new at index " << zoneId <<
")"
825 Info<< ZoneType::typeName <<
" " << zoneName
826 <<
" (existing at index " << zoneId <<
")"
831 return zones[zoneId];
837 template<
class ZoneType,
class MeshType>
844 const label sz = zones.size();
848 os << sz <<
nl << token::BEGIN_LIST;
850 for (label i=0; i < sz; ++i)
852 zones[i].writeDict(os);
855 os << token::END_LIST;
859 os << sz << token::BEGIN_LIST << token::END_LIST;
const Map< label > & zoneMap() const
Map of zones containing zone index for all zoned elements.
int debug
Static debugging option.
bool checkDefinition(const bool report=false) const
Check zone definition. Return true if in error.
List< label > labelList
A List of labels.
void clear()
Clear the zones.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
static wordList namesImpl(const PtrList< coordinateSystem > &list, const UnaryMatchPredicate &matcher, const bool doSort)
A class for handling words, derived from Foam::string.
bool writeData(Ostream &os) const
writeData member function required by regIOobject
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
int debugSwitch(const char *name, const int deflt=0)
Lookup debug switch or add default value.
bool isPattern() const
The keyType is treated as a pattern, not as literal string.
Template functions to aid in the implementation of demand driven data.
void set(const bitSet &bitset)
Set specified bits from another bitset.
A HashTable to objects of type <T> with a label key.
List< bool > boolList
A List of bools.
label findIndex(const keyType &key) const
Return zone index for the first match, return -1 if not found.
Ostream & endl(Ostream &os)
Add newline and flush stream.
bitSet bitset(const labelHashSet &locations)
Transform the on locations to a bitSet.
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
#define forAll(list, i)
Loop across all elements in list.
label findIndexImpl(const faPatchList &list, const UnaryMatchPredicate &matcher)
static labelList indicesImpl(const faPatchList &list, const UnaryMatchPredicate &matcher)
void deleteDemandDrivenData(DataPtr &dataPtr)
A class for handling keywords in dictionaries.
void movePoints(const pointField &pts)
Correct zone mesh after moving points.
messageStream Info
Information stream (uses stdout - output is on the master only)
#define DebugInFunction
Report an information message using Foam::Info.
word name(const complex &c)
Return string representation of complex.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Wrapper around C++11 regular expressions.
void resize(const label newSize)
Adjust allocated size of list.
label whichZone(const label objectIndex) const
Given a global object index, return the zone it is in.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
errorManip< error > abort(error &err)
const T * set(const label i) const
Return const pointer to element (if set) or nullptr.
label findZoneID(const word &zoneName) const
Find zone index given a name, return -1 if not found.
friend Ostream & operator(Ostream &os, const ZoneMesh< ZoneType, MeshType > &zones)
wordList names() const
A list of the zone names.
void resize(const label newLen)
Adjust size of PtrList.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
wordList sortedNames() const
Sorted list of the zone names.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
A List of wordRe with additional matching capabilities.
static int disallowGenericZones
Debug switch to disallow the use of generic zones.
bitSet selection(const labelUList &zoneIds) const
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
void clearAddressing()
Clear addressing.
bool good() const
Return true if next operation might succeed.
labelList indices(const keyType &key) const
Return zone indices for all matches.
const ZoneType * zonePtr(const word &zoneName) const
Lookup zone by name and return const pointer, nullptr on error.
bool checkParallelSync(const bool report=false) const
Check whether all procs have all zones and in same order.
wordList types() const
Return a list of zone types.