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);
95 <<
"' which clashes with patch " << patchi
96 <<
" of the same name." 103 void Foam::faBoundaryMesh::populate(PtrList<entry>&& entries)
105 clearLocalAddressing();
120 entries[patchi].keyword(),
121 entries[patchi].
dict(),
132 bool Foam::faBoundaryMesh::readIOcontents(
const bool allowOptionalRead)
134 bool updated =
false;
135 PtrList<entry> entries;
139 this->isReadRequired()
140 || (allowOptionalRead && this->isReadOptional() && this->headerOk())
144 warnNoRereading<faBoundaryMesh>();
147 Istream& is = readStream(typeName);
159 populate(std::move(entries));
178 readIOcontents(
false);
219 if (!readIOcontents(
true))
237 PtrList<entry>&& entries
244 if (!readIOcontents(
true))
246 populate(std::move(entries));
256 clearLocalAddressing();
261 void Foam::faBoundaryMesh::clearLocalAddressing()
263 groupIDsPtr_.reset(
nullptr);
284 (void)mesh_.edgeAreaNormals();
285 (void)mesh_.pointAreaNormals();
287 (void)mesh_.areaCentres();
288 (void)mesh_.faceAreaNormals();
301 operator[](patchi).initGeometry(pBufs);
304 pBufs.finishedSends();
308 operator[](patchi).calcGeometry(pBufs);
316 pBufs.finishedSends();
318 for (
const auto& patchEval : patchSchedule)
320 const label patchi = patchEval.patch;
324 operator[](patchi).initGeometry(pBufs);
328 operator[](patchi).calcGeometry(pBufs);
344 list.
set(patchi, &
patches[patchi].edgeLabels());
375 const lduInterface* lduPtr = isA<lduInterface>(
patches[patchi]);
379 list.
set(patchi, lduPtr);
395 if (isA<processorFaPatch>(
p))
415 if (isA<processorFaPatch>(
p))
433 return *groupIDsPtr_;
439 const word& groupName,
443 groupIDsPtr_.reset(
nullptr);
452 if (pending.test(patchi))
454 pending.
unset(patchi);
455 patches[patchi].addGroup(groupName);
462 if (pending.test(patchi))
464 patches[patchi].removeGroup(groupName);
490 label beg = mesh_.nInternalEdges();
493 const label len =
patches[patchi].nEdges();
504 PtrListOps::get<label>
507 [](
const faPatch&
p) {
return p.nEdges(); }
518 label beg = mesh_.nInternalEdges();
521 const label len =
patches[patchi].nEdges();
522 list[patchi].reset(beg, len);
531 return this->groupPatchIDs().sortedToc();
537 return mesh_.nInternalEdges();
543 return mesh_.nBoundaryEdges();
549 return labelRange(mesh_.nInternalEdges(), mesh_.nBoundaryEdges());
565 const bool checkGroups = (useGroups && this->hasGroupIDs());
573 ids.reserve(this->size());
575 const auto& groupLookup = groupPatchIDs();
578 if (matcher(iter.key()))
581 ids.insert(iter.val());
606 else if (checkGroups)
608 const auto iter = groupPatchIDs().cfind(matcher);
613 ids.insert(iter.val());
618 return ids.sortedToc();
624 const wordRes& matcher,
632 else if (matcher.size() == 1)
634 return this->indices(matcher.front(), useGroups);
640 if (useGroups && this->hasGroupIDs())
642 ids.reserve(this->size());
644 const auto& groupLookup = groupPatchIDs();
647 if (matcher(iter.key()))
650 ids.insert(iter.val());
664 return ids.sortedToc();
671 const wordRes& ignore,
677 return this->indices(
select, useGroups);
680 const wordRes::filter matcher(
select, ignore);
685 if (useGroups && this->hasGroupIDs())
687 ids.reserve(this->size());
689 const auto& groupLookup = groupPatchIDs();
692 if (matcher(iter.key()))
695 ids.insert(iter.val());
709 return ids.sortedToc();
725 const word& patchName,
729 if (patchName.empty())
744 <<
"Patch '" << patchName <<
"' not found. " 745 <<
"Available patch names: " <<
names() <<
endl 752 Pout<<
"label faBoundaryMesh::findPatchID(const word&) const" 753 <<
"Patch named " << patchName <<
" not found. " 754 <<
"Available patch names: " <<
names() <<
endl;
764 if (edgeIndex <
mesh().nInternalEdges())
769 else if (edgeIndex >=
mesh().nEdges())
773 <<
"Edge " << edgeIndex
774 <<
" out of bounds. Number of geometric edges " <<
mesh().
nEdges()
784 label start = mesh_.patchStarts()[patchi];
785 label size = operator[](patchi).faPatch::size();
787 if (edgeIndex >= start && edgeIndex < start + size)
795 <<
"Error in patch search algorithm" 809 const faBoundaryMesh& bm = *
this;
811 bool hasError =
false;
821 if (!isA<processorFaPatch>(bm[patchi]))
823 if (nonProci != patchi)
830 Pout<<
" ***Problem with boundary patch " << patchi
831 <<
" name:" << bm[patchi].
name()
832 <<
" type:" << bm[patchi].
type()
833 <<
" - seems to be preceeded by processor patches." 834 <<
" This is usually a problem." <<
endl;
839 localNames[nonProci] = bm[patchi].
name();
840 localTypes[nonProci] = bm[patchi].
type();
845 localNames.resize(nonProci);
846 localTypes.resize(nonProci);
851 const globalIndex
procAddr(globalIndex::gatherNonLocal{}, nonProci);
862 if (procNames != localNames || procTypes != localTypes)
868 Info<<
" ***Inconsistent patches across processors, " 869 "processor0 has patch names:" << localNames
870 <<
" patch types:" << localTypes
871 <<
" processor" << proci
872 <<
" has patch names:" << procNames
873 <<
" patch types:" << procTypes
887 const faBoundaryMesh& bm = *
this;
889 bool hasError =
false;
893 if (bm[patchi].start() != nextPatchStart && !hasError)
898 <<
" ****Problem with boundary patch " << patchi
899 <<
" named " << bm[patchi].name()
900 <<
" of type " << bm[patchi].type()
901 <<
". The patch should start on face no " << nextPatchStart
902 <<
" and the patch specifies " << bm[patchi].start()
904 <<
"Possibly consecutive patches have this same problem." 905 <<
" Suppressing future warnings." <<
endl;
910 nextPatchStart += bm[patchi].faPatch::size();
916 <<
"This mesh is not valid: boundary definition is in error." 923 Info <<
"Boundary definition OK." <<
endl;
935 (void)mesh_.edgeAreaNormals();
936 (void)mesh_.pointAreaNormals();
938 (void)mesh_.areaCentres();
939 (void)mesh_.faceAreaNormals();
952 operator[](patchi).initMovePoints(pBufs,
p);
955 pBufs.finishedSends();
959 operator[](patchi).movePoints(pBufs,
p);
967 pBufs.finishedSends();
969 for (
const auto& schedEval : patchSchedule)
971 const label patchi = schedEval.patch;
975 operator[](patchi).initMovePoints(pBufs,
p);
979 operator[](patchi).movePoints(pBufs,
p);
998 operator[](patchi).initUpdateMesh(pBufs);
1001 pBufs.finishedSends();
1005 operator[](patchi).updateMesh(pBufs);
1013 pBufs.finishedSends();
1015 for (
const auto& schedEval : patchSchedule)
1017 const label patchi = schedEval.patch;
1021 operator[](patchi).initUpdateMesh(pBufs);
1025 operator[](patchi).updateMesh(pBufs);
1036 os << entries.size();
1038 if (entries.empty())
1047 for (
const auto&
pp : entries)
1061 const word& keyword,
1067 if (!keyword.empty())
1089 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.
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 standard) : (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" (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.
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.
"buffered" : (MPI_Bsend, MPI_Recv)
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.