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 "setToFaceZone.H"
00027 #include <OpenFOAM/polyMesh.H>
00028 #include <meshTools/faceZoneSet.H>
00029
00030 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00031
00032
00033
00034 namespace Foam
00035 {
00036
00037 defineTypeNameAndDebug(setToFaceZone, 0);
00038
00039 addToRunTimeSelectionTable(topoSetSource, setToFaceZone, word);
00040
00041 addToRunTimeSelectionTable(topoSetSource, setToFaceZone, istream);
00042
00043 }
00044
00045
00046 Foam::topoSetSource::addToUsageTable Foam::setToFaceZone::usage_
00047 (
00048 setToFaceZone::typeName,
00049 "\n Usage: setToFaceZone <faceSet>\n\n"
00050 " Select all faces in the faceSet."
00051 " Sets flipMap.\n\n"
00052 );
00053
00054
00055
00056
00057
00058 Foam::setToFaceZone::setToFaceZone
00059 (
00060 const polyMesh& mesh,
00061 const word& setName
00062 )
00063 :
00064 topoSetSource(mesh),
00065 setName_(setName)
00066 {}
00067
00068
00069
00070 Foam::setToFaceZone::setToFaceZone
00071 (
00072 const polyMesh& mesh,
00073 const dictionary& dict
00074 )
00075 :
00076 topoSetSource(mesh),
00077 setName_(dict.lookup("faceSet"))
00078 {}
00079
00080
00081
00082 Foam::setToFaceZone::setToFaceZone
00083 (
00084 const polyMesh& mesh,
00085 Istream& is
00086 )
00087 :
00088 topoSetSource(mesh),
00089 setName_(checkIs(is))
00090 {}
00091
00092
00093
00094
00095 Foam::setToFaceZone::~setToFaceZone()
00096 {}
00097
00098
00099
00100
00101 void Foam::setToFaceZone::applyToSet
00102 (
00103 const topoSetSource::setAction action,
00104 topoSet& set
00105 ) const
00106 {
00107 if (!isA<faceZoneSet>(set))
00108 {
00109 WarningIn
00110 (
00111 "setToFaceZone::applyToSet(const topoSetSource::setAction"
00112 ", topoSet"
00113 ) << "Operation only allowed on a faceZoneSet." << endl;
00114 }
00115 else
00116 {
00117 faceZoneSet& fzSet = refCast<faceZoneSet>(set);
00118
00119 if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
00120 {
00121 Info<< " Adding all faces from faceSet " << setName_
00122 << " ..." << endl;
00123
00124
00125 faceSet fSet(mesh_, setName_);
00126
00127
00128 DynamicList<label> newAddressing(fzSet.addressing());
00129 DynamicList<bool> newFlipMap(fzSet.flipMap());
00130
00131 forAllConstIter(faceSet, fSet, iter)
00132 {
00133 label faceI = iter.key();
00134
00135 if (!fzSet.found(faceI))
00136 {
00137 newAddressing.append(faceI);
00138 newFlipMap.append(false);
00139 }
00140 }
00141
00142 fzSet.addressing().transfer(newAddressing);
00143 fzSet.flipMap().transfer(newFlipMap);
00144 fzSet.updateSet();
00145 }
00146 else if (action == topoSetSource::DELETE)
00147 {
00148 Info<< " Removing all faces from faceSet " << setName_
00149 << " ..." << endl;
00150
00151
00152 faceSet loadedSet(mesh_, setName_);
00153
00154
00155 DynamicList<label> newAddressing(fzSet.addressing().size());
00156 DynamicList<bool> newFlipMap(fzSet.flipMap().size());
00157
00158 forAll(fzSet.addressing(), i)
00159 {
00160 if (!loadedSet.found(fzSet.addressing()[i]))
00161 {
00162 newAddressing.append(fzSet.addressing()[i]);
00163 newFlipMap.append(fzSet.flipMap()[i]);
00164 }
00165 }
00166 fzSet.addressing().transfer(newAddressing);
00167 fzSet.flipMap().transfer(newFlipMap);
00168 fzSet.updateSet();
00169 }
00170 }
00171 }
00172
00173
00174