46bool Foam::faBoundaryMesh::hasGroupIDs()
const
51 return !groupIDsPtr_->empty();
58 if (!
p.inGroups().empty())
68void 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."
109 clearLocalAddressing();
124 entries[patchi].keyword(),
125 entries[patchi].
dict(),
136bool Foam::faBoundaryMesh::readIOcontents(
const bool allowOptionalRead)
138 bool updated =
false;
143 this->isReadRequired()
144 || (allowOptionalRead && this->isReadOptional() && this->headerOk())
148 warnNoRereading<faBoundaryMesh>();
163 populate(std::move(entries));
182 readIOcontents(
false);
223 if (!readIOcontents(
true))
248 if (!readIOcontents(
true))
250 populate(std::move(entries));
260 clearLocalAddressing();
265void 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);
339Foam::UPtrList<const Foam::labelUList>
348 list.set(patchi, &
patches[patchi].edgeLabels());
360 UPtrList<const labelUList> list(
patches.size());
383 list.set(patchi, lduPtr);
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))
514 label beg = mesh_.nInternalEdges();
517 const label len =
patches[patchi].nEdges();
531 [](
const faPatch&
p) {
return p.nEdges(); }
540 List<labelRange> list(
patches.size());
542 label beg = mesh_.nInternalEdges();
545 const label len =
patches[patchi].nEdges();
546 list[patchi].reset(beg, len);
561 return mesh_.nInternalEdges();
567 return mesh_.nBoundaryEdges();
573 return labelRange(mesh_.nInternalEdges(), mesh_.nBoundaryEdges());
589 const bool checkGroups = (useGroups && this->hasGroupIDs());
597 ids.reserve(this->size());
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());
656 else if (matcher.size() == 1)
658 return this->indices(matcher.front(), useGroups);
664 if (useGroups && this->hasGroupIDs())
666 ids.reserve(this->size());
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())
710 if (useGroups && this->hasGroupIDs())
712 ids.reserve(this->size());
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 const word& patchName
794 if (!patchName.empty())
806 if (edgeIndex <
mesh().nInternalEdges())
811 else if (edgeIndex >=
mesh().nEdges())
815 <<
"Edge " << edgeIndex
816 <<
" out of bounds. Number of geometric edges " <<
mesh().
nEdges()
826 label start = mesh_.patchStarts()[patchi];
827 label size = operator[](patchi).faPatch::size();
829 if (edgeIndex >= start && edgeIndex < start + size)
837 <<
"Error in patch search algorithm"
851 const faBoundaryMesh& bm = *
this;
853 bool hasError =
false;
865 if (nonProci != patchi)
872 Pout<<
" ***Problem with boundary patch " << patchi
873 <<
" name:" << bm[patchi].
name()
874 <<
" type:" << bm[patchi].
type()
875 <<
" - seems to be preceeded by processor patches."
876 <<
" This is usually a problem." <<
endl;
881 localNames[nonProci] = bm[patchi].name();
882 localTypes[nonProci] = bm[patchi].type();
887 localNames.resize(nonProci);
888 localTypes.resize(nonProci);
895 const wordList allNames(procAddr.gather(localNames));
896 const wordList allTypes(procAddr.gather(localTypes));
899 for (
const int proci : procAddr.subProcs())
901 const auto procNames(allNames.slice(procAddr.range(proci)));
902 const auto procTypes(allTypes.slice(procAddr.range(proci)));
904 if (procNames != localNames || procTypes != localTypes)
910 Info<<
" ***Inconsistent patches across processors, "
911 "processor0 has patch names:" << localNames
912 <<
" patch types:" << localTypes
913 <<
" processor" << proci
914 <<
" has patch names:" << procNames
915 <<
" patch types:" << procTypes
929 const faBoundaryMesh& bm = *
this;
931 bool hasError =
false;
935 if (bm[patchi].start() != nextPatchStart && !hasError)
940 <<
" ****Problem with boundary patch " << patchi
941 <<
" named " << bm[patchi].name()
942 <<
" of type " << bm[patchi].type()
943 <<
". The patch should start on face no " << nextPatchStart
944 <<
" and the patch specifies " << bm[patchi].start()
946 <<
"Possibly consecutive patches have this same problem."
947 <<
" Suppressing future warnings." <<
endl;
952 nextPatchStart += bm[patchi].faPatch::size();
958 <<
"This mesh is not valid: boundary definition is in error."
965 Info <<
"Boundary definition OK." <<
endl;
977 (void)mesh_.edgeAreaNormals();
978 (void)mesh_.pointAreaNormals();
980 (void)mesh_.areaCentres();
981 (void)mesh_.faceAreaNormals();
994 operator[](patchi).initMovePoints(pBufs,
p);
997 pBufs.finishedSends();
1001 operator[](patchi).movePoints(pBufs,
p);
1009 pBufs.finishedSends();
1011 for (
const auto& schedEval : patchSchedule)
1013 const label patchi = schedEval.patch;
1017 operator[](patchi).initMovePoints(pBufs,
p);
1040 operator[](patchi).initUpdateMesh(pBufs);
1043 pBufs.finishedSends();
1047 operator[](patchi).updateMesh(pBufs);
1055 pBufs.finishedSends();
1057 for (
const auto& schedEval : patchSchedule)
1059 const label patchi = schedEval.patch;
1063 operator[](patchi).initUpdateMesh(pBufs);
1078 os << entries.size();
1080 if (entries.empty())
1089 for (
const auto&
pp : entries)
1103 const word& keyword,
1109 if (!keyword.empty())
1117 if (!keyword.empty())
os.endEntry();
1131 const bool writeOnProc
Functions to operate on Pointer Lists.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
A HashTable similar to std::unordered_map.
List< Key > sortedToc() const
The table of contents (the keys) in sorted order.
bool empty() const noexcept
True if the hash table is empty.
void reserve(label numEntries)
Reserve space for at least the specified number of elements (not the number of buckets) and regenerat...
Defines the attributes of an object for which implicit objectRegistry management is supported,...
const word & name() const noexcept
Return the object name.
static word groupName(StringType base, const word &group)
Create dot-delimited name.group string.
autoPtr< IOobject > clone() const
Clone.
A simple container for options an IOstream can normally have.
compressionType compression() const noexcept
Get the stream compression.
@ UNCOMPRESSED
compression = false
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void resize(const label len)
Adjust allocated size of list.
virtual Ostream & write(const char c) override
Write character.
virtual const fileName & name() const override
Get the name of the output serial stream. (eg, the name of the Fstream file name).
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
virtual Ostream & endBlock()
Write end block group.
virtual Ostream & beginBlock(const keyType &kw)
Write begin block group with the given name.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
UPstream::commsTypes commsType() const noexcept
The communications type of the stream.
void finishedSends(const bool wait=true)
Mark the send phase as being finished.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie,...
void resize_null(const label newLen)
Set the addressed list to the given size, deleting all existing entries. Afterwards the list contains...
constexpr PtrList() noexcept
bool test(const label i) const
Test bool value at specified position, always false for out-of-range access.
bool empty() const noexcept
True if List is empty (ie, size() is zero).
SubList< T > slice(const label pos, label len=-1)
Return SubList slice (non-const access) - no range checking.
T & front()
Access first element of the list, position [0].
bool unset(const label i)
Unset the bool entry at specified position, always false for out-of-range access.
void size(const label n)
Older name for setAddressableSize.
@ scheduled
"scheduled" (MPI standard) : (MPI_Send, MPI_Recv)
@ nonBlocking
"nonBlocking" (immediate) : (MPI_Isend, MPI_Irecv)
@ buffered
"buffered" : (MPI_Bsend, MPI_Recv)
static bool parRun(const bool on) noexcept
Set as parallel run on/off.
static commsTypes defaultCommsType
Default commsType.
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
const T & operator[](const label i) const
Return const reference to the element at given position. FatalError for bounds problem or nullptr....
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie,...
bool empty() const noexcept
True if the list is empty (ie, size() is zero).
label size() const noexcept
The number of entries in the list.
label count() const noexcept
The number of non-nullptr entries in the list.
Finite area boundary mesh, which is a faPatch list with registered IO, a reference to the associated ...
UPtrList< const labelUList > edgeFaces() const
Return a list of edgeFaces for each patch.
bool checkDefinition(const bool report=false) const
Check boundary definition.
label nNonProcessor() const
The number of patches before the first processor patch.
void calcGeometry()
Calculate the geometry for the patches.
const faPatch * cfindPatch(const word &patchName) const
Find patch by name and return const pointer.
const HashTable< labelList > & groupPatchIDs() const
The patch indices per patch group.
labelList patchStarts() const
Return a list of patch start indices.
lduInterfacePtrsList interfaces() const
Return a list of pointers for each patch with only those pointing to interfaces being set.
virtual bool writeObject(IOstreamOption streamOpt, const bool writeOnProc=true) const
Write using stream options, but always UNCOMPRESSED.
const faMesh & mesh() const noexcept
Return the mesh reference.
labelRange range() const
The edge range for all boundary edges.
wordList types() const
Return a list of patch types.
label findPatchID(const word &patchName, const bool allowNotFound=true) const
Find patch index given a name, return -1 if not found.
virtual bool writeData(Ostream &os) const
The writeData member function required by regIOobject.
void setGroup(const word &groupName, const labelUList &patchIDs)
Set/add group with patches.
List< labelRange > patchRanges() const
Return a list of patch ranges.
faBoundaryMesh(const faBoundaryMesh &)=delete
No copy construct.
label whichPatch(const label edgeIndex) const
Return patch index for a given edge label.
void movePoints(const pointField &)
Correct faBoundaryMesh after moving points.
void writeEntry(Ostream &os) const
Write as a plain list of entries.
labelList patchSizes() const
Return a list of patch sizes (number of edges in each patch).
void clear()
Clear the patch list and all demand-driven data.
wordList groupNames() const
A list of the group names (if any).
wordList names() const
Return a list of patch names.
bool checkParallelSync(const bool report=false) const
Check whether all procs have all patches and in same order.
void updateMesh()
Correct faBoundaryMesh after topology update.
label nProcessorPatches() const
The number of processorFaPatch patches.
UPtrList< const labelUList > edgeLabels() const
Return a list of edgeLabels for each patch.
label nNonProcessorEdges() const
The number of boundary edges before the first processor patch.
labelList indices(const wordRe &matcher, const bool useGroups=true) const
The (sorted) patch indices for all matches, optionally matching patch groups.
label nEdges() const
The number of boundary edges for the underlying mesh.
label findIndex(const wordRe &key) const
Return patch index for the first match, return -1 if not found.
label start() const
The start label of the edges in the faMesh edges list.
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Finite area patch class. Used for 2-D non-Euclidian finite area method.
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.
Type type(bool followLink=true, bool checkGzip=false) const
Return the directory entry type: UNDEFINED, FILE, DIRECTORY (or SYMLINK).
Calculates a non-overlapping list of offsets based on an input size (eg, number of cells) from differ...
const lduSchedule & patchSchedule() const noexcept
Order in which the patches should be initialised/evaluated corresponding to the schedule.
A range or interval of labels defined by a start and a size.
An abstract base class for implicitly-coupled interfaces e.g. processor and cyclic patches.
A class representing the concept of 1 (one) that can be used to avoid manipulating objects known to b...
const globalMeshData & globalData() const
Return parallel info (demand-driven).
label nInternalEdges() const
Internal edges using 0,1 or 2 boundary points.
label nEdges() const
Number of mesh edges.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
virtual bool writeObject(IOstreamOption streamOpt, const bool writeOnProc) const
Write using stream options.
regIOobject(const IOobject &io, const bool isTimeObject=false)
Construct from IOobject. The optional flag adds special handling if the object is the top-level regIO...
@ BEGIN_LIST
Begin list [isseparator].
@ END_LIST
End list [isseparator].
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
bool isPattern() const noexcept
The wordRe is a pattern, not a literal string.
A List of wordRe with additional matching capabilities.
A class for handling words, derived from Foam::string.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
const polyBoundaryMesh & patches
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
#define WarningInFunction
Report a warning using Foam::Warning.
#define InfoInFunction
Report an information message using Foam::Info.
#define SeriousErrorInFunction
Report an error message using Foam::SeriousError.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
labelList findMatching(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
Extract list indices for all items with 'name()' that matches.
label firstMatching(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
Find first list item with 'name()' that matches, -1 on failure.
Namespace for handling debugging switches.
List< word > wordList
List of word.
bool returnReduceOr(const bool value, const int communicator=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
List< label > labelList
A List of labels.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
UPtrList< const lduInterface > lduInterfacePtrsList
Store lists of lduInterface as a UPtrList.
messageStream Info
Information stream (stdout output on master, null elsewhere).
List< lduScheduleEntry > lduSchedule
A List of lduSchedule entries.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
Ostream & incrIndent(Ostream &os)
Increment the indent level.
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
Ostream & endl(Ostream &os)
Add newline and flush stream.
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
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...
errorManip< error > abort(error &err)
List< bool > boolList
A List of bools.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
vectorField pointField
pointField is a vectorField.
PtrList< faPatch > faPatchList
Store lists of faPatch as a PtrList.
errorManipArg< error, int > exit(error &err, const int errNo=1)
UList< label > labelUList
A UList of labels.
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
constexpr char nl
The newline '\n' character (0x0a).
Calculate the matrix for the second temporal derivative.
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.
Dispatch tag: Construct 'one-sided' from the non-master local sizes using gather but no broadcast.
Extract name (as a word) from an object, typically using its name() method.
Extract type (as a word) from an object, typically using its type() method.
Functor wrapper of allow/deny lists of wordRe for filtering.