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::cuttingPlane 00026 00027 Description 00028 Constructs plane through mesh. 00029 00030 No attempt at resolving degenerate cases. Since the cut faces are 00031 usually quite ugly, they will always be triangulated. 00032 00033 Note 00034 When the cutting plane coincides with a mesh face, the cell edge on the 00035 positive side of the plane is taken. 00036 00037 SourceFiles 00038 cuttingPlane.C 00039 00040 \*---------------------------------------------------------------------------*/ 00041 00042 #ifndef cuttingPlane_H 00043 #define cuttingPlane_H 00044 00045 #include <OpenFOAM/plane.H> 00046 #include <OpenFOAM/pointField.H> 00047 #include <OpenFOAM/faceList.H> 00048 #include <surfMesh/MeshedSurface.H> 00049 00050 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00051 00052 namespace Foam 00053 { 00054 00055 class primitiveMesh; 00056 00057 /*---------------------------------------------------------------------------*\ 00058 Class cuttingPlane Declaration 00059 \*---------------------------------------------------------------------------*/ 00060 00061 class cuttingPlane 00062 : 00063 public plane, 00064 public MeshedSurface<face> 00065 { 00066 //- Private typedefs for convenience 00067 typedef MeshedSurface<face> MeshStorage; 00068 00069 // Private data 00070 00071 //- List of cells cut by the plane 00072 labelList cutCells_; 00073 00074 // Private Member Functions 00075 00076 //- Determine cut cells, possibly restricted to a list of cells 00077 void calcCutCells 00078 ( 00079 const primitiveMesh&, 00080 const scalarField& dotProducts, 00081 const UList<label>& cellIdLabels = UList<label>::null() 00082 ); 00083 00084 //- Determine intersection points (cutPoints). 00085 void intersectEdges 00086 ( 00087 const primitiveMesh&, 00088 const scalarField& dotProducts, 00089 List<label>& edgePoint 00090 ); 00091 00092 //- Walk circumference of cell, starting from startEdgeI crossing 00093 // only cut edges. Record cutPoint labels in faceVerts. 00094 static bool walkCell 00095 ( 00096 const primitiveMesh&, 00097 const UList<label>& edgePoint, 00098 const label cellI, 00099 const label startEdgeI, 00100 DynamicList<label>& faceVerts 00101 ); 00102 00103 //- Determine cuts for all cut cells. 00104 void walkCellCuts 00105 ( 00106 const primitiveMesh& mesh, 00107 const UList<label>& edgePoint 00108 ); 00109 00110 00111 protected: 00112 00113 // Constructors 00114 00115 //- Construct plane description without cutting 00116 cuttingPlane(const plane&); 00117 00118 // Protected Member Functions 00119 00120 //- recut mesh with existing planeDesc, restricted to a list of cells 00121 void reCut 00122 ( 00123 const primitiveMesh&, 00124 const UList<label>& cellIdLabels = UList<label>::null() 00125 ); 00126 00127 //- remap action on triangulation or cleanup 00128 virtual void remapFaces(const UList<label>& faceMap); 00129 00130 public: 00131 00132 // Constructors 00133 00134 //- Construct from plane and mesh reference, 00135 // possibly restricted to a list of cells 00136 cuttingPlane 00137 ( 00138 const plane&, 00139 const primitiveMesh&, 00140 const UList<label>& cellIdLabels = UList<label>::null() 00141 ); 00142 00143 00144 // Member Functions 00145 00146 //- Return plane used 00147 const plane& planeDesc() const 00148 { 00149 return static_cast<const plane&>(*this); 00150 } 00151 00152 //- Return List of cells cut by the plane 00153 const labelList& cutCells() const 00154 { 00155 return cutCells_; 00156 } 00157 00158 //- Return true or false to question: have any cells been cut? 00159 bool cut() const 00160 { 00161 return cutCells_.size(); 00162 } 00163 00164 //- Sample the cell field 00165 template<class Type> 00166 tmp<Field<Type> > sample(const Field<Type>&) const; 00167 00168 template<class Type> 00169 tmp<Field<Type> > sample(const tmp<Field<Type> >&) const; 00170 00171 00172 // Member Operators 00173 00174 void operator=(const cuttingPlane&); 00175 }; 00176 00177 00178 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00179 00180 } // End namespace Foam 00181 00182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00183 00184 #ifdef NoRepository 00185 # include "cuttingPlaneTemplates.C" 00186 #endif 00187 00188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00189 00190 #endif 00191 00192 // ************************ vim: set sw=4 sts=4 et: ************************ //