67 pointPatchNormal.clear();
70 # pragma omp parallel for schedule(dynamic, 20)
72 forAll(hairEdges_, hairEdgeI)
74 if( !(hairEdgeType_[hairEdgeI] & eType) )
77 const label bpI = bp[hairEdges_[hairEdgeI][0]];
83 patchNormalPtr = &pointPatchNormal[bpI];
85 patchNormalPtr = &pointPatchNormal[bpI];
92 const label bfI = pointFaces(bpI, pfI);
93 const label patchI = facePatch[bfI];
95 if( patchNormal.find(patchI) == patchNormal.end() )
97 patchNormal[patchI].first = fNormals[bfI];
98 patchNormal[patchI].second =
mag(fNormals[bfI]);
102 patchNormal[patchI].first += fNormals[bfI];
103 patchNormal[patchI].second +=
mag(fNormals[bfI]);
116 std::map<label, LongList<refLabelledPointScalar> > exchangeData;
118 exchangeData[neiProcs[i]].clear();
122 const label bpI = it();
124 if( pointPatchNormal.find(bpI) != pointPatchNormal.end() )
130 const label neiProc = bpAtProcs(bpI, i);
136 exchangeData[neiProc].append
171 # pragma omp parallel
172 # pragma omp single nowait
177 # pragma omp task firstprivate(it)
185 pIt->second.first /= pIt->second.second;
214 Info <<
"Calculating normals using smoother " <<
endl;
217 # pragma omp parallel for schedule(dynamic, 50)
219 forAll(hairEdgeType_, heI)
221 if( !(hairEdgeType_[heI] & eType) )
224 const edge&
he = hairEdges_[heI];
225 const label bpI = bp[
he.start()];
227 const label triPointI = triPointLabel[bpI];
232 # pragma omp critical
233 patchNormalPtr = &pointPatchNormal[bpI];
235 patchNormalPtr = &pointPatchNormal[bpI];
246 triangles[pTriangles(triPointI, ptI)].region()
250 forAll(patchesAtPoint, ptchI)
252 const label patchI = patchesAtPoint[ptchI];
262 bpToSimplex.insert(bpI, 0);
266 const labelledTri& tri = triangles[pTriangles(triPointI, ptI)];
268 if( tri.
region() == patchI )
274 const label spLabel = tri[pI];
275 const label bpLabel = surfPointLabel[spLabel];
279 triLabels[pI] = pts.
size();
280 pts.
append(triMeshPoints[spLabel]);
284 if( !bpToSimplex.found(bpLabel) )
286 bpToSimplex.insert(bpLabel, pts.
size());
287 pts.
append(triMeshPoints[spLabel]);
290 triLabels[pI] = bpToSimplex[bpLabel];
296 partTet(triLabels[2], triLabels[1], triLabels[0], 1)
311 vector n = -1.0 * (newP - pts[0]);
312 const scalar magN = (
mag(
n) + VSMALL);
314 patchNormal[patchI].first = (
n / magN);
315 patchNormal[patchI].second = magN;
319 Info <<
"Finished calculating normals using smoother " <<
endl;
328 hairVecs.setSize(hairEdges_.size());
340 # pragma omp parallel for schedule(dynamic, 50)
342 forAll(hairEdges_, hairEdgeI)
344 const direction hairType = hairEdgeType_[hairEdgeI];
346 if( hairType & BOUNDARY )
348 const edge&
he = hairEdges_[hairEdgeI];
349 vector& hv = hairVecs[hairEdgeI];
352 if( hairType & FEATUREEDGE )
357 else if( hairType & (ATEDGE|ATCORNER) )
364 const label bps = bp[
he.start()];
367 const label beJ = bpEdges(bps, bpeI);
369 if( edges[beJ] ==
he )
379 "boundaryLayerOptimisation::"
380 "calculateHairVectorsAtTheBoundary(vectorField&)"
381 ) <<
"Cannot find hair edge "
387 const face& bf = bFaces[edgeFaces(beI, befI)];
395 "boundaryLayerOptimisation::"
396 "calculateHairVectorsAtTheBoundary(vectorField&)"
397 ) <<
"Cannot find hair edge "
398 << hairEdgeI <<
" in face " << bf
406 vector hev = fNormal ^ ev;
407 hev /= (
mag(hev) + VSMALL);
416 vector hev = fNormal ^ ev;
417 hev /= (
mag(hev) + VSMALL);
427 "boundaryLayerOptimisation::"
428 "calculateHairVectorsAtTheBoundary(vectorField&)"
429 ) <<
"Invalid hair type " <<
label(hairType)
441 const edgeList& edges = mesh_.addressingData().edges();
442 const VRWGraph& pointEdges = mesh_.addressingData().pointEdges();
444 mesh_.addressingData().edgeAtProcs();
446 mesh_.addressingData().globalEdgeLabel();
448 mesh_.addressingData().globalToLocalEdgeAddressing();
450 mesh_.addressingData().edgeNeiProcs();
452 std::map<label, LongList<labelledPoint> > exchangeData;
454 exchangeData[eNeiProcs[i]].clear();
458 const label bpI = it();
462 const label hairEdgeI = hairEdgesAtBndPoint_(bpI, i);
463 const edge&
he = hairEdges_[hairEdgeI];
465 const direction eType = hairEdgeType_[hairEdgeI];
468 if( !(eType & BOUNDARY) )
473 const label edgeI = pointEdges(
he.start(), peI);
475 if(
he == edges[edgeI] )
479 globalEdgeLabel[edgeI],
485 const label neiProc = edgesAtProcs(edgeI, j);
491 exchangeData[neiProc];
507 const edge&
e = edges[edgeI];
510 for(
label pI=0;pI<2;++pI)
512 const label bpI = bp[
e[pI]];
519 const label hairEdgeI = hairEdgesAtBndPoint_(bpI, i);
521 if( hairEdges_[hairEdgeI] ==
e )
538 # pragma omp parallel for schedule(dynamic, 100)
540 forAll(hairVecs, hairEdgeI)
542 if( hairEdgeType_[hairEdgeI] & BOUNDARY )
543 hairVecs[hairEdgeI] /= (
mag(hairVecs[hairEdgeI]) + VSMALL);
547 Info <<
"Saving bnd hair vectors" <<
endl;
548 writeHairEdges(
"bndHairVectors.vtk", (BOUNDARY | ATEDGE), hairVecs);
578 # pragma omp parallel for schedule(dynamic, 50)
584 Info <<
"Smoothing boundary hair vectors" <<
endl;
594 # pragma omp parallel for schedule(dynamic, 50)
598 vector& newNormal = newNormals[hairEdgeI];
608 newNormal += hairVecs[hairEdgeI];
615 const label bps = bp[
he.start()];
619 const face& bf = bFaces[bfI];
634 const label hairEdgeJ =
639 bool useNeighbour(
false);
643 const face& bf = bFaces[edgeFaces[efI]];
656 newNormal += hairVecs[hairEdgeJ];
663 "void boundaryLayerOptimisation::"
664 "optimiseHairNormalsAtTheBoundary(const label)"
665 ) <<
"Cannot smooth hair with type " <<
label(eType)
688 std::map<label, LongList<labelledPoint> > exchangeData;
690 exchangeData[eNeiProcs[i]].clear();
694 const label bpI = it();
713 const label edgeI = pointEdges(
he.start(), peI);
715 if(
he == edges[edgeI] )
719 globalEdgeLabel[edgeI],
725 const label neiProc = edgesAtProcs(edgeI, j);
731 exchangeData[neiProc];
747 const edge&
e = edges[edgeI];
750 for(
label pI=0;pI<2;++pI)
752 const label bpI = bp[
e[pI]];
778 # pragma omp parallel for schedule(dynamic, 100)
784 newNormals[heI] /= (
mag(newNormals[heI]) + VSMALL);
785 newNormals[heI] = 0.5 * (newNormals[heI] + hairVecs[heI]);
786 newNormals[heI] /= (
mag(newNormals[heI]) + VSMALL);
791 hairVecs.transfer(newNormals);
808 # pragma omp parallel for schedule(dynamic, 100)
816 const vector& hv = hairVecs[hairEdgeI];
822 Info <<
"Finished smoothing boundary hair vectors" <<
endl;
846 # pragma omp parallel for schedule(dynamic, 50)
854 vector& hv = hairVecs[hairEdgeI];
863 hv -= pIt->second.first;
871 "void boundaryLayerOptimisation::"
872 "optimiseHairNormalsInside()"
873 ) <<
"No valid patches for boundary point "
877 hv /= (
mag(hv) + VSMALL);
884 hvec /= (
mag(hvec) + VSMALL);
885 hairVecs[hairEdgeI] = hvec;
894 Info <<
"Using existing hair vectors" <<
endl;
897 # pragma omp parallel for schedule(dynamic, 50)
903 hvec /= (
mag(hvec) + VSMALL);
904 hairVecs[hairEdgeI] = hvec;
912 Info <<
"Smoothing internal hair vectors" <<
endl;
922 # pragma omp parallel for schedule(dynamic, 50)
926 vector& newNormal = newNormals[hairEdgeI];
932 const vector& heVec = hairVecs[hairEdgeI];
939 newNormal = hairVecs[hairEdgeI];
945 const label hairEdgeJ =
949 const vector& nhVec = hairVecs[hairEdgeJ];
952 n /= (
mag(
n) + VSMALL);
954 vector newVec = heVec - (heVec &
n) *
n;
955 newVec /= (
mag(newVec) + VSMALL);
963 const edge be(
he[0], nhe[0]);
968 const edge& bndEdge = edges[bpEdges(bpI, bpeI)];
978 newNormal += weight * newVec;
987 const label hairEdgeJ =
997 const edge be(
he[0], nhe[0]);
1002 const edge& bndEdge = edges[bpEdges(bpI, bpeI)];
1012 newNormal += weight * hairVecs[hairEdgeJ];
1019 newNormal = hairVecs[hairEdgeI];
1040 std::map<label, LongList<labelledPoint> > exchangeData;
1042 exchangeData[eNeiProcs[i]].clear();
1046 const label bpI = it();
1061 const label edgeI = pointEdges(
he.start(), peI);
1063 if(
he == edges[edgeI] )
1067 globalEdgeLabel[edgeI],
1073 const label neiProc = edgesAtProcs(edgeI, j);
1079 exchangeData[neiProc];
1095 const edge&
e = edges[edgeI];
1098 for(
label pI=0;pI<2;++pI)
1100 const label bpI = bp[
e[pI]];
1126 # pragma omp parallel for schedule(dynamic, 100)
1128 forAll(newNormals, hairEdgeI)
1131 newNormals[hairEdgeI] /= (
mag(newNormals[hairEdgeI]) + VSMALL);
1135 hairVecs.transfer(newNormals);
1152 # pragma omp parallel for schedule(dynamic, 100)
1160 const vector& hv = hairVecs[hairEdgeI];
1166 Info <<
"Finished smoothing internal hair vectors" <<
endl;