diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/Make/files b/applications/utilities/postProcessing/dataConversion/foamToEnsight/Make/files
index 78e39e9df6..44c513a079 100644
--- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/Make/files
+++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/Make/files
@@ -2,6 +2,5 @@ itoa.C
ensightMesh.C
ensightParticlePositions.C
foamToEnsight.C
-ensightWriteBinary.C
EXE = $(FOAM_APPBIN)/foamToEnsight
diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/cellSets.H b/applications/utilities/postProcessing/dataConversion/foamToEnsight/cellSets.H
index 2c9755ef43..a4447108ab 100644
--- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/cellSets.H
+++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/cellSets.H
@@ -44,15 +44,6 @@ namespace Foam
class cellSets
{
- // Private Member Functions
-
- //- Disallow default bitwise copy construct
- cellSets(const cellSets&);
-
- //- Disallow default bitwise assignment
- void operator=(const cellSets&);
-
-
public:
label nHexesWedges;
diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightAsciiStream.H b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightAsciiStream.H
new file mode 100644
index 0000000000..2230b75b24
--- /dev/null
+++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightAsciiStream.H
@@ -0,0 +1,156 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
+ \\/ M anipulation |
+-------------------------------------------------------------------------------
+License
+ This file is part of OpenFOAM.
+
+ OpenFOAM is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with OpenFOAM. If not, see .
+
+Class
+ Foam::ensightAsciiStream
+
+Description
+
+SourceFiles
+ ensightAsciiStream.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef ensightAsciiStream_H
+#define ensightAsciiStream_H
+
+#include "ensightStream.H"
+#include "OFstream.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+/*---------------------------------------------------------------------------*\
+ Class ensightAsciiStream Declaration
+\*---------------------------------------------------------------------------*/
+
+class ensightAsciiStream
+:
+ public ensightStream
+{
+ // Private data
+
+ //- Description of data_
+ OFstream str_;
+
+
+ // Private Member Functions
+
+ //- Disallow default bitwise copy construct
+ ensightAsciiStream(const ensightAsciiStream&);
+
+ //- Disallow default bitwise assignment
+ void operator=(const ensightAsciiStream&);
+
+
+public:
+
+ // Constructors
+
+ //- Construct from components
+ ensightAsciiStream(const fileName& f, const Time& runTime)
+ :
+ ensightStream(f),
+ str_
+ (
+ f,
+ runTime.writeFormat(),
+ runTime.writeVersion(),
+ IOstream::UNCOMPRESSED
+ )
+ {
+
+ str_.setf(ios_base::scientific, ios_base::floatfield);
+ str_.precision(5);
+ }
+
+
+ //- Destructor
+ virtual ~ensightAsciiStream()
+ {}
+
+
+ // Member Functions
+
+ virtual void write(const char* c)
+ {
+ str_ << c << nl;
+ }
+
+ virtual void write(const int v)
+ {
+ str_ << setw(10) << v << nl;
+ }
+
+ virtual void write(const scalarField& sf)
+ {
+ forAll(sf, i)
+ {
+ if (mag(sf[i]) >= scalar(floatScalarVSMALL))
+ {
+ str_ << setw(12) << sf[i] << nl;
+ }
+ else
+ {
+ str_ << setw(12) << scalar(0) << nl;
+ }
+ }
+ }
+
+ virtual void write(const List& sf)
+ {
+ forAll(sf, i)
+ {
+ str_ << setw(10) << sf[i];
+ }
+ str_<< nl;
+ }
+
+ virtual void writePartHeader(const label partI)
+ {
+ str_<< "part" << nl
+ << setw(10) << partI << nl;
+ }
+
+ // Member Operators
+
+ // Friend Functions
+
+ // Friend Operators
+
+ // IOstream Operators
+
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightBinaryStream.H b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightBinaryStream.H
new file mode 100644
index 0000000000..b4f1421e4a
--- /dev/null
+++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightBinaryStream.H
@@ -0,0 +1,158 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
+ \\/ M anipulation |
+-------------------------------------------------------------------------------
+License
+ This file is part of OpenFOAM.
+
+ OpenFOAM is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with OpenFOAM. If not, see .
+
+Class
+ Foam::ensightBinaryStream
+
+Description
+
+SourceFiles
+ ensightBinaryStream.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef ensightBinaryStream_H
+#define ensightBinaryStream_H
+
+#include "ensightStream.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+/*---------------------------------------------------------------------------*\
+ Class ensightBinaryStream Declaration
+\*---------------------------------------------------------------------------*/
+
+class ensightBinaryStream
+:
+ public ensightStream
+{
+ // Private data
+
+ //- Description of data_
+ autoPtr str_;
+
+
+ // Private Member Functions
+
+ //- Disallow default bitwise copy construct
+ ensightBinaryStream(const ensightBinaryStream&);
+
+ //- Disallow default bitwise assignment
+ void operator=(const ensightBinaryStream&);
+
+
+public:
+
+ // Constructors
+
+ //- Construct from components
+ ensightBinaryStream(const fileName& f, const Time&)
+ :
+ ensightStream(f),
+ str_
+ (
+ new std::ofstream
+ (
+ f.c_str(),
+ ios_base::out | ios_base::binary | ios_base::trunc
+ )
+ )
+ {}
+
+
+ //- Destructor
+ virtual ~ensightBinaryStream()
+ {}
+
+
+ // Member Functions
+
+ virtual void write(const char* val)
+ {
+ char buffer[80] = {0};
+ strcpy(buffer, val);
+ str_().write(buffer, 80*sizeof(char));
+ }
+
+ virtual void write(const int val)
+ {
+ str_().write(reinterpret_cast(&val), sizeof(int));
+ }
+
+ virtual void write(const scalarField& sf)
+ {
+ if (sf.size())
+ {
+ List temp(sf.size());
+
+ forAll(sf, i)
+ {
+ temp[i] = float(sf[i]);
+ }
+
+ str_().write
+ (
+ reinterpret_cast(temp.begin()),
+ sf.size()*sizeof(float)
+ );
+ }
+ }
+
+ virtual void write(const List& sf)
+ {
+ str_().write
+ (
+ reinterpret_cast(sf.begin()),
+ sf.size()*sizeof(int)
+ );
+ }
+
+ virtual void writePartHeader(const label partI)
+ {
+ write("part");
+ write(partI);
+ }
+
+ // Member Operators
+
+ // Friend Functions
+
+ // Friend Operators
+
+ // IOstream Operators
+
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightField.C b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightField.C
index 680d5ff894..8a366d1a22 100644
--- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightField.C
+++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightField.C
@@ -29,28 +29,14 @@ License
#include "OFstream.H"
#include "IOmanip.H"
#include "itoa.H"
-#include "ensightWriteBinary.H"
+#include "volPointInterpolation.H"
+#include "ensightBinaryStream.H"
+#include "ensightAsciiStream.H"
using namespace Foam;
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
-void writeData(const scalarField& sf, OFstream& ensightFile)
-{
- forAll(sf, i)
- {
- if (mag( sf[i] ) >= scalar(floatScalarVSMALL))
- {
- ensightFile << setw(12) << sf[i] << nl;
- }
- else
- {
- ensightFile << setw(12) << scalar(0) << nl;
- }
- }
-}
-
-
template
scalarField map
(
@@ -104,64 +90,25 @@ void writeAllData
const Field& vf,
const labelList& prims,
const label nPrims,
- OFstream& ensightFile
+ ensightStream& ensightFile
)
{
if (nPrims)
{
if (Pstream::master())
{
- ensightFile << key << nl;
+ ensightFile.write(key);
for (direction cmpt=0; cmpt::nComponents; cmpt++)
{
- writeData(map(vf, prims, cmpt), ensightFile);
+ scalarField masterData(map(vf, prims, cmpt));
+ ensightFile.write(masterData);
for (int slave=1; slave::nComponents; cmpt++)
- {
- OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
- toMaster<< map(vf, prims, cmpt);
- }
- }
- }
-}
-
-
-template
-void writeAllDataBinary
-(
- const char* key,
- const Field& vf,
- const labelList& prims,
- const label nPrims,
- std::ofstream& ensightFile
-)
-{
- if (nPrims)
- {
- if (Pstream::master())
- {
- writeEnsDataBinary(key,ensightFile);
-
- for (direction cmpt=0; cmpt::nComponents; cmpt++)
- {
- writeEnsDataBinary(map(vf, prims, cmpt), ensightFile);
-
- for (int slave=1; slave& pf,
- OFstream& ensightFile
+ ensightStream& ensightFile
)
{
if (nPrims)
{
if (Pstream::master())
{
- ensightFile << key << nl;
+ ensightFile.write(key);
for (direction cmpt=0; cmpt::nComponents; cmpt++)
{
- writeData(map(pf, prims, cmpt), ensightFile);
+ ensightFile.write(map(pf, prims, cmpt));
for (int slave=1; slave::nComponents; cmpt++)
- {
- OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
- toMaster<< map(pf, prims, cmpt);
- }
- }
- }
-}
-
-
-template
-void writeAllFaceDataBinary
-(
- const char* key,
- const labelList& prims,
- const label nPrims,
- const Field& pf,
- std::ofstream& ensightFile
-)
-{
- if (nPrims)
- {
- if (Pstream::master())
- {
- writeEnsDataBinary(key,ensightFile);
-
- for (direction cmpt=0; cmpt::nComponents; cmpt++)
- {
- writeEnsDataBinary(map(pf, prims, cmpt), ensightFile);
-
- for (int slave=1; slave
-bool writePatchFieldBinary
-(
- const Foam::Field& pf,
- const Foam::label patchi,
- const Foam::label ensightPatchI,
- const Foam::faceSets& boundaryFaceSet,
- const Foam::ensightMesh::nFacePrimitives& nfp,
- std::ofstream& ensightFile
-)
-{
- if (nfp.nTris || nfp.nQuads || nfp.nPolys)
- {
- if (Pstream::master())
- {
- writeEnsDataBinary("part",ensightFile);
- writeEnsDataBinary(ensightPatchI,ensightFile);
- }
-
- writeAllFaceDataBinary
- (
- "tria3",
- boundaryFaceSet.tris,
- nfp.nTris,
- pf,
- ensightFile
- );
-
- writeAllFaceDataBinary
- (
- "quad4",
- boundaryFaceSet.quads,
- nfp.nQuads,
- pf,
- ensightFile
- );
-
- writeAllFaceDataBinary
- (
- "nsided",
- boundaryFaceSet.polys,
- nfp.nPolys,
- pf,
- ensightFile
- );
-
- return true;
- }
- else
- {
- return false;
- }
-}
-
-
template
void writePatchField
(
@@ -380,6 +229,7 @@ void writePatchField
const Foam::fileName& postProcPath,
const Foam::word& prepend,
const Foam::label timeIndex,
+ const bool binary,
Foam::Ostream& ensightCaseFile
)
{
@@ -409,7 +259,7 @@ void writePatchField
word timeFile = prepend + itoa(timeIndex);
- OFstream *ensightFilePtr = NULL;
+ autoPtr ensightFilePtr;
if (Pstream::master())
{
if (timeIndex == 0)
@@ -426,20 +276,36 @@ void writePatchField
// set the filename of the ensight file
fileName ensightFileName(timeFile + "." + pfName);
- ensightFilePtr = new OFstream
- (
- postProcPath/ensightFileName,
- runTime.writeFormat(),
- runTime.writeVersion(),
- runTime.writeCompression()
- );
+
+ if (binary)
+ {
+ ensightFilePtr.reset
+ (
+ new ensightBinaryStream
+ (
+ postProcPath/ensightFileName,
+ runTime
+ )
+ );
+ }
+ else
+ {
+ ensightFilePtr.reset
+ (
+ new ensightAsciiStream
+ (
+ postProcPath/ensightFileName,
+ runTime
+ )
+ );
+ }
}
- OFstream& ensightFile = *ensightFilePtr;
+ ensightStream& ensightFile = ensightFilePtr();
if (Pstream::master())
{
- ensightFile << pTraits::typeName << nl;
+ ensightFile.write(pTraits::typeName);
}
if (patchi >= 0)
@@ -468,26 +334,22 @@ void writePatchField
ensightFile
);
}
-
- if (Pstream::master())
- {
- delete ensightFilePtr;
- }
}
template
-void ensightFieldAscii
+void ensightField
(
- const Foam::IOobject& fieldObject,
+ const GeometricField& vf,
const Foam::ensightMesh& eMesh,
const Foam::fileName& postProcPath,
const Foam::word& prepend,
const Foam::label timeIndex,
+ const bool binary,
Foam::Ostream& ensightCaseFile
)
{
- Info<< "Converting field " << fieldObject.name() << endl;
+ Info<< "Converting field " << vf.name() << endl;
word timeFile = prepend + itoa(timeIndex);
@@ -512,23 +374,37 @@ void ensightFieldAscii
const labelList& hexes = meshCellSets.hexes;
const labelList& polys = meshCellSets.polys;
- OFstream *ensightFilePtr = NULL;
+ autoPtr ensightFilePtr;
if (Pstream::master())
{
// set the filename of the ensight file
- fileName ensightFileName(timeFile + "." + fieldObject.name());
- ensightFilePtr = new OFstream
- (
- postProcPath/ensightFileName,
- runTime.writeFormat(),
- runTime.writeVersion(),
- IOstream::UNCOMPRESSED
- );
+ fileName ensightFileName(timeFile + "." + vf.name());
+
+ if (binary)
+ {
+ ensightFilePtr.reset
+ (
+ new ensightBinaryStream
+ (
+ postProcPath/ensightFileName,
+ runTime
+ )
+ );
+ }
+ else
+ {
+ ensightFilePtr.reset
+ (
+ new ensightAsciiStream
+ (
+ postProcPath/ensightFileName,
+ runTime
+ )
+ );
+ }
}
- OFstream& ensightFile = *ensightFilePtr;
-
- GeometricField vf(fieldObject, mesh);
+ ensightStream& ensightFile = ensightFilePtr();
if (patchNames.empty())
{
@@ -548,34 +424,26 @@ void ensightFieldAscii
<< nl;
}
- ensightFile
- << pTraits::typeName << nl
- << "part" << nl
- << setw(10) << 1 << nl;
-
- ensightFile.setf(ios_base::scientific, ios_base::floatfield);
- ensightFile.precision(5);
+ ensightFile.write(pTraits::typeName);
+ ensightFile.writePartHeader(1);
}
if (meshCellSets.nHexesWedges)
{
if (Pstream::master())
{
- ensightFile << "hexa8" << nl;
+ ensightFile.write("hexa8");
for (direction cmpt=0; cmpt::nComponents; cmpt++)
{
- writeData
- (
- map(vf, hexes, wedges, cmpt),
- ensightFile
- );
+ scalarField masterData(map(vf, hexes, wedges, cmpt));
+ ensightFile.write(masterData);
for (int slave=1; slave
-void ensightFieldBinary
+void ensightPointField
(
- const Foam::IOobject& fieldObject,
+ const GeometricField& pf,
const Foam::ensightMesh& eMesh,
const Foam::fileName& postProcPath,
const Foam::word& prepend,
const Foam::label timeIndex,
+ const bool binary,
Foam::Ostream& ensightCaseFile
)
{
- Info<< "Converting field (binary) " << fieldObject.name() << endl;
+ Info<< "Converting field " << pf.name() << endl;
word timeFile = prepend + itoa(timeIndex);
- const fvMesh& mesh = eMesh.mesh();
+ //const fvMesh& mesh = eMesh.mesh();
//const Time& runTime = mesh.time();
- const cellSets& meshCellSets = eMesh.meshCellSets();
- const List& boundaryFaceSets = eMesh.boundaryFaceSets();
- const wordList& allPatchNames = eMesh.allPatchNames();
- const wordHashSet& patchNames = eMesh.patchNames();
- const HashTable&
- nPatchPrims = eMesh.nPatchPrims();
- const List& faceZoneFaceSets = eMesh.faceZoneFaceSets();
- const wordHashSet& faceZoneNames = eMesh.faceZoneNames();
- const HashTable&
- nFaceZonePrims = eMesh.nFaceZonePrims();
-
- const labelList& tets = meshCellSets.tets;
- const labelList& pyrs = meshCellSets.pyrs;
- const labelList& prisms = meshCellSets.prisms;
- const labelList& wedges = meshCellSets.wedges;
- const labelList& hexes = meshCellSets.hexes;
- const labelList& polys = meshCellSets.polys;
-
- std::ofstream *ensightFilePtr = NULL;
+ autoPtr ensightFilePtr;
if (Pstream::master())
{
// set the filename of the ensight file
- fileName ensightFileName(timeFile + "." + fieldObject.name());
- ensightFilePtr = new std::ofstream
- (
- (postProcPath/ensightFileName).c_str(),
- ios_base::out | ios_base::binary | ios_base::trunc
- );
- // Check on file opened?
+ fileName ensightFileName(timeFile + "." + pf.name());
+
+ if (binary)
+ {
+ ensightFilePtr.reset
+ (
+ new ensightBinaryStream
+ (
+ postProcPath/ensightFileName,
+ eMesh.mesh().time()
+ )
+ );
+ }
+ else
+ {
+ ensightFilePtr.reset
+ (
+ new ensightAsciiStream
+ (
+ postProcPath/ensightFileName,
+ eMesh.mesh().time()
+ )
+ );
+ }
}
- std::ofstream& ensightFile = *ensightFilePtr;
+ ensightStream& ensightFile = ensightFilePtr();
- GeometricField vf(fieldObject, mesh);
-
- if (patchNames.empty())
+ if (eMesh.patchNames().empty())
{
eMesh.barrier();
@@ -800,192 +661,44 @@ void ensightFieldBinary
ensightCaseFile
<< pTraits::typeName
- << " per element: 1 "
- << setw(15) << vf.name()
- << (' ' + prepend + "***." + vf.name()).c_str()
+ << " per node: 1 "
+ << setw(15) << pf.name()
+ << (' ' + prepend + "***." + pf.name()).c_str()
<< nl;
}
- writeEnsDataBinary(pTraits::typeName,ensightFile);
- writeEnsDataBinary("part",ensightFile);
- writeEnsDataBinary(1,ensightFile);
+ ensightFile.write(pTraits::typeName);
+ ensightFile.write("part");
+ ensightFile.write(1);
}
- if (meshCellSets.nHexesWedges)
+ if (Pstream::master())
{
- if (Pstream::master())
- {
- writeEnsDataBinary("hexa8",ensightFile);
+ ensightFile.write("coordinates");
- for (direction cmpt=0; cmpt::nComponents; cmpt++)
- {
- writeEnsDataBinary
- (
- map(vf, hexes, wedges, cmpt),
- ensightFile
- );
+ Field uniqueFld(pf.internalField(), eMesh.uniquePointMap());
- for (int slave=1; slave::nComponents; cmpt++)
{
- for (direction cmpt=0; cmpt::nComponents; cmpt++)
+ ensightFile.write(uniqueFld.component(cmpt));
+
+ for (int slave=1; slave uniqueFld(pf.internalField(), eMesh.uniquePointMap());
+ for (direction cmpt=0; cmpt::nComponents; cmpt++)
{
- ensightPatchI++;
+ OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
+ toMaster<< uniqueFld.component(cmpt);
}
}
-
- }
-
- // write faceZones, if requested
- if (faceZoneNames.size())
- {
- // Interpolates cell values to faces - needed only when exporting
- // faceZones...
- GeometricField sf
- (
- linearInterpolate(vf)
- );
-
- forAllConstIter(wordHashSet, faceZoneNames, iter)
- {
- const word& faceZoneName = iter.key();
-
- eMesh.barrier();
-
- label zoneID = mesh.faceZones().findZoneID(faceZoneName);
-
- const faceZone& fz = mesh.faceZones()[zoneID];
-
- // Prepare data to write
- label nIncluded = 0;
- forAll(fz, i)
- {
- if (eMesh.faceToBeIncluded(fz[i]))
- {
- ++nIncluded;
- }
- }
-
- Field values(nIncluded);
-
- // Loop on the faceZone and store the needed field values
- label j = 0;
- forAll(fz, i)
- {
- label faceI = fz[i];
- if (mesh.isInternalFace(faceI))
- {
- values[j] = sf[faceI];
- ++j;
- }
- else
- {
- if (eMesh.faceToBeIncluded(faceI))
- {
- label patchI = mesh.boundaryMesh().whichPatch(faceI);
- const polyPatch& pp = mesh.boundaryMesh()[patchI];
- label patchFaceI = pp.whichFace(faceI);
- Type value = sf.boundaryField()[patchI][patchFaceI];
- values[j] = value;
- ++j;
- }
- }
- }
-
- if
- (
- writePatchFieldBinary
- (
- values,
- zoneID,
- ensightPatchI,
- faceZoneFaceSets[zoneID],
- nFaceZonePrims.find(faceZoneName)(),
- ensightFile
- )
- )
- {
- ensightPatchI++;
- }
- }
- }
-
- if (Pstream::master())
- {
- ensightFile.close();
}
}
@@ -999,30 +712,42 @@ void ensightField
const Foam::word& prepend,
const Foam::label timeIndex,
const bool binary,
+ const bool nodeValues,
Foam::Ostream& ensightCaseFile
)
{
- if (binary)
+ // Read field
+ GeometricField vf(fieldObject, eMesh.mesh());
+
+ if (nodeValues)
{
- ensightFieldBinary
+ tmp > pfld
(
- fieldObject,
+ volPointInterpolation::New(eMesh.mesh()).interpolate(vf)
+ );
+ pfld().rename(vf.name());
+
+ ensightPointField
+ (
+ pfld,
eMesh,
postProcPath,
prepend,
timeIndex,
+ binary,
ensightCaseFile
);
}
else
{
- ensightFieldAscii
+ ensightField
(
- fieldObject,
+ vf,
eMesh,
postProcPath,
prepend,
timeIndex,
+ binary,
ensightCaseFile
);
}
diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.C b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.C
index 00c733890a..c1d36da210 100644
--- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.C
+++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.C
@@ -23,9 +23,9 @@ License
\*---------------------------------------------------------------------------*/
+#include "ensightMesh.H"
#include "argList.H"
#include "Time.H"
-#include "ensightMesh.H"
#include "fvMesh.H"
#include "globalMeshData.H"
#include "PstreamCombineReduceOps.H"
@@ -33,38 +33,31 @@ License
#include "cellModeller.H"
#include "IOmanip.H"
#include "itoa.H"
-#include "ensightWriteBinary.H"
#include "globalIndex.H"
#include "mapDistribute.H"
#include "stringListOps.H"
+#include "ensightBinaryStream.H"
+#include "ensightAsciiStream.H"
+
#include
// * * * * * * * * * * * * * Private Functions * * * * * * * * * * * * * * //
-// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
-
-Foam::ensightMesh::ensightMesh
-(
- const fvMesh& mesh,
- const argList& args,
- const bool binary
-)
-:
- mesh_(mesh),
- binary_(binary),
- patchPartOffset_(2),
- meshCellSets_(mesh_.nCells()),
- boundaryFaceSets_(mesh_.boundary().size()),
- allPatchNames_(0),
- patchNames_(0),
- nPatchPrims_(0),
- faceZoneFaceSets_(mesh_.faceZones().size()),
- faceZoneNames_(0),
- nFaceZonePrims_(0),
- boundaryFaceToBeIncluded_(0)
+void Foam::ensightMesh::correct()
{
- const cellShapeList& cellShapes = mesh.cellShapes();
+ patchPartOffset_ = 2;
+ meshCellSets_ = mesh_.nCells();
+ boundaryFaceSets_.setSize(mesh_.boundary().size());
+ allPatchNames_.clear();
+ patchNames_.clear();
+ nPatchPrims_ = 0;
+ faceZoneFaceSets_.setSize(mesh_.faceZones().size());
+ faceZoneNames_.clear();
+ nFaceZonePrims_ = 0;
+ boundaryFaceToBeIncluded_.clear();
+
+ const cellShapeList& cellShapes = mesh_.cellShapes();
const cellModel& tet = *(cellModeller::lookup("tet"));
const cellModel& pyr = *(cellModeller::lookup("pyr"));
@@ -72,7 +65,7 @@ Foam::ensightMesh::ensightMesh
const cellModel& wedge = *(cellModeller::lookup("wedge"));
const cellModel& hex = *(cellModeller::lookup("hex"));
- if (!args.optionFound("noPatches"))
+ if (!noPatches_)
{
// Patches are output. Check that they're synced.
mesh_.boundaryMesh().checkParallelSync(true);
@@ -84,11 +77,9 @@ Foam::ensightMesh::ensightMesh
- mesh_.globalData().processorPatches().size()
);
- if (args.optionFound("patches"))
+ if (patches_)
{
- wordReList patterns(args.optionLookup("patches")());
-
- if (patterns.empty())
+ if (patchPatterns_.empty())
{
forAll(allPatchNames_, nameI)
{
@@ -101,7 +92,7 @@ Foam::ensightMesh::ensightMesh
forAll(allPatchNames_, nameI)
{
const word& patchName = allPatchNames_[nameI];
- if (findStrings(patterns, patchName))
+ if (findStrings(patchPatterns_, patchName))
{
patchNames_.insert(patchName);
}
@@ -184,15 +175,23 @@ Foam::ensightMesh::ensightMesh
meshCellSets_.nPolys = nPolys;
reduce(meshCellSets_.nPolys, sumOp