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>
499 <<
"Zone named " << zoneName <<
" not found. "
500 <<
"List of available zone names: " << names() <<
endl;
503 if (disallowGenericZones != 0)
507 Info<<
"Creating dummy zone " << zoneName <<
endl;
509 dict.set(
"type", ZoneType::typeName);
519 zm.append(
new ZoneType(zoneName,
dict, zoneId, zm));
526 template<
class ZoneType,
class MeshType>
534 for (
const label zonei : zoneIds)
537 if (zonei < 0 || zonei >= this->size())
540 << ZoneType::typeName <<
" "
541 << zonei <<
" out of range [0," << this->size() <<
")"
548 static_cast<const labelList&
>(this->
operator[](zonei))
556 template<
class ZoneType,
class MeshType>
562 return this->selection(this->indices(key));
566 template<
class ZoneType,
class MeshType>
572 return this->selection(this->indices(matcher));
576 template<
class ZoneType,
class MeshType>
584 for (
auto iter = zones.begin(); iter != zones.end(); ++iter)
586 const ZoneType* ptr = iter.get();
588 if (ptr && zoneName == ptr->name())
598 template<
class ZoneType,
class MeshType>
606 for (
auto iter = zones.begin(); iter != zones.end(); ++iter)
608 ZoneType* ptr = iter.get();
610 if (ptr && zoneName == ptr->name())
620 template<
class ZoneType,
class MeshType>
627 for (ZoneType& zn : zones)
629 zn.clearAddressing();
634 template<
class ZoneType,
class MeshType>
642 template<
class ZoneType,
class MeshType>
648 bool inError =
false;
652 for (
const ZoneType& zn : zones)
654 inError |= zn.checkDefinition(report);
661 template<
class ZoneType,
class MeshType>
667 if (!Pstream::parRun())
674 bool hasError =
false;
678 allNames[Pstream::myProcNo()] = this->names();
679 Pstream::gatherList(allNames);
680 Pstream::scatterList(allNames);
683 allTypes[Pstream::myProcNo()] = this->types();
684 Pstream::gatherList(allTypes);
685 Pstream::scatterList(allTypes);
689 for (
label proci = 1; proci < allNames.size(); ++proci)
693 (allNames[proci] != allNames[0])
694 || (allTypes[proci] != allTypes[0])
699 if (
debug || (report && Pstream::master()))
701 Info<<
" ***Inconsistent zones across processors, "
702 "processor 0 has zone names:" << allNames[0]
703 <<
" zone types:" << allTypes[0]
704 <<
" processor " << proci <<
" has zone names:"
706 <<
" zone types:" << allTypes[proci]
715 for (
const ZoneType& zn : zones)
717 if (zn.checkParallelSync(
false))
721 if (
debug || (report && Pstream::master()))
723 Info<<
" ***Zone " << zn.name()
724 <<
" of type " << zn.type()
725 <<
" is not correctly synchronised"
726 <<
" across coupled boundaries."
727 <<
" (coupled faces are either not both"
728 <<
" present in set or have same flipmap)" <<
endl;
738 template<
class ZoneType,
class MeshType>
743 for (ZoneType& zn : zones)
750 template<
class ZoneType,
class MeshType>
760 template<
class ZoneType,
class MeshType>
766 const label zonei = findZoneID(zoneName);
771 <<
"Zone named " << zoneName <<
" not found." <<
nl
772 <<
"Available zone names: " << names() <<
endl
776 return operator[](zonei);
780 template<
class ZoneType,
class MeshType>
786 const label zonei = findZoneID(zoneName);
791 <<
"Zone named " << zoneName <<
" not found." <<
nl
792 <<
"Available zone names: " << names() <<
endl
796 return operator[](zonei);
800 template<
class ZoneType,
class MeshType>
803 const word& zoneName,
809 label zoneId = findZoneID(zoneName);
813 zoneId = zones.size();
815 zones.
set(zoneId,
new ZoneType(zoneName, zoneId, *
this));
819 Info<< ZoneType::typeName <<
" " << zoneName
820 <<
" (new at index " << zoneId <<
")"
828 Info<< ZoneType::typeName <<
" " << zoneName
829 <<
" (existing at index " << zoneId <<
")"
834 return zones[zoneId];
840 template<
class ZoneType,
class MeshType>
847 const label sz = zones.size();
851 os << sz <<
nl << token::BEGIN_LIST;
853 for (
label i=0; i < sz; ++i)
855 zones[i].writeDict(os);
858 os << token::END_LIST;
862 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)
#define InfoInFunction
Report an information message using Foam::Info.
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.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
void movePoints(const pointField &pts)
Correct zone mesh after moving points.
messageStream Info
Information stream (uses stdout - output is on the master only)
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.