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/>.
25 Foam::extendedFeatureEdgeMesh
29 Description of feature edges and points.
31 Feature points are a sorted subset at the start of the overall points list:
32 0 .. concaveStart_-1 : convex points (w.r.t normals)
33 concaveStart_-1 .. mixedStart_-1 : concave points
34 mixedStart_ .. nonFeatureStart_ : mixed internal/external points
35 nonFeatureStart_ .. size-1 : non-feature points
37 Feature edges are the edgeList of the edgeMesh and are sorted:
38 0 .. internalStart_-1 : external edges (convex w.r.t normals)
39 internalStart_ .. flatStart_-1 : internal edges (concave)
40 flatStart_ .. openStart_-1 : flat edges (neither concave or convex)
41 can arise from region interfaces on
43 openStart_ .. multipleStart_-1 : open edges (e.g. from baffle surfaces)
44 multipleStart_ .. size-1 : multiply connected edges
46 The edge direction and feature edge and feature point adjacent normals
50 extendedFeatureEdgeMeshI.H
51 extendedFeatureEdgeMesh.C
53 \*---------------------------------------------------------------------------*/
55 #ifndef extendedFeatureEdgeMesh_H
56 #define extendedFeatureEdgeMesh_H
59 #include "surfaceFeatures.H"
60 #include "objectRegistry.H"
61 #include "IOdictionary.H"
62 #include "indexedOctree.H"
63 #include "treeDataEdge.H"
64 #include "pointIndexHit.H"
66 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
71 /*---------------------------------------------------------------------------*\
72 Class extendedFeatureEdgeMesh Declaration
73 \*---------------------------------------------------------------------------*/
75 class extendedFeatureEdgeMesh
83 //- Runtime type information
84 TypeName("extendedFeatureEdgeMesh");
88 CONVEX, // Fully convex point (w.r.t normals)
89 CONCAVE, // Fully concave point
90 MIXED, // A point surrounded by both convex and concave edges
91 NONFEATURE // Not a feature point
96 EXTERNAL, // "Convex" edge
97 INTERNAL, // "Concave" edge
98 FLAT, // Neither concave or convex, on a flat surface
99 OPEN, // i.e. only connected to one face
100 MULTIPLE, // Multiply connected (connected to more than two faces)
101 NONE // Not a classified feature edge (consistency with
109 //- Angular closeness tolerance for treating normals as the same
110 static scalar cosNormalAngleTol_;
112 //- Index of the start of the convex feature points - static as 0
113 static label convexStart_;
115 //- Index of the start of the external feature edges - static as 0
116 static label externalStart_;
121 //- Index of the start of the concave feature points
124 //- Index of the start of the mixed type feature points
127 //- Index of the start of the non-feature points
128 label nonFeatureStart_;
130 //- Index of the start of the internal feature edges
131 label internalStart_;
133 //- Index of the start of the flat feature edges
136 //- Index of the start of the open feature edges
139 //- Index of the start of the multiply-connected feature edges
140 label multipleStart_;
142 //- Normals of the features, to be referred to by index by both feature
143 // points and edges, unsorted
144 vectorField normals_;
146 //- Flat and open edges require the direction of the edge
147 vectorField edgeDirections_;
149 //- Indices of the normals that are adjacent to the feature edges
150 labelListList edgeNormals_;
152 //- Indices of the normals that are adjacent to the feature points
153 labelListList featurePointNormals_;
155 //- Feature edges which are on the boundary between regions
156 labelList regionEdges_;
158 //- Search tree for all edges
159 mutable autoPtr<indexedOctree<treeDataEdge> > edgeTree_;
161 //- Individual search trees for each type of edge
162 mutable PtrList<indexedOctree<treeDataEdge> > edgeTreesByType_;
165 // Private Member Functions
167 //- Classify the type of feature point. Requires valid stored member
168 // data for edges and normals.
169 pointStatus classifyFeaturePoint(label ptI) const;
171 //- Classify the type of feature edge. Requires face centre 0 to face
172 // centre 1 vector to distinguish internal from external
173 edgeStatus classifyEdge
175 const List<vector>& norms,
176 const labelList& edNorms,
177 const vector& fC0tofC1
185 //- Number of possible point types (i.e. number of slices)
186 static label nPointTypes;
188 //- Number of possible feature edge types (i.e. number of slices)
189 static label nEdgeTypes;
193 //- Construct (read) given an IOobject
194 extendedFeatureEdgeMesh(const IOobject&);
196 //- Construct as copy
197 explicit extendedFeatureEdgeMesh
200 const extendedFeatureEdgeMesh&
203 //- Construct by transferring components (points, edges)
204 extendedFeatureEdgeMesh
207 const Xfer<pointField>&,
208 const Xfer<edgeList>&
211 //- Construct (read) given surfaceFeatures, an objectRegistry and a
212 // fileName to write to. Extracts, classifies and reorders the data
213 // from surfaceFeatures.
214 extendedFeatureEdgeMesh
216 const surfaceFeatures& sFeat,
217 const objectRegistry& obr,
218 const fileName& sFeatFileName
221 //- Construct from all components
222 extendedFeatureEdgeMesh
225 const pointField& pts,
229 label nonFeatureStart,
234 const vectorField& normals,
235 const vectorField& edgeDirections,
236 const labelListList& edgeNormals,
237 const labelListList& featurePointNormals,
238 const labelList& regionEdges
243 ~extendedFeatureEdgeMesh();
250 //- Find nearest surface edge for the sample point.
251 void nearestFeatureEdge
254 scalar searchDistSqr,
258 //- Find nearest surface edge for each sample point.
259 void nearestFeatureEdge
261 const pointField& samples,
262 const scalarField& searchDistSqr,
263 List<pointIndexHit>& info
266 //- Find the nearest point on each type of feature edge
267 void nearestFeatureEdgeByType
270 const scalarField& searchDistSqr,
271 List<pointIndexHit>& info
276 //- Return the index of the start of the convex feature points
277 inline label convexStart() const;
279 //- Return the index of the start of the concave feature points
280 inline label concaveStart() const;
282 //- Return the index of the start of the mixed type feature points
283 inline label mixedStart() const;
285 //- Return the index of the start of the non-feature points
286 inline label nonFeatureStart() const;
288 //- Return the index of the start of the external feature edges
289 inline label externalStart() const;
291 //- Return the index of the start of the internal feature edges
292 inline label internalStart() const;
294 //- Return the index of the start of the flat feature edges
295 inline label flatStart() const;
297 //- Return the index of the start of the open feature edges
298 inline label openStart() const;
300 //- Return the index of the start of the multiply-connected feature
302 inline label multipleStart() const;
304 //- Return whether or not the point index is a feature point
305 inline bool featurePoint(label ptI) const;
307 //- Return the normals of the surfaces adjacent to the feature edges
309 inline const vectorField& normals() const;
311 //- Return the edgeDirection vectors
312 inline const vectorField& edgeDirections() const;
314 //- Return the direction of edgeI, pointing away from ptI
315 inline vector edgeDirection(label edgeI, label ptI) const;
317 //- Return the indices of the normals that are adjacent to the
319 inline const labelListList& edgeNormals() const;
321 //- Return the normal vectors for a given set of normal indices
322 inline vectorField edgeNormals(const labelList& edgeNormIs) const;
324 //- Return the normal vectors for a given edge
325 inline vectorField edgeNormals(label edgeI) const;
327 //- Return the indices of the normals that are adjacent to the
329 inline const labelListList& featurePointNormals() const;
331 //- Return the normal vectors for a given feature point
332 inline vectorField featurePointNormals(label ptI) const;
334 //- Return the feature edges which are on the boundary between
336 inline const labelList& regionEdges() const;
338 //- Return the pointStatus of a specified point
339 inline pointStatus getPointStatus(label ptI) const;
341 //- Return the edgeStatus of a specified edge
342 inline edgeStatus getEdgeStatus(label edgeI) const;
344 //- Demand driven construction of octree for boundary edges
345 const indexedOctree<treeDataEdge>& edgeTree() const;
347 //- Demand driven construction of octree for boundary edges by type
348 const PtrList<indexedOctree<treeDataEdge> >&
349 edgeTreesByType() const;
354 //- Write all components of the extendedFeatureEdgeMesh as obj files
355 void writeObj(const fileName& prefix) const;
357 //- Give precedence to the regIOobject write
358 using regIOobject::write;
360 //- WriteData function required for regIOobject write operation
361 virtual bool writeData(Ostream&) const;
365 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
367 } // End namespace Foam
369 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
371 #include "extendedFeatureEdgeMeshI.H"
373 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
377 // ************************************************************************* //