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

removePoints.H

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 Class
00026     Foam::removePoints
00027 
00028 Description
00029     Removes selected points from mesh and updates faces using these
00030     points.
00031 
00032 SourceFiles
00033     removePoints.C
00034 
00035 \*---------------------------------------------------------------------------*/
00036 
00037 #ifndef removePoints_H
00038 #define removePoints_H
00039 
00040 #include "typeInfo.H"
00041 #include "boolList.H"
00042 #include "pointField.H"
00043 #include "faceList.H"
00044 
00045 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00046 
00047 namespace Foam
00048 {
00049 
00050 // Forward declaration of classes
00051 class polyMesh;
00052 class polyTopoChange;
00053 class mapPolyMesh;
00054 class face;
00055 
00056 /*---------------------------------------------------------------------------*\
00057                            Class removePoints Declaration
00058 \*---------------------------------------------------------------------------*/
00059 
00060 class removePoints
00061 {
00062 
00063     // Private classes
00064 
00065         //- Combine-reduce operator to combine data on faces. Takes care
00066         //  of reverse orientation on coupled face.
00067         template <class T, template<class> class CombineOp>
00068         class faceEqOp
00069         {
00070 
00071         public:
00072 
00073             void operator()(List<T>& x, const List<T>& y) const
00074             {
00075                 if (y.size() > 0)
00076                 {
00077                     if (x.empty())
00078                     {
00079                         x = y;
00080                     }
00081                     else
00082                     {
00083                         label j = 0;
00084                         forAll(x, i)
00085                         {
00086                             CombineOp<T>()(x[i], y[j]);
00087                             j = y.rcIndex(j);
00088                         }
00089                     }
00090                 }
00091             }
00092         };
00093 
00094 
00095     // Private data
00096 
00097         //- Reference to mesh
00098         const polyMesh& mesh_;
00099 
00100         //- Whether undoable
00101         const bool undoable_;
00102 
00103         //- If undoable: deleted points
00104         pointField savedPoints_;
00105 
00106         //- If undoable: per stored face the original mesh face label
00107         labelList savedFaceLabels_;
00108 
00109         //- If undoable: per stored face the vertices. Negative indices
00110         //  refer to deletedPoints_
00111         faceList savedFaces_;
00112 
00113 
00114     // Private Member Functions
00115 
00116         //- Change the vertices of the face whilst keeping everything else
00117         //  (patch, zone) the same.
00118         void modifyFace
00119         (
00120             const label faceI,
00121             const face&,
00122             polyTopoChange&
00123         ) const;
00124 
00125 
00126         //- Disallow default bitwise copy construct
00127         removePoints(const removePoints&);
00128 
00129         //- Disallow default bitwise assignment
00130         void operator=(const removePoints&);
00131 
00132 public:
00133 
00134     //- Runtime type information
00135     ClassName("removePoints");
00136 
00137 
00138     // Constructors
00139 
00140         //- Construct from mesh
00141         removePoints(const polyMesh& mesh, const bool undoable = false);
00142 
00143 
00144     // Member Functions
00145 
00146             //- If undoable: affected face labels. Already restored faces
00147             //  will be -1.
00148             const labelList& savedFaceLabels() const
00149             {
00150                 return savedFaceLabels_;
00151             }
00152 
00153 
00154         // Helper functions
00155 
00156             //- Mark in pointCanBeDeleted the points that can be deleted
00157             //  (parallel synchronised) and returns the global number of these
00158             //  points. (this number is the global number before synchronisation
00159             //  so might be off!)
00160             //  A point can be deleted if
00161             //  - it is not used by any edge.
00162             //  or
00163             //  - is not used by an internal edge
00164             //  - is used by only two boundary edges. (note that these two
00165             //    edges will always be boundary ones!)
00166             //  - these two edges are sufficiently in line (cos > minCos)
00167             //  - all processors agree that point can be deleted.
00168             label countPointUsage
00169             (
00170                 const scalar minCos,
00171                 boolList& pointCanBeDeleted
00172             ) const;
00173 
00174         // Topology changes
00175 
00176             //- Play commands into polyTopoChange to remove points. Gets
00177             //  boolList (output of countPointUsage) as input.
00178             //  Does no check for whether resulting face is legal.
00179             //  Since pointCanBeDeleted is synced all coupled faces should
00180             //  decide the same.
00181             void setRefinement(const boolList&, polyTopoChange&);
00182 
00183             //- Force recalculation of locally stored data on topological change
00184             void updateMesh(const mapPolyMesh&);
00185 
00186             //- Given set of faces to restore calculates a consistent set of
00187             //  saved faces (indices into savedFaces_) and saved vertices
00188             //  (indices into savedPoints_) to restore. The undoFaces have to
00189             //  be synced.
00190             void getUnrefimentSet
00191             (
00192                 const labelList& undoFaces,
00193                 labelList& localFaces,
00194                 labelList& localPoints
00195             ) const;
00196 
00197             //- Restore selected faces and vertices.
00198             void setUnrefinement
00199             (
00200                 const labelList& localFaces,
00201                 const labelList& localPoints,
00202                 polyTopoChange&
00203             );
00204 };
00205 
00206 
00207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00208 
00209 } // End namespace Foam
00210 
00211 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00212 
00213 #endif
00214 
00215 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd