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))
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>
488 if (zoneName.empty())
498 <<
"Zone named " << zoneName <<
" not found. "
499 <<
"List of available zone names: " << names() <<
endl;
502 if (disallowGenericZones != 0)
507 Info<<
"Creating dummy zone " << zoneName <<
endl;
508 zm.append(
new ZoneType(zoneName, zoneId, zm));
516 template<
class ZoneType,
class MeshType>
522 if (zoneName.empty())
529 for (
auto iter = zones.begin(); iter != zones.end(); ++iter)
531 const ZoneType* ptr = iter.get();
533 if (ptr && zoneName == ptr->name())
540 if (disallowGenericZones != 0)
544 Info<<
"Creating dummy zone " << zoneName <<
endl;
545 zm.append(
new ZoneType(zoneName, zm.size(), zm));
552 template<
class ZoneType,
class MeshType>
558 return const_cast<ZoneType*
>(this->cfindZone(zoneName));
562 template<
class ZoneType,
class MeshType>
570 for (
const label zonei : zoneIds)
573 if (zonei < 0 || zonei >= this->size())
576 << ZoneType::typeName <<
" "
577 << zonei <<
" out of range [0," << this->size() <<
")"
584 static_cast<const labelList&
>(this->
operator[](zonei))
592 template<
class ZoneType,
class MeshType>
599 return this->selection(this->indices(key));
603 template<
class ZoneType,
class MeshType>
610 return this->selection(this->indices(matcher));
614 template<
class ZoneType,
class MeshType>
621 for (ZoneType& zn : zones)
623 zn.clearAddressing();
628 template<
class ZoneType,
class MeshType>
636 template<
class ZoneType,
class MeshType>
642 bool inError =
false;
646 for (
const ZoneType& zn : zones)
648 inError |= zn.checkDefinition(report);
655 template<
class ZoneType,
class MeshType>
661 if (!Pstream::parRun())
668 bool hasError =
false;
672 allNames[Pstream::myProcNo()] = this->names();
673 Pstream::gatherList(allNames);
674 Pstream::scatterList(allNames);
677 allTypes[Pstream::myProcNo()] = this->types();
678 Pstream::gatherList(allTypes);
679 Pstream::scatterList(allTypes);
683 for (label proci = 1; proci < allNames.size(); ++proci)
687 (allNames[proci] != allNames[0])
688 || (allTypes[proci] != allTypes[0])
693 if (
debug || (report && Pstream::master()))
695 Info<<
" ***Inconsistent zones across processors, "
696 "processor 0 has zone names:" << allNames[0]
697 <<
" zone types:" << allTypes[0]
698 <<
" processor " << proci <<
" has zone names:"
700 <<
" zone types:" << allTypes[proci]
709 for (
const ZoneType& zn : zones)
711 if (zn.checkParallelSync(
false))
715 if (
debug || (report && Pstream::master()))
717 Info<<
" ***Zone " << zn.name()
718 <<
" of type " << zn.type()
719 <<
" is not correctly synchronised"
720 <<
" across coupled boundaries."
721 <<
" (coupled faces are either not both"
722 <<
" present in set or have same flipmap)" <<
endl;
732 template<
class ZoneType,
class MeshType>
737 for (ZoneType& zn : zones)
744 template<
class ZoneType,
class MeshType>
754 template<
class ZoneType,
class MeshType>
760 const label zonei = findZoneID(zoneName);
765 <<
"Zone named " << zoneName <<
" not found." <<
nl
766 <<
"Available zone names: " << names() <<
endl
770 return operator[](zonei);
774 template<
class ZoneType,
class MeshType>
780 const label zonei = findZoneID(zoneName);
785 <<
"Zone named " << zoneName <<
" not found." <<
nl
786 <<
"Available zone names: " << names() <<
endl
790 return operator[](zonei);
794 template<
class ZoneType,
class MeshType>
797 const word& zoneName,
801 ZoneType* ptr = findZone(zoneName);
803 const bool existing =
bool(ptr);
807 ptr =
new ZoneType(zoneName, this->size(), *
this);
813 Info<< ZoneType::typeName <<
' ' << zoneName
814 <<
" (" << (existing ?
"existing" :
"new")
815 <<
" at index " << ptr->index() <<
')'
825 template<
class ZoneType,
class MeshType>
832 const label sz = zones.size();
836 os << sz <<
nl << token::BEGIN_LIST;
838 for (label i=0; i < sz; ++i)
840 zones[i].writeDict(os);
843 os << token::END_LIST;
847 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)
static Ostream & output(Ostream &os, const IntRange< T > &range)
A class for handling words, derived from Foam::string.
bool writeData(Ostream &os) const
writeData member function required by regIOobject
const ZoneType * cfindZone(const word &zoneName) const
Find zone by name and return const pointer, nullptr on error.
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.
label findIndex(const keyType &key) const
Zone index for the first match, return -1 if not found.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const T * set(const label i) const
Return const pointer to element (can be nullptr),.
rAUs append(new volScalarField(IOobject::groupName("rAU", phase1.name()), 1.0/(U1Eqn.A()+byDt(max(phase1.residualAlpha() - alpha1, scalar(0)) *rho1))))
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.
label whichZone(const label objectIndex) const
Given a global object index, return the zone it is in.
errorManip< error > abort(error &err)
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 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.
ZoneType * findZone(const word &zoneName)
Find zone by name and return 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.