51bool Foam::polyBoundaryMesh::hasGroupIDs()
const
56 return !groupIDsPtr_->empty();
73void 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."
110bool Foam::polyBoundaryMesh::readContents(
const bool allowReadIfPresent)
124 warnNoRereading<polyBoundaryMesh>();
129 Istream& is = readStream(typeName);
132 PtrList<entry> patchEntries(is);
143 patchEntries[patchi].keyword(),
144 patchEntries[patchi].
dict(),
200 if (!readContents(
true))
227 neighbourEdgesPtr_.clear();
229 groupIDsPtr_.clear();
242void Foam::polyBoundaryMesh::calcGeometry()
254 operator[](patchi).initGeometry(pBufs);
257 pBufs.finishedSends();
261 operator[](patchi).calcGeometry(pBufs);
269 pBufs.finishedSends();
271 for (
const auto& schedEval : patchSchedule)
273 const label patchi = schedEval.patch;
277 operator[](patchi).initGeometry(pBufs);
281 operator[](patchi).calcGeometry(pBufs);
310 <<
"Neighbour edge addressing not correct across parallel"
311 <<
" boundaries." <<
endl;
314 if (!neighbourEdgesPtr_)
317 auto& neighbourEdges = *neighbourEdgesPtr_;
320 label nEdgePairs = 0;
323 const polyPatch& pp = operator[](patchi);
327 for (
labelPair& edgeInfo : neighbourEdges[patchi])
342 const polyPatch& pp = operator[](patchi);
349 edgei < edges.
size();
354 const edge&
e = edges[edgei];
359 auto fnd = pointsToEdge.
find(meshEdge);
383 neighbourEdges[edgeInfo[0]][edgeInfo[1]]
389 pointsToEdge.
erase(meshEdge);
394 if (pointsToEdge.
size())
397 <<
"Not all boundary edges of patches match up." <<
nl
398 <<
"Is the outside of your mesh multiply connected?"
404 const polyPatch& pp = operator[](patchi);
412 if (edgeInfo[0] == -1 || edgeInfo[1] == -1)
418 <<
"Not all boundary edges of patches match up." <<
nl
419 <<
"Edge " << edgei <<
" on patch " << pp.
name()
422 <<
" edge on any other patch." <<
nl
423 <<
"Is the outside of your mesh multiply connected?"
430 return *neighbourEdgesPtr_;
438 patchIDPtr_.reset(
new labelList(mesh_.nBoundaryFaces()));
449 (
patches[patchi].start() - mesh_.nInternalFaces())
466 return *groupIDsPtr_;
472 const word& groupName,
476 groupIDsPtr_.clear();
483 for (
const label patchi : patchIDs)
485 patches[patchi].inGroups().appendUniq(groupName);
486 donePatch[patchi] =
true;
492 if (!donePatch[patchi])
496 if (groups.
found(groupName))
501 if (groups[i] != groupName)
503 groups[newi++] = groups[i];
521 if (isA<processorPolyPatch>(
p))
548 PtrListOps::get<word>
551 [](
const polyPatch&
p) {
return p.physicalType(); }
559 PtrListOps::get<label>
570 PtrListOps::get<label>
581 PtrListOps::get<labelRange>
591 return mesh_.nInternalFaces();
597 return mesh_.nBoundaryFaces();
603 return labelRange(mesh_.nInternalFaces(), mesh_.nBoundaryFaces());
615 return (*
this)[patchi].range();
631 const bool checkGroups = (useGroups && this->hasGroupIDs());
639 const auto& groupLookup = groupPatchIDs();
642 if (matcher.
match(iter.key()))
670 else if (checkGroups)
672 const auto iter = groupPatchIDs().cfind(matcher);
696 else if (matcher.
size() == 1)
698 return this->indices(matcher.
first(), useGroups);
704 if (useGroups && this->hasGroupIDs())
706 ids.
resize(2*this->size());
708 const auto& groupLookup = groupPatchIDs();
711 if (matcher.
match(iter.key()))
744 const word& patchName,
748 if (patchName.empty())
763 <<
"Patch '" << patchName <<
"' not found. "
764 <<
"Available patch names";
769 <<
" in region '" << mesh_.name() <<
"'";
773 <<
" include: " << names() <<
endl
780 Pout<<
"label polyBoundaryMesh::findPatchID(const word&) const"
781 <<
"Patch named " << patchName <<
" not found. "
782 <<
"Available patch names: " << names() <<
endl;
796 if (faceIndex <
mesh().nInternalFaces())
803 <<
"Face " << faceIndex
804 <<
" out of bounds. Number of geometric faces " <<
mesh().
nFaces()
820 [](
const polyPatch&
p, label val) {
return (
p.start() <= val); }
827 <<
"Face " << faceIndex <<
" not found in any of the patches "
829 <<
"The patches appear to be inconsistent with the mesh :"
831 <<
" total number of faces:" <<
mesh().
nFaces()
844 const bool warnNotFound,
848 const wordList allPatchNames(this->names());
852 const bool checkGroups = (useGroups && this->hasGroupIDs());
859 bool missed = matchIndices.
empty();
861 if (missed && checkGroups)
864 if (matcher.isPattern())
868 if (matcher.match(iter.key()))
878 const auto iter = groupPatchIDs().cfind(matcher);
889 if (missed && warnNotFound)
894 <<
"Cannot find any patch or group names matching "
900 <<
"Cannot find any patch names matching "
933 label nMatch = nonGroupPatches.
erase(groupPatchSet);
935 if (nMatch == groupPatchSet.
size())
937 matchedGroups.
append(iter.key());
939 else if (nMatch != 0)
942 nonGroupPatches.
transfer(oldNonGroupPatches);
959 bool hasError =
false;
969 if (!isA<processorPolyPatch>(bm[patchi]))
971 if (nonProci != patchi)
978 Pout<<
" ***Problem with boundary patch " << patchi
979 <<
" name:" << bm[patchi].
name()
980 <<
" type:" << bm[patchi].type()
981 <<
" - seems to be preceeded by processor patches."
982 <<
" This is usually a problem." <<
endl;
987 localNames[nonProci] = bm[patchi].
name();
988 localTypes[nonProci] = bm[patchi].type();
993 localNames.
resize(nonProci);
994 localTypes.
resize(nonProci);
1011 const auto procNames(allNames.slice(
procAddr.
range(proci)));
1014 if (procNames != localNames || procTypes != localTypes)
1018 if (debug || report)
1020 Info<<
" ***Inconsistent patches across processors, "
1021 "processor0 has patch names:" << localNames
1022 <<
" patch types:" << localTypes
1023 <<
" processor" << proci
1024 <<
" has patch names:" << procNames
1025 <<
" patch types:" << procTypes
1043 bool hasError =
false;
1049 if (bm[patchi].start() != nextPatchStart && !hasError)
1053 Info<<
" ****Problem with boundary patch " << patchi
1054 <<
" named " << bm[patchi].
name()
1055 <<
" of type " << bm[patchi].type()
1056 <<
". The patch should start on face no " << nextPatchStart
1057 <<
" and the patch specifies " << bm[patchi].
start()
1059 <<
"Possibly consecutive patches have this same problem."
1060 <<
" Suppressing future warnings." <<
endl;
1067 Info<<
" ****Duplicate boundary patch " << patchi
1068 <<
" named " << bm[patchi].
name()
1069 <<
" of type " << bm[patchi].type()
1071 <<
"Suppressing future warnings." <<
endl;
1074 nextPatchStart += bm[patchi].
size();
1079 if (debug || report)
1083 Pout<<
" ***Boundary definition is in error." <<
endl;
1087 Info<<
" Boundary definition OK." <<
endl;
1107 operator[](patchi).initMovePoints(pBufs,
p);
1114 operator[](patchi).movePoints(pBufs,
p);
1124 for (
const auto& schedEval : patchSchedule)
1126 const label patchi = schedEval.patch;
1130 operator[](patchi).initMovePoints(pBufs,
p);
1134 operator[](patchi).movePoints(pBufs,
p);
1143 neighbourEdgesPtr_.clear();
1144 patchIDPtr_.clear();
1145 groupIDsPtr_.clear();
1157 operator[](patchi).initUpdateMesh(pBufs);
1164 operator[](patchi).updateMesh(pBufs);
1174 for (
const auto& schedEval : patchSchedule)
1176 const label patchi = schedEval.patch;
1180 operator[](patchi).initUpdateMesh(pBufs);
1184 operator[](patchi).updateMesh(pBufs);
1194 const bool validBoundary
1198 polyPatchList::reorder(oldToNew);
1205 patches[patchi].index() = patchi;
1250 const word& patchName
1253 const label patchi = findPatchID(patchName);
1258 <<
"Patch named " << patchName <<
" not found." <<
nl
1259 <<
"Available patch names: " << names() <<
endl
1263 return operator[](patchi);
1269 const word& patchName
1272 const label patchi = findPatchID(patchName);
1277 <<
"Patch named " << patchName <<
" not found." <<
nl
1278 <<
"Available patch names: " << names() <<
endl
1282 return operator[](patchi);
Functions to operate on Pointer Lists.
globalIndex procAddr(aMesh.nFaces())
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void append(const T &val)
Copy append an element to the end of this list.
Map from edge (expressed as its endpoints) to value. For easier forward declaration it is currently i...
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
A HashTable similar to std::unordered_map.
List< Key > sortedToc() const
The table of contents (the keys) in sorted order.
bool empty() const noexcept
True if the hash table is empty.
void resize(const label sz)
Resize the hash table for efficiency.
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
void transfer(HashTable< T, Key, Hash > &rhs)
Transfer contents into this table.
label size() const noexcept
The number of elements in table.
iterator find(const Key &key)
Find and return an iterator set at the hashed entry.
bool erase(const iterator &iter)
Erase an entry specified by given iterator.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
const word & name() const noexcept
Return the object name.
autoPtr< IOobject > clone() const
Clone.
The IOstreamOption is a simple container for options an IOstream can normally have.
compressionType compression() const noexcept
Get the stream compression.
@ UNCOMPRESSED
compression = false
virtual bool check(const char *operation) const
Check IOstream status for given operation.
bool good() const noexcept
True if next operation might succeed.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void transfer(List< T > &list)
void resize(const label len)
Adjust allocated size of list.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
virtual Ostream & endBlock()
Write end block group.
virtual Ostream & beginBlock(const keyType &kw)
Write begin block group with the given name.
label nEdges() const
Number of edges in patch.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
label nInternalEdges() const
Number of internal edges.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
const Field< point_type > & localPoints() const
Return pointField of points in patch.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
UPstream::commsTypes commsType() const noexcept
The communications type of the stream.
void finishedSends(const bool wait=true)
Mark sends as done.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
const T * set(const label i) const
void append(T *ptr)
Append an element to the end of the list.
void resize(const label newLen)
Adjust size of PtrList.
const labelUList & indices() const noexcept
Return the list of sorted indices (updated every sort).
A List obtained as a section of another List.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
T & first()
Return the first element of the list.
bool found(const T &val, label pos=0) const
True if the value if found in the list.
bool empty() const noexcept
True if the UList is empty (ie, size() is zero)
SubList< T > slice(const label pos, label len=-1)
Return SubList slice (non-const access) - no range checking.
void size(const label n)
Older name for setAddressableSize.
@ nonBlocking
"nonBlocking"
static commsTypes defaultCommsType
Default commsType.
static bool & parRun() noexcept
Test if this a parallel run.
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
const T * set(const label i) const
label size() const noexcept
The number of elements in the list.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
friend Ostream & operator(Ostream &, const faMatrix< Type > &)
Smooth ATC in cells next to a set of patches supplied by type.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
labelRange range() const
Return start/size range of local processor data.
static void gather(const labelUList &offsets, const label comm, const ProcIDsContainer &procIDs, const UList< Type > &fld, List< Type > &allFld, const int tag=UPstream::msgType(), const UPstream::commsTypes=UPstream::commsTypes::nonBlocking)
Collect data in processor order on master (== procIDs[0]).
labelRange subProcs() const noexcept
Range of process indices for addressed sub-offsets (processes)
const lduSchedule & patchSchedule() const noexcept
const labelHashSet & patchSet() const
Wall patches to process.
A range or interval of labels defined by a start and a size.
void movePoints()
Update for new mesh geometry.
A class representing the concept of 1 (one) that can be used to avoid manipulating objects known to b...
const word & name() const noexcept
The patch name.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
bool checkDefinition(const bool report=false) const
Check boundary definition.
label nNonProcessor() const
The number of patches before the first processor patch.
wordList physicalTypes() const
Return a list of physical types.
const HashTable< labelList > & groupPatchIDs() const
The patch indices per patch group.
labelList patchStarts() const
Return a list of patch start face indices.
const List< labelPairList > & neighbourEdges() const
Per patch the edges on the neighbouring patch.
void reorder(const labelUList &oldToNew, const bool validBoundary)
Reorders patches. Ordering does not have to be done in.
wordList types() const
Return a list of patch types.
void clearGeom()
Clear geometry at this level and at patches.
label findPatchID(const word &patchName, const bool allowNotFound=true) const
Find patch index given a name, return -1 if not found.
UPtrList< const labelUList > faceCells() const
Return a list of faceCells for each patch.
virtual bool writeData(Ostream &os) const
writeData member function required by regIOobject
void setGroup(const word &groupName, const labelUList &patchIDs)
Set/add group with patches.
labelRange range() const noexcept
The face range for all boundary faces.
virtual bool writeObject(IOstreamOption streamOpt, const bool valid) const
Write using stream options.
label whichPatch(const label faceIndex) const
Return patch index for a given face label.
List< labelRange > patchRanges() const
Return a list of patch ranges.
void matchGroups(const labelUList &patchIDs, wordList &groups, labelHashSet &nonGroupPatches) const
Match the patches to groups.
void clearAddressing()
Clear addressing at this level and at patches.
label nFaces() const noexcept
The number of boundary faces in the underlying mesh.
label start() const noexcept
The start label of boundary faces in the polyMesh face list.
const labelList & patchID() const
Per boundary face label the patch index.
labelList patchSizes() const
Return a list of patch sizes.
wordList names() const
Return a list of patch names.
bool checkParallelSync(const bool report=false) const
Check whether all procs have all patches and in same order.
void updateMesh()
Correct polyBoundaryMesh after topology update.
label findIndex(const wordRe &key) const
Return patch index for the first match, return -1 if not found.
Mesh consisting of general polyhedral cells.
static word defaultRegion
Return the default region name.
const globalMeshData & globalData() const
Return parallel info.
A patch is a list of labels that address the faces in the global face list.
label nInternalFaces() const noexcept
Number of internal faces.
label nFaces() const noexcept
Number of mesh faces.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
virtual bool writeObject(IOstreamOption streamOpt, const bool valid) const
Write using stream options.
splitCell * master() const
@ BEGIN_LIST
Begin list [isseparator].
@ END_LIST
End list [isseparator].
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
bool isPattern() const noexcept
The wordRe is a pattern, not a literal string.
bool match(const std::string &text, bool literal=false) const
Smart match as regular expression or as a string.
A List of wordRe with additional matching capabilities.
bool match(const std::string &text, bool literal=false) const
Smart match as literal or regex, stopping on the first match.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
const polyBoundaryMesh & patches
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
const labelList nFaces(UPstream::listGatherValues< label >(aMesh.nFaces()))
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
#define WarningInFunction
Report a warning using Foam::Warning.
labelList findMatching(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
Extract list indices for all items with 'name()' that matches.
label firstMatching(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
Find first list item with 'name()' that matches, -1 on failure.
Pair< label > labelPair
A pair of labels.
PtrList< polyPatch > polyPatchList
Store lists of polyPatch as a PtrList.
List< word > wordList
A List of words.
List< label > labelList
A List of labels.
messageStream Info
Information stream (stdout output on master, null elsewhere)
labelList findMatchingStrings(const UnaryMatchPredicate &matcher, const UList< StringType > &input, const bool invert=false)
Extract list indices for all matches.
label findLower(const ListType &input, const T &val, const label start, const ComparePredicate &comp)
List< lduScheduleEntry > lduSchedule
A List of lduSchedule entries.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
errorManip< error > abort(error &err)
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
constexpr char nl
The newline '\n' character (0x0a)
wordList patchNames(nPatches)
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.
Operations on lists of strings.
Extract name (as a word) from an object, typically using its name() method.
Extract type (as a word) from an object, typically using its type() method.