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::combineFaces 00026 00027 Description 00028 Combines boundary faces into single face. The faces get the patch 00029 of the first face ('the master') 00030 00031 SourceFiles 00032 combineFaces.C 00033 00034 \*---------------------------------------------------------------------------*/ 00035 00036 #ifndef combineFaces_H 00037 #define combineFaces_H 00038 00039 #include <OpenFOAM/indirectPrimitivePatch.H> 00040 00041 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00042 00043 namespace Foam 00044 { 00045 00046 // Forward declaration of classes 00047 class polyMesh; 00048 class polyTopoChange; 00049 class mapPolyMesh; 00050 class face; 00051 00052 /*---------------------------------------------------------------------------*\ 00053 Class combineFaces Declaration 00054 \*---------------------------------------------------------------------------*/ 00055 00056 class combineFaces 00057 { 00058 // Private data 00059 00060 //- Reference to mesh 00061 const polyMesh& mesh_; 00062 00063 //- Whether undoable 00064 const bool undoable_; 00065 00066 //- If undoable: masterface for every set. 00067 labelList masterFace_; 00068 00069 //- If undoable: per set the vertices of all the faces in the set. 00070 List<faceList> faceSetsVertices_; 00071 00072 //- If undoable: saved point labels. 00073 labelList savedPointLabels_; 00074 00075 //- If undoable: saved coordinates of above points. 00076 pointField savedPoints_; 00077 00078 00079 00080 // Private Member Functions 00081 00082 //- Test if face is convex. Allow slight concavity through 00083 // minConcaveCos. 00084 static bool convexFace 00085 ( 00086 const scalar minConcaveCos, 00087 const pointField&, 00088 const face& 00089 ); 00090 00091 //- Test if set of faces (in primitivePatch) can be combined into 00092 // single face. Uses convexFace. 00093 static bool validFace 00094 ( 00095 const scalar minConcaveCos, 00096 const indirectPrimitivePatch& 00097 ); 00098 00099 //- Create cell-local map from face to region (formed by merging faces 00100 // across edges) 00101 void regioniseFaces 00102 ( 00103 const scalar minCos, 00104 const label cellI, 00105 const labelList& cEdges, 00106 Map<label>& faceRegion 00107 ) const; 00108 00109 //- Does merging faces invalidate (unmerged) neighbouring faces? 00110 bool faceNeighboursValid 00111 ( 00112 const label cellI, 00113 const Map<label>& faceRegion 00114 ) const; 00115 00116 00117 00118 //- Disallow default bitwise copy construct 00119 combineFaces(const combineFaces&); 00120 00121 //- Disallow default bitwise assignment 00122 void operator=(const combineFaces&); 00123 00124 public: 00125 00126 //- Runtime type information 00127 ClassName("combineFaces"); 00128 00129 00130 // Constructors 00131 00132 //- Construct from mesh 00133 combineFaces(const polyMesh& mesh, const bool undoable = false); 00134 00135 00136 // Member Functions 00137 00138 // Access 00139 00140 //- If undoable: masterface for every set. 00141 const labelList& masterFace() const 00142 { 00143 return masterFace_; 00144 } 00145 00146 //- If undoable: set of original point labels of stored points 00147 const labelList& savedPointLabels() const 00148 { 00149 return savedPointLabels_; 00150 } 00151 00152 00153 // Helper functions 00154 00155 //- Extract lists of all (non-coupled) boundary faces on selected 00156 // cells that can be merged. Uses getFaceRegions. 00157 labelListList getMergeSets 00158 ( 00159 const scalar featureCos, 00160 const scalar minConcaveCos, 00161 const labelHashSet& boundaryCells 00162 ) const; 00163 00164 //- Extract lists of all (non-coupled) boundary faces that can 00165 // be merged. Uses getFaceRegions. 00166 labelListList getMergeSets 00167 ( 00168 const scalar featureCos, 00169 const scalar minConcaveCos 00170 ) const; 00171 00172 //- Gets outside of patch as a face (in mesh point labels) 00173 static face getOutsideFace(const indirectPrimitivePatch&); 00174 00175 00176 // Topology changes 00177 00178 //- Play commands into polyTopoChange to combine faces. Gets 00179 // labelListList of sets of faces to combine. Does no check 00180 // for whether resulting face is legal. 00181 void setRefinement 00182 ( 00183 const labelListList&, 00184 polyTopoChange& 00185 ); 00186 00187 //- Force recalculation of locally stored data on topological change 00188 void updateMesh(const mapPolyMesh&); 00189 00190 //- Play commands into polyTopoChange to reinsert original faces. 00191 // No other topo changes can be done inbetween setRefinement and 00192 // setUnrefinement. Can be called multiple times to undo parts 00193 // of the last setRefinement call. 00194 // Gets the master face labels whose sets need to be restored. 00195 // Returns maps from added restored point to 00196 // original point label (i.e. content of savedPointLabels_). 00197 // (only restoredPoints are actually set; rest are just for 00198 // generalness) 00199 void setUnrefinement 00200 ( 00201 const labelList& masterFaces, 00202 polyTopoChange& meshMod, 00203 Map<label>& restoredPoints, 00204 Map<label>& restoredFaces, 00205 Map<label>& restoredCells 00206 ); 00207 }; 00208 00209 00210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00211 00212 } // End namespace Foam 00213 00214 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00215 00216 #endif 00217 00218 // ************************ vim: set sw=4 sts=4 et: ************************ //