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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::meshDualiser
28 
29 Description
30  Creates dual of polyMesh. Every point becomes a cell (or multiple cells
31  for feature points), a walk around every edge creates faces between them.
32 
33  Put all points you want in the final mesh into featurePoints; all edge(mid)s
34  you want in the final mesh into featureEdges; all face(centre)s in
35  faceFaces.
36 
37  Usually to preserve boundaries:
38  - all boundary faces are featureFaces
39  - all edges and points inbetween different patches are
40  featureEdges/points.
41 
42  In same way you can also preserve internal faces (e.g. faceZones)
43 
44 SourceFiles
45  Foam::meshDualiser.C
46 
47 \*---------------------------------------------------------------------------*/
48 
49 #ifndef Foam_meshDualiser_H
50 #define Foam_meshDualiser_H
51 
52 #include "bitSet.H"
53 #include "boolList.H"
54 #include "labelList.H"
55 #include "typeInfo.H"
56 
57 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58 
59 namespace Foam
60 {
61 
62 // Forward Declarations
63 class polyMesh;
64 class polyTopoChange;
65 
66 /*---------------------------------------------------------------------------*\
67  Class meshDualiser Declaration
68 \*---------------------------------------------------------------------------*/
69 
70 class meshDualiser
71 {
72  // Private data
73 
74  const polyMesh& mesh_;
75 
76  //- From point on cell to dual cell. Either single entry or
77  // one entry per pointCells
78  labelListList pointToDualCells_;
79 
80  //- From point to dual point (or -1 if not feature point).
81  labelList pointToDualPoint_;
82 
83  //- From cell to dual point. All cells become point
84  labelList cellToDualPoint_;
85 
86  //- From face to dual point (or -1 if not feature face)
87  labelList faceToDualPoint_;
88 
89  //- From edge to dual point (or -1 if not feature edge)
90  labelList edgeToDualPoint_;
91 
92 
93  // Private Member Functions
94 
95  static void checkPolyTopoChange(const polyTopoChange&);
96 
97  static void dumpPolyTopoChange(const polyTopoChange&, const fileName&);
98 
99  //- Find dual cell given point and cell
100  label findDualCell(const label celli, const label pointi) const;
101 
102  //- Helper function to generate dualpoints on all boundary edges
103  // emanating from (boundary & feature) point
104  void generateDualBoundaryEdges
105  (
106  const bitSet& isBoundaryEdge,
107  const label pointi,
108  polyTopoChange& meshMod
109  );
110 
111  //- Check that owner and neighbour of face have same dual cell
112  bool sameDualCell
113  (
114  const label facei,
115  const label pointi
116  ) const;
117 
118  //- Add internal face
119  label addInternalFace
120  (
121  const label masterPointi,
122  const label masterEdgeI,
123  const label masterFacei,
124 
125  const bool edgeOrder,
126  const label dualCell0,
127  const label dualCell1,
128  const labelUList& verts,
129  polyTopoChange& meshMod
130  ) const;
131 
132  //- Add boundary face
133  label addBoundaryFace
134  (
135  const label masterPointi,
136  const label masterEdgeI,
137  const label masterFacei,
138 
139  const label dualCelli,
140  const label patchi,
141  const labelUList& verts,
142  polyTopoChange& meshMod
143  ) const;
144 
145  //- Create internal faces walking around edge
146  void createFacesAroundEdge
147  (
148  const bool splitFace,
149  const bitSet& isBoundaryEdge,
150  const label edgeI,
151  const label startFacei,
152  polyTopoChange& meshMod,
153  boolList& doneEFaces
154  ) const;
155 
156  //- Create single internal face from internal face
157  void createFaceFromInternalFace
158  (
159  const label facei,
160  label& fp,
162  ) const;
163 
164  //- Creates boundary faces walking around point on patchi.
165  void createFacesAroundBoundaryPoint
166  (
167  const label patchi,
168  const label patchPointi,
169  const label startFacei,
171  boolList& donePFaces // pFaces visited
172  ) const;
173 
174 
175 public:
176 
177  //- Runtime type information
178  ClassName("meshDualiser");
179 
180 
181  // Generated Methods
182 
183  //- No copy construct
184  meshDualiser(const meshDualiser&) = delete;
185 
186  //- No copy assignment
187  void operator=(const meshDualiser&) = delete;
188 
189 
190  // Constructors
191 
192  //- Construct from mesh
193  explicit meshDualiser(const polyMesh&);
194 
195 
196  // Member Functions
197 
198  // Access
199 
200  //- From point on cell to dual cell. Either single entry or
201  // one entry per pointCells.
202  const labelListList& pointToDualCells() const
203  {
204  return pointToDualCells_;
205  }
206 
207  //- From point to dual point (or -1 if not feature point).
208  const labelList& pointToDualPoint() const
209  {
210  return pointToDualPoint_;
211  }
212 
213  //- From cell to dual point (at cell centre). All cells become
214  // points.
215  const labelList& cellToDualPoint() const
216  {
217  return cellToDualPoint_;
218  }
219 
220  //- From face to dual point (at face centre; or -1 if not
221  // feature face).
222  const labelList& faceToDualPoint() const
223  {
224  return faceToDualPoint_;
225  }
226 
227  //- From edge to dual point (at edge mid; or -1 if not feature
228  // edge).
229  const labelList& edgeToDualPoint() const
230  {
231  return edgeToDualPoint_;
232  }
233 
234 
235  // Edit
237 
238  //- Insert all changes into meshMod to convert the polyMesh into
239  // its dual.
240  // featureFaces : faces where we want a point at the face centre
241  // featureEdges : edges ,, edge mid
242  // featurePoints : points ,, point. Two variants:
243  // singleCellFeaturePoints : point becomes one dualcell.
244  // Use this for e.g. convex boundary points.
245  // multiCellFeaturePoints : one dualcell per original cell
246  // around point. Use this for e.g. concave boundary points
247  // since it prevents big concave boundary cells.
248  void setRefinement
249  (
250  const bool splitFace,
251  const labelList& featureFaces,
252  const labelList& featureEdges,
253  const labelList& singleCellFeaturePoints,
254  const labelList& multiCellFeaturePoints,
255  polyTopoChange& meshMod
256  );
257 };
258 
259 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
260 
261 } // End namespace Foam
262 
263 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
265 #endif
266 
267 // ************************************************************************* //
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.
A class for handling file names.
Definition: fileName.H:72
meshDualiser(const meshDualiser &)=delete
No copy construct.
const labelListList & pointToDualCells() const
From point on cell to dual cell. Either single entry or.
Definition: meshDualiser.H:236
const labelList & pointToDualPoint() const
From point to dual point (or -1 if not feature point).
Definition: meshDualiser.H:244
const labelList & faceToDualPoint() const
From face to dual point (at face centre; or -1 if not.
Definition: meshDualiser.H:264
Creates dual of polyMesh. Every point becomes a cell (or multiple cells for feature points)...
Definition: meshDualiser.H:65
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:58
const labelList & edgeToDualPoint() const
From edge to dual point (at edge mid; or -1 if not feature.
Definition: meshDualiser.H:274
Direct mesh changes based on v1.3 polyTopoChange syntax.
ClassName("meshDualiser")
Runtime type information.
void operator=(const meshDualiser &)=delete
No copy assignment.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:76
const labelList & cellToDualPoint() const
From cell to dual point (at cell centre). All cells become.
Definition: meshDualiser.H:254
Namespace for OpenFOAM.