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::geomCellLooper 00026 00027 Description 00028 Implementation of cellLooper. Does pure geometric cut through cell. 00029 00030 Handles all cell shapes in the same way: cut edges with plane through 00031 cell centre and normal in direction of provided direction. Snaps cuts 00032 close to edge endpoints (close = snapTol * minEdgeLen) to vertices. 00033 00034 Currently determines cuts through edges (and edgeendpoints close to plane) 00035 in random order and then sorts them acc. to angle. Could be converted to 00036 use walk but problem is that face can be cut multiple times (since does 00037 not need to be convex). Another problem is that edges parallel to plane 00038 might not be cut. So these are handled by looking at the distance from 00039 edge endpoints to the plane. 00040 00041 SourceFiles 00042 geomCellLooper.C 00043 00044 \*---------------------------------------------------------------------------*/ 00045 00046 #ifndef geomCellLooper_H 00047 #define geomCellLooper_H 00048 00049 #include "cellLooper.H" 00050 #include <OpenFOAM/typeInfo.H> 00051 00052 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00053 00054 namespace Foam 00055 { 00056 00057 // Forward declaration of classes 00058 class plane; 00059 00060 /*---------------------------------------------------------------------------*\ 00061 Class geomCellLooper Declaration 00062 \*---------------------------------------------------------------------------*/ 00063 00064 class geomCellLooper 00065 : 00066 public cellLooper 00067 { 00068 00069 // Static 00070 00071 //- Tolerance for point equal test. Fraction of edge length. 00072 static const scalar pointEqualTol_; 00073 00074 //- Tolerance for cut through edges to get snapped to edge end point. 00075 // Fraction of length of minimum connected edge length. 00076 static scalar snapTol_; 00077 00078 00079 // Private Member Functions 00080 00081 //- Min length of attached edges 00082 scalar minEdgeLen(const label vertI) const; 00083 00084 //- Return true and set weight if edge is cut 00085 bool cutEdge 00086 ( 00087 const plane& cutPlane, 00088 const label edgeI, 00089 scalar& weight 00090 ) const; 00091 00092 //- Snaps cut through edge by cut through vertex (if weight closer than 00093 // tol to 0 or 1). Returns vertex label snapped to or -1. 00094 label snapToVert 00095 ( 00096 const scalar tol, 00097 const label edgeI, 00098 const scalar weight 00099 ) const; 00100 00101 //- Gets two (random) vectors perpendicular to n and each other to be 00102 // used as base. 00103 void getBase 00104 ( 00105 const vector& n, 00106 vector& e0, 00107 vector& e1 00108 ) const; 00109 00110 //- Return true if the cut edge at loop[index] is inbetween the cuts 00111 // through the edge end points. 00112 bool edgeEndsCut(const labelList&, const label index) const; 00113 00114 00115 //- Disallow default bitwise copy construct 00116 geomCellLooper(const geomCellLooper&); 00117 00118 //- Disallow default bitwise assignment 00119 void operator=(const geomCellLooper&); 00120 00121 00122 public: 00123 00124 //- Runtime type information 00125 TypeName("geomCellLooper"); 00126 00127 00128 // Static Functions 00129 00130 static scalar snapTol() 00131 { 00132 return snapTol_; 00133 } 00134 00135 static void setSnapTol(const scalar tol) 00136 { 00137 snapTol_ = tol; 00138 } 00139 00140 00141 00142 00143 // Constructors 00144 00145 //- Construct from components 00146 geomCellLooper(const polyMesh& mesh); 00147 00148 00149 // Destructor 00150 00151 virtual ~geomCellLooper(); 00152 00153 00154 // Member Functions 00155 00156 00157 00158 //- Create cut along circumference of cellI. Gets current mesh cuts. 00159 // Cut along circumference is expressed as loop of cuts plus weights 00160 // for cuts along edges (only valid for edge cuts). 00161 // Return true if successful cut. 00162 virtual bool cut 00163 ( 00164 const vector& refDir, 00165 const label cellI, 00166 const boolList& vertIsCut, 00167 const boolList& edgeIsCut, 00168 const scalarField& edgeWeight, 00169 00170 labelList& loop, 00171 scalarField& loopWeights 00172 ) const; 00173 00174 //- Same but now also base point of cut provided (instead of always 00175 // cell centre) 00176 virtual bool cut 00177 ( 00178 const plane& cutPlane, 00179 const label cellI, 00180 const boolList& vertIsCut, 00181 const boolList& edgeIsCut, 00182 const scalarField& edgeWeight, 00183 00184 labelList& loop, 00185 scalarField& loopWeights 00186 ) const; 00187 }; 00188 00189 00190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00191 00192 } // End namespace Foam 00193 00194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00195 00196 #endif 00197 00198 // ************************ vim: set sw=4 sts=4 et: ************************ //