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 "tetPoints.H"
32 #include "polyMesh.H"
33 #include "OFstream.H"
34 #include "treeBoundBox.H"
35 #include "indexedOctree.H"
36 #include "treeDataCell.H"
37 
38 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
39 
40 namespace Foam
41 {
42  defineTypeNameAndDebug(tetOverlapVolume, 0);
43 }
44 
45 
46 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
47 
49 {}
50 
51 
52 // * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * * //
53 
54 Foam::treeBoundBox Foam::tetOverlapVolume::pyrBb
55 (
56  const pointField& points,
57  const face& f,
58  const point& fc
59 )
60 {
61  treeBoundBox bb(fc);
62  bb.add(points, f);
63 
64  return bb;
65 }
66 
67 
68 // * * * * * * * * * * * Public Member Functions * * * * * * * * * * * * * //
69 
70 bool Foam::tetOverlapVolume::cellCellOverlapMinDecomp
71 (
72  const primitiveMesh& meshA,
73  const label cellAI,
74  const primitiveMesh& meshB,
75  const label cellBI,
76  const treeBoundBox& cellBbB,
77  const scalar threshold
78 ) const
79 {
80  hasOverlapOp overlapCheckOp(threshold);
81  cellCellOverlapMinDecomp<hasOverlapOp>
82  (
83  meshA,
84  cellAI,
85  meshB,
86  cellBI,
87  cellBbB,
88  overlapCheckOp
89  );
90 
91  return overlapCheckOp.ok_;
92 }
93 
94 
96 (
97  const primitiveMesh& meshA,
98  const label cellAI,
99 
100  const primitiveMesh& meshB,
101  const label cellBI,
102  const treeBoundBox& cellBbB
103 ) const
104 {
105  sumOverlapOp overlapSumOp;
106  cellCellOverlapMinDecomp<sumOverlapOp>
107  (
108  meshA,
109  cellAI,
110  meshB,
111  cellBI,
112  cellBbB,
113  overlapSumOp
114  );
115 
116  return overlapSumOp.iop_.vol_;
117 }
118 
119 
122 (
123  const primitiveMesh& meshA,
124  const label cellAI,
125 
126  const primitiveMesh& meshB,
127  const label cellBI,
128  const treeBoundBox& cellBbB
129 ) const
130 {
131  sumOverlapMomentOp overlapSumOp;
132  cellCellOverlapMinDecomp<sumOverlapMomentOp>
133  (
134  meshA,
135  cellAI,
136  meshB,
137  cellBI,
138  cellBbB,
139  overlapSumOp
140  );
141 
142  return overlapSumOp.iop_.vol_;
143 }
144 
145 
147 (
148  const polyMesh& fromMesh,
149  const polyMesh& toMesh,
150  const label iTo
151 ) const
152 {
153  const indexedOctree<treeDataCell>& treeA = fromMesh.cellTree();
154 
155  treeBoundBox bbB(toMesh.points(), toMesh.cellPoints()[iTo]);
156 
157  return treeA.findBox(bbB);
158 }
159 
160 
161 // ************************************************************************* //
Foam::polyMesh::points
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:1069
Foam::primitiveMesh::cellPoints
const labelListList & cellPoints() const
Definition: primitiveMeshCellPoints.C:34
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:96
Foam::treeBoundBox
Standard boundBox with extra functionality for use in octree.
Definition: treeBoundBox.H:86
indexedOctree.H
polyMesh.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
OFstream.H
Foam::Field< vector >
treeBoundBox.H
Foam::indexedOctree
Non-pointer based hierarchical recursive searching.
Definition: treeDataEdge.H:50
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:147
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:122
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
treeDataCell.H
Foam::tetOverlapVolume::tetOverlapVolume
tetOverlapVolume()
Null constructor.
Definition: tetOverlapVolume.C:48
tetOverlapVolume.H
Foam::polyMesh::cellTree
const indexedOctree< treeDataCell > & cellTree() const
Return the cell search tree.
Definition: polyMesh.C:926
f
labelList f(nPoints)
Foam::Vector< scalar >
Foam::List< label >
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:72
Foam::Tuple2
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
Definition: stringOps.H:60
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
tetPoints.H
tetrahedron.H
Foam::primitiveMesh
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:78