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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2012-2015 OpenFOAM Foundation
9  Copyright (C) 2016-2017 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "tetOverlapVolume.H"
30 #include "tetrahedron.H"
31 #include "polyMesh.H"
32 #include "OFstream.H"
33 #include "treeBoundBox.H"
34 #include "indexedOctree.H"
35 #include "treeDataCell.H"
36 
37 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38 
39 namespace Foam
40 {
41  defineTypeNameAndDebug(tetOverlapVolume, 0);
42 }
43 
44 
45 // * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * * //
46 
47 Foam::treeBoundBox Foam::tetOverlapVolume::pyrBb
48 (
49  const pointField& points,
50  const face& f,
51  const point& fc
52 )
53 {
54  treeBoundBox bb(fc);
55  bb.add(points, f);
56 
57  return bb;
58 }
59 
60 
61 // * * * * * * * * * * * Public Member Functions * * * * * * * * * * * * * //
62 
63 bool Foam::tetOverlapVolume::cellCellOverlapMinDecomp
64 (
65  const primitiveMesh& meshA,
66  const label cellAI,
67  const primitiveMesh& meshB,
68  const label cellBI,
69  const treeBoundBox& cellBbB,
70  const scalar threshold
71 ) const
72 {
73  hasOverlapOp overlapCheckOp(threshold);
74  cellCellOverlapMinDecomp<hasOverlapOp>
75  (
76  meshA,
77  cellAI,
78  meshB,
79  cellBI,
80  cellBbB,
81  overlapCheckOp
82  );
83 
84  return overlapCheckOp.ok_;
85 }
86 
87 
89 (
90  const primitiveMesh& meshA,
91  const label cellAI,
92 
93  const primitiveMesh& meshB,
94  const label cellBI,
95  const treeBoundBox& cellBbB
96 ) const
97 {
98  sumOverlapOp overlapSumOp;
99  cellCellOverlapMinDecomp<sumOverlapOp>
100  (
101  meshA,
102  cellAI,
103  meshB,
104  cellBI,
105  cellBbB,
106  overlapSumOp
107  );
109  return overlapSumOp.iop_.vol_;
110 }
111 
112 
115 (
116  const primitiveMesh& meshA,
117  const label cellAI,
118 
119  const primitiveMesh& meshB,
120  const label cellBI,
121  const treeBoundBox& cellBbB
122 ) const
123 {
124  sumOverlapMomentOp overlapSumOp;
125  cellCellOverlapMinDecomp<sumOverlapMomentOp>
126  (
127  meshA,
128  cellAI,
129  meshB,
130  cellBI,
131  cellBbB,
132  overlapSumOp
133  );
134 
135  return overlapSumOp.iop_.vol_;
136 }
137 
138 
140 (
141  const polyMesh& fromMesh,
142  const polyMesh& toMesh,
143  const label iTo
144 ) const
145 {
146  const indexedOctree<treeDataCell>& treeA = fromMesh.cellTree();
147 
148  treeBoundBox bbB(toMesh.points(), toMesh.cellPoints()[iTo]);
149 
150  return treeA.findBox(bbB);
151 }
152 
153 
154 // ************************************************************************* //
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
Definition: stringOps.H:54
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:75
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:1078
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:38
const pointField & points
defineTypeNameAndDebug(combustionModel, 0)
labelList f(nPoints)
const indexedOctree< treeDataCell > & cellTree() const
Return the cell search tree.
Definition: polyMesh.C:939
vector point
Point is a vector.
Definition: point.H:37
Non-pointer based hierarchical recursive searching.
Standard boundBox with extra functionality for use in octree.
Definition: treeBoundBox.H:90
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
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.
scalar cellCellOverlapVolumeMinDecomp(const primitiveMesh &meshA, const label cellAI, const primitiveMesh &meshB, const label cellBI, const treeBoundBox &cellBbB) const
Calculates the overlap volume.
const labelListList & cellPoints() const
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.