1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. 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 "PrimitivePatchTemplate.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");
204 const bMesh& mesh() const
208 FatalErrorIn("boundaryMesh::mesh()")
209 << "No mesh available. Probably mesh not yet"
210 << " read." << abort(FatalError);
215 const PtrList<boundaryPatch>& patches() const
221 //- Label of original face in polyMesh (before patchify(...))
222 const labelList& meshFace() const
228 const pointField& featurePoints() const
230 return featurePoints_;
233 //- Feature edges. Indices into featurePoints.
234 const edgeList& featureEdges() const
236 return featureEdges_;
239 //- From index into featureEdge to index into meshedges,
240 const labelList& featureToEdge() const
242 return featureToEdge_;
245 //- From edge into featureEdges
246 const labelList& edgeToFeature() const
248 return edgeToFeature_;
251 //- Lists of connected featureEdges. Indices into featureEdges.
252 const labelListList& featureSegments() const
254 return featureSegments_;
257 //- Indices into edges of additional edges.
258 const labelList& extraEdges() const
266 //- Read from boundaryMesh of polyMesh.
267 void read(const polyMesh&);
269 //- Read from triSurface
270 void readTriSurface(const fileName&);
273 void writeTriSurface(const fileName&) const;
275 //- Get bMesh index of nearest face for every boundary face in
276 // pMesh. Gets passed initial search box. If not found
277 // returns -1 for the face.
280 const primitiveMesh& pMesh,
281 const vector& searchSpan
284 //- Take over patches onto polyMesh from nearest face in *this
285 // (from call to getNearest). Insert as
286 // -new set of patches (newMesh.addPatches)
287 // -topoChanges to change faces.
288 // nearest is list of nearest face in *this for every boundary
289 // face. oldPatches is list of existing patches in mesh.
290 // newMesh is the mesh to which the new patches are added.
291 // (so has to be constructed without patches).
294 const labelList& nearest,
295 const polyBoundaryMesh& oldPatches,
301 //- Get index of patch face is in
302 label whichPatch(const label faceI) const;
304 //- Get index of patch by name
305 label findPatchID(const word& patchName) const;
307 //- Get names of patches
308 wordList patchNames() const;
310 //- Add to back of patch list.
311 void addPatch(const word& patchName);
313 //- Delete from patch list.
314 void deletePatch(const word& patchName);
317 void changePatchType(const word& patchName, const word& type);
319 //- Recalculate face ordering and patches. Return old to new
321 void changeFaces(const labelList& patchIDs, labelList& oldToNew);
326 //- Set featureEdges, edgeToFeature, featureSegments according
327 // to angle of faces across edge
328 void setFeatureEdges(const scalar minCos);
330 //- Set extraEdges to edges 'near' to edgeI. Uses point-edge walk
331 // to determine 'near'.
332 void setExtraEdges(const label edgeI);
337 //- Simple triangulation of face subset. Returns number of triangles
339 label getNTris(const label faceI) const;
341 //- Simple triangulation of face subset. TotalNTris is total number
342 // of triangles, nTris is per face number of triangles.
345 const label startFaceI,
350 //- Simple triangulation of face subset. TotalNTris is total number
351 // of triangles (from call to getNTris)
352 // triVerts is triangle vertices, three per triangle.
355 const label startFaceI,
357 const label totalNTris,
361 //- Number of points used in face subset.
362 label getNPoints(const label startFaceI, const label nFaces) const;
364 //- Same as triangulate but in local vertex numbering.
366 void triangulateLocal
368 const label startFaceI,
370 const label totalNTris,
372 labelList& localToGlobal
377 // Flood filling without crossing protected edges.
380 const labelList& protectedEdges,
387 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
389 } // End namespace Foam
391 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
395 // ************************************************************************* //