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);
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
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)
FvWallInfoData< WallInfo, label > 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.
const labelListList & faceEdges() const
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
label rcIndex(const label i) const
Return the reverse circular index, i.e. the previous index.
virtual const labelList & faceNeighbour() const
Return face neighbour.
A list that is sorted upon construction or when explicitly requested with the sort() method...
void size(const label)
Override size to be inconsistent with allocated storage.
label fcIndex(const label i) const
Return the forward circular index, i.e. the next index.
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.
Holds information (coordinate and normal) regarding nearest wall point.
HashTable< T, label, Hash< label > >::const_iterator const_iterator
faceCollapser(const polyMesh &mesh)
Construct from mesh.
void setRefinement(const labelList &faceLabels, const labelList &fpA, const labelList &fpB, polyTopoChange &) const
Collapse faces along endpoints. Play commands into.
virtual const pointField & points() const
Return raw points.
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
HashSet< label, Hash< label > > labelHashSet
A HashSet with label keys.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
virtual const labelList & faceOwner() const
Return face owner.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
List< label > labelList
A List of labels.
virtual const faceList & faces() const
Return raw faces.
errorManip< error > abort(error &err)
bool isInternalFace(const label faceIndex) const
Return true if given face label is internal to the mesh.
const labelList & indices() const
Return the list of sorted indices. Updated every sort.
dimensioned< scalar > magSqr(const dimensioned< Type > &)
Class describing modification of a point.
const Point & rawPoint() const
Return point with no checking.
void reverse(UList< T > &, const label n)
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
label whichZone(const label objectIndex) const
Given a global object index, return the zone it is in.
prefixOSstream Pout(cout, "Pout")
const meshFaceZones & faceZones() const
Return face zones.
Direct mesh changes based on v1.3 polyTopoChange syntax.
Mesh consisting of general polyhedral cells.
label whichPatch(const label faceIndex) const
Return patch index for a given face label.
void setPoint(const Point &p)
PointHit< Point > nearestDist(const Point &p) const
Return nearest distance to line from a given point.
const labelListList & edgeFaces() const
label start() const
Return start vertex label.
A HashTable to objects of type <T> with a label key.
label setAction(const topoAction &action)
For compatibility with polyTopoChange: set topological action.