46 bool Foam::faBoundaryMesh::hasGroupIDs()
const 51 return !groupIDsPtr_->empty();
58 if (!
p.inGroups().empty())
68 void Foam::faBoundaryMesh::calcGroupIDs()
const 75 groupIDsPtr_.emplace(16);
76 auto& groupLookup = *groupIDsPtr_;
82 for (
const word& groupName :
patches[patchi].inGroups())
84 groupLookup(groupName).push_back(patchi);
91 if (groupLookup.empty())
99 <<
"' which clashes with patch " << patchi
100 <<
" of the same name." 107 void Foam::faBoundaryMesh::populate(PtrList<entry>&& entries)
109 clearLocalAddressing();
124 entries[patchi].keyword(),
125 entries[patchi].
dict(),
136 bool Foam::faBoundaryMesh::readIOcontents(
const bool allowOptionalRead)
138 bool updated =
false;
139 PtrList<entry> entries;
143 this->isReadRequired()
144 || (allowOptionalRead && this->isReadOptional() && this->headerOk())
148 warnNoRereading<faBoundaryMesh>();
151 Istream& is = readStream(typeName);
163 populate(std::move(entries));
182 readIOcontents(
false);
223 if (!readIOcontents(
true))
241 PtrList<entry>&& entries
248 if (!readIOcontents(
true))
250 populate(std::move(entries));
260 clearLocalAddressing();
265 void Foam::faBoundaryMesh::clearLocalAddressing()
267 groupIDsPtr_.reset(
nullptr);
288 (void)mesh_.edgeAreaNormals();
289 (void)mesh_.pointAreaNormals();
291 (void)mesh_.areaCentres();
292 (void)mesh_.faceAreaNormals();
305 operator[](patchi).initGeometry(pBufs);
308 pBufs.finishedSends();
312 operator[](patchi).calcGeometry(pBufs);
320 pBufs.finishedSends();
322 for (
const auto& patchEval : patchSchedule)
324 const label patchi = patchEval.patch;
328 operator[](patchi).initGeometry(pBufs);
332 operator[](patchi).calcGeometry(pBufs);
348 list.
set(patchi, &
patches[patchi].edgeLabels());
379 const lduInterface* lduPtr = isA<lduInterface>(
patches[patchi]);
383 list.
set(patchi, lduPtr);
399 if (isA<processorFaPatch>(
p))
419 if (isA<processorFaPatch>(
p))
437 if (isA<processorFaPatch>(
p))
457 return *groupIDsPtr_;
463 const word& groupName,
467 groupIDsPtr_.reset(
nullptr);
476 if (pending.test(patchi))
478 pending.
unset(patchi);
479 patches[patchi].addGroup(groupName);
486 if (pending.test(patchi))
488 patches[patchi].removeGroup(groupName);
514 label beg = mesh_.nInternalEdges();
517 const label len =
patches[patchi].nEdges();
528 PtrListOps::get<label>
531 [](
const faPatch&
p) {
return p.nEdges(); }
542 label beg = mesh_.nInternalEdges();
545 const label len =
patches[patchi].nEdges();
546 list[patchi].reset(beg, len);
555 return this->groupPatchIDs().sortedToc();
561 return mesh_.nInternalEdges();
567 return mesh_.nBoundaryEdges();
573 return labelRange(mesh_.nInternalEdges(), mesh_.nBoundaryEdges());
589 const bool checkGroups = (useGroups && this->hasGroupIDs());
599 const auto& groupLookup = groupPatchIDs();
602 if (matcher(iter.key()))
605 ids.insert(iter.val());
630 else if (checkGroups)
632 const auto iter = groupPatchIDs().cfind(matcher);
637 ids.insert(iter.val());
642 return ids.sortedToc();
648 const wordRes& matcher,
656 else if (matcher.size() == 1)
658 return this->indices(matcher.front(), useGroups);
664 if (useGroups && this->hasGroupIDs())
668 const auto& groupLookup = groupPatchIDs();
671 if (matcher(iter.key()))
674 ids.insert(iter.val());
688 return ids.sortedToc();
694 const wordRes& allow,
699 if (allow.empty() && deny.empty())
705 const wordRes::filter matcher(allow, deny);
710 if (useGroups && this->hasGroupIDs())
714 const auto& groupLookup = groupPatchIDs();
717 if (matcher(iter.key()))
720 ids.insert(iter.val());
734 return ids.sortedToc();
750 const word& patchName,
754 if (patchName.empty())
769 <<
"Patch '" << patchName <<
"' not found. " 770 <<
"Available patch names: " <<
names() <<
endl 777 Pout<<
"label faBoundaryMesh::findPatchID(const word&) const" 778 <<
"Patch named " << patchName <<
" not found. " 779 <<
"Available patch names: " <<
names() <<
endl;
789 if (edgeIndex <
mesh().nInternalEdges())
794 else if (edgeIndex >=
mesh().nEdges())
798 <<
"Edge " << edgeIndex
799 <<
" out of bounds. Number of geometric edges " <<
mesh().
nEdges()
809 label start = mesh_.patchStarts()[patchi];
810 label size = operator[](patchi).faPatch::size();
812 if (edgeIndex >= start && edgeIndex < start + size)
820 <<
"Error in patch search algorithm" 834 const faBoundaryMesh& bm = *
this;
836 bool hasError =
false;
846 if (!isA<processorFaPatch>(bm[patchi]))
848 if (nonProci != patchi)
855 Pout<<
" ***Problem with boundary patch " << patchi
856 <<
" name:" << bm[patchi].
name()
857 <<
" type:" << bm[patchi].
type()
858 <<
" - seems to be preceeded by processor patches." 859 <<
" This is usually a problem." <<
endl;
864 localNames[nonProci] = bm[patchi].
name();
865 localTypes[nonProci] = bm[patchi].
type();
870 localNames.resize(nonProci);
871 localTypes.resize(nonProci);
876 const globalIndex
procAddr(globalIndex::gatherNonLocal{}, nonProci);
887 if (procNames != localNames || procTypes != localTypes)
893 Info<<
" ***Inconsistent patches across processors, " 894 "processor0 has patch names:" << localNames
895 <<
" patch types:" << localTypes
896 <<
" processor" << proci
897 <<
" has patch names:" << procNames
898 <<
" patch types:" << procTypes
912 const faBoundaryMesh& bm = *
this;
914 bool hasError =
false;
918 if (bm[patchi].start() != nextPatchStart && !hasError)
923 <<
" ****Problem with boundary patch " << patchi
924 <<
" named " << bm[patchi].name()
925 <<
" of type " << bm[patchi].type()
926 <<
". The patch should start on face no " << nextPatchStart
927 <<
" and the patch specifies " << bm[patchi].start()
929 <<
"Possibly consecutive patches have this same problem." 930 <<
" Suppressing future warnings." <<
endl;
935 nextPatchStart += bm[patchi].faPatch::size();
941 <<
"This mesh is not valid: boundary definition is in error." 948 Info <<
"Boundary definition OK." <<
endl;
960 (void)mesh_.edgeAreaNormals();
961 (void)mesh_.pointAreaNormals();
963 (void)mesh_.areaCentres();
964 (void)mesh_.faceAreaNormals();
977 operator[](patchi).initMovePoints(pBufs,
p);
980 pBufs.finishedSends();
984 operator[](patchi).movePoints(pBufs,
p);
992 pBufs.finishedSends();
994 for (
const auto& schedEval : patchSchedule)
996 const label patchi = schedEval.patch;
1000 operator[](patchi).initMovePoints(pBufs,
p);
1004 operator[](patchi).movePoints(pBufs,
p);
1023 operator[](patchi).initUpdateMesh(pBufs);
1026 pBufs.finishedSends();
1030 operator[](patchi).updateMesh(pBufs);
1038 pBufs.finishedSends();
1040 for (
const auto& schedEval : patchSchedule)
1042 const label patchi = schedEval.patch;
1046 operator[](patchi).initUpdateMesh(pBufs);
1050 operator[](patchi).updateMesh(pBufs);
1061 os << entries.size();
1063 if (entries.empty())
1072 for (
const auto&
pp : entries)
1086 const word& keyword,
1092 if (!keyword.empty())
1114 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 ...
labelRange range(const label proci) const
Return start/size range of proci data.
List< labelRange > patchRanges() const
Return a list of patch ranges.
const labelList patchIDs(pbm.indices(polyPatchNames, true))
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.
autoPtr< IOobject > clone() const
Clone.
labelList indices(const wordRe &matcher, const bool useGroups=true) const
The (sorted) patch indices for all matches, optionally matching patch groups.
labelList findMatching(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
Extract list indices for all items with 'name()' that matches.
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.
virtual bool writeData(Ostream &os) const
The writeData member function required by regIOobject.
errorManipArg< error, int > exit(error &err, const int errNo=1)
virtual Ostream & write(const char c) override
Write character.
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.
static void gather(const labelUList &offsets, const label comm, const ProcIDsContainer &procIDs, const UList< Type > &fld, UList< Type > &allFld, const int tag=UPstream::msgType(), UPstream::commsTypes commsType=UPstream::commsTypes::nonBlocking)
Collect data in processor order on master (== procIDs[0]).
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.
virtual const fileName & name() const override
Get the name of the output serial stream. (eg, the name of the Fstream file name) ...
void writeEntry(Ostream &os) const
Write as a plain list of entries.
UList< label > labelUList
A UList of labels.
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.
void resize_null(const label newLen)
Set the addressed list to the given size, deleting all existing entries. Afterwards the list contains...
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.
label nNonProcessorEdges() const
The number of boundary edges before the first processor patch.
vectorField pointField
pointField is a vectorField.
void movePoints(const pointField &)
Correct faBoundaryMesh after moving points.
"scheduled" (MPI standard) : (MPI_Send, MPI_Recv)
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i), works like std::iota() but returning a...
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 (demand-driven)
auto key(const Type &t) -> std::enable_if_t< std::is_enum_v< Type >, std::underlying_type_t< Type > >
A HashTable similar to std::unordered_map.
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
bool returnReduceOr(const bool value, const int communicator=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
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.
std::enable_if_t< std::is_same_v< bool, TypeT >, bool > unset(const label i)
Unset the bool entry at specified position, always false for out-of-range access. ...
defineTypeNameAndDebug(combustionModel, 0)
Finite area patch class. Used for 2-D non-Euclidian finite area method.
compressionType compression() const noexcept
Get the stream compression.
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)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
List< word > wordList
List of word.
static commsTypes defaultCommsType
Default commsType.
#define WarningInFunction
Report a warning using Foam::Warning.
globalIndex procAddr(aMesh.nFaces())
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.
void reserve(label numEntries)
Reserve space for at least the specified number of elements (not the number of buckets) and regenerat...
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" (immediate) : (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.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
labelRange range() const
The edge range for all boundary edges.
List< label > labelList
A List of labels.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
virtual Ostream & endEntry()
Write end entry (';') followed by newline.
"buffered" : (MPI_Bsend, MPI_Recv)
Ostream & incrIndent(Ostream &os)
Increment the indent level.
virtual bool writeObject(IOstreamOption streamOpt, const bool writeOnProc=true) const
Write using stream options, but always UNCOMPRESSED.
Defines the attributes of an object for which implicit objectRegistry management is supported...
Calculate the matrix for the second temporal derivative.
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.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
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.