OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

polyMeshZipUpCells.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "polyMeshZipUpCells.H"
00028 #include "polyMesh.H"
00029 #include "Time.H"
00030 
00031 // #define DEBUG_ZIPUP 1
00032 // #define DEBUG_CHAIN 1
00033 // #define DEBUG_ORDER 1
00034 
00035 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00036 
00037 bool Foam::polyMeshZipUpCells(polyMesh& mesh)
00038 {
00039     if (polyMesh::debug)
00040     {
00041         Info<< "bool polyMeshZipUpCells(polyMesh& mesh) const: "
00042             << "zipping up topologically open cells" << endl;
00043     }
00044 
00045     // Algorithm:
00046     // Take the original mesh and visit all cells.  For every cell
00047     // calculate the edges of all faces on the cells.  A cell is
00048     // correctly topologically closed when all the edges are referenced
00049     // by exactly two faces.  If the edges are referenced only by a
00050     // single face, additional vertices need to be inserted into some
00051     // of the faces (topological closedness).  If an edge is
00052     // referenced by more that two faces, there is an error in
00053     // topological closedness.
00054     // Point insertion into the faces is done by attempting to create
00055     // closed loops and inserting the intermediate points into the
00056     // defining edge
00057     // Note:
00058     // The algorithm is recursive and changes the mesh faces in each
00059     // pass.  It is therefore essential to discard the addressing
00060     // after every pass.  The algorithm is completed when the mesh
00061     // stops changing.
00062 
00063     label nChangedFacesInMesh = 0;
00064     label nCycles = 0;
00065 
00066     labelHashSet problemCells;
00067 
00068     do
00069     {
00070         nChangedFacesInMesh = 0;
00071 
00072         const cellList& Cells = mesh.cells();
00073         const pointField& Points = mesh.points();
00074 
00075         faceList newFaces = mesh.faces();
00076 
00077         const faceList& oldFaces = mesh.faces();
00078         const labelListList& pFaces = mesh.pointFaces();
00079 
00080         forAll (Cells, cellI)
00081         {
00082             const labelList& curFaces = Cells[cellI];
00083             const edgeList cellEdges = Cells[cellI].edges(oldFaces);
00084             const labelList cellPoints = Cells[cellI].labels(oldFaces);
00085 
00086             // Find the edges used only once in the cell
00087 
00088             labelList edgeUsage(cellEdges.size(), 0);
00089 
00090             forAll (curFaces, faceI)
00091             {
00092                 edgeList curFaceEdges = oldFaces[curFaces[faceI]].edges();
00093 
00094                 forAll (curFaceEdges, faceEdgeI)
00095                 {
00096                     const edge& curEdge = curFaceEdges[faceEdgeI];
00097 
00098                     forAll (cellEdges, cellEdgeI)
00099                     {
00100                         if (cellEdges[cellEdgeI] == curEdge)
00101                         {
00102                             edgeUsage[cellEdgeI]++;
00103                             break;
00104                         }
00105                     }
00106                 }
00107             }
00108 
00109             edgeList singleEdges(cellEdges.size());
00110             label nSingleEdges = 0;
00111 
00112             forAll (edgeUsage, edgeI)
00113             {
00114                 if (edgeUsage[edgeI] == 1)
00115                 {
00116                     singleEdges[nSingleEdges] = cellEdges[edgeI];
00117                     nSingleEdges++;
00118                 }
00119                 else if (edgeUsage[edgeI] != 2)
00120                 {
00121                     WarningIn("void polyMeshZipUpCells(polyMesh& mesh)")
00122                         << "edge " << cellEdges[edgeI] << " in cell " << cellI
00123                         << " used " << edgeUsage[edgeI] << " times. " << nl
00124                         << "Should be 1 or 2 - serious error "
00125                         << "in mesh structure. " << endl;
00126 
00127 #                   ifdef DEBUG_ZIPUP
00128                     forAll (curFaces, faceI)
00129                     {
00130                         Info<< "face: " << oldFaces[curFaces[faceI]]
00131                             << endl;
00132                     }
00133 
00134                     Info<< "Cell edges: " << cellEdges << nl
00135                         << "Edge usage: " << edgeUsage << nl
00136                         << "Cell points: " << cellPoints << endl;
00137 
00138                     forAll (cellPoints, cpI)
00139                     {
00140                         Info<< "vertex create \"" << cellPoints[cpI]
00141                             << "\" coordinates "
00142                             << Points[cellPoints[cpI]] << endl;
00143                     }
00144 #                   endif
00145 
00146                     // Gather the problem cell
00147                     problemCells.insert(cellI);
00148                 }
00149             }
00150 
00151             // Check if the cell is already zipped up
00152             if (nSingleEdges == 0) continue;
00153 
00154             singleEdges.setSize(nSingleEdges);
00155 
00156 #           ifdef DEBUG_ZIPUP
00157             Info << "Cell " << cellI << endl;
00158 
00159             forAll (curFaces, faceI)
00160             {
00161                 Info<< "face: " << oldFaces[curFaces[faceI]] << endl;
00162             }
00163 
00164             Info<< "Cell edges: " << cellEdges << nl
00165                 << "Edge usage: " << edgeUsage << nl
00166                 << "Single edges: " << singleEdges << nl
00167                 << "Cell points: " << cellPoints << endl;
00168 
00169             forAll (cellPoints, cpI)
00170             {
00171                 Info<< "vertex create \"" << cellPoints[cpI]
00172                     << "\" coordinates "
00173                     << points()[cellPoints[cpI]] << endl;
00174             }
00175 #           endif
00176 
00177             // Loop through all single edges and mark the points they use
00178             // points marked twice are internal to edge; those marked more than
00179             // twice are corners
00180 
00181             labelList pointUsage(cellPoints.size(), 0);
00182 
00183             forAll (singleEdges, edgeI)
00184             {
00185                 const edge& curEdge = singleEdges[edgeI];
00186 
00187                 forAll (cellPoints, pointI)
00188                 {
00189                     if
00190                     (
00191                         cellPoints[pointI] == curEdge.start()
00192                      || cellPoints[pointI] == curEdge.end()
00193                     )
00194                     {
00195                         pointUsage[pointI]++;
00196                     }
00197                 }
00198             }
00199 
00200             boolList singleEdgeUsage(singleEdges.size(), false);
00201 
00202             // loop through all edges and eliminate the ones that are
00203             // blocked out
00204             forAll (singleEdges, edgeI)
00205             {
00206                 bool blockedHead = false;
00207                 bool blockedTail = false;
00208 
00209                 label newEdgeStart = singleEdges[edgeI].start();
00210                 label newEdgeEnd = singleEdges[edgeI].end();
00211 
00212                 // check that the edge has not got all ends blocked
00213                 forAll (cellPoints, pointI)
00214                 {
00215                     if (cellPoints[pointI] == newEdgeStart)
00216                     {
00217                         if (pointUsage[pointI] > 2)
00218                         {
00219                             blockedHead = true;
00220                         }
00221                     }
00222                     else if (cellPoints[pointI] == newEdgeEnd)
00223                     {
00224                         if (pointUsage[pointI] > 2)
00225                         {
00226                             blockedTail = true;
00227                         }
00228                     }
00229                 }
00230 
00231                 if (blockedHead && blockedTail)
00232                 {
00233                     // Eliminating edge singleEdges[edgeI] as blocked
00234                     singleEdgeUsage[edgeI] = true;
00235                 }
00236             }
00237 
00238             // Go through the points and start from the point used twice
00239             // check all the edges to find the edges starting from this point
00240             // add the
00241 
00242             labelListList edgesToInsert(singleEdges.size());
00243             label nEdgesToInsert = 0;
00244 
00245             // Find a good edge
00246             forAll (singleEdges, edgeI)
00247             {
00248                 SLList<label> pointChain;
00249 
00250                 bool blockHead = false;
00251                 bool blockTail = false;
00252 
00253                 if (!singleEdgeUsage[edgeI])
00254                 {
00255                     // found a new edge
00256                     singleEdgeUsage[edgeI] = true;
00257 
00258                     label newEdgeStart = singleEdges[edgeI].start();
00259                     label newEdgeEnd = singleEdges[edgeI].end();
00260 
00261                     pointChain.insert(newEdgeStart);
00262                     pointChain.append(newEdgeEnd);
00263 
00264 #                   ifdef DEBUG_CHAIN
00265                     Info<< "found edge to start with: "
00266                         << singleEdges[edgeI] << endl;
00267 #                   endif
00268 
00269                     // Check if head or tail are blocked
00270                     forAll (cellPoints, pointI)
00271                     {
00272                         if (cellPoints[pointI] == newEdgeStart)
00273                         {
00274                             if (pointUsage[pointI] > 2)
00275                             {
00276 #                               ifdef DEBUG_CHAIN
00277                                 Info << "start head blocked" << endl;
00278 #                               endif
00279 
00280                                 blockHead = true;
00281                             }
00282                         }
00283                         else if(cellPoints[pointI] == newEdgeEnd)
00284                         {
00285                             if (pointUsage[pointI] > 2)
00286                             {
00287 #                               ifdef DEBUG_CHAIN
00288                                 Info << "start tail blocked" << endl;
00289 #                               endif
00290 
00291                                 blockTail = true;
00292                             }
00293                         }
00294                     }
00295 
00296                     bool stopSearching = false;
00297 
00298                     // Go through the unused edges and try to chain them up
00299                     do
00300                     {
00301                         stopSearching = false;
00302 
00303                         forAll (singleEdges, addEdgeI)
00304                         {
00305                             if (!singleEdgeUsage[addEdgeI])
00306                             {
00307                                 // Grab start and end of the candidate
00308                                 label addStart =
00309                                     singleEdges[addEdgeI].start();
00310 
00311                                 label addEnd =
00312                                     singleEdges[addEdgeI].end();
00313 
00314 #                               ifdef DEBUG_CHAIN
00315                                 Info<< "Trying candidate "
00316                                     << singleEdges[addEdgeI] << endl;
00317 #                               endif
00318 
00319                                 // Try to add the edge onto the head
00320                                 if (!blockHead)
00321                                 {
00322                                     if (pointChain.first() == addStart)
00323                                     {
00324                                         // Added at start mark as used
00325                                         pointChain.insert(addEnd);
00326 
00327                                         singleEdgeUsage[addEdgeI] = true;
00328                                     }
00329                                     else if (pointChain.first() == addEnd)
00330                                     {
00331                                         pointChain.insert(addStart);
00332 
00333                                         singleEdgeUsage[addEdgeI] = true;
00334                                     }
00335                                 }
00336 
00337                                 // Try the other end only if the first end
00338                                 // did not add it
00339                                 if (!blockTail && !singleEdgeUsage[addEdgeI])
00340                                 {
00341                                     if (pointChain.last() == addStart)
00342                                     {
00343                                         // Added at start mark as used
00344                                         pointChain.append(addEnd);
00345 
00346                                         singleEdgeUsage[addEdgeI] = true;
00347                                     }
00348                                     else if (pointChain.last() == addEnd)
00349                                     {
00350                                         pointChain.append(addStart);
00351 
00352                                         singleEdgeUsage[addEdgeI] = true;
00353                                     }
00354                                 }
00355 
00356                                 // check if the new head or tail are blocked
00357                                 label curEdgeStart = pointChain.first();
00358                                 label curEdgeEnd = pointChain.last();
00359 
00360 #                               ifdef DEBUG_CHAIN
00361                                 Info<< "curEdgeStart: " << curEdgeStart
00362                                     << " curEdgeEnd: " << curEdgeEnd << endl;
00363 #                               endif
00364 
00365                                 forAll (cellPoints, pointI)
00366                                 {
00367                                     if (cellPoints[pointI] == curEdgeStart)
00368                                     {
00369                                         if (pointUsage[pointI] > 2)
00370                                         {
00371 #                                           ifdef DEBUG_CHAIN
00372                                             Info << "head blocked" << endl;
00373 #                                           endif
00374 
00375                                             blockHead = true;
00376                                         }
00377                                     }
00378                                     else if(cellPoints[pointI] == curEdgeEnd)
00379                                     {
00380                                         if (pointUsage[pointI] > 2)
00381                                         {
00382 #                                           ifdef DEBUG_CHAIN
00383                                             Info << "tail blocked" << endl;
00384 #                                           endif
00385 
00386                                             blockTail = true;
00387                                         }
00388                                     }
00389                                 }
00390 
00391                                 // Check if the loop is closed
00392                                 if (curEdgeStart == curEdgeEnd)
00393                                 {
00394 #                                   ifdef DEBUG_CHAIN
00395                                     Info << "closed loop" << endl;
00396 #                                   endif
00397 
00398                                     pointChain.removeHead();
00399 
00400                                     blockHead = true;
00401                                     blockTail = true;
00402 
00403                                     stopSearching = true;
00404                                 }
00405 
00406 #                               ifdef DEBUG_CHAIN
00407                                 Info<< "current pointChain: " << pointChain
00408                                     << endl;
00409 #                               endif
00410 
00411                                 if (stopSearching) break;
00412                             }
00413                         }
00414                     } while (stopSearching);
00415                 }
00416 
00417 #               ifdef DEBUG_CHAIN
00418                 Info << "completed patch chain: " << pointChain << endl;
00419 #               endif
00420 
00421                 if (pointChain.size() > 2)
00422                 {
00423                     edgesToInsert[nEdgesToInsert] = pointChain;
00424                     nEdgesToInsert++;
00425                 }
00426             }
00427 
00428             edgesToInsert.setSize(nEdgesToInsert);
00429 
00430 #           ifdef DEBUG_ZIPUP
00431             Info << "edgesToInsert: " << edgesToInsert << endl;
00432 #           endif
00433 
00434             // Insert the edges into a list of faces
00435             forAll (edgesToInsert, edgeToInsertI)
00436             {
00437                 // Order the points of the edge
00438                 // Warning: the ordering must be parametric, because in
00439                 // the case of multiple point insertion onto the same edge
00440                 // it is possible to get non-cyclic loops
00441                 //
00442 
00443                 const labelList& unorderedEdge = edgesToInsert[edgeToInsertI];
00444 
00445                 scalarField dist(unorderedEdge.size());
00446 
00447                 // Calculate distance
00448                 point startPoint = Points[unorderedEdge[0]];
00449                 dist[0] = 0;
00450 
00451                 vector dir =
00452                     Points[unorderedEdge[unorderedEdge.size() - 1]]
00453                   - startPoint;
00454 
00455                 for (label i = 1; i < dist.size(); i++)
00456                 {
00457                     dist[i] = (Points[unorderedEdge[i]] - startPoint) & dir;
00458                 }
00459 
00460                 // Sort points
00461                 labelList orderedEdge(unorderedEdge.size(), -1);
00462                 boolList used(unorderedEdge.size(), false);
00463 
00464                 forAll (orderedEdge, epI)
00465                 {
00466                     label nextPoint = -1;
00467                     scalar minDist = GREAT;
00468 
00469                     forAll (dist, i)
00470                     {
00471                         if (!used[i] && dist[i] < minDist)
00472                         {
00473                             minDist = dist[i];
00474                             nextPoint = i;
00475                         }
00476                     }
00477 
00478                     // Insert the next point
00479                     orderedEdge[epI] = unorderedEdge[nextPoint];
00480                     used[nextPoint] = true;
00481                 }
00482 
00483 #               ifdef DEBUG_ORDER
00484                 Info<< "unorderedEdge: " << unorderedEdge << nl
00485                     << "orderedEdge: " << orderedEdge << endl;
00486 #               endif
00487 
00488                 // check for duplicate points in the ordered edge
00489                 forAll (orderedEdge, checkI)
00490                 {
00491                     for
00492                     (
00493                         label checkJ = checkI + 1;
00494                         checkJ < orderedEdge.size();
00495                         checkJ++
00496                     )
00497                     {
00498                         if (orderedEdge[checkI] == orderedEdge[checkJ])
00499                         {
00500                             WarningIn("void polyMeshZipUpCells(polyMesh& mesh)")
00501                                 << "Duplicate point found in edge to insert. "
00502                                 << nl << "Point: " << orderedEdge[checkI]
00503                                 << " edge: " << orderedEdge << endl;
00504 
00505                             problemCells.insert(cellI);
00506                         }
00507                     }
00508                 }
00509 
00510                 edge testEdge
00511                 (
00512                     orderedEdge[0],
00513                     orderedEdge[orderedEdge.size() - 1]
00514                 );
00515 
00516                 // In order to avoid edge-to-edge comparison, get faces using
00517                 // point-face addressing in two goes.
00518                 const labelList& startPF = pFaces[testEdge.start()];
00519                 const labelList& endPF = pFaces[testEdge.start()];
00520 
00521                 labelList facesSharingEdge(startPF.size() + endPF.size());
00522                 label nfse = 0;
00523 
00524                 forAll (startPF, pfI)
00525                 {
00526                     facesSharingEdge[nfse++] = startPF[pfI];
00527                 }
00528                 forAll (endPF, pfI)
00529                 {
00530                     facesSharingEdge[nfse++] = endPF[pfI];
00531                 }
00532 
00533                 forAll (facesSharingEdge, faceI)
00534                 {
00535                     bool faceChanges = false;
00536 
00537                     // Label of the face being analysed
00538                     const label currentFaceIndex = facesSharingEdge[faceI];
00539 
00540                     const edgeList curFaceEdges =
00541                         oldFaces[currentFaceIndex].edges();
00542 
00543                     forAll (curFaceEdges, cfeI)
00544                     {
00545                         if (curFaceEdges[cfeI] == testEdge)
00546                         {
00547                             faceChanges = true;
00548                             break;
00549                         }
00550                     }
00551 
00552                     if (faceChanges)
00553                     {
00554                         nChangedFacesInMesh++;
00555                         // In order to avoid loosing point from multiple
00556                         // insertions into the same face, the new face
00557                         // will be change incrementally.
00558                         // 1) Check if all the internal points of the edge
00559                         // to add already exist in the face. If so, the
00560                         // edge has already been included 2) Check if the
00561                         // point insertion occurs on an edge which is
00562                         // still untouched. If so, simply insert
00563                         // additional points into the face.  3) If not,
00564                         // the edge insertion occurs on an already
00565                         // modified edge. ???
00566 
00567                         face& newFace = newFaces[currentFaceIndex];
00568 
00569                         bool allPointsPresent = true;
00570 
00571                         forAll (orderedEdge, oeI)
00572                         {
00573                             bool curPointFound = false;
00574 
00575                             forAll (newFace, nfI)
00576                             {
00577                                 if (newFace[nfI] == orderedEdge[oeI])
00578                                 {
00579                                     curPointFound = true;
00580                                     break;
00581                                 }
00582                             }
00583 
00584                             allPointsPresent =
00585                                 allPointsPresent && curPointFound;
00586                         }
00587 
00588 #                       ifdef DEBUG_ZIPUP
00589                         if (allPointsPresent)
00590                         {
00591                             Info << "All points present" << endl;
00592                         }
00593 #                       endif
00594 
00595                         if (!allPointsPresent)
00596                         {
00597                             // Not all points are already present.  The
00598                             // new edge will need to be inserted into the
00599                             // face.
00600 
00601                             // Check to see if a new edge fits onto an
00602                             // untouched edge of the face.  Make sure the
00603                             // edges are grabbed before the face is
00604                             // resized.
00605                             edgeList newFaceEdges = newFace.edges();
00606 
00607 #                           ifdef DEBUG_ZIPUP
00608                             Info << "Not all points present." << endl;
00609 #                           endif
00610 
00611                             label nNewFacePoints = 0;
00612 
00613                             bool edgeAdded = false;
00614 
00615                             forAll (newFaceEdges, curFacEdgI)
00616                             {
00617                                 // Does the current edge change?
00618                                 if (newFaceEdges[curFacEdgI] == testEdge)
00619                                 {
00620                                     // Found an edge match
00621                                     edgeAdded = true;
00622 
00623                                     // Resize the face to accept additional
00624                                     // points
00625                                     newFace.setSize
00626                                     (
00627                                         newFace.size()
00628                                       + orderedEdge.size() - 2
00629                                     );
00630 
00631                                     if
00632                                     (
00633                                         newFaceEdges[curFacEdgI].start()
00634                                      == testEdge.start()
00635                                     )
00636                                     {
00637                                         // insertion in ascending order
00638                                         for
00639                                         (
00640                                             label i = 0;
00641                                             i < orderedEdge.size() - 1;
00642                                             i++
00643                                         )
00644                                         {
00645                                             newFace[nNewFacePoints] =
00646                                                 orderedEdge[i];
00647                                             nNewFacePoints++;
00648                                         }
00649                                     }
00650                                     else
00651                                     {
00652                                         // insertion in reverse order
00653                                         for
00654                                         (
00655                                             label i = orderedEdge.size() - 1;
00656                                             i > 0;
00657                                             i--
00658                                         )
00659                                         {
00660                                             newFace[nNewFacePoints] =
00661                                                 orderedEdge[i];
00662                                             nNewFacePoints++;
00663                                         }
00664                                     }
00665                                 }
00666                                 else
00667                                 {
00668                                     // Does not fit onto this edge.
00669                                     // Copy the next point into the face
00670                                     newFace[nNewFacePoints] =
00671                                         newFaceEdges[curFacEdgI].start();
00672                                     nNewFacePoints++;
00673                                 }
00674                             }
00675 
00676 #                           ifdef DEBUG_ZIPUP
00677                             Info<< "oldFace: "
00678                                 << oldFaces[currentFaceIndex] << nl
00679                                 << "newFace: " << newFace << endl;
00680 #                           endif
00681 
00682                             // Check for duplicate points in the new face
00683                             forAll (newFace, checkI)
00684                             {
00685                                 for
00686                                 (
00687                                     label checkJ = checkI + 1;
00688                                     checkJ < newFace.size();
00689                                     checkJ++
00690                                 )
00691                                 {
00692                                     if (newFace[checkI] == newFace[checkJ])
00693                                     {
00694                                         WarningIn("void polyMeshZipUpCells(polyMesh& mesh)")
00695                                             << "Duplicate point found "
00696                                             << "in the new face. " << nl
00697                                             << "Point: "
00698                                             << orderedEdge[checkI]
00699                                             << " face: "
00700                                             << newFace << endl;
00701 
00702                                         problemCells.insert(cellI);
00703                                     }
00704                                 }
00705                             }
00706 
00707                             // Check if the edge is added.
00708                             // If not, then it comes on top of an already
00709                             // modified edge and they need to be
00710                             // merged in together.
00711                             if (!edgeAdded)
00712                             {
00713                                 Info<< "This edge modifies an already modified "
00714                                     << "edge.  Point insertions skipped."
00715                                     << endl;
00716                             }
00717                         }
00718                     }
00719                 }
00720             }
00721         }
00722 
00723         if (problemCells.size())
00724         {
00725             // This cycle has failed.  Print out the problem cells
00726             labelList toc(problemCells.toc());
00727             sort(toc);
00728 
00729             FatalErrorIn("void polyMeshZipUpCells(polyMesh& mesh)")
00730                 << "Found " << problemCells.size() << " problem cells." << nl
00731                 << "Cells: " << toc
00732                 << abort(FatalError);
00733         }
00734 
00735         Info<< "Cycle " << ++nCycles
00736             << " changed " << nChangedFacesInMesh << " faces." << endl;
00737 
00738 
00739         const polyBoundaryMesh& bMesh = mesh.boundaryMesh();
00740 
00741         // Reset the polyMesh. Number of points/faces/cells/patches stays the
00742         // same, only the faces themselves have changed so clear all derived
00743         // (edge, point) addressing.
00744 
00745         // Collect the patch sizes
00746         labelList patchSizes(bMesh.size(), 0);
00747         labelList patchStarts(bMesh.size(), 0);
00748 
00749         forAll (bMesh, patchI)
00750         {
00751             patchSizes[patchI] = bMesh[patchI].size();
00752             patchStarts[patchI] = bMesh[patchI].start();
00753         }
00754 
00755         // Reset the mesh. Number of active faces is one beyond the last patch
00756         // (patches guaranteed to be in increasing order)
00757         mesh.resetPrimitives
00758         (
00759             Xfer<pointField>::null(),
00760             xferMove(newFaces),
00761             Xfer<labelList>::null(),
00762             Xfer<labelList>::null(),
00763             patchSizes,
00764             patchStarts,
00765             true                // boundary forms valid boundary mesh.
00766         );
00767 
00768         // Reset any addressing on face zones.
00769         mesh.faceZones().clearAddressing();
00770 
00771         // Clear the addressing
00772         mesh.clearOut();
00773 
00774     } while (nChangedFacesInMesh > 0 || nCycles > 100);
00775 
00776     // Flags the mesh files as being changed
00777     mesh.setInstance(mesh.time().timeName());
00778 
00779     if (nChangedFacesInMesh > 0)
00780     {
00781         FatalErrorIn("void polyMeshZipUpCells(polyMesh& mesh)")
00782             << "cell zip-up failed after 100 cycles.  Probable problem "
00783             << "with the original mesh"
00784             << abort(FatalError);
00785     }
00786 
00787     return nCycles != 1;
00788 }
00789 
00790 
00791 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd