Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / src / dynamicMesh / meshCut / cellLooper / geomCellLooper.H
blob1dd27a252b84e61b1dbb8d4d5dc0ed8eda0677ef
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2004-2010 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software: you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by
13     the Free Software Foundation, either version 3 of the License, or
14     (at your option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
24 Class
25     Foam::geomCellLooper
27 Description
28     Implementation of cellLooper. Does pure geometric cut through cell.
30     Handles all cell shapes in the same way: cut edges with plane through
31     cell centre and normal in direction of provided direction. Snaps cuts
32     close to edge endpoints (close = snapTol * minEdgeLen) to vertices.
34     Currently determines cuts through edges (and edgeendpoints close to plane)
35     in random order and then sorts them acc. to angle. Could be converted to
36     use walk but problem is that face can be cut multiple times (since does
37     not need to be convex). Another problem is that edges parallel to plane
38     might not be cut. So these are handled by looking at the distance from
39     edge endpoints to the plane.
41 SourceFiles
42     geomCellLooper.C
44 \*---------------------------------------------------------------------------*/
46 #ifndef geomCellLooper_H
47 #define geomCellLooper_H
49 #include "cellLooper.H"
50 #include "typeInfo.H"
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 namespace Foam
57 // Forward declaration of classes
58 class plane;
60 /*---------------------------------------------------------------------------*\
61                            Class geomCellLooper Declaration
62 \*---------------------------------------------------------------------------*/
64 class geomCellLooper
66     public cellLooper
69     // Static
71         //- Tolerance for point equal test. Fraction of edge length.
72         static const scalar pointEqualTol_;
74         //- Tolerance for cut through edges to get snapped to edge end point.
75         //  Fraction of length of minimum connected edge length.
76         static scalar snapTol_;
79     // Private Member Functions
81         //- Min length of attached edges
82         scalar minEdgeLen(const label vertI) const;
84         //- Return true and set weight if edge is cut
85         bool cutEdge
86         (
87             const plane& cutPlane,
88             const label edgeI,
89             scalar& weight
90         ) const;
92         //- Snaps cut through edge by cut through vertex (if weight closer than
93         //  tol to 0 or 1). Returns vertex label snapped to or -1.
94         label snapToVert
95         (
96             const scalar tol,
97             const label edgeI,
98             const scalar weight
99         ) const;
101         //- Gets two (random) vectors perpendicular to n and each other to be
102         //  used as base.
103         void getBase
104         (
105             const vector& n,
106             vector& e0,
107             vector& e1
108         ) const;
110         //- Return true if the cut edge at loop[index] is inbetween the cuts
111         //  through the edge end points.
112         bool edgeEndsCut(const labelList&, const label index) const;
115         //- Disallow default bitwise copy construct
116         geomCellLooper(const geomCellLooper&);
118         //- Disallow default bitwise assignment
119         void operator=(const geomCellLooper&);
122 public:
124     //- Runtime type information
125     TypeName("geomCellLooper");
128     // Static Functions
130         static scalar snapTol()
131         {
132             return snapTol_;
133         }
135         static void setSnapTol(const scalar tol)
136         {
137             snapTol_ = tol;
138         }
143     // Constructors
145         //- Construct from components
146         geomCellLooper(const polyMesh& mesh);
149     //- Destructor
150     virtual ~geomCellLooper();
153     // Member Functions
157         //- Create cut along circumference of cellI. Gets current mesh cuts.
158         //  Cut along circumference is expressed as loop of cuts plus weights
159         //  for cuts along edges (only valid for edge cuts).
160         //  Return true if successful cut.
161         virtual bool cut
162         (
163             const vector& refDir,
164             const label cellI,
165             const boolList& vertIsCut,
166             const boolList& edgeIsCut,
167             const scalarField& edgeWeight,
169             labelList& loop,
170             scalarField& loopWeights
171         ) const;
173         //- Same but now also base point of cut provided (instead of always
174         //  cell centre)
175         virtual bool cut
176         (
177             const plane& cutPlane,
178             const label cellI,
179             const boolList& vertIsCut,
180             const boolList& edgeIsCut,
181             const scalarField& edgeWeight,
183             labelList& loop,
184             scalarField& loopWeights
185         ) const;
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
191 } // End namespace Foam
193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
195 #endif
197 // ************************************************************************* //