foamToEnsight* fixes and tweaks

foamToEnsight:
    - add -noPatches option
    - had incorrect part# when the internalMesh was not output
    - case file is always ascii

foamToEnsightParts:
    - fixed field selection bug,
      no fields were selected when a single time-step was selected
This commit is contained in:
Mark Olesen
2009-05-12 12:37:25 +02:00
parent 4366d8df2c
commit 72362de6b1
12 changed files with 420 additions and 501 deletions

View File

@ -1,18 +1,21 @@
for (int n1=startTime; n1<endTime; n1++)
// ignore special fields or fields that we don't handle
//
bool variableGood = true;
for (label n1=startTime; n1<endTime && variableGood; ++n1)
{
// ignore _0 fields
if (fieldName.size() > 2 && fieldName(fieldName.size() - 2, 2) == "_0")
{
variableGood = false;
break;
}
IOobject fieldObjectHeader
(
fieldName,
Times[n1].name(),
mesh,
IOobject::NO_READ
);
variableGood = variableGood && fieldObjectHeader.headerOk();
else
{
variableGood = IOobject
(
fieldName,
Times[n1].name(),
mesh,
IOobject::NO_READ
).headerOk();
}
}

View File

@ -1,19 +1,19 @@
bool meshMoving = true;
// check for "points" in all of the result directories
bool meshMoving = true;
if (Times.size() > 2)
{
for(label n2=2; n2<Times.size(); n2++)
{
IOobject tmpPoints
(
"points",
Times[n2].name(),
polyMesh::meshSubDir,
mesh,
IOobject::NO_READ
);
meshMoving = meshMoving && tmpPoints.headerOk();
}
for (label n1=2; n1<Times.size() && meshMoving; ++n1)
{
meshMoving = IOobject
(
"points",
Times[n1].name(),
polyMesh::meshSubDir,
mesh,
IOobject::NO_READ
).headerOk();
}
}
else
{

View File

@ -1,5 +0,0 @@
if (Pstream::master())
{
ensightCaseFile << "FORMAT" << nl;
ensightCaseFile << "type: ensight gold" << nl << nl;
}

View File

@ -275,8 +275,8 @@ template<class Type>
bool writePatchField
(
const Foam::Field<Type>& pf,
const Foam::label patchi,
const Foam::label ensightPatchi,
const Foam::label patchI,
const Foam::label ensightPatchI,
const Foam::faceSets& boundaryFaceSet,
const Foam::ensightMesh::nFacePrimitives& nfp,
const Foam::labelList& patchProcessors,
@ -289,7 +289,7 @@ bool writePatchField
{
ensightFile
<< "part" << nl
<< setw(10) << ensightPatchi << nl;
<< setw(10) << ensightPatchI << nl;
}
writeAllFaceData
@ -335,8 +335,8 @@ template<class Type>
bool writePatchFieldBinary
(
const Foam::Field<Type>& pf,
const Foam::label patchi,
const Foam::label ensightPatchi,
const Foam::label patchI,
const Foam::label ensightPatchI,
const Foam::faceSets& boundaryFaceSet,
const Foam::ensightMesh::nFacePrimitives& nfp,
const Foam::labelList& patchProcessors,
@ -348,7 +348,7 @@ bool writePatchFieldBinary
if (Pstream::master())
{
writeEnsDataBinary("part",ensightFile);
writeEnsDataBinary(ensightPatchi,ensightFile);
writeEnsDataBinary(ensightPatchI,ensightFile);
}
writeAllFaceDataBinary
@ -411,14 +411,14 @@ void writePatchField
const HashTable<ensightMesh::nFacePrimitives>&
nPatchPrims = eMesh.nPatchPrims();
label patchi = -1;
label patchI = -1;
if (patchIndices.found(patchName))
{
patchi = patchIndices.find(patchName)();
patchI = patchIndices.find(patchName)();
}
label ensightPatchi = 2;
label ensightPatchI = eMesh.patchPartOffset();
for
(
@ -429,7 +429,7 @@ void writePatchField
)
{
if (iter.key() == patchName) break;
ensightPatchi++;
ensightPatchI++;
}
@ -472,14 +472,14 @@ void writePatchField
ensightFile << pTraits<Type>::typeName << nl;
}
if (patchi >= 0)
if (patchI >= 0)
{
writePatchField
(
pf,
patchi,
ensightPatchi,
boundaryFaceSets[patchi],
patchI,
ensightPatchI,
boundaryFaceSets[patchI],
nPatchPrims.find(patchName)(),
patchProcessors,
ensightFile
@ -493,7 +493,7 @@ void writePatchField
(
Field<Type>(),
-1,
ensightPatchi,
ensightPatchI,
nullFaceSets,
nPatchPrims.find(patchName)(),
patchProcessors,
@ -621,7 +621,7 @@ void ensightFieldAscii
writeAllData("nfaced", vf, polys, meshCellSets.nPolys, ensightFile);
}
label ensightPatchi = 2;
label ensightPatchI = eMesh.patchPartOffset();
for
(
@ -637,23 +637,23 @@ void ensightFieldAscii
{
if (patchIndices.found(patchName))
{
label patchi = patchIndices.find(patchName)();
label patchI = patchIndices.find(patchName)();
if
(
writePatchField
(
vf.boundaryField()[patchi],
patchi,
ensightPatchi,
boundaryFaceSets[patchi],
vf.boundaryField()[patchI],
patchI,
ensightPatchI,
boundaryFaceSets[patchI],
nPatchPrims.find(patchName)(),
patchProcessors,
ensightFile
)
)
{
ensightPatchi++;
ensightPatchI++;
}
}
@ -667,7 +667,7 @@ void ensightFieldAscii
(
Field<Type>(),
-1,
ensightPatchi,
ensightPatchI,
nullFaceSet,
nPatchPrims.find(patchName)(),
patchProcessors,
@ -675,7 +675,7 @@ void ensightFieldAscii
)
)
{
ensightPatchi++;
ensightPatchI++;
}
}
}
@ -793,7 +793,7 @@ void ensightFieldBinary
writeAllDataBinary("nfaced", vf, polys, meshCellSets.nPolys, ensightFile);
}
label ensightPatchi = 2;
label ensightPatchI = eMesh.patchPartOffset();
for
(
@ -809,23 +809,23 @@ void ensightFieldBinary
{
if (patchIndices.found(patchName))
{
label patchi = patchIndices.find(patchName)();
label patchI = patchIndices.find(patchName)();
if
(
writePatchFieldBinary
(
vf.boundaryField()[patchi],
patchi,
ensightPatchi,
boundaryFaceSets[patchi],
vf.boundaryField()[patchI],
patchI,
ensightPatchI,
boundaryFaceSets[patchI],
nPatchPrims.find(patchName)(),
patchProcessors,
ensightFile
)
)
{
ensightPatchi++;
ensightPatchI++;
}
}
@ -839,7 +839,7 @@ void ensightFieldBinary
(
Field<Type>(),
-1,
ensightPatchi,
ensightPatchI,
nullFaceSet,
nPatchPrims.find(patchName)(),
patchProcessors,
@ -847,7 +847,7 @@ void ensightFieldBinary
)
)
{
ensightPatchi++;
ensightPatchI++;
}
}
}

View File

@ -89,8 +89,9 @@ Foam::ensightMesh::ensightMesh
const bool binary
)
:
binary_(binary),
mesh_(mesh),
binary_(binary),
patchPartOffset_(2),
meshCellSets_(mesh_.nCells()),
boundaryFaceSets_(mesh_.boundary().size()),
allPatchNames_(0),
@ -98,48 +99,6 @@ Foam::ensightMesh::ensightMesh
patchNames_(0),
nPatchPrims_(0)
{
forAll (mesh_.boundaryMesh(), patchi)
{
if
(
typeid(mesh_.boundaryMesh()[patchi])
!= typeid(processorPolyPatch)
)
{
if (!allPatchNames_.found(mesh_.boundaryMesh()[patchi].name()))
{
allPatchNames_.insert
(
mesh_.boundaryMesh()[patchi].name(),
labelList(1, Pstream::myProcNo())
);
patchIndices_.insert
(
mesh_.boundaryMesh()[patchi].name(),
patchi
);
}
}
}
combineReduce(allPatchNames_, concatPatchNames());
if (args.options().found("patches"))
{
wordList patchNameList(IStringStream(args.options()["patches"])());
if (patchNameList.empty())
{
patchNameList = allPatchNames_.toc();
}
forAll (patchNameList, i)
{
patchNames_.insert(patchNameList[i]);
}
}
const cellShapeList& cellShapes = mesh.cellShapes();
const cellModel& tet = *(cellModeller::lookup("tet"));
@ -148,51 +107,101 @@ Foam::ensightMesh::ensightMesh
const cellModel& wedge = *(cellModeller::lookup("wedge"));
const cellModel& hex = *(cellModeller::lookup("hex"));
labelList& tets = meshCellSets_.tets;
labelList& pyrs = meshCellSets_.pyrs;
labelList& prisms = meshCellSets_.prisms;
labelList& wedges = meshCellSets_.wedges;
labelList& hexes = meshCellSets_.hexes;
labelList& polys = meshCellSets_.polys;
// Count the shapes
label nTets = 0;
label nPyrs = 0;
label nPrisms = 0;
label nWedges = 0;
label nHexes = 0;
label nPolys = 0;
if (patchNames_.empty())
if (!args.options().found("noPatches"))
{
forAll(cellShapes, celli)
forAll (mesh_.boundaryMesh(), patchI)
{
const cellShape& cellShape = cellShapes[celli];
if
(
typeid(mesh_.boundaryMesh()[patchI])
!= typeid(processorPolyPatch)
)
{
if (!allPatchNames_.found(mesh_.boundaryMesh()[patchI].name()))
{
allPatchNames_.insert
(
mesh_.boundaryMesh()[patchI].name(),
labelList(1, Pstream::myProcNo())
);
patchIndices_.insert
(
mesh_.boundaryMesh()[patchI].name(),
patchI
);
}
}
}
combineReduce(allPatchNames_, concatPatchNames());
if (args.options().found("patches"))
{
wordList patchNameList(IStringStream(args.options()["patches"])());
if (patchNameList.empty())
{
patchNameList = allPatchNames_.toc();
}
forAll (patchNameList, i)
{
patchNames_.insert(patchNameList[i]);
}
}
}
if (patchNames_.size())
{
// no internalMesh
patchPartOffset_ = 1;
}
else
{
// Count the shapes
labelList& tets = meshCellSets_.tets;
labelList& pyrs = meshCellSets_.pyrs;
labelList& prisms = meshCellSets_.prisms;
labelList& wedges = meshCellSets_.wedges;
labelList& hexes = meshCellSets_.hexes;
labelList& polys = meshCellSets_.polys;
label nTets = 0;
label nPyrs = 0;
label nPrisms = 0;
label nWedges = 0;
label nHexes = 0;
label nPolys = 0;
forAll(cellShapes, cellI)
{
const cellShape& cellShape = cellShapes[cellI];
const cellModel& cellModel = cellShape.model();
if (cellModel == tet)
{
tets[nTets++] = celli;
tets[nTets++] = cellI;
}
else if (cellModel == pyr)
{
pyrs[nPyrs++] = celli;
pyrs[nPyrs++] = cellI;
}
else if (cellModel == prism)
{
prisms[nPrisms++] = celli;
prisms[nPrisms++] = cellI;
}
else if (cellModel == wedge)
{
wedges[nWedges++] = celli;
wedges[nWedges++] = cellI;
}
else if (cellModel == hex)
{
hexes[nHexes++] = celli;
hexes[nHexes++] = cellI;
}
else
{
polys[nPolys++] = celli;
polys[nPolys++] = cellI;
}
}
@ -219,49 +228,52 @@ Foam::ensightMesh::ensightMesh
reduce(meshCellSets_.nPolys, sumOp<label>());
}
forAll (mesh.boundary(), patchi)
if (!args.options().found("noPatches"))
{
if (mesh.boundary()[patchi].size())
forAll (mesh.boundary(), patchI)
{
const polyPatch& p = mesh.boundaryMesh()[patchi];
labelList& tris = boundaryFaceSets_[patchi].tris;
labelList& quads = boundaryFaceSets_[patchi].quads;
labelList& polys = boundaryFaceSets_[patchi].polys;
tris.setSize(p.size());
quads.setSize(p.size());
polys.setSize(p.size());
label nTris = 0;
label nQuads = 0;
label nPolys = 0;
forAll(p, facei)
if (mesh.boundary()[patchI].size())
{
const face& f = p[facei];
const polyPatch& p = mesh.boundaryMesh()[patchI];
if (f.size() == 3)
labelList& tris = boundaryFaceSets_[patchI].tris;
labelList& quads = boundaryFaceSets_[patchI].quads;
labelList& polys = boundaryFaceSets_[patchI].polys;
tris.setSize(p.size());
quads.setSize(p.size());
polys.setSize(p.size());
label nTris = 0;
label nQuads = 0;
label nPolys = 0;
forAll(p, faceI)
{
tris[nTris++] = facei;
}
else if (f.size() == 4)
{
quads[nQuads++] = facei;
}
else
{
polys[nPolys++] = facei;
const face& f = p[faceI];
if (f.size() == 3)
{
tris[nTris++] = faceI;
}
else if (f.size() == 4)
{
quads[nQuads++] = faceI;
}
else
{
polys[nPolys++] = faceI;
}
}
tris.setSize(nTris);
quads.setSize(nQuads);
polys.setSize(nPolys);
}
tris.setSize(nTris);
quads.setSize(nQuads);
polys.setSize(nPolys);
}
}
forAllConstIter(HashTable<labelList>, allPatchNames_, iter)
{
const word& patchName = iter.key();
@ -271,12 +283,12 @@ Foam::ensightMesh::ensightMesh
{
if (patchIndices_.found(patchName))
{
label patchi = patchIndices_.find(patchName)();
label patchI = patchIndices_.find(patchName)();
nfp.nPoints = mesh.boundaryMesh()[patchi].localPoints().size();
nfp.nTris = boundaryFaceSets_[patchi].tris.size();
nfp.nQuads = boundaryFaceSets_[patchi].quads.size();
nfp.nPolys = boundaryFaceSets_[patchi].polys.size();
nfp.nPoints = mesh.boundaryMesh()[patchI].localPoints().size();
nfp.nTris = boundaryFaceSets_[patchI].tris.size();
nfp.nQuads = boundaryFaceSets_[patchI].quads.size();
nfp.nPolys = boundaryFaceSets_[patchI].polys.size();
}
}
@ -304,9 +316,9 @@ void Foam::ensightMesh::writePoints
OFstream& ensightGeometryFile
) const
{
forAll(pointsComponent, pointi)
forAll(pointsComponent, pointI)
{
ensightGeometryFile<< setw(12) << float(pointsComponent[pointi]) << nl;
ensightGeometryFile<< setw(12) << float(pointsComponent[pointI]) << nl;
}
}
@ -380,9 +392,9 @@ void Foam::ensightMesh::writePrims
{
const cellShape& cellPoints = cellShapes[i];
forAll(cellPoints, pointi)
forAll(cellPoints, pointI)
{
ensightGeometryFile<< setw(10) << cellPoints[pointi] + po;
ensightGeometryFile<< setw(10) << cellPoints[pointI] + po;
}
ensightGeometryFile << nl;
}
@ -415,9 +427,9 @@ void Foam::ensightMesh::writePrimsBinary
{
const cellShape& cellPoints = cellShapes[i];
forAll(cellPoints, pointi)
forAll(cellPoints, pointI)
{
temp[n] = cellPoints[pointi] + po;
temp[n] = cellPoints[pointI] + po;
n++;
}
}
@ -457,10 +469,10 @@ void Foam::ensightMesh::writePolys
{
const labelList& cf = cellFaces[polys[i]];
forAll(cf, facei)
forAll(cf, faceI)
{
ensightGeometryFile
<< setw(10) << faces[cf[facei]].size() << nl;
<< setw(10) << faces[cf[faceI]].size() << nl;
}
}
@ -468,13 +480,13 @@ void Foam::ensightMesh::writePolys
{
const labelList& cf = cellFaces[polys[i]];
forAll(cf, facei)
forAll(cf, faceI)
{
const face& f = faces[cf[facei]];
const face& f = faces[cf[faceI]];
forAll(f, pointi)
forAll(f, pointI)
{
ensightGeometryFile << setw(10) << f[pointi] + po;
ensightGeometryFile << setw(10) << f[pointI] + po;
}
ensightGeometryFile << nl;
}
@ -513,11 +525,11 @@ void Foam::ensightMesh::writePolysBinary
{
const labelList& cf = cellFaces[polys[i]];
forAll(cf, facei)
forAll(cf, faceI)
{
writeEnsDataBinary
(
faces[cf[facei]].size(),
faces[cf[faceI]].size(),
ensightGeometryFile
);
}
@ -527,13 +539,13 @@ void Foam::ensightMesh::writePolysBinary
{
const labelList& cf = cellFaces[polys[i]];
forAll(cf, facei)
forAll(cf, faceI)
{
const face& f = faces[cf[facei]];
const face& f = faces[cf[faceI]];
forAll(f, pointi)
forAll(f, pointI)
{
writeEnsDataBinary(f[pointi] + po,ensightGeometryFile);
writeEnsDataBinary(f[pointI] + po,ensightGeometryFile);
}
}
}
@ -648,9 +660,9 @@ void Foam::ensightMesh::writeFacePrims
{
const face& patchFace = patchFaces[i];
forAll(patchFace, pointi)
forAll(patchFace, pointI)
{
ensightGeometryFile << setw(10) << patchFace[pointi] + po;
ensightGeometryFile << setw(10) << patchFace[pointI] + po;
}
ensightGeometryFile << nl;
}
@ -690,11 +702,11 @@ void Foam::ensightMesh::writeFacePrimsBinary
{
const face& patchFace = patchFaces[i];
forAll(patchFace, pointi)
forAll(patchFace, pointI)
{
writeEnsDataBinary
(
patchFace[pointi] + po,
patchFace[pointI] + po,
ensightGeometryFile
);
}
@ -892,7 +904,7 @@ void Foam::ensightMesh::writeAscii
postProcPath/ensightGeometryFileName,
runTime.writeFormat(),
runTime.writeVersion(),
runTime.writeCompression()
IOstream::UNCOMPRESSED
);
}
@ -909,8 +921,8 @@ void Foam::ensightMesh::writeAscii
ensightGeometryFile.precision(5);
ensightGeometryFile
<< "OpenFOAM Geometry File " << nl
<< "OpenFOAM version " << Foam::FOAMversion << nl
<< "EnSight Geometry File" << nl
<< "written from OpenFOAM-" << Foam::FOAMversion << nl
<< "node id assign" << nl
<< "element id assign" << nl;
}
@ -927,7 +939,7 @@ void Foam::ensightMesh::writeAscii
ensightGeometryFile
<< "part" << nl
<< setw(10) << 1 << nl
<< "FOAM cells" << nl
<< "internalMesh" << nl
<< "coordinates" << nl
<< setw(10) << nPoints
<< endl;
@ -1038,7 +1050,7 @@ void Foam::ensightMesh::writeAscii
}
label ensightPatchi = 2;
label ensightPatchI = patchPartOffset_;
forAllConstIter(HashTable<labelList>, allPatchNames_, iter)
{
@ -1049,7 +1061,7 @@ void Foam::ensightMesh::writeAscii
const word& patchName = iter.key();
const nFacePrimitives& nfp = nPatchPrims_.find(patchName)();
const labelList *trisPtr = NULL;
const labelList *trisPtr = NULL;
const labelList *quadsPtr = NULL;
const labelList *polysPtr = NULL;
@ -1058,15 +1070,15 @@ void Foam::ensightMesh::writeAscii
if (patchIndices_.found(iter.key()))
{
label patchi = patchIndices_.find(iter.key())();
const polyPatch& p = mesh_.boundaryMesh()[patchi];
label patchI = patchIndices_.find(iter.key())();
const polyPatch& p = mesh_.boundaryMesh()[patchI];
trisPtr = &boundaryFaceSets_[patchi].tris;
quadsPtr = &boundaryFaceSets_[patchi].quads;
polysPtr = &boundaryFaceSets_[patchi].polys;
trisPtr = &boundaryFaceSets_[patchI].tris;
quadsPtr = &boundaryFaceSets_[patchI].quads;
polysPtr = &boundaryFaceSets_[patchI].polys;
patchPointsPtr = &(p.localPoints());
patchFacesPtr = &(p.localFaces());
patchFacesPtr = &(p.localFaces());
}
const labelList& tris = *trisPtr;
@ -1083,7 +1095,7 @@ void Foam::ensightMesh::writeAscii
{
ensightGeometryFile
<< "part" << nl
<< setw(10) << ensightPatchi++ << nl
<< setw(10) << ensightPatchI++ << nl
<< patchName << nl
<< "coordinates" << nl
<< setw(10) << nfp.nPoints
@ -1235,11 +1247,11 @@ void Foam::ensightMesh::writeBinary
if (Pstream::master())
{
writeEnsDataBinary("C binary",ensightGeometryFile);
writeEnsDataBinary("OpenFOAM Geometry File",ensightGeometryFile);
writeEnsDataBinary("Binary format",ensightGeometryFile);
writeEnsDataBinary("node id assign",ensightGeometryFile);
writeEnsDataBinary("element id assign",ensightGeometryFile);
writeEnsDataBinary("C binary", ensightGeometryFile);
writeEnsDataBinary("EnSight Geometry File", ensightGeometryFile);
writeEnsDataBinary("written from OpenFOAM", ensightGeometryFile);
writeEnsDataBinary("node id assign", ensightGeometryFile);
writeEnsDataBinary("element id assign", ensightGeometryFile);
}
labelList pointOffsets(Pstream::nProcs(), 0);
@ -1364,8 +1376,7 @@ void Foam::ensightMesh::writeBinary
}
label ensightPatchi = 2;
label ensightPatchI = patchPartOffset_;
label iCount = 0;
forAllConstIter(HashTable<labelList>, allPatchNames_, iter)
@ -1387,12 +1398,12 @@ void Foam::ensightMesh::writeBinary
if (patchIndices_.found(iter.key()))
{
label patchi = patchIndices_.find(iter.key())();
const polyPatch& p = mesh_.boundaryMesh()[patchi];
label patchI = patchIndices_.find(iter.key())();
const polyPatch& p = mesh_.boundaryMesh()[patchI];
trisPtr = &boundaryFaceSets_[patchi].tris;
quadsPtr = &boundaryFaceSets_[patchi].quads;
polysPtr = &boundaryFaceSets_[patchi].polys;
trisPtr = &boundaryFaceSets_[patchI].tris;
quadsPtr = &boundaryFaceSets_[patchI].quads;
polysPtr = &boundaryFaceSets_[patchI].polys;
patchPointsPtr = &(p.localPoints());
patchFacesPtr = &(p.localFaces());
@ -1411,7 +1422,7 @@ void Foam::ensightMesh::writeBinary
if (Pstream::master())
{
writeEnsDataBinary("part",ensightGeometryFile);
writeEnsDataBinary(ensightPatchi++,ensightGeometryFile);
writeEnsDataBinary(ensightPatchI++,ensightGeometryFile);
//writeEnsDataBinary(patchName.c_str(),ensightGeometryFile);
writeEnsDataBinary(iter.key().c_str(),ensightGeometryFile);
writeEnsDataBinary("coordinates",ensightGeometryFile);

View File

@ -78,11 +78,14 @@ class ensightMesh
// Private data
//- Reference to the OpenFOAM mesh
const fvMesh& mesh_;
//- Set binary file output
bool binary_;
//- Reference to the OpenFOAM mesh
const fvMesh& mesh_;
//- The ensight part id for the first patch
label patchPartOffset_;
cellSets meshCellSets_;
@ -286,6 +289,12 @@ public:
return nPatchPrims_;
}
//- The ensight part id for the first patch
label patchPartOffset() const
{
return patchPartOffset_;
}
// I-O

View File

@ -23,7 +23,9 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Translates FOAM data to EnSight format
Translates FOAM data to EnSight format.
An Ensight part is created for the internalMesh and for each patch.
Usage
- foamToEnsight [OPTION] \n
@ -32,8 +34,16 @@ Usage
@param -ascii \n
Write Ensight data in ASCII format instead of "C Binary"
@param -patches patchList \n
Specify particular patches to write.
Specifying an empty list suppresses writing the internalMesh.
@param -noPatches \n
Suppress writing any patches.
Note
Parallel support for cloud data is not supported
- writes to @a EnSight directory to avoid collisions with foamToEnsightParts
\*---------------------------------------------------------------------------*/
@ -82,10 +92,11 @@ bool inFileNameList
int main(int argc, char *argv[])
{
argList::validOptions.insert("patches", "patch list");
argList::validOptions.insert("ascii", "" );
# include "addTimeOptions.H"
argList::validOptions.insert("patches", "patchList");
argList::validOptions.insert("noPatches", "");
# include "addTimeOptions.H"
# include "setRootCase.H"
// Check options
@ -114,29 +125,28 @@ int main(int argc, char *argv[])
regionPrefix = regionName;
}
const label nTypes = 2;
const word fieldTypes[] =
const label nVolFieldTypes = 5;
const word volFieldTypes[] =
{
volScalarField::typeName,
volVectorField::typeName
volVectorField::typeName,
volSphericalTensorField::typeName,
volSymmTensorField::typeName,
volTensorField::typeName
};
// Create the output folder
const word postProcDir = "EnSight";
// Path to EnSight folder at case level only
// - For parallel cases, data only written from master
// fileName postProcPath = runTime.path()/postProcDir;
fileName postProcPath = args.rootPath()/args.globalCaseName()/postProcDir;
fileName ensightDir = args.rootPath()/args.globalCaseName()/"EnSight";
if (Pstream::master())
{
if (isDir(postProcPath))
if (isDir(ensightDir))
{
rmDir(postProcPath);
rmDir(ensightDir);
}
mkDir(postProcPath);
mkDir(ensightDir);
}
// Start of case file header output
@ -147,36 +157,23 @@ int main(int argc, char *argv[])
OFstream *ensightCaseFilePtr = NULL;
if (Pstream::master())
{
fileName ensightCaseFileName = prepend + "case";
fileName caseFileName = prepend + "case";
Info<< nl << "write case: " << caseFileName.c_str() << endl;
if (!binary)
{
ensightCaseFilePtr = new OFstream
(
postProcPath/ensightCaseFileName,
runTime.writeFormat(),
runTime.writeVersion(),
runTime.writeCompression()
);
}
else
{
ensightCaseFilePtr = new OFstream
(
postProcPath/ensightCaseFileName,
runTime.writeFormat(),
runTime.writeVersion(),
IOstream::UNCOMPRESSED
);
}
// the case file is always ASCII
ensightCaseFilePtr = new OFstream
(
ensightDir/caseFileName,
IOstream::ASCII
);
Info<< nl << "Case file is " << ensightCaseFileName << endl;
*ensightCaseFilePtr
<< "FORMAT" << nl
<< "type: ensight gold" << nl << nl;
}
OFstream& ensightCaseFile = *ensightCaseFilePtr;
# include "ensightCaseHeader.H"
// Construct the EnSight mesh
ensightMesh eMesh(mesh, args, binary);
@ -188,19 +185,20 @@ int main(int argc, char *argv[])
# include "checkMeshMoving.H"
wordHashSet allCloudNames;
word geomCaseFileName = prepend + "000";
if (Pstream::master())
{
word geomFileName = prepend + "000";
// test pre check variable if there is a moving mesh
if (meshMoving == true)
if (meshMoving)
{
geomCaseFileName = prepend + "***";
geomFileName = prepend + "***";
}
ensightCaseFile
<< "GEOMETRY" << nl
<< "model: 1 "
<< (geomCaseFileName + ".mesh").c_str() << nl;
<< (geomFileName + ".mesh").c_str() << nl;
}
// Identify if lagrangian data exists at each time, and add clouds
@ -304,7 +302,7 @@ int main(int argc, char *argv[])
{
eMesh.write
(
postProcPath,
ensightDir,
prepend,
timeIndex,
ensightCaseFile
@ -324,94 +322,94 @@ int main(int argc, char *argv[])
// Cell field data output
// ~~~~~~~~~~~~~~~~~~~~~~
for (label i=0; i<nTypes; i++)
for (label i=0; i<nVolFieldTypes; i++)
{
wordList fieldNames = objects.names(fieldTypes[i]);
wordList fieldNames = objects.names(volFieldTypes[i]);
for (label j=0; j<fieldNames.size(); j++)
{
word fieldName = fieldNames[j];
bool variableGood = true;
# include "checkData.H"
if (variableGood)
if (!variableGood)
{
IOobject fieldObject
(
fieldName,
mesh.time().timeName(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
);
continue;
}
if (fieldTypes[i] == volScalarField::typeName)
{
ensightField<scalar>
(
fieldObject,
eMesh,
postProcPath,
prepend,
timeIndex,
binary,
ensightCaseFile
);
}
else if (fieldTypes[i] == volVectorField::typeName)
{
ensightField<vector>
(
fieldObject,
eMesh,
postProcPath,
prepend,
timeIndex,
binary,
ensightCaseFile
);
}
else if (fieldTypes[i] == volSphericalTensorField::typeName)
{
ensightField<sphericalTensor>
(
fieldObject,
eMesh,
postProcPath,
prepend,
timeIndex,
binary,
ensightCaseFile
);
}
else if (fieldTypes[i] == volSymmTensorField::typeName)
{
ensightField<symmTensor>
(
fieldObject,
eMesh,
postProcPath,
prepend,
timeIndex,
binary,
ensightCaseFile
);
}
else if (fieldTypes[i] == volTensorField::typeName)
{
ensightField<tensor>
(
fieldObject,
eMesh,
postProcPath,
prepend,
timeIndex,
binary,
ensightCaseFile
);
}
IOobject fieldObject
(
fieldName,
mesh.time().timeName(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
);
if (volFieldTypes[i] == volScalarField::typeName)
{
ensightField<scalar>
(
fieldObject,
eMesh,
ensightDir,
prepend,
timeIndex,
binary,
ensightCaseFile
);
}
else if (volFieldTypes[i] == volVectorField::typeName)
{
ensightField<vector>
(
fieldObject,
eMesh,
ensightDir,
prepend,
timeIndex,
binary,
ensightCaseFile
);
}
else if (volFieldTypes[i] == volSphericalTensorField::typeName)
{
ensightField<sphericalTensor>
(
fieldObject,
eMesh,
ensightDir,
prepend,
timeIndex,
binary,
ensightCaseFile
);
}
else if (volFieldTypes[i] == volSymmTensorField::typeName)
{
ensightField<symmTensor>
(
fieldObject,
eMesh,
ensightDir,
prepend,
timeIndex,
binary,
ensightCaseFile
);
}
else if (volFieldTypes[i] == volTensorField::typeName)
{
ensightField<tensor>
(
fieldObject,
eMesh,
ensightDir,
prepend,
timeIndex,
binary,
ensightCaseFile
);
}
}
}
@ -434,7 +432,7 @@ int main(int argc, char *argv[])
ensightParticlePositions
(
mesh,
postProcPath,
ensightDir,
timeFile,
cloudName,
cloudExists
@ -460,7 +458,7 @@ int main(int argc, char *argv[])
ensightCloudField<scalar>
(
fieldObject,
postProcPath,
ensightDir,
prepend,
timeIndex,
cloudName,
@ -473,7 +471,7 @@ int main(int argc, char *argv[])
ensightCloudField<vector>
(
fieldObject,
postProcPath,
ensightDir,
prepend,
timeIndex,
cloudName,