45 Info<<
"bool polyMeshZipUpCells(polyMesh& mesh) const: " 46 <<
"zipping up topologically open cells" <<
endl;
67 label nChangedFacesInMesh = 0;
77 nChangedFacesInMesh = 0;
90 const edgeList cellEdges = Cells[celli].edges(oldFaces);
91 const labelList cellPoints = Cells[celli].labels(oldFaces);
99 edgeList curFaceEdges = oldFaces[curFaces[facei]].edges();
101 forAll(curFaceEdges, faceEdgeI)
103 const edge& curEdge = curFaceEdges[faceEdgeI];
105 forAll(cellEdges, cellEdgeI)
107 if (cellEdges[cellEdgeI] == curEdge)
109 edgeUsage[cellEdgeI]++;
117 label nSingleEdges = 0;
121 if (edgeUsage[edgeI] == 1)
123 singleEdges[nSingleEdges] = cellEdges[edgeI];
126 else if (edgeUsage[edgeI] != 2)
129 <<
"edge " << cellEdges[edgeI] <<
" in cell " << celli
130 <<
" used " << edgeUsage[edgeI] <<
" times. " <<
nl 131 <<
"Should be 1 or 2 - serious error " 132 <<
"in mesh structure. " <<
endl;
137 Info<<
"face: " << oldFaces[curFaces[facei]]
141 Info<<
"Cell edges: " << cellEdges <<
nl 142 <<
"Edge usage: " << edgeUsage <<
nl 143 <<
"Cell points: " << cellPoints <<
endl;
147 Info<<
"vertex create \"" << cellPoints[cpI]
154 problemCells.
insert(celli);
159 if (nSingleEdges == 0)
continue;
161 singleEdges.setSize(nSingleEdges);
168 Info<<
"face: " << oldFaces[curFaces[facei]] <<
endl;
171 Info<<
"Cell edges: " << cellEdges <<
nl 172 <<
"Edge usage: " << edgeUsage <<
nl 173 <<
"Single edges: " << singleEdges <<
nl 174 <<
"Cell points: " << cellPoints <<
endl;
178 Info<<
"vertex create \"" << cellPoints[cpI]
190 forAll(singleEdges, edgeI)
192 const edge& curEdge = singleEdges[edgeI];
194 forAll(cellPoints, pointi)
198 cellPoints[pointi] == curEdge.
start()
199 || cellPoints[pointi] == curEdge.
end()
202 pointUsage[pointi]++;
208 singleEdgeUsage =
false;
212 forAll(singleEdges, edgeI)
214 bool blockedHead =
false;
215 bool blockedTail =
false;
217 label newEdgeStart = singleEdges[edgeI].start();
218 label newEdgeEnd = singleEdges[edgeI].end();
221 forAll(cellPoints, pointi)
223 if (cellPoints[pointi] == newEdgeStart)
225 if (pointUsage[pointi] > 2)
230 else if (cellPoints[pointi] == newEdgeEnd)
232 if (pointUsage[pointi] > 2)
239 if (blockedHead && blockedTail)
242 singleEdgeUsage[edgeI] =
true;
251 label nEdgesToInsert = 0;
254 forAll(singleEdges, edgeI)
258 bool blockHead =
false;
259 bool blockTail =
false;
261 if (!singleEdgeUsage[edgeI])
264 singleEdgeUsage[edgeI] =
true;
266 label newEdgeStart = singleEdges[edgeI].start();
267 label newEdgeEnd = singleEdges[edgeI].
end();
273 Info<<
"found edge to start with: " 274 << singleEdges[edgeI] <<
endl;
278 forAll(cellPoints, pointi)
280 if (cellPoints[pointi] == newEdgeStart)
282 if (pointUsage[pointi] > 2)
285 Info<<
"start head blocked" <<
endl;
291 else if (cellPoints[pointi] == newEdgeEnd)
293 if (pointUsage[pointi] > 2)
296 Info<<
"start tail blocked" <<
endl;
304 bool stopSearching =
false;
309 stopSearching =
false;
311 forAll(singleEdges, addEdgeI)
313 if (!singleEdgeUsage[addEdgeI])
317 singleEdges[addEdgeI].start();
320 singleEdges[addEdgeI].end();
323 Info<<
"Trying candidate " 324 << singleEdges[addEdgeI] <<
endl;
330 if (pointChain.
front() == addStart)
335 singleEdgeUsage[addEdgeI] =
true;
337 else if (pointChain.
front() == addEnd)
341 singleEdgeUsage[addEdgeI] =
true;
347 if (!blockTail && !singleEdgeUsage[addEdgeI])
349 if (pointChain.
back() == addStart)
354 singleEdgeUsage[addEdgeI] =
true;
356 else if (pointChain.
back() == addEnd)
360 singleEdgeUsage[addEdgeI] =
true;
365 label curEdgeStart = pointChain.
front();
366 label curEdgeEnd = pointChain.
back();
369 Info<<
"curEdgeStart: " << curEdgeStart
370 <<
" curEdgeEnd: " << curEdgeEnd <<
endl;
373 forAll(cellPoints, pointi)
375 if (cellPoints[pointi] == curEdgeStart)
377 if (pointUsage[pointi] > 2)
386 else if (cellPoints[pointi] == curEdgeEnd)
388 if (pointUsage[pointi] > 2)
400 if (curEdgeStart == curEdgeEnd)
411 stopSearching =
true;
415 Info<<
"current pointChain: " 416 << pointChain <<
endl;
419 if (stopSearching)
break;
422 }
while (stopSearching);
426 Info<<
"completed patch chain: " << pointChain <<
endl;
429 if (pointChain.
size() > 2)
431 edgesToInsert[nEdgesToInsert] = pointChain.
list();
436 edgesToInsert.
setSize(nEdgesToInsert);
439 Info<<
"edgesToInsert: " << edgesToInsert <<
endl;
443 forAll(edgesToInsert, edgeToInsertI)
451 const labelList& unorderedEdge = edgesToInsert[edgeToInsertI];
461 for (label i = 1; i < dist.size(); i++)
463 dist[i] = (
Points[unorderedEdge[i]] - startPoint) & dir;
467 labelList orderedEdge(unorderedEdge.size(), -1);
472 label nextPoint = -1;
473 scalar minDist = GREAT;
477 if (!
used[i] && dist[i] < minDist)
485 orderedEdge[epI] = unorderedEdge[nextPoint];
486 used[nextPoint] =
true;
490 Info<<
"unorderedEdge: " << unorderedEdge <<
nl 491 <<
"orderedEdge: " << orderedEdge <<
endl;
495 forAll(orderedEdge, checkI)
499 label checkJ = checkI + 1;
500 checkJ < orderedEdge.size();
504 if (orderedEdge[checkI] == orderedEdge[checkJ])
507 <<
"Duplicate point found in edge to insert. " 508 <<
nl <<
"Point: " << orderedEdge[checkI]
509 <<
" edge: " << orderedEdge <<
endl;
511 problemCells.
insert(celli);
532 facesSharingEdge[nfse++] = startPF[pfI];
536 facesSharingEdge[nfse++] = endPF[pfI];
539 forAll(facesSharingEdge, facei)
541 bool faceChanges =
false;
544 const label currentFaceIndex = facesSharingEdge[facei];
547 oldFaces[currentFaceIndex].edges();
549 forAll(curFaceEdges, cfeI)
551 if (curFaceEdges[cfeI] == testEdge)
560 nChangedFacesInMesh++;
573 face& newFace = newFaces[currentFaceIndex];
575 bool allPointsPresent =
true;
579 bool curPointFound =
false;
583 if (newFace[nfI] == orderedEdge[oeI])
585 curPointFound =
true;
591 allPointsPresent && curPointFound;
595 if (allPointsPresent)
597 Info<<
"All points present" <<
endl;
601 if (!allPointsPresent)
614 Info<<
"Not all points present." <<
endl;
617 label nNewFacePoints = 0;
619 bool edgeAdded =
false;
621 forAll(newFaceEdges, curFacEdgI)
624 if (newFaceEdges[curFacEdgI] == testEdge)
634 + orderedEdge.size() - 2
639 newFaceEdges[curFacEdgI].start()
647 i < orderedEdge.size() - 1;
651 newFace[nNewFacePoints] =
661 label i = orderedEdge.size() - 1;
666 newFace[nNewFacePoints] =
676 newFace[nNewFacePoints] =
677 newFaceEdges[curFacEdgI].start();
684 << oldFaces[currentFaceIndex] <<
nl 685 <<
"newFace: " << newFace <<
endl;
693 label checkJ = checkI + 1;
694 checkJ < newFace.
size();
698 if (newFace[checkI] == newFace[checkJ])
701 <<
"Duplicate point found " 702 <<
"in the new face. " <<
nl 704 << orderedEdge[checkI]
708 problemCells.
insert(celli);
719 Info<<
"This edge modifies an already modified " 720 <<
"edge. Point insertions skipped." 729 if (problemCells.
size())
733 <<
"Found " << problemCells.
size() <<
" problem cells." <<
nl 738 Info<<
"Cycle " << ++nCycles
739 <<
" changed " << nChangedFacesInMesh <<
" faces." <<
endl;
754 patchSizes[patchi] =
bMesh[patchi].size();
755 patchStarts[patchi] =
bMesh[patchi].start();
772 mesh.faceZones().clearAddressing();
777 }
while (nChangedFacesInMesh > 0 || nCycles > 100);
780 mesh.setInstance(
mesh.time().timeName());
782 if (nChangedFacesInMesh > 0)
785 <<
"with the original mesh"
void size(const label n)
Older name for setAddressableSize.
void pop_front(label n=1)
Shrink by moving the front of the buffer 1 or more times.
A face is a list of labels corresponding to mesh vertices.
edgeList edges() const
Return list of edges in forward walk order.
labelHashSet used(const bitSet &select)
Convert a bitset to a labelHashSet of the indices used.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
bool polyMeshZipUpCells(polyMesh &mesh)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void clear() noexcept
Clear the addressed buffer, does not change allocation.
constexpr char nl
The newline '\n' character (0x0a)
void push_front(const T &val)
Copy prepend an element to the front of the buffer.
Ostream & endl(Ostream &os)
Add newline and flush stream.
label size() const noexcept
The current number of buffer items.
T & back()
Access the last element (back). Requires !empty().
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
#define forAll(list, i)
Loop across all elements in list.
label start() const noexcept
The start (first) vertex label.
label size() const noexcept
The number of elements in table.
A list of faces which address into the list of points.
List< T > list() const
Return a copy of the buffer flattened into a single List. Use sparingly!
void setSize(const label n)
Alias for resize()
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
A simple list of objects of type <T> that is intended to be used as a circular buffer (eg...
errorManip< error > abort(error &err)
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO...
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
int debug
Static debugging option.
T & front()
Access the first element (front). Requires !empty().
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 WarningInFunction
Report a warning using Foam::Warning.
List< Key > sortedToc() const
The table of contents (the keys) in sorted order.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Cell zip-up tool. This function modifies the list of faces such that all the cells are topologically ...
void push_back(const T &val)
Copy append an element to the end of the buffer.
void resize_nocopy(const label len)
Alter addressable list size, allocating new space if required without necessarily recovering old cont...
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Mesh consisting of general polyhedral cells.
label end() const noexcept
The end (last/second) vertex label.
iterator end() noexcept
Return an iterator to end traversing the UList.
static constexpr const zero Zero
Global zero (0)