cellShapeI.H
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
00027 #include "Istream.H"
00028 #include "cell.H"
00029
00030
00031
00032 inline Foam::cellShape::cellShape()
00033 :
00034 m(NULL)
00035 {}
00036
00037
00038 inline Foam::cellShape::cellShape
00039 (
00040 const cellModel& M,
00041 const labelList& l,
00042 const bool doCollapse
00043 )
00044 :
00045 labelList(l),
00046 m(&M)
00047 {
00048 if (doCollapse)
00049 {
00050 collapse();
00051 }
00052 }
00053
00054
00055 inline Foam::cellShape::cellShape(Istream& is)
00056 {
00057 is >> *this;
00058 }
00059
00060
00061 inline Foam::autoPtr<Foam::cellShape> Foam::cellShape::clone() const
00062 {
00063 return autoPtr<cellShape>(new cellShape(*this));
00064 }
00065
00066
00067
00068
00069 inline Foam::pointField Foam::cellShape::points
00070 (
00071 const pointField& meshPoints
00072 ) const
00073 {
00074
00075 pointField p(size());
00076
00077
00078
00079 forAll(p, i)
00080 {
00081 p[i] = meshPoints[operator[](i)];
00082 }
00083
00084
00085 return p;
00086 }
00087
00088
00089 inline const Foam::cellModel& Foam::cellShape::model() const
00090 {
00091 return *m;
00092 }
00093
00094
00095 inline Foam::labelList Foam::cellShape::meshFaces
00096 (
00097 const faceList& allFaces,
00098 const cell& cFaces
00099 ) const
00100 {
00101
00102 faceList localFaces(faces());
00103
00104
00105
00106 labelList modelToMesh(localFaces.size(), -1);
00107
00108 forAll(localFaces, i)
00109 {
00110 const face& localF = localFaces[i];
00111
00112 forAll(cFaces, j)
00113 {
00114 label meshFaceI = cFaces[j];
00115
00116 if (allFaces[meshFaceI] == localF)
00117 {
00118 modelToMesh[i] = meshFaceI;
00119
00120 break;
00121 }
00122 }
00123 }
00124
00125 return modelToMesh;
00126 }
00127
00128
00129 inline Foam::labelList Foam::cellShape::meshEdges
00130 (
00131 const edgeList& allEdges,
00132 const labelList& cEdges
00133 ) const
00134 {
00135
00136 edgeList localEdges(edges());
00137
00138
00139
00140 labelList modelToMesh(localEdges.size(), -1);
00141
00142 forAll(localEdges, i)
00143 {
00144 const edge& e = localEdges[i];
00145
00146 forAll(cEdges, j)
00147 {
00148 label edgeI = cEdges[j];
00149
00150 if (allEdges[edgeI] == e)
00151 {
00152 modelToMesh[i] = edgeI;
00153
00154 break;
00155 }
00156 }
00157 }
00158
00159 return modelToMesh;
00160 }
00161
00162
00163 inline Foam::faceList Foam::cellShape::faces() const
00164 {
00165 return m->faces(*this);
00166 }
00167
00168
00169 inline Foam::faceList Foam::cellShape::collapsedFaces() const
00170 {
00171 faceList oldFaces(faces());
00172
00173 faceList newFaces(oldFaces.size());
00174 label newFaceI = 0;
00175
00176 forAll(oldFaces, oldFaceI)
00177 {
00178 const face& f = oldFaces[oldFaceI];
00179
00180 face& newF = newFaces[newFaceI];
00181
00182 newF.setSize(f.size());
00183
00184 label newFp = 0;
00185 label prevVertI = -1;
00186
00187 forAll(f, fp)
00188 {
00189 label vertI = f[fp];
00190
00191 if (vertI != prevVertI)
00192 {
00193 newF[newFp++] = vertI;
00194
00195 prevVertI = vertI;
00196 }
00197 }
00198
00199 if ((newFp > 1) && (newF[newFp-1] == newF[0]))
00200 {
00201 --newFp;
00202 }
00203
00204 if (newFp > 2)
00205 {
00206
00207 newF.setSize(newFp);
00208
00209 newFaceI++;
00210 }
00211 }
00212 newFaces.setSize(newFaceI);
00213
00214 return newFaces;
00215 }
00216
00217
00218 inline Foam::label Foam::cellShape::nFaces() const
00219 {
00220 return m->nFaces();
00221 }
00222
00223
00224 inline Foam::edgeList Foam::cellShape::edges() const
00225 {
00226 return m->edges(*this);
00227 }
00228
00229
00230 inline Foam::label Foam::cellShape::nEdges() const
00231 {
00232 return m->nEdges();
00233 }
00234
00235
00236 inline Foam::label Foam::cellShape::nPoints() const
00237 {
00238 return size();
00239 }
00240
00241
00242 inline Foam::point Foam::cellShape::centre(const pointField& points) const
00243 {
00244 return m->centre(*this, points);
00245 }
00246
00247
00248 inline Foam::scalar Foam::cellShape::mag(const pointField& points) const
00249 {
00250 return m->mag(*this, points);
00251 }
00252
00253
00254
Copyright © 2000-2009 OpenCFD Ltd