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