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 "pointToCell.H"
00027 #include <OpenFOAM/polyMesh.H>
00028 #include <meshTools/pointSet.H>
00029 
00030 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00031 
00032 
00033 
00034 namespace Foam
00035 {
00036 
00037 defineTypeNameAndDebug(pointToCell, 0);
00038 
00039 addToRunTimeSelectionTable(topoSetSource, pointToCell, word);
00040 
00041 addToRunTimeSelectionTable(topoSetSource, pointToCell, istream);
00042 
00043 }
00044 
00045 
00046 Foam::topoSetSource::addToUsageTable Foam::pointToCell::usage_
00047 (
00048     pointToCell::typeName,
00049     "\n    Usage: pointToCell <pointSet> any\n\n"
00050     "    Select all cells with any point in the pointSet\n\n"
00051 );
00052 
00053 template<>
00054 const char* Foam::NamedEnum<Foam::pointToCell::pointAction, 1>::names[] =
00055 {
00056     "any"
00057 };
00058 
00059 
00060 const Foam::NamedEnum<Foam::pointToCell::pointAction, 1>
00061     Foam::pointToCell::pointActionNames_;
00062 
00063 
00064 
00065 
00066 void Foam::pointToCell::combine(topoSet& set, const bool add) const
00067 {
00068     
00069     pointSet loadedSet(mesh_, setName_);
00070 
00071 
00072     
00073     if (option_ == ANY)
00074     {
00075         for
00076         (
00077             pointSet::const_iterator iter = loadedSet.begin();
00078             iter != loadedSet.end();
00079             ++iter
00080         )
00081         {
00082             label pointI = iter.key();
00083 
00084             const labelList& pCells = mesh_.pointCells()[pointI];
00085 
00086             forAll(pCells, pCellI)
00087             {
00088                 addOrDelete(set, pCells[pCellI], add);
00089             }
00090         }
00091     }
00092 }
00093 
00094 
00095 
00096 
00097 
00098 Foam::pointToCell::pointToCell
00099 (
00100     const polyMesh& mesh,
00101     const word& setName,
00102     const pointAction option
00103 )
00104 :
00105     topoSetSource(mesh),
00106     setName_(setName),
00107     option_(option)
00108 {}
00109 
00110 
00111 
00112 Foam::pointToCell::pointToCell
00113 (
00114     const polyMesh& mesh,
00115     const dictionary& dict
00116 )
00117 :
00118     topoSetSource(mesh),
00119     setName_(dict.lookup("set")),
00120     option_(pointActionNames_.read(dict.lookup("option")))
00121 {}
00122 
00123 
00124 
00125 Foam::pointToCell::pointToCell
00126 (
00127     const polyMesh& mesh,
00128     Istream& is
00129 )
00130 :
00131     topoSetSource(mesh),
00132     setName_(checkIs(is)),
00133     option_(pointActionNames_.read(checkIs(is)))
00134 {}
00135 
00136 
00137 
00138 
00139 Foam::pointToCell::~pointToCell()
00140 {}
00141 
00142 
00143 
00144 
00145 void Foam::pointToCell::applyToSet
00146 (
00147     const topoSetSource::setAction action,
00148     topoSet& set
00149 ) const
00150 {
00151     if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
00152     {
00153         Info<< "    Adding cells according to pointSet " << setName_
00154             << " ..." << endl;
00155 
00156         combine(set, true);
00157     }
00158     else if (action == topoSetSource::DELETE)
00159     {
00160         Info<< "    Removing cells according to pointSet " << setName_
00161             << " ..." << endl;
00162 
00163         combine(set, false);
00164     }
00165 }
00166 
00167 
00168