1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM 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 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 \*---------------------------------------------------------------------------*/
29 #include "cellLooper.H"
30 #include <OpenFOAM/polyMesh.H>
31 #include <OpenFOAM/ListOps.H>
32 #include <meshTools/meshTools.H>
39 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
41 defineTypeNameAndDebug(cellLooper, 0);
42 defineRunTimeSelectionTable(cellLooper, word);
46 // Construct named object from given arguments
47 autoPtr<cellLooper> cellLooper::New
53 wordConstructorTable::iterator cstrIter =
54 wordConstructorTablePtr_
57 if (cstrIter == wordConstructorTablePtr_->end())
61 "cellLooper::New(const word&, const polyMesh&)"
62 ) << "Unknown set type " << type
64 << "Valid cellLooper types : " << endl
65 << wordConstructorTablePtr_->toc()
69 return autoPtr<cellLooper>(cstrIter()(mesh));
74 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
76 // Get faces (on cell) connected to vertI which are not using edgeI
77 Foam::labelList Foam::cellLooper::getVertFacesNonEdge
84 // Get faces connected to startEdge
86 meshTools::getEdgeFaces(mesh(), cellI, edgeI, face0, face1);
88 const labelList& pFaces = mesh().pointFaces()[vertI];
90 labelList vertFaces(pFaces.size());
93 forAll(pFaces, pFaceI)
95 label faceI = pFaces[pFaceI];
101 && (meshTools::faceOnCell(mesh(), cellI, faceI))
104 vertFaces[vertFaceI++] = faceI;
107 vertFaces.setSize(vertFaceI);
113 // Get first edge connected to vertI and on faceI
114 Foam::label Foam::cellLooper::getFirstVertEdge
120 const labelList& fEdges = mesh().faceEdges()[faceI];
122 forAll(fEdges, fEdgeI)
124 label edgeI = fEdges[fEdgeI];
126 const edge& e = mesh().edges()[edgeI];
128 if ((e.start() == vertI) || (e.end() == vertI))
136 "getFirstVertEdge(const label, const label)"
137 ) << "Can not find edge on face " << faceI
138 << " using vertex " << vertI
139 << abort(FatalError);
145 // Get edges (on cell) connected to vertI which are not on faceI
146 Foam::labelList Foam::cellLooper::getVertEdgesNonFace
153 const labelList& exclEdges = mesh().faceEdges()[faceI];
155 const labelList& pEdges = mesh().pointEdges()[vertI];
157 labelList vertEdges(pEdges.size());
160 forAll(pEdges, pEdgeI)
162 label edgeI = pEdges[pEdgeI];
166 (findIndex(exclEdges, edgeI) == -1)
167 && meshTools::edgeOnCell(mesh(), cellI, edgeI)
170 vertEdges[vertEdgeI++] = edgeI;
174 vertEdges.setSize(vertEdgeI);
180 // Return edge from cellEdges that is most perpendicular
181 // to refinement direction.
182 Foam::label Foam::cellLooper::getMisAlignedEdge
184 const vector& refDir,
188 const labelList& cEdges = mesh().cellEdges()[cellI];
191 scalar maxCos = -GREAT;
193 forAll(cEdges, cEdgeI)
195 label edgeI = cEdges[cEdgeI];
197 scalar cosAngle = mag(refDir & meshTools::normEdgeVec(mesh(), edgeI));
199 if (cosAngle > maxCos)
211 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
213 // Construct from components
214 Foam::cellLooper::cellLooper(const polyMesh& mesh)
220 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
222 Foam::cellLooper::~cellLooper()
226 // ************************ vim: set sw=4 sts=4 et: ************************ //