tetIndicesI.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) 2011-2024 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 "tetIndices.H"
27 #include "Time.H"
28 
29 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
30 
32 {
33  return celli_;
34 }
35 
36 
38 {
39  return celli_;
40 }
41 
42 
44 {
45  return facei_;
46 }
47 
48 
50 {
51  return facei_;
52 }
53 
54 
56 {
57  return tetPti_;
58 }
59 
60 
62 {
63  return tetPti_;
64 }
65 
66 
68 {
69  const Foam::face& f = mesh.faces()[face()];
70 
71  label faceBasePtI = mesh.tetBasePtIs()[face()];
72 
73  if (faceBasePtI < 0)
74  {
75  static labelHashSet badFaces;
76  static label badTimeIndex = -1;
77 
78  if (badTimeIndex != mesh.time().timeIndex())
79  {
80  badFaces.clear();
81  badTimeIndex = mesh.time().timeIndex();
82  }
83 
84  if (!badFaces[face()])
85  {
87  << "No base point for face " << face() << ", " << f
88  << ", produces a valid tet decomposition." << endl;
89 
90  badFaces.set(face());
91  }
92 
93  faceBasePtI = 0;
94  }
95 
96  label facePtI = (tetPt() + faceBasePtI) % f.size();
97  label faceOtherPtI = f.fcIndex(facePtI);
98 
99  if (mesh.faceOwner()[face()] != cell())
100  {
101  Swap(facePtI, faceOtherPtI);
102  }
103 
104  return triFace(f[faceBasePtI], f[facePtI], f[faceOtherPtI]);
105 }
106 
107 
109 (
110  const polyMesh& mesh,
111  const pointField& meshPoints,
112  const pointField& cellCentres
113 ) const
114 {
115  const triFace tri = faceTriIs(mesh);
116 
117  return tetPointRef
118  (
119  cellCentres[cell()],
120  meshPoints[tri[0]],
121  meshPoints[tri[1]],
122  meshPoints[tri[2]]
123  );
124 }
125 
126 
128 {
129  return tet(mesh, mesh.points(), mesh.cellCentres());
130 }
131 
132 
134 (
135  const polyMesh& mesh,
136  const pointField& meshPoints
137 ) const
138 {
139  const triFace tri = faceTriIs(mesh);
140 
141  return triPointRef
142  (
143  meshPoints[tri[0]],
144  meshPoints[tri[1]],
145  meshPoints[tri[2]]
146  );
147 }
148 
149 
151 {
152  return faceTri(mesh, mesh.points());
153 }
154 
155 
156 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
157 
158 inline bool Foam::tetIndices::operator==(const Foam::tetIndices& rhs) const
159 {
160  return
161  cell() == rhs.cell()
162  && face() == rhs.face()
163  && tetPt() == rhs.tetPt();
164 }
165 
166 
167 inline bool Foam::tetIndices::operator!=(const Foam::tetIndices& rhs) const
168 {
169  return !(*this == rhs);
170 }
171 
172 
173 // ************************************************************************* //
bool set(const Key &key)
Same as insert (cannot overwrite nil content)
Definition: HashSet.H:123
void clear()
Clear all entries from table.
Definition: HashTable.C:542
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
label timeIndex() const
Return current time index.
Definition: TimeStateI.H:28
label fcIndex(const label i) const
Return the forward circular index, i.e. the next index.
Definition: UListI.H:58
A cell is defined as a list of faces with extra functionality.
Definition: cell.H:60
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:76
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:420
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
virtual const faceList & faces() const
Return raw faces.
Definition: polyMesh.C:1344
virtual const labelList & faceOwner() const
Return face owner.
Definition: polyMesh.C:1357
const labelIOList & tetBasePtIs() const
Return the tetBasePtIs.
Definition: polyMesh.C:1046
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:1331
const vectorField & cellCentres() const
Storage and named access for the indices of a tet which is part of the decomposition of a cell.
Definition: tetIndices.H:82
label face() const
Return the face.
Definition: tetIndicesI.H:43
label tetPt() const
Return the characterising tetPtI.
Definition: tetIndicesI.H:55
bool operator==(const tetIndices &) const
Definition: tetIndicesI.H:158
label cell() const
Return the cell.
Definition: tetIndicesI.H:31
bool operator!=(const tetIndices &) const
Definition: tetIndicesI.H:167
triFace faceTriIs(const polyMesh &mesh) const
Return the indices corresponding to the tri on the face for.
Definition: tetIndicesI.H:67
tetPointRef tet(const polyMesh &mesh, const pointField &meshPoints, const pointField &cellCentres) const
Return the geometry corresponding to this tet and the given.
Definition: tetIndicesI.H:109
triPointRef faceTri(const polyMesh &mesh, const pointField &meshPoints) const
Return the geometry corresponding to the tri on the face for.
Definition: tetIndicesI.H:134
A tetrahedron primitive.
Definition: tetrahedron.H:82
A triangular face using a FixedList of labels corresponding to mesh vertices.
Definition: triFace.H:71
A triangle primitive used to calculate face areas and swept volumes.
Definition: triangle.H:80
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define WarningInFunction
Report a warning using Foam::Warning.
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
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:258
triangle< point, const point & > triPointRef
Definition: triPointRef.H:44
void Swap(T &a, T &b)
Definition: Swap.H:43
tetrahedron< point, const point & > tetPointRef
Definition: tetPointRef.H:44
face triFace(3)
labelList f(nPoints)