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