ensightParts.C
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 "ensightParts.H"
00028
00029
00030
00031 Foam::ensightParts::ensightParts(const polyMesh& pMesh)
00032 :
00033 partsList_()
00034 {
00035 recalculate(pMesh);
00036 }
00037
00038
00039 Foam::ensightParts::ensightParts(const IOobject& ioObj)
00040 :
00041 partsList_()
00042 {
00043 IOPtrList<ensightPart> ioList(ioObj);
00044 partsList_.transfer(ioList);
00045 }
00046
00047
00048
00049
00050 Foam::ensightParts::~ensightParts()
00051 {}
00052
00053
00054
00055
00056 void Foam::ensightParts::recalculate(const polyMesh& pMesh)
00057 {
00058 partsList_.clear();
00059
00060
00061 label nPart =
00062 (
00063 pMesh.cellZones().size()
00064 + pMesh.boundaryMesh().size()
00065 + 1
00066 );
00067
00068 partsList_.setSize(nPart);
00069 nPart = 0;
00070
00071 label nZoneCells = 0;
00072
00073
00074 forAll(pMesh.cellZones(), zoneI)
00075 {
00076 const cellZone& cZone = pMesh.cellZones()[zoneI];
00077 nZoneCells += cZone.size();
00078
00079 if (cZone.size())
00080 {
00081 partsList_.set
00082 (
00083 nPart,
00084 new ensightPartCells
00085 (
00086 nPart,
00087 pMesh,
00088 cZone
00089 )
00090 );
00091
00092 nPart++;
00093 }
00094 }
00095
00096
00097
00098
00099 if (nZoneCells == 0)
00100 {
00101 partsList_.set
00102 (
00103 nPart,
00104 new ensightPartCells
00105 (
00106 nPart,
00107 pMesh
00108 )
00109 );
00110
00111 nPart++;
00112 }
00113 else if (pMesh.nCells() > nZoneCells)
00114 {
00115
00116 labelList unzoned(pMesh.nCells(), -1);
00117
00118 forAll(pMesh.cellZones(), zoneI)
00119 {
00120 const labelList& idList = pMesh.cellZones()[zoneI];
00121
00122 forAll(idList, i)
00123 {
00124 unzoned[idList[i]] = idList[i];
00125 }
00126 }
00127
00128 label nUnzoned = 0;
00129 forAll(unzoned, i)
00130 {
00131 if (unzoned[i] < 0)
00132 {
00133 unzoned[nUnzoned] = i;
00134 nUnzoned++;
00135 }
00136 }
00137 unzoned.setSize(nUnzoned);
00138
00139 if (unzoned.size())
00140 {
00141 partsList_.set
00142 (
00143 nPart,
00144 new ensightPartCells
00145 (
00146 nPart,
00147 pMesh,
00148 unzoned
00149 )
00150 );
00151
00152 nPart++;
00153 }
00154 }
00155
00156
00157
00158 forAll(pMesh.boundaryMesh(), patchI)
00159 {
00160 const polyPatch& pPatch = pMesh.boundaryMesh()[patchI];
00161 if
00162 (
00163 pPatch.size()
00164 && typeid(pPatch) != typeid(processorPolyPatch)
00165 )
00166 {
00167 partsList_.set
00168 (
00169 nPart,
00170 new ensightPartFaces
00171 (
00172 nPart,
00173 pMesh,
00174 pPatch
00175 )
00176 );
00177
00178 nPart++;
00179 }
00180 }
00181
00182
00183 partsList_.setSize(nPart);
00184 }
00185
00186
00187 void Foam::ensightParts::renumber
00188 (
00189 const labelList& origCellId,
00190 const labelList& origFaceId
00191 )
00192 {
00193 forAll(partsList_, partI)
00194 {
00195 if (partsList_[partI].isCellData())
00196 {
00197 partsList_[partI].renumber(origCellId);
00198 }
00199 else
00200 {
00201 partsList_[partI].renumber(origFaceId);
00202 }
00203 }
00204 }
00205
00206
00207 void Foam::ensightParts::writeGeometry( ensightGeoFile& os) const
00208 {
00209
00210 Info<< "write geometry part:" << nl << flush;
00211
00212 forAll(partsList_, partI)
00213 {
00214 Info<< " " << partI << flush;
00215 partsList_[partI].writeGeometry(os);
00216 }
00217 }
00218
00219
00220 bool Foam::ensightParts::writeSummary(Ostream& os) const
00221 {
00222 forAll(partsList_, partI)
00223 {
00224 partsList_[partI].writeSummary(os);
00225 }
00226
00227 return true;
00228 }
00229
00230
00231 void Foam::ensightParts::writeData(Ostream& os) const
00232 {
00233
00234 os << nl << partsList_.size();
00235
00236
00237 os << nl << token::BEGIN_LIST;
00238
00239
00240 forAll(partsList_, i)
00241 {
00242 os << nl << partsList_[i];
00243 }
00244
00245
00246 os << nl << token::END_LIST << nl;
00247
00248
00249 os.check("Ostream& operator<<(Ostream&, const PtrList&)");
00250 }
00251
00252
00253 void Foam::ensightParts::writeScalarField
00254 (
00255 ensightFile& os,
00256 const List<scalar>& field,
00257 bool useFaceData
00258 ) const
00259 {
00260 forAll(partsList_, partI)
00261 {
00262 if
00263 (
00264 useFaceData
00265 ? partsList_[partI].isFaceData()
00266 : partsList_[partI].isCellData()
00267 )
00268 {
00269 partsList_[partI].writeScalarField(os,field);
00270 }
00271 }
00272 }
00273
00274
00275 void Foam::ensightParts::writeVectorField
00276 (
00277 ensightFile& os,
00278 const List<scalar>& field0,
00279 const List<scalar>& field1,
00280 const List<scalar>& field2,
00281 bool useFaceData
00282 ) const
00283 {
00284 forAll(partsList_, partI)
00285 {
00286 if
00287 (
00288 useFaceData
00289 ? partsList_[partI].isFaceData()
00290 : partsList_[partI].isCellData()
00291 )
00292 {
00293 partsList_[partI].writeVectorField(os, field0, field1, field2);
00294 }
00295 }
00296 }
00297
00298
00299
00300
00301 Foam::ensightGeoFile& Foam::operator<<
00302 (
00303 ensightGeoFile& os,
00304 const ensightParts& parts
00305 )
00306 {
00307 parts.writeGeometry(os);
00308 return os;
00309 }
00310
00311
00312
Copyright © 2000-2009 OpenCFD Ltd