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