69bool Foam::localPointRegion::isDuplicate
76 if (f0.size() != f1.size())
81 label fp1 = f1.find(f0[0]);
90 if (f0[fp0] != f1[fp1])
97 fp1 = f1.fcIndex(fp1);
101 fp1 = f1.rcIndex(fp1);
109void Foam::localPointRegion::countPointRegions
121 meshPointMap_.resize(candidateFace.size()/100);
126 meshFaceMap_.resize(meshPointMap_.size());
130 const label facei = iter.key();
136 if (minRegion[facei].empty())
139 <<
"Face from candidateFace without minRegion set." <<
endl
146 const label pointi =
f[fp];
151 if (candidatePoint[pointi])
153 const label region = minRegion[facei][fp];
155 if (minPointRegion[pointi] == -1)
157 minPointRegion[pointi] = region;
159 else if (minPointRegion[pointi] != region)
162 const auto iter = meshPointMap_.cfind(pointi);
165 labelList& regions = pointRegions[iter.val()];
166 if (!regions.found(region))
168 label sz = regions.size();
169 regions.setSize(sz+1);
170 regions[sz] = region;
175 const label localPointi = meshPointMap_.size();
176 meshPointMap_.insert(pointi, localPointi);
178 regions[0] = minPointRegion[pointi];
180 pointRegions.append(regions);
183 const label meshFaceMapI = meshFaceMap_.size();
184 meshFaceMap_.insert(facei, meshFaceMapI);
190 minPointRegion.clear();
196 const label facei = iter.key();
206 if (candidatePoint[
f[fp]] && meshPointMap_.found(
f[fp]))
208 const label meshFaceMapI = meshFaceMap_.size();
209 meshFaceMap_.insert(facei, meshFaceMapI);
217 pointRegions.shrink();
218 pointRegions_.setSize(pointRegions.size());
221 pointRegions_[i].transfer(pointRegions[i]);
225 faceRegions_.setSize(meshFaceMap_.size());
228 faceRegions_[iter()].labelList::transfer(minRegion[iter.key()]);
250void Foam::localPointRegion::calcPointRegions
275 label candidateFacei = 0;
278 label candidateCelli = 0;
286 if (candidatePoint[
f[fp]])
289 if (candidateFace.insert(facei, candidateFacei))
295 if (candidateCell.insert(faceOwner[facei], candidateCelli))
302 label nei = faceNeighbour[facei];
303 if (candidateCell.insert(nei, candidateCelli))
327 label facei = iter.key();
332 label globOwn = globalCells.toGlobal(faceOwner[facei]);
333 label globNei = globalCells.toGlobal(faceNeighbour[facei]);
334 minRegion[facei].setSize(
f.
size(),
min(globOwn, globNei));
338 label globOwn = globalCells.toGlobal(faceOwner[facei]);
339 minRegion[facei].setSize(
f.
size(), globOwn);
356 minPointValue.clear();
358 label celli = iter.key();
364 label facei = cFaces[cFacei];
366 if (minRegion[facei].size())
372 const label pointi =
f[fp];
373 auto iter = minPointValue.
find(pointi);
377 minPointValue.insert(pointi, minRegion[facei][fp]);
381 label currentMin = iter();
382 iter() =
min(currentMin, minRegion[facei][fp]);
391 label facei = cFaces[cFacei];
393 if (minRegion[facei].size())
399 label minVal = minPointValue[
f[fp]];
401 if (minVal != minRegion[facei][fp])
403 minRegion[facei][fp] = minVal;
433 Foam::dummyTransform()
437 label f0 = baffles[i].first();
438 label f1 = baffles[i].second();
440 minRegion[f1] = minRegion[f0];
446 countPointRegions(
mesh, candidatePoint, candidateFace, minRegion);
483 candidatePoint[
pp.meshPoints()[i]] =
true;
506 forAll(candidatePoints, i)
508 candidatePoint[candidatePoints[i]] =
true;
517 const polyMesh&
mesh,
530 forAll(candidatePoints, i)
532 candidatePoint[candidatePoints[i]] =
true;
535 calcPointRegions(
mesh, baffles, candidatePoint);
570 label otherFacei =
pFaces[i];
572 if (otherFacei > bFacei)
576 if (isDuplicate(
f, otherF,
true))
579 <<
"Face:" << bFacei +
mesh.nInternalFaces()
580 <<
" has local points:" <<
f <<
" at:"
582 <<
" which are in same order as face:"
583 << otherFacei +
mesh.nInternalFaces()
584 <<
" with local points:" << otherF
587 else if (isDuplicate(
f, otherF,
false))
589 label meshFace0 = bFacei +
mesh.nInternalFaces();
590 label meshFace1 = otherFacei +
mesh.nInternalFaces();
594 duplicateFace[bFacei] != -1
595 || duplicateFace[otherFacei] != -1
599 <<
"One of two duplicate faces already marked"
600 <<
" as duplicate." <<
nl
601 <<
"This means that three or more faces share"
602 <<
" the same points and this is illegal." <<
nl
603 <<
"Face:" << meshFace0
604 <<
" with local points:" <<
f <<
" at:"
606 <<
" which are in same order as face:"
608 <<
" with local points:" << otherF
612 duplicateFace[bFacei] = otherFacei;
613 duplicateFace[otherFacei] = bFacei;
620 return duplicateFace;
638 const labelList duplicateFace(findDuplicateFaces(
mesh, testFaces));
645 label otherFacei = duplicateFace[i];
647 if (otherFacei != -1 && i < otherFacei)
649 label meshFace0 = testFaces[i];
651 label meshFace1 = testFaces[otherFacei];
662 <<
"One of two duplicate faces is on"
663 <<
" processorPolyPatch."
664 <<
"This is not allowed." <<
nl
665 <<
"Face:" << meshFace0
669 <<
"Face:" << meshFace1
676 baffles.append(
labelPair(meshFace0, meshFace1));
681 return List<labelPair>(std::move(baffles));
692 const label newFacei = map.reverseFaceMap()[iter.key()];
696 newMap.insert(newFacei, iter.val());
699 meshFaceMap_.transfer(newMap);
706 const label
newPointi = map.reversePointMap()[iter.key()];
714 meshPointMap_.transfer(newMap);
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void append(const T &val)
Copy append an element to the end of this list.
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
const word & name() const noexcept
Return the object name.
label size() const noexcept
The number of elements in the list.
A List with indirect addressing.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
A HashTable to objects of type <T> with a label key.
const Field< point_type > & localPoints() const
Return pointField of points in patch.
const labelListList & pointFaces() const
Return point-face addressing.
const List< face_type > & localFaces() const
Return patch faces addressing into local point list.
A non-owning sub-view of a List (allocated or unallocated storage).
A List with indirect addressing. Like IndirectList but does not store addressing.
void size(const label n)
Older name for setAddressableSize.
label find(const T &val) const
Find index of the first occurrence of the value.
A cell is defined as a list of faces with extra functionality.
A face is a list of labels corresponding to mesh vertices.
Calculates a non-overlapping list of offsets based on an input size (eg, number of cells) from differ...
Takes mesh with 'baffles' (= boundary faces sharing points). Determines for selected points on bounda...
localPointRegion(const polyMesh &mesh)
Construct from mesh. Assumes all non-coupled boundary points.
static labelList findDuplicateFaces(const primitiveMesh &, const labelList &)
Helper routine to find baffles (two boundary faces using the.
void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
static labelPairList findDuplicateFacePairs(const polyMesh &)
Helper routine to find all baffles (two boundary faces.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
const labelList & reverseFaceMap() const noexcept
Reverse face map.
const labelList & reversePointMap() const noexcept
Reverse point map.
void operator()(face &x, const face &y) const
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh,...
label whichPatch(const label meshFacei) const
Return patch index for a given mesh face index. Uses binary search.
Mesh consisting of general polyhedral cells.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
virtual const faceList & faces() const
Return raw faces.
virtual const labelList & faceOwner() const
Return face owner.
virtual const labelList & faceNeighbour() const
Return face neighbour.
A patch is a list of labels that address the faces in the global face list.
Cell-face mesh analysis engine.
bool isInternalFace(const label faceIndex) const noexcept
Return true if given face label is internal to the mesh.
label nBoundaryFaces() const noexcept
Number of boundary faces (== nFaces - nInternalFaces).
const vectorField & faceCentres() const
label nInternalFaces() const noexcept
Number of internal faces.
label nPoints() const noexcept
Number of mesh points.
label nCells() const noexcept
Number of mesh cells.
label nFaces() const noexcept
Number of mesh faces.
const cellList & cells() const
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
const polyBoundaryMesh & patches
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Pair< label > labelPair
A pair of labels.
bool returnReduceOr(const bool value, const int communicator=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
List< labelPair > labelPairList
List of labelPair.
List< label > labelList
A List of labels.
List< face > faceList
List of faces.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
PrimitivePatch< IndirectList< face >, const pointField & > indirectPrimitivePatch
A PrimitivePatch with an IndirectList for the faces, const reference for the point field.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
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...
constexpr char nl
The newline '\n' character (0x0a).
Info<< "Finished reading KIVA file"<< endl;cellShapeList cellShapes(nPoints);labelList cellZoning(nPoints, -1);const cellModel &hex=cellModel::ref(cellModel::HEX);labelList hexLabels(8);label activeCells=0;labelList pointMap(nPoints);forAll(pointMap, i){ pointMap[i]=i;}for(label i=0;i< nPoints;i++){ if(f[i] > 0.0) { hexLabels[0]=i;hexLabels[1]=i1tab[i];hexLabels[2]=i3tab[i1tab[i]];hexLabels[3]=i3tab[i];hexLabels[4]=i8tab[i];hexLabels[5]=i1tab[i8tab[i]];hexLabels[6]=i3tab[i1tab[i8tab[i]]];hexLabels[7]=i3tab[i8tab[i]];cellShapes[activeCells].reset(hex, hexLabels);edgeList edges=cellShapes[activeCells].edges();forAll(edges, ei) { if(edges[ei].mag(points)< SMALL) { label start=pointMap[edges[ei].start()];while(start !=pointMap[start]) { start=pointMap[start];} label end=pointMap[edges[ei].end()];while(end !=pointMap[end]) { end=pointMap[end];} pointMap[start]=pointMap[end]=Foam::min(start, end);} } cellZoning[activeCells]=idreg[i];activeCells++;}}cellShapes.setSize(activeCells);cellZoning.setSize(activeCells);forAll(cellShapes, celli){ cellShape &cs=cellShapes[celli];forAll(cs, i) { cs[i]=pointMap[cs[i]];} cs.collapse();}label bcIDs[11]={-1, 0, 2, 4, -1, 5, -1, 6, 7, 8, 9};constexpr label nBCs=12;const word *kivaPatchTypes[nBCs]={ &wallPolyPatch::typeName, &wallPolyPatch::typeName, &wallPolyPatch::typeName, &wallPolyPatch::typeName, &symmetryPolyPatch::typeName, &wedgePolyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &symmetryPolyPatch::typeName, &oldCyclicPolyPatch::typeName};enum patchTypeNames{ PISTON, VALVE, LINER, CYLINDERHEAD, AXIS, WEDGE, INFLOW, OUTFLOW, PRESIN, PRESOUT, SYMMETRYPLANE, CYCLIC};const char *kivaPatchNames[nBCs]={ "piston", "valve", "liner", "cylinderHead", "axis", "wedge", "inflow", "outflow", "presin", "presout", "symmetryPlane", "cyclic"};List< DynamicList< face > > pFaces[nBCs]
#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.