FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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