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