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