1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "shapeToCell.H"
28 #include "mathematicalConstants.H"
29 #include "hexMatcher.H"
30 #include "cellFeatures.H"
32 #include "addToRunTimeSelectionTable.H"
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
39 defineTypeNameAndDebug(shapeToCell, 0);
41 addToRunTimeSelectionTable(topoSetSource, shapeToCell, word);
43 addToRunTimeSelectionTable(topoSetSource, shapeToCell, istream);
48 Foam::topoSetSource::addToUsageTable Foam::shapeToCell::usage_
50 shapeToCell::typeName,
51 "\n Usage: shapeToCell tet|pyr|prism|hex|tetWedge|wedge|splitHex\n\n"
52 " Select all cells of given cellShape.\n"
53 " (splitHex hardcoded with internal angle < 10 degrees)\n"
57 // Angle for polys to be considered splitHexes.
58 Foam::scalar Foam::shapeToCell::featureCos =
59 Foam::cos(10.0 * mathematicalConstant::pi/180.0);
62 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
64 void Foam::shapeToCell::combine(topoSet& set, const bool add) const
66 if (type_ == "splitHex")
68 for (label cellI = 0; cellI < mesh_.nCells(); cellI++)
70 cellFeatures superCell(mesh_, featureCos, cellI);
72 if (hexMatcher().isA(superCell.faces()))
74 addOrDelete(set, cellI, add);
80 const cellModel& wantedModel = *(cellModeller::lookup(type_));
82 const cellShapeList& cellShapes = mesh_.cellShapes();
84 forAll(cellShapes, cellI)
86 if (cellShapes[cellI].model() == wantedModel)
88 addOrDelete(set, cellI, add);
95 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
97 // Construct from components
98 Foam::shapeToCell::shapeToCell
100 const polyMesh& mesh,
107 if (!cellModeller::lookup(type_) && (type_ != "splitHex"))
111 "shapeToCell::shapeToCell(const polyMesh&, const word&)"
112 ) << "Illegal cell type " << type_ << exit(FatalError);
117 // Construct from dictionary
118 Foam::shapeToCell::shapeToCell
120 const polyMesh& mesh,
121 const dictionary& dict
125 type_(dict.lookup("type"))
127 if (!cellModeller::lookup(type_) && (type_ != "splitHex"))
131 "shapeToCell::shapeToCell(const polyMesh&, const dictionary&)"
132 ) << "Illegal cell type " << type_ << exit(FatalError);
137 // Construct from Istream
138 Foam::shapeToCell::shapeToCell
140 const polyMesh& mesh,
147 if (!cellModeller::lookup(type_) && (type_ != "splitHex"))
151 "shapeToCell::shapeToCell(const polyMesh&, Istream&)"
152 ) << "Illegal cell type " << type_ << exit(FatalError);
156 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
158 Foam::shapeToCell::~shapeToCell()
162 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
164 void Foam::shapeToCell::applyToSet
166 const topoSetSource::setAction action,
170 if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
172 Info<< " Adding all cells of type " << type_ << " ..." << endl;
176 else if (action == topoSetSource::DELETE)
178 Info<< " Removing all cells of type " << type_ << " ..." << endl;
185 // ************************************************************************* //