tetOverlapVolume.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) 2012-2014 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::tetOverlapVolume
28 
29 Description
30  Calculates the overlap volume of two cells using tetrahedral decomposition
31 
32 SourceFiles
33  tetOverlapVolume.C
34  tetOverlapVolumeTemplates.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef Foam_tetOverlapVolume_H
39 #define Foam_tetOverlapVolume_H
40 
41 #include "FixedList.H"
42 #include "labelList.H"
43 #include "treeBoundBox.H"
44 #include "Tuple2.H"
45 #include "tetrahedron.H"
46 
47 namespace Foam
48 {
49 
50 // Forward Declarations
51 class primitiveMesh;
52 class polyMesh;
53 
54 /*---------------------------------------------------------------------------*\
55  Class tetOverlapVolume Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 class tetOverlapVolume
59 {
60  // Private Classes
61 
62  //- tetPoints handling : sum resulting volumes
63  class sumMomentOp
64  {
65  public:
67 
68  inline sumMomentOp()
69  :
70  vol_(0.0, Zero)
71  {}
72 
73  inline void operator()(const tetPoints& tet)
74  {
75  const tetPointRef t(tet.tet());
76  scalar tetVol = t.mag();
77  vol_.first() += tetVol;
78  vol_.second() += (tetVol*t.centre());
79  }
80  };
81 
82  //- tetPoints combining : check for overlap
83  class hasOverlapOp
84  {
85  public:
86 
87  const scalar threshold_;
89  bool ok_;
90 
91  inline hasOverlapOp(const scalar threshold)
92  :
93  threshold_(threshold),
94  iop_(),
95  ok_(false)
96  {}
97 
98  //- Overlap two tets
99  inline bool operator()(const tetPoints& A, const tetPoints& B)
100  {
101  tetTetOverlap<tetPointRef::sumVolOp>(A, B, iop_);
102  ok_ = (iop_.vol_ > threshold_);
103  return ok_;
104  }
105  };
106 
107  //- tetPoints combining : sum overlap volume
108  class sumOverlapOp
109  {
110  public:
111 
113 
114  inline sumOverlapOp()
115  :
116  iop_()
117  {}
118 
119  //- Overlap two tets
120  inline bool operator()(const tetPoints& A, const tetPoints& B)
121  {
122  tetTetOverlap<tetPointRef::sumVolOp>(A, B, iop_);
123  return false;
124  }
125  };
126 
127  //- tetPoints combining : sum overlap volume
128  class sumOverlapMomentOp
129  {
130  public:
131 
132  sumMomentOp iop_;
133 
134  inline sumOverlapMomentOp()
135  :
136  iop_()
137  {}
138 
139  //- Overlap two tets
140  inline bool operator()(const tetPoints& A, const tetPoints& B)
141  {
142  tetTetOverlap<sumMomentOp>(A, B, iop_);
143  return false;
144  }
145  };
146 
147 
148  // Private member functions
149 
150  //- Tet overlap calculation
151  template<class tetPointsOp>
152  static void tetTetOverlap
153  (
154  const tetPoints& tetA,
155  const tetPoints& tetB,
156  tetPointsOp& insideOp
157  );
158 
159  //- Cell overlap calculation
160  template<class tetsOp>
161  static void cellCellOverlapMinDecomp
162  (
163  const primitiveMesh& meshA,
164  const label cellAI,
165  const primitiveMesh& meshB,
166  const label cellBI,
167  const treeBoundBox& cellBbB,
168  tetsOp& combineTetsOp
169  );
170 
171  //- Return a const treeBoundBox
172  static treeBoundBox pyrBb
173  (
174  const pointField& points,
175  const face& f,
176  const point& fc
177  );
178 
179 
180 public:
181 
182  //- Runtime type information
183  ClassName("tetOverlapVolume");
184 
185 
186  // Constructors
187 
188  //- Default construct
189  tetOverlapVolume() = default;
190 
191 
192  // Public members
193 
194  //- Return a list of cells in meshA which overlaps with cellBI in
195  //- meshB
197  (
198  const polyMesh& meshA,
199  const polyMesh& meshB,
200  const label cellBI
201  ) const;
202 
203  //- Return true if overlap volume is greater than threshold
204  bool cellCellOverlapMinDecomp
205  (
206  const primitiveMesh& meshA,
207  const label cellAI,
208  const primitiveMesh& meshB,
209  const label cellBI,
210  const treeBoundBox& cellBbB,
211  const scalar threshold = 0.0
212  ) const;
213 
214  //- Calculates the overlap volume
216  (
217  const primitiveMesh& meshA,
218  const label cellAI,
219 
220  const primitiveMesh& meshB,
221  const label cellBI,
222  const treeBoundBox& cellBbB
223  ) const;
224 
225  //- Calculates the overlap volume and moment
227  (
228  const primitiveMesh& meshA,
229  const label cellAI,
230 
231  const primitiveMesh& meshB,
232  const label cellBI,
233  const treeBoundBox& cellBbB
234  ) const;
235 };
236 
237 
238 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
239 
240 } // End namespace Foam
241 
242 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
243 
244 #ifdef NoRepository
245 # include "tetOverlapVolumeTemplates.C"
246 #endif
247 
248 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
249 
250 #endif
251 
252 // ************************************************************************* //
A tetrahedron primitive.
Definition: tetrahedron.H:58
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:68
tetPointRef tet() const
Return as tetrahedron reference.
Definition: tetrahedronI.H:120
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:75
const pointField & points
Calculates the overlap volume of two cells using tetrahedral decomposition.
Sum resulting volumes.
Definition: tetrahedron.H:242
scalar mag() const
Return volume.
Definition: tetrahedronI.H:252
ClassName("tetOverlapVolume")
Runtime type information.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
labelList f(nPoints)
tetOverlapVolume()=default
Default construct.
Tet point storage. Default constructable (tetrahedron is not)
Definition: tetrahedron.H:82
const T2 & second() const noexcept
Access the second element.
Definition: Tuple2.H:142
Standard boundBox with extra functionality for use in octree.
Definition: treeBoundBox.H:90
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
const T1 & first() const noexcept
Access the first element.
Definition: Tuple2.H:132
static const Foam::dimensionedScalar A("", Foam::dimPressure, 611.21)
labelList overlappingCells(const polyMesh &meshA, const polyMesh &meshB, const label cellBI) const
Return a list of cells in meshA which overlaps with cellBI in meshB.
static const Foam::dimensionedScalar B("", Foam::dimless, 18.678)
scalar cellCellOverlapVolumeMinDecomp(const primitiveMesh &meshA, const label cellAI, const primitiveMesh &meshB, const label cellBI, const treeBoundBox &cellBbB) const
Calculates the overlap volume.
Namespace for OpenFOAM.
Tuple2< scalar, point > cellCellOverlapMomentMinDecomp(const primitiveMesh &meshA, const label cellAI, const primitiveMesh &meshB, const label cellBI, const treeBoundBox &cellBbB) const
Calculates the overlap volume and moment.
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127