cellToFace.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 #include "cellToFace.H"
00028 #include "polyMesh.H"
00029 #include "cellSet.H"
00030 #include "Time.H"
00031 #include "syncTools.H"
00032 #include "addToRunTimeSelectionTable.H"
00033
00034
00035
00036 namespace Foam
00037 {
00038
00039 defineTypeNameAndDebug(cellToFace, 0);
00040
00041 addToRunTimeSelectionTable(topoSetSource, cellToFace, word);
00042
00043 addToRunTimeSelectionTable(topoSetSource, cellToFace, istream);
00044
00045 }
00046
00047
00048 Foam::topoSetSource::addToUsageTable Foam::cellToFace::usage_
00049 (
00050 cellToFace::typeName,
00051 "\n Usage: cellToFace <cellSet> all|both\n\n"
00052 " Select -all : all faces of cells in the cellSet\n"
00053 " -both: faces where both neighbours are in the cellSet\n\n"
00054 );
00055
00056 template<>
00057 const char* Foam::NamedEnum<Foam::cellToFace::cellAction, 2>::names[] =
00058 {
00059 "all",
00060 "both"
00061 };
00062
00063 const Foam::NamedEnum<Foam::cellToFace::cellAction, 2>
00064 Foam::cellToFace::cellActionNames_;
00065
00066
00067
00068
00069 void Foam::cellToFace::combine(topoSet& set, const bool add) const
00070 {
00071
00072 if (!exists(mesh_.time().path()/topoSet::localPath(mesh_, setName_)))
00073 {
00074 SeriousError<< "Cannot load set "
00075 << setName_ << endl;
00076 }
00077
00078 cellSet loadedSet(mesh_, setName_);
00079
00080 if (option_ == ALL)
00081 {
00082
00083 for
00084 (
00085 cellSet::const_iterator iter = loadedSet.begin();
00086 iter != loadedSet.end();
00087 ++iter
00088 )
00089 {
00090 label cellI = iter.key();
00091
00092 const labelList& cFaces = mesh_.cells()[cellI];
00093
00094 forAll(cFaces, cFaceI)
00095 {
00096 addOrDelete(set, cFaces[cFaceI], add);
00097 }
00098 }
00099 }
00100 else if (option_ == BOTH)
00101 {
00102
00103
00104 label nInt = mesh_.nInternalFaces();
00105 const labelList& own = mesh_.faceOwner();
00106 const labelList& nei = mesh_.faceNeighbour();
00107 const polyBoundaryMesh& patches = mesh_.boundaryMesh();
00108
00109
00110
00111 for (label faceI = 0; faceI < nInt; faceI++)
00112 {
00113 if (loadedSet.found(own[faceI]) && loadedSet.found(nei[faceI]))
00114 {
00115 addOrDelete(set, faceI, add);
00116 }
00117 }
00118
00119
00120
00121 boolList neiInSet(mesh_.nFaces()-nInt, false);
00122
00123 forAll(patches, patchI)
00124 {
00125 const polyPatch& pp = patches[patchI];
00126
00127 if (pp.coupled())
00128 {
00129 label faceI = pp.start();
00130 forAll(pp, i)
00131 {
00132 neiInSet[faceI-nInt] = loadedSet.found(own[faceI]);
00133 faceI++;
00134 }
00135 }
00136 }
00137 syncTools::swapBoundaryFaceList(mesh_, neiInSet, false);
00138
00139
00140
00141 forAll(patches, patchI)
00142 {
00143 const polyPatch& pp = patches[patchI];
00144
00145 if (pp.coupled())
00146 {
00147 label faceI = pp.start();
00148 forAll(pp, i)
00149 {
00150 if (loadedSet.found(own[faceI]) && neiInSet[faceI-nInt])
00151 {
00152 addOrDelete(set, faceI, add);
00153 }
00154 faceI++;
00155 }
00156 }
00157 }
00158 }
00159 }
00160
00161
00162
00163
00164
00165 Foam::cellToFace::cellToFace
00166 (
00167 const polyMesh& mesh,
00168 const word& setName,
00169 const cellAction option
00170 )
00171 :
00172 topoSetSource(mesh),
00173 setName_(setName),
00174 option_(option)
00175 {}
00176
00177
00178
00179 Foam::cellToFace::cellToFace
00180 (
00181 const polyMesh& mesh,
00182 const dictionary& dict
00183 )
00184 :
00185 topoSetSource(mesh),
00186 setName_(dict.lookup("set")),
00187 option_(cellActionNames_.read(dict.lookup("option")))
00188 {}
00189
00190
00191
00192 Foam::cellToFace::cellToFace
00193 (
00194 const polyMesh& mesh,
00195 Istream& is
00196 )
00197 :
00198 topoSetSource(mesh),
00199 setName_(checkIs(is)),
00200 option_(cellActionNames_.read(checkIs(is)))
00201 {}
00202
00203
00204
00205
00206 Foam::cellToFace::~cellToFace()
00207 {}
00208
00209
00210
00211
00212 void Foam::cellToFace::applyToSet
00213 (
00214 const topoSetSource::setAction action,
00215 topoSet& set
00216 ) const
00217 {
00218 if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
00219 {
00220 Pout<< " Adding faces according to cellSet " << setName_
00221 << " ..." << endl;
00222
00223 combine(set, true);
00224 }
00225 else if (action == topoSetSource::DELETE)
00226 {
00227 Pout<< " Removing faces according to cellSet " << setName_
00228 << " ..." << endl;
00229
00230 combine(set, false);
00231 }
00232 }
00233
00234
00235
Copyright © 2000-2009 OpenCFD Ltd