/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Copyright (C) 2013-2025 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 "intersectionCellsToCells.H" #include "meshSearch.H" #include "tetOverlapVolume.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { namespace cellsToCellss { defineTypeNameAndDebug(intersection, 0); addToRunTimeSelectionTable(cellsToCells, intersection, word); } } const Foam::scalar Foam::cellsToCellss::intersection::tolerance_ = 1e-6; // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // bool Foam::cellsToCellss::intersection::intersect ( const polyMesh& srcMesh, const polyMesh& tgtMesh, const label srcCelli, const label tgtCelli ) const { return tetOverlapVolume().cellCellOverlapMinDecomp ( srcMesh, srcCelli, tgtMesh, tgtCelli, treeBoundBox(tgtMesh.points(), tgtMesh.cellPoints()[tgtCelli]), tolerance_*srcMesh.cellVolumes()[srcCelli] ); } Foam::scalar Foam::cellsToCellss::intersection::interVol ( const polyMesh& srcMesh, const polyMesh& tgtMesh, const label srcCelli, const label tgtCelli ) const { return tetOverlapVolume().cellCellOverlapVolumeMinDecomp ( srcMesh, srcCelli, tgtMesh, tgtCelli, treeBoundBox(tgtMesh.points(), tgtMesh.cellPoints()[tgtCelli]) ); } bool Foam::cellsToCellss::intersection::findInitialSeeds ( const polyMesh& srcMesh, const polyMesh& tgtMesh, const labelList& srcCellIDs, const boolList& mapFlag, const label startSeedI, label& srcSeedI, label& tgtSeedI ) const { const cellList& srcCells = srcMesh.cells(); const faceList& srcFaces = srcMesh.faces(); const pointField& srcPts = srcMesh.points(); const meshSearch& tgtSearchEngine = meshSearch::New(tgtMesh); for (label i = startSeedI; i < srcCellIDs.size(); i++) { const label srcI = srcCellIDs[i]; if (mapFlag[srcI]) { const labelList tgtIDs ( tgtSearchEngine.cellTree().findBox ( treeBoundBox(srcCells[srcI].bb(srcPts, srcFaces)) ) ); forAll(tgtIDs, j) { const label tgtI = tgtIDs[j]; if (intersect(srcMesh, tgtMesh, srcI, tgtI)) { srcSeedI = srcI; tgtSeedI = tgtI; return true; } } } } if (debug) { Pout<< "could not find starting seed" << endl; } return false; } Foam::scalar Foam::cellsToCellss::intersection::calculateAddressing ( const polyMesh& srcMesh, const polyMesh& tgtMesh, labelListList& srcToTgtCellAddr, scalarListList& srcToTgtCellWght, labelListList& tgtToSrcCellAddr, scalarListList& tgtToSrcCellWght, const label srcSeedI, const label tgtSeedI, const labelList& srcCellIDs, boolList& mapFlag, label& startSeedI ) { scalar V = 0; label srcCelli = srcSeedI; label tgtCelli = tgtSeedI; List> srcToTgtAddr(srcMesh.nCells()); List> srcToTgtWght(srcMesh.nCells()); List> tgtToSrcAddr(tgtMesh.nCells()); List> tgtToSrcWght(tgtMesh.nCells()); // list of tgt cell neighbour cells DynamicList