Loading...
Searching...
No Matches
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 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
47namespace Foam
48{
49
50// Forward Declarations
51class primitiveMesh;
52class polyMesh;
54/*---------------------------------------------------------------------------*\
55 Class tetOverlapVolume Declaration
56\*---------------------------------------------------------------------------*/
57
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_;
88 tetPointRef::sumVolOp iop_;
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
112 tetPointRef::sumVolOp iop_;
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
180public:
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
246#endif
247
248// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
249
250#endif
251
252// ************************************************************************* //
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:51
const T1 & first() const noexcept
Access the first element.
Definition Tuple2.H:132
const T2 & second() const noexcept
Access the second element.
Definition Tuple2.H:142
A face is a list of labels corresponding to mesh vertices.
Definition face.H:71
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
Cell-face mesh analysis engine.
scalar cellCellOverlapVolumeMinDecomp(const primitiveMesh &meshA, const label cellAI, const primitiveMesh &meshB, const label cellBI, const treeBoundBox &cellBbB) const
Calculates the overlap volume.
tetOverlapVolume()=default
Default construct.
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 meshB.
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 point storage. Default constructable (tetrahedron is not).
Definition tetrahedron.H:85
tetPointRef tet() const
Return as tetrahedron reference.
Point centre() const
Return centre (centroid).
scalar mag() const
Return volume.
Standard boundBox with extra functionality for use in octree.
#define ClassName(TypeNameString)
Add typeName information from argument TypeNameString to a class.
Definition className.H:74
const pointField & points
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition List.H:62
tetrahedron< point, const point & > tetPointRef
A tetrahedron using referred points.
Definition tetrahedron.H:72
vector point
Point is a vector.
Definition point.H:37
static constexpr const zero Zero
Global zero (0).
Definition zero.H:127
vectorField pointField
pointField is a vectorField.
labelList f(nPoints)