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 "setsToFaceZone.H"
00027 #include <OpenFOAM/polyMesh.H>
00028 #include <meshTools/faceZoneSet.H>
00029 #include <meshTools/cellSet.H>
00030
00031 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00032
00033
00034
00035 namespace Foam
00036 {
00037 defineTypeNameAndDebug(setsToFaceZone, 0);
00038 addToRunTimeSelectionTable(topoSetSource, setsToFaceZone, word);
00039 addToRunTimeSelectionTable(topoSetSource, setsToFaceZone, istream);
00040 }
00041
00042
00043 Foam::topoSetSource::addToUsageTable Foam::setsToFaceZone::usage_
00044 (
00045 setsToFaceZone::typeName,
00046 "\n Usage: setsToFaceZone <faceSet> <slaveCellSet>\n\n"
00047 " Select all faces in the faceSet."
00048 " Orientated so slave side is in cellSet.\n\n"
00049 );
00050
00051
00052
00053
00054
00055 Foam::setsToFaceZone::setsToFaceZone
00056 (
00057 const polyMesh& mesh,
00058 const word& faceSetName,
00059 const word& cellSetName
00060 )
00061 :
00062 topoSetSource(mesh),
00063 faceSetName_(faceSetName),
00064 cellSetName_(cellSetName)
00065 {}
00066
00067
00068
00069 Foam::setsToFaceZone::setsToFaceZone
00070 (
00071 const polyMesh& mesh,
00072 const dictionary& dict
00073 )
00074 :
00075 topoSetSource(mesh),
00076 faceSetName_(dict.lookup("faceSet")),
00077 cellSetName_(dict.lookup("cellSet"))
00078 {}
00079
00080
00081
00082 Foam::setsToFaceZone::setsToFaceZone
00083 (
00084 const polyMesh& mesh,
00085 Istream& is
00086 )
00087 :
00088 topoSetSource(mesh),
00089 faceSetName_(checkIs(is)),
00090 cellSetName_(checkIs(is))
00091 {}
00092
00093
00094
00095
00096 Foam::setsToFaceZone::~setsToFaceZone()
00097 {}
00098
00099
00100
00101
00102 void Foam::setsToFaceZone::applyToSet
00103 (
00104 const topoSetSource::setAction action,
00105 topoSet& set
00106 ) const
00107 {
00108 if (!isA<faceZoneSet>(set))
00109 {
00110 WarningIn
00111 (
00112 "setsToFaceZone::applyToSet(const topoSetSource::setAction"
00113 ", topoSet"
00114 ) << "Operation only allowed on a faceZoneSet." << endl;
00115 }
00116 else
00117 {
00118 faceZoneSet& fzSet = refCast<faceZoneSet>(set);
00119
00120 if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
00121 {
00122 Info<< " Adding all faces from faceSet " << faceSetName_
00123 << " ..." << endl;
00124
00125
00126 faceSet fSet(mesh_, faceSetName_);
00127 cellSet cSet(mesh_, cellSetName_);
00128
00129
00130 DynamicList<label> newAddressing(fzSet.addressing());
00131 DynamicList<bool> newFlipMap(fzSet.flipMap());
00132
00133 forAllConstIter(faceSet, fSet, iter)
00134 {
00135 label faceI = iter.key();
00136
00137 if (!fzSet.found(faceI))
00138 {
00139 bool flip = false;
00140
00141 label own = mesh_.faceOwner()[faceI];
00142 bool ownFound = cSet.found(own);
00143
00144 if (mesh_.isInternalFace(faceI))
00145 {
00146 label nei = mesh_.faceNeighbour()[faceI];
00147 bool neiFound = cSet.found(nei);
00148
00149 if (ownFound && !neiFound)
00150 {
00151 flip = false;
00152 }
00153 else if (!ownFound && neiFound)
00154 {
00155 flip = true;
00156 }
00157 else
00158 {
00159 WarningIn
00160 (
00161 "setsToFaceZone::applyToSet"
00162 "(const topoSetSource::setAction, topoSet)"
00163 ) << "One of owner or neighbour of internal face "
00164 << faceI << " should be in cellSet "
00165 << cSet.name()
00166 << " to be able to determine orientation."
00167 << endl
00168 << "Face:" << faceI << " own:" << own
00169 << " OwnInCellSet:" << ownFound
00170 << " nei:" << nei
00171 << " NeiInCellSet:" << neiFound
00172 << endl;
00173 }
00174 }
00175 else
00176 {
00177 flip = !ownFound;
00178 }
00179
00180 newAddressing.append(faceI);
00181 newFlipMap.append(flip);
00182 }
00183 }
00184
00185 fzSet.addressing().transfer(newAddressing);
00186 fzSet.flipMap().transfer(newFlipMap);
00187 fzSet.updateSet();
00188 }
00189 else if (action == topoSetSource::DELETE)
00190 {
00191 Info<< " Removing all faces from faceSet " << faceSetName_
00192 << " ..." << endl;
00193
00194
00195 faceZoneSet loadedSet(mesh_, faceSetName_);
00196
00197
00198 DynamicList<label> newAddressing(fzSet.addressing().size());
00199 DynamicList<bool> newFlipMap(fzSet.flipMap().size());
00200
00201 forAll(fzSet.addressing(), i)
00202 {
00203 if (!loadedSet.found(fzSet.addressing()[i]))
00204 {
00205 newAddressing.append(fzSet.addressing()[i]);
00206 newFlipMap.append(fzSet.flipMap()[i]);
00207 }
00208 }
00209 fzSet.addressing().transfer(newAddressing);
00210 fzSet.flipMap().transfer(newFlipMap);
00211 fzSet.updateSet();
00212 }
00213 }
00214 }
00215
00216
00217