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