ENH: foamToEnsight : cleanup and -nodeValues for outputting interpolate
This commit is contained in:
parent
f2c3ba65a6
commit
9ad20b0a3b
@ -2,6 +2,5 @@ itoa.C
|
||||
ensightMesh.C
|
||||
ensightParticlePositions.C
|
||||
foamToEnsight.C
|
||||
ensightWriteBinary.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/foamToEnsight
|
||||
|
@ -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;
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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<int>& 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
|
||||
|
||||
// ************************************************************************* //
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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<std::ofstream> 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<const char*>(&val), sizeof(int));
|
||||
}
|
||||
|
||||
virtual void write(const scalarField& sf)
|
||||
{
|
||||
if (sf.size())
|
||||
{
|
||||
List<float> temp(sf.size());
|
||||
|
||||
forAll(sf, i)
|
||||
{
|
||||
temp[i] = float(sf[i]);
|
||||
}
|
||||
|
||||
str_().write
|
||||
(
|
||||
reinterpret_cast<const char*>(temp.begin()),
|
||||
sf.size()*sizeof(float)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void write(const List<int>& sf)
|
||||
{
|
||||
str_().write
|
||||
(
|
||||
reinterpret_cast<const char*>(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
|
||||
|
||||
// ************************************************************************* //
|
@ -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<class Type>
|
||||
scalarField map
|
||||
(
|
||||
@ -104,64 +90,25 @@ void writeAllData
|
||||
const Field<Type>& 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<pTraits<Type>::nComponents; cmpt++)
|
||||
{
|
||||
writeData(map(vf, prims, cmpt), ensightFile);
|
||||
scalarField masterData(map(vf, prims, cmpt));
|
||||
ensightFile.write(masterData);
|
||||
|
||||
for (int slave=1; slave<Pstream::nProcs(); slave++)
|
||||
{
|
||||
IPstream fromSlave(Pstream::scheduled, slave);
|
||||
scalarField data(fromSlave);
|
||||
writeData(data, ensightFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
|
||||
{
|
||||
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
|
||||
toMaster<< map(vf, prims, cmpt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void writeAllDataBinary
|
||||
(
|
||||
const char* key,
|
||||
const Field<Type>& vf,
|
||||
const labelList& prims,
|
||||
const label nPrims,
|
||||
std::ofstream& ensightFile
|
||||
)
|
||||
{
|
||||
if (nPrims)
|
||||
{
|
||||
if (Pstream::master())
|
||||
{
|
||||
writeEnsDataBinary(key,ensightFile);
|
||||
|
||||
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
|
||||
{
|
||||
writeEnsDataBinary(map(vf, prims, cmpt), ensightFile);
|
||||
|
||||
for (int slave=1; slave<Pstream::nProcs(); slave++)
|
||||
{
|
||||
IPstream fromSlave(Pstream::scheduled, slave);
|
||||
scalarField data(fromSlave);
|
||||
writeEnsDataBinary(data, ensightFile);
|
||||
scalarField slaveData(fromSlave);
|
||||
ensightFile.write(slaveData);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -184,66 +131,25 @@ void writeAllFaceData
|
||||
const labelList& prims,
|
||||
const label nPrims,
|
||||
const Field<Type>& pf,
|
||||
OFstream& ensightFile
|
||||
ensightStream& ensightFile
|
||||
)
|
||||
{
|
||||
if (nPrims)
|
||||
{
|
||||
if (Pstream::master())
|
||||
{
|
||||
ensightFile << key << nl;
|
||||
ensightFile.write(key);
|
||||
|
||||
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
|
||||
{
|
||||
writeData(map(pf, prims, cmpt), ensightFile);
|
||||
ensightFile.write(map(pf, prims, cmpt));
|
||||
|
||||
for (int slave=1; slave<Pstream::nProcs(); slave++)
|
||||
{
|
||||
IPstream fromSlave(Pstream::scheduled, slave);
|
||||
scalarField pf(fromSlave);
|
||||
|
||||
writeData(pf, ensightFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
|
||||
{
|
||||
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
|
||||
toMaster<< map(pf, prims, cmpt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void writeAllFaceDataBinary
|
||||
(
|
||||
const char* key,
|
||||
const labelList& prims,
|
||||
const label nPrims,
|
||||
const Field<Type>& pf,
|
||||
std::ofstream& ensightFile
|
||||
)
|
||||
{
|
||||
if (nPrims)
|
||||
{
|
||||
if (Pstream::master())
|
||||
{
|
||||
writeEnsDataBinary(key,ensightFile);
|
||||
|
||||
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
|
||||
{
|
||||
writeEnsDataBinary(map(pf, prims, cmpt), ensightFile);
|
||||
|
||||
for (int slave=1; slave<Pstream::nProcs(); slave++)
|
||||
{
|
||||
IPstream fromSlave(Pstream::scheduled, slave);
|
||||
scalarField pf(fromSlave);
|
||||
|
||||
writeEnsDataBinary(pf, ensightFile);
|
||||
ensightFile.write(pf);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -267,16 +173,14 @@ bool writePatchField
|
||||
const Foam::label ensightPatchI,
|
||||
const Foam::faceSets& boundaryFaceSet,
|
||||
const Foam::ensightMesh::nFacePrimitives& nfp,
|
||||
Foam::OFstream& ensightFile
|
||||
ensightStream& ensightFile
|
||||
)
|
||||
{
|
||||
if (nfp.nTris || nfp.nQuads || nfp.nPolys)
|
||||
{
|
||||
if (Pstream::master())
|
||||
{
|
||||
ensightFile
|
||||
<< "part" << nl
|
||||
<< setw(10) << ensightPatchI << nl;
|
||||
ensightFile.writePartHeader(ensightPatchI);
|
||||
}
|
||||
|
||||
writeAllFaceData
|
||||
@ -315,61 +219,6 @@ bool writePatchField
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
bool writePatchFieldBinary
|
||||
(
|
||||
const Foam::Field<Type>& 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<class Type>
|
||||
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<ensightStream> 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<Type>::typeName << nl;
|
||||
ensightFile.write(pTraits<Type>::typeName);
|
||||
}
|
||||
|
||||
if (patchi >= 0)
|
||||
@ -468,26 +334,22 @@ void writePatchField
|
||||
ensightFile
|
||||
);
|
||||
}
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
delete ensightFilePtr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void ensightFieldAscii
|
||||
void ensightField
|
||||
(
|
||||
const Foam::IOobject& fieldObject,
|
||||
const GeometricField<Type, fvPatchField, volMesh>& 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<ensightStream> 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<Type, fvPatchField, volMesh> vf(fieldObject, mesh);
|
||||
ensightStream& ensightFile = ensightFilePtr();
|
||||
|
||||
if (patchNames.empty())
|
||||
{
|
||||
@ -548,34 +424,26 @@ void ensightFieldAscii
|
||||
<< nl;
|
||||
}
|
||||
|
||||
ensightFile
|
||||
<< pTraits<Type>::typeName << nl
|
||||
<< "part" << nl
|
||||
<< setw(10) << 1 << nl;
|
||||
|
||||
ensightFile.setf(ios_base::scientific, ios_base::floatfield);
|
||||
ensightFile.precision(5);
|
||||
ensightFile.write(pTraits<Type>::typeName);
|
||||
ensightFile.writePartHeader(1);
|
||||
}
|
||||
|
||||
if (meshCellSets.nHexesWedges)
|
||||
{
|
||||
if (Pstream::master())
|
||||
{
|
||||
ensightFile << "hexa8" << nl;
|
||||
ensightFile.write("hexa8");
|
||||
|
||||
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
|
||||
{
|
||||
writeData
|
||||
(
|
||||
map(vf, hexes, wedges, cmpt),
|
||||
ensightFile
|
||||
);
|
||||
scalarField masterData(map(vf, hexes, wedges, cmpt));
|
||||
ensightFile.write(masterData);
|
||||
|
||||
for (int slave=1; slave<Pstream::nProcs(); slave++)
|
||||
{
|
||||
IPstream fromSlave(Pstream::scheduled, slave);
|
||||
scalarField data(fromSlave);
|
||||
writeData(data, ensightFile);
|
||||
ensightFile.write(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -727,68 +595,61 @@ void ensightFieldAscii
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
delete ensightFilePtr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void ensightFieldBinary
|
||||
void ensightPointField
|
||||
(
|
||||
const Foam::IOobject& fieldObject,
|
||||
const GeometricField<Type, pointPatchField, pointMesh>& 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<faceSets>& boundaryFaceSets = eMesh.boundaryFaceSets();
|
||||
const wordList& allPatchNames = eMesh.allPatchNames();
|
||||
const wordHashSet& patchNames = eMesh.patchNames();
|
||||
const HashTable<ensightMesh::nFacePrimitives>&
|
||||
nPatchPrims = eMesh.nPatchPrims();
|
||||
const List<faceSets>& faceZoneFaceSets = eMesh.faceZoneFaceSets();
|
||||
const wordHashSet& faceZoneNames = eMesh.faceZoneNames();
|
||||
const HashTable<ensightMesh::nFacePrimitives>&
|
||||
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<ensightStream> 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<Type, fvPatchField, volMesh> vf(fieldObject, mesh);
|
||||
|
||||
if (patchNames.empty())
|
||||
if (eMesh.patchNames().empty())
|
||||
{
|
||||
eMesh.barrier();
|
||||
|
||||
@ -800,192 +661,44 @@ void ensightFieldBinary
|
||||
|
||||
ensightCaseFile
|
||||
<< pTraits<Type>::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<Type>::typeName,ensightFile);
|
||||
writeEnsDataBinary("part",ensightFile);
|
||||
writeEnsDataBinary(1,ensightFile);
|
||||
ensightFile.write(pTraits<Type>::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<pTraits<Type>::nComponents; cmpt++)
|
||||
{
|
||||
writeEnsDataBinary
|
||||
(
|
||||
map(vf, hexes, wedges, cmpt),
|
||||
ensightFile
|
||||
);
|
||||
Field<Type> uniqueFld(pf.internalField(), eMesh.uniquePointMap());
|
||||
|
||||
for (int slave=1; slave<Pstream::nProcs(); slave++)
|
||||
{
|
||||
IPstream fromSlave(Pstream::scheduled, slave);
|
||||
scalarField data(fromSlave);
|
||||
writeEnsDataBinary(data, ensightFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
|
||||
{
|
||||
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
|
||||
ensightFile.write(uniqueFld.component(cmpt));
|
||||
|
||||
for (int slave=1; slave<Pstream::nProcs(); slave++)
|
||||
{
|
||||
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
|
||||
toMaster<< map(vf, hexes, wedges, cmpt);
|
||||
IPstream fromSlave(Pstream::scheduled, slave);
|
||||
scalarField data(fromSlave);
|
||||
ensightFile.write(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
writeAllDataBinary
|
||||
(
|
||||
"penta6",
|
||||
vf,
|
||||
prisms,
|
||||
meshCellSets.nPrisms,
|
||||
ensightFile
|
||||
);
|
||||
|
||||
writeAllDataBinary
|
||||
(
|
||||
"pyramid5",
|
||||
vf,
|
||||
pyrs,
|
||||
meshCellSets.nPyrs,
|
||||
ensightFile
|
||||
);
|
||||
|
||||
writeAllDataBinary
|
||||
(
|
||||
"tetra4",
|
||||
vf,
|
||||
tets,
|
||||
meshCellSets.nTets,
|
||||
ensightFile
|
||||
);
|
||||
|
||||
writeAllDataBinary
|
||||
(
|
||||
"nfaced",
|
||||
vf,
|
||||
polys,
|
||||
meshCellSets.nPolys,
|
||||
ensightFile
|
||||
);
|
||||
}
|
||||
|
||||
label ensightPatchI = eMesh.patchPartOffset();
|
||||
|
||||
forAll(allPatchNames, patchi)
|
||||
{
|
||||
const word& patchName = allPatchNames[patchi];
|
||||
|
||||
eMesh.barrier();
|
||||
|
||||
if (patchNames.empty() || patchNames.found(patchName))
|
||||
else
|
||||
{
|
||||
if
|
||||
(
|
||||
writePatchFieldBinary
|
||||
(
|
||||
vf.boundaryField()[patchi],
|
||||
patchi,
|
||||
ensightPatchI,
|
||||
boundaryFaceSets[patchi],
|
||||
nPatchPrims.find(patchName)(),
|
||||
ensightFile
|
||||
)
|
||||
)
|
||||
Field<Type> uniqueFld(pf.internalField(), eMesh.uniquePointMap());
|
||||
for (direction cmpt=0; cmpt<pTraits<Type>::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<Type, fvsPatchField, surfaceMesh> 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<Type> 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<Type, fvPatchField, volMesh> vf(fieldObject, eMesh.mesh());
|
||||
|
||||
if (nodeValues)
|
||||
{
|
||||
ensightFieldBinary<Type>
|
||||
tmp<GeometricField<Type, pointPatchField, pointMesh> > pfld
|
||||
(
|
||||
fieldObject,
|
||||
volPointInterpolation::New(eMesh.mesh()).interpolate(vf)
|
||||
);
|
||||
pfld().rename(vf.name());
|
||||
|
||||
ensightPointField<Type>
|
||||
(
|
||||
pfld,
|
||||
eMesh,
|
||||
postProcPath,
|
||||
prepend,
|
||||
timeIndex,
|
||||
binary,
|
||||
ensightCaseFile
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
ensightFieldAscii<Type>
|
||||
ensightField<Type>
|
||||
(
|
||||
fieldObject,
|
||||
vf,
|
||||
eMesh,
|
||||
postProcPath,
|
||||
prepend,
|
||||
timeIndex,
|
||||
binary,
|
||||
ensightCaseFile
|
||||
);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -38,10 +38,13 @@ SourceFiles
|
||||
#include "faceSets.H"
|
||||
#include "HashTable.H"
|
||||
#include "HashSet.H"
|
||||
#include "fvMesh.H"
|
||||
#include "OFstream.H"
|
||||
#include <fstream>
|
||||
#include "PackedBoolList.H"
|
||||
#include "wordReList.H"
|
||||
#include "scalarField.H"
|
||||
#include "cellShapeList.H"
|
||||
#include "cellList.H"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -51,6 +54,7 @@ namespace Foam
|
||||
class fvMesh;
|
||||
class argList;
|
||||
class globalIndex;
|
||||
class ensightStream;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class ensightMesh Declaration
|
||||
@ -82,8 +86,19 @@ private:
|
||||
//- Reference to the OpenFOAM mesh
|
||||
const fvMesh& mesh_;
|
||||
|
||||
//- Suppress patches
|
||||
const bool noPatches_;
|
||||
|
||||
//- Output selected patches only
|
||||
const bool patches_;
|
||||
const wordReList patchPatterns_;
|
||||
|
||||
//- Output selected faceZones
|
||||
const bool faceZones_;
|
||||
const wordReList faceZonePatterns_;
|
||||
|
||||
//- Set binary file output
|
||||
bool binary_;
|
||||
const bool binary_;
|
||||
|
||||
//- The ensight part id for the first patch
|
||||
label patchPartOffset_;
|
||||
@ -109,6 +124,19 @@ private:
|
||||
PackedBoolList boundaryFaceToBeIncluded_;
|
||||
|
||||
|
||||
// Parallel merged points
|
||||
|
||||
//- Global numbering for merged points
|
||||
autoPtr<globalIndex> globalPointsPtr_;
|
||||
|
||||
//- From mesh point to global merged point
|
||||
labelList pointToGlobal_;
|
||||
|
||||
//- Local points that are unique
|
||||
labelList uniquePointMap_;
|
||||
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
@ -120,7 +148,7 @@ private:
|
||||
void writePoints
|
||||
(
|
||||
const scalarField& pointsComponent,
|
||||
OFstream& ensightGeometryFile
|
||||
ensightStream& ensightGeometryFile
|
||||
) const;
|
||||
|
||||
cellShapeList map
|
||||
@ -141,14 +169,14 @@ private:
|
||||
void writePrims
|
||||
(
|
||||
const cellShapeList& cellShapes,
|
||||
OFstream& ensightGeometryFile
|
||||
ensightStream& ensightGeometryFile
|
||||
) const;
|
||||
|
||||
void writePolysNFaces
|
||||
(
|
||||
const labelList& polys,
|
||||
const cellList& cellFaces,
|
||||
OFstream& ensightGeometryFile
|
||||
ensightStream& ensightGeometryFile
|
||||
) const;
|
||||
|
||||
void writePolysNPointsPerFace
|
||||
@ -156,7 +184,7 @@ private:
|
||||
const labelList& polys,
|
||||
const cellList& cellFaces,
|
||||
const faceList& faces,
|
||||
OFstream& ensightGeometryFile
|
||||
ensightStream& ensightGeometryFile
|
||||
) const;
|
||||
|
||||
void writePolysPoints
|
||||
@ -164,13 +192,13 @@ private:
|
||||
const labelList& polys,
|
||||
const cellList& cellFaces,
|
||||
const faceList& faces,
|
||||
OFstream& ensightGeometryFile
|
||||
ensightStream& ensightGeometryFile
|
||||
) const;
|
||||
|
||||
void writeAllPolys
|
||||
(
|
||||
const labelList& pointToGlobal,
|
||||
OFstream& ensightGeometryFile
|
||||
ensightStream& ensightGeometryFile
|
||||
) const;
|
||||
|
||||
void writeAllPrims
|
||||
@ -178,13 +206,13 @@ private:
|
||||
const char* key,
|
||||
const label nPrims,
|
||||
const cellShapeList& cellShapes,
|
||||
OFstream& ensightGeometryFile
|
||||
ensightStream& ensightGeometryFile
|
||||
) const;
|
||||
|
||||
void writeFacePrims
|
||||
(
|
||||
const faceList& patchFaces,
|
||||
OFstream& ensightGeometryFile
|
||||
ensightStream& ensightGeometryFile
|
||||
) const;
|
||||
|
||||
void writeAllFacePrims
|
||||
@ -193,19 +221,19 @@ private:
|
||||
const labelList& prims,
|
||||
const label nPrims,
|
||||
const faceList& patchFaces,
|
||||
OFstream& ensightGeometryFile
|
||||
ensightStream& ensightGeometryFile
|
||||
) const;
|
||||
|
||||
void writeNSidedNPointsPerFace
|
||||
(
|
||||
const faceList& patchFaces,
|
||||
OFstream& ensightGeometryFile
|
||||
ensightStream& ensightGeometryFile
|
||||
) const;
|
||||
|
||||
void writeNSidedPoints
|
||||
(
|
||||
const faceList& patchFaces,
|
||||
OFstream& ensightGeometryFile
|
||||
ensightStream& ensightGeometryFile
|
||||
) const;
|
||||
|
||||
void writeAllNSided
|
||||
@ -213,14 +241,14 @@ private:
|
||||
const labelList& prims,
|
||||
const label nPrims,
|
||||
const faceList& patchFaces,
|
||||
OFstream& ensightGeometryFile
|
||||
ensightStream& ensightGeometryFile
|
||||
) const;
|
||||
|
||||
void writeAllInternalPoints
|
||||
(
|
||||
const pointField& uniquePoints,
|
||||
const label nPoints,
|
||||
OFstream& ensightGeometryFile
|
||||
ensightStream& ensightGeometryFile
|
||||
) const;
|
||||
|
||||
void writeAllPatchPoints
|
||||
@ -229,123 +257,7 @@ private:
|
||||
const word& patchName,
|
||||
const pointField& uniquePoints,
|
||||
const label nPoints,
|
||||
OFstream& ensightGeometryFile
|
||||
) const;
|
||||
|
||||
void writeAllInternalPointsBinary
|
||||
(
|
||||
const pointField& uniquePoints,
|
||||
const label nPoints,
|
||||
std::ofstream& ensightGeometryFile
|
||||
) const;
|
||||
|
||||
void writeAllPatchPointsBinary
|
||||
(
|
||||
label ensightPatchI,
|
||||
const word& patchName,
|
||||
const pointField& uniquePoints,
|
||||
const label nPoints,
|
||||
std::ofstream& ensightGeometryFile
|
||||
) const;
|
||||
|
||||
void writeAscii
|
||||
(
|
||||
const fileName& postProcPath,
|
||||
const word& prepend,
|
||||
const label timeIndex,
|
||||
Ostream& ensightCaseFile,
|
||||
const labelList& pointToGlobal,
|
||||
const pointField& uniquePoints,
|
||||
const globalIndex& globalPoints
|
||||
) const;
|
||||
|
||||
void writeBinary
|
||||
(
|
||||
const fileName& postProcPath,
|
||||
const word& prepend,
|
||||
const label timeIndex,
|
||||
Ostream& ensightCaseFile,
|
||||
const labelList& pointToGlobal,
|
||||
const pointField& uniquePoints,
|
||||
const globalIndex& globalPoints
|
||||
) const;
|
||||
|
||||
void writePrimsBinary
|
||||
(
|
||||
const cellShapeList& cellShapes,
|
||||
std::ofstream& ensightGeometryFile
|
||||
) const;
|
||||
|
||||
void writeAllPrimsBinary
|
||||
(
|
||||
const char* key,
|
||||
const label nPrims,
|
||||
const cellShapeList& cellShapes,
|
||||
std::ofstream& ensightGeometryFile
|
||||
) const;
|
||||
|
||||
void writePolysNFacesBinary
|
||||
(
|
||||
const labelList& polys,
|
||||
const cellList& cellFaces,
|
||||
std::ofstream& ensightGeometryFile
|
||||
) const;
|
||||
|
||||
void writePolysNPointsPerFaceBinary
|
||||
(
|
||||
const labelList& polys,
|
||||
const cellList& cellFaces,
|
||||
const faceList& faces,
|
||||
std::ofstream& ensightGeometryFile
|
||||
) const;
|
||||
|
||||
void writePolysPointsBinary
|
||||
(
|
||||
const labelList& polys,
|
||||
const cellList& cellFaces,
|
||||
const faceList& faces,
|
||||
std::ofstream& ensightGeometryFile
|
||||
) const;
|
||||
|
||||
void writeAllPolysBinary
|
||||
(
|
||||
const labelList& pointToGlobal,
|
||||
std::ofstream& ensightGeometryFile
|
||||
) const;
|
||||
|
||||
void writeAllFacePrimsBinary
|
||||
(
|
||||
const char* key,
|
||||
const labelList& prims,
|
||||
const label nPrims,
|
||||
const faceList& patchFaces,
|
||||
std::ofstream& ensightGeometryFile
|
||||
) const;
|
||||
|
||||
void writeFacePrimsBinary
|
||||
(
|
||||
const faceList& patchFaces,
|
||||
std::ofstream& ensightGeometryFile
|
||||
) const;
|
||||
|
||||
void writeNSidedPointsBinary
|
||||
(
|
||||
const faceList& patchFaces,
|
||||
std::ofstream& ensightGeometryFile
|
||||
) const;
|
||||
|
||||
void writeNSidedNPointsPerFaceBinary
|
||||
(
|
||||
const faceList& patchFaces,
|
||||
std::ofstream& ensightGeometryFile
|
||||
) const;
|
||||
|
||||
void writeAllNSidedBinary
|
||||
(
|
||||
const labelList& prims,
|
||||
const label nPrims,
|
||||
const faceList& patchFaces,
|
||||
std::ofstream& ensightGeometryFile
|
||||
ensightStream& ensightGeometryFile
|
||||
) const;
|
||||
|
||||
public:
|
||||
@ -355,8 +267,12 @@ public:
|
||||
//- Construct from fvMesh
|
||||
ensightMesh
|
||||
(
|
||||
const fvMesh&,
|
||||
const argList& args,
|
||||
const fvMesh& mesh,
|
||||
const bool noPatches,
|
||||
const bool patches,
|
||||
const wordReList& patchPatterns,
|
||||
const bool faceZones,
|
||||
const wordReList& faceZonePatterns,
|
||||
const bool binary
|
||||
);
|
||||
|
||||
@ -420,8 +336,35 @@ public:
|
||||
return patchPartOffset_;
|
||||
}
|
||||
|
||||
|
||||
// Parallel point merging
|
||||
|
||||
//- Global numbering for merged points
|
||||
const globalIndex& globalPoints() const
|
||||
{
|
||||
return globalPointsPtr_();
|
||||
}
|
||||
|
||||
//- From mesh point to global merged point
|
||||
const labelList& pointToGlobal() const
|
||||
{
|
||||
return pointToGlobal_;
|
||||
}
|
||||
|
||||
//- Local points that are unique
|
||||
const labelList& uniquePointMap() const
|
||||
{
|
||||
return uniquePointMap_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Other
|
||||
|
||||
//- Update for new mesh
|
||||
void correct();
|
||||
|
||||
//- When exporting faceZones, check if a given face has to be included
|
||||
// or not (i.e. faces on processor boundaries)
|
||||
bool faceToBeIncluded(const label faceI) const;
|
||||
|
@ -0,0 +1,112 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::ensightStream
|
||||
|
||||
Description
|
||||
Abstract base class for writing Ensight data
|
||||
|
||||
SourceFiles
|
||||
ensightStream.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef ensightStream_H
|
||||
#define ensightStream_H
|
||||
|
||||
#include "fileName.H"
|
||||
#include "scalarField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class ensightStream Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class ensightStream
|
||||
{
|
||||
// Private data
|
||||
|
||||
const fileName name_;
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
ensightStream(const ensightStream&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const ensightStream&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
ensightStream(const fileName& f)
|
||||
:
|
||||
name_(f)
|
||||
{}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~ensightStream()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
const fileName& name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
virtual void write(const char*) = 0;
|
||||
|
||||
virtual void write(const int) = 0;
|
||||
|
||||
virtual void write(const scalarField&) = 0;
|
||||
|
||||
virtual void write(const List<int>&) = 0;
|
||||
|
||||
virtual void writePartHeader(const label) = 0;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
@ -1,78 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "ensightWriteBinary.H"
|
||||
#include <fstream>
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
void writeEnsDataBinary
|
||||
(
|
||||
const char* val,
|
||||
std::ofstream& ensFile
|
||||
)
|
||||
{
|
||||
char buffer[80] = {0};
|
||||
strcpy(buffer, val);
|
||||
ensFile.write(buffer, 80*sizeof(char));
|
||||
}
|
||||
|
||||
|
||||
void writeEnsDataBinary
|
||||
(
|
||||
const int val,
|
||||
std::ofstream& ensFile
|
||||
)
|
||||
{
|
||||
ensFile.write(reinterpret_cast<const char*>(&val), sizeof(int));
|
||||
}
|
||||
|
||||
|
||||
void writeEnsDataBinary
|
||||
(
|
||||
const scalarField& sf,
|
||||
std::ofstream& ensightFile
|
||||
)
|
||||
{
|
||||
if (sf.size())
|
||||
{
|
||||
List<float> temp(sf.size());
|
||||
|
||||
forAll(sf, i)
|
||||
{
|
||||
temp[i] = float(sf[i]);
|
||||
}
|
||||
|
||||
ensightFile.write
|
||||
(
|
||||
reinterpret_cast<char*>(temp.begin()),
|
||||
sf.size()*sizeof(float)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
@ -1,67 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
InApplication
|
||||
foamToEnsight
|
||||
|
||||
Description
|
||||
Collection of functions for binary write in EnSight files
|
||||
|
||||
SourceFiles
|
||||
ensightWriteBinary.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef ensightWriteBinary_H
|
||||
#define ensightWriteBinary_H
|
||||
|
||||
#include "ensightMesh.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
void writeEnsDataBinary
|
||||
(
|
||||
const char* val,
|
||||
std::ofstream& ensFile
|
||||
);
|
||||
|
||||
void writeEnsDataBinary
|
||||
(
|
||||
const int val,
|
||||
std::ofstream& ensFile
|
||||
);
|
||||
|
||||
|
||||
void writeEnsDataBinary
|
||||
(
|
||||
const scalarField& sf,
|
||||
std::ofstream& ensightFile
|
||||
);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
@ -44,15 +44,6 @@ namespace Foam
|
||||
|
||||
class faceSets
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
faceSets(const faceSets&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const faceSets&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
label nTris;
|
||||
|
@ -104,6 +104,11 @@ int main(int argc, char *argv[])
|
||||
"write in ASCII format instead of 'C Binary'"
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"nodeValues",
|
||||
"write values in nodes"
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"noPatches",
|
||||
"suppress writing any patches"
|
||||
@ -126,6 +131,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Check options
|
||||
const bool binary = !args.optionFound("ascii");
|
||||
const bool nodeValues = args.optionFound("nodeValues");
|
||||
|
||||
# include "createTime.H"
|
||||
|
||||
@ -191,7 +197,29 @@ int main(int argc, char *argv[])
|
||||
OFstream& ensightCaseFile = *ensightCaseFilePtr;
|
||||
|
||||
// Construct the EnSight mesh
|
||||
ensightMesh eMesh(mesh, args, binary);
|
||||
const bool selectedPatches = args.optionFound("patches");
|
||||
wordReList patchPatterns;
|
||||
if (selectedPatches)
|
||||
{
|
||||
patchPatterns = wordReList(args.optionLookup("patches")());
|
||||
}
|
||||
const bool selectedZones = args.optionFound("faceZones");
|
||||
wordReList zonePatterns;
|
||||
if (selectedZones)
|
||||
{
|
||||
zonePatterns = wordReList(args.optionLookup("faceZones")());
|
||||
}
|
||||
|
||||
ensightMesh eMesh
|
||||
(
|
||||
mesh,
|
||||
args.optionFound("noPatches"),
|
||||
selectedPatches,
|
||||
patchPatterns,
|
||||
selectedZones,
|
||||
zonePatterns,
|
||||
binary
|
||||
);
|
||||
|
||||
// Set Time to the last time before looking for the lagrangian objects
|
||||
runTime.setTime(Times.last(), Times.size()-1);
|
||||
@ -313,6 +341,11 @@ int main(int argc, char *argv[])
|
||||
|
||||
polyMesh::readUpdateState meshState = mesh.readUpdate();
|
||||
|
||||
if (meshState != polyMesh::UNCHANGED)
|
||||
{
|
||||
eMesh.correct();
|
||||
}
|
||||
|
||||
if (timeIndex == 0 || (meshState != polyMesh::UNCHANGED))
|
||||
{
|
||||
eMesh.write
|
||||
@ -371,6 +404,7 @@ int main(int argc, char *argv[])
|
||||
prepend,
|
||||
timeIndex,
|
||||
binary,
|
||||
nodeValues,
|
||||
ensightCaseFile
|
||||
);
|
||||
}
|
||||
@ -384,6 +418,7 @@ int main(int argc, char *argv[])
|
||||
prepend,
|
||||
timeIndex,
|
||||
binary,
|
||||
nodeValues,
|
||||
ensightCaseFile
|
||||
);
|
||||
}
|
||||
@ -397,6 +432,7 @@ int main(int argc, char *argv[])
|
||||
prepend,
|
||||
timeIndex,
|
||||
binary,
|
||||
nodeValues,
|
||||
ensightCaseFile
|
||||
);
|
||||
}
|
||||
@ -410,6 +446,7 @@ int main(int argc, char *argv[])
|
||||
prepend,
|
||||
timeIndex,
|
||||
binary,
|
||||
nodeValues,
|
||||
ensightCaseFile
|
||||
);
|
||||
}
|
||||
@ -423,6 +460,7 @@ int main(int argc, char *argv[])
|
||||
prepend,
|
||||
timeIndex,
|
||||
binary,
|
||||
nodeValues,
|
||||
ensightCaseFile
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user