40 void Foam::faceCollapser::insert
43 const label excludeElem,
49 if (elems[i] != excludeElem)
68 label edgeI = edgeLabels[i];
70 const edge& e = edges[edgeI];
74 (e[0] == v0 && e[1] == v1)
75 || (e[0] == v1 && e[1] == v0)
83 <<
" and " << v1 <<
" in edge labels " << edgeLabels
93 void Foam::faceCollapser::filterFace
95 const Map<labelList>& splitEdges,
97 polyTopoChange& meshMod
100 const face& f = mesh_.
faces()[facei];
104 DynamicList<label> newFace(10 * f.size());
113 label fp1 = f.fcIndex(fp);
118 label edgeI = findEdge(mesh_.
edges(), fEdges, v0, v1);
121 splitEdges.
find(edgeI);
123 if (edgeFnd != splitEdges.end())
131 if (v0 == mesh_.
edges()[edgeI].start())
135 newFace.append(extraVerts[i]);
142 newFace.append(extraVerts[i]);
147 face newF(newFace.shrink());
170 bool zoneFlip =
false;
174 const faceZone& fZone = mesh_.
faceZones()[zoneID];
176 zoneFlip = fZone.flipMap()[fZone.whichFace(facei)];
238 const label facei = faceLabels[i];
240 const face& f = faces[facei];
242 const label fpA = fpStart[i];
243 const label fpB = fpEnd[i];
245 const point& pA = points[f[fpA]];
246 const point& pB = points[f[fpB]];
248 Pout<<
"Face:" << f <<
" collapsed to fp:" << fpA <<
' ' << fpB
249 <<
" with points:" << pA <<
' ' << pB
261 dist[fpB] =
magSqr(pB - pA);
268 label fp = f.fcIndex(fpMin1);
277 if (w <= dist[fpMin1])
280 w = dist[fpMin1] + 1e-6*(dist[fpB] - dist[fpA]);
284 pA +
Foam::sqrt(w / (dist[fpB] - dist[fpA]))*(pB - pA)
287 Pout<<
"Adapting position of vertex " << f[fp] <<
" on face " 288 << f <<
" from " << near.
rawPoint() <<
" to " << newPoint
321 fp = f.rcIndex(fpMin1);
330 if (w <= dist[fpMin1])
333 w = dist[fpMin1] + 1e-6*(dist[fpB] - dist[fpA]);
337 pA +
Foam::sqrt(w / (dist[fpB] - dist[fpA]))*(pB - pA)
340 Pout<<
"Adapting position of vertex " << f[fp] <<
" on face " 341 << f <<
" from " << near.
rawPoint() <<
" to " << newPoint
374 OFstream str(
"conflictingFace.obj");
378 <<
"Trying to collapse face:" << facei <<
" vertices:" << f
379 <<
" to edges between vertices " << f[fpA] <<
" and " 380 << f[fpB] <<
" but " << f[fpB] <<
" does not seem to be the" 381 <<
" vertex furthest away from " << f[fpA] << endl
382 <<
"Dumped conflicting face to obj file conflictingFace.obj" 388 Pout<<
"Face:" << f <<
" fpA:" << fpA <<
" fpB:" << fpB <<
nl;
395 Pout<<
" fp:" << fp <<
" distance:" << dist[i] <<
nl;
410 label fp1 = f.fcIndex(fp);
413 label sorted0 = sortedFp[fp];
414 label sorted1 = sortedFp[fp1];
422 if (sorted0 < sorted1)
426 for (
label j = sorted0+1; j < sorted1; j++)
435 for (
label j = sorted1+1; j < sorted0; j++)
441 if (edgePoints.size())
445 label edgeI = findEdge(edges, fEdges, f[fp], f[fp1]);
447 const edge& e = edges[edgeI];
449 if (fpToFp1 == (f[fp] == e.
start()))
451 splitEdges.insert(edgeI, edgePoints);
456 splitEdges.insert(edgeI, edgePoints);
460 insert(edgeFaces[edgeI], facei, affectedFaces);
467 Pout<<
"Split edge:" << iter.key()
468 <<
" verts:" << mesh_.
edges()[iter.key()]
474 Pout<<
" " << edgePoints[i] <<
nl;
485 const label facei = faceLabels[i];
490 affectedFaces.erase(facei);
500 filterFace(splitEdges, iter.key(), meshMod);
Class containing data for face removal.
#define forAll(list, i)
Loop across all elements in list.
void sort()
(stable) sort the list (if changed after construction time)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
A face is a list of labels corresponding to mesh vertices.
void setRefinement(const labelList &faceLabels, const labelList &fpA, const labelList &fpB, polyTopoChange &) const
Collapse faces along endpoints. Play commands into.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
A list that is sorted upon construction or when explicitly requested with the sort() method...
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
void size(const label)
Override size to be inconsistent with allocated storage.
const Point & rawPoint() const
Return point with no checking.
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
#define forAllReverse(list, i)
Reverse loop across all elements in list.
HashTable< T, label, Hash< label > >::const_iterator const_iterator
bool isInternalFace(const label faceIndex) const
Return true if given face label is internal to the mesh.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
const labelListList & edgeFaces() const
virtual const pointField & points() const
Return raw points.
label fcIndex(const label i) const
Return the forward circular index, i.e. the next index.
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
HashSet< label, Hash< label > > labelHashSet
A HashSet with label keys.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
List< label > labelList
A List of labels.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
errorManip< error > abort(error &err)
dimensioned< scalar > magSqr(const dimensioned< Type > &)
Class describing modification of a point.
prefixOSstream Pout(cout,"Pout")
label start() const
Return start vertex label.
void reverse(UList< T > &, const label n)
label rcIndex(const label i) const
Return the reverse circular index, i.e. the previous index.
virtual const labelList & faceNeighbour() const
Return face neighbour.
label whichPatch(const label faceIndex) const
Return patch index for a given face label.
label whichZone(const label objectIndex) const
Given a global object index, return the zone it is in.
Direct mesh changes based on v1.3 polyTopoChange syntax.
const faceZoneMesh & faceZones() const
Return face zone mesh.
PointHit< Point > nearestDist(const Point &p) const
Return nearest distance to line from a given point.
Mesh consisting of general polyhedral cells.
virtual const labelList & faceOwner() const
Return face owner.
virtual const faceList & faces() const
Return raw faces.
const labelListList & faceEdges() const
const labelList & indices() const
Return the list of sorted indices. Updated every sort.
void setPoint(const Point &p)
A HashTable to objects of type <T> with a label key.
label setAction(const topoAction &action)
For compatibility with polyTopoChange: set topological action.