/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Copyright (C) 2023-2026 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . \*---------------------------------------------------------------------------*/ #include "TriPatchIntersection.H" #include "barycentricTensor2D.H" #include "boundSphere.H" #include "cpuTime.H" #include "indexedOctree.H" #include "OFstream.H" #include "treeDataPrimitivePatch.H" #include "triIntersect.H" #include "vtkWritePolyData.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // template void Foam::TriPatchIntersection::checkPatchFace ( const label patchFacei, const bool isSrc ) const { #ifdef FULLDEBUG const labelList& patchFaceTris = isSrc ? srcFaceTris_[patchFacei] : tgtFaceTris_[patchFacei]; forAll(patchFaceTris, patchFaceTrii) { const label trii = patchFaceTris[patchFaceTrii]; if (triPoints_[trii] != FixedList({-1, -1, -1})) { forAll(triEdges_[trii], triEdgei) { const label edgei = triEdges_[trii][triEdgei]; // Check that there are no duplicate points const edge e = triEdgePoints(trii, triEdgei); if (e[0] == e[1]) { FatalErrorInFunction << "Tri #" << trii << "'s tri-edge #" << triEdgei << " (edge #" << triEdges_[trii][triEdgei] << ") has " << "duplicate points " << e << exit(FatalError); } // Check that this edge also references this tri const label edgeTrii = findIndex(edgeTris_[edgei], trii); if (edgeTrii == -1) { FatalErrorInFunction << "Tri #" << trii << " references edge #" << edgei << " but the reverse is not true" << exit(FatalError); } // If there is a connected tri ... const label otherTrii = edgeTris_[edgei][!edgeTrii]; if (otherTrii != -1) { // Check that the connected tri also references this edge const label otherTriEdgei = findIndex(triEdges_[otherTrii], edgei); if (otherTriEdgei == -1) { FatalErrorInFunction << "Edge #" << edgei << " references tri #" << otherTrii << " but the reverse is not true" << exit(FatalError); } // Check that the edge is correspondingly oriented in its // two connected tris const edge otherE = triEdgePoints(otherTrii, otherTriEdgei); if (edge::compare(e, otherE) != -1) { FatalErrorInFunction << "Edge #" << edgei << ' ' << edgePoints(edgei) << " is not the same in adjacent tri #" << trii << ' ' << triPoints(trii) << " and tri #" << otherTrii << ' ' << triPoints(otherTrii) << exit(FatalError); } } // Check edge-points and point-edges ... !!! // If this is a front edge ... if (edgeFrontEdges_[edgei] != -1) { // Check that the front arrays are consistent const label frontEdgei = edgeFrontEdges_[edgei]; if ( frontEdgeEdges_.size() <= frontEdgei || frontEdgeEdges_[frontEdgei] != edgei ) { FatalErrorInFunction << "Edge #" << edgei << " is marked as part of the " << "front but is not in the front edge list" << exit(FatalError); } // Check that the edge connects source to target const label trii0 = edgeTris_[edgei][0]; const label trii1 = edgeTris_[edgei][1]; if ( trii0 == -1 || trii1 == -1 || (triSrcFace_[trii0] == -1) == (triSrcFace_[trii1] == -1) ) { FatalErrorInFunction << "Front edge #" << edgei << " does not connect a source-tri to a target-tri" << exit(FatalError); } } // If this is a star edge ... !!! } // If this is a candidate tri ... !!! // If this is a marked tri ... !!! } } #endif } template void Foam::TriPatchIntersection::checkPatchEdge ( const label patchEdgei, const bool isSrc ) const { #ifdef FULLDEBUG const labelListList& patchEdgePatchFaces = isSrc ? this->srcPatch_.edgeFaces() : this->tgtPatch_.edgeFaces(); const labelList patchFaceis = patchEdgePatchFaces[patchEdgei]; forAll(patchFaceis, i) { checkPatchFace(patchFaceis[i], isSrc); } #endif } template void Foam::TriPatchIntersection::checkPatchFaces ( const bool isSrc ) const { #ifdef FULLDEBUG const List>& patchFaceTris = isSrc ? srcFaceTris_ : tgtFaceTris_; forAll(patchFaceTris, patchFacei) { checkPatchFace(patchFacei, isSrc); } #endif } template void Foam::TriPatchIntersection::removeEdge ( const label edgei ) { #ifdef FULLDEBUG if ( edgeTris_[edgei] != labelPair(-1, -1) && intersectEdgeFaces_[edgei] != labelPair(-1, -1) ) { FatalErrorInFunction << "Attempted to remove edge #" << edgei << " which is still " << "connected to triangles " << edgeTris_[edgei] << " and faces " << intersectEdgeFaces_[edgei] << exit(FatalError); } #endif removedEdges_.append(edgei); if (edgeFrontEdges_[edgei] != -1) { frontEdgeEdges_[edgeFrontEdges_[edgei]] = -1; edgeFrontEdges_[edgei] = -1; } } template void Foam::TriPatchIntersection::removeTri ( const label trii ) { triPoints_[trii] = triFace(-1, -1, -1); { const bool isSrc = triSrcFace_[trii] != -1; const label patchFacei = isSrc ? triSrcFace_[trii] : triTgtFace_[trii]; DynamicList