47 bool Foam::faBoundaryMesh::hasGroupIDs()
const 52 return !groupIDsPtr_->empty();
59 if (!
p.inGroups().empty())
69 void Foam::faBoundaryMesh::calcGroupIDs()
const 76 groupIDsPtr_.emplace(16);
77 auto& groupLookup = *groupIDsPtr_;
83 for (
const word& groupName :
patches[patchi].inGroups())
85 groupLookup(groupName).push_back(patchi);
96 <<
"' which clashes with patch " << patchi
97 <<
" of the same name." 104 void Foam::faBoundaryMesh::populate(PtrList<entry>&& entries)
106 clearLocalAddressing();
121 entries[patchi].keyword(),
122 entries[patchi].
dict(),
133 bool Foam::faBoundaryMesh::readContents(
const bool allowOptionalRead)
135 bool updated =
false;
136 PtrList<entry> entries;
141 || (allowOptionalRead && this->isReadOptional() && this->headerOk())
145 warnNoRereading<faBoundaryMesh>();
148 Istream& is = readStream(typeName);
160 populate(std::move(entries));
220 if (!readContents(
true))
238 PtrList<entry>&& entries
245 if (!readContents(
true))
247 populate(std::move(entries));
257 clearLocalAddressing();
262 void Foam::faBoundaryMesh::clearLocalAddressing()
264 groupIDsPtr_.reset(
nullptr);
285 (void)mesh_.edgeAreaNormals();
286 (void)mesh_.pointAreaNormals();
288 (void)mesh_.areaCentres();
289 (void)mesh_.faceAreaNormals();
302 operator[](patchi).initGeometry(pBufs);
305 pBufs.finishedSends();
309 operator[](patchi).calcGeometry(pBufs);
317 pBufs.finishedSends();
319 for (
const auto& patchEval : patchSchedule)
321 const label patchi = patchEval.patch;
325 operator[](patchi).initGeometry(pBufs);
329 operator[](patchi).calcGeometry(pBufs);
345 list.
set(patchi, &
patches[patchi].edgeLabels());
376 const lduInterface* lduPtr = isA<lduInterface>(
patches[patchi]);
380 list.
set(patchi, lduPtr);
396 if (isA<processorFaPatch>(
p))
416 if (isA<processorFaPatch>(
p))
434 return *groupIDsPtr_;
440 const word& groupName,
444 groupIDsPtr_.reset(
nullptr);
453 if (pending.test(patchi))
455 pending.
unset(patchi);
456 patches[patchi].addGroup(groupName);
463 if (pending.test(patchi))
465 patches[patchi].removeGroup(groupName);
491 label beg = mesh_.nInternalEdges();
494 const label len =
patches[patchi].nEdges();
505 PtrListOps::get<label>
508 [](
const faPatch&
p) {
return p.nEdges(); }
519 label beg = mesh_.nInternalEdges();
522 const label len =
patches[patchi].nEdges();
523 list[patchi].reset(beg, len);
532 return this->groupPatchIDs().sortedToc();
538 return mesh_.nInternalEdges();
544 return mesh_.nBoundaryEdges();
550 return labelRange(mesh_.nInternalEdges(), mesh_.nBoundaryEdges());
566 const bool checkGroups = (useGroups && this->hasGroupIDs());
574 ids.reserve(this->size());
576 const auto& groupLookup = groupPatchIDs();
579 if (matcher(iter.key()))
582 ids.insert(iter.val());
607 else if (checkGroups)
609 const auto iter = groupPatchIDs().cfind(matcher);
614 ids.insert(iter.val());
619 return ids.sortedToc();
625 const wordRes& matcher,
633 else if (matcher.size() == 1)
635 return this->indices(matcher.front(), useGroups);
641 if (useGroups && this->hasGroupIDs())
643 ids.reserve(this->size());
645 const auto& groupLookup = groupPatchIDs();
648 if (matcher(iter.key()))
651 ids.insert(iter.val());
665 return ids.sortedToc();
672 const wordRes& ignore,
678 return this->indices(
select, useGroups);
681 const wordRes::filter matcher(
select, ignore);
686 if (useGroups && this->hasGroupIDs())
688 ids.reserve(this->size());
690 const auto& groupLookup = groupPatchIDs();
693 if (matcher(iter.key()))
696 ids.insert(iter.val());
710 return ids.sortedToc();
726 const word& patchName,
730 if (patchName.empty())
745 <<
"Patch '" << patchName <<
"' not found. " 746 <<
"Available patch names: " <<
names() <<
endl 753 Pout<<
"label faBoundaryMesh::findPatchID(const word&) const" 754 <<
"Patch named " << patchName <<
" not found. " 755 <<
"Available patch names: " <<
names() <<
endl;
765 if (edgeIndex <
mesh().nInternalEdges())
770 else if (edgeIndex >=
mesh().nEdges())
774 <<
"Edge " << edgeIndex
775 <<
" out of bounds. Number of geometric edges " <<
mesh().
nEdges()
785 label start = mesh_.patchStarts()[patchi];
786 label size = operator[](patchi).faPatch::size();
788 if (edgeIndex >= start && edgeIndex < start + size)
796 <<
"Error in patch search algorithm" 810 const faBoundaryMesh& bm = *
this;
812 bool hasError =
false;
822 if (!isA<processorFaPatch>(bm[patchi]))
824 if (nonProci != patchi)
831 Pout<<
" ***Problem with boundary patch " << patchi
832 <<
" name:" << bm[patchi].
name()
833 <<
" type:" << bm[patchi].
type()
834 <<
" - seems to be preceeded by processor patches." 835 <<
" This is usually a problem." <<
endl;
840 localNames[nonProci] = bm[patchi].
name();
841 localTypes[nonProci] = bm[patchi].
type();
846 localNames.resize(nonProci);
847 localTypes.resize(nonProci);
852 const globalIndex
procAddr(globalIndex::gatherNonLocal{}, nonProci);
863 if (procNames != localNames || procTypes != localTypes)
869 Info<<
" ***Inconsistent patches across processors, " 870 "processor0 has patch names:" << localNames
871 <<
" patch types:" << localTypes
872 <<
" processor" << proci
873 <<
" has patch names:" << procNames
874 <<
" patch types:" << procTypes
888 const faBoundaryMesh& bm = *
this;
890 bool hasError =
false;
894 if (bm[patchi].start() != nextPatchStart && !hasError)
899 <<
" ****Problem with boundary patch " << patchi
900 <<
" named " << bm[patchi].name()
901 <<
" of type " << bm[patchi].type()
902 <<
". The patch should start on face no " << nextPatchStart
903 <<
" and the patch specifies " << bm[patchi].start()
905 <<
"Possibly consecutive patches have this same problem." 906 <<
" Suppressing future warnings." <<
endl;
911 nextPatchStart += bm[patchi].faPatch::size();
917 <<
"This mesh is not valid: boundary definition is in error." 924 Info <<
"Boundary definition OK." <<
endl;
936 (void)mesh_.edgeAreaNormals();
937 (void)mesh_.pointAreaNormals();
939 (void)mesh_.areaCentres();
940 (void)mesh_.faceAreaNormals();
953 operator[](patchi).initMovePoints(pBufs,
p);
956 pBufs.finishedSends();
960 operator[](patchi).movePoints(pBufs,
p);
968 pBufs.finishedSends();
970 for (
const auto& schedEval : patchSchedule)
972 const label patchi = schedEval.patch;
976 operator[](patchi).initMovePoints(pBufs,
p);
980 operator[](patchi).movePoints(pBufs,
p);
999 operator[](patchi).initUpdateMesh(pBufs);
1002 pBufs.finishedSends();
1006 operator[](patchi).updateMesh(pBufs);
1014 pBufs.finishedSends();
1016 for (
const auto& schedEval : patchSchedule)
1018 const label patchi = schedEval.patch;
1022 operator[](patchi).initUpdateMesh(pBufs);
1026 operator[](patchi).updateMesh(pBufs);
1037 os << entries.size();
1039 if (entries.empty())
1048 for (
const auto&
pp : entries)
1062 const keyType& keyword,
1068 if (!keyword.empty())
1090 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
Return (sorted) patch indices for all matches.
std::enable_if< std::is_same< bool, TypeT >::value, bool >::type unset(const label i)
Unset the bool entry at specified position, always false for out-of-range access. ...
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.
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.
List< bool > select(const label n, const labelUList &locations)
Construct a selection list of bools (all false) with the given pre-size, subsequently add specified l...
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.
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.
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 (demand-driven)
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.
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())
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.
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.
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)
virtual Ostream & endEntry()
Write end entry (';') followed by newline.
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.
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.