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

boundaryCutter.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 Description
00026 
00027 \*---------------------------------------------------------------------------*/
00028 
00029 #include "boundaryCutter.H"
00030 #include "polyMesh.H"
00031 #include "polyTopoChange.H"
00032 #include "polyAddCell.H"
00033 #include "polyAddFace.H"
00034 #include "polyAddPoint.H"
00035 #include "polyModifyFace.H"
00036 #include "polyModifyPoint.H"
00037 #include "mapPolyMesh.H"
00038 #include "meshTools.H"
00039 
00040 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00041 
00042 namespace Foam
00043 {
00044 
00045 defineTypeNameAndDebug(boundaryCutter, 0);
00046 
00047 }
00048 
00049 
00050 // * * * * * * * * * * * * * Private Static Functions  * * * * * * * * * * * //
00051 
00052 
00053 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00054 
00055 void Foam::boundaryCutter::getFaceInfo
00056 (
00057     const label faceI,
00058     label& patchID,
00059     label& zoneID,
00060     label& zoneFlip
00061 ) const
00062 {
00063     patchID = -1;
00064 
00065     if (!mesh_.isInternalFace(faceI))
00066     {
00067         patchID = mesh_.boundaryMesh().whichPatch(faceI);
00068     }
00069 
00070     zoneID = mesh_.faceZones().whichZone(faceI);
00071 
00072     zoneFlip = false;
00073 
00074     if (zoneID >= 0)
00075     {
00076         const faceZone& fZone = mesh_.faceZones()[zoneID];
00077 
00078         zoneFlip = fZone.flipMap()[fZone.whichFace(faceI)];
00079     }
00080 }
00081 
00082 
00083 // Adds additional vertices (from edge cutting) to face. Used for faces which
00084 // are not split but still might use edge that has been cut.
00085 Foam::face Foam::boundaryCutter::addEdgeCutsToFace
00086 (
00087     const label faceI,
00088     const Map<labelList>& edgeToAddedPoints
00089 ) const
00090 {
00091     const edgeList& edges = mesh_.edges();
00092     const face& f = mesh_.faces()[faceI];
00093     const labelList& fEdges = mesh_.faceEdges()[faceI];
00094 
00095     // Storage for face
00096     DynamicList<label> newFace(2 * f.size());
00097 
00098     forAll(f, fp)
00099     {
00100         // Duplicate face vertex .
00101         newFace.append(f[fp]);
00102 
00103         // Check if edge has been cut.
00104         label v1 = f.nextLabel(fp);
00105 
00106         label edgeI = meshTools::findEdge(edges, fEdges, f[fp], v1);
00107 
00108         Map<labelList>::const_iterator fnd = edgeToAddedPoints.find(edgeI);
00109 
00110         if (fnd != edgeToAddedPoints.end())
00111         {
00112             // edge has been cut. Introduce new vertices. Check order.
00113             const labelList& addedPoints = fnd();
00114 
00115             if (edges[edgeI].start() == f[fp])
00116             {
00117                 // Introduce in same order.
00118                 forAll(addedPoints, i)
00119                 {
00120                     newFace.append(addedPoints[i]);
00121                 }
00122             }
00123             else
00124             {
00125                 // Introduce in opposite order.
00126                 forAllReverse(addedPoints, i)
00127                 {
00128                     newFace.append(addedPoints[i]);
00129                 }
00130             }
00131         }
00132     }
00133 
00134     face returnFace;
00135     returnFace.transfer(newFace);
00136 
00137     if (debug)
00138     {
00139         Pout<< "addEdgeCutsToFace:" << nl
00140             << "    from : " << f << nl
00141             << "    to   : " << returnFace << endl;
00142     }
00143 
00144     return returnFace;
00145 }
00146 
00147 
00148 void Foam::boundaryCutter::addFace
00149 (
00150     const label faceI,
00151     const face& newFace,
00152 
00153     bool& modifiedFace,     // have we already 'used' faceI
00154     polyTopoChange& meshMod
00155 ) const
00156 {
00157     // Information about old face
00158     label patchID, zoneID, zoneFlip;
00159     getFaceInfo(faceI, patchID, zoneID, zoneFlip);
00160     label own = mesh_.faceOwner()[faceI];
00161     label masterPoint = mesh_.faces()[faceI][0];
00162     
00163     if (!modifiedFace)
00164     {
00165         meshMod.setAction
00166         (
00167             polyModifyFace
00168             (
00169                 newFace,       // face
00170                 faceI,
00171                 own,           // owner
00172                 -1,            // neighbour
00173                 false,         // flux flip
00174                 patchID,       // patch for face
00175                 false,         // remove from zone
00176                 zoneID,        // zone for face
00177                 zoneFlip       // face zone flip
00178             )
00179         );
00180 
00181         modifiedFace = true;
00182     }
00183     else
00184     {
00185         meshMod.setAction
00186         (
00187             polyAddFace
00188             (
00189                 newFace,       // face
00190                 own,           // owner
00191                 -1,            // neighbour
00192                 masterPoint,   // master point
00193                 -1,            // master edge
00194                 -1,            // master face for addition
00195                 false,         // flux flip
00196                 patchID,       // patch for face
00197                 zoneID,        // zone for face
00198                 zoneFlip       // face zone flip
00199             )
00200         );
00201     }
00202 }
00203 
00204 
00205 
00206 // Splits a face using the cut edges and modified points 
00207 bool Foam::boundaryCutter::splitFace
00208 (
00209     const label faceI,
00210     const Map<point>& pointToPos,
00211     const Map<labelList>& edgeToAddedPoints,
00212     polyTopoChange& meshMod
00213 ) const
00214 {
00215     const edgeList& edges = mesh_.edges();
00216     const face& f = mesh_.faces()[faceI];
00217     const labelList& fEdges = mesh_.faceEdges()[faceI];
00218 
00219     // Count number of split edges and total number of splits.
00220     label nSplitEdges = 0;
00221     label nModPoints = 0;
00222     label nTotalSplits = 0;
00223 
00224     forAll(f, fp)
00225     {
00226         if (pointToPos.found(f[fp]))
00227         {
00228             nModPoints++;
00229             nTotalSplits++;
00230         }
00231 
00232         // Check if edge has been cut.
00233         label nextV = f.nextLabel(fp);
00234 
00235         label edgeI = meshTools::findEdge(edges, fEdges, f[fp], nextV);
00236 
00237         Map<labelList>::const_iterator fnd = edgeToAddedPoints.find(edgeI);
00238 
00239         if (fnd != edgeToAddedPoints.end())
00240         {
00241             nSplitEdges++;
00242             nTotalSplits += fnd().size();
00243         }
00244     }
00245 
00246     if (debug)
00247     {
00248         Pout<< "Face:" << faceI
00249             << " nModPoints:" << nModPoints
00250             << " nSplitEdges:" << nSplitEdges
00251             << " nTotalSplits:" << nTotalSplits << endl;
00252     }
00253 
00254     if (nSplitEdges == 0 && nModPoints == 0)
00255     {
00256         FatalErrorIn("boundaryCutter::splitFace") << "Problem : face:" << faceI
00257             << " nSplitEdges:" << nSplitEdges
00258             << " nTotalSplits:" << nTotalSplits
00259             << abort(FatalError);
00260         return false;
00261     }
00262     else if (nSplitEdges + nModPoints == 1)
00263     {
00264         // single or multiple cuts on a single edge or single modified point
00265         // Dont cut and let caller handle this.
00266         Warning << "Face " << faceI << " has only one edge cut " << endl;
00267         return false;
00268     }
00269     else
00270     {
00271         // So guaranteed to have two edges cut or points modified. Split face:
00272         // - find starting cut
00273         // - walk to next cut. Make face
00274         // - loop until face done.
00275 
00276         // Information about old face
00277         label patchID, zoneID, zoneFlip;
00278         getFaceInfo(faceI, patchID, zoneID, zoneFlip);
00279 
00280         // Get face with new points on cut edges for ease of looping
00281         face extendedFace(addEdgeCutsToFace(faceI, edgeToAddedPoints));
00282 
00283         // Find first added point. This is the starting vertex for splitting.
00284         label startFp = -1;
00285 
00286         forAll(extendedFace, fp)
00287         {
00288             if (extendedFace[fp] >= mesh_.nPoints())
00289             {
00290                 startFp = fp;
00291                 break;
00292             }
00293         }
00294 
00295         if (startFp == -1)
00296         {
00297             // No added point. Maybe there is a modified point?
00298             forAll(extendedFace, fp)
00299             {
00300                 if (pointToPos.found(extendedFace[fp]))
00301                 {
00302                     startFp = fp;
00303                     break;
00304                 }
00305             }
00306         }
00307 
00308         if (startFp == -1)
00309         {
00310             FatalErrorIn("boundaryCutter::splitFace")
00311                 << "Problem" << abort(FatalError);
00312         }
00313 
00314         // Have we already modified existing face (first face gets done
00315         // as modification; all following ones as polyAddFace)
00316         bool modifiedFace = false;
00317 
00318         // Example face:
00319         //    +--+
00320         //   /   |
00321         //  /    |
00322         // +     +
00323         //  \    |
00324         //   \   |
00325         //    +--+
00326         //
00327         // Needs to get split into:
00328         // - three 'side' faces a,b,c
00329         // - one middle face d
00330         //    +--+
00331         //   /|\A|
00332         //  / | \|
00333         // + C|D +
00334         //  \ | /|
00335         //   \|/B|
00336         //    +--+
00337 
00338 
00339         // Storage for new face
00340         DynamicList<label> newFace(extendedFace.size());
00341 
00342         label fp = startFp;
00343 
00344         forAll(extendedFace, i)
00345         {
00346             label pointI = extendedFace[fp];
00347 
00348             newFace.append(pointI);
00349 
00350             if
00351             (
00352                 newFace.size() > 2
00353              && (
00354                     pointI >= mesh_.nPoints()
00355                  || pointToPos.found(pointI)
00356                 )
00357             )
00358             {
00359                 // Enough vertices to create a face from.
00360                 face tmpFace;
00361                 tmpFace.transfer(newFace);
00362 
00363                 // Add face tmpFace
00364                 addFace(faceI, tmpFace, modifiedFace, meshMod);
00365 
00366                 // Starting point is also the starting point for the new face
00367                 newFace.append(extendedFace[startFp]);
00368                 newFace.append(extendedFace[fp]);
00369             }
00370 
00371             fp = (fp+1) % extendedFace.size();
00372         }
00373 
00374         // Check final face.
00375         if (newFace.size() > 2)
00376         {
00377             // Enough vertices to create a face from.
00378             face tmpFace;
00379             tmpFace.transfer(newFace);
00380 
00381             // Add face tmpFace
00382             addFace(faceI, tmpFace, modifiedFace, meshMod);
00383         }
00384 
00385         // Split something
00386         return true;
00387     }
00388 }
00389 
00390 
00391 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00392 
00393 // Construct from components
00394 Foam::boundaryCutter::boundaryCutter(const polyMesh& mesh)
00395 :
00396     mesh_(mesh),
00397     edgeAddedPoints_(),
00398     faceAddedPoint_()
00399 {}
00400 
00401 
00402 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00403 
00404 Foam::boundaryCutter::~boundaryCutter()
00405 {}
00406 
00407 
00408 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00409 
00410 void Foam::boundaryCutter::setRefinement
00411 (
00412     const Map<point>& pointToPos,
00413     const Map<List<point> >& edgeToCuts,
00414     const Map<labelPair>& faceToSplit,
00415     const Map<point>& faceToFeaturePoint,
00416     polyTopoChange& meshMod
00417 )
00418 {
00419     // Clear and size maps here since mesh size will change.
00420     edgeAddedPoints_.clear();
00421 
00422     faceAddedPoint_.clear();
00423     faceAddedPoint_.resize(faceToFeaturePoint.size());
00424 
00425 
00426     //
00427     // Points that just need to be moved
00428     // Note: could just as well be handled outside of setRefinement.
00429     //
00430 
00431     forAllConstIter(Map<point>, pointToPos, iter)
00432     {
00433         meshMod.setAction
00434         (
00435             polyModifyPoint
00436             (
00437                 iter.key(), // point
00438                 iter(),     // position
00439                 false,      // no zone
00440                 -1,         // zone for point
00441                 true        // supports a cell
00442             )
00443         );
00444     }
00445 
00446 
00447     //
00448     // Add new points along cut edges.
00449     //
00450 
00451     // Map from edge label to sorted list of points
00452     Map<labelList> edgeToAddedPoints(edgeToCuts.size());
00453 
00454     forAllConstIter(Map<List<point> >, edgeToCuts, iter)
00455     {
00456         label edgeI = iter.key();
00457 
00458         const edge& e = mesh_.edges()[edgeI];
00459 
00460         // Sorted (from start to end) list of cuts on edge
00461         const List<point>& cuts = iter();
00462 
00463         forAll(cuts, cutI)
00464         {
00465             // point on feature to move to
00466             const point& featurePoint = cuts[cutI];
00467 
00468             label addedPointI =
00469                 meshMod.setAction
00470                 (
00471                     polyAddPoint
00472                     (
00473                         featurePoint,               // point
00474                         e.start(),                  // master point
00475                         -1,                         // zone for point
00476                         true                        // supports a cell
00477                     )
00478                 );
00479 
00480             Map<labelList>::iterator fnd = edgeToAddedPoints.find(edgeI);
00481 
00482             if (fnd != edgeToAddedPoints.end())
00483             {
00484                 labelList& addedPoints = fnd();
00485 
00486                 label sz = addedPoints.size();
00487                 addedPoints.setSize(sz+1);
00488                 addedPoints[sz] = addedPointI;
00489             }
00490             else
00491             {
00492                 edgeToAddedPoints.insert(edgeI, labelList(1, addedPointI));
00493             }
00494 
00495             if (debug)
00496             {
00497                 Pout<< "Added point " << addedPointI << " for edge " << edgeI
00498                     << " with cuts:" << edgeToAddedPoints[edgeI] << endl;
00499             }
00500         }
00501     }
00502 
00503 
00504     //
00505     // Introduce feature points.
00506     //
00507 
00508     forAllConstIter(Map<point>, faceToFeaturePoint, iter)
00509     {
00510         label faceI = iter.key();
00511 
00512         const face& f = mesh_.faces()[faceI];
00513 
00514         if (faceToSplit.found(faceI))
00515         {
00516             FatalErrorIn("boundaryCutter::setRefinement")
00517                 << "Face " << faceI << " vertices " << f
00518                 << " is both marked for face-centre decomposition and"
00519                 << " diagonal splitting."
00520                 << abort(FatalError);
00521         }
00522 
00523         if (mesh_.isInternalFace(faceI))
00524         {
00525             FatalErrorIn("boundaryCutter::setRefinement")
00526                 << "Face " << faceI << " vertices " << f
00527                 << " is not an external face. Cannot split it"
00528                 << abort(FatalError);
00529         }
00530 
00531         label addedPointI =
00532             meshMod.setAction
00533             (
00534                 polyAddPoint
00535                 (
00536                     iter(), // point
00537                     f[0],   // master point
00538                     -1,     // zone for point
00539                     true    // supports a cell
00540                 )
00541             );
00542         faceAddedPoint_.insert(faceI, addedPointI);
00543 
00544         if (debug)
00545         {
00546             Pout<< "Added point " << addedPointI << " for feature point "
00547                 << iter() << " on face " << faceI << " with centre "
00548                 << mesh_.faceCentres()[faceI] << endl;
00549         }
00550     }
00551 
00552 
00553     //
00554     // Split or retriangulate faces
00555     //
00556 
00557 
00558     // Maintain whether face has been updated (for -split edges
00559     // -new owner/neighbour)
00560     boolList faceUptodate(mesh_.nFaces(), false);
00561 
00562 
00563     // Triangulate faces containing feature points
00564     forAllConstIter(Map<label>, faceAddedPoint_, iter)
00565     {
00566         label faceI = iter.key();
00567 
00568         // Get face with new points on cut edges.
00569         face newFace(addEdgeCutsToFace(faceI, edgeToAddedPoints));
00570 
00571         label addedPointI = iter();
00572 
00573         // Information about old face
00574         label patchID, zoneID, zoneFlip;
00575         getFaceInfo(faceI, patchID, zoneID, zoneFlip);
00576         label own = mesh_.faceOwner()[faceI];
00577         label masterPoint = mesh_.faces()[faceI][0];
00578 
00579         // Triangulate face around mid point
00580 
00581         face tri(3);
00582 
00583         forAll(newFace, fp)
00584         {
00585             label nextV = newFace.nextLabel(fp);
00586 
00587             tri[0] = newFace[fp];
00588             tri[1] = nextV;
00589             tri[2] = addedPointI;
00590 
00591             if (fp == 0)
00592             {
00593                 // Modify the existing face.
00594                 meshMod.setAction
00595                 (
00596                     polyModifyFace
00597                     (
00598                         tri,                        // face
00599                         faceI,
00600                         own,                        // owner
00601                         -1,                         // neighbour
00602                         false,                      // flux flip
00603                         patchID,                    // patch for face
00604                         false,                      // remove from zone
00605                         zoneID,                     // zone for face
00606                         zoneFlip                    // face zone flip
00607                     )
00608                 );
00609             }
00610             else
00611             {
00612                 // Add additional faces
00613                 meshMod.setAction
00614                 (
00615                     polyAddFace
00616                     (
00617                         tri,                        // face
00618                         own,                        // owner
00619                         -1,                         // neighbour
00620                         masterPoint,                // master point
00621                         -1,                         // master edge
00622                         -1,                         // master face for addition
00623                         false,                      // flux flip
00624                         patchID,                    // patch for face
00625                         zoneID,                     // zone for face
00626                         zoneFlip                    // face zone flip
00627                     )
00628                 );
00629             }
00630         }
00631 
00632         faceUptodate[faceI] = true;
00633     }
00634 
00635 
00636     // Diagonally split faces
00637     forAllConstIter(Map<labelPair>, faceToSplit, iter)
00638     {
00639         label faceI = iter.key();
00640 
00641         const face& f = mesh_.faces()[faceI];
00642 
00643         if (faceAddedPoint_.found(faceI))
00644         {
00645             FatalErrorIn("boundaryCutter::setRefinement")
00646                 << "Face " << faceI << " vertices " << f
00647                 << " is both marked for face-centre decomposition and"
00648                 << " diagonal splitting."
00649                 << abort(FatalError);
00650         }
00651 
00652 
00653         // Get face with new points on cut edges.
00654         face newFace(addEdgeCutsToFace(faceI, edgeToAddedPoints));
00655 
00656         // Information about old face
00657         label patchID, zoneID, zoneFlip;
00658         getFaceInfo(faceI, patchID, zoneID, zoneFlip);
00659         label own = mesh_.faceOwner()[faceI];
00660         label masterPoint = mesh_.faces()[faceI][0];
00661 
00662         // Split face from one side of diagonal to other.
00663         const labelPair& diag = iter();
00664 
00665         label fp0 = findIndex(newFace, f[diag[0]]);
00666         label fp1 = findIndex(newFace, f[diag[1]]);
00667 
00668         if (fp0 == -1 || fp1 == -1 || fp0 == fp1)
00669         {
00670             FatalErrorIn("boundaryCutter::setRefinement")
00671                 << "Problem : Face " << faceI << " vertices " << f
00672                 << " newFace:" << newFace << " diagonal:" << f[diag[0]]
00673                 << ' ' << f[diag[1]]
00674                 << abort(FatalError);
00675         }
00676 
00677         // Replace existing face by newFace from fp0 to fp1 and add new one
00678         // from fp1 to fp0.
00679 
00680         DynamicList<label> newVerts(newFace.size());
00681 
00682         // Get vertices from fp0 to (and including) fp1
00683         label fp = fp0;
00684 
00685         do
00686         {
00687             newVerts.append(newFace[fp]);
00688 
00689             fp = (fp == newFace.size()-1 ? 0 : fp+1);
00690 
00691         } while (fp != fp1);
00692 
00693         newVerts.append(newFace[fp1]);
00694 
00695 
00696         // Modify the existing face.
00697         meshMod.setAction
00698         (
00699             polyModifyFace
00700             (
00701                 face(newVerts.shrink()),    // face
00702                 faceI,
00703                 own,                        // owner
00704                 -1,                         // neighbour
00705                 false,                      // flux flip
00706                 patchID,                    // patch for face
00707                 false,                      // remove from zone
00708                 zoneID,                     // zone for face
00709                 zoneFlip                    // face zone flip
00710             )
00711         );
00712 
00713 
00714         newVerts.clear();
00715 
00716         // Get vertices from fp1 to (and including) fp0
00717 
00718         do
00719         {
00720             newVerts.append(newFace[fp]);
00721 
00722             fp = (fp == newFace.size()-1 ? 0 : fp+1);
00723 
00724         } while (fp != fp0);
00725 
00726         newVerts.append(newFace[fp0]);
00727 
00728         // Add additional face
00729         meshMod.setAction
00730         (
00731             polyAddFace
00732             (
00733                 face(newVerts.shrink()),    // face
00734                 own,                        // owner
00735                 -1,                         // neighbour
00736                 masterPoint,                // master point
00737                 -1,                         // master edge
00738                 -1,                         // master face for addition
00739                 false,                      // flux flip
00740                 patchID,                    // patch for face
00741                 zoneID,                     // zone for face
00742                 zoneFlip                    // face zone flip
00743             )
00744         );
00745 
00746         faceUptodate[faceI] = true;
00747     }
00748 
00749 
00750     // Split external faces without feature point but using cut edges.
00751     // Does right handed walk but not really.
00752     forAllConstIter(Map<labelList>, edgeToAddedPoints, iter)
00753     {
00754         label edgeI = iter.key();
00755 
00756         const labelList& eFaces = mesh_.edgeFaces()[edgeI];
00757 
00758         forAll(eFaces, i)    
00759         {
00760             label faceI = eFaces[i];
00761 
00762             if (!faceUptodate[faceI] && !mesh_.isInternalFace(faceI))
00763             {
00764                 // Is external face so split
00765                 if (splitFace(faceI, pointToPos, edgeToAddedPoints, meshMod))
00766                 {
00767                     // Successfull split
00768                     faceUptodate[faceI] = true;
00769                 }
00770             }
00771         }
00772     }
00773 
00774 
00775     // Add cut edges (but don't split) any other faces using any cut edge.
00776     // These can be external faces where splitFace hasn't cut them or
00777     // internal faces.
00778     forAllConstIter(Map<labelList>, edgeToAddedPoints, iter)
00779     {
00780         label edgeI = iter.key();
00781 
00782         const labelList& eFaces = mesh_.edgeFaces()[edgeI];
00783 
00784         forAll(eFaces, i)    
00785         {
00786             label faceI = eFaces[i];
00787 
00788             if (!faceUptodate[faceI])
00789             {
00790                 // Renumber face to include split edges.
00791                 face newFace(addEdgeCutsToFace(faceI, edgeToAddedPoints));
00792 
00793                 label own = mesh_.faceOwner()[faceI];
00794 
00795                 label nei = -1;
00796 
00797                 if (mesh_.isInternalFace(faceI))
00798                 {
00799                     nei = mesh_.faceNeighbour()[faceI];
00800                 }
00801 
00802                 label patchID, zoneID, zoneFlip;
00803                 getFaceInfo(faceI, patchID, zoneID, zoneFlip);
00804 
00805                 meshMod.setAction
00806                 (
00807                     polyModifyFace
00808                     (
00809                         newFace,            // modified face
00810                         faceI,              // label of face being modified
00811                         own,                // owner
00812                         nei,                // neighbour
00813                         false,              // face flip
00814                         patchID,            // patch for face
00815                         false,              // remove from zone
00816                         zoneID,             // zone for face
00817                         zoneFlip            // face flip in zone
00818                     )
00819                 );
00820 
00821                 faceUptodate[faceI] = true;
00822             }
00823         }
00824     }
00825 
00826     // Convert edge to points storage from edge labels (not preserved)
00827     // to point labels
00828     edgeAddedPoints_.resize(edgeToCuts.size());
00829 
00830     forAllConstIter(Map<labelList>, edgeToAddedPoints, iter)
00831     {
00832         edgeAddedPoints_.insert(mesh_.edges()[iter.key()], iter());
00833     }
00834 }
00835 
00836 
00837 void Foam::boundaryCutter::updateMesh(const mapPolyMesh& morphMap)
00838 {
00839     // Update stored labels for mesh change.
00840 
00841     //
00842     // Do faceToAddedPoint
00843     //
00844 
00845     {
00846         // Create copy since we're deleting entries.
00847         Map<label> newAddedPoints(faceAddedPoint_.size());
00848 
00849         forAllConstIter(Map<label>, faceAddedPoint_, iter)
00850         {
00851             label oldFaceI = iter.key();
00852 
00853             label newFaceI = morphMap.reverseFaceMap()[oldFaceI];
00854 
00855             label oldPointI = iter();
00856 
00857             label newPointI = morphMap.reversePointMap()[oldPointI];
00858 
00859             if (newFaceI >= 0 && newPointI >= 0)
00860             {
00861                 newAddedPoints.insert(newFaceI, newPointI);
00862             }
00863         }
00864 
00865         // Copy
00866         faceAddedPoint_.transfer(newAddedPoints);
00867     }
00868 
00869 
00870     //
00871     // Do edgeToAddedPoints
00872     //
00873 
00874 
00875     {
00876         // Create copy since we're deleting entries
00877         HashTable<labelList, edge, Hash<edge> >
00878             newEdgeAddedPoints(edgeAddedPoints_.size());
00879 
00880         for
00881         (
00882             HashTable<labelList, edge, Hash<edge> >::const_iterator iter =
00883                 edgeAddedPoints_.begin();
00884             iter != edgeAddedPoints_.end();
00885             ++iter
00886         )
00887         {
00888             const edge& e = iter.key();
00889 
00890             label newStart = morphMap.reversePointMap()[e.start()];
00891 
00892             label newEnd = morphMap.reversePointMap()[e.end()];
00893 
00894             if (newStart >= 0 && newEnd >= 0)
00895             {
00896                 const labelList& addedPoints = iter();
00897 
00898                 labelList newAddedPoints(addedPoints.size());
00899                 label newI = 0;
00900 
00901                 forAll(addedPoints, i)
00902                 {
00903                     label newAddedPointI =
00904                         morphMap.reversePointMap()[addedPoints[i]];
00905 
00906                     if (newAddedPointI >= 0)
00907                     {
00908                         newAddedPoints[newI++] = newAddedPointI;
00909                     }
00910                 }
00911                 if (newI > 0)
00912                 {
00913                     newAddedPoints.setSize(newI);
00914 
00915                     edge newE = edge(newStart, newEnd);
00916 
00917                     newEdgeAddedPoints.insert(newE, newAddedPoints);
00918                 }
00919             }
00920         }
00921 
00922         // Copy
00923         edgeAddedPoints_.transfer(newEdgeAddedPoints);
00924     }
00925 }
00926 
00927 
00928 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd