tetOverlapVolume.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2012-2022 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 Class
25  Foam::tetOverlapVolume
26 
27 Description
28  Calculates the overlap volume of two cells using tetrahedral decomposition
29 
30 SourceFiles
31  tetOverlapVolume.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef tetOverlapVolume_H
36 #define tetOverlapVolume_H
37 
38 #include "FixedList.H"
39 #include "labelList.H"
40 #include "treeBoundBox.H"
41 #include "tetPointRef.H"
42 
43 namespace Foam
44 {
45 
46 class primitiveMesh;
47 class polyMesh;
48 
49 /*---------------------------------------------------------------------------*\
50  Class tetOverlapVolume Declaration
51 \*---------------------------------------------------------------------------*/
52 
53 class tetOverlapVolume
54 {
55  // Private Member Functions
56 
57  //- Tet overlap volume
58  scalar tetTetOverlapVol
59  (
60  const tetPointRef& tetA,
61  const tetPointRef& tetB
62  ) const;
63 
64  //- Return a const treeBoundBox
65  treeBoundBox pyrBb
66  (
67  const pointField& points,
68  const face& f,
69  const point& fc
70  ) const;
71 
72 
73  // Private classes
74 
75  //- A fixed list of tets which simulates a dynamic list by incrementing
76  // a counter whenever its append method is called. This is used as an
77  // optimisation for the tetTetOverlapVol method.
78  template<unsigned Size>
79  class cutTetList
80  :
81  public FixedList<FixedList<point, 4>, Size>
82  {
83  private:
84 
85  //- The number of stored elements
86  label n_;
87 
88 
89  public:
90 
91  //- Construct null
92  cutTetList()
93  :
94  n_(0)
95  {}
96 
97  //- Clear the array
98  void clear()
99  {
100  n_ = 0;
101  }
102 
103  //- Get the current size
104  label size() const
105  {
106  return n_;
107  }
108 
109  //- Add a new tet to the end of the array
110  void append(const FixedList<point, 4>& t)
111  {
112  this->operator[](n_) = t;
113  ++ n_;
114  }
115  };
116 
117 
118 public:
119 
120  //- Runtime type information
121  ClassName("tetOverlapVolume");
122 
123 
124  // Constructors
125 
126  //- Null constructor
128 
129 
130  // Public members
131 
132  //- Return a list of cells in meshA which overlaps with cellBI in
133  // meshB
135  (
136  const polyMesh& meshA,
137  const polyMesh& meshB,
138  const label cellBI
139  ) const;
140 
141  //- Calculates the cell volume
142  scalar cellVolumeMinDecomp
143  (
144  const primitiveMesh& mesh,
145  const label celli
146  ) const;
147 
148  //- Return true if olverlap volume is greater than threshold
150  (
151  const primitiveMesh& meshA,
152  const label cellAI,
153  const primitiveMesh& meshB,
154  const label cellBI,
155  const treeBoundBox& cellBbB,
156  const scalar threshold = 0.0
157  ) const;
158 
159  //- Calculates the overlap volume
161  (
162  const primitiveMesh& meshA,
163  const label cellAI,
164  const primitiveMesh& meshB,
165  const label cellBI,
166  const treeBoundBox& cellBbB
167  ) const;
168 };
169 
170 
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 
173 } // End namespace Foam
174 
175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 
177 #endif
178 
179 // ************************************************************************* //
A 1D vector of objects of type <T> with a fixed size <Size>.
Definition: FixedList.H:78
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:76
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:75
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.
scalar cellVolumeMinDecomp(const primitiveMesh &mesh, const label celli) const
Calculates the cell volume.
labelList overlappingCells(const polyMesh &meshA, const polyMesh &meshB, const label cellBI) const
Return a list of cells in meshA which overlaps with cellBI in.
bool cellCellOverlapMinDecomp(const primitiveMesh &meshA, const label cellAI, const primitiveMesh &meshB, const label cellBI, const treeBoundBox &cellBbB, const scalar threshold=0.0) const
Return true if olverlap volume is greater than threshold.
tetOverlapVolume()
Null constructor.
A tetrahedron primitive.
Definition: tetrahedron.H:82
Standard boundBox + extra functionality for use in octree.
Definition: treeBoundBox.H:90
const pointField & points
tUEqn clear()
Namespace for OpenFOAM.
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
labelList f(nPoints)