/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2012 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 "outsideCellSelection.H" #include "addToRunTimeSelectionTable.H" #include "faceSet.H" #include "polyMesh.H" #include "motionSmoother.H" #include "regionSplit.H" #include "syncTools.H" #include "zeroGradientFvPatchFields.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { namespace cellSelections { defineTypeNameAndDebug(outsideCellSelection, 0); addToRunTimeSelectionTable(cellSelection, outsideCellSelection, dictionary); } } // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // Foam::tmp Foam::cellSelections::outsideCellSelection::generateField ( const word& name, const boolList& lst ) const { const fvMesh& mesh = dynamic_cast(mesh_); tmp tfld ( new volScalarField ( IOobject ( name, mesh.time().timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), mesh, dimensionedScalar(name, dimless, 0), zeroGradientFvPatchScalarField::typeName ) ); scalarField& fld = tfld().internalField(); forAll(fld, celli) { fld[celli] = 1.0*lst[celli]; } tfld().correctBoundaryConditions(); return tfld; } void Foam::cellSelections::outsideCellSelection::markRegionFaces ( const boolList& selectedCell, boolList& regionFace ) const { // Internal faces const labelList& faceOwner = mesh_.faceOwner(); const labelList& faceNeighbour = mesh_.faceNeighbour(); forAll(faceNeighbour, faceI) { if ( selectedCell[faceOwner[faceI]] != selectedCell[faceNeighbour[faceI]] ) { regionFace[faceI] = true; } } // Swap neighbour selectedCell state boolList nbrSelected; syncTools::swapBoundaryCellList(mesh_, selectedCell, nbrSelected); // Boundary faces const polyBoundaryMesh& pbm = mesh_.boundaryMesh(); forAll(pbm, patchI) { const polyPatch& pp = pbm[patchI]; const labelUList& faceCells = pp.faceCells(); forAll(faceCells, i) { label faceI = pp.start()+i; label bFaceI = faceI-mesh_.nInternalFaces(); if ( selectedCell[faceCells[i]] != selectedCell[nbrSelected[bFaceI]] ) { regionFace[faceI] = true; } } } } Foam::boolList Foam::cellSelections::outsideCellSelection::findRegions ( const bool verbose, const regionSplit& cellRegion ) const { boolList keepRegion(cellRegion.nRegions(), false); forAll(locationsInMesh_, i) { // Find the region containing the insidePoint label cellI = mesh_.findCell(locationsInMesh_[i]); label keepRegionI = -1; label keepProcI = -1; if (cellI != -1) { keepRegionI = cellRegion[cellI]; keepProcI = Pstream::myProcNo(); } reduce(keepRegionI, maxOp