meshDualiser.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 | Copyright (C) 2011-2016 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 inbetween 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  //- Disallow default bitwise copy construct
172  meshDualiser(const meshDualiser&);
173 
174  //- Disallow default bitwise assignment
175  void operator=(const meshDualiser&);
176 
177 
178 public:
179 
180  //- Runtime type information
181  ClassName("meshDualiser");
182 
183 
184  // Constructors
185 
186  //- Construct from mesh
187  meshDualiser(const polyMesh&);
188 
189 
190  // Member Functions
191 
192  // Access
193 
194  //- From point on cell to dual cell. Either single entry or
195  // one entry per pointCells.
196  const labelListList& pointToDualCells() const
197  {
198  return pointToDualCells_;
199  }
200 
201  //- From point to dual point (or -1 if not feature point).
202  const labelList& pointToDualPoint() const
203  {
204  return pointToDualPoint_;
205  }
206 
207  //- From cell to dual point (at cell centre). All cells become
208  // points.
209  const labelList& cellToDualPoint() const
210  {
211  return cellToDualPoint_;
212  }
213 
214  //- From face to dual point (at face centre; or -1 if not
215  // feature face).
216  const labelList& faceToDualPoint() const
217  {
218  return faceToDualPoint_;
219  }
220 
221  //- From edge to dual point (at edge mid; or -1 if not feature
222  // edge).
223  const labelList& edgeToDualPoint() const
224  {
225  return edgeToDualPoint_;
226  }
227 
228 
229  // Edit
230 
231 
232  //- Insert all changes into meshMod to convert the polyMesh into
233  // its dual.
234  // featureFaces : faces where we want a point at the face centre
235  // featureEdges : edges ,, edge mid
236  // featurePoints : points ,, point. Two variants:
237  // singleCellFeaturePoints : point becomes one dualcell.
238  // Use this for e.g. convex boundary points.
239  // multiCellFeaturePoints : one dualcell per original cell
240  // around point. Use this for e.g. concave boundary points
241  // since it prevents big concave boundary cells.
242  void setRefinement
243  (
244  const bool splitFace,
245  const labelList& featureFaces,
246  const labelList& featureEdges,
247  const labelList& singleCellFeaturePoints,
248  const labelList& multiCellFeaturePoints,
249  polyTopoChange& meshMod
250  );
251 };
252 
253 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
254 
255 } // End namespace Foam
256 
257 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
258 
259 #endif
260 
261 // ************************************************************************* //
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:69
const labelList & edgeToDualPoint() const
From edge to dual point (at edge mid; or -1 if not feature.
Definition: meshDualiser.H:222
const labelList & pointToDualPoint() const
From point to dual point (or -1 if not feature point).
Definition: meshDualiser.H:201
const labelList & faceToDualPoint() const
From face to dual point (at face centre; or -1 if not.
Definition: meshDualiser.H:215
const labelListList & pointToDualCells() const
From point on cell to dual cell. Either single entry or.
Definition: meshDualiser.H:195
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
Direct mesh changes based on v1.3 polyTopoChange syntax.
ClassName("meshDualiser")
Runtime type information.
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:208
Namespace for OpenFOAM.