69 bool 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);
109 void Foam::localPointRegion::countPointRegions
111 const polyMesh&
mesh,
113 const Map<label>& candidateFace,
121 meshPointMap_.
resize(candidateFace.size()/100);
123 DynamicList<labelList> pointRegions(meshPointMap_.size());
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()]);
250 void Foam::localPointRegion::calcPointRegions
252 const polyMesh&
mesh,
274 Map<label> candidateFace(2*nBnd);
275 label candidateFacei = 0;
277 Map<label> candidateCell(nBnd);
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]);
338 label globOwn = globalCells.toGlobal(faceOwner[facei]);
339 minRegion[facei].setSize(
f.
size(), globOwn);
352 Map<label> minPointValue(128);
356 minPointValue.clear();
358 label celli = iter.key();
359 const cell& cFaces =
mesh.
cells()[celli];
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;
437 label f0 = baffles[i].first();
438 label f1 = baffles[i].second();
439 minEqOpFace()(minRegion[f0], minRegion[f1]);
440 minRegion[f1] = minRegion[f0];
446 countPointRegions(
mesh, candidatePoint, candidateFace, minRegion);
494 const polyMesh&
mesh,
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);
556 labelList duplicateFace(allPatch.size(), -1);
557 label nDuplicateFaces = 0;
562 const face&
f = allPatch.localFaces()[bFacei];
570 label otherFacei =
pFaces[i];
572 if (otherFacei > bFacei)
574 const face& otherF = allPatch.localFaces()[otherFacei];
576 if (isDuplicate(
f, otherF,
true))
580 <<
" has local points:" <<
f <<
" at:" 582 <<
" which are in same order as face:" 584 <<
" with local points:" << otherF
587 else if (isDuplicate(
f, otherF,
false))
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));
641 DynamicList<labelPair> baffles(testFaces.size());
645 label otherFacei = duplicateFace[i];
647 if (otherFacei != -1 && i < otherFacei)
649 label meshFace0 = testFaces[i];
651 label meshFace1 = testFaces[otherFacei];
657 (patch0 != -1 && isA<processorPolyPatch>(
patches[patch0]))
658 || (patch1 != -1 && isA<processorPolyPatch>(
patches[patch1]))
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));
680 return baffles.shrink();
687 Map<label> newMap(meshFaceMap_.size());
691 const label newFacei = map.reverseFaceMap()[iter.key()];
695 newMap.insert(newFacei, iter.val());
698 meshFaceMap_.transfer(newMap);
701 Map<label> newMap(meshPointMap_.size());
705 const label
newPointi = map.reversePointMap()[iter.key()];
713 meshPointMap_.transfer(newMap);
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
void size(const label n)
Older name for setAddressableSize.
A face is a list of labels corresponding to mesh vertices.
void resize(const label len)
Adjust allocated size of list.
label nPoints() const noexcept
Number of mesh points.
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.
label find(const T &val, label pos=0) const
Find index of the first occurrence of the value.
virtual const labelList & faceNeighbour() const
Return face neighbour.
const word & name() const noexcept
Return the object name.
Cell-face mesh analysis engine.
constexpr char nl
The newline '\n' character (0x0a)
List< face > faceList
A List of faces.
bool coupled(solutionDict.getOrDefault("coupledEnergyField", false))
Ostream & endl(Ostream &os)
Add newline and flush stream.
const cellList & cells() const
label nFaces() const noexcept
Number of mesh faces.
bool isInternalFace(const label faceIndex) const noexcept
Return true if given face label is internal to the mesh.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
Takes mesh with 'baffles' (= boundary faces sharing points). Determines for selected points on bounda...
static labelPairList findDuplicateFacePairs(const polyMesh &)
Helper routine to find all baffles (two boundary faces.
virtual const pointField & points() const
Return raw points.
#define forAll(list, i)
Loop across all elements in list.
A list of faces which address into the list of points.
void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
void setSize(const label n)
Alias for resize()
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
localPointRegion(const polyMesh &mesh)
Construct from mesh. Assumes all non-coupled boundary points.
virtual const labelList & faceOwner() const
Return face owner.
label nInternalFaces() const noexcept
Number of internal faces.
virtual const faceList & faces() const
Return raw faces.
List< labelPair > labelPairList
List of labelPairs.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
errorManip< error > abort(error &err)
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO...
Pair< label > labelPair
A pair of labels.
defineTypeNameAndDebug(combustionModel, 0)
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];} label minLabel=min(start, end);pointMap[start]=pointMap[end]=minLabel;} } 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};const 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< SLList< face > > pFaces[nBCs]
const vectorField & faceCentres() const
void operator()(face &x, const face &y) const
label nCells() const noexcept
Number of mesh cells.
A List with indirect addressing. Like IndirectList but does not store addressing. ...
label whichPatch(const label faceIndex) const
Return patch index for a given mesh face index.
const polyBoundaryMesh & patches
static labelList findDuplicateFaces(const primitiveMesh &, const labelList &)
Helper routine to find baffles (two boundary faces using the.
Mesh consisting of general polyhedral cells.
List< label > labelList
A List of labels.
A patch is a list of labels that address the faces in the global face list.
label nBoundaryFaces() const noexcept
Number of boundary faces (== nFaces - nInternalFaces)
bool returnReduceOr(const bool value, const label comm=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
List< bool > boolList
A List of bools.
A List with indirect addressing.
forAllConstIters(mixture.phases(), phase)