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
25 \*---------------------------------------------------------------------------*/
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 inline Foam::cellShape::cellShape()
38 inline Foam::cellShape::cellShape
55 inline Foam::cellShape::cellShape(Istream& is)
61 inline Foam::autoPtr<Foam::cellShape> Foam::cellShape::clone() const
63 return autoPtr<cellShape>(new cellShape(*this));
67 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
69 inline Foam::pointField Foam::cellShape::points
71 const pointField& meshPoints
74 // There are as many points as there labels for them
77 // For each point in list, set it to the point in 'pnts' addressed
81 p[i] = meshPoints[operator[](i)];
89 inline const Foam::cellModel& Foam::cellShape::model() const
95 inline Foam::labelList Foam::cellShape::meshFaces
97 const faceList& allFaces,
101 // Faces in model order
102 faceList localFaces(faces());
104 // Do linear match (usually cell shape is low complexity)
106 labelList modelToMesh(localFaces.size(), -1);
108 forAll(localFaces, i)
110 const face& localF = localFaces[i];
114 label meshFaceI = cFaces[j];
116 if (allFaces[meshFaceI] == localF)
118 modelToMesh[i] = meshFaceI;
129 inline Foam::labelList Foam::cellShape::meshEdges
131 const edgeList& allEdges,
132 const labelList& cEdges
135 // Edges in model order
136 edgeList localEdges(edges());
138 // Do linear match (usually cell shape is low complexity)
140 labelList modelToMesh(localEdges.size(), -1);
142 forAll(localEdges, i)
144 const edge& e = localEdges[i];
148 label edgeI = cEdges[j];
150 if (allEdges[edgeI] == e)
152 modelToMesh[i] = edgeI;
163 inline Foam::faceList Foam::cellShape::faces() const
165 return m->faces(*this);
169 inline Foam::faceList Foam::cellShape::collapsedFaces() const
171 faceList oldFaces(faces());
173 faceList newFaces(oldFaces.size());
176 forAll(oldFaces, oldFaceI)
178 const face& f = oldFaces[oldFaceI];
180 face& newF = newFaces[newFaceI];
182 newF.setSize(f.size());
185 label prevVertI = -1;
191 if (vertI != prevVertI)
193 newF[newFp++] = vertI;
199 if ((newFp > 1) && (newF[newFp-1] == newF[0]))
206 // Size face and go to next one
212 newFaces.setSize(newFaceI);
218 inline Foam::label Foam::cellShape::nFaces() const
224 inline Foam::edgeList Foam::cellShape::edges() const
226 return m->edges(*this);
230 inline Foam::label Foam::cellShape::nEdges() const
236 inline Foam::label Foam::cellShape::nPoints() const
242 inline Foam::point Foam::cellShape::centre(const pointField& points) const
244 return m->centre(*this, points);
248 inline Foam::scalar Foam::cellShape::mag(const pointField& points) const
250 return m->mag(*this, points);
254 // ************************************************************************* //