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 "nearestToCell.H"
00027 #include <OpenFOAM/polyMesh.H>
00028 #include <meshTools/meshSearch.H>
00029
00030 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00031
00032
00033
00034 namespace Foam
00035 {
00036
00037 defineTypeNameAndDebug(nearestToCell, 0);
00038
00039 addToRunTimeSelectionTable(topoSetSource, nearestToCell, word);
00040
00041 addToRunTimeSelectionTable(topoSetSource, nearestToCell, istream);
00042
00043 }
00044
00045
00046 Foam::topoSetSource::addToUsageTable Foam::nearestToCell::usage_
00047 (
00048 nearestToCell::typeName,
00049 "\n Usage: nearestToCell (pt0 .. ptn)\n\n"
00050 " Select the nearest cell for each of the points pt0 ..ptn\n\n"
00051 );
00052
00053
00054
00055
00056 void Foam::nearestToCell::combine(topoSet& set, const bool add) const
00057 {
00058
00059 meshSearch queryMesh(mesh_, false);
00060
00061 forAll(points_, pointI)
00062 {
00063 addOrDelete(set, queryMesh.findNearestCell(points_[pointI]), add);
00064 }
00065 }
00066
00067
00068
00069
00070
00071 Foam::nearestToCell::nearestToCell
00072 (
00073 const polyMesh& mesh,
00074 const pointField& points
00075 )
00076 :
00077 topoSetSource(mesh),
00078 points_(points)
00079 {}
00080
00081
00082
00083 Foam::nearestToCell::nearestToCell
00084 (
00085 const polyMesh& mesh,
00086 const dictionary& dict
00087 )
00088 :
00089 topoSetSource(mesh),
00090 points_(dict.lookup("points"))
00091 {}
00092
00093
00094
00095 Foam::nearestToCell::nearestToCell
00096 (
00097 const polyMesh& mesh,
00098 Istream& is
00099 )
00100 :
00101 topoSetSource(mesh),
00102 points_(checkIs(is))
00103 {}
00104
00105
00106
00107
00108 Foam::nearestToCell::~nearestToCell()
00109 {}
00110
00111
00112
00113
00114 void Foam::nearestToCell::applyToSet
00115 (
00116 const topoSetSource::setAction action,
00117 topoSet& set
00118 ) const
00119 {
00120 if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
00121 {
00122 Info<< " Adding cells nearest to " << points_ << endl;
00123
00124 combine(set, true);
00125 }
00126 else if (action == topoSetSource::DELETE)
00127 {
00128 Info<< " Removing cells nearest to " << points_ << endl;
00129
00130 combine(set, false);
00131 }
00132 }
00133
00134
00135