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