/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. \\/ 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 2 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, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA \*---------------------------------------------------------------------------*/ #include "slidingInterface.H" #include "polyTopoChanger.H" #include "polyMesh.H" #include "polyTopoChange.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 ); } template<> const char* Foam::NamedEnum::names[] = { "integral", "partial" }; const Foam::NamedEnum Foam::slidingInterface::typeOfMatchNames_; // * * * * * * * * * * * * * 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() ) { FatalErrorIn ( "void slidingInterface::checkDefinition()" ) << "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() ) { FatalErrorIn("void slidingInterface::checkDefinition()") << "Master or slave face zone contain no faces. " << "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 * * * * * * * * * * * * * * // // Construct from components 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_(NULL), cutFaceSlavePtr_(NULL), masterFaceCellsPtr_(NULL), slaveFaceCellsPtr_(NULL), masterStickOutFacesPtr_(NULL), slaveStickOutFacesPtr_(NULL), retiredPointMapPtr_(NULL), cutPointEdgePairMapPtr_(NULL), slavePointPointHitsPtr_(NULL), slavePointEdgeHitsPtr_(NULL), slavePointFaceHitsPtr_(NULL), masterPointEdgeHitsPtr_(NULL), projectedSlavePointsPtr_(NULL) { checkDefinition(); if (attached_) { FatalErrorIn ( "Foam::slidingInterface::slidingInterface\n" "(\n" " const word& name,\n" " const label index,\n" " const polyTopoChanger& mme,\n" " const word& masterFaceZoneName,\n" " const word& slaveFaceZoneName,\n" " const word& cutFaceZoneName,\n" " const word& cutPointZoneName,\n" " const word& masterPatchName,\n" " const word& slavePatchName,\n" " const typeOfMatch tom,\n" " const bool coupleDecouple\n" ")" ) << "Creation of a sliding interface from components " << "in attached state not supported." << abort(FatalError); } else { calcAttachedAddressing(); } } // Construct from components Foam::slidingInterface::slidingInterface ( const word& name, const dictionary& dict, const label index, const polyTopoChanger& mme ) : polyMeshModifier(name, index, mme, Switch(dict.lookup("active"))), masterFaceZoneID_ ( dict.lookup("masterFaceZoneName"), mme.mesh().faceZones() ), slaveFaceZoneID_ ( dict.lookup("slaveFaceZoneName"), mme.mesh().faceZones() ), cutPointZoneID_ ( dict.lookup("cutPointZoneName"), mme.mesh().pointZones() ), cutFaceZoneID_ ( dict.lookup("cutFaceZoneName"), mme.mesh().faceZones() ), masterPatchID_ ( dict.lookup("masterPatchName"), mme.mesh().boundaryMesh() ), slavePatchID_ ( dict.lookup("slavePatchName"), mme.mesh().boundaryMesh() ), matchType_(typeOfMatchNames_.read((dict.lookup("typeOfMatch")))), coupleDecouple_(dict.lookup("coupleDecouple")), attached_(dict.lookup("attached")), projectionAlgo_ ( intersection::algorithmNames_.read(dict.lookup("projection")) ), trigger_(false), cutFaceMasterPtr_(NULL), cutFaceSlavePtr_(NULL), masterFaceCellsPtr_(NULL), slaveFaceCellsPtr_(NULL), masterStickOutFacesPtr_(NULL), slaveStickOutFacesPtr_(NULL), retiredPointMapPtr_(NULL), cutPointEdgePairMapPtr_(NULL), slavePointPointHitsPtr_(NULL), slavePointEdgeHitsPtr_(NULL), slavePointFaceHitsPtr_(NULL), masterPointEdgeHitsPtr_(NULL), projectedSlavePointsPtr_(NULL) { // 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_ = new labelList(dict.lookup("masterFaceCells")); slaveFaceCellsPtr_ = new labelList(dict.lookup("slaveFaceCells")); masterStickOutFacesPtr_ = new labelList(dict.lookup("masterStickOutFaces")); slaveStickOutFacesPtr_ = new labelList(dict.lookup("slaveStickOutFaces")); retiredPointMapPtr_ = new Map