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
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()]);
250void 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);
506 forAll(candidatePoints, i)
508 candidatePoint[candidatePoints[i]] =
true;
530 forAll(candidatePoints, i)
532 candidatePoint[candidatePoints[i]] =
true;
535 calcPointRegions(
mesh, baffles, candidatePoint);
556 labelList duplicateFace(allPatch.size(), -1);
557 label nDuplicateFaces = 0;
570 label otherFacei =
pFaces[i];
572 if (otherFacei > bFacei)
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));
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
695 newMap.
insert(newFacei, iter.val());
698 meshFaceMap_.transfer(newMap);
713 meshPointMap_.transfer(newMap);
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
DynamicList< T, SizeMin > & shrink()
Shrink the allocated space to the number of elements used.
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.
A List with indirect addressing.
void setSize(const label n)
Alias for resize()
A HashTable to objects of type <T> with a label key.
A list of faces which address into the list of points.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
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 List with indirect addressing. Like IndirectList but does not store addressing.
label find(const T &val, label pos=0) const
Find index of the first occurrence of the value.
void size(const label n)
Older name for setAddressableSize.
A face is a list of labels corresponding to mesh vertices.
Takes mesh with 'baffles' (= boundary faces sharing points). Determines for selected points on bounda...
static labelList findDuplicateFaces(const primitiveMesh &, const labelList &)
Helper routine to find baffles (two boundary faces using the.
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 & reversePointMap() const
Reverse point map.
const labelList & reverseFaceMap() const
Reverse face map.
void operator()(face &x, const face &y) const
void updateMesh()
Update for new mesh topology.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
label whichPatch(const label faceIndex) const
Return patch index for a given face label.
Mesh consisting of general polyhedral cells.
virtual const faceList & faces() const
Return raw faces.
virtual const labelList & faceOwner() const
Return face owner.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
virtual const labelList & faceNeighbour() const
Return face neighbour.
virtual const pointField & points() const
Return raw points.
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
bool coupled(solutionDict.getOrDefault("coupledEnergyField", false))
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Pair< label > labelPair
A pair of labels.
List< labelPair > labelPairList
List of labelPairs.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
List< label > labelList
A List of labels.
Ostream & endl(Ostream &os)
Add newline and flush stream.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
errorManip< error > abort(error &err)
List< bool > boolList
A List of bools.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce (copy) and return value.
List< face > faceList
A List of faces.
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];} 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]
#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.