geomCellLooper.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::geomCellLooper
28 
29 Description
30  Implementation of cellLooper. Does pure geometric cut through cell.
31 
32  Handles all cell shapes in the same way: cut edges with plane through
33  cell centre and normal in direction of provided direction. Snaps cuts
34  close to edge endpoints (close = snapTol * minEdgeLen) to vertices.
35 
36  Currently determines cuts through edges (and edge endpoints close to plane)
37  in random order and then sorts them acc. to angle. Could be converted to
38  use walk but problem is that face can be cut multiple times (since does
39  not need to be convex). Another problem is that edges parallel to plane
40  might not be cut. So these are handled by looking at the distance from
41  edge endpoints to the plane.
42 
43 SourceFiles
44  geomCellLooper.C
45 
46 \*---------------------------------------------------------------------------*/
47 
48 #ifndef geomCellLooper_H
49 #define geomCellLooper_H
50 
51 #include "cellLooper.H"
52 #include "typeInfo.H"
53 
54 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 
56 namespace Foam
57 {
58 
59 // Forward declaration of classes
60 class plane;
61 
62 /*---------------------------------------------------------------------------*\
63  Class geomCellLooper Declaration
64 \*---------------------------------------------------------------------------*/
65 
66 class geomCellLooper
67 :
68  public cellLooper
69 {
70 
71  // Static
72 
73  //- Tolerance for point equal test. Fraction of edge length.
74  static const scalar pointEqualTol_;
75 
76  //- Tolerance for cut through edges to get snapped to edge end point.
77  // Fraction of length of minimum connected edge length.
78  static scalar snapTol_;
79 
80 
81  // Private Member Functions
82 
83  //- Min length of attached edges
84  scalar minEdgeLen(const label vertI) const;
85 
86  //- Return true and set weight if edge is cut
87  bool cutEdge
88  (
89  const plane& cutPlane,
90  const label edgeI,
91  scalar& weight
92  ) const;
93 
94  //- Snaps cut through edge by cut through vertex (if weight closer than
95  // tol to 0 or 1). Returns vertex label snapped to or -1.
96  label snapToVert
97  (
98  const scalar tol,
99  const label edgeI,
100  const scalar weight
101  ) const;
102 
103  //- Gets two (random) vectors perpendicular to n and each other to be
104  // used as base.
105  void getBase
106  (
107  const vector& n,
108  vector& e0,
109  vector& e1
110  ) const;
111 
112  //- Return true if the cut edge at loop[index] is inbetween the cuts
113  // through the edge end points.
114  bool edgeEndsCut(const labelList&, const label index) const;
115 
116 
117  //- No copy construct
118  geomCellLooper(const geomCellLooper&) = delete;
119 
120  //- No copy assignment
121  void operator=(const geomCellLooper&) = delete;
122 
123 
124 public:
125 
126  //- Runtime type information
127  TypeName("geomCellLooper");
128 
129 
130  // Static Functions
131 
132  static scalar snapTol()
133  {
134  return snapTol_;
135  }
136 
137  static void setSnapTol(const scalar tol)
138  {
139  snapTol_ = tol;
140  }
141 
142 
143 
144 
145  // Constructors
146 
147  //- Construct from components
148  geomCellLooper(const polyMesh& mesh);
149 
150 
151  //- Destructor
152  virtual ~geomCellLooper();
153 
154 
155  // Member Functions
156 
157 
158 
159  //- Create cut along circumference of celli. Gets current mesh cuts.
160  // Cut along circumference is expressed as loop of cuts plus weights
161  // for cuts along edges (only valid for edge cuts).
162  // Return true if successful cut.
163  virtual bool cut
164  (
165  const vector& refDir,
166  const label celli,
167  const boolList& vertIsCut,
168  const boolList& edgeIsCut,
169  const scalarField& edgeWeight,
170 
171  labelList& loop,
172  scalarField& loopWeights
173  ) const;
174 
175  //- Same but now also base point of cut provided (instead of always
176  // cell centre)
177  virtual bool cut
178  (
179  const plane& cutPlane,
180  const label celli,
181  const boolList& vertIsCut,
182  const boolList& edgeIsCut,
183  const scalarField& edgeWeight,
184 
185  labelList& loop,
186  scalarField& loopWeights
187  ) const;
188 };
189 
190 
191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192 
193 } // End namespace Foam
194 
195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 
197 #endif
198 
199 // ************************************************************************* //
typeInfo.H
Foam::geomCellLooper::cut
virtual bool cut(const vector &refDir, const label celli, const boolList &vertIsCut, const boolList &edgeIsCut, const scalarField &edgeWeight, labelList &loop, scalarField &loopWeights) const
Create cut along circumference of celli. Gets current mesh cuts.
Definition: geomCellLooper.C:228
cellLooper.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::plane
Geometric class that creates a 3D plane and can return the intersection point between a line and the ...
Definition: plane.H:89
Foam::geomCellLooper::snapTol
static scalar snapTol()
Definition: geomCellLooper.H:131
n
label n
Definition: TABSMDCalcMethod2.H:31
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:62
Foam::Field< scalar >
Foam::cellLooper
Abstract base class. Concrete implementations know how to cut a cell (i.e. determine a loop around th...
Definition: cellLooper.H:71
Foam::geomCellLooper
Implementation of cellLooper. Does pure geometric cut through cell.
Definition: geomCellLooper.H:65
Foam::geomCellLooper::TypeName
TypeName("geomCellLooper")
Runtime type information.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::geomCellLooper::setSnapTol
static void setSnapTol(const scalar tol)
Definition: geomCellLooper.H:136
Foam::geomCellLooper::~geomCellLooper
virtual ~geomCellLooper()
Destructor.
Definition: geomCellLooper.C:221
Foam::Vector< scalar >
Foam::List< label >
Foam::edgeVertex::mesh
const polyMesh & mesh() const
Definition: edgeVertex.H:100