Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "nbrToCell.H"
00027 #include <OpenFOAM/polyMesh.H>
00028
00029 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00030
00031
00032
00033 namespace Foam
00034 {
00035
00036 defineTypeNameAndDebug(nbrToCell, 0);
00037
00038 addToRunTimeSelectionTable(topoSetSource, nbrToCell, word);
00039
00040 addToRunTimeSelectionTable(topoSetSource, nbrToCell, istream);
00041
00042 }
00043
00044
00045 Foam::topoSetSource::addToUsageTable Foam::nbrToCell::usage_
00046 (
00047 nbrToCell::typeName,
00048 "\n Usage: nbrToCell <nNeighbours>\n\n"
00049 " Select all cells with <= nNeighbours neighbouring cells\n\n"
00050 );
00051
00052
00053
00054
00055 void Foam::nbrToCell::combine(topoSet& set, const bool add) const
00056 {
00057 const cellList& cells = mesh().cells();
00058 const polyBoundaryMesh& patches = mesh_.boundaryMesh();
00059
00060 boolList isCoupled(mesh_.nFaces()-mesh_.nInternalFaces(), false);
00061
00062 forAll(patches, patchI)
00063 {
00064 const polyPatch& pp = patches[patchI];
00065
00066 if (pp.coupled())
00067 {
00068 label faceI = pp.start();
00069 forAll(pp, i)
00070 {
00071 isCoupled[faceI-mesh_.nInternalFaces()] = true;
00072 faceI++;
00073 }
00074 }
00075 }
00076
00077 forAll(cells, cellI)
00078 {
00079 const cell& cFaces = cells[cellI];
00080
00081 label nNbrCells = 0;
00082
00083 forAll(cFaces, i)
00084 {
00085 label faceI = cFaces[i];
00086
00087 if (mesh_.isInternalFace(faceI))
00088 {
00089 nNbrCells++;
00090 }
00091 else if (isCoupled[faceI-mesh_.nInternalFaces()])
00092 {
00093 nNbrCells++;
00094 }
00095 }
00096
00097 if (nNbrCells <= minNbrs_)
00098 {
00099 addOrDelete(set, cellI, add);
00100 }
00101 }
00102 }
00103
00104
00105
00106
00107
00108 Foam::nbrToCell::nbrToCell
00109 (
00110 const polyMesh& mesh,
00111 const label minNbrs
00112 )
00113 :
00114 topoSetSource(mesh),
00115 minNbrs_(minNbrs)
00116 {}
00117
00118
00119
00120 Foam::nbrToCell::nbrToCell
00121 (
00122 const polyMesh& mesh,
00123 const dictionary& dict
00124 )
00125 :
00126 topoSetSource(mesh),
00127 minNbrs_(readLabel(dict.lookup("neighbours")))
00128 {}
00129
00130
00131
00132 Foam::nbrToCell::nbrToCell
00133 (
00134 const polyMesh& mesh,
00135 Istream& is
00136 )
00137 :
00138 topoSetSource(mesh),
00139 minNbrs_(readLabel(checkIs(is)))
00140 {}
00141
00142
00143
00144
00145 Foam::nbrToCell::~nbrToCell()
00146 {}
00147
00148
00149
00150
00151 void Foam::nbrToCell::applyToSet
00152 (
00153 const topoSetSource::setAction action,
00154 topoSet& set
00155 ) const
00156 {
00157 if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
00158 {
00159 Info<< " Adding cells with only " << minNbrs_ << " or less"
00160 " neighbouring cells" << " ..." << endl;
00161
00162 combine(set, true);
00163 }
00164 else if (action == topoSetSource::DELETE)
00165 {
00166 Info<< " Removing cells with only " << minNbrs_ << " or less"
00167 " neighbouring cells" << " ..." << endl;
00168
00169 combine(set, false);
00170 }
00171 }
00172
00173
00174