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