OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

ensightField.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "ensightField.H"
00028 #include "fvMesh.H"
00029 #include "volFields.H"
00030 #include "OFstream.H"
00031 #include "IOmanip.H"
00032 #include "itoa.H"
00033 #include "ensightWriteBinary.H"
00034 
00035 using namespace Foam;
00036 
00037 // * * * * * * * * * * * * * * * Global Functions  * * * * * * * * * * * * * //
00038 
00039 void writeData(const scalarField& sf, OFstream& ensightFile)
00040 {
00041     forAll(sf, i)
00042     {
00043         if (mag( sf[i] ) >= scalar(floatScalarVSMALL))
00044         {
00045             ensightFile << setw(12) << sf[i] << nl;
00046         }
00047         else
00048         {
00049             ensightFile << setw(12) << scalar(0) << nl;
00050         }
00051     }
00052 }
00053 
00054 
00055 template<class Type>
00056 scalarField map
00057 (
00058     const Field<Type>& vf,
00059     const labelList& map,
00060     const label cmpt
00061 )
00062 {
00063     scalarField mf(map.size());
00064 
00065     forAll(map, i)
00066     {
00067         mf[i] = component(vf[map[i]], cmpt);
00068     }
00069 
00070     return mf;
00071 }
00072 
00073 
00074 template<class Type>
00075 scalarField map
00076 (
00077     const Field<Type>& vf,
00078     const labelList& map1,
00079     const labelList& map2,
00080     const label cmpt
00081 )
00082 {
00083     scalarField mf(map1.size() + map2.size());
00084 
00085     forAll(map1, i)
00086     {
00087         mf[i] = component(vf[map1[i]], cmpt);
00088     }
00089 
00090     label offset = map1.size();
00091 
00092     forAll(map2, i)
00093     {
00094         mf[i + offset] = component(vf[map2[i]], cmpt);
00095     }
00096 
00097     return mf;
00098 }
00099 
00100 
00101 template<class Type>
00102 void writeAllData
00103 (
00104     const char* key,
00105     const Field<Type>& vf,
00106     const labelList& prims,
00107     const label nPrims,
00108     OFstream& ensightFile
00109 )
00110 {
00111     if (nPrims)
00112     {
00113         if (Pstream::master())
00114         {
00115             ensightFile << key << nl;
00116 
00117             for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
00118             {
00119                 writeData(map(vf, prims, cmpt), ensightFile);
00120 
00121                 for (int slave=1; slave<Pstream::nProcs(); slave++)
00122                 {
00123                     IPstream fromSlave(Pstream::scheduled, slave);
00124                     scalarField data(fromSlave);
00125                     writeData(data, ensightFile);
00126                 }
00127             }
00128         }
00129         else
00130         {
00131             for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
00132             {
00133                 OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
00134                 toMaster<< map(vf, prims, cmpt);
00135             }
00136         }
00137     }
00138 }
00139 
00140 
00141 template<class Type>
00142 void writeAllDataBinary
00143 (
00144     const char* key,
00145     const Field<Type>& vf,
00146     const labelList& prims,
00147     const label nPrims,
00148     std::ofstream& ensightFile
00149 )
00150 {
00151     if (nPrims)
00152     {
00153         if (Pstream::master())
00154         {
00155             writeEnsDataBinary(key,ensightFile);
00156 
00157             for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
00158             {
00159                 writeEnsDataBinary(map(vf, prims, cmpt), ensightFile);
00160 
00161                 for (int slave=1; slave<Pstream::nProcs(); slave++)
00162                 {
00163                     IPstream fromSlave(Pstream::scheduled, slave);
00164                     scalarField data(fromSlave);
00165                     writeEnsDataBinary(data, ensightFile);
00166                 }
00167             }
00168         }
00169         else
00170         {
00171             for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
00172             {
00173                 OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
00174                 toMaster<< map(vf, prims, cmpt);
00175             }
00176         }
00177     }
00178 }
00179 
00180 
00181 template<class Type>
00182 void writeAllFaceData
00183 (
00184     const char* key,
00185     const labelList& prims,
00186     const label nPrims,
00187     const Field<Type>& pf,
00188     const labelList& patchProcessors,
00189     OFstream& ensightFile
00190 )
00191 {
00192     if (nPrims)
00193     {
00194         if (Pstream::master())
00195         {
00196             ensightFile << key << nl;
00197 
00198             for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
00199             {
00200                 writeData(map(pf, prims, cmpt), ensightFile);
00201 
00202                 forAll (patchProcessors, i)
00203                 {
00204                     if (patchProcessors[i] != 0)
00205                     {
00206                         label slave = patchProcessors[i];
00207                         IPstream fromSlave(Pstream::scheduled, slave);
00208                         scalarField pf(fromSlave);
00209 
00210                         writeData(pf, ensightFile);
00211                     }
00212                 }
00213             }
00214         }
00215         else
00216         {
00217             for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
00218             {
00219                 OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
00220                 toMaster<< map(pf, prims, cmpt);
00221             }
00222         }
00223     }
00224 }
00225 
00226 
00227 template<class Type>
00228 void writeAllFaceDataBinary
00229 (
00230     const char* key,
00231     const labelList& prims,
00232     const label nPrims,
00233     const Field<Type>& pf,
00234     const labelList& patchProcessors,
00235     std::ofstream& ensightFile
00236 )
00237 {
00238     if (nPrims)
00239     {
00240         if (Pstream::master())
00241         {
00242             writeEnsDataBinary(key,ensightFile);
00243 
00244             for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
00245             {
00246                 writeEnsDataBinary(map(pf, prims, cmpt), ensightFile);
00247 
00248                 forAll (patchProcessors, i)
00249                 {
00250                     if (patchProcessors[i] != 0)
00251                     {
00252                         label slave = patchProcessors[i];
00253                         IPstream fromSlave(Pstream::scheduled, slave);
00254                         scalarField pf(fromSlave);
00255 
00256                         writeEnsDataBinary(pf, ensightFile);
00257                     }
00258                 }
00259             }
00260         }
00261         else
00262         {
00263             for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
00264             {
00265                 OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
00266                 toMaster<< map(pf, prims, cmpt);
00267             }
00268         }
00269     }
00270 }
00271 
00272 
00273 template<class Type>
00274 bool writePatchField
00275 (
00276     const Foam::Field<Type>& pf,
00277     const Foam::label patchi,
00278     const Foam::label ensightPatchI,
00279     const Foam::faceSets& boundaryFaceSet,
00280     const Foam::ensightMesh::nFacePrimitives& nfp,
00281     const Foam::labelList& patchProcessors,
00282     Foam::OFstream& ensightFile
00283 )
00284 {
00285     if (nfp.nTris || nfp.nQuads || nfp.nPolys)
00286     {
00287         if (Pstream::master())
00288         {
00289             ensightFile
00290                 << "part" << nl
00291                 << setw(10) << ensightPatchI << nl;
00292         }
00293 
00294         writeAllFaceData
00295         (
00296             "tria3",
00297             boundaryFaceSet.tris,
00298             nfp.nTris,
00299             pf,
00300             patchProcessors,
00301             ensightFile
00302         );
00303 
00304         writeAllFaceData
00305         (
00306             "quad4",
00307             boundaryFaceSet.quads,
00308             nfp.nQuads,
00309             pf,
00310             patchProcessors,
00311             ensightFile
00312         );
00313 
00314         writeAllFaceData
00315         (
00316             "nsided",
00317             boundaryFaceSet.polys,
00318             nfp.nPolys,
00319             pf,
00320             patchProcessors,
00321             ensightFile
00322         );
00323 
00324         return true;
00325     }
00326     else
00327     {
00328         return false;
00329     }
00330 }
00331 
00332 
00333 template<class Type>
00334 bool writePatchFieldBinary
00335 (
00336     const Foam::Field<Type>& pf,
00337     const Foam::label patchi,
00338     const Foam::label ensightPatchI,
00339     const Foam::faceSets& boundaryFaceSet,
00340     const Foam::ensightMesh::nFacePrimitives& nfp,
00341     const Foam::labelList& patchProcessors,
00342     std::ofstream& ensightFile
00343 )
00344 {
00345     if (nfp.nTris || nfp.nQuads || nfp.nPolys)
00346     {
00347         if (Pstream::master())
00348         {
00349             writeEnsDataBinary("part",ensightFile);
00350             writeEnsDataBinary(ensightPatchI,ensightFile);
00351         }
00352 
00353         writeAllFaceDataBinary
00354         (
00355             "tria3",
00356             boundaryFaceSet.tris,
00357             nfp.nTris,
00358             pf,
00359             patchProcessors,
00360             ensightFile
00361         );
00362 
00363         writeAllFaceDataBinary
00364         (
00365             "quad4",
00366             boundaryFaceSet.quads,
00367             nfp.nQuads,
00368             pf,
00369             patchProcessors,
00370             ensightFile
00371         );
00372 
00373         writeAllFaceDataBinary
00374         (
00375             "nsided",
00376             boundaryFaceSet.polys,
00377             nfp.nPolys,
00378             pf,
00379             patchProcessors,
00380             ensightFile
00381         );
00382 
00383         return true;
00384     }
00385     else
00386     {
00387         return false;
00388     }
00389 }
00390 
00391 
00392 template<class Type>
00393 void writePatchField
00394 (
00395     const Foam::word& fieldName,
00396     const Foam::Field<Type>& pf,
00397     const Foam::word& patchName,
00398     const Foam::ensightMesh& eMesh,
00399     const Foam::fileName& postProcPath,
00400     const Foam::word& prepend,
00401     const Foam::label timeIndex,
00402     Foam::Ostream& ensightCaseFile
00403 )
00404 {
00405     const Time& runTime = eMesh.mesh().time();
00406 
00407     const List<faceSets>& boundaryFaceSets = eMesh.boundaryFaceSets();
00408     const wordList& allPatchNames = eMesh.allPatchNames();
00409     const List<labelList>& allPatchProcs = eMesh.allPatchProcs();
00410     const HashTable<ensightMesh::nFacePrimitives>&
00411         nPatchPrims = eMesh.nPatchPrims();
00412 
00413     label ensightPatchI = eMesh.patchPartOffset();
00414 
00415     label patchi = -1;
00416 
00417     forAll(allPatchNames, i)
00418     {
00419         if (allPatchNames[i] == patchName)
00420         {
00421             patchi = i;
00422             break;
00423         }
00424         ensightPatchI++;
00425     }
00426 
00427 
00428     const labelList& patchProcessors = allPatchProcs[patchi];
00429 
00430     word pfName = patchName + '.' + fieldName;
00431 
00432     word timeFile = prepend + itoa(timeIndex);
00433 
00434     OFstream *ensightFilePtr = NULL;
00435     if (Pstream::master())
00436     {
00437         if (timeIndex == 0)
00438         {
00439             ensightCaseFile.setf(ios_base::left);
00440 
00441             ensightCaseFile
00442                 << pTraits<Type>::typeName
00443                 << " per element:            1       "
00444                 << setw(15) << pfName
00445                 << (' ' + prepend + "***." + pfName).c_str()
00446                 << nl;
00447         }
00448 
00449         // set the filename of the ensight file
00450         fileName ensightFileName(timeFile + "." + pfName);
00451         ensightFilePtr = new OFstream
00452         (
00453             postProcPath/ensightFileName,
00454             runTime.writeFormat(),
00455             runTime.writeVersion(),
00456             runTime.writeCompression()
00457         );
00458     }
00459 
00460     OFstream& ensightFile = *ensightFilePtr;
00461 
00462     if (Pstream::master())
00463     {
00464         ensightFile << pTraits<Type>::typeName << nl;
00465     }
00466 
00467     if (patchi >= 0)
00468     {
00469         writePatchField
00470         (
00471             pf,
00472             patchi,
00473             ensightPatchI,
00474             boundaryFaceSets[patchi],
00475             nPatchPrims.find(patchName)(),
00476             patchProcessors,
00477             ensightFile
00478         );
00479     }
00480     else
00481     {
00482         faceSets nullFaceSets;
00483 
00484         writePatchField
00485         (
00486             Field<Type>(),
00487             -1,
00488             ensightPatchI,
00489             nullFaceSets,
00490             nPatchPrims.find(patchName)(),
00491             patchProcessors,
00492             ensightFile
00493         );
00494     }
00495 
00496     if (Pstream::master())
00497     {
00498         delete ensightFilePtr;
00499     }
00500 }
00501 
00502 
00503 template<class Type>
00504 void ensightFieldAscii
00505 (
00506     const Foam::IOobject& fieldObject,
00507     const Foam::ensightMesh& eMesh,
00508     const Foam::fileName& postProcPath,
00509     const Foam::word& prepend,
00510     const Foam::label timeIndex,
00511     Foam::Ostream& ensightCaseFile
00512 )
00513 {
00514     Info<< "Converting field " << fieldObject.name() << endl;
00515 
00516     word timeFile = prepend + itoa(timeIndex);
00517 
00518     const fvMesh& mesh = eMesh.mesh();
00519     const Time& runTime = mesh.time();
00520 
00521     const cellSets& meshCellSets = eMesh.meshCellSets();
00522     const List<faceSets>& boundaryFaceSets = eMesh.boundaryFaceSets();
00523     const wordList& allPatchNames = eMesh.allPatchNames();
00524     const List<labelList>& allPatchProcs = eMesh.allPatchProcs();
00525     const wordHashSet& patchNames = eMesh.patchNames();
00526     const HashTable<ensightMesh::nFacePrimitives>&
00527         nPatchPrims = eMesh.nPatchPrims();
00528 
00529     const labelList& tets = meshCellSets.tets;
00530     const labelList& pyrs = meshCellSets.pyrs;
00531     const labelList& prisms = meshCellSets.prisms;
00532     const labelList& wedges = meshCellSets.wedges;
00533     const labelList& hexes = meshCellSets.hexes;
00534     const labelList& polys = meshCellSets.polys;
00535 
00536     OFstream *ensightFilePtr = NULL;
00537     if (Pstream::master())
00538     {
00539         // set the filename of the ensight file
00540         fileName ensightFileName(timeFile + "." + fieldObject.name());
00541         ensightFilePtr = new OFstream
00542         (
00543             postProcPath/ensightFileName,
00544             runTime.writeFormat(),
00545             runTime.writeVersion(),
00546             runTime.writeCompression()
00547         );
00548     }
00549 
00550     OFstream& ensightFile = *ensightFilePtr;
00551 
00552     GeometricField<Type, fvPatchField, volMesh> vf(fieldObject, mesh);
00553 
00554     if (patchNames.empty())
00555     {
00556         if (Pstream::master())
00557         {
00558             if (timeIndex == 0)
00559             {
00560                 ensightCaseFile.setf(ios_base::left);
00561 
00562                 ensightCaseFile
00563                     << pTraits<Type>::typeName
00564                     << " per element:            1       "
00565                     << setw(15) << vf.name()
00566                     << (' ' + prepend + "***." + vf.name()).c_str()
00567                     << nl;
00568             }
00569 
00570             ensightFile
00571                 << pTraits<Type>::typeName << nl
00572                 << "part" << nl
00573                 << setw(10) << 1 << nl;
00574 
00575             ensightFile.setf(ios_base::scientific, ios_base::floatfield);
00576             ensightFile.precision(5);
00577         }
00578 
00579         if (meshCellSets.nHexesWedges)
00580         {
00581             if (Pstream::master())
00582             {
00583                 ensightFile << "hexa8" << nl;
00584 
00585                 for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
00586                 {
00587                     writeData
00588                     (
00589                         map(vf, hexes, wedges, cmpt),
00590                         ensightFile
00591                     );
00592 
00593                     for (int slave=1; slave<Pstream::nProcs(); slave++)
00594                     {
00595                         IPstream fromSlave(Pstream::scheduled, slave);
00596                         scalarField data(fromSlave);
00597                         writeData(data, ensightFile);
00598                     }
00599                 }
00600             }
00601             else
00602             {
00603                 for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
00604                 {
00605                     OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
00606                     toMaster<< map(vf, hexes, wedges, cmpt);
00607                 }
00608             }
00609         }
00610 
00611         writeAllData("penta6", vf, prisms, meshCellSets.nPrisms, ensightFile);
00612         writeAllData("pyramid5", vf, pyrs, meshCellSets.nPyrs, ensightFile);
00613         writeAllData("tetra4", vf, tets, meshCellSets.nTets, ensightFile);
00614         writeAllData("nfaced", vf, polys, meshCellSets.nPolys, ensightFile);
00615     }
00616 
00617     label ensightPatchI = eMesh.patchPartOffset();
00618 
00619     forAll(allPatchNames, patchi)
00620     {
00621         const word& patchName = allPatchNames[patchi];
00622         const labelList& patchProcessors = allPatchProcs[patchi];
00623 
00624         if (patchNames.empty() || patchNames.found(patchName))
00625         {
00626             if (mesh.boundary()[patchi].size())
00627             {
00628                 if
00629                 (
00630                     writePatchField
00631                     (
00632                         vf.boundaryField()[patchi],
00633                         patchi,
00634                         ensightPatchI,
00635                         boundaryFaceSets[patchi],
00636                         nPatchPrims.find(patchName)(),
00637                         patchProcessors,
00638                         ensightFile
00639                     )
00640                 )
00641                 {
00642                     ensightPatchI++;
00643                 }
00644 
00645             }
00646             else if (Pstream::master())
00647             {
00648                 faceSets nullFaceSet;
00649 
00650                 if
00651                 (
00652                     writePatchField
00653                     (
00654                         Field<Type>(),
00655                         -1,
00656                         ensightPatchI,
00657                         nullFaceSet,
00658                         nPatchPrims.find(patchName)(),
00659                         patchProcessors,
00660                         ensightFile
00661                     )
00662                 )
00663                 {
00664                     ensightPatchI++;
00665                 }
00666             }
00667         }
00668     }
00669 
00670     if (Pstream::master())
00671     {
00672         delete ensightFilePtr;
00673     }
00674 }
00675 
00676 
00677 template<class Type>
00678 void ensightFieldBinary
00679 (
00680     const Foam::IOobject& fieldObject,
00681     const Foam::ensightMesh& eMesh,
00682     const Foam::fileName& postProcPath,
00683     const Foam::word& prepend,
00684     const Foam::label timeIndex,
00685     Foam::Ostream& ensightCaseFile
00686 )
00687 {
00688     Info<< "Converting field (binary) " << fieldObject.name() << endl;
00689 
00690     word timeFile = prepend + itoa(timeIndex);
00691 
00692     const fvMesh& mesh = eMesh.mesh();
00693     //const Time& runTime = mesh.time();
00694 
00695     const cellSets& meshCellSets = eMesh.meshCellSets();
00696     const List<faceSets>& boundaryFaceSets = eMesh.boundaryFaceSets();
00697     const wordList& allPatchNames = eMesh.allPatchNames();
00698     const List<labelList>& allPatchProcs = eMesh.allPatchProcs();
00699     const wordHashSet& patchNames = eMesh.patchNames();
00700     const HashTable<ensightMesh::nFacePrimitives>&
00701         nPatchPrims = eMesh.nPatchPrims();
00702 
00703     const labelList& tets = meshCellSets.tets;
00704     const labelList& pyrs = meshCellSets.pyrs;
00705     const labelList& prisms = meshCellSets.prisms;
00706     const labelList& wedges = meshCellSets.wedges;
00707     const labelList& hexes = meshCellSets.hexes;
00708     const labelList& polys = meshCellSets.polys;
00709 
00710     std::ofstream *ensightFilePtr = NULL;
00711     if (Pstream::master())
00712     {
00713         // set the filename of the ensight file
00714         fileName ensightFileName(timeFile + "." + fieldObject.name());
00715         ensightFilePtr = new std::ofstream
00716         (
00717             (postProcPath/ensightFileName).c_str(),
00718             ios_base::out | ios_base::binary | ios_base::trunc
00719         );
00720         // Check on file opened?
00721     }
00722 
00723     std::ofstream& ensightFile = *ensightFilePtr;
00724 
00725     GeometricField<Type, fvPatchField, volMesh> vf(fieldObject, mesh);
00726 
00727     if (patchNames.empty())
00728     {
00729         if (Pstream::master())
00730         {
00731             if (timeIndex == 0)
00732             {
00733                 ensightCaseFile.setf(ios_base::left);
00734 
00735                 ensightCaseFile
00736                     << pTraits<Type>::typeName
00737                     << " per element:            1       "
00738                     << setw(15) << vf.name()
00739                     << (' ' + prepend + "***." + vf.name()).c_str()
00740                     << nl;
00741             }
00742 
00743             writeEnsDataBinary(pTraits<Type>::typeName,ensightFile);
00744             writeEnsDataBinary("part",ensightFile);
00745             writeEnsDataBinary(1,ensightFile);
00746         }
00747 
00748         if (meshCellSets.nHexesWedges)
00749         {
00750             if (Pstream::master())
00751             {
00752                 writeEnsDataBinary("hexa8",ensightFile);
00753 
00754                 for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
00755                 {
00756                     writeEnsDataBinary
00757                     (
00758                         map(vf, hexes, wedges, cmpt),
00759                         ensightFile
00760                     );
00761 
00762                     for (int slave=1; slave<Pstream::nProcs(); slave++)
00763                     {
00764                         IPstream fromSlave(Pstream::scheduled, slave);
00765                         scalarField data(fromSlave);
00766                         writeEnsDataBinary(data, ensightFile);
00767                     }
00768                 }
00769             }
00770             else
00771             {
00772                 for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
00773                 {
00774                     OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
00775                     toMaster<< map(vf, hexes, wedges, cmpt);
00776                 }
00777             }
00778         }
00779 
00780         writeAllDataBinary
00781         (
00782             "penta6",
00783             vf,
00784             prisms,
00785             meshCellSets.nPrisms,
00786             ensightFile
00787         );
00788 
00789         writeAllDataBinary
00790         (
00791             "pyramid5",
00792             vf,
00793             pyrs,
00794             meshCellSets.nPyrs,
00795             ensightFile
00796         );
00797 
00798         writeAllDataBinary
00799         (
00800             "tetra4",
00801             vf,
00802             tets,
00803             meshCellSets.nTets,
00804             ensightFile
00805         );
00806 
00807         writeAllDataBinary
00808         (
00809             "nfaced",
00810             vf,
00811             polys,
00812             meshCellSets.nPolys,
00813             ensightFile
00814         );
00815     }
00816 
00817     label ensightPatchI = eMesh.patchPartOffset();
00818 
00819     forAll(allPatchNames, patchi)
00820     {
00821         const word& patchName = allPatchNames[patchi];
00822         const labelList& patchProcessors = allPatchProcs[patchi];
00823 
00824         if (patchNames.empty() || patchNames.found(patchName))
00825         {
00826             if (mesh.boundary()[patchi].size())
00827             {
00828                 if
00829                 (
00830                     writePatchFieldBinary
00831                     (
00832                         vf.boundaryField()[patchi],
00833                         patchi,
00834                         ensightPatchI,
00835                         boundaryFaceSets[patchi],
00836                         nPatchPrims.find(patchName)(),
00837                         patchProcessors,
00838                         ensightFile
00839                     )
00840                 )
00841                 {
00842                     ensightPatchI++;
00843                 }
00844 
00845             }
00846             else if (Pstream::master())
00847             {
00848                 faceSets nullFaceSet;
00849 
00850                 if
00851                 (
00852                     writePatchFieldBinary
00853                     (
00854                         Field<Type>(),
00855                         -1,
00856                         ensightPatchI,
00857                         nullFaceSet,
00858                         nPatchPrims.find(patchName)(),
00859                         patchProcessors,
00860                         ensightFile
00861                     )
00862                 )
00863                 {
00864                     ensightPatchI++;
00865                 }
00866             }
00867         }
00868     }
00869 
00870     if (Pstream::master())
00871     {
00872         ensightFile.close();
00873     }
00874 }
00875 
00876 
00877 template<class Type>
00878 void ensightField
00879 (
00880     const Foam::IOobject& fieldObject,
00881     const Foam::ensightMesh& eMesh,
00882     const Foam::fileName& postProcPath,
00883     const Foam::word& prepend,
00884     const Foam::label timeIndex,
00885     const bool binary,
00886     Foam::Ostream& ensightCaseFile
00887 )
00888 {
00889     if (binary)
00890     {
00891         ensightFieldBinary<Type>
00892         (
00893             fieldObject,
00894             eMesh,
00895             postProcPath,
00896             prepend,
00897             timeIndex,
00898             ensightCaseFile
00899         );
00900     }
00901     else
00902     {
00903         ensightFieldAscii<Type>
00904         (
00905             fieldObject,
00906             eMesh,
00907             postProcPath,
00908             prepend,
00909             timeIndex,
00910             ensightCaseFile
00911         );
00912     }
00913 }
00914 
00915 
00916 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd