indexedCellChecks.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2012-2018 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "plane.H"
27 #include "tetPointRef.H"
28 #include "pointConversion.H"
30 
31 
32 template<class Cell>
34 (
35  Cell& c,
36  const scalar tol
37 )
38 {
39  tetPointRef tet
40  (
41  topoint(c->vertex(0)->point()),
42  topoint(c->vertex(1)->point()),
43  topoint(c->vertex(2)->point()),
44  topoint(c->vertex(3)->point())
45  );
46 
47  const scalar quality = tet.quality();
48 
49  if (quality < tol)
50  {
51  return quality;
52  }
53 
54  return 0;
55 
56 // plane triPlane
57 // (
58 // topoint(c->vertex(0)->point()),
59 // topoint(c->vertex(1)->point()),
60 // topoint(c->vertex(2)->point())
61 // );
62 //
63 // const scalar distance = triPlane.distance(topoint(c->vertex(3)->point()));
64 //
65 // // Check if the four points are roughly coplanar. If they are then we
66 // // cannot calculate the circumcentre. Better test might be the volume
67 // // of the tet.
68 // if (distance < tol)
69 // {
70 // return 0;
71 // }
72 //
73 // return distance;
74 }
75 
76 
77 template<class Cell>
79 (
80  Cell& c,
81  const scalar tol
82 )
83 {
84  for (label v = 0; v < 4; ++v)
85  {
86  for (label vA = v + 1; vA < 4; ++vA)
87  {
88  if
89  (
90  mag
91  (
92  topoint(c->vertex(v)->point())
93  - topoint(c->vertex(vA)->point())
94  )
95  < tol
96  )
97  {
98  return true;
99  }
100  }
101  }
102 
103  return false;
104 }
105 
106 
107 template<class Cell>
109 (
110  Cell& c,
111  const scalar tol
112 )
113 {
114  CGAL::Tetrahedron_3<baseK> tet
115  (
116  c->vertex(0)->point(),
117  c->vertex(1)->point(),
118  c->vertex(2)->point(),
119  c->vertex(3)->point()
120  );
121 
122  if (tet.volume() < tol)
123  {
124  return true;
125  }
126 
127  return false;
128 }
bool smallVolume(Cell &c, const scalar tol=0.0)
tetrahedron< point, const point & > tetPointRef
Definition: tetPointRef.H:44
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:59
bool closePoints(Cell &c, const scalar tol=1e-12)
pointFromPoint topoint(const Point &P)
dimensioned< scalar > mag(const dimensioned< Type > &)
scalar coplanarTet(Cell &c, const scalar tol=1e-12)