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