1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2010 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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 inline Foam::cellShape::cellShape()
37 inline Foam::cellShape::cellShape
54 inline Foam::cellShape::cellShape(Istream& is)
60 inline Foam::autoPtr<Foam::cellShape> Foam::cellShape::clone() const
62 return autoPtr<cellShape>(new cellShape(*this));
66 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
68 inline Foam::pointField Foam::cellShape::points
70 const pointField& meshPoints
73 // There are as many points as there labels for them
76 // For each point in list, set it to the point in 'pnts' addressed
80 p[i] = meshPoints[operator[](i)];
88 inline const Foam::cellModel& Foam::cellShape::model() const
94 inline Foam::labelList Foam::cellShape::meshFaces
96 const faceList& allFaces,
100 // Faces in model order
101 faceList localFaces(faces());
103 // Do linear match (usually cell shape is low complexity)
105 labelList modelToMesh(localFaces.size(), -1);
107 forAll(localFaces, i)
109 const face& localF = localFaces[i];
113 label meshFaceI = cFaces[j];
115 if (allFaces[meshFaceI] == localF)
117 modelToMesh[i] = meshFaceI;
128 inline Foam::labelList Foam::cellShape::meshEdges
130 const edgeList& allEdges,
131 const labelList& cEdges
134 // Edges in model order
135 edgeList localEdges(edges());
137 // Do linear match (usually cell shape is low complexity)
139 labelList modelToMesh(localEdges.size(), -1);
141 forAll(localEdges, i)
143 const edge& e = localEdges[i];
147 label edgeI = cEdges[j];
149 if (allEdges[edgeI] == e)
151 modelToMesh[i] = edgeI;
162 inline Foam::faceList Foam::cellShape::faces() const
164 return m->faces(*this);
168 inline Foam::faceList Foam::cellShape::collapsedFaces() const
170 faceList oldFaces(faces());
172 faceList newFaces(oldFaces.size());
175 forAll(oldFaces, oldFaceI)
177 const face& f = oldFaces[oldFaceI];
179 face& newF = newFaces[newFaceI];
181 newF.setSize(f.size());
184 label prevVertI = -1;
190 if (vertI != prevVertI)
192 newF[newFp++] = vertI;
198 if ((newFp > 1) && (newF[newFp-1] == newF[0]))
205 // Size face and go to next one
211 newFaces.setSize(newFaceI);
217 inline Foam::label Foam::cellShape::nFaces() const
223 inline Foam::edgeList Foam::cellShape::edges() const
225 return m->edges(*this);
229 inline Foam::label Foam::cellShape::nEdges() const
235 inline Foam::label Foam::cellShape::nPoints() const
241 inline Foam::point Foam::cellShape::centre(const pointField& points) const
243 return m->centre(*this, points);
247 inline Foam::scalar Foam::cellShape::mag(const pointField& points) const
249 return m->mag(*this, points);
253 // ************************************************************************* //