40 Info<<
"bool polyMeshZipUpCells(polyMesh& mesh) const: " 41 <<
"zipping up topologically open cells" <<
endl;
62 label nChangedFacesInMesh = 0;
69 nChangedFacesInMesh = 0;
82 const edgeList cellEdges = Cells[celli].edges(oldFaces);
83 const labelList cellPoints = Cells[celli].labels(oldFaces);
91 edgeList curFaceEdges = oldFaces[curFaces[facei]].edges();
93 forAll(curFaceEdges, faceEdgeI)
95 const edge& curEdge = curFaceEdges[faceEdgeI];
97 forAll(cellEdges, cellEdgeI)
99 if (cellEdges[cellEdgeI] == curEdge)
101 edgeUsage[cellEdgeI]++;
109 label nSingleEdges = 0;
113 if (edgeUsage[edgeI] == 1)
115 singleEdges[nSingleEdges] = cellEdges[edgeI];
118 else if (edgeUsage[edgeI] != 2)
121 <<
"edge " << cellEdges[edgeI] <<
" in cell " << celli
122 <<
" used " << edgeUsage[edgeI] <<
" times. " <<
nl 123 <<
"Should be 1 or 2 - serious error " 124 <<
"in mesh structure. " <<
endl;
129 Info<<
"face: " << oldFaces[curFaces[facei]]
133 Info<<
"Cell edges: " << cellEdges <<
nl 134 <<
"Edge usage: " << edgeUsage <<
nl 135 <<
"Cell points: " << cellPoints <<
endl;
139 Info<<
"vertex create \"" << cellPoints[cpI]
141 << Points[cellPoints[cpI]] <<
endl;
146 problemCells.
insert(celli);
151 if (nSingleEdges == 0)
continue;
153 singleEdges.setSize(nSingleEdges);
160 Info<<
"face: " << oldFaces[curFaces[facei]] <<
endl;
163 Info<<
"Cell edges: " << cellEdges <<
nl 164 <<
"Edge usage: " << edgeUsage <<
nl 165 <<
"Single edges: " << singleEdges <<
nl 166 <<
"Cell points: " << cellPoints <<
endl;
170 Info<<
"vertex create \"" << cellPoints[cpI]
182 forAll(singleEdges, edgeI)
184 const edge& curEdge = singleEdges[edgeI];
186 forAll(cellPoints, pointi)
190 cellPoints[pointi] == curEdge.
start()
191 || cellPoints[pointi] == curEdge.
end()
194 pointUsage[pointi]++;
199 boolList singleEdgeUsage(singleEdges.size(),
false);
203 forAll(singleEdges, edgeI)
205 bool blockedHead =
false;
206 bool blockedTail =
false;
208 label newEdgeStart = singleEdges[edgeI].start();
209 label newEdgeEnd = singleEdges[edgeI].end();
212 forAll(cellPoints, pointi)
214 if (cellPoints[pointi] == newEdgeStart)
216 if (pointUsage[pointi] > 2)
221 else if (cellPoints[pointi] == newEdgeEnd)
223 if (pointUsage[pointi] > 2)
230 if (blockedHead && blockedTail)
233 singleEdgeUsage[edgeI] =
true;
242 label nEdgesToInsert = 0;
245 forAll(singleEdges, edgeI)
249 bool blockHead =
false;
250 bool blockTail =
false;
252 if (!singleEdgeUsage[edgeI])
255 singleEdgeUsage[edgeI] =
true;
257 label newEdgeStart = singleEdges[edgeI].start();
258 label newEdgeEnd = singleEdges[edgeI].
end();
260 pointChain.
insert(newEdgeStart);
261 pointChain.
append(newEdgeEnd);
264 Info<<
"found edge to start with: " 265 << singleEdges[edgeI] <<
endl;
269 forAll(cellPoints, pointi)
271 if (cellPoints[pointi] == newEdgeStart)
273 if (pointUsage[pointi] > 2)
276 Info<<
"start head blocked" <<
endl;
282 else if (cellPoints[pointi] == newEdgeEnd)
284 if (pointUsage[pointi] > 2)
287 Info<<
"start tail blocked" <<
endl;
295 bool stopSearching =
false;
300 stopSearching =
false;
302 forAll(singleEdges, addEdgeI)
304 if (!singleEdgeUsage[addEdgeI])
308 singleEdges[addEdgeI].start();
311 singleEdges[addEdgeI].end();
314 Info<<
"Trying candidate " 315 << singleEdges[addEdgeI] <<
endl;
321 if (pointChain.
first() == addStart)
324 pointChain.
insert(addEnd);
326 singleEdgeUsage[addEdgeI] =
true;
328 else if (pointChain.
first() == addEnd)
330 pointChain.
insert(addStart);
332 singleEdgeUsage[addEdgeI] =
true;
338 if (!blockTail && !singleEdgeUsage[addEdgeI])
340 if (pointChain.
last() == addStart)
343 pointChain.
append(addEnd);
345 singleEdgeUsage[addEdgeI] =
true;
347 else if (pointChain.
last() == addEnd)
349 pointChain.
append(addStart);
351 singleEdgeUsage[addEdgeI] =
true;
360 Info<<
"curEdgeStart: " << curEdgeStart
361 <<
" curEdgeEnd: " << curEdgeEnd <<
endl;
364 forAll(cellPoints, pointi)
366 if (cellPoints[pointi] == curEdgeStart)
368 if (pointUsage[pointi] > 2)
377 else if (cellPoints[pointi] == curEdgeEnd)
379 if (pointUsage[pointi] > 2)
391 if (curEdgeStart == curEdgeEnd)
402 stopSearching =
true;
406 Info<<
"current pointChain: " << pointChain
410 if (stopSearching)
break;
413 }
while (stopSearching);
417 Info<<
"completed patch chain: " << pointChain <<
endl;
420 if (pointChain.size() > 2)
422 edgesToInsert[nEdgesToInsert] = pointChain;
427 edgesToInsert.setSize(nEdgesToInsert);
430 Info<<
"edgesToInsert: " << edgesToInsert <<
endl;
434 forAll(edgesToInsert, edgeToInsertI)
442 const labelList& unorderedEdge = edgesToInsert[edgeToInsertI];
447 point startPoint = Points[unorderedEdge[0]];
450 vector dir = Points[unorderedEdge.last()] - startPoint;
452 for (
label i = 1; i < dist.size(); i++)
454 dist[i] = (Points[unorderedEdge[i]] - startPoint) & dir;
458 labelList orderedEdge(unorderedEdge.size(), -1);
459 boolList used(unorderedEdge.size(),
false);
463 label nextPoint = -1;
468 if (!used[i] && dist[i] < minDist)
476 orderedEdge[epI] = unorderedEdge[nextPoint];
477 used[nextPoint] =
true;
481 Info<<
"unorderedEdge: " << unorderedEdge <<
nl 482 <<
"orderedEdge: " << orderedEdge <<
endl;
486 forAll(orderedEdge, checkI)
490 label checkJ = checkI + 1;
491 checkJ < orderedEdge.size();
495 if (orderedEdge[checkI] == orderedEdge[checkJ])
498 <<
"Duplicate point found in edge to insert. " 499 <<
nl <<
"Point: " << orderedEdge[checkI]
500 <<
" edge: " << orderedEdge <<
endl;
502 problemCells.
insert(celli);
515 const labelList& startPF = pFaces[testEdge.start()];
516 const labelList& endPF = pFaces[testEdge.start()];
523 facesSharingEdge[nfse++] = startPF[pfI];
527 facesSharingEdge[nfse++] = endPF[pfI];
530 forAll(facesSharingEdge, facei)
532 bool faceChanges =
false;
535 const label currentFaceIndex = facesSharingEdge[facei];
538 oldFaces[currentFaceIndex].edges();
540 forAll(curFaceEdges, cfeI)
542 if (curFaceEdges[cfeI] == testEdge)
551 nChangedFacesInMesh++;
564 face& newFace = newFaces[currentFaceIndex];
566 bool allPointsPresent =
true;
570 bool curPointFound =
false;
574 if (newFace[nfI] == orderedEdge[oeI])
576 curPointFound =
true;
582 allPointsPresent && curPointFound;
586 if (allPointsPresent)
588 Info<<
"All points present" <<
endl;
592 if (!allPointsPresent)
605 Info<<
"Not all points present." <<
endl;
608 label nNewFacePoints = 0;
610 bool edgeAdded =
false;
612 forAll(newFaceEdges, curFacEdgI)
615 if (newFaceEdges[curFacEdgI] == testEdge)
625 + orderedEdge.size() - 2
630 newFaceEdges[curFacEdgI].start()
638 i < orderedEdge.size() - 1;
642 newFace[nNewFacePoints] =
652 label i = orderedEdge.size() - 1;
657 newFace[nNewFacePoints] =
667 newFace[nNewFacePoints] =
668 newFaceEdges[curFacEdgI].start();
675 << oldFaces[currentFaceIndex] <<
nl 676 <<
"newFace: " << newFace <<
endl;
684 label checkJ = checkI + 1;
685 checkJ < newFace.
size();
689 if (newFace[checkI] == newFace[checkJ])
692 <<
"Duplicate point found " 693 <<
"in the new face. " <<
nl 695 << orderedEdge[checkI]
699 problemCells.
insert(celli);
710 Info<<
"This edge modifies an already modified " 711 <<
"edge. Point insertions skipped." 720 if (problemCells.
size())
727 <<
"Found " << problemCells.
size() <<
" problem cells." <<
nl 732 Info<<
"Cycle " << ++nCycles
733 <<
" changed " << nChangedFacesInMesh <<
" faces." <<
endl;
771 }
while (nChangedFacesInMesh > 0 || nCycles > 100);
776 if (nChangedFacesInMesh > 0)
779 <<
"with the original mesh" const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
A simple container for copying or transferring objects of type <T>.
#define forAll(list, i)
Loop across all elements in list.
void clearAddressing()
Clear addressing.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
const faceZoneMesh & faceZones() const
Return face zone mesh.
A face is a list of labels corresponding to mesh vertices.
edgeList edges() const
Return edges in face point ordering,.
bool polyMeshZipUpCells(polyMesh &mesh)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void clearOut()
Clear all geometry and addressing unnecessary for CFD.
Template class for non-intrusive linked lists.
T & first()
Return the first entry added.
void size(const label)
Override size to be inconsistent with allocated storage.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const cellList & cells() const
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
bool insert(const Key &key)
Insert a new entry.
scalar minDist(const List< pointIndexHit > &hitList)
label size() const
Return number of elements in table.
virtual const pointField & points() const
Return raw points.
T removeHead()
Remove and return head.
A list of faces which address into the list of points.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
void resetPrimitives(const Xfer< pointField > &points, const Xfer< faceList > &faces, const Xfer< labelList > &owner, const Xfer< labelList > &neighbour, const labelList &patchSizes, const labelList &patchStarts, const bool validBoundary=true)
Reset mesh primitive data. Assumes all patch info correct.
Xfer< T > xferMove(T &)
Construct by transferring the contents of the arg.
virtual const faceList & faces() const
Return raw faces.
errorManip< error > abort(error &err)
void insert(const T &a)
Add at head of list.
const Time & time() const
Return time.
T & last()
Return the last entry added.
void append(const T &a)
Add at tail of list.
void setInstance(const fileName &)
Set the instance for mesh files.
label size() const
Return the number of elements in the UPtrList.
void setSize(const label)
Reset size of List.
#define WarningInFunction
Report a warning using Foam::Warning.
label end() const
Return end vertex label.
const labelListList & pointFaces() const
Cell zip-up tool. This function modifies the list of faces such that all the cells are topologically ...
Mesh consisting of general polyhedral cells.
List< Key > toc() const
Return the table of contents.
Info<< "Finished reading KIVA file"<< endl;cellShapeList cellShapes(nPoints);labelList cellZoning(nPoints, -1);const cellModel &hex=*(cellModeller::lookup("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]=cellShape(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]
label start() const
Return start vertex label.