/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2020-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- 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 "slidingInterface.H" #include "polyTopoChanger.H" #include "polyMesh.H" #include "batchPolyTopoChange.H" #include "addToRunTimeSelectionTable.H" #include "plane.H" // Index of debug signs: // p - adjusting a projection point // * - adjusting edge intersection // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { defineTypeNameAndDebug(slidingInterface, 0); addToRunTimeSelectionTable ( polyMeshModifier, slidingInterface, dictionary ); } const Foam::Enum < Foam::slidingInterface::typeOfMatch > Foam::slidingInterface::typeOfMatchNames ({ { typeOfMatch::INTEGRAL, "integral" }, { typeOfMatch::PARTIAL, "partial" }, }); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // void Foam::slidingInterface::checkDefinition() { const polyMesh& mesh = topoChanger().mesh(); if ( !masterFaceZoneID_.active() || !slaveFaceZoneID_.active() || !cutPointZoneID_.active() || !cutFaceZoneID_.active() || !masterPatchID_.active() || !slavePatchID_.active() ) { FatalErrorInFunction << "Not all zones and patches needed in the definition " << "have been found. Please check your mesh definition." << abort(FatalError); } // Check the sizes and set up state if ( mesh.faceZones()[masterFaceZoneID_.index()].empty() || mesh.faceZones()[slaveFaceZoneID_.index()].empty() ) { FatalErrorInFunction << "Please check your mesh definition." << abort(FatalError); } if (debug) { Pout<< "Sliding interface object " << name() << " :" << nl << " master face zone: " << masterFaceZoneID_.index() << nl << " slave face zone: " << slaveFaceZoneID_.index() << endl; } } void Foam::slidingInterface::clearOut() const { clearPointProjection(); clearAttachedAddressing(); clearAddressing(); } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::slidingInterface::slidingInterface ( const word& name, const label index, const polyTopoChanger& mme, const word& masterFaceZoneName, const word& slaveFaceZoneName, const word& cutPointZoneName, const word& cutFaceZoneName, const word& masterPatchName, const word& slavePatchName, const typeOfMatch tom, const bool coupleDecouple, const intersection::algorithm algo ) : polyMeshModifier(name, index, mme, true), masterFaceZoneID_ ( masterFaceZoneName, mme.mesh().faceZones() ), slaveFaceZoneID_ ( slaveFaceZoneName, mme.mesh().faceZones() ), cutPointZoneID_ ( cutPointZoneName, mme.mesh().pointZones() ), cutFaceZoneID_ ( cutFaceZoneName, mme.mesh().faceZones() ), masterPatchID_ ( masterPatchName, mme.mesh().boundaryMesh() ), slavePatchID_ ( slavePatchName, mme.mesh().boundaryMesh() ), matchType_(tom), coupleDecouple_(coupleDecouple), attached_(false), projectionAlgo_(algo), trigger_(false), pointMergeTol_(pointMergeTolDefault_), edgeMergeTol_(edgeMergeTolDefault_), nFacesPerSlaveEdge_(nFacesPerSlaveEdgeDefault_), edgeFaceEscapeLimit_(edgeFaceEscapeLimitDefault_), integralAdjTol_(integralAdjTolDefault_), edgeMasterCatchFraction_(edgeMasterCatchFractionDefault_), edgeCoPlanarTol_(edgeCoPlanarTolDefault_), edgeEndCutoffTol_(edgeEndCutoffTolDefault_), cutFaceMasterPtr_(nullptr), cutFaceSlavePtr_(nullptr), masterFaceCellsPtr_(nullptr), slaveFaceCellsPtr_(nullptr), masterStickOutFacesPtr_(nullptr), slaveStickOutFacesPtr_(nullptr), retiredPointMapPtr_(nullptr), cutPointEdgePairMapPtr_(nullptr), slavePointPointHitsPtr_(nullptr), slavePointEdgeHitsPtr_(nullptr), slavePointFaceHitsPtr_(nullptr), masterPointEdgeHitsPtr_(nullptr), projectedSlavePointsPtr_(nullptr) { checkDefinition(); if (attached_) { FatalErrorInFunction << "Creation of a sliding interface from components " << "in attached state not supported." << abort(FatalError); } else { calcAttachedAddressing(); } } Foam::slidingInterface::slidingInterface ( const word& name, const dictionary& dict, const label index, const polyTopoChanger& mme ) : polyMeshModifier(name, index, mme, dict.get("active")), masterFaceZoneID_ ( dict.get("masterFaceZoneName"), mme.mesh().faceZones() ), slaveFaceZoneID_ ( dict.get("slaveFaceZoneName"), mme.mesh().faceZones() ), cutPointZoneID_ ( dict.get("cutPointZoneName"), mme.mesh().pointZones() ), cutFaceZoneID_ ( dict.get("cutFaceZoneName"), mme.mesh().faceZones() ), masterPatchID_ ( dict.get("masterPatchName"), mme.mesh().boundaryMesh() ), slavePatchID_ ( dict.get("slavePatchName"), mme.mesh().boundaryMesh() ), matchType_(typeOfMatchNames.get("typeOfMatch", dict)), coupleDecouple_(dict.get("coupleDecouple")), attached_(dict.get("attached")), projectionAlgo_ ( intersection::algorithmNames_.get("projection", dict) ), trigger_(false), cutFaceMasterPtr_(nullptr), cutFaceSlavePtr_(nullptr), masterFaceCellsPtr_(nullptr), slaveFaceCellsPtr_(nullptr), masterStickOutFacesPtr_(nullptr), slaveStickOutFacesPtr_(nullptr), retiredPointMapPtr_(nullptr), cutPointEdgePairMapPtr_(nullptr), slavePointPointHitsPtr_(nullptr), slavePointEdgeHitsPtr_(nullptr), slavePointFaceHitsPtr_(nullptr), masterPointEdgeHitsPtr_(nullptr), projectedSlavePointsPtr_(nullptr) { // Optionally default tolerances from dictionary setTolerances(dict); checkDefinition(); // If the interface is attached, the master and slave face zone addressing // needs to be read in; otherwise it will be created if (attached_) { if (debug) { Pout<< "slidingInterface::slidingInterface(...) " << " for object " << name << " : " << "Interface attached. Reading master and slave face zones " << "and retired point lookup." << endl; } // The face zone addressing is written out in the definition dictionary masterFaceCellsPtr_.reset(new labelList()); slaveFaceCellsPtr_.reset(new labelList()); masterStickOutFacesPtr_.reset(new labelList()); slaveStickOutFacesPtr_.reset(new labelList()); retiredPointMapPtr_.reset(new Map