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 "faceZoneToCell.H"
00027 #include <OpenFOAM/polyMesh.H>
00028
00029 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00030
00031
00032
00033 namespace Foam
00034 {
00035
00036 defineTypeNameAndDebug(faceZoneToCell, 0);
00037
00038 addToRunTimeSelectionTable(topoSetSource, faceZoneToCell, word);
00039
00040 addToRunTimeSelectionTable(topoSetSource, faceZoneToCell, istream);
00041
00042 }
00043
00044
00045 Foam::topoSetSource::addToUsageTable Foam::faceZoneToCell::usage_
00046 (
00047 faceZoneToCell::typeName,
00048 "\n Usage: faceZoneToCell zone master|slave\n\n"
00049 " Select master or slave side of the faceZone."
00050 " Note:accepts wildcards for zone.\n\n"
00051 );
00052
00053
00054 template<>
00055 const char* Foam::NamedEnum<Foam::faceZoneToCell::faceAction, 2>::names[] =
00056 {
00057 "master",
00058 "slave"
00059 };
00060
00061
00062 const Foam::NamedEnum<Foam::faceZoneToCell::faceAction, 2>
00063 Foam::faceZoneToCell::faceActionNames_;
00064
00065
00066
00067
00068 void Foam::faceZoneToCell::combine(topoSet& set, const bool add) const
00069 {
00070 bool hasMatched = false;
00071
00072 forAll(mesh_.faceZones(), i)
00073 {
00074 const faceZone& zone = mesh_.faceZones()[i];
00075
00076 if (zoneName_.match(zone.name()))
00077 {
00078 const labelList& cellLabels =
00079 (
00080 option_ == MASTER
00081 ? zone.masterCells()
00082 : zone.slaveCells()
00083 );
00084
00085 Info<< " Found matching zone " << zone.name()
00086 << " with " << cellLabels.size() << " cells on selected side."
00087 << endl;
00088
00089 hasMatched = true;
00090
00091 forAll(cellLabels, i)
00092 {
00093
00094 if (cellLabels[i] < mesh_.nCells())
00095 {
00096 addOrDelete(set, cellLabels[i], add);
00097 }
00098 }
00099 }
00100 }
00101
00102 if (!hasMatched)
00103 {
00104 WarningIn("faceZoneToCell::combine(topoSet&, const bool)")
00105 << "Cannot find any faceZone named " << zoneName_ << endl
00106 << "Valid names are " << mesh_.faceZones().names() << endl;
00107 }
00108 }
00109
00110
00111
00112
00113
00114 Foam::faceZoneToCell::faceZoneToCell
00115 (
00116 const polyMesh& mesh,
00117 const word& zoneName,
00118 const faceAction option
00119 )
00120 :
00121 topoSetSource(mesh),
00122 zoneName_(zoneName),
00123 option_(option)
00124 {}
00125
00126
00127
00128 Foam::faceZoneToCell::faceZoneToCell
00129 (
00130 const polyMesh& mesh,
00131 const dictionary& dict
00132 )
00133 :
00134 topoSetSource(mesh),
00135 zoneName_(dict.lookup("name")),
00136 option_(faceActionNames_.read(dict.lookup("option")))
00137 {}
00138
00139
00140
00141 Foam::faceZoneToCell::faceZoneToCell
00142 (
00143 const polyMesh& mesh,
00144 Istream& is
00145 )
00146 :
00147 topoSetSource(mesh),
00148 zoneName_(checkIs(is)),
00149 option_(faceActionNames_.read(checkIs(is)))
00150 {}
00151
00152
00153
00154
00155 Foam::faceZoneToCell::~faceZoneToCell()
00156 {}
00157
00158
00159
00160
00161 void Foam::faceZoneToCell::applyToSet
00162 (
00163 const topoSetSource::setAction action,
00164 topoSet& set
00165 ) const
00166 {
00167 if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
00168 {
00169 Info<< " Adding all " << faceActionNames_[option_]
00170 << " cells of faceZone " << zoneName_ << " ..." << endl;
00171
00172 combine(set, true);
00173 }
00174 else if (action == topoSetSource::DELETE)
00175 {
00176 Info<< " Removing all " << faceActionNames_[option_]
00177 << " cells of faceZone " << zoneName_ << " ..." << endl;
00178
00179 combine(set, false);
00180 }
00181 }
00182
00183
00184