tetDecomposer.H
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-2016 OpenFOAM Foundation
9  Copyright (C) 2018-2020,2024 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 Class
28  Foam::tetDecomposer
29 
30 Description
31  Decomposes polyMesh into tets (or pyramids)
32 
33  Cells neighbouring decomposed cells are not decomposed themselves
34  so will be polyhedral.
35 
36 SourceFiles
37  tetDecomposer.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef tetDecomposer_H
42 #define tetDecomposer_H
43 
44 #include "DynamicList.H"
45 #include "bitSet.H"
46 #include "boolList.H"
47 #include "typeInfo.H"
48 #include "Enum.H"
49 #include "faceList.H"
50 
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 
53 namespace Foam
54 {
55 
56 class polyMesh;
57 class polyTopoChange;
58 class face;
59 class mapPolyMesh;
60 
61 /*---------------------------------------------------------------------------*\
62  Class tetDecomposer Declaration
63 \*---------------------------------------------------------------------------*/
64 
65 class tetDecomposer
66 {
67 public:
68 
69  // Public data types
70 
72  {
73  FACE_CENTRE_TRIS, //- Faces decomposed into triangles
74  // using face-centre
75  FACE_DIAG_TRIS, //- Faces decomposed into triangles diagonally
76  PYRAMID, //- Faces not decomposed (generates pyramids)
77  FACE_DIAG_QUADS //- Like FACE_DIAG_TRIS but does quads mainly
78  };
80 
81 
82 private:
83 
84  // Private data
85 
86  const polyMesh& mesh_;
87 
88  //- From cell to tet point
89  labelList cellToPoint_;
90 
91  //- From face to tet point
92  labelList faceToPoint_;
93 
94  // Per face, per point (faceCentre) or triangle (faceDiag)
95  // the added tet on the owner side
96  labelListList faceOwnerCells_;
97 
98  // Per face, per point (faceCentre) or triangle (faceDiag)
99  // the added tet on the neighbour side
100  labelListList faceNeighbourCells_;
101 
102 
103  // Private Member Functions
104 
105  //- Modify a face
106  void modifyFace
107  (
108  polyTopoChange& meshMod,
109  const face& f,
110  const label facei,
111  const label own,
112  const label nei,
113  const label patchi,
114  const label zoneI,
115  const bool zoneFlip
116  ) const;
117 
118  //- Add a face
119  void addFace
120  (
121  polyTopoChange& meshMod,
122  const face& f,
123  const label facei,
124  const label own,
125  const label nei,
126  const label masterPointID,
127  const label masterEdgeID,
128  const label masterFaceID,
129  const label patchi,
130  const label zoneI,
131  const bool zoneFlip
132  ) const;
133 
134  //- Work out triangle index given the starting vertex in the face
135  label triIndex(const label facei, const label fp) const;
136 
137  //- Calculate triangulation of boundary faces
138  void splitBoundaryFaces
139  (
140  List<faceList>& boundaryQuads,
141  List<faceList>& boundaryTris
142  ) const;
143 
144  //- Correct coupled faces to match up
145  void relativeIndicesToFace
146  (
147  const bool doFlip,
148  const face& meshFace,
149  const faceList& indexLists,
150  faceList& faces
151  ) const;
152 
153  //- Calculate triangulation of any face
154  void splitFace
155  (
156  const List<faceList>& boundaryQuads,
157  const List<faceList>& boundaryTris,
158  const label facei,
159  const label patchi,
160  label& quadi,
161  faceList& quadFaces,
162  label& trii,
163  faceList& triFaces
164  ) const;
165 
166  void splitFace
167  (
168  const List<faceList>& boundaryQuads,
169  const List<faceList>& boundaryTris,
170  const label facei,
171  const label patchi,
172  faceList& quadFaces,
173  faceList& triFaces,
174  faceList& subFaces
175  ) const;
176 
177  //- No copy construct
178  tetDecomposer(const tetDecomposer&) = delete;
179 
180  //- No copy assignment
181  void operator=(const tetDecomposer&) = delete;
182 
183 
184 public:
185 
186  //- Runtime type information
187  ClassName("tetDecomposer");
188 
189 
190  // Constructors
191 
192  //- Construct from mesh
193  tetDecomposer(const polyMesh&);
194 
195 
196  // Member Functions
197 
198  // Access
199 
200  //- From cell to tet point
201  const labelList& cellToPoint() const
202  {
203  return cellToPoint_;
204  }
205 
206  //- From face to tet point (only for faceCentre)
207  const labelList& faceToPoint() const
208  {
209  return faceToPoint_;
210  }
211 
212 
213  //- Per face, per point (faceCentre) or triangle (faceDiag)
214  // the added tet on the owner side. For non-face (pyramid)
215  // size 1.
216  const labelListList& faceOwnerCells() const
217  {
218  return faceOwnerCells_;
219  }
220 
221  //- Per face, per point (faceCentre) or triangle (faceDiag)
222  // the added tet on the neighbour side. For non-face (pyramid)
223  // size 1.
224  const labelListList& faceNeighbourCells() const
225  {
226  return faceNeighbourCells_;
227  }
228 
229 
230  // Edit
231 
232  //- Insert all changes into meshMod to convert the polyMesh into
233  // subshapes (tets/prisms)
234  void setRefinement
235  (
236  const decompositionType decomposeType,
237  const bitSet& decomposeCell,
238  polyTopoChange& meshMod
239  );
240 
241  //- Insert all changes into meshMod to convert the polyMesh into
242  //- subshapes (tets/prisms). Explicit control over which faces
243  //- get decomposed. Can be used e.g. to not split triangles.
244  void setRefinement
245  (
246  const decompositionType decomposeType,
247  const bitSet& decomposeCell,
248  const bitSet& decomposeFace,
249  polyTopoChange& meshMod
250  );
251 
252  //- Force recalculation of locally stored data on topological change
253  void updateMesh(const mapPolyMesh&);
254 };
255 
256 
257 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
258 
259 } // End namespace Foam
260 
261 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
262 
263 #endif
264 
265 // ************************************************************************* //
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:68
List< labelList > labelListList
List of labelList.
Definition: labelList.H:38
Decomposes polyMesh into tets (or pyramids)
Definition: tetDecomposer.H:60
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
static const Enum< decompositionType > decompositionTypeNames
Definition: tetDecomposer.H:74
const labelList & cellToPoint() const
From cell to tet point.
const labelListList & faceNeighbourCells() const
Per face, per point (faceCentre) or triangle (faceDiag)
ClassName("tetDecomposer")
Runtime type information.
void setRefinement(const decompositionType decomposeType, const bitSet &decomposeCell, polyTopoChange &meshMod)
Insert all changes into meshMod to convert the polyMesh into.
labelList f(nPoints)
Basic run-time type information using word as the type&#39;s name. Used to enhance the standard RTTI to c...
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:59
Direct mesh changes based on v1.3 polyTopoChange syntax.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:75
const labelList & faceToPoint() const
From face to tet point (only for faceCentre)
List< label > labelList
A List of labels.
Definition: List.H:61
void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
const labelListList & faceOwnerCells() const
Per face, per point (faceCentre) or triangle (faceDiag)
Namespace for OpenFOAM.