diff --git a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatchExtra/PrimitivePatchExtra.H b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatchExtra/PrimitivePatchExtra.H index 094dfb7340..6c3f381ff9 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatchExtra/PrimitivePatchExtra.H +++ b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatchExtra/PrimitivePatchExtra.H @@ -79,8 +79,8 @@ private: //- Edge-face addressing (sorted) mutable labelListList* sortedEdgeFacesPtr_; - //- Label of face that 'owns' edge (i.e. e.vec() is righthanded walk - // along face) + //- Label of face that 'owns' edge + // i.e. e.vec() is righthanded walk along face mutable labelList* edgeOwnerPtr_; @@ -92,42 +92,6 @@ private: //- Calculate owner void calcEdgeOwner() const; -protected: - // Protected Member Functions - - // Edit - - //- Fill faceZone with currentZone for every face reachable - // from faceI without crossing edge marked in borderEdge. - // Note: faceZone has to be sized nFaces before calling this fun. - void markZone - ( - const boolList& borderEdge, - const label faceI, - const label currentZone, - labelList& faceZone - ) const; - - //- (size and) fills faceZone with zone of face. - // Zone is area reachable by edge crossing without crossing borderEdge - // (bool for every edge in surface). Returns number of zones. - label markZones - ( - const boolList& borderEdge, - labelList& faceZone - ) const; - - //- Determine the mapping for a sub mesh. - // Only include faces for which boolList entry is true - // Sets: pointMap: from new to old localPoints - // faceMap: new to old faces - void subsetMap - ( - const boolList& include, - labelList& pointMap, - labelList& faceMap - ) const; - public: // Constructors @@ -183,14 +147,47 @@ public: // Check - //- Check triply (or more) connected edges. - // Return list of faces sharing these edges. + //- Check multiply-connected edges. void checkEdges(const bool verbose) const; //- Check orientation (normals) and normals of neighbouring faces boolList checkOrientation(const bool verbose) const; + // Edit + + //- Fill faceZone with currentZone for every face reachable + // from faceI without crossing edge marked in borderEdge. + // Note: faceZone has to be sized nFaces before calling. + void markZone + ( + const boolList& borderEdge, + const label faceI, + const label currentZone, + labelList& faceZone + ) const; + + //- (size and) fills faceZone with zone of face. + // Zone is area reachable by edge crossing without crossing borderEdge + // (bool for every edge in surface). Returns number of zones. + label markZones + ( + const boolList& borderEdge, + labelList& faceZone + ) const; + + //- Determine the mapping for a sub-mesh. + // Only include faces for which boolList entry is true + // @param[out] pointMap mapping new to old localPoints + // @param[out] faceMap mapping new to old faces + void subsetMap + ( + const boolList& include, + labelList& pointMap, + labelList& faceMap + ) const; + + }; diff --git a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatchExtra/PrimitivePatchExtraCleanup.C b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatchExtra/PrimitivePatchExtraCleanup.C index 433802ae72..7a5343a7ac 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatchExtra/PrimitivePatchExtraCleanup.C +++ b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatchExtra/PrimitivePatchExtraCleanup.C @@ -28,14 +28,6 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // Check/fix edges with more than two faces @@ -52,16 +44,15 @@ checkEdges const bool verbose ) const { - const labelListList& eFaces = - PrimitivePatch::edgeFaces(); + const labelListList& eFaces = TemplateType::edgeFaces(); + const edgeList& edgeLst = TemplateType::edges(); - const edgeList& edgeLst = - PrimitivePatch::edges(); - - forAll (eFaces, edgeI) + forAll(eFaces, edgeI) { const labelList& myFaces = eFaces[edgeI]; + // boundary edges have one face + // interior edges have two faces if (myFaces.size() == 0) { FatalErrorIn("PrimitivePatchExtra::checkEdges(bool verbose)") @@ -97,15 +88,15 @@ checkOrientation const bool verbose ) const { + const ListType& faceLst = *this; const edgeList& edgeLst = TemplateType::edges(); const labelListList& faceEs = TemplateType::faceEdges(); - const List& faceLst = TemplateType::faces(); const label numEdges = TemplateType::nEdges(); const pointField& pointLst = TemplateType::points(); const vectorField& normLst = TemplateType::faceNormals(); // Check edge normals, face normals, point normals. - forAll (faceEs, faceI) + forAll(faceEs, faceI) { const labelList& edgeLabels = faceEs[faceI]; @@ -118,7 +109,7 @@ checkOrientation } bool valid = true; - forAll (edgeLabels, i) + forAll(edgeLabels, i) { if (edgeLabels[i] < 0 || edgeLabels[i] >= numEdges) { @@ -126,8 +117,8 @@ checkOrientation ( "PrimitivePatchExtra::checkOrientation(bool)" ) << "edge number " << edgeLabels[i] << " on face " << faceI - << " out of range" - << "\nThis usually means that the input surface has " + << " out-of-range\n" + << "This usually means that the input surface has " << "edges with more than 2 faces connected.\n" << endl; valid = false; @@ -141,7 +132,7 @@ checkOrientation // //- Compute normal from 3 points, use the first as the origin - // + // minor warpage should not be a problem const FaceType& f = faceLst[faceI]; const point p0(pointLst[f[0]]); const point p1(pointLst[f[1]]); @@ -169,58 +160,34 @@ checkOrientation // edge boolList borderEdge(numEdges, false); - forAll (edgeLst, edgeI) + forAll(edgeLst, edgeI) { + const edge& e = edgeLst[edgeI]; const labelList& neighbours = eFaces[edgeI]; if (neighbours.size() == 2) { - // Two faces, A and B. Check if edge orientation is - // anticlockwise on both. - const labelList& fEdgesA = faceEs[neighbours[0]]; - const labelList& fEdgesB = faceEs[neighbours[1]]; + const FaceType& faceA = faceLst[neighbours[0]]; + const FaceType& faceB = faceLst[neighbours[1]]; - // Get next edge after edgeI - label nextEdgeA = fEdgesA.fcIndex(findIndex(fEdgesA, edgeI)); - label nextEdgeB = fEdgesB.fcIndex(findIndex(fEdgesB, edgeI)); - - // Now check if nextEdgeA and nextEdgeB have any common points + // The edge cannot be going in the same direction if both faces + // are oriented counterclockwise. + // Thus the next face point *must* different between the faces. if ( - edgeLst[nextEdgeA].start() == edgeLst[nextEdgeB].start() - || edgeLst[nextEdgeA].start() == edgeLst[nextEdgeB].end() - || edgeLst[nextEdgeA].end() == edgeLst[nextEdgeB].start() - || edgeLst[nextEdgeA].end() == edgeLst[nextEdgeB].end() + faceA[faceA.fcIndex(findIndex(faceA, e.start()))] + == faceB[faceB.fcIndex(findIndex(faceB, e.start()))] ) { borderEdge[edgeI] = true; if (verbose) { - // just list first three points - // to simplify generating the message WarningIn("PrimitivePatchExtra::checkOrientation(bool)") << "face orientation incorrect." << nl - << "edge neighbours:" << neighbours << nl - << "face " << neighbours[0] << " has edges " - << fEdgesA << nl - << " with points " << nl - << " " << edgeLst[fEdgesA[0]].start() << ' ' - << edgeLst[fEdgesA[0]].end() << nl - << " " << edgeLst[fEdgesA[1]].start() << ' ' - << edgeLst[fEdgesA[1]].end() << nl - << " " << edgeLst[fEdgesA[2]].start() << ' ' - << edgeLst[fEdgesA[2]].end() - << endl - << "face " << neighbours[1] << " has edges " - << fEdgesB << nl - << " with points " << nl - << " " << edgeLst[fEdgesB[0]].start() << ' ' - << edgeLst[fEdgesB[0]].end() << nl - << " " << edgeLst[fEdgesB[1]].start() << ' ' - << edgeLst[fEdgesB[1]].end() << nl - << " " << edgeLst[fEdgesB[2]].start() << ' ' - << edgeLst[fEdgesB[2]].end() << nl - << endl; + << "edge[" << edgeI << "] " << e + << " between faces " << neighbours << ":" << nl + << "face[" << neighbours[0] << "] " << faceA << nl + << "face[" << neighbours[1] << "] " << faceB << endl; } } } @@ -228,10 +195,9 @@ checkOrientation { if (verbose) { - const edge& e = edgeLst[edgeI]; WarningIn("PrimitivePatchExtra::checkOrientation(bool)") << "Wrong number of edge neighbours." << endl - << "Edge:" << e + << "edge[" << edgeI << "] " << e << "with points:" << locPointsLst[e.start()] << ' ' << locPointsLst[e.end()] << " has neighbours:" << neighbours << endl; diff --git a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatchExtra/PrimitivePatchExtraSearch.C b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatchExtra/PrimitivePatchExtraSearch.C index c9d4d75fa6..453cdd63c9 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatchExtra/PrimitivePatchExtraSearch.C +++ b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatchExtra/PrimitivePatchExtraSearch.C @@ -26,8 +26,6 @@ License #include "PrimitivePatchExtra.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // Finds area, starting at faceI, delimited by borderEdge. Marks all visited @@ -58,13 +56,13 @@ void Foam::PrimitivePatchExtra::markZone // Pick up neighbours of changedFaces DynamicList