1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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.
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
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/>.
28 Addressing for all faces on surface of mesh. Can either be read
29 from polyMesh or from triSurface. Used for repatching existing meshes.
34 \*---------------------------------------------------------------------------*/
36 #ifndef boundaryMesh_H
37 #define boundaryMesh_H
40 #include "boundaryPatch.H"
41 #include "PrimitivePatch.H"
43 #include "polyPatchList.H"
44 #include "className.H"
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 // Forward declaration of classes
56 /*---------------------------------------------------------------------------*\
57 Class boundaryMesh Declaration
58 \*---------------------------------------------------------------------------*/
64 //- Normal along which to divide faces into categories
65 // (used in getNearest)
66 static const vector splitNormal_;
68 //- Distance to face tolerance for getNearest. Triangles are considered
69 // near if they are nearer than distanceTol_*typDim where typDim is
70 // the largest distance from face centre to one of its vertices.
71 static const scalar distanceTol_;
75 //- All boundary mesh data. Reconstructed every time faces are repatched
78 //- Patches. Reconstructed every time faces are repatched.
79 PtrList<boundaryPatch> patches_;
81 //- For every face in mesh() gives corresponding polyMesh face
82 // (not sensible if mesh read from triSurface)
90 //- points referenced by feature edges.
91 pointField featurePoints_;
93 //- feature edges. Indices into featurePoints.
94 edgeList featureEdges_;
96 //- from feature edge to mesh edge.
97 labelList featureToEdge_;
99 //- from mesh edges to featureEdges_;
100 labelList edgeToFeature_;
102 //- Feature 'segments'. Collections of connected featureEdges.
103 // Indices into featureEdges_.
104 labelListList featureSegments_;
106 //- Additional edges (indices of mesh edges)
107 labelList extraEdges_;
110 // Private Member Functions
112 //- Number of connected feature edges.
113 label nFeatureEdges(label pointI) const;
115 //- Step to next feature edge
116 label nextFeatureEdge(const label edgeI, const label vertI) const;
118 //- Return connected list of feature edges.
119 labelList collectSegment
121 const boolList& isFeaturePoint,
122 const label startEdgeI,
123 boolList& featVisited
126 //- Do point-edge walk to determine nearest (to edgeI). Stops if
127 // distance >= maxDistance. Used to determine edges close to seed
131 const label maxDistance,
133 const label distance,
134 labelList& minDistance,
135 DynamicList<label>& visited
138 //- Get index of polypatch by name
139 label findPatchID(const polyPatchList&, const word&) const;
141 //- Get index of patch for face
142 label whichPatch(const polyPatchList&, const label) const;
144 //- Gets labels of changed faces and propagates them to the edges.
145 // Returns labels of edges changed. Fills edgeRegion of visited edges
146 // with current region.
149 const boolList& regionEdge,
151 const labelList& changedFaces,
152 labelList& edgeRegion
155 //- Reverse of faceToEdge: gets edges and returns faces
159 const labelList& changedEdges,
160 labelList& faceRegion
163 //- Finds area, starting at faceI, delimited by borderEdge. Marks all
164 // faces thus visited with currentZone.
167 const boolList& borderEdge,
174 //- Disallow default bitwise copy construct
175 boundaryMesh(const boundaryMesh&);
177 //- Disallow default bitwise assignment
178 void operator=(const boundaryMesh&);
183 //- Runtime type information
184 ClassName("boundaryMesh");
203 const bMesh& mesh() const
207 FatalErrorIn("boundaryMesh::mesh()")
208 << "No mesh available. Probably mesh not yet"
209 << " read." << abort(FatalError);
214 const PtrList<boundaryPatch>& patches() const
220 //- Label of original face in polyMesh (before patchify(...))
221 const labelList& meshFace() const
227 const pointField& featurePoints() const
229 return featurePoints_;
232 //- Feature edges. Indices into featurePoints.
233 const edgeList& featureEdges() const
235 return featureEdges_;
238 //- From index into featureEdge to index into meshedges,
239 const labelList& featureToEdge() const
241 return featureToEdge_;
244 //- From edge into featureEdges
245 const labelList& edgeToFeature() const
247 return edgeToFeature_;
250 //- Lists of connected featureEdges. Indices into featureEdges.
251 const labelListList& featureSegments() const
253 return featureSegments_;
256 //- Indices into edges of additional edges.
257 const labelList& extraEdges() const
265 //- Read from boundaryMesh of polyMesh.
266 void read(const polyMesh&);
268 //- Read from triSurface
269 void readTriSurface(const fileName&);
272 void writeTriSurface(const fileName&) const;
274 //- Get bMesh index of nearest face for every boundary face in
275 // pMesh. Gets passed initial search box. If not found
276 // returns -1 for the face.
279 const primitiveMesh& pMesh,
280 const vector& searchSpan
283 //- Take over patches onto polyMesh from nearest face in *this
284 // (from call to getNearest). Insert as
285 // -new set of patches (newMesh.addPatches)
286 // -topoChanges to change faces.
287 // nearest is list of nearest face in *this for every boundary
288 // face. oldPatches is list of existing patches in mesh.
289 // newMesh is the mesh to which the new patches are added.
290 // (so has to be constructed without patches).
293 const labelList& nearest,
294 const polyBoundaryMesh& oldPatches,
300 //- Get index of patch face is in
301 label whichPatch(const label faceI) const;
303 //- Get index of patch by name
304 label findPatchID(const word& patchName) const;
306 //- Get names of patches
307 wordList patchNames() const;
309 //- Add to back of patch list.
310 void addPatch(const word& patchName);
312 //- Delete from patch list.
313 void deletePatch(const word& patchName);
316 void changePatchType(const word& patchName, const word& type);
318 //- Recalculate face ordering and patches. Return old to new
320 void changeFaces(const labelList& patchIDs, labelList& oldToNew);
325 //- Set featureEdges, edgeToFeature, featureSegments according
326 // to angle of faces across edge
327 void setFeatureEdges(const scalar minCos);
329 //- Set extraEdges to edges 'near' to edgeI. Uses point-edge walk
330 // to determine 'near'.
331 void setExtraEdges(const label edgeI);
336 //- Simple triangulation of face subset. Returns number of triangles
338 label getNTris(const label faceI) const;
340 //- Simple triangulation of face subset. TotalNTris is total number
341 // of triangles, nTris is per face number of triangles.
344 const label startFaceI,
349 //- Simple triangulation of face subset. TotalNTris is total number
350 // of triangles (from call to getNTris)
351 // triVerts is triangle vertices, three per triangle.
354 const label startFaceI,
356 const label totalNTris,
360 //- Number of points used in face subset.
361 label getNPoints(const label startFaceI, const label nFaces) const;
363 //- Same as triangulate but in local vertex numbering.
365 void triangulateLocal
367 const label startFaceI,
369 const label totalNTris,
371 labelList& localToGlobal
376 // Flood filling without crossing protected edges.
379 const labelList& protectedEdges,
386 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
388 } // End namespace Foam
390 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
394 // ************************************************************************* //