35void Foam::singleCellFvMesh::agglomerateMesh
38 const labelListList& agglom
46 const polyBoundaryMesh& oldPatches =
mesh.boundaryMesh();
53 const polyPatch&
pp = oldPatches[patchi];
56 if (agglom[patchi].
size() !=
pp.size())
59 <<
"agglomeration on patch " << patchi
60 <<
" (size " <<
pp.size()
61 <<
") is of size " << agglom[patchi].size()
65 nAgglom[patchi] =
max(agglom[patchi])+1;
69 if (agglom[patchi][i] < 0 || agglom[patchi][i] >=
pp.size())
72 <<
"agglomeration on patch " << patchi
73 <<
" is out of range 0.." <<
pp.size()-1
86 const polyPatch&
pp = oldPatches[patchi];
90 label offset =
pp.start()-
mesh.nInternalFaces();
93 nbrAgglom[offset+i] = agglom[patchi][i];
101 Map<label> localToNbr(nbrAgglom.size()/10);
103 forAll(oldPatches, patchi)
105 const polyPatch&
pp = oldPatches[patchi];
109 label offset =
pp.start()-
mesh.nInternalFaces();
113 label bFacei = offset+i;
114 label myZone = agglom[patchi][i];
115 label nbrZone = nbrAgglom[bFacei];
117 const auto iter = localToNbr.cfind(myZone);
122 if (iter.val() != nbrZone)
125 <<
"agglomeration is not synchronised across"
126 <<
" coupled patch " <<
pp.name()
128 <<
"Local agglomeration " << myZone
129 <<
". Remote agglomeration " << nbrZone
137 localToNbr.insert(myZone, nbrZone);
148 coarseI += nAgglom[patchi];
153 labelList patchStarts(oldPatches.size());
157 patchFaceMap_.setSize(oldPatches.size());
160 reverseFaceMap_.setSize(
mesh.nFaces());
161 reverseFaceMap_.labelList::operator=(-1);
167 forAll(oldPatches, patchi)
169 patchStarts[patchi] = coarseI;
171 const polyPatch&
pp = oldPatches[patchi];
175 patchFaceMap_[patchi].setSize(nAgglom[patchi]);
184 labelList agglomToFace(nAgglom[patchi], -1);
188 label myAgglom = agglom[patchi][i];
190 if (agglomToFace[myAgglom] == -1)
197 label coarsePatchFacei = coarseI - patchStarts[patchi];
198 patchFaceMap_[patchi][coarsePatchFacei] = myAgglom;
199 agglomToFace[myAgglom] = coarsePatchFacei;
201 const labelList& fineFaces = agglomToPatch[myAgglom];
206 reverseFaceMap_[
pp.start()+fineFaces[fineI]] = coarseI;
212 UIndirectList<face>(
pp, fineFaces),
216 if (upp.edgeLoops().size() != 1)
219 <<
"agglomeration does not create a"
220 <<
" single, non-manifold"
221 <<
" face for agglomeration " << myAgglom
222 <<
" on patch " << patchi
226 patchFaces[coarseI++] = face
238 patchSizes[patchi] = coarseI-patchStarts[patchi];
246 reversePointMap_.setSize(
mesh.nPoints());
247 reversePointMap_.labelList::operator=(-1);
250 forAll(patchFaces, coarseI)
252 face&
f = patchFaces[coarseI];
256 if (reversePointMap_[
f[fp]] == -1)
258 reversePointMap_[
f[fp]] = newI++;
261 f[fp] = reversePointMap_[
f[fp]];
265 pointMap_ =
invert(newI, reversePointMap_);
272 forAll(oldPatches, patchi)
277 oldPatches[patchi].
clone
288 const label nFace = patchFaces.size();
308 const cellZone& oldFz =
mesh.cellZones()[zoneI];
310 DynamicList<label> newAddressing;
338 const faceZone& oldFz =
mesh.faceZones()[zoneI];
340 DynamicList<label> newAddressing(oldFz.size());
341 DynamicList<bool> newFlipMap(oldFz.size());
345 label newFacei = reverseFaceMap_[oldFz[i]];
349 newAddressing.append(newFacei);
350 newFlipMap.append(oldFz.flipMap()[i]);
374 const pointZone& oldFz =
mesh.pointZones()[zoneI];
376 DynamicList<label> newAddressing(oldFz.size());
380 label
newPointi = reversePointMap_[oldFz[i]];
408Foam::singleCellFvMesh::singleCellFvMesh
416 patchFaceAgglomeration_
420 "patchFaceAgglomeration",
486 forAll(oldPatches, patchi)
491 agglomerateMesh(
mesh, agglom);
501Foam::singleCellFvMesh::singleCellFvMesh
510 patchFaceAgglomeration_
514 "patchFaceAgglomeration",
521 patchFaceAgglomeration
534 mesh.boundaryMesh().size()
585Foam::singleCellFvMesh::singleCellFvMesh(
const IOobject&
io,
const bool doInit)
588 patchFaceAgglomeration_
592 "patchFaceAgglomeration",
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
label size() const noexcept
readOption readOpt() const noexcept
Get the read option.
writeOption writeOpt() const noexcept
Get the write option.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
const fileName & instance() const noexcept
Read access to instance path component.
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie,...
void setSize(const label n)
Same as resize().
label size() const noexcept
The number of entries in the list.
void clear()
Clear the zones.
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
autoPtr< dictionary > clone() const
Construct and return clone.
Mesh data needed to do the Finite Volume discretisation.
void addFvPatches(polyPatchList &plist, const bool validBoundary=true)
Add boundary patches. Constructor helper.
const Time & time() const
Return the top-level database.
virtual bool init(const bool doInit)
Initialise all non-demand-driven data.
fvMesh(const fvMesh &)=delete
No copy construct.
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh,...
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
void setInstance(const fileName &instance, const IOobjectOption::writeOption wOpt=IOobject::AUTO_WRITE)
Set the instance for mesh files.
const faceZoneMesh & faceZones() const noexcept
Return face zone mesh.
const cellZoneMesh & cellZones() const noexcept
Return cell zone mesh.
const pointZoneMesh & pointZones() const noexcept
Return point zone mesh.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh").
void resetPrimitives(autoPtr< pointField > &&points, autoPtr< faceList > &&faces, autoPtr< labelList > &&owner, autoPtr< labelList > &&neighbour, const labelUList &patchSizes, const labelUList &patchStarts, const bool validBoundary=true)
Reset mesh primitive data. Assumes all patch info correct.
label nPoints() const noexcept
Number of mesh points.
label nFaces() const noexcept
Number of mesh faces.
const labelListList & patchFaceAgglomeration() const noexcept
Fine patch face to agglomeration index addressing.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Different types of constants.
PtrList< polyPatch > polyPatchList
Store lists of polyPatch as a PtrList.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
List< labelList > labelListList
List of labelList.
List< label > labelList
A List of labels.
IntListType renumber(const labelUList &oldToNew, const IntListType &input)
Renumber the values within a list.
List< face > faceList
List of faces.
Ostream & endl(Ostream &os)
Add newline and flush stream.
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...
static constexpr const zero Zero
Global zero (0).
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
labelList invert(const label len, const labelUList &map)
Create an inverse one-to-one mapping.
PrimitivePatch< UIndirectList< face >, const pointField & > uindirectPrimitivePatch
A PrimitivePatch with UIndirectList for the faces, const reference for the point field.
vectorField pointField
pointField is a vectorField.
labelListList invertOneToMany(const label len, const labelUList &map)
Invert one-to-many map. Unmapped elements will be size 0.
errorManipArg< error, int > exit(error &err, const int errNo=1)
#define forAll(list, i)
Loop across all elements in list.