File size: 18,791 Bytes
5a600cf | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 | /*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2025 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::extendedEdgeMesh
Description
Description of feature edges and points.
Feature points are a sorted subset at the start of the overall points list:
0 .. concaveStart_-1 : convex points (w.r.t normals)
concaveStart_ .. mixedStart_-1 : concave points
mixedStart_ .. nonFeatureStart_-1 : mixed internal/external points
nonFeatureStart_ .. size-1 : non-feature points
Feature edges are the edgeList of the edgeMesh and are sorted:
0 .. internalStart_-1 : external edges (convex w.r.t normals)
internalStart_ .. flatStart_-1 : internal edges (concave)
flatStart_ .. openStart_-1 : flat edges (neither concave or convex)
can arise from region interfaces on
flat surfaces
openStart_ .. multipleStart_-1 : open edges (e.g. from baffle surfaces)
multipleStart_ .. size-1 : multiply connected edges
The edge direction and feature edge and feature point adjacent normals
are stored.
SourceFiles
extendedEdgeMeshI.H
extendedEdgeMesh.C
extendedEdgeMeshNew.C
\*---------------------------------------------------------------------------*/
#ifndef extendedEdgeMesh_H
#define extendedEdgeMesh_H
#include "edgeMesh.H"
#include "indexedOctree.H"
#include "treeDataEdge.H"
#include "treeDataPoint.H"
#include "PrimitivePatch.H"
#include "pointIndexHitList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class surfaceFeatures;
class objectRegistry;
// Forward declaration of friend functions and operators
class extendedEdgeMesh;
Istream& operator>>(Istream&, extendedEdgeMesh&);
Ostream& operator<<(Ostream&, const extendedEdgeMesh&);
/*---------------------------------------------------------------------------*\
Class extendedEdgeMesh Declaration
\*---------------------------------------------------------------------------*/
class extendedEdgeMesh
:
public edgeMesh
{
public:
//- Runtime type information
TypeName("extendedEdgeMesh");
enum pointStatus
{
CONVEX, // Fully convex point (w.r.t normals)
CONCAVE, // Fully concave point
MIXED, // A point surrounded by both convex and concave edges
NONFEATURE // Not a feature point
};
static const Foam::NamedEnum<pointStatus, 4> pointStatusNames_;
enum edgeStatus
{
EXTERNAL, // "Convex" edge
INTERNAL, // "Concave" edge
FLAT, // Neither concave nor convex, on a flat surface
OPEN, // i.e. only connected to one face
MULTIPLE, // Multiply connected (connected to more than two faces)
NONE // Not a classified feature edge (consistency with
// surfaceFeatures)
};
static const Foam::NamedEnum<edgeStatus, 6> edgeStatusNames_;
//- Normals point to the outside
enum sideVolumeType
{
INSIDE = 0, // mesh inside
OUTSIDE = 1, // mesh outside
BOTH = 2, // e.g. a baffle
NEITHER = 3 // not sure when this may be used
};
static const Foam::NamedEnum<sideVolumeType, 4> sideVolumeTypeNames_;
//- Angular closeness tolerance for treating normals as the same
static scalar cosNormalAngleTol_;
protected:
// Static data
//- Index of the start of the convex feature points - static as 0
static label convexStart_;
//- Index of the start of the external feature edges - static as 0
static label externalStart_;
// Protected data
//- Index of the start of the concave feature points
label concaveStart_;
//- Index of the start of the mixed type feature points
label mixedStart_;
//- Index of the start of the non-feature points
label nonFeatureStart_;
//- Index of the start of the internal feature edges
label internalStart_;
//- Index of the start of the flat feature edges
label flatStart_;
//- Index of the start of the open feature edges
label openStart_;
//- Index of the start of the multiply-connected feature edges
label multipleStart_;
//- Normals of the features, to be referred to by index by both feature
// points and edges, unsorted
vectorField normals_;
//- Type per normal: which side of normal to mesh
List<sideVolumeType> normalVolumeTypes_;
//- Flat and open edges require the direction of the edge
vectorField edgeDirections_;
//- Starting directions for the edges.
// This vector points to the half of the plane defined by the first
// edge normal.
labelListList normalDirections_;
//- Indices of the normals that are adjacent to the feature edges
labelListList edgeNormals_;
//- Indices of the normals that are adjacent to the feature points
// (only valid for 0..nonFeatureStart_-1)
labelListList featurePointNormals_;
//- Indices of feature edges attached to feature points. The edges are
// ordered so that they can be circulated.
labelListList featurePointEdges_;
//- Feature edges which are on the boundary between regions
labelList regionEdges_;
//- Search tree for all feature points
mutable autoPtr<indexedOctree<treeDataPoint>> pointTree_;
//- Search tree for all edges
mutable autoPtr<indexedOctree<treeDataEdge>> edgeTree_;
//- Individual search trees for each type of edge
mutable PtrList<indexedOctree<treeDataEdge>> edgeTreesByType_;
// Protected Member Functions
//- Classify the type of feature point. Requires valid stored member
// data for edges and normals.
pointStatus classifyFeaturePoint(label ptI) const;
template<class Patch>
void sortPointsAndEdges
(
const Patch&,
const labelList& featureEdges,
const labelList& regionFeatureEdges,
const labelList& feaurePoints
);
public:
// Static data
//- Number of possible point types (i.e. number of slices)
static label nPointTypes;
//- Number of possible feature edge types (i.e. number of slices)
static label nEdgeTypes;
//- Can we read this file format?
static bool canRead(const fileName&, const bool verbose=false);
//- Can we read this file format?
static bool canReadType(const word& ext, const bool verbose=false);
//- Can we write this file format type?
static bool canWriteType(const word& ext, const bool verbose=false);
static wordHashSet readTypes();
static wordHashSet writeTypes();
// Constructors
//- Construct null
extendedEdgeMesh();
//- Copy constructor
explicit extendedEdgeMesh(const extendedEdgeMesh&);
//- Move constructor
explicit extendedEdgeMesh(extendedEdgeMesh&&);
//- Construct from file name (uses extension to determine type)
extendedEdgeMesh(const fileName&);
//- Construct from file name (uses extension to determine type)
extendedEdgeMesh(const fileName&, const word& ext);
//- Construct from Istream
extendedEdgeMesh(Istream&);
//- Construct by transferring components (points, edges)
extendedEdgeMesh
(
pointField&&,
edgeList&&
);
//- Construct given a surface with selected edges,points
// (surfaceFeatures)
// Extracts, classifies and reorders the data from surfaceFeatures.
extendedEdgeMesh
(
const surfaceFeatures& sFeat,
const boolList& surfBaffleRegions
);
//- Construct from PrimitivePatch
extendedEdgeMesh
(
const PrimitivePatch<faceList, pointField>& surf,
const labelList& featureEdges,
const labelList& regionFeatureEdges,
const labelList& featurePoints
);
//- Construct from all components
extendedEdgeMesh
(
const pointField& pts,
const edgeList& eds,
label concaveStart,
label mixedStart,
label nonFeatureStart,
label internalStart,
label flatStart,
label openStart,
label multipleStart,
const vectorField& normals,
const List<sideVolumeType>& normalVolumeTypes,
const vectorField& edgeDirections,
const labelListList& normalDirections,
const labelListList& edgeNormals,
const labelListList& featurePointNormals,
const labelListList& featurePointEdges,
const labelList& regionEdges
);
// Declare run-time constructor selection table
declareRunTimeSelectionTable
(
autoPtr,
extendedEdgeMesh,
fileExtension,
(
const fileName& name
),
(name)
);
// Selectors
//- Select constructed from filename (explicit extension)
static autoPtr<extendedEdgeMesh> New
(
const fileName&,
const word& ext
);
//- Select constructed from filename (implicit extension)
static autoPtr<extendedEdgeMesh> New(const fileName&);
//- Destructor
~extendedEdgeMesh();
// Member Functions
// Find
//- Find nearest surface edge for the sample point.
void nearestFeaturePoint
(
const point& sample,
scalar searchDistSqr,
pointIndexHit& info
) const;
//- Find nearest surface edge for the sample point.
void nearestFeatureEdge
(
const point& sample,
scalar searchDistSqr,
pointIndexHit& info
) const;
//- Find nearest surface edge for each sample point.
void nearestFeatureEdge
(
const pointField& samples,
const scalarField& searchDistSqr,
pointIndexHitList& info
) const;
//- Find the nearest point on each type of feature edge
void nearestFeatureEdgeByType
(
const point& sample,
const scalarField& searchDistSqr,
pointIndexHitList& info
) const;
//- Find all the feature points within searchDistSqr of sample
void allNearestFeaturePoints
(
const point& sample,
scalar searchRadiusSqr,
pointIndexHitList& info
) const;
//- Find all the feature edges within searchDistSqr of sample
void allNearestFeatureEdges
(
const point& sample,
const scalar searchRadiusSqr,
pointIndexHitList& info
) const;
//- Return the minimum distance between disconnected edges
scalar minDisconnectedDist(const pointIndexHitList& hitList) const;
// Access
//- Return the index of the start of the convex feature points
inline label convexStart() const;
//- Return the index of the start of the concave feature points
inline label concaveStart() const;
//- Return the index of the start of the mixed type feature points
inline label mixedStart() const;
//- Return the index of the start of the non-feature points
inline label nonFeatureStart() const;
//- Return the index of the start of the external feature edges
inline label externalStart() const;
//- Return the index of the start of the internal feature edges
inline label internalStart() const;
//- Return the index of the start of the flat feature edges
inline label flatStart() const;
//- Return the index of the start of the open feature edges
inline label openStart() const;
//- Return the index of the start of the multiply-connected feature
// edges
inline label multipleStart() const;
//- Return whether or not the point index is a feature point
inline bool featurePoint(label ptI) const;
//- Return the normals of the surfaces adjacent to the feature edges
// and points
inline const vectorField& normals() const;
//- Return
inline const List<sideVolumeType>& normalVolumeTypes() const;
//- Return the edgeDirection vectors
inline const vectorField& edgeDirections() const;
//-
inline const labelListList& normalDirections() const;
//- Return the direction of edgeI, pointing away from ptI
inline vector edgeDirection(label edgeI, label ptI) const;
//- Return the indices of the normals that are adjacent to the
// feature edges
inline const labelListList& edgeNormals() const;
//- Return the normal vectors for a given set of normal indices
inline vectorField edgeNormals(const labelList& edgeNormIs) const;
//- Return the normal vectors for a given edge
inline vectorField edgeNormals(label edgeI) const;
//- Return the indices of the normals that are adjacent to the
// feature points
inline const labelListList& featurePointNormals() const;
//- Return the normal vectors for a given feature point
inline vectorField featurePointNormals(label ptI) const;
//- Return the edge labels for a given feature point. Edges are
// ordered by the faces that they share. The edge labels
// correspond to the entry in edges().
inline const labelListList& featurePointEdges() const;
//- Return the feature edges which are on the boundary between
// regions
inline const labelList& regionEdges() const;
//- Return the pointStatus of a specified point
inline pointStatus getPointStatus(label ptI) const;
//- Return the edgeStatus of a specified edge
inline edgeStatus getEdgeStatus(label edgeI) const;
//- Return the baffle faces of a specified edge
inline PackedList<2> edgeBaffles(label edgeI) const;
//- Demand driven construction of octree for feature points
const indexedOctree<treeDataPoint>& pointTree() const;
//- Demand driven construction of octree for boundary edges
const indexedOctree<treeDataEdge>& edgeTree() const;
//- Demand driven construction of octree for boundary edges by type
const PtrList<indexedOctree<treeDataEdge>>&
edgeTreesByType() const;
// Edit
//- Transfer the contents of the argument and annul the argument
void transfer(extendedEdgeMesh&);
//- Clear all storage
virtual void clear();
//- Add extendedEdgeMesh. No filtering of duplicates.
void add(const extendedEdgeMesh&);
//- Flip normals. All concave become convex, all internal external
// etc.
void flipNormals();
// Read
//- Read from file. Chooses reader based on explicit extension
bool read(const fileName&, const word& ext);
//- Read from file. Chooses reader based on detected extension
virtual bool read(const fileName&);
// Write
//- Write all components of the extendedEdgeMesh as obj files
void writeObj
(
const fileName& prefix,
const bool verbose = true
) const;
//- Dump some information
virtual void writeStats(Ostream& os) const;
friend Istream& operator>>(Istream& is, sideVolumeType& vt);
friend Ostream& operator<<(Ostream& os, const sideVolumeType& vt);
//- Classify the type of feature edge. Requires face centre 0 to face
// centre 1 vector to distinguish internal from external
static edgeStatus classifyEdge
(
const List<vector>& norms,
const labelList& edNorms,
const vector& fC0tofC1
);
// IOstream Operators
friend Ostream& operator<<(Ostream&, const extendedEdgeMesh&);
friend Istream& operator>>(Istream&, extendedEdgeMesh&);
};
Istream& operator>>(Istream& is, extendedEdgeMesh::sideVolumeType& vt);
Ostream& operator<<(Ostream& os, const extendedEdgeMesh::sideVolumeType& vt);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "extendedEdgeMeshI.H"
#ifdef NoRepository
#include "extendedEdgeMeshTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
|