shapeToCell.C
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
00027
00028
00029 #include "shapeToCell.H"
00030 #include "polyMesh.H"
00031 #include "mathematicalConstants.H"
00032 #include "hexMatcher.H"
00033 #include "cellFeatures.H"
00034
00035 #include "addToRunTimeSelectionTable.H"
00036
00037
00038
00039 namespace Foam
00040 {
00041
00042 defineTypeNameAndDebug(shapeToCell, 0);
00043
00044 addToRunTimeSelectionTable(topoSetSource, shapeToCell, word);
00045
00046 addToRunTimeSelectionTable(topoSetSource, shapeToCell, istream);
00047
00048 }
00049
00050
00051 Foam::topoSetSource::addToUsageTable Foam::shapeToCell::usage_
00052 (
00053 shapeToCell::typeName,
00054 "\n Usage: shapeToCell tet|pyr|prism|hex|tetWedge|wedge|splitHex\n\n"
00055 " Select all cells of given cellShape.\n"
00056 " (splitHex hardcoded with internal angle < 10 degrees)\n"
00057 );
00058
00059
00060
00061 Foam::scalar Foam::shapeToCell::featureCos =
00062 Foam::cos(10.0 * mathematicalConstant::pi/180.0);
00063
00064
00065
00066
00067 void Foam::shapeToCell::combine(topoSet& set, const bool add) const
00068 {
00069 if (type_ == "splitHex")
00070 {
00071 for (label cellI = 0; cellI < mesh_.nCells(); cellI++)
00072 {
00073 cellFeatures superCell(mesh_, featureCos, cellI);
00074
00075 if (hexMatcher().isA(superCell.faces()))
00076 {
00077 addOrDelete(set, cellI, add);
00078 }
00079 }
00080 }
00081 else
00082 {
00083 const cellModel& wantedModel = *(cellModeller::lookup(type_));
00084
00085 const cellShapeList& cellShapes = mesh_.cellShapes();
00086
00087 forAll(cellShapes, cellI)
00088 {
00089 if (cellShapes[cellI].model() == wantedModel)
00090 {
00091 addOrDelete(set, cellI, add);
00092 }
00093 }
00094 }
00095 }
00096
00097
00098
00099
00100
00101 Foam::shapeToCell::shapeToCell
00102 (
00103 const polyMesh& mesh,
00104 const word& type
00105 )
00106 :
00107 topoSetSource(mesh),
00108 type_(type)
00109 {
00110 if (!cellModeller::lookup(type_) && (type_ != "splitHex"))
00111 {
00112 FatalErrorIn
00113 (
00114 "shapeToCell::shapeToCell(const polyMesh&, const word&)"
00115 ) << "Illegal cell type " << type_ << exit(FatalError);
00116 }
00117 }
00118
00119
00120
00121 Foam::shapeToCell::shapeToCell
00122 (
00123 const polyMesh& mesh,
00124 const dictionary& dict
00125 )
00126 :
00127 topoSetSource(mesh),
00128 type_(dict.lookup("type"))
00129 {
00130 if (!cellModeller::lookup(type_) && (type_ != "splitHex"))
00131 {
00132 FatalErrorIn
00133 (
00134 "shapeToCell::shapeToCell(const polyMesh&, const dictionary&)"
00135 ) << "Illegal cell type " << type_ << exit(FatalError);
00136 }
00137 }
00138
00139
00140
00141 Foam::shapeToCell::shapeToCell
00142 (
00143 const polyMesh& mesh,
00144 Istream& is
00145 )
00146 :
00147 topoSetSource(mesh),
00148 type_(checkIs(is))
00149 {
00150 if (!cellModeller::lookup(type_) && (type_ != "splitHex"))
00151 {
00152 FatalErrorIn
00153 (
00154 "shapeToCell::shapeToCell(const polyMesh&, Istream&)"
00155 ) << "Illegal cell type " << type_ << exit(FatalError);
00156 }
00157 }
00158
00159
00160
00161 Foam::shapeToCell::~shapeToCell()
00162 {}
00163
00164
00165
00166
00167 void Foam::shapeToCell::applyToSet
00168 (
00169 const topoSetSource::setAction action,
00170 topoSet& set
00171 ) const
00172 {
00173 if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
00174 {
00175 Info<< " Adding all cells of type " << type_ << " ..." << endl;
00176
00177 combine(set, true);
00178 }
00179 else if (action == topoSetSource::DELETE)
00180 {
00181 Info<< " Removing all cells of type " << type_ << " ..." << endl;
00182
00183 combine(set, false);
00184 }
00185 }
00186
00187
00188
Copyright © 2000-2009 OpenCFD Ltd