meshDualiser.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-2019 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::meshDualiser
26 
27 Description
28  Creates dual of polyMesh. Every point becomes a cell (or multiple cells
29  for feature points), a walk around every edge creates faces between them.
30 
31  Put all points you want in the final mesh into featurePoints; all edge(mid)s
32  you want in the final mesh into featureEdges; all face(centre)s in
33  faceFaces.
34 
35  Usually to preserve boundaries:
36  - all boundary faces are featureFaces
37  - all edges and points in between different patches are
38  featureEdges/points.
39 
40  In same way you can also preserve internal faces (e.g. faceZones)
41 
42 SourceFiles
43  Foam::meshDualiser.C
44 
45 \*---------------------------------------------------------------------------*/
46 
47 #ifndef meshDualiser_H
48 #define meshDualiser_H
49 
50 #include "DynamicList.H"
51 #include "PackedBoolList.H"
52 #include "boolList.H"
53 #include "typeInfo.H"
54 
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 
57 namespace Foam
58 {
59 
60 class polyMesh;
61 class polyTopoChange;
62 
63 /*---------------------------------------------------------------------------*\
64  Class meshDualiser Declaration
65 \*---------------------------------------------------------------------------*/
66 
67 class meshDualiser
68 {
69  // Private Data
70 
71  const polyMesh& mesh_;
72 
73  //- From point on cell to dual cell. Either single entry or
74  // one entry per pointCells
75  labelListList pointToDualCells_;
76 
77  //- From point to dual point (or -1 if not feature point).
78  labelList pointToDualPoint_;
79 
80  //- From cell to dual point. All cells become point
81  labelList cellToDualPoint_;
82 
83  //- From face to dual point (or -1 if not feature face)
84  labelList faceToDualPoint_;
85 
86  //- From edge to dual point (or -1 if not feature edge)
87  labelList edgeToDualPoint_;
88 
89 
90  // Private Member Functions
91 
92  static void checkPolyTopoChange(const polyTopoChange&);
93 
94  static void dumpPolyTopoChange(const polyTopoChange&, const fileName&);
95 
96  //- Find dual cell given point and cell
97  label findDualCell(const label celli, const label pointi) const;
98 
99  //- Helper function to generate dualpoints on all boundary edges
100  // emanating from (boundary & feature) point
101  void generateDualBoundaryEdges
102  (
103  const PackedBoolList&,
104  const label pointi,
106  );
107 
108  //- Check that owner and neighbour of face have same dual cell
109  bool sameDualCell
110  (
111  const label facei,
112  const label pointi
113  ) const;
114 
115  //- Add internal face
116  label addInternalFace
117  (
118  const label masterPointi,
119  const label masterEdgeI,
120  const label masterFacei,
121 
122  const bool edgeOrder,
123  const label dualCell0,
124  const label dualCell1,
125  const DynamicList<label>& verts,
126  polyTopoChange& meshMod
127  ) const;
128 
129  //- Add boundary face
130  label addBoundaryFace
131  (
132  const label masterPointi,
133  const label masterEdgeI,
134  const label masterFacei,
135 
136  const label dualCelli,
137  const label patchi,
138  const DynamicList<label>& verts,
139  polyTopoChange& meshMod
140  ) const;
141 
142  //- Create internal faces walking around edge
143  void createFacesAroundEdge
144  (
145  const bool splitFace,
146  const PackedBoolList&,
147  const label edgeI,
148  const label startFacei,
150  boolList& doneEFaces
151  ) const;
152 
153  //- Create single internal face from internal face
154  void createFaceFromInternalFace
155  (
156  const label facei,
157  label& fp,
159  ) const;
160 
161  //- Creates boundary faces walking around point on patchi.
162  void createFacesAroundBoundaryPoint
163  (
164  const label patchi,
165  const label patchPointi,
166  const label startFacei,
168  boolList& donePFaces // pFaces visited
169  ) const;
170 
171 
172 public:
173 
174  //- Runtime type information
175  ClassName("meshDualiser");
176 
177 
178  // Constructors
179 
180  //- Construct from mesh
181  meshDualiser(const polyMesh&);
182 
183  //- Disallow default bitwise copy construction
184  meshDualiser(const meshDualiser&) = delete;
185 
186 
187  // Member Functions
188 
189  // Access
190 
191  //- From point on cell to dual cell. Either single entry or
192  // one entry per pointCells.
193  const labelListList& pointToDualCells() const
194  {
195  return pointToDualCells_;
196  }
197 
198  //- From point to dual point (or -1 if not feature point).
199  const labelList& pointToDualPoint() const
200  {
201  return pointToDualPoint_;
202  }
203 
204  //- From cell to dual point (at cell centre). All cells become
205  // points.
206  const labelList& cellToDualPoint() const
207  {
208  return cellToDualPoint_;
209  }
210 
211  //- From face to dual point (at face centre; or -1 if not
212  // feature face).
213  const labelList& faceToDualPoint() const
214  {
215  return faceToDualPoint_;
216  }
217 
218  //- From edge to dual point (at edge mid; or -1 if not feature
219  // edge).
220  const labelList& edgeToDualPoint() const
221  {
222  return edgeToDualPoint_;
223  }
224 
225 
226  // Edit
227 
228  //- Insert all changes into meshMod to convert the polyMesh into
229  // its dual.
230  // featureFaces : faces where we want a point at the face centre
231  // featureEdges : edges ,, edge mid
232  // featurePoints : points ,, point. Two variants:
233  // singleCellFeaturePoints : point becomes one dualcell.
234  // Use this for e.g. convex boundary points.
235  // multiCellFeaturePoints : one dualcell per original cell
236  // around point. Use this for e.g. concave boundary points
237  // since it prevents big concave boundary cells.
238  void setRefinement
239  (
240  const bool splitFace,
241  const labelList& featureFaces,
242  const labelList& featureEdges,
243  const labelList& singleCellFeaturePoints,
244  const labelList& multiCellFeaturePoints,
245  polyTopoChange& meshMod
246  );
247 
248 
249  // Member Operators
250 
251  //- Disallow default bitwise assignment
252  void operator=(const meshDualiser&) = delete;
253 };
254 
255 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
256 
257 } // End namespace Foam
258 
259 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
260 
261 #endif
262 
263 // ************************************************************************* //
void setRefinement(const bool splitFace, const labelList &featureFaces, const labelList &featureEdges, const labelList &singleCellFeaturePoints, const labelList &multiCellFeaturePoints, polyTopoChange &meshMod)
Insert all changes into meshMod to convert the polyMesh into.
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
A class for handling file names.
Definition: fileName.H:79
const labelListList & pointToDualCells() const
From point on cell to dual cell. Either single entry or.
Definition: meshDualiser.H:192
const labelList & pointToDualPoint() const
From point to dual point (or -1 if not feature point).
Definition: meshDualiser.H:198
const labelList & faceToDualPoint() const
From face to dual point (at face centre; or -1 if not.
Definition: meshDualiser.H:212
meshDualiser(const polyMesh &)
Construct from mesh.
Creates dual of polyMesh. Every point becomes a cell (or multiple cells for feature points)...
Definition: meshDualiser.H:66
A bit-packed bool list.
label patchi
const labelList & edgeToDualPoint() const
From edge to dual point (at edge mid; or -1 if not feature.
Definition: meshDualiser.H:219
Direct mesh changes based on v1.3 polyTopoChange syntax.
ClassName("meshDualiser")
Runtime type information.
void operator=(const meshDualiser &)=delete
Disallow default bitwise assignment.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
const labelList & cellToDualPoint() const
From cell to dual point (at cell centre). All cells become.
Definition: meshDualiser.H:205
Namespace for OpenFOAM.