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 #include "ensightPartFaces.H"
00027 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00028 #include <OpenFOAM/IOstreams.H>
00029 #include <OpenFOAM/IStringStream.H>
00030 #include <OpenFOAM/dictionary.H>
00031
00032
00033
00034 namespace Foam
00035 {
00036 defineTypeNameAndDebug(ensightPartFaces, 0);
00037 addToRunTimeSelectionTable(ensightPart, ensightPartFaces, istream);
00038 }
00039
00040
00041 Foam::List<Foam::word> Foam::ensightPartFaces::elemTypes_
00042 (
00043 IStringStream
00044 (
00045 "(tria3 quad4 nsided)"
00046 )()
00047 );
00048
00049
00050
00051
00052 Foam::ensightPartFaces::ensightPartFaces
00053 (
00054 label partNumber,
00055 const string& partDescription
00056 )
00057 :
00058 ensightPart(partNumber, partDescription)
00059 {
00060 isCellData_ = false;
00061 }
00062
00063
00064 Foam::ensightPartFaces::ensightPartFaces
00065 (
00066 label partNumber,
00067 const polyMesh& pMesh,
00068 const polyPatch& pPatch
00069 )
00070 :
00071 ensightPart(partNumber, pPatch.name(), pMesh)
00072 {
00073 isCellData_ = false;
00074 offset_ = pPatch.start();
00075 size_ = pPatch.size();
00076
00077
00078 label nTri = 0;
00079 label nQuad = 0;
00080 label nPoly = 0;
00081
00082 forAll (pPatch, patchfaceI)
00083 {
00084 const face& f = pMesh.faces()[patchfaceI + offset_];
00085
00086 if (f.size() == 3)
00087 {
00088 nTri++;
00089 }
00090 else if (f.size() == 4)
00091 {
00092 nQuad++;
00093 }
00094 else
00095 {
00096 nPoly++;
00097 }
00098 }
00099
00100
00101
00102 labelList triCells(nTri);
00103 labelList quadCells(nQuad);
00104 labelList polygonCells(nPoly);
00105
00106 nTri = 0;
00107 nQuad = 0;
00108 nPoly = 0;
00109
00110
00111 forAll(pPatch, patchfaceI)
00112 {
00113 const face& f = pMesh.faces()[patchfaceI + offset_];
00114
00115 if (f.size() == 3)
00116 {
00117 triCells[nTri++] = patchfaceI;
00118 }
00119 else if (f.size() == 4)
00120 {
00121 quadCells[nQuad++] = patchfaceI;
00122 }
00123 else
00124 {
00125 polygonCells[nPoly++] = patchfaceI;
00126 }
00127 }
00128
00129
00130
00131 elemLists_.setSize(elementTypes().size());
00132
00133 elemLists_[tria3Elements].transfer( triCells );
00134 elemLists_[quad4Elements].transfer( quadCells );
00135 elemLists_[nsidedElements].transfer( polygonCells );
00136 }
00137
00138
00139 Foam::ensightPartFaces::ensightPartFaces(const ensightPartFaces &part)
00140 :
00141 ensightPart(part)
00142 {}
00143
00144
00145 Foam::ensightPartFaces::ensightPartFaces(Istream& is)
00146 :
00147 ensightPart()
00148 {
00149 isCellData_ = false;
00150 reconstruct(is);
00151 }
00152
00153
00154
00155
00156 Foam::ensightPartFaces::~ensightPartFaces()
00157 {}
00158
00159
00160
00161
00162 Foam::ensightPart::localPoints Foam::ensightPartFaces::calcLocalPoints() const
00163 {
00164 const polyMesh& mesh = *meshPtr_;
00165
00166 localPoints ptList(mesh);
00167 labelList& usedPoints = ptList.list;
00168 label nPoints = 0;
00169
00170 forAll(elemLists_, typeI)
00171 {
00172 const labelList& idList = elemLists_[typeI];
00173
00174
00175 forAll(idList, i)
00176 {
00177 label id = idList[i] + offset_;
00178 const face& f = mesh.faces()[id];
00179
00180 forAll(f, fp)
00181 {
00182 if (usedPoints[f[fp]] == -1)
00183 {
00184 usedPoints[f[fp]] = nPoints++;
00185 }
00186 }
00187 }
00188 }
00189
00190
00191 nPoints = 0;
00192 forAll(usedPoints, ptI)
00193 {
00194 if (usedPoints[ptI] > -1)
00195 {
00196 usedPoints[ptI] = nPoints++;
00197 }
00198 }
00199
00200 ptList.nPoints = nPoints;
00201 return ptList;
00202 }
00203
00204
00205 void Foam::ensightPartFaces::writeConnectivity
00206 (
00207 ensightGeoFile& os,
00208 const string& key,
00209 const labelList& idList,
00210 const labelList& pointMap
00211 ) const
00212 {
00213 os.writeKeyword(key);
00214 os.write(idList.size());
00215 os.newline();
00216
00217 const faceList& meshFaces = meshPtr_->faces();
00218
00219
00220 if (word(key) == "nsided")
00221 {
00222
00223 forAll(idList, i)
00224 {
00225 label id = idList[i] + offset_;
00226 const face& f = meshFaces[id];
00227
00228 os.write( f.size() );
00229 os.newline();
00230 }
00231 }
00232
00233
00234 forAll(idList, i)
00235 {
00236 label id = idList[i] + offset_;
00237 const face& f = meshFaces[id];
00238
00239
00240
00241 forAll(f, fp)
00242 {
00243 os.write( pointMap[f[fp]] + 1 );
00244 }
00245 os.newline();
00246 }
00247 }
00248
00249
00250