46 bool Foam::faBoundaryMesh::hasGroupIDs()
const 51 return !groupIDsPtr_->empty();
58 if (!
p.inGroups().empty())
68 void Foam::faBoundaryMesh::calcGroupIDs()
const 75 groupIDsPtr_.reset(
new HashTable<labelList>(16));
76 auto& groupLookup = *groupIDsPtr_;
84 for (
const word& groupName : groups)
86 groupLookup(groupName).
append(patchi);
97 <<
"' which clashes with patch " << patchi
98 <<
" of the same name." 105 bool Foam::faBoundaryMesh::readContents(
const bool allowReadIfPresent)
110 || (allowReadIfPresent && isReadOptional() && headerOk())
114 warnNoRereading<faBoundaryMesh>();
119 Istream& is = readStream(typeName);
122 PtrList<entry> patchEntries(is);
133 patchEntries[patchi].keyword(),
134 patchEntries[patchi].
dict(),
184 groupIDsPtr_.reset(
nullptr);
205 (void)mesh_.edgeAreaNormals();
206 (void)mesh_.pointAreaNormals();
208 (void)mesh_.areaCentres();
209 (void)mesh_.faceAreaNormals();
222 operator[](patchi).initGeometry(pBufs);
225 pBufs.finishedSends();
229 operator[](patchi).calcGeometry(pBufs);
237 pBufs.finishedSends();
239 for (
const auto& patchEval : patchSchedule)
241 const label patchi = patchEval.patch;
245 operator[](patchi).initGeometry(pBufs);
249 operator[](patchi).calcGeometry(pBufs);
265 list.set(patchi, &
patches[patchi].edgeLabels());
281 list.set(patchi, &
patches[patchi].edgeFaces());
296 const lduInterface* lduPtr = isA<lduInterface>(
patches[patchi]);
300 list.set(patchi, lduPtr);
316 if (isA<processorFaPatch>(
p))
336 if (isA<processorFaPatch>(
p))
354 return *groupIDsPtr_;
360 const word& groupName,
364 groupIDsPtr_.clear();
373 patches[patchi].inGroups().appendUniq(groupName);
374 donePatch[patchi] =
true;
380 if (!donePatch[patchi])
384 if (groups.found(groupName))
389 if (groups[i] != groupName)
391 groups[newi++] = groups[i];
421 label beg = mesh_.nInternalEdges();
424 const label len =
patches[patchi].nEdges();
435 PtrListOps::get<label>
438 [](
const faPatch&
p) {
return p.nEdges(); }
449 label beg = mesh_.nInternalEdges();
452 const label len =
patches[patchi].nEdges();
453 list[patchi].reset(beg, len);
462 return this->groupPatchIDs().sortedToc();
468 return mesh_.nInternalEdges();
474 return mesh_.nBoundaryEdges();
480 return labelRange(mesh_.nInternalEdges(), mesh_.nBoundaryEdges());
496 const bool checkGroups = (useGroups && this->hasGroupIDs());
504 const auto& groupLookup = groupPatchIDs();
507 if (matcher.
match(iter.key()))
510 ids.insert(iter.val());
535 else if (checkGroups)
537 const auto iter = groupPatchIDs().cfind(matcher);
542 ids.insert(iter.val());
547 return ids.sortedToc();
553 const wordRes& matcher,
561 else if (matcher.size() == 1)
563 return this->indices(matcher.first(), useGroups);
569 if (useGroups && this->hasGroupIDs())
571 ids.
resize(2*this->size());
573 const auto& groupLookup = groupPatchIDs();
576 if (matcher.match(iter.key()))
579 ids.insert(iter.val());
593 return ids.sortedToc();
609 const word& patchName,
613 if (patchName.empty())
628 <<
"Patch '" << patchName <<
"' not found. " 629 <<
"Available patch names: " <<
names() <<
endl 636 Pout<<
"label faBoundaryMesh::findPatchID(const word&) const" 637 <<
"Patch named " << patchName <<
" not found. " 638 <<
"Available patch names: " <<
names() <<
endl;
648 if (edgeIndex <
mesh().nInternalEdges())
653 else if (edgeIndex >=
mesh().nEdges())
657 <<
"Edge " << edgeIndex
658 <<
" out of bounds. Number of geometric edges " <<
mesh().
nEdges()
668 label start = mesh_.patchStarts()[patchi];
669 label size = operator[](patchi).faPatch::size();
671 if (edgeIndex >= start && edgeIndex < start + size)
679 <<
"Error in patch search algorithm" 693 const faBoundaryMesh& bm = *
this;
695 bool hasError =
false;
705 if (!isA<processorFaPatch>(bm[patchi]))
707 if (nonProci != patchi)
714 Pout<<
" ***Problem with boundary patch " << patchi
715 <<
" name:" << bm[patchi].
name()
716 <<
" type:" << bm[patchi].
type()
717 <<
" - seems to be preceeded by processor patches." 718 <<
" This is usually a problem." <<
endl;
723 localNames[nonProci] = bm[patchi].
name();
724 localTypes[nonProci] = bm[patchi].
type();
729 localNames.resize(nonProci);
730 localTypes.resize(nonProci);
735 const globalIndex
procAddr(globalIndex::gatherNonLocal{}, nonProci);
746 if (procNames != localNames || procTypes != localTypes)
752 Info<<
" ***Inconsistent patches across processors, " 753 "processor0 has patch names:" << localNames
754 <<
" patch types:" << localTypes
755 <<
" processor" << proci
756 <<
" has patch names:" << procNames
757 <<
" patch types:" << procTypes
771 const faBoundaryMesh& bm = *
this;
773 bool hasError =
false;
777 if (bm[patchi].start() != nextPatchStart && !hasError)
782 <<
" ****Problem with boundary patch " << patchi
783 <<
" named " << bm[patchi].name()
784 <<
" of type " << bm[patchi].type()
785 <<
". The patch should start on face no " << nextPatchStart
786 <<
" and the patch specifies " << bm[patchi].start()
788 <<
"Possibly consecutive patches have this same problem." 789 <<
" Suppressing future warnings." <<
endl;
794 nextPatchStart += bm[patchi].faPatch::size();
800 <<
"This mesh is not valid: boundary definition is in error." 807 Info <<
"Boundary definition OK." <<
endl;
819 (void)mesh_.edgeAreaNormals();
820 (void)mesh_.pointAreaNormals();
822 (void)mesh_.areaCentres();
823 (void)mesh_.faceAreaNormals();
836 operator[](patchi).initMovePoints(pBufs,
p);
839 pBufs.finishedSends();
843 operator[](patchi).movePoints(pBufs,
p);
851 pBufs.finishedSends();
853 for (
const auto& schedEval : patchSchedule)
855 const label patchi = schedEval.patch;
859 operator[](patchi).initMovePoints(pBufs,
p);
863 operator[](patchi).movePoints(pBufs,
p);
882 operator[](patchi).initUpdateMesh(pBufs);
885 pBufs.finishedSends();
889 operator[](patchi).updateMesh(pBufs);
897 pBufs.finishedSends();
899 for (
const auto& schedEval : patchSchedule)
901 const label patchi = schedEval.patch;
905 operator[](patchi).initUpdateMesh(pBufs);
909 operator[](patchi).updateMesh(pBufs);
939 const bool writeOnProc
wordList groupNames() const
A list of the group names (if any)
label whichPatch(const label edgeIndex) const
Return patch index for a given edge label.
PtrList< faPatch > faPatchList
Store lists of faPatch as a PtrList.
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
List< labelRange > patchRanges() const
Return a list of patch ranges.
virtual const fileName & name() const
Get the name of the output serial stream. (eg, the name of the Fstream file name) ...
static autoPtr< faPatch > New(const word &name, const dictionary &dict, const label index, const faBoundaryMesh &bm)
Return pointer to a new patch created on freestore from dictionary.
labelList indices(const wordRe &matcher, const bool useGroups=true) const
Return (sorted) patch indices for all matches.
const labelList patchIDs(pbm.patchSet(polyPatchNames, false, true).sortedToc())
labelList findMatching(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
Extract list indices for all items with 'name()' that matches.
"blocking" : (MPI_Bsend, MPI_Recv)
bool checkDefinition(const bool report=false) const
Check boundary definition.
List< word > names(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
List of names generated by calling name() for each list item and filtered for matches.
void clear()
Clear the patch list and all demand-driven data.
virtual const fileName & name() const
The name of the stream.
bool writeData(Ostream &os) const
The writeData member function required by regIOobject.
errorManipArg< error, int > exit(error &err, const int errNo=1)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
virtual bool check(const char *operation) const
Check IOstream status for given operation.
lduInterfacePtrsList interfaces() const
Return a list of pointers for each patch with only those pointing to interfaces being set...
void calcGeometry()
Calculate the geometry for the patches.
const word & name() const noexcept
Return the object name.
labelList patchSizes() const
Return a list of patch sizes (number of edges in each patch)
UPtrList< const labelUList > edgeFaces() const
Return a list of edgeFaces for each patch.
A range or interval of labels defined by a start and a size.
constexpr char nl
The newline '\n' character (0x0a)
Type type(bool followLink=true, bool checkGzip=false) const
Return the directory entry type: UNDEFINED, FILE, DIRECTORY (or SYMLINK).
Ostream & endl(Ostream &os)
Add newline and flush stream.
void updateMesh()
Correct faBoundaryMesh after topology update.
static bool & parRun() noexcept
Test if this a parallel run.
Begin list [isseparator].
List< lduScheduleEntry > lduSchedule
A List of lduSchedule entries.
Functions to operate on Pointer Lists.
A simple container for options an IOstream can normally have.
virtual bool writeObject(IOstreamOption streamOpt, const bool writeOnProc) const
Write using stream options.
virtual bool writeObject(IOstreamOption streamOpt, const bool writeOnProc) const
Write using stream options.
const HashTable< labelList > & groupPatchIDs() const
The patch indices per patch group.
label findIndex(const wordRe &key) const
Return patch index for the first match, return -1 if not found.
UList< label > labelUList
A UList of labels.
labelRange range() const
Return start/size range of local processor data.
void resize(const label sz)
Resize the hash table for efficiency.
Extract name (as a word) from an object, typically using its name() method.
#define SeriousErrorInFunction
Report an error message using Foam::SeriousError.
#define forAll(list, i)
Loop across all elements in list.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
label findPatchID(const word &patchName, const bool allowNotFound=true) const
Find patch index given a name, return -1 if not found.
vectorField pointField
pointField is a vectorField.
void movePoints(const pointField &)
Correct faBoundaryMesh after moving points.
"scheduled" : (MPI_Send, MPI_Recv)
wordList names() const
Return a list of patch names.
label size() const noexcept
The number of entries in the list.
virtual Ostream & endBlock()
Write end block group.
UPtrList< const lduInterface > lduInterfacePtrsList
Store lists of lduInterface as a UPtrList.
const globalMeshData & globalData() const
Return parallel info.
A HashTable similar to std::unordered_map.
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
errorManip< error > abort(error &err)
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie...
label nEdges() const
Number of mesh edges.
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings...
label nInternalEdges() const
Internal edges using 0,1 or 2 boundary points.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
int debug
Static debugging option.
wordList types() const
Return a list of patch types.
OBJstream os(runTime.globalPath()/outputName)
faBoundaryMesh(const faBoundaryMesh &)=delete
No copy construct.
defineTypeNameAndDebug(combustionModel, 0)
Finite area patch class. Used for 2-D non-Euclidian finite area method.
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
label start() const
The start label of the edges in the faMesh edges list.
UPtrList< const labelUList > edgeLabels() const
Return a list of edgeLabels for each patch.
label nEdges() const
The number of boundary edges for the underlying mesh.
labelRange subProcs() const noexcept
Range of process indices for addressed sub-offsets (processes)
void resize(const label newLen)
Adjust size of PtrList.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
List< word > wordList
List of word.
void append(autoPtr< T > &ptr)
Move append an element to the end of the list.
static commsTypes defaultCommsType
Default commsType.
#define WarningInFunction
Report a warning using Foam::Warning.
globalIndex procAddr(aMesh.nFaces())
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
label nNonProcessor() const
The number of patches before the first processor patch.
bool good() const noexcept
True if next operation might succeed.
const lduSchedule & patchSchedule() const noexcept
Order in which the patches should be initialised/evaluated corresponding to the schedule.
const polyBoundaryMesh & patches
void setGroup(const word &groupName, const labelUList &patchIDs)
Set/add group with patches.
bool checkParallelSync(const bool report=false) const
Check whether all procs have all patches and in same order.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
void clear()
Clear the PtrList. Delete allocated entries and set size to zero.
"nonBlocking" : (MPI_Isend, MPI_Irecv)
messageStream Info
Information stream (stdout output on master, null elsewhere)
virtual Ostream & beginBlock(const keyType &kw)
Write begin block group with the given name.
bool match(const std::string &text, bool literal=false) const
Smart match as regular expression or as a string.
labelRange range() const
The edge range for all boundary edges.
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]).
List< label > labelList
A List of labels.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
bool returnReduceOr(const bool value, const label comm=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Defines the attributes of an object for which implicit objectRegistry management is supported...
labelList patchStarts() const
Return a list of patch start indices.
List< bool > boolList
A List of bools.
label nProcessorPatches() const
The number of processorFaPatch patches.
bool isPattern() const noexcept
The wordRe is a pattern, not a literal string.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
Extract type (as a word) from an object, typically using its type() method.
forAllConstIters(mixture.phases(), phase)
label firstMatching(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
Find first list item with 'name()' that matches, -1 on failure.
#define InfoInFunction
Report an information message using Foam::Info.