Go to the documentation of this file.
28 #include "primitiveMesh.H"
58 readOpt() == IOobject::MUST_READ
59 || readOpt() == IOobject::MUST_READ_IF_MODIFIED
62 if (readOpt() == IOobject::MUST_READ_IF_MODIFIED)
65 <<
"Specified IOobject::MUST_READ_IF_MODIFIED but class"
66 <<
" does not support automatic rereading."
74 Istream& is = readStream(typeName);
86 patchEntries[patchI].keyword(),
87 patchEntries[patchI].
dict(),
97 "polyBoundaryMesh::polyBoundaryMesh"
98 "(const IOobject&, const polyMesh&)"
132 (this->readOpt() == IOobject::READ_IF_PRESENT && this->headerOk())
133 || this->readOpt() == IOobject::MUST_READ
134 || this->readOpt() == IOobject::MUST_READ_IF_MODIFIED
138 if (readOpt() == IOobject::MUST_READ_IF_MODIFIED)
141 <<
"Specified IOobject::MUST_READ_IF_MODIFIED but class"
142 <<
" does not support automatic rereading."
149 Istream& is = readStream(typeName);
161 patchEntries[patchI].keyword(),
162 patchEntries[patchI].
dict(),
172 "polyBoundaryMesh::polyBoundaryMesh"
173 "(const IOobject&, const polyMesh&, const polyPatchList&)"
184 patches.set(patchI, ppl[patchI].clone(*this).ptr());
200 operator[](patchI).clearGeom();
207 neighbourEdgesPtr_.clear();
209 groupPatchIDsPtr_.clear();
213 operator[](patchI).clearAddressing();
232 operator[](patchI).initGeometry(pBufs);
239 operator[](patchI).calcGeometry(pBufs);
249 forAll(patchSchedule, patchEvali)
251 const label patchI = patchSchedule[patchEvali].patch;
253 if (patchSchedule[patchEvali].init)
255 operator[](patchI).initGeometry(pBufs);
259 operator[](patchI).calcGeometry(pBufs);
272 <<
"Neighbour edge addressing not correct across parallel"
273 <<
" boundaries." <<
endl;
276 if (!neighbourEdgesPtr_.valid())
282 label nEdgePairs = 0;
285 const polyPatch& pp = operator[](patchI);
289 forAll(neighbourEdges[patchI], i)
291 labelPair& edgeInfo = neighbourEdges[patchI][i];
306 const polyPatch& pp = operator[](patchI);
313 edgei < edges.
size();
318 const edge&
e = edges[edgei];
324 pointsToEdge.
find(meshEdge);
326 if (fnd == pointsToEdge.end())
348 neighbourEdges[edgeInfo[0]][edgeInfo[1]]
354 pointsToEdge.
erase(meshEdge);
359 if (pointsToEdge.
size())
362 <<
"Not all boundary edges of patches match up." <<
nl
363 <<
"Is the outside of your mesh multiply connected?"
369 const polyPatch& pp = operator[](patchI);
377 if (edgeInfo[0] == -1 || edgeInfo[1] == -1)
383 <<
"Not all boundary edges of patches match up." <<
nl
384 <<
"Edge " << edgeI <<
" on patch " << pp.
name()
387 <<
" edge on any other patch." <<
nl
388 <<
"Is the outside of your mesh multiply connected?"
395 return neighbourEdgesPtr_();
401 if (!patchIDPtr_.valid())
408 - mesh_.nInternalFaces()
417 label bFaceI = bm[patchI].start() - mesh_.nInternalFaces();
420 patchID[bFaceI++] = patchI;
424 return patchIDPtr_();
431 if (!groupPatchIDsPtr_.valid())
440 const wordList& groups = bm[patchI].inGroups();
449 <<
"Patch " << bm[patchI].
name()
450 <<
" specifies a group " <<
name
451 <<
" which is also a patch name."
452 <<
" This might give problems later on." <<
endl;
461 if (iter != groupPatchIDs.end())
463 iter().append(patchI);
472 return groupPatchIDsPtr_();
478 const word& groupName,
482 groupPatchIDsPtr_.clear();
491 label patchI = patchIDs[i];
498 donePatch[patchI] =
true;
504 if (!donePatch[patchI])
515 if (groups[i] != groupName)
517 groups[newI++] = groups[i];
535 t[patchI] =
patches[patchI].name();
550 t[patchI] =
patches[patchI].type();
565 t[patchI] =
patches[patchI].physicalType();
575 const bool usePatchGroups
586 if (usePatchGroups && groupPatchIDs().size())
590 const wordList allGroupNames = groupPatchIDs().toc();
594 const word& grpName = allGroupNames[groupIDs[i]];
595 const labelList& patchIDs = groupPatchIDs()[grpName];
598 if (indexSet.
insert(patchIDs[j]))
600 indices.
append(patchIDs[j]);
614 if (key ==
operator[](i).
name())
621 if (usePatchGroups && groupPatchIDs().size())
624 groupPatchIDs().find(key);
626 if (iter != groupPatchIDs().end())
633 if (indexSet.
insert(patchIDs[j]))
635 indices.
append(patchIDs[j]);
656 if (!indices.empty())
665 if (key ==
operator[](i).
name())
693 Pout<<
"label polyBoundaryMesh::findPatchID(const word&) const"
694 <<
"Patch named " << patchName <<
" not found. "
695 <<
"List of available patch names: " << names() <<
endl;
709 if (faceIndex <
mesh().nInternalFaces())
713 else if (faceIndex >=
mesh().nFaces())
716 <<
"given label " << faceIndex
717 <<
" greater than the number of geometric faces " <<
mesh().
nFaces()
724 const polyPatch& bp = operator[](patchI);
728 faceIndex >= bp.
start()
729 && faceIndex < bp.
start() + bp.size()
738 <<
"Cannot find face " << faceIndex <<
" in any of the patches "
740 <<
"It seems your patches are not consistent with the mesh :"
742 <<
" total number of faces:" <<
mesh().
nFaces()
752 const bool warnNotFound,
753 const bool usePatchGroups
756 const wordList allPatchNames(this->names());
772 if (patchIDs.empty())
776 const wordList allGroupNames = groupPatchIDs().toc();
783 const word&
name = allGroupNames[groupIDs[i]];
786 forAll(extraPatchIDs, extraI)
788 ids.
insert(extraPatchIDs[extraI]);
792 if (groupIDs.empty() && warnNotFound)
795 <<
"Cannot find any patch or group names matching "
800 else if (warnNotFound)
803 <<
"Cannot find any patch names matching " << patchName
830 groupPatchIDs.
begin();
831 iter != groupPatchIDs.end();
842 label nMatch = nonGroupPatches.
erase(groupPatchSet);
844 if (nMatch == groupPatchSet.
size())
846 matchedGroups.
append(iter.key());
848 else if (nMatch != 0)
851 nonGroupPatches.
transfer(oldNonGroupPatches);
869 bool hasError =
false;
879 if (!isA<processorPolyPatch>(bm[patchI]))
881 if (nonProcI != patchI)
888 Pout<<
" ***Problem with boundary patch " << patchI
889 <<
" named " << bm[patchI].
name()
890 <<
" of type " << bm[patchI].type()
891 <<
". The patch seems to be preceeded by processor"
892 <<
" patches. This is can give problems."
898 names[nonProcI] = bm[patchI].
name();
899 types[nonProcI] = bm[patchI].type();
919 for (
label procI = 1; procI < allNames.
size(); ++procI)
923 (allNames[procI] != allNames[0])
924 || (allTypes[procI] != allTypes[0])
931 Info<<
" ***Inconsistent patches across processors, "
932 "processor 0 has patch names:" << allNames[0]
933 <<
" patch types:" << allTypes[0]
934 <<
" processor " << procI <<
" has patch names:"
936 <<
" patch types:" << allTypes[procI]
951 bool hasError =
false;
957 if (bm[patchI].start() != nextPatchStart && !hasError)
961 Info<<
" ****Problem with boundary patch " << patchI
962 <<
" named " << bm[patchI].
name()
963 <<
" of type " << bm[patchI].type()
964 <<
". The patch should start on face no " << nextPatchStart
965 <<
" and the patch specifies " << bm[patchI].start()
967 <<
"Possibly consecutive patches have this same problem."
968 <<
" Suppressing future warnings." <<
endl;
975 Info<<
" ****Duplicate boundary patch " << patchI
976 <<
" named " << bm[patchI].
name()
977 <<
" of type " << bm[patchI].type()
979 <<
"Suppressing future warnings." <<
endl;
982 nextPatchStart += bm[patchI].
size();
991 Pout<<
" ***Boundary definition is in error." <<
endl;
995 Info<<
" Boundary definition OK." <<
endl;
1015 operator[](patchI).initMovePoints(pBufs,
p);
1022 operator[](patchI).movePoints(pBufs,
p);
1032 forAll(patchSchedule, patchEvali)
1034 const label patchI = patchSchedule[patchEvali].patch;
1036 if (patchSchedule[patchEvali].init)
1038 operator[](patchI).initMovePoints(pBufs,
p);
1042 operator[](patchI).movePoints(pBufs,
p);
1051 neighbourEdgesPtr_.clear();
1052 patchIDPtr_.clear();
1053 groupPatchIDsPtr_.clear();
1065 operator[](patchI).initUpdateMesh(pBufs);
1072 operator[](patchI).updateMesh(pBufs);
1082 forAll(patchSchedule, patchEvali)
1084 const label patchI = patchSchedule[patchEvali].patch;
1086 if (patchSchedule[patchEvali].init)
1088 operator[](patchI).initUpdateMesh(pBufs);
1092 operator[](patchI).updateMesh(pBufs);
1102 const bool validBoundary
1113 patches[patchI].index() = patchI;
1140 os.
check(
"polyBoundaryMesh::writeData(Ostream& os) const");
1160 const word& patchName
1168 <<
"Patch named " << patchName <<
" not found." <<
nl
1169 <<
"Available patch names: " << names() <<
endl
1173 return operator[](patchI);
1179 const word& patchName
1187 <<
"Patch named " << patchName <<
" not found." <<
nl
1188 <<
"Available patch names: " << names() <<
endl
1192 return operator[](patchI);
const HashTable< labelList, word > & groupPatchIDs() const
Per patch group the patch indices.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
label findPatchID(const word &patchName) const
Find patch index given a name.
virtual bool writeObject(IOstream::streamFormat, IOstream::versionNumber, IOstream::compressionType) const
Write using given format, version and compression.
void matchGroups(const labelUList &patchIDs, wordList &groups, labelHashSet &nonGroupPatches) const
Match the patches to groups. Returns all the (fully matched) groups.
A class for handling words, derived from string.
autoPtr< BasicCompressibleTurbulenceModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleTurbulenceModel::transportModel &transport, const word &propertiesName)
wordList physicalTypes() const
Return a list of physical types.
List< label > labelList
A List of labels.
An STL-conforming iterator.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
#define forAll(list, i)
Loop across all elements in list.
void movePoints(const pointField &)
Correct polyBoundaryMesh after moving points.
void transfer(HashTable< T, Key, Hash > &)
Transfer the contents of the argument table into this table.
bool writeObject(IOstream::streamFormat fmt, IOstream::versionNumber ver, IOstream::compressionType cmp) const
Write using given format, version and form uncompression.
bool isPattern() const
Should be treated as a match rather than a literal string.
static void scatterList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Scatter data. Reverse of gatherList.
const Field< PointType > & localPoints() const
Return pointField of points in patch.
compressionType
Enumeration for the format of data in the stream.
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).
An STL-conforming const_iterator.
static bool & parRun()
Is this a parallel run?
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static commsTypes defaultCommsType
Default commsType.
void clearGeom()
Clear geometry at this level and at patches.
void reorder(const labelUList &, const bool validBoundary)
Reorders patches. Ordering does not have to be done in.
Ostream & incrIndent(Ostream &os)
Increment the indent level.
void clearAddressing()
Clear addressing at this level and at patches.
A wordRe is a word, but can also have a regular expression for matching words.
label findIndex(const keyType &) 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.
An STL-conforming iterator.
void setGroup(const word &groupName, const labelList &patchIDs)
Set/add group with patches.
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)
labelList findIndices(const keyType &, const bool usePatchGroups=true) const
Return patch indices for all matches. Optionally matches patchGroups.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
bool inGroup(const word &) const
Test if in group.
Pre-declare SubField and related Field type.
const wordList & inGroups() const
Return the optional groups patch belongs to.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
void append(const T &)
Append an element at the end of the list.
~polyBoundaryMesh()
Destructor.
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.
PtrList< polyPatch > polyPatchList
container classes for polyPatch
void setCapacity(const label)
Alter the size of the underlying storage.
bool erase(const iterator &)
Erase a hashedEntry specified by given iterator.
label whichPatch(const label faceIndex) const
Return patch index for a given face label.
const word & name() const
Return name.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
wordList patchNames(nPatches)
Ostream & operator<<(Ostream &, const edgeMesh &)
label findPatchID(const polyBoundaryMesh &patches, const word &name)
void finishedSends(const bool block=true)
Mark all sends as having been done. This will start receives.
void reorder(const labelUList &)
Reorders elements. Ordering does not have to be done in.
virtual bool check(const char *operation) const
Check IOstream status for given operation.
label size() const
Return number of elements in table.
label nInternalFaces() const
const lduSchedule & patchSchedule() const
Order in which the patches should be initialised/evaluated.
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
errorManip< error > abort(error &err)
const double e
Elementary charge.
Ostream & indent(Ostream &os)
Indent stream.
label start() const
Return start label of this patch in the polyMesh face list.
void calcGeometry()
Calculate the geometry for the patches (transformation tensors etc.)
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
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.
An STL-conforming hash table.
void updateMesh()
Correct polyBoundaryMesh after topology update.
label nInternalEdges() const
Number of internal edges.
void setSize(const label)
Reset size of List.
bool writeData(Ostream &) const
writeData member function required by regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
bool findStrings(const wordReListMatcher &matcher, const std::string &str)
Return true if string matches one of the regular expressions.
#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. Is for every external.
iterator begin()
Iterator set to the beginning of the HashTable.
An ordered pair of two objects of type <T> with first() and second() elements.
prefixOSstream Pout(cout, "Pout")
polyBoundaryMesh(const polyBoundaryMesh &)
Disallow construct as copy.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
label size() const
Return the number of elements in the PtrList.
bool insert(const Key &key)
Insert a new entry.
friend Ostream & operator(Ostream &, const PtrList< T > &)
Operations on lists of strings.
void size(const label)
Override size to be inconsistent with allocated storage.
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.
labelHashSet patchSet(const UList< wordRe > &patchNames, const bool warnNotFound=true, const bool usePatchGroups=true) const
Return the set of patch IDs corresponding to the given names.
HashSet< label, Hash< label > > labelHashSet
A HashSet with label keys.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
defineTypeNameAndDebug(combustionModel, 0)
labelList findIndices(const ListType &, typename ListType::const_reference, const label start=0)
Find all occurences of given element. Linear search.
const word & name() const
Return name.
#define WarningInFunction
Report a warning using Foam::Warning.
Pair< label > labelPair
Label pair.
word name(const complex &)
Return a string representation of a complex.
streamFormat
Enumeration for the format of data in the stream.