/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Copyright (C) 2023-2024 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 "FacePatchIntersection.H" #include "cpuTime.H" #include "primitiveTriPatch.H" #include "polygonTriangulate.H" #include "TriPatchIntersection.H" #include "vtkWritePolyData.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { template void inplaceRemove(ListType& lst, const T& value) { if (lst.size()) { inplaceRemove(lst, value, lst[0]); } } template void inplaceRemove(ListType& lst, const T& value, const NotT&) { forAll(lst, i) { if (lst[i].size()) { inplaceRemove(lst[i], value, lst[i][0]); } } } template void inplaceRemove(ListType& lst, const T& value, const T&) { label iNew = 0; forAll(lst, iOld) { if (lst[iOld] != value) { lst[iNew] = lst[iOld]; ++ iNew; } } lst.resize(iNew); } template ListType reorder ( const label size, const typename ListType::value_type& defaultValue, const labelUList& oldToNew, const ListType& lst ) { ListType newLst(size, defaultValue); forAll(lst, elemI) { if (oldToNew[elemI] >= 0) { newLst[oldToNew[elemI]] = lst[elemI]; } } return newLst; } } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template Foam::FacePatchIntersection::FacePatchIntersection ( const SrcPatchType& srcPatch, const TgtPatchType& tgtPatch, const scalar snapTol ) : FacePatchIntersection(srcPatch, srcPatch.pointNormals(), tgtPatch, snapTol) {} template Foam::FacePatchIntersection::FacePatchIntersection ( const SrcPatchType& srcPatch, const vectorField& srcPointNormals, const TgtPatchType& tgtPatch, const scalar snapTol ) : PatchIntersection(srcPatch, tgtPatch) { cpuTime time; Info<< type() << ": Intersecting " << this->srcPatch_.size() << " source faces and " << this->tgtPatch_.size() << " target faces" << incrIndent << endl; if (this->debug) { Info<< indent << "Writing patches" << incrIndent << endl; const fileName srcFileName = type() + "_srcPatch.vtk"; Info<< indent << "Writing patch to " << srcFileName << endl; vtkWritePolyData::write ( srcFileName, "source", false, this->srcPatch_.localPoints(), labelList(), labelListList(), this->srcPatch_.localFaces(), "normals", true, srcPointNormals ); const fileName tgtFileName = type() + "_tgtPatch.vtk"; Info<< indent << "Writing patch to " << tgtFileName << endl; vtkWritePolyData::write ( tgtFileName, "target", false, this->tgtPatch_.localPoints(), labelList(), labelListList(), this->tgtPatch_.localFaces() ); Info<< decrIndent; } // Step 1: Triangulate the source and target patches and create addressing DynamicList srcTris, tgtTris; DynamicList