OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

geomCellLooper.H

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