Go to the documentation of this file.
51 bool Foam::polyBoundaryMesh::hasGroupIDs()
const
56 return !groupIDsPtr_->empty();
63 if (!
p.inGroups().empty())
73 void Foam::polyBoundaryMesh::calcGroupIDs()
const
80 groupIDsPtr_.reset(
new HashTable<labelList>(16));
81 auto& groupLookup = *groupIDsPtr_;
89 for (
const word& groupName : groups)
91 groupLookup(groupName).
append(patchi);
102 <<
"' which clashes with patch " << patchi
103 <<
" of the same name."
112 Foam::polyBoundaryMesh::polyBoundaryMesh
129 warnNoRereading<polyBoundaryMesh>();
134 Istream& is = readStream(typeName);
136 PtrList<entry> patchEntries(is);
137 patches.setSize(patchEntries.size());
146 patchEntries[patchi].keyword(),
147 patchEntries[patchi].
dict(),
161 Foam::polyBoundaryMesh::polyBoundaryMesh
174 Foam::polyBoundaryMesh::polyBoundaryMesh
193 warnNoRereading<polyBoundaryMesh>();
198 Istream& is = readStream(typeName);
201 patches.setSize(patchEntries.size());
210 patchEntries[patchi].keyword(),
211 patchEntries[patchi].
dict(),
249 neighbourEdgesPtr_.clear();
251 groupIDsPtr_.clear();
264 void Foam::polyBoundaryMesh::calcGeometry()
276 operator[](patchi).initGeometry(pBufs);
279 pBufs.finishedSends();
283 operator[](patchi).calcGeometry(pBufs);
291 pBufs.finishedSends();
293 for (
const auto& patchEval : patchSchedule)
295 const label patchi = patchEval.patch;
299 operator[](patchi).initGeometry(pBufs);
303 operator[](patchi).calcGeometry(pBufs);
315 UPtrList<const labelUList> list(
patches.size());
319 list.set(patchi, &
patches[patchi].faceCells());
332 <<
"Neighbour edge addressing not correct across parallel"
333 <<
" boundaries." <<
endl;
336 if (!neighbourEdgesPtr_)
338 neighbourEdgesPtr_.reset(
new List<labelPairList>(size()));
339 auto& neighbourEdges = *neighbourEdgesPtr_;
342 label nEdgePairs = 0;
345 const polyPatch& pp = operator[](patchi);
347 neighbourEdges[patchi].setSize(pp.nEdges() - pp.nInternalEdges());
349 for (
labelPair& edgeInfo : neighbourEdges[patchi])
355 nEdgePairs += pp.nEdges() - pp.nInternalEdges();
360 EdgeMap<labelPair> pointsToEdge(nEdgePairs);
364 const polyPatch& pp = operator[](patchi);
370 label edgei = pp.nInternalEdges();
371 edgei < edges.size();
376 const edge&
e = edges[edgei];
379 edge meshEdge(pp.meshPoints()[
e[0]], pp.meshPoints()[
e[1]]);
381 auto fnd = pointsToEdge.find(meshEdge);
393 edgei - pp.nInternalEdges()
402 neighbourEdges[patchi][edgei - pp.nInternalEdges()] =
405 neighbourEdges[edgeInfo[0]][edgeInfo[1]]
406 =
labelPair(patchi, edgei - pp.nInternalEdges());
411 pointsToEdge.erase(meshEdge);
416 if (pointsToEdge.size())
419 <<
"Not all boundary edges of patches match up." <<
nl
420 <<
"Is the outside of your mesh multiply connected?"
426 const polyPatch& pp = operator[](patchi);
434 if (edgeInfo[0] == -1 || edgeInfo[1] == -1)
436 const label edgei = pp.nInternalEdges() + i;
437 const edge&
e = pp.edges()[edgei];
440 <<
"Not all boundary edges of patches match up." <<
nl
441 <<
"Edge " << edgei <<
" on patch " << pp.name()
442 <<
" end points " << pp.localPoints()[
e[0]] <<
' '
443 << pp.localPoints()[
e[1]] <<
" is not matched to an"
444 <<
" edge on any other patch." <<
nl
445 <<
"Is the outside of your mesh multiply connected?"
452 return *neighbourEdgesPtr_;
460 patchIDPtr_.reset(
new labelList(mesh_.nBoundaryFaces()));
471 (
patches[patchi].start() - mesh_.nInternalFaces())
488 return *groupIDsPtr_;
494 const word& groupName,
498 groupIDsPtr_.clear();
505 for (
const label patchi : patchIDs)
507 patches[patchi].inGroups().appendUniq(groupName);
508 donePatch[patchi] =
true;
514 if (!donePatch[patchi])
518 if (groups.found(groupName))
523 if (groups[i] != groupName)
525 groups[newi++] = groups[i];
543 if (isA<processorPolyPatch>(
p))
570 PtrListOps::get<word>
573 [](
const polyPatch&
p) {
return p.physicalType(); }
581 PtrListOps::get<label>
592 PtrListOps::get<label>
603 PtrListOps::get<labelRange>
613 return mesh_.nInternalFaces();
619 return mesh_.nBoundaryFaces();
625 return labelRange(mesh_.nInternalFaces(), mesh_.nBoundaryFaces());
637 return (*
this)[patchi].range();
653 const bool checkGroups = (useGroups && this->hasGroupIDs());
661 const auto& groupLookup = groupPatchIDs();
664 if (matcher.
match(iter.key()))
667 ids.insert(iter.val());
692 else if (checkGroups)
694 const auto iter = groupPatchIDs().cfind(matcher);
699 ids.insert(iter.val());
704 return ids.sortedToc();
710 const wordRes& matcher,
718 else if (matcher.size() == 1)
720 return this->indices(matcher.first(), useGroups);
726 if (useGroups && this->hasGroupIDs())
728 ids.resize(2*this->size());
730 const auto& groupLookup = groupPatchIDs();
733 if (matcher.match(iter.key()))
736 ids.insert(iter.val());
750 return ids.sortedToc();
766 const word& patchName,
770 if (patchName.empty())
785 <<
"Patch '" << patchName <<
"' not found. "
786 <<
"Available patch names";
791 <<
" in region '" << mesh_.name() <<
"'";
802 Pout<<
"label polyBoundaryMesh::findPatchID(const word&) const"
803 <<
"Patch named " << patchName <<
" not found. "
804 <<
"Available patch names: " <<
names() <<
endl;
818 if (faceIndex <
mesh().nInternalFaces())
822 else if (faceIndex >=
mesh().nFaces())
825 <<
"Face " << faceIndex
826 <<
" out of bounds. Number of geometric faces " <<
mesh().
nFaces()
842 [](
const polyPatch&
p, label val) {
return (
p.start() <= val); }
849 <<
"Face " << faceIndex <<
" not found in any of the patches "
851 <<
"The patches appear to be inconsistent with the mesh :"
853 <<
" total number of faces:" <<
mesh().
nFaces()
866 const bool warnNotFound,
874 const bool checkGroups = (useGroups && this->hasGroupIDs());
879 ids.insert(matchIndices);
881 bool missed = matchIndices.empty();
883 if (missed && checkGroups)
886 if (matcher.isPattern())
890 if (matcher.match(iter.key()))
893 ids.insert(iter.val());
900 const auto iter = groupPatchIDs().cfind(matcher);
905 ids.insert(iter.val());
911 if (missed && warnNotFound)
916 <<
"Cannot find any patch or group names matching "
922 <<
"Cannot find any patch names matching "
940 DynamicList<word> matchedGroups(1);
945 const HashTable<labelList>& groupLookup = this->groupPatchIDs();
955 label nMatch = nonGroupPatches.erase(groupPatchSet);
957 if (nMatch == groupPatchSet.size())
959 matchedGroups.append(iter.key());
961 else if (nMatch != 0)
964 nonGroupPatches.transfer(oldNonGroupPatches);
968 groups.transfer(matchedGroups);
979 const polyBoundaryMesh& bm = *
this;
981 bool hasError =
false;
991 if (!isA<processorPolyPatch>(bm[patchi]))
993 if (nonProci != patchi)
1000 Pout<<
" ***Problem with boundary patch " << patchi
1001 <<
" named " << bm[patchi].
name()
1002 <<
" of type " << bm[patchi].
type()
1003 <<
". The patch seems to be preceeded by processor"
1004 <<
" patches. This is can give problems."
1010 names[nonProci] = bm[patchi].name();
1011 types[nonProci] = bm[patchi].type();
1017 types.setSize(nonProci);
1036 (allNames[proci] != allNames.first())
1037 || (allTypes[proci] != allTypes.first())
1044 Info<<
" ***Inconsistent patches across processors, "
1045 "processor 0 has patch names:"
1047 <<
" patch types:" << allTypes.first()
1048 <<
" processor " << proci
1049 <<
" has patch names:" << allNames[proci]
1050 <<
" patch types:" << allTypes[proci]
1063 const polyBoundaryMesh& bm = *
this;
1065 bool hasError =
false;
1071 if (bm[patchi].start() != nextPatchStart && !hasError)
1075 Info<<
" ****Problem with boundary patch " << patchi
1076 <<
" named " << bm[patchi].name()
1077 <<
" of type " << bm[patchi].type()
1078 <<
". The patch should start on face no " << nextPatchStart
1079 <<
" and the patch specifies " << bm[patchi].start()
1081 <<
"Possibly consecutive patches have this same problem."
1082 <<
" Suppressing future warnings." <<
endl;
1085 if (!
patchNames.insert(bm[patchi].name()) && !hasError)
1089 Info<<
" ****Duplicate boundary patch " << patchi
1090 <<
" named " << bm[patchi].name()
1091 <<
" of type " << bm[patchi].type()
1093 <<
"Suppressing future warnings." <<
endl;
1096 nextPatchStart += bm[patchi].size();
1099 reduce(hasError, orOp<bool>());
1101 if (
debug || report)
1105 Pout<<
" ***Boundary definition is in error." <<
endl;
1109 Info<<
" Boundary definition OK." <<
endl;
1129 operator[](patchi).initMovePoints(pBufs,
p);
1132 pBufs.finishedSends();
1136 operator[](patchi).movePoints(pBufs,
p);
1144 pBufs.finishedSends();
1146 for (
const auto& patchEval : patchSchedule)
1148 const label patchi = patchEval.patch;
1152 operator[](patchi).initMovePoints(pBufs,
p);
1156 operator[](patchi).movePoints(pBufs,
p);
1165 neighbourEdgesPtr_.clear();
1166 patchIDPtr_.clear();
1167 groupIDsPtr_.clear();
1179 operator[](patchi).initUpdateMesh(pBufs);
1182 pBufs.finishedSends();
1186 operator[](patchi).updateMesh(pBufs);
1194 pBufs.finishedSends();
1196 for (
const auto& patchEval : patchSchedule)
1198 const label patchi = patchEval.patch;
1202 operator[](patchi).initUpdateMesh(pBufs);
1206 operator[](patchi).updateMesh(pBufs);
1216 const bool validBoundary
1227 patches[patchi].index() = patchi;
1243 for (
const polyPatch& pp :
patches)
1272 const word& patchName
1275 const label patchi = findPatchID(patchName);
1280 <<
"Patch named " << patchName <<
" not found." <<
nl
1281 <<
"Available patch names: " <<
names() <<
endl
1285 return operator[](patchi);
1291 const word& patchName
1294 const label patchi = findPatchID(patchName);
1299 <<
"Patch named " << patchName <<
" not found." <<
nl
1300 <<
"Available patch names: " <<
names() <<
endl
1304 return operator[](patchi);
@ UNCOMPRESSED
compression = false
List< label > labelList
A List of labels.
vectorField pointField
pointField is a vectorField.
label size() const noexcept
labelList patchSizes() const
Defines the attributes of an object for which implicit objectRegistry management is supported,...
bool isPattern() const noexcept
void matchGroups(const labelUList &patchIDs, wordList &groups, labelHashSet &nonGroupPatches) const
List< edge > edgeList
A List of edges.
A class for handling words, derived from Foam::string.
List< lduScheduleEntry > lduSchedule
wordList physicalTypes() const
void resize(const label len)
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
const edgeList & edges() const
static word defaultRegion
static void scatterList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
A List obtained as a section of another List.
List< labelPair > labelPairList
List of labelPairs.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
const HashTable< labelList > & groupPatchIDs() const
void reorder(const labelUList &oldToNew, const bool validBoundary)
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
bool insert(const Key &key, const T &obj)
labelList findMatching(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
A class representing the concept of 1 (one) that can be used to avoid manipulating objects known to b...
static bool master(const label communicator=worldComm)
List< bool > boolList
A List of bools.
Functions to operate on Pointer Lists.
Ostream & endl(Ostream &os)
const T * set(const label i) const
static commsTypes defaultCommsType
virtual Ostream & beginBlock(const keyType &kw)
A HashTable with keys but without contents that is similar to std::unordered_set.
Ostream & incrIndent(Ostream &os)
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
label findIndex(const wordRe &key) const
Mesh consisting of general polyhedral cells.
bool good() const noexcept
bool match(const std::string &text, bool literal=false) const
Pair< label > labelPair
A pair of labels.
List< word > wordList
A List of words.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
const labelList & patchID() const
bool checkParallelSync(const bool report=false) const
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
static rangeType subProcs(const label communicator=worldComm)
Generic templated field type.
label findLower(const ListType &input, const T &val, const label start, const ComparePredicate &comp)
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
bool erase(const iterator &iter)
A patch is a list of labels that address the faces in the global face list.
UPtrList< const labelUList > faceCells() const
bool checkDefinition(const bool report=false) const
PtrList< polyPatch > polyPatchList
container classes for polyPatch
virtual const fileName & name() const
void setSize(const label n)
DynamicList< T, SizeMin > & append(const T &val)
void transfer(List< T > &list)
Type type(bool followLink=true, bool checkGzip=false) const
The IOstreamOption is a simple container for options an IOstream can normally have.
void setSize(const label newLen)
labelList patchStarts() const
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
A range or interval of labels defined by a start and a size.
label whichPatch(const label faceIndex) const
ListType reorder(const labelUList &oldToNew, const ListType &input, const bool prune=false)
autoPtr< IOobject > clone() const
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
wordList patchNames(nPatches)
label findPatchID(const word &patchName, const bool allowNotFound=true) const
void finishedSends(const bool block=true)
virtual Ostream & endBlock()
virtual bool check(const char *operation) const
static autoPtr< polyPatch > New(const word &patchType, const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm)
OBJstream os(runTime.globalPath()/outputName)
virtual bool writeObject(IOstreamOption streamOpt, const bool valid) const
const lduSchedule & patchSchedule() const
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Ostream & decrIndent(Ostream &os)
errorManip< error > abort(error &err)
iterator find(const Key &key)
void movePoints(const pointField &p)
errorManipArg< error, int > exit(error &err, const int errNo=1)
const Field< point_type > & localPoints() const
readOption readOpt() const noexcept
A HashTable similar to std::unordered_map.
label nNonProcessor() const
label nInternalEdges() const
virtual bool writeData(Ostream &os) const
const word & name() const noexcept
Map from edge (expressed as its endpoints) to value. For easier forward declaration it is currently i...
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
#define FatalErrorInFunction
static void gatherList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
const List< labelPairList > & neighbourEdges() const
const T * set(const label i) const
static int myProcNo(const label communicator=worldComm)
An ordered pair of two objects of type <T> with first() and second() elements.
forAllConstIters(mixture.phases(), phase)
virtual bool writeObject(IOstreamOption streamOpt, const bool valid) const
label nInternalFaces() const noexcept
static bool & parRun() noexcept
labelList indices(const wordRe &matcher, const bool useGroups=true) const
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void setGroup(const word &groupName, const labelUList &patchIDs)
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
const dimensionedScalar e
A List of wordRe with additional matching capabilities.
labelHashSet patchSet(const UList< wordRe > &patchNames, const bool warnNotFound=true, const bool useGroups=true) const
List< labelRange > patchRanges() const
bool insert(const Key &key)
label firstMatching(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
const polyBoundaryMesh & patches
@ END_LIST
End list [isseparator].
HashSet< word, Hash< word > > wordHashSet
A HashSet with word keys and string hasher.
Operations on lists of strings.
label nFaces() const noexcept
const word & name() const noexcept
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
const globalMeshData & globalData() const
UList< label > labelUList
A UList of labels.
compressionType compression() const noexcept
HashSet< label, Hash< label > > labelHashSet
A HashSet with label keys and label hasher.
const labelList & meshPoints() const
@ BEGIN_LIST
Begin list [isseparator].
List< word > names(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
labelList findMatchingStrings(const UnaryMatchPredicate &matcher, const UList< StringType > &input, const bool invert=false)
defineTypeNameAndDebug(combustionModel, 0)
#define WarningInFunction
Smooth ATC in cells next to a set of patches supplied by type.
bool match(const std::string &text, bool literal=false) const
static label nProcs(const label communicator=worldComm)