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::edgeCollapser 00026 00027 Description 00028 Does polyTopoChanges to remove edges. Can remove faces due to edge 00029 collapse but can not remove cells due to face removal! 00030 Also removes unused points. 00031 00032 SourceFiles 00033 edgeCollapser.C 00034 00035 \*---------------------------------------------------------------------------*/ 00036 00037 #ifndef edgeCollapser_H 00038 #define edgeCollapser_H 00039 00040 #include <OpenFOAM/labelList.H> 00041 #include <OpenFOAM/DynamicList.H> 00042 #include <OpenFOAM/typeInfo.H> 00043 00044 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00045 00046 namespace Foam 00047 { 00048 00049 // Forward declaration of classes 00050 class polyMesh; 00051 class polyTopoChange; 00052 class face; 00053 class mapPolyMesh; 00054 00055 /*---------------------------------------------------------------------------*\ 00056 Class edgeCollapser Declaration 00057 \*---------------------------------------------------------------------------*/ 00058 00059 class edgeCollapser 00060 { 00061 // Private data 00062 00063 //- Reference to mesh 00064 const polyMesh& mesh_; 00065 00066 //- For every point -1 or region number 00067 labelList pointRegion_; 00068 00069 //- -1 or master vertex for region number 00070 DynamicList<label> pointRegionMaster_; 00071 00072 //- Stack of free region numbers. Corresponds to -1 in pointRegionMaster 00073 SLList<label> freeRegions_; 00074 00075 00076 // Static Functions 00077 00078 //- Find val in list. Search starts at start, continues to size-1. 00079 static label findIndex 00080 ( 00081 const labelList&, 00082 const label start, 00083 const label size, 00084 const label val 00085 ); 00086 00087 00088 // Private Member Functions 00089 00090 //- Determine points connected through edgesToRemove_. 00091 // Note: Only routine that uses edgesToRemove! 00092 label changePointRegion 00093 ( 00094 const label pointI, 00095 const label oldRegion, 00096 const label newRegion 00097 ); 00098 00099 //- Whether point is master of region or has been removed 00100 bool pointRemoved(const label) const; 00101 00102 //- Renumber f with new vertices. Removes duplicates. 00103 void filterFace(const label faceI, face&) const; 00104 00105 //- Some debugging printing 00106 void printRegions() const; 00107 00108 //- Collapse list of edges. Tries to find master to collapse to. 00109 void collapseEdges(const labelList& edgeLabels); 00110 00111 //- Disallow default bitwise copy construct 00112 edgeCollapser(const edgeCollapser&); 00113 00114 //- Disallow default bitwise assignment 00115 void operator=(const edgeCollapser&); 00116 00117 00118 public: 00119 00120 //- Runtime type information 00121 ClassName("edgeCollapser"); 00122 00123 00124 // Constructors 00125 00126 //- Construct from mesh. 00127 edgeCollapser(const polyMesh& mesh); 00128 00129 00130 // Member Functions 00131 00132 // Access 00133 00134 //- For every point the region it belongs to or -1. 00135 const labelList& pointRegion() const 00136 { 00137 return pointRegion_; 00138 } 00139 00140 //- For every region the master (i.e. the point the region will 00141 // be replaced by) 00142 const DynamicList<label>& pointRegionMaster() const 00143 { 00144 return pointRegionMaster_; 00145 } 00146 00147 //- Check that edge is not marked for anything 00148 bool unaffectedEdge(const label edgeI) const; 00149 00150 00151 // Edit 00152 00153 //- Set edge to collapse and point to collapse it to. 00154 // Return true if collapse is valid. 00155 // (always true at the moment) 00156 bool collapseEdge(const label edgeI, const label master); 00157 00158 //- Play commands into polyTopoChange to create mesh. Return true 00159 // if anything changed. 00160 bool setRefinement(polyTopoChange&); 00161 00162 void updateMesh(const mapPolyMesh&); 00163 }; 00164 00165 00166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00167 00168 } // End namespace Foam 00169 00170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00171 00172 #endif 00173 00174 // ************************ vim: set sw=4 sts=4 et: ************************ //