pointToFace.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 "pointToFace.H"
00030 #include "polyMesh.H"
00031 #include "pointSet.H"
00032
00033 #include "addToRunTimeSelectionTable.H"
00034
00035
00036
00037 namespace Foam
00038 {
00039
00040 defineTypeNameAndDebug(pointToFace, 0);
00041
00042 addToRunTimeSelectionTable(topoSetSource, pointToFace, word);
00043
00044 addToRunTimeSelectionTable(topoSetSource, pointToFace, istream);
00045
00046 }
00047
00048
00049 Foam::topoSetSource::addToUsageTable Foam::pointToFace::usage_
00050 (
00051 pointToFace::typeName,
00052 "\n Usage: pointToFace <pointSet> any|all\n\n"
00053 " Select faces with\n"
00054 " -any point in the pointSet\n"
00055 " -all points in the pointSet\n\n"
00056 );
00057
00058 template<>
00059 const char* Foam::NamedEnum<Foam::pointToFace::pointAction, 2>::names[] =
00060 {
00061 "any",
00062 "all"
00063 };
00064
00065 const Foam::NamedEnum<Foam::pointToFace::pointAction, 2>
00066 Foam::pointToFace::pointActionNames_;
00067
00068
00069
00070
00071 void Foam::pointToFace::combine(topoSet& set, const bool add) const
00072 {
00073
00074 pointSet loadedSet(mesh_, setName_);
00075
00076 if (option_ == ANY)
00077 {
00078
00079 for
00080 (
00081 pointSet::const_iterator iter = loadedSet.begin();
00082 iter != loadedSet.end();
00083 ++iter
00084 )
00085 {
00086 label pointI = iter.key();
00087
00088 const labelList& pFaces = mesh_.pointFaces()[pointI];
00089
00090 forAll(pFaces, pFaceI)
00091 {
00092 addOrDelete(set, pFaces[pFaceI], add);
00093 }
00094 }
00095 }
00096 else if (option_ == ALL)
00097 {
00098
00099
00100
00101 Map<label> numPoints(loadedSet.size());
00102
00103 forAllConstIter(pointSet, loadedSet, iter)
00104 {
00105 label pointI = iter.key();
00106
00107 const labelList& pFaces = mesh_.pointFaces()[pointI];
00108
00109 forAll(pFaces, pFaceI)
00110 {
00111 label faceI = pFaces[pFaceI];
00112
00113 Map<label>::iterator fndFace = numPoints.find(faceI);
00114
00115 if (fndFace == numPoints.end())
00116 {
00117 numPoints.insert(faceI, 1);
00118 }
00119 else
00120 {
00121 fndFace()++;
00122 }
00123 }
00124 }
00125
00126
00127
00128
00129 for
00130 (
00131 Map<label>::const_iterator iter = numPoints.begin();
00132 iter != numPoints.end();
00133 ++iter
00134 )
00135 {
00136 label faceI = iter.key();
00137
00138 if (iter() == mesh_.faces()[faceI].size())
00139 {
00140 addOrDelete(set, faceI, add);
00141 }
00142 }
00143 }
00144 }
00145
00146
00147
00148
00149
00150 Foam::pointToFace::pointToFace
00151 (
00152 const polyMesh& mesh,
00153 const word& setName,
00154 const pointAction option
00155 )
00156 :
00157 topoSetSource(mesh),
00158 setName_(setName),
00159 option_(option)
00160 {}
00161
00162
00163
00164 Foam::pointToFace::pointToFace
00165 (
00166 const polyMesh& mesh,
00167 const dictionary& dict
00168 )
00169 :
00170 topoSetSource(mesh),
00171 setName_(dict.lookup("set")),
00172 option_(pointActionNames_.read(dict.lookup("option")))
00173 {}
00174
00175
00176
00177 Foam::pointToFace::pointToFace
00178 (
00179 const polyMesh& mesh,
00180 Istream& is
00181 )
00182 :
00183 topoSetSource(mesh),
00184 setName_(checkIs(is)),
00185 option_(pointActionNames_.read(checkIs(is)))
00186 {}
00187
00188
00189
00190
00191 Foam::pointToFace::~pointToFace()
00192 {}
00193
00194
00195
00196
00197 void Foam::pointToFace::applyToSet
00198 (
00199 const topoSetSource::setAction action,
00200 topoSet& set
00201 ) const
00202 {
00203 if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
00204 {
00205 Info<< " Adding faces according to pointSet " << setName_
00206 << " ..." << endl;
00207
00208 combine(set, true);
00209 }
00210 else if (action == topoSetSource::DELETE)
00211 {
00212 Info<< " Removing faces according to pointSet " << setName_
00213 << " ..." << endl;
00214
00215 combine(set, false);
00216 }
00217 }
00218
00219
00220
Copyright © 2000-2009 OpenCFD Ltd