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