/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | foam-extend: Open Source CFD \\ / O peration | Version: 3.2 \\ / A nd | Web: http://www.foam-extend.org \\/ M anipulation | For copyright notice see file Copyright ------------------------------------------------------------------------------- License This file is part of foam-extend. foam-extend 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. foam-extend 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 foam-extend. If not, see . Description Create coupled match faces and add them to the cells \*---------------------------------------------------------------------------*/ #include "starMesh.H" #include "boolList.H" #include "pointHit.H" #include "IOmanip.H" #include "boundBox.H" #include "Map.H" #include "mathematicalConstants.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // void starMesh::createCoupleMatches() { // Loop through all couples and create intersection faces. Add all points // of intersection faces to the couple points lists. The numbering of // the list is set such that the list can be appended to the // existing points list // Estimate the number of cells affected by couple matches const label cellMapSize = min ( cellShapes_.size()/10, couples_.size()*2 ); // Store newly created faces for each cell Map > cellAddedFaces(cellMapSize); Map > cellRemovedFaces(cellMapSize); // In order to remove often allocation, remember the number of live points. // If you run out of space in point creation, increase it by the number of // couples (good scale) and resize at the end; label nLivePoints = points_.size(); const label infoJump = max(1000, couples_.size()/20); forAll (couples_, coupleI) { if (coupleI % infoJump == 0) { Info << "Doing couple " << coupleI << ". STAR couple ID: " << couples_[coupleI].coupleID() << endl; } // Initialise cell edges for master and slave cells const coupledFacePair& fp = couples_[coupleI]; const face& masterFace = cellFaces_[fp.masterCell()][fp.masterFace()]; const face& slaveFace = cellFaces_[fp.slaveCell()][fp.slaveFace()]; # ifdef DEBUG_COUPLE Info<< "coupleI: " << coupleI << endl << "masterFace: " << masterFace << endl << "master points: " << masterFace.points(points_) << endl << "slaveFace: " << slaveFace << endl << "slave points: " << slaveFace.points(points_) << endl << endl; # endif // check the angle of face area vectors scalar faceAreaAngle = mag ( -(masterFace.normal(points_) & slaveFace.normal(points_))/ (masterFace.mag(points_)*slaveFace.mag(points_) + VSMALL) ); if (faceAreaAngle < 0.94) { Info<< "Couple direction mismatch in the couple match " << coupleI << ". STAR couple ID: " << couples_[coupleI].coupleID() << endl << "The angle between face normals is " << Foam::acos(faceAreaAngle)/mathematicalConstant::pi*180 << " deg." << endl << "master cell: " << fp.masterCell() << " STAR number: " << starCellID_[fp.masterCell()] << " type: " << cellShapes_[fp.masterCell()].model().name() << " face: " << fp.masterFace() << endl << "slave cell : " << fp.slaveCell() << " STAR number: " << starCellID_[fp.slaveCell()] << " type: " << cellShapes_[fp.slaveCell()].model().name() << " face: " << fp.slaveFace() << endl; } // Deal with integral patches if (fp.integralMatch()) { // Master face is replaced by a set of slave faces Map >::iterator crfIter = cellRemovedFaces.find(fp.masterCell()); if (crfIter == cellRemovedFaces.end()) { cellRemovedFaces.insert ( fp.masterCell(), SLList