44 const Foam::scalar Foam::featurePointConformer::tolParallel = 1
e-3;
49 Foam::vector Foam::featurePointConformer::sharedFaceNormal
51 const extendedFeatureEdgeMesh& feMesh,
56 const labelList& edgeInormals = feMesh.edgeNormals()[edgeI];
57 const labelList& nextEdgeInormals = feMesh.edgeNormals()[nextEdgeI];
59 const vector& A1 = feMesh.normals()[edgeInormals[0]];
60 const vector& A2 = feMesh.normals()[edgeInormals[1]];
62 const vector& B1 = feMesh.normals()[nextEdgeInormals[0]];
63 const vector& B2 = feMesh.normals()[nextEdgeInormals[1]];
70 const scalar A1B1 =
mag((A1 & B1) - 1.0);
71 const scalar A1B2 =
mag((A1 & B2) - 1.0);
72 const scalar A2B1 =
mag((A2 & B1) - 1.0);
73 const scalar A2B2 =
mag((A2 & B2) - 1.0);
80 if (A1B1 < A1B2 && A1B1 < A2B1 && A1B1 < A2B2)
84 else if (A1B2 < A1B1 && A1B2 < A2B1 && A1B2 < A2B2)
88 else if (A2B1 < A1B1 && A2B1 < A1B2 && A2B1 < A2B2)
117 void Foam::featurePointConformer::addMasterAndSlavePoints
119 const DynamicList<Foam::point>& masterPoints,
120 const DynamicList<Foam::indexedVertexEnum::vertexType>& masterPointsTypes,
121 const Map<DynamicList<autoPtr<plane>>>& masterPointReflections,
122 DynamicList<Vb>& pts,
126 typedef DynamicList<autoPtr<plane>> planeDynList;
134 const vertexType masterType = masterPointsTypes[pI];
143 foamyHexMesh_.vertexCount() + pts.
size(),
149 const label masterIndex = pts.last().index();
153 const planeDynList& masterPointPlanes = masterPointReflections[pI];
155 forAll(masterPointPlanes, planeI)
159 const plane& reflPlane = masterPointPlanes[planeI]();
161 const Foam::point slavePt = reflPlane.mirror(masterPt);
165 const vertexType slaveType =
167 masterType == Vb::vtInternalFeaturePoint
169 : Vb::vtInternalFeaturePoint
177 foamyHexMesh_.vertexCount() + pts.size(),
183 ftPtPairs_.addPointPair
195 void Foam::featurePointConformer::createMasterAndSlavePoints
197 const extendedFeatureEdgeMesh& feMesh,
202 typedef DynamicList<autoPtr<plane>> planeDynList;
212 && !foamyHexMesh_.decomposition().positionOnThisProcessor(featPt)
214 || geometryToConformTo_.outside(featPt)
220 const scalar ppDist = foamyHexMesh_.pointPairDistance(featPt);
223 DynamicList<Foam::point> masterPoints;
224 DynamicList<vertexType> masterPointsTypes;
225 Map<planeDynList> masterPointReflections;
227 const labelList& featPtEdges = feMesh.featurePointEdges()[ptI];
229 pointFeatureEdgesTypes pointEdgeTypes(feMesh, ptI);
231 const List<extendedFeatureEdgeMesh::edgeStatus> allEdStat =
232 pointEdgeTypes.calcPointFeatureEdgesTypes();
236 ConstCirculator<labelList> circ(featPtEdges);
242 const edgeStatus eStatusCurr = feMesh.getEdgeStatus(circ());
255 label sign = getSign(eStatusCurr);
257 const vector n = sharedFaceNormal(feMesh, circ(), circ.next());
259 const vector pointMotionDirection = sign*0.5*ppDist*
n;
265 if (masterPoints.empty())
270 planeDynList firstPlane;
271 firstPlane.append(autoPtr<plane>(
new plane(featPt, n)));
273 masterPoints.append(pt);
275 masterPointsTypes.append
279 : Vb::vtInternalFeaturePoint
290 masterPointReflections.insert
292 masterPoints.size() - 1,
335 masterPoints.last() += pointMotionDirection;
337 masterPointReflections[masterPoints.size() - 1].append
339 autoPtr<plane>(
new plane(featPt, n))
345 addMasterAndSlavePoints
349 masterPointReflections,
356 void Foam::featurePointConformer::createMixedFeaturePoints
361 if (foamyHexMeshControls_.mixedFeaturePointPPDistanceCoeff() < 0)
364 <<
"Skipping specialised handling for mixed feature points" <<
endl;
369 const PtrList<extendedFeatureEdgeMesh>& feMeshes
371 geometryToConformTo_.features()
376 const extendedFeatureEdgeMesh& feMesh = feMeshes[i];
382 label ptI = feMesh.mixedStart();
383 ptI < feMesh.nonFeatureStart();
392 && !foamyHexMesh_.decomposition().positionOnThisProcessor(featPt))
397 const labelList& pEds = pointsEdges[ptI];
399 pointFeatureEdgesTypes pFEdgeTypes(feMesh, ptI);
401 const List<extendedFeatureEdgeMesh::edgeStatus> allEdStat =
402 pFEdgeTypes.calcPointFeatureEdgesTypes();
404 bool specialisedSuccess =
false;
406 if (foamyHexMeshControls_.specialiseFeaturePoints())
409 createSpecialisedFeaturePoint
411 feMesh, pEds, pFEdgeTypes, allEdStat, ptI, pts
415 if (!specialisedSuccess && foamyHexMeshControls_.edgeAiming())
457 const scalar edgeGroupDistance =
458 foamyHexMesh_.mixedFeaturePointDistance(pt);
462 const label edgeI = pEds[
e];
465 pt + edgeGroupDistance*feMesh.edgeDirection(edgeI, ptI);
469 foamyHexMesh_.createEdgePointGroup(feMesh, edgeHit, pts);
477 void Foam::featurePointConformer::createFeaturePoints(DynamicList<Vb>& pts)
479 const PtrList<extendedFeatureEdgeMesh>& feMeshes
481 geometryToConformTo_.features()
486 const extendedFeatureEdgeMesh& feMesh(feMeshes[i]);
490 label ptI = feMesh.convexStart();
491 ptI < feMesh.mixedStart();
496 createMasterAndSlavePoints(feMesh, ptI, pts);
499 if (foamyHexMeshControls_.guardFeaturePoints())
504 label ptI = feMesh.mixedStart();
505 ptI < feMesh.nonFeatureStart();
513 feMesh.points()[ptI],
525 Foam::featurePointConformer::featurePointConformer
527 const conformalVoronoiMesh& foamyHexMesh
530 foamyHexMesh_(foamyHexMesh),
531 foamyHexMeshControls_(foamyHexMesh.foamyHexMeshControls()),
532 geometryToConformTo_(foamyHexMesh.geometryToConformTo()),
533 featurePointVertices_(),
534 ftPtPairs_(foamyHexMesh)
537 <<
"Conforming to feature points" <<
endl;
540 <<
indent <<
"Circulating edges is: " 542 <<
indent <<
"Guarding feature points is: " 544 <<
indent <<
"Snapping to feature points is: " 546 <<
indent <<
"Specialising feature points is: " 553 createFeaturePoints(pts);
555 createMixedFeaturePoints(pts);
582 featurePointVertices_.transfer(pts);
596 const backgroundMeshDecomposition& decomposition
600 decomposition.distributePoints(featurePointVertices_);
603 forAll(featurePointVertices_, vI)
614 const Map<label>& oldToNewIndices
617 forAll(featurePointVertices_, vI)
619 const label currentIndex = featurePointVertices_[vI].index();
622 oldToNewIndices.find(currentIndex);
624 if (newIndexIter != oldToNewIndices.end())
626 featurePointVertices_[vI].index() = newIndexIter();
630 ftPtPairs_.reIndex(oldToNewIndices);
List< labelList > labelListList
A List of labelList.
bool internalBoundaryPoint() const
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & indent(Ostream &os)
Indent stream.
const double e
Elementary charge.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
Ostream & endl(Ostream &os)
Add newline and flush stream.
HashTable< label, label, Hash< label > >::const_iterator const_iterator
PointIndexHit< point > pointIndexHit
Vector< scalar > vector
A scalar version of the templated Vector.
Switch snapFeaturePoints() const
Switch specialiseFeaturePoints() const
Return whether to use specialised feature points.
An indexed form of CGAL::Triangulation_vertex_base_3<K> used to keep track of the Delaunay vertices i...
Switch guardFeaturePoints() const
vectorField pointField
pointField is a vectorField.
List< label > labelList
A List of labels.
Switch objOutput() const
Return the objOutput Switch.
static direction size()
Return the number of elements in the VectorSpace = Ncmpts.
defineTypeNameAndDebug(combustionModel, 0)
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
static bool & parRun()
Is this a parallel run?
const char * asText() const
Return a text representation of the Switch.
dimensioned< scalar > mag(const dimensioned< Type > &)
Switch circulateEdges() const
Ostream & incrIndent(Ostream &os)
Increment the indent level.
bool externalBoundaryPoint() const