42 void Foam::faceCollapser::insert
45 const label excludeElem,
51 if (elems[i] != excludeElem)
70 label edgeI = edgeLabels[i];
72 const edge&
e = edges[edgeI];
76 (e[0] == v0 && e[1] == v1)
77 || (e[0] == v1 && e[1] == v0)
84 FatalErrorIn(
"findEdge") <<
"Cannot find edge between vertices " << v0
85 <<
" and " << v1 <<
" in edge labels " << edgeLabels
95 void Foam::faceCollapser::filterFace
97 const Map<labelList>& splitEdges,
99 polyTopoChange& meshMod
102 const face&
f = mesh_.faces()[faceI];
103 const labelList& fEdges = mesh_.faceEdges()[faceI];
106 DynamicList<label> newFace(10 * f.size());
115 label fp1 = f.fcIndex(fp);
120 label edgeI =
findEdge(mesh_.edges(), fEdges, v0,
v1);
123 splitEdges.
find(edgeI);
125 if (edgeFnd != splitEdges.end())
133 if (v0 == mesh_.edges()[edgeI].start())
137 newFace.append(extraVerts[i]);
144 newFace.append(extraVerts[i]);
149 face newF(newFace.shrink());
160 if (mesh_.isInternalFace(faceI))
162 nei = mesh_.faceNeighbour()[faceI];
166 patchI = mesh_.boundaryMesh().whichPatch(faceI);
170 label zoneID = mesh_.faceZones().whichZone(faceI);
172 bool zoneFlip =
false;
176 const faceZone& fZone = mesh_.faceZones()[zoneID];
178 zoneFlip = fZone.flipMap()[fZone.whichFace(faceI)];
187 mesh_.faceOwner()[faceI],
220 const edgeList& edges = mesh_.edges();
221 const faceList& faces = mesh_.faces();
240 const label faceI = faceLabels[i];
242 const face& f = faces[faceI];
244 const label fpA = fpStart[i];
245 const label fpB = fpEnd[i];
247 const point& pA = points[f[fpA]];
248 const point& pB = points[f[fpB]];
250 Pout<<
"Face:" << f <<
" collapsed to fp:" << fpA <<
' ' << fpB
251 <<
" with points:" << pA <<
' ' << pB
263 dist[fpB] =
magSqr(pB - pA);
270 label fp = f.fcIndex(fpMin1);
279 if (w <= dist[fpMin1])
282 w = dist[fpMin1] + 1
E-6*(dist[fpB] - dist[fpA]);
286 pA +
Foam::sqrt(w / (dist[fpB] - dist[fpA]))*(pB - pA)
289 Pout<<
"Adapting position of vertex " << f[fp] <<
" on face "
290 << f <<
" from " << near.
rawPoint() <<
" to " << newPoint
323 fp = f.rcIndex(fpMin1);
332 if (w <= dist[fpMin1])
335 w = dist[fpMin1] + 1
E-6*(dist[fpB] - dist[fpA]);
339 pA +
Foam::sqrt(w / (dist[fpB] - dist[fpA]))*(pB - pA)
342 Pout<<
"Adapting position of vertex " << f[fp] <<
" on face "
343 << f <<
" from " << near.
rawPoint() <<
" to " << newPoint
376 OFstream str(
"conflictingFace.obj");
380 <<
"Trying to collapse face:" << faceI <<
" vertices:" << f
381 <<
" to edges between vertices " << f[fpA] <<
" and "
382 << f[fpB] <<
" but " << f[fpB] <<
" does not seem to be the"
383 <<
" vertex furthest away from " << f[fpA] << endl
384 <<
"Dumped conflicting face to obj file conflictingFace.obj"
390 Pout<<
"Face:" << f <<
" fpA:" << fpA <<
" fpB:" << fpB <<
nl;
397 Pout<<
" fp:" << fp <<
" distance:" << dist[i] <<
nl;
402 const labelList& fEdges = mesh_.faceEdges()[faceI];
412 label fp1 = f.fcIndex(fp);
415 label sorted0 = sortedFp[fp];
416 label sorted1 = sortedFp[fp1];
424 if (sorted0 < sorted1)
428 for (label j = sorted0+1; j < sorted1; j++)
437 for (label j = sorted1+1; j < sorted0; j++)
443 if (edgePoints.size())
447 label edgeI =
findEdge(edges, fEdges, f[fp], f[fp1]);
449 const edge& e = edges[edgeI];
451 if (fpToFp1 == (f[fp] == e.
start()))
453 splitEdges.insert(edgeI, edgePoints);
458 splitEdges.insert(edgeI, edgePoints);
462 insert(edgeFaces[edgeI], faceI, affectedFaces);
470 iter != splitEdges.end();
474 Pout<<
"Split edge:" << iter.key()
475 <<
" verts:" << mesh_.edges()[iter.key()]
481 Pout<<
" " << edgePoints[i] <<
nl;
492 const label faceI = faceLabels[i];
497 affectedFaces.erase(faceI);
508 iter != affectedFaces.end();
512 filterFace(splitEdges, iter.key(), meshMod);