39 bool Foam::cellFeatures::faceAlignedEdge(
const label facei,
const label edgeI)
42 const edge&
e = mesh_.
edges()[edgeI];
44 const face&
f = mesh_.
faces()[facei];
48 if (
f[fp] ==
e.start())
52 return f[fp1] ==
e.end();
57 <<
"Can not find edge " << mesh_.
edges()[edgeI]
68 const Map<label>& toSuperFace,
69 const label superFacei,
70 const label thisEdgeI,
74 const labelList& pEdges = mesh_.pointEdges()[thisVertI];
78 label edgeI = pEdges[pEdgeI];
80 if ((edgeI != thisEdgeI) && featureEdge_.found(edgeI))
84 const labelList& eFaces = mesh_.edgeFaces()[edgeI];
88 label facei = eFaces[eFacei];
93 && (toSuperFace[facei] == superFacei)
103 <<
"Can not find edge in " << featureEdge_ <<
" connected to edge "
104 << thisEdgeI <<
" at vertex " << thisVertI <<
endl
105 <<
"This might mean that the externalEdges do not form a closed loop"
113 bool Foam::cellFeatures::isCellFeatureEdge
127 vector n0 = mesh_.faceAreas()[face0];
130 vector n1 = mesh_.faceAreas()[face1];
133 scalar cosAngle = n0 & n1;
136 const edge&
e = mesh_.edges()[edgeI];
138 const face& f0 = mesh_.faces()[face0];
141 label face0End = f0.fcIndex(face0Start);
143 const face& f1 = mesh_.faces()[face1];
146 label face1End = f1.fcIndex(face1Start);
151 (f0[face0End] ==
e.end())
152 && (f1[face1End] !=
e.end())
155 (f0[face0End] !=
e.end())
156 && (f1[face1End] ==
e.end())
163 cosAngle = -cosAngle;
166 if (cosAngle < minCos)
179 void Foam::cellFeatures::walkSuperFace
182 const label superFacei,
183 Map<label>& toSuperFace
186 if (!toSuperFace.found(facei))
188 toSuperFace.insert(facei, superFacei);
190 const labelList& fEdges = mesh_.faceEdges()[facei];
194 label edgeI = fEdges[fEdgeI];
196 if (!featureEdge_.found(edgeI))
219 void Foam::cellFeatures::calcSuperFaces()
const
223 const labelList& cFaces = mesh_.cells()[celli_];
228 Map<label> toSuperFace(10*cFaces.size());
230 label superFacei = 0;
234 label facei = cFaces[cFacei];
236 if (!toSuperFace.found(facei))
250 faceMap_.setSize(superFacei);
254 label facei = cFaces[cFacei];
256 faceMap_[toSuperFace[facei]].append(facei);
261 faceMap_[superI].shrink();
267 facesPtr_ =
new faceList(superFacei);
273 label facei = cFaces[cFacei];
275 label superFacei = toSuperFace[facei];
277 if (faces[superFacei].empty())
282 label startEdgeI = -1;
284 const labelList& fEdges = mesh_.faceEdges()[facei];
288 label edgeI = fEdges[fEdgeI];
290 if (featureEdge_.found(edgeI))
299 if (startEdgeI != -1)
303 DynamicList<label> superFace(10*mesh_.faces()[facei].size());
305 const edge&
e = mesh_.edges()[startEdgeI];
309 bool flipOrientation =
310 (mesh_.faceOwner()[facei] == celli_)
311 ^ (faceAlignedEdge(facei, startEdgeI));
313 label startVertI = -1;
317 startVertI =
e.end();
321 startVertI =
e.start();
324 label edgeI = startEdgeI;
326 label vertI =
e.otherVertex(startVertI);
330 label newEdgeI = nextEdge
339 if (isFeaturePoint(edgeI, newEdgeI))
341 superFace.append(vertI);
346 if (vertI == startVertI)
351 vertI = mesh_.edges()[edgeI].otherVertex(vertI);
355 if (superFace.size() <= 2)
358 <<
" Can not collapse faces " << faceMap_[superFacei]
359 <<
" into one big face on cell " << celli_ <<
endl
360 <<
"Try decreasing minCos:" << minCos_ <<
endl;
364 faces[superFacei].transfer(superFace);
385 featureEdge_(10*mesh.cellEdges()[celli].size()),
393 label edgeI = cEdges[cEdgeI];
395 if (isCellFeatureEdge(minCos_, edgeI))
397 featureEdge_.
insert(edgeI);
420 || (edge0 >= mesh_.nEdges())
422 || (edge1 >= mesh_.nEdges())
426 <<
"Illegal edge labels : edge0:" << edge0 <<
" edge1:" << edge1
430 const edge& e0 = mesh_.edges()[edge0];
435 const edge& e1 = mesh_.edges()[edge1];
449 cosAngle = e0Vec & e1Vec;
458 cosAngle = - e0Vec & e1Vec;
465 <<
"Edges do not share common vertex. e0:" << e0
469 if (cosAngle < minCos_)
487 || (facei >= mesh_.nFaces())
489 || (vertI >= mesh_.nPoints())
493 <<
"Illegal face " << facei <<
" or vertex " << vertI
497 const labelList& pEdges = mesh_.pointEdges()[vertI];
504 label edgeI = pEdges[pEdgeI];
525 <<
"Did not find two edges sharing vertex " << vertI
526 <<
" on face " << facei <<
" vertices:" << mesh_.faces()[facei]
530 return isFeaturePoint(edge0, edge1);
Various functions to operate on Lists.
#define forAll(list, i)
Loop across all elements in list.
bool insert(const Key &key)
Insert a new entry.
bool isFeaturePoint(const label edge0, const label edge1) const
Are two edges connected at feature point?
bool isFeatureVertex(const label facei, const label vertI) const
Is vertexI on facei used by two edges that form feature.
~cellFeatures()
Destructor.
cellFeatures(const primitiveMesh &, const scalar minCos, const label celli)
Construct from cell in mesh.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
label end() const
Return end vertex label.
vector vec(const pointField &) const
Return the vector (end - start)
label start() const
Return start vertex label.
Cell-face mesh analysis engine.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
const labelListList & cellEdges() const
virtual const faceList & faces() const =0
Return faces.
Template functions to aid in the implementation of demand driven data.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define WarningInFunction
Report a warning using Foam::Warning.
List< label > labelList
A List of labels.
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 & endl(Ostream &os)
Add newline and flush stream.
void deleteDemandDrivenData(DataType *&dataPtr)
errorManip< error > abort(error &err)
Vector< scalar > vector
A scalar version of the templated Vector.
dimensioned< scalar > mag(const dimensioned< Type > &)
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.