Go to the documentation of this file.
51 template<
class ListType,
class GetOp>
58 const label len = list.size();
62 for (label i = 0; i < len; ++i)
64 output[i] = getop(list[i]);
72 template<
class UnaryMatchPredicate>
76 const UnaryMatchPredicate& matcher
79 const label len = list.size();
84 for (label i = 0; i < len; ++i)
86 if (matcher(list[i].
name()))
99 template<
class UnaryMatchPredicate>
103 const UnaryMatchPredicate& matcher
106 const label len = list.size();
108 for (label i = 0; i < len; ++i)
110 if (matcher(list[i].
name()))
124 Foam::polyBoundaryMesh::polyBoundaryMesh
136 readOpt() == IOobject::MUST_READ
137 || readOpt() == IOobject::MUST_READ_IF_MODIFIED
141 warnNoRereading<polyBoundaryMesh>();
146 Istream& is = readStream(typeName);
149 patches.setSize(patchEntries.size());
158 patchEntries[patchi].keyword(),
159 patchEntries[patchi].
dict(),
173 Foam::polyBoundaryMesh::polyBoundaryMesh
186 Foam::polyBoundaryMesh::polyBoundaryMesh
199 (this->readOpt() == IOobject::READ_IF_PRESENT && this->headerOk())
200 || this->readOpt() == IOobject::MUST_READ
201 || this->readOpt() == IOobject::MUST_READ_IF_MODIFIED
205 warnNoRereading<polyBoundaryMesh>();
210 Istream& is = readStream(typeName);
213 patches.setSize(patchEntries.size());
222 patchEntries[patchi].keyword(),
223 patchEntries[patchi].
dict(),
240 patches.set(patchi, ppl[patchi].clone(*this).ptr());
261 neighbourEdgesPtr_.clear();
263 groupPatchIDsPtr_.clear();
276 void Foam::polyBoundaryMesh::calcGeometry()
288 operator[](patchi).initGeometry(pBufs);
291 pBufs.finishedSends();
295 operator[](patchi).calcGeometry(pBufs);
303 pBufs.finishedSends();
305 for (
const auto& patchEval : patchSchedule)
307 const label patchi = patchEval.patch;
311 operator[](patchi).initGeometry(pBufs);
315 operator[](patchi).calcGeometry(pBufs);
328 <<
"Neighbour edge addressing not correct across parallel"
329 <<
" boundaries." <<
endl;
332 if (!neighbourEdgesPtr_.valid())
338 label nEdgePairs = 0;
341 const polyPatch& pp = operator[](patchi);
345 for (
labelPair& edgeInfo : neighbourEdges[patchi])
360 const polyPatch& pp = operator[](patchi);
367 edgei < edges.size();
372 const edge&
e = edges[edgei];
377 auto fnd = pointsToEdge.
find(meshEdge);
401 neighbourEdges[edgeInfo[0]][edgeInfo[1]]
407 pointsToEdge.
erase(meshEdge);
412 if (pointsToEdge.
size())
415 <<
"Not all boundary edges of patches match up." <<
nl
416 <<
"Is the outside of your mesh multiply connected?"
422 const polyPatch& pp = operator[](patchi);
430 if (edgeInfo[0] == -1 || edgeInfo[1] == -1)
436 <<
"Not all boundary edges of patches match up." <<
nl
437 <<
"Edge " << edgei <<
" on patch " << pp.
name()
440 <<
" edge on any other patch." <<
nl
441 <<
"Is the outside of your mesh multiply connected?"
448 return *neighbourEdgesPtr_;
454 if (!patchIDPtr_.valid())
456 patchIDPtr_.reset(
new labelList(mesh_.nBoundaryFaces()));
467 (
patches[patchi].start() - mesh_.nInternalFaces())
479 if (!groupPatchIDsPtr_.valid())
482 auto& groupPatchIDs = *groupPatchIDsPtr_;
490 for (
const word& groupName : groups)
492 auto iter = groupPatchIDs.find(groupName);
500 groupPatchIDs.insert(groupName,
labelList(
one(), patchi));
511 <<
"Removed patchGroup '" <<
patches[patchi].
name()
512 <<
"' which clashes with patch " << patchi
513 <<
" of the same name."
519 return *groupPatchIDsPtr_;
525 const word& groupName,
529 groupPatchIDsPtr_.clear();
536 for (
const label patchi : patchIDs)
544 donePatch[patchi] =
true;
550 if (!donePatch[patchi])
561 if (groups[i] != groupName)
563 groups[newI++] = groups[i];
581 if (isA<processorPolyPatch>(
p))
608 getMethodImpl<wordList>
611 [](
const polyPatch&
p) {
return p.physicalType(); }
619 getMethodImpl<labelList>
630 getMethodImpl<labelList>
640 return mesh_.nInternalFaces();
646 return mesh_.nBoundaryFaces();
652 return labelRange(mesh_.nInternalFaces(), mesh_.nBoundaryFaces());
664 return (*
this)[patchi].range();
683 const regExp matcher(key);
688 if (useGroups && !groupPatchIDs().empty())
692 groupPatchIDs().tocKeys(matcher)
695 if (groupNames.size())
699 for (
const word& grpName : groupNames)
702 groupIndices.
insert( groupPatchIDs()[grpName] );
705 groupIndices.
erase(patchIndices);
715 const word& matcher = key;
725 if (useGroups && !groupPatchIDs().empty())
727 const auto iter = groupPatchIDs().cfind(key);
734 groupIndices.
erase(patchIndices);
735 patchIndices.
append(groupIndices.sortedToc());
759 const word& matcher = key;
767 const word& patchName,
783 regionStr =
"in region '" + mesh_.name() +
"' ";
787 <<
"Patch '" << patchName <<
"' not found. "
788 <<
"Available patch names " << regionStr <<
"include: " << names()
795 Pout<<
"label polyBoundaryMesh::findPatchID(const word&) const"
796 <<
"Patch named " << patchName <<
" not found. "
797 <<
"List of available patch names: " << names() <<
endl;
811 if (faceIndex <
mesh().nInternalFaces())
815 else if (faceIndex >=
mesh().nFaces())
818 <<
"Face " << faceIndex
819 <<
" out of bounds. Number of geometric faces " <<
mesh().
nFaces()
835 [](
const polyPatch&
p, label val) {
return (
p.start() <= val); }
838 if (patchi < 0 || !
patches[patchi].
range().found(faceIndex))
842 <<
"Face " << faceIndex <<
" not found in any of the patches "
844 <<
"The patches appear to be inconsistent with the mesh :"
846 <<
" total number of faces:" <<
mesh().
nFaces()
859 const bool warnNotFound,
863 const wordList allPatchNames(this->names());
873 if (patchIndices.empty())
881 groupPatchIDs().tocKeys(patchName)
884 for (
const word& grpName : groupNames)
886 ids.
insert( groupPatchIDs()[grpName] );
889 if (groupNames.empty() && warnNotFound)
892 <<
"Cannot find any patch or group names matching "
897 else if (warnNotFound)
900 <<
"Cannot find any patch names matching " << patchName
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 <<
" named " << bm[patchi].
name()
980 <<
" of type " << bm[patchi].type()
981 <<
". The patch seems to be preceeded by processor"
982 <<
" patches. This is can give problems."
988 names[nonProci] = bm[patchi].
name();
989 types[nonProci] = bm[patchi].type();
995 types.setSize(nonProci);
1014 (allNames[proci] != allNames.first())
1015 || (allTypes[proci] != allTypes.first())
1022 Info<<
" ***Inconsistent patches across processors, "
1023 "processor 0 has patch names:"
1025 <<
" patch types:" << allTypes.first()
1026 <<
" processor " << proci
1027 <<
" has patch names:" << allNames[proci]
1028 <<
" patch types:" << allTypes[proci]
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& patchEval : patchSchedule)
1126 const label patchi = patchEval.patch;
1130 operator[](patchi).initMovePoints(pBufs,
p);
1134 operator[](patchi).movePoints(pBufs,
p);
1143 neighbourEdgesPtr_.clear();
1144 patchIDPtr_.clear();
1145 groupPatchIDsPtr_.clear();
1157 operator[](patchi).initUpdateMesh(pBufs);
1164 operator[](patchi).updateMesh(pBufs);
1174 for (
const auto& patchEval : patchSchedule)
1176 const label patchi = patchEval.patch;
1180 operator[](patchi).initUpdateMesh(pBufs);
1184 operator[](patchi).updateMesh(pBufs);
1194 const bool validBoundary
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);
int debug
Static debugging option.
List< label > labelList
A List of labels.
General get operation to extract the 'type' from an object as a word.
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,...
label nFaces() const
The number of boundary faces in the underlying mesh.
const word & name() const
Return name.
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.
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.
bool isPattern() const
The keyType is treated as a pattern, not as literal string.
label nInternalFaces() const
Number of internal faces.
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 findIndex(const keyType &key) const
Return patch index for the first match, return -1 if not found.
label nFaces() const
Number of mesh faces.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
label nEdges() const
Return number of edges in patch.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
const HashTable< labelList > & groupPatchIDs() const
The patch indices per patch group.
static bool & parRun()
Is this a parallel run?
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...
bool insert(const edge &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
A class representing the concept of 1 (one) that can be used to avoid manipulating objects known to b...
void append(const T &val)
Append an element at the end of the list.
Ostream & endl(Ostream &os)
Add newline and flush stream.
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
An Ostream wrapper for parallel output to std::cout.
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.
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.
label findIndexImpl(const faPatchList &list, const UnaryMatchPredicate &matcher)
static labelList indicesImpl(const faPatchList &list, const UnaryMatchPredicate &matcher)
Pair< label > labelPair
A pair of labels.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
A class for handling keywords in dictionaries.
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)
label findLower(const ListType &input, const T &val, const label start, const ComparePredicate &comp)
const wordList & inGroups() const
The (optional) groups that the patch belongs to.
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.
bool inGroup(const word &name) const
True if the patch is in named group.
messageStream Info
Information stream (uses stdout - output is on the master only)
A patch is a list of labels that address the faces in the global face list.
bool checkDefinition(const bool report=false) const
Check boundary definition. Return true if in error.
word name(const complex &c)
Return string representation of complex.
PtrList< polyPatch > polyPatchList
container classes for polyPatch
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 range or interval of labels defined by a start and a size.
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)
Wrapper around C++11 regular expressions.
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 resize(const label newSize)
Adjust allocated size of list.
void finishedSends(const bool block=true)
Mark all sends as having been done. This will start receives.
virtual Ostream & endBlock()
Write end block group.
virtual bool check(const char *operation) const
Check IOstream status for given operation.
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.
General get operation to extract the 'name' from an object as a word.
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
labelList findStrings(const regExp &matcher, const UList< StringType > &input, const bool invert=false)
Return list indices for strings matching the regular expression.
errorManip< error > abort(error &err)
List< Key > sortedToc() const
The table of contents (the keys) in sorted order.
iterator find(const edge &key)
Find and return an iterator set at the hashed entry.
void transfer(HashTable< T, Key, Hash > &rhs)
Transfer contents into this table.
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.
labelList indices(const keyType &key, const bool useGroups=true) const
Return patch indices for all matches.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
static bool master(const label communicator=0)
Am I the master process.
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.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
virtual bool writeData(Ostream &os) const
writeData member function required by regIOobject
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.
forAllConstIters(mixture.phases(), phase)
FlatOutput< Container > flatOutput(const Container &obj, label len=0)
Global flatOutput function.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
virtual bool writeObject(IOstreamOption streamOpt, const bool valid) const
Write using stream options.
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.
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.
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
const polyBoundaryMesh & patches
Operations on lists of strings.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
const globalMeshData & globalData() const
Return parallel info.
bool good() const
Return true if next operation might succeed.
compressionType compression() const noexcept
Get the stream compression.
HashSet< label, Hash< label > > labelHashSet
A HashSet with label keys and label hasher.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
void setSize(const label newSize)
Alias for resize(const label)
Begin list [isseparator].
defineTypeNameAndDebug(combustionModel, 0)
const word & name() const
The patch name.
#define WarningInFunction
Report a warning using Foam::Warning.
static ListType getMethodImpl(const faPatchList &list, const GetOp &getop)