/*---------------------------------------------------------------------------*\ ========= | \\ / 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 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 "meshRefinement.H" #include "volMesh.H" #include "volFields.H" #include "surfaceMesh.H" #include "syncTools.H" #include "Time.H" #include "refinementHistory.H" #include "refinementSurfaces.H" #include "decompositionMethod.H" #include "regionSplit.H" #include "fvMeshDistribute.H" #include "indirectPrimitivePatch.H" #include "polyTopoChange.H" #include "removeCells.H" #include "mapDistributePolyMesh.H" #include "localPointRegion.H" #include "pointMesh.H" #include "pointFields.H" #include "slipPointPatchFields.H" #include "fixedValuePointPatchFields.H" #include "calculatedPointPatchFields.H" #include "processorPointPatch.H" #include "globalIndex.H" #include "meshTools.H" #include "OFstream.H" #include "geomDecomp.H" #include "Random.H" #include "searchableSurfaces.H" #include "treeBoundBox.H" #include "zeroGradientFvPatchFields.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { defineTypeNameAndDebug(meshRefinement, 0); } // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // void Foam::meshRefinement::calcNeighbourData ( labelList& neiLevel, pointField& neiCc ) const { const labelList& cellLevel = meshCutter_.cellLevel(); const pointField& cellCentres = mesh_.cellCentres(); label nBoundaryFaces = mesh_.nFaces() - mesh_.nInternalFaces(); if (neiLevel.size() != nBoundaryFaces || neiCc.size() != nBoundaryFaces) { FatalErrorIn("meshRefinement::calcNeighbour(..)") << "nBoundaries:" << nBoundaryFaces << " neiLevel:" << neiLevel.size() << abort(FatalError); } const polyBoundaryMesh& patches = mesh_.boundaryMesh(); labelHashSet addedPatchIDSet(meshedPatches()); forAll(patches, patchI) { const polyPatch& pp = patches[patchI]; const unallocLabelList& faceCells = pp.faceCells(); const vectorField::subField faceCentres = pp.faceCentres(); const vectorField::subField faceAreas = pp.faceAreas(); label bFaceI = pp.start()-mesh_.nInternalFaces(); if (pp.coupled()) { forAll(faceCells, i) { neiLevel[bFaceI] = cellLevel[faceCells[i]]; neiCc[bFaceI] = cellCentres[faceCells[i]]; bFaceI++; } } else if (addedPatchIDSet.found(patchI)) { // Face was introduced from cell-cell intersection. Try to // reconstruct other side cell(centre). Three possibilities: // - cells same size. // - preserved cell smaller. Not handled. // - preserved cell larger. forAll(faceCells, i) { // Extrapolate the face centre. vector fn = faceAreas[i]; fn /= mag(fn)+VSMALL; label own = faceCells[i]; label ownLevel = cellLevel[own]; label faceLevel = meshCutter_.getAnchorLevel(pp.start()+i); // Normal distance from face centre to cell centre scalar d = ((faceCentres[i] - cellCentres[own]) & fn); if (faceLevel > ownLevel) { // Other cell more refined. Adjust normal distance d *= 0.5; } neiLevel[bFaceI] = cellLevel[ownLevel]; // Calculate other cell centre by extrapolation neiCc[bFaceI] = faceCentres[i] + d*fn; bFaceI++; } } else { forAll(faceCells, i) { neiLevel[bFaceI] = cellLevel[faceCells[i]]; neiCc[bFaceI] = faceCentres[i]; bFaceI++; } } } // Swap coupled boundaries. Apply separation to cc since is coordinate. syncTools::swapBoundaryFaceList(mesh_, neiCc, true); syncTools::swapBoundaryFaceList(mesh_, neiLevel, false); } // Find intersections of edges (given by their two endpoints) with surfaces. // Returns first intersection if there are more than one. void Foam::meshRefinement::updateIntersections(const labelList& changedFaces) { const pointField& cellCentres = mesh_.cellCentres(); // Stats on edges to test. Count proc faces only once. PackedBoolList isMasterFace(syncTools::getMasterFaces(mesh_)); { label nMasterFaces = 0; forAll(isMasterFace, faceI) { if (isMasterFace.get(faceI) == 1) { nMasterFaces++; } } reduce(nMasterFaces, sumOp