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);
146 patchEntries[patchi].keyword(),
147 patchEntries[patchi].
dict(),
161 Foam::polyBoundaryMesh::polyBoundaryMesh
174 Foam::polyBoundaryMesh::polyBoundaryMesh
193 warnNoRereading<polyBoundaryMesh>();
198 Istream& is = readStream(typeName);
210 patchEntries[patchi].keyword(),
211 patchEntries[patchi].
dict(),
228 patches.
set(patchi, ppl[patchi].clone(*this).ptr());
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);
332 <<
"Neighbour edge addressing not correct across parallel"
333 <<
" boundaries." <<
endl;
336 if (!neighbourEdgesPtr_)
339 auto& neighbourEdges = *neighbourEdgesPtr_;
342 label nEdgePairs = 0;
345 const polyPatch& pp = operator[](patchi);
349 for (
labelPair& edgeInfo : neighbourEdges[patchi])
364 const polyPatch& pp = operator[](patchi);
371 edgei < edges.size();
376 const edge&
e = edges[edgei];
381 auto fnd = pointsToEdge.
find(meshEdge);
405 neighbourEdges[edgeInfo[0]][edgeInfo[1]]
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)
440 <<
"Not all boundary edges of patches match up." <<
nl
441 <<
"Edge " << edgei <<
" on patch " << pp.
name()
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()))
692 else if (checkGroups)
694 const auto iter = groupPatchIDs().cfind(matcher);
704 return ids.sortedToc();
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()))
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); }
845 if (patchi < 0 || !
patches[patchi].
range().found(faceIndex))
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());
881 bool missed = matchIndices.empty();
883 if (missed && checkGroups)
886 if (matcher.isPattern())
890 if (matcher.
match(iter.key()))
900 const auto iter = groupPatchIDs().cfind(matcher);
911 if (missed && warnNotFound)
916 <<
"Cannot find any patch or group names matching "
922 <<
"Cannot find any patch names matching "
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);
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."
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]
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;
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();
1101 if (
debug || report)
1105 Pout<<
" ***Boundary definition is in error." <<
endl;
1109 Info<<
" Boundary definition OK." <<
endl;
1129 operator[](patchi).initMovePoints(pBufs,
p);
1136 operator[](patchi).movePoints(pBufs,
p);
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);
1186 operator[](patchi).updateMesh(pBufs);
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;
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);
int debug
Static debugging option.
List< label > labelList
A List of labels.
label size() const noexcept
The number of elements in table.
labelList patchSizes() const
Return a list of patch sizes.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
bool isPattern() const noexcept
The wordRe is treated as a pattern, not as literal string.
label nFaces() const
The number of boundary faces in the underlying mesh.
void matchGroups(const labelUList &patchIDs, wordList &groups, labelHashSet &nonGroupPatches) const
Match the patches to groups.
A class for handling words, derived from Foam::string.
List< lduScheduleEntry > lduSchedule
wordList physicalTypes() const
Return a list of physical types.
void resize(const label len)
Adjust allocated size of list.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
static word defaultRegion
Return the default region name.
static void scatterList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Scatter data. Reverse of gatherList.
A List obtained as a section of another List.
label nEdges() const
Number of edges in patch.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
const HashTable< labelList > & groupPatchIDs() const
The patch indices per patch group.
void reorder(const labelUList &oldToNew, const bool validBoundary)
Reorders patches. Ordering does not have to be done in.
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 edge &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
labelList findMatching(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
Extract list indices for all items with 'name()' that matches.
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)
Am I the master process.
Functions to operate on Pointer Lists.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const T * set(const label i) const
Return const pointer to element (can be nullptr),.
static commsTypes defaultCommsType
Default commsType.
void clearGeom()
Clear geometry at this level and at patches.
virtual Ostream & beginBlock(const keyType &kw)
Write begin block group with the given name.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
Ostream & incrIndent(Ostream &os)
Increment the indent level.
void clearAddressing()
Clear addressing at this level and at patches.
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
label start() const
The start label of the boundary faces in the polyMesh face list.
label findIndex(const wordRe &key) const
Return patch index for the first match, return -1 if not found.
wordList types() const
Return a list of patch types.
Mesh consisting of general polyhedral cells.
wordList names() const
Return a list of patch names.
labelRange range() const
The face range for all boundary faces.
#define forAll(list, i)
Loop across all elements in list.
bool good() const noexcept
True if next operation might succeed.
bool match(const std::string &text, bool literal=false) const
Smart match as literal or regex, stopping on the first match.
Pair< label > labelPair
A pair of labels.
List< word > wordList
A List of words.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
const labelList & patchID() const
Per boundary face label the patch index.
bool checkParallelSync(const bool report=false) const
Check whether all procs have all patches and in same order. Return.
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)
Range of process indices for sub-processes.
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)
Erase an entry specified by given iterator.
messageStream Info
Information stream (stdout output on master, null elsewhere)
A patch is a list of labels that address the faces in the global face list.
UPtrList< const labelUList > faceCells() const
Return a list of faceCells for each patch.
bool checkDefinition(const bool report=false) const
Check boundary definition. Return true if in error.
PtrList< polyPatch > polyPatchList
container classes for polyPatch
void setSize(const label n)
Alias for resize()
DynamicList< T, SizeMin > & append(const T &val)
Append an element to the end of this list.
void transfer(List< T > &list)
The IOstreamOption is a simple container for options an IOstream can normally have.
void setSize(const label newLen)
Same as resize()
labelList patchStarts() const
Return a list of patch start face indices.
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.
Extract name (as a word) from an object, typically using its name() method.
label whichPatch(const label faceIndex) const
Return patch index for a given face label.
ListType reorder(const labelUList &oldToNew, const ListType &input, const bool prune=false)
Reorder the elements of a list.
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
Find patch index given a name, return -1 if not found.
void append(T *ptr)
Append an element to the end of the list.
void finishedSends(const bool block=true)
Mark all sends as having been done.
virtual Ostream & endBlock()
Write end block group.
virtual bool check(const char *operation) const
Check IOstream status for given operation.
static autoPtr< polyPatch > New(const word &patchType, const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm)
Return pointer to a new patch created on freestore from components.
OBJstream os(runTime.globalPath()/outputName)
virtual bool writeObject(IOstreamOption streamOpt, const bool valid) const
Write using stream options.
const lduSchedule & patchSchedule() const
Order in which the patches should be initialised/evaluated.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
errorManip< error > abort(error &err)
iterator find(const edge &key)
Find and return an iterator set at the hashed entry.
void movePoints(const pointField &p)
Correct polyBoundaryMesh after moving points.
errorManipArg< error, int > exit(error &err, const int errNo=1)
const Field< point_type > & localPoints() const
Return pointField of points in patch.
A HashTable similar to std::unordered_map.
void updateMesh()
Correct polyBoundaryMesh after topology update.
label nNonProcessor() const
The number of patches before the first processor patch.
label nInternalEdges() const
Number of internal edges.
virtual bool writeData(Ostream &os) const
writeData member function required by regIOobject
const word & name() const noexcept
Return name.
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
Report an error message using Foam::FatalError.
static void gatherList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Gather data but keep individual values separate.
const List< labelPairList > & neighbourEdges() const
Per patch the edges on the neighbouring patch.
static int myProcNo(const label communicator=worldComm)
Number of this process (starting from masterNo() = 0)
forAllConstIters(mixture.phases(), phase)
virtual bool writeObject(IOstreamOption streamOpt, const bool valid) const
Write using stream options.
label nInternalFaces() const noexcept
Number of internal faces.
static bool & parRun() noexcept
Test if this a parallel run.
labelList indices(const wordRe &matcher, const bool useGroups=true) const
Return (sorted) patch indices for all matches.
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)
Set/add group with patches.
const dimensionedScalar e
Elementary charge.
A List of wordRe with additional matching capabilities.
labelHashSet patchSet(const UList< wordRe > &patchNames, const bool warnNotFound=true, const bool useGroups=true) const
Return the set of patch IDs corresponding to the given names.
List< labelRange > patchRanges() const
Return a list of patch ranges.
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
label firstMatching(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
Find first list item with 'name()' that matches, -1 on failure.
const polyBoundaryMesh & patches
Operations on lists of strings.
label nFaces() const noexcept
Number of mesh faces.
const word & name() const noexcept
The patch name.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
const globalMeshData & globalData() const
Return parallel info.
compressionType compression() const noexcept
Get the stream compression.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
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)
Extract list indices for all matches.
defineTypeNameAndDebug(combustionModel, 0)
Extract type (as a word) from an object, typically using its type() method.
#define WarningInFunction
Report a warning using Foam::Warning.
Smooth ATC in cells next to a set of patches supplied by type.
bool match(const std::string &text, bool literal=false) const
Smart match as regular expression or as a string.
static label nProcs(const label communicator=worldComm)
Number of processes in parallel run, and 1 for serial run.