tetOverlapVolume.C
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-2015 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 "tetOverlapVolume.H"
27 #include "tetrahedron.H"
28 #include "tetPoints.H"
29 #include "polyMesh.H"
30 #include "OFstream.H"
31 #include "treeBoundBox.H"
32 #include "indexedOctree.H"
33 #include "treeDataCell.H"
34 
35 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 
37 namespace Foam
38 {
39  defineTypeNameAndDebug(tetOverlapVolume, 0);
40 }
41 
42 // When to consider a tet to be zero volume. We want to avoid doing clipping
43 // against negative volume tets. Tet volume can be calculated incorrectly
44 // due to truncation errors. The value below works for single and double
45 // precision but could probably be tighter for double precision.
46 Foam::scalar Foam::tetOverlapVolume::minTetVolume_ = SMALL*SMALL;
47 
48 
49 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50 
52 {}
53 
54 
55 // * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * * //
56 
58 (
59  const pointField& points,
60  const face& f,
61  const point& fc
62 )
63 {
64  treeBoundBox bb(fc, fc);
65  forAll(f, fp)
66  {
67  const point& pt = points[f[fp]];
68  bb.min() = min(bb.min(), pt);
69  bb.max() = max(bb.max(), pt);
70  }
71  return bb;
72 }
73 
74 
75 // * * * * * * * * * * * Public Member Functions * * * * * * * * * * * * * //
76 
78 (
79  const primitiveMesh& meshA,
80  const label cellAI,
81  const primitiveMesh& meshB,
82  const label cellBI,
83  const treeBoundBox& cellBbB,
84  const scalar threshold
85 ) const
86 {
87  hasOverlapOp overlapCheckOp(threshold);
88  cellCellOverlapMinDecomp<hasOverlapOp>
89  (
90  meshA,
91  cellAI,
92  meshB,
93  cellBI,
94  cellBbB,
95  overlapCheckOp
96  );
97 
98  return overlapCheckOp.ok_;
99 }
100 
101 
103 (
104  const primitiveMesh& meshA,
105  const label cellAI,
106 
107  const primitiveMesh& meshB,
108  const label cellBI,
109  const treeBoundBox& cellBbB
110 ) const
111 {
112  sumOverlapOp overlapSumOp;
113  cellCellOverlapMinDecomp<sumOverlapOp>
114  (
115  meshA,
116  cellAI,
117  meshB,
118  cellBI,
119  cellBbB,
120  overlapSumOp
121  );
122 
123  return overlapSumOp.iop_.vol_;
124 }
125 
126 
129 (
130  const primitiveMesh& meshA,
131  const label cellAI,
132 
133  const primitiveMesh& meshB,
134  const label cellBI,
135  const treeBoundBox& cellBbB
136 ) const
137 {
138  sumOverlapMomentOp overlapSumOp;
139  cellCellOverlapMinDecomp<sumOverlapMomentOp>
140  (
141  meshA,
142  cellAI,
143  meshB,
144  cellBI,
145  cellBbB,
146  overlapSumOp
147  );
148 
149  return overlapSumOp.iop_.vol_;
150 }
151 
152 
154 (
155  const polyMesh& fromMesh,
156  const polyMesh& toMesh,
157  const label iTo
158 ) const
159 {
160  const indexedOctree<treeDataCell>& treeA = fromMesh.cellTree();
161 
162  treeBoundBox bbB(toMesh.points(), toMesh.cellPoints()[iTo]);
163 
164  return treeA.findBox(bbB);
165 }
166 
167 
168 // ************************************************************************* //
Foam::polyMesh::points
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:979
Foam::tetOverlapVolume::pyrBb
static treeBoundBox pyrBb(const pointField &points, const face &f, const point &fc)
Return a const treeBoundBox.
Definition: tetOverlapVolume.C:58
Foam::boundBox::max
const point & max() const
Maximum describing the bounding box.
Definition: boundBoxI.H:60
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::primitiveMesh::cellPoints
const labelListList & cellPoints() const
Definition: primitiveMeshCellPoints.C:31
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::treeBoundBox
Standard boundBox + extra functionality for use in octree.
Definition: treeBoundBox.H:75
indexedOctree.H
polyMesh.H
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
OFstream.H
Foam::indexedOctree::findBox
void findBox(const label nodeI, const treeBoundBox &searchBox, labelHashSet &elements) const
Find all elements intersecting box.
Definition: indexedOctree.C:1994
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::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
treeBoundBox.H
Foam::indexedOctree
Non-pointer based hierarchical recursive searching.
Definition: treeDataTriSurface.H:47
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::boundBox::min
const point & min() const
Minimum describing the bounding box.
Definition: boundBoxI.H:54
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
Namespace for OpenFOAM.
Definition: combustionModel.C:30
treeDataCell.H
Foam::tetOverlapVolume::tetOverlapVolume
tetOverlapVolume()
Null constructor.
Definition: tetOverlapVolume.C:51
tetOverlapVolume.H
Foam::max
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
Foam::polyMesh::cellTree
const indexedOctree< treeDataCell > & cellTree() const
Return the cell search tree.
Definition: polyMesh.C:843
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
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
Foam::Tuple2
A 2-tuple for storing two objects of different types.
Definition: Tuple2.H:47
Foam::tetOverlapVolume::sumOverlapMomentOp::iop_
sumMomentOp iop_
Definition: tetOverlapVolume.H:134
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::min
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
tetPoints.H
tetrahedron.H
Foam::primitiveMesh
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:79