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