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-2015 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
76 
77  //- From point to dual point (or -1 if not feature point).
79 
80  //- From cell to dual point. All cells become point
82 
83  //- From face to dual point (or -1 if not feature face)
85 
86  //- From edge to dual point (or -1 if not feature edge)
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
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
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
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
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
155  (
156  const label faceI,
157  label& fp,
159  ) const;
160 
161  //- Creates boundary faces walking around point on patchI.
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 // ************************************************************************* //
Foam::meshDualiser::faceToDualPoint
const labelList & faceToDualPoint() const
From face to dual point (at face centre; or -1 if not.
Definition: meshDualiser.H:215
Foam::PackedBoolList
A bit-packed bool list.
Definition: PackedBoolList.H:63
Foam::meshDualiser::dumpPolyTopoChange
static void dumpPolyTopoChange(const polyTopoChange &, const fileName &)
boolList.H
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::labelList
List< label > labelList
A List of labels.
Definition: labelList.H:56
typeInfo.H
Foam::DynamicList< label >
Foam::meshDualiser::operator=
void operator=(const meshDualiser &)
Disallow default bitwise assignment.
Foam::meshDualiser::createFacesAroundEdge
void createFacesAroundEdge(const bool splitFace, const PackedBoolList &, const label edgeI, const label startFaceI, polyTopoChange &, boolList &doneEFaces) const
Create internal faces walking around edge.
Foam::meshDualiser::mesh_
const polyMesh & mesh_
Definition: meshDualiser.H:70
Foam::meshDualiser::addBoundaryFace
label addBoundaryFace(const label masterPointI, const label masterEdgeI, const label masterFaceI, const label dualCellI, const label patchI, const DynamicList< label > &verts, polyTopoChange &meshMod) const
Add boundary face.
Foam::meshDualiser::createFaceFromInternalFace
void createFaceFromInternalFace(const label faceI, label &fp, polyTopoChange &) const
Create single internal face from internal face.
Foam::polyTopoChange
Direct mesh changes based on v1.3 polyTopoChange syntax.
Definition: polyTopoChange.H:97
Foam::meshDualiser::addInternalFace
label addInternalFace(const label masterPointI, const label masterEdgeI, const label masterFaceI, const bool edgeOrder, const label dualCell0, const label dualCell1, const DynamicList< label > &verts, polyTopoChange &meshMod) const
Add internal face.
Foam::meshDualiser::findDualCell
label findDualCell(const label cellI, const label pointI) const
Find dual cell given point and cell.
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::meshDualiser::edgeToDualPoint
const labelList & edgeToDualPoint() const
From edge to dual point (at edge mid; or -1 if not feature.
Definition: meshDualiser.H:222
Foam::meshDualiser::meshDualiser
meshDualiser(const meshDualiser &)
Disallow default bitwise copy construct.
Foam::label
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
Foam::meshDualiser::pointToDualPoint_
labelList pointToDualPoint_
From point to dual point (or -1 if not feature point).
Definition: meshDualiser.H:77
Foam::meshDualiser::cellToDualPoint_
labelList cellToDualPoint_
From cell to dual point. All cells become point.
Definition: meshDualiser.H:80
PackedBoolList.H
Foam::meshDualiser::setRefinement
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.
Foam::meshDualiser::checkPolyTopoChange
static void checkPolyTopoChange(const polyTopoChange &)
Foam::meshDualiser::edgeToDualPoint_
labelList edgeToDualPoint_
From edge to dual point (or -1 if not feature edge)
Definition: meshDualiser.H:86
Foam::meshDualiser::generateDualBoundaryEdges
void generateDualBoundaryEdges(const PackedBoolList &, const label pointI, polyTopoChange &)
Helper function to generate dualpoints on all boundary edges.
Foam::meshDualiser::createFacesAroundBoundaryPoint
void createFacesAroundBoundaryPoint(const label patchI, const label patchPointI, const label startFaceI, polyTopoChange &, boolList &donePFaces) const
Creates boundary faces walking around point on patchI.
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::meshDualiser::pointToDualCells
const labelListList & pointToDualCells() const
From point on cell to dual cell. Either single entry or.
Definition: meshDualiser.H:195
Foam::meshDualiser::faceToDualPoint_
labelList faceToDualPoint_
From face to dual point (or -1 if not feature face)
Definition: meshDualiser.H:83
Foam::meshDualiser::ClassName
ClassName("meshDualiser")
Runtime type information.
Foam::meshDualiser::sameDualCell
bool sameDualCell(const label faceI, const label pointI) const
Check that owner and neighbour of face have same dual cell.
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::meshDualiser::pointToDualCells_
labelListList pointToDualCells_
From point on cell to dual cell. Either single entry or.
Definition: meshDualiser.H:74
Foam::meshDualiser::pointToDualPoint
const labelList & pointToDualPoint() const
From point to dual point (or -1 if not feature point).
Definition: meshDualiser.H:201
DynamicList.H
Foam::meshDualiser
Creates dual of polyMesh. Every point becomes a cell (or multiple cells for feature points),...
Definition: meshDualiser.H:66
Foam::meshDualiser::cellToDualPoint
const labelList & cellToDualPoint() const
From cell to dual point (at cell centre). All cells become.
Definition: meshDualiser.H:208