diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/checkData.H b/applications/utilities/postProcessing/dataConversion/foamToEnsight/checkData.H index 59be3c5dc9ffda60e2ceaae872a7054b797b68f3..1144833a0136070251c67aec0d4f5ca2eec118f2 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/checkData.H +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/checkData.H @@ -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(); + } } diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/checkMeshMoving.H b/applications/utilities/postProcessing/dataConversion/foamToEnsight/checkMeshMoving.H index e6e46c8f868adf8e382f53d6c36228051f44fcf0..123036f63afe9d1a30c205fce0efc311125d6785 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/checkMeshMoving.H +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/checkMeshMoving.H @@ -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 { diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightCaseHeader.H b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightCaseHeader.H deleted file mode 100644 index cc81cb465952ed52026b274d56375de627f45134..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightCaseHeader.H +++ /dev/null @@ -1,5 +0,0 @@ -if (Pstream::master()) -{ - ensightCaseFile << "FORMAT" << nl; - ensightCaseFile << "type: ensight gold" << nl << nl; -} diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightField.C b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightField.C index 980a3c61536eb12601d6b541c187409108722878..64452a05f70c00bffbfc7ab792e545a4cda369a7 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightField.C +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightField.C @@ -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++; } } } diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.C b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.C index b69a9264c124845c74669733762e95e45592660c..94f8c19c3fed065d2b0abcc3bd6ad5953d1b5d2d 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.C +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.C @@ -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,101 +99,109 @@ Foam::ensightMesh::ensightMesh patchNames_(0), nPatchPrims_(0) { - forAll (mesh_.boundaryMesh(), patchi) + const cellShapeList& cellShapes = mesh.cellShapes(); + + const cellModel& tet = *(cellModeller::lookup("tet")); + const cellModel& pyr = *(cellModeller::lookup("pyr")); + const cellModel& prism = *(cellModeller::lookup("prism")); + const cellModel& wedge = *(cellModeller::lookup("wedge")); + const cellModel& hex = *(cellModeller::lookup("hex")); + + if (!args.options().found("noPatches")) { - if - ( - typeid(mesh_.boundaryMesh()[patchi]) - != typeid(processorPolyPatch) - ) + forAll (mesh_.boundaryMesh(), patchI) { - if (!allPatchNames_.found(mesh_.boundaryMesh()[patchi].name())) + if + ( + typeid(mesh_.boundaryMesh()[patchI]) + != typeid(processorPolyPatch) + ) { - allPatchNames_.insert - ( - mesh_.boundaryMesh()[patchi].name(), - labelList(1, Pstream::myProcNo()) - ); + if (!allPatchNames_.found(mesh_.boundaryMesh()[patchI].name())) + { + allPatchNames_.insert + ( + mesh_.boundaryMesh()[patchI].name(), + labelList(1, Pstream::myProcNo()) + ); - patchIndices_.insert - ( - mesh_.boundaryMesh()[patchi].name(), - patchi - ); + patchIndices_.insert + ( + mesh_.boundaryMesh()[patchI].name(), + patchI + ); + } } } - } - combineReduce(allPatchNames_, concatPatchNames()); - - if (args.options().found("patches")) - { - wordList patchNameList(IStringStream(args.options()["patches"])()); + combineReduce(allPatchNames_, concatPatchNames()); - if (patchNameList.empty()) + if (args.options().found("patches")) { - patchNameList = allPatchNames_.toc(); - } + wordList patchNameList(IStringStream(args.options()["patches"])()); - forAll (patchNameList, i) - { - patchNames_.insert(patchNameList[i]); + if (patchNameList.empty()) + { + patchNameList = allPatchNames_.toc(); + } + + forAll (patchNameList, i) + { + patchNames_.insert(patchNameList[i]); + } } } - const cellShapeList& cellShapes = mesh.cellShapes(); - - const cellModel& tet = *(cellModeller::lookup("tet")); - const cellModel& pyr = *(cellModeller::lookup("pyr")); - const cellModel& prism = *(cellModeller::lookup("prism")); - 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 (patchNames_.size()) { - forAll(cellShapes, celli) + // 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 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; + if (mesh.boundary()[patchI].size()) + { + const polyPatch& p = mesh.boundaryMesh()[patchI]; - tris.setSize(p.size()); - quads.setSize(p.size()); - polys.setSize(p.size()); + labelList& tris = boundaryFaceSets_[patchI].tris; + labelList& quads = boundaryFaceSets_[patchI].quads; + labelList& polys = boundaryFaceSets_[patchI].polys; - label nTris = 0; - label nQuads = 0; - label nPolys = 0; + tris.setSize(p.size()); + quads.setSize(p.size()); + polys.setSize(p.size()); - forAll(p, facei) - { - const face& f = p[facei]; + label nTris = 0; + label nQuads = 0; + label nPolys = 0; - if (f.size() == 3) + 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); diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.H b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.H index fff8b797ab6fb4c139801ff59ec154f0c010b591..6a3cb824708bb7a3e7543f327acc69fc2c918379 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.H +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.H @@ -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 diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/foamToEnsight.C b/applications/utilities/postProcessing/dataConversion/foamToEnsight/foamToEnsight.C index 10d261bca5e508e59f19f4535f83eb2f2cb438de..5dc6af99f31d89f7a41d7f45ad6d25d77b0da949 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/foamToEnsight.C +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/foamToEnsight.C @@ -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 + continue; + } + + IOobject fieldObject + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ); + + if (volFieldTypes[i] == volScalarField::typeName) + { + ensightField<scalar> ( - fieldName, - mesh.time().timeName(), - mesh, - IOobject::MUST_READ, - IOobject::NO_WRITE + 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 ); - - 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 - ); - } } } } @@ -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, diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/checkHasMovingMesh.H b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/checkHasMovingMesh.H index a9367daf8eb9870b055ecb1f5a2025eb39d3cee5..a5a2dd7d2d8d9e1b05c1c629fb4c6aa3935ed918 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/checkHasMovingMesh.H +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/checkHasMovingMesh.H @@ -6,15 +6,13 @@ if (timeDirs.size() > 1) hasMovingMesh = true; for (label i=0; i < timeDirs.size() && hasMovingMesh; ++i) { - IOobject io + hasMovingMesh = IOobject ( "points", timeDirs[i].name(), polyMesh::meshSubDir, mesh, IOobject::NO_READ - ); - - hasMovingMesh = io.headerOk(); + ).headerOk(); } } diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/findFields.H b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/findFields.H index edfbb5ae7d9b483fad7e7d7eb876ace2914750a2..63ef5eef21d7baee8c01bc8683fc29c16516cd4c 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/findFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/findFields.H @@ -1,40 +1,40 @@ -// check the final time directory for +// check the final time directory for the following: // 1. volume fields HashTable<word> volumeFields; // 2. the fields for each cloud: -HashTable<HashTable<word> > cloudFields; +HashTable< HashTable<word> > cloudFields; -if (timeDirs.size() > 1) +if (timeDirs.size()) { IOobjectList objs(mesh, timeDirs[timeDirs.size()-1].name()); forAllConstIter(IOobjectList, objs, fieldIter) { const IOobject& obj = *fieldIter(); + const word& fieldName = obj.name(); + const word& fieldType = obj.headerClassName(); - if - ( - obj.headerClassName() == volScalarField::typeName - || obj.headerClassName() == volVectorField::typeName - ) + if (fieldName.size() > 2 && fieldName(fieldName.size()-2, 2) == "_0") + { + // ignore _0 fields + } + else if (volFieldTypes.found(fieldType)) { - // Add field and field type - volumeFields.insert - ( - obj.name(), - obj.headerClassName() - ); + // simply ignore types that we don't handle + volumeFields.insert(fieldName, fieldType); } } - // now check for lagrangian/<cloudName> + // + // now check for lagrangian/<cloudName> + // fileNameList cloudDirs = readDir ( runTime.path() - / timeDirs[timeDirs.size() - 1].name() + / timeDirs[timeDirs.size()-1].name() / regionPrefix / cloud::prefix, fileName::DIRECTORY @@ -47,42 +47,59 @@ if (timeDirs.size() > 1) // Create a new hash table for each cloud cloudFields.insert(cloudName, HashTable<word>()); - // Identify the new cloud in the hash table + // Identify the new cloud within the hash table HashTable<HashTable<word> >::iterator cloudIter = cloudFields.find(cloudName); - IOobjectList cloudObjs + IOobjectList objs ( mesh, - timeDirs[timeDirs.size() - 1].name(), + timeDirs[timeDirs.size()-1].name(), cloud::prefix/cloudName ); bool hasPositions = false; - forAllConstIter(IOobjectList, cloudObjs, fieldIter) + forAllConstIter(IOobjectList, objs, fieldIter) { const IOobject obj = *fieldIter(); + const word& fieldName = obj.name(); + const word& fieldType = obj.headerClassName(); - if (obj.name() == "positions") + if (fieldName == "positions") { hasPositions = true; } - else + else if (cloudFieldTypes.found(fieldType)) { - // Add field and field type - cloudIter().insert - ( - obj.name(), - obj.headerClassName() - ); + // simply ignore types that we don't handle + cloudIter().insert(fieldName, fieldType); } } - // drop this cloud if it has no positions - if (!hasPositions) + // drop this cloud if it has no positions or is otherwise empty + if (!hasPositions || cloudIter().empty()) { + Info<< "removing cloud " << cloudName << endl; cloudFields.erase(cloudIter); } } + + // + // verify that the variable is present for all times + // + for (label i=0; volumeFields.size() && i < timeDirs.size(); ++i) + { + IOobjectList objs(mesh, timeDirs[i].name()); + + forAllIter(HashTable<word>, volumeFields, fieldIter) + { + const word& fieldName = fieldIter.key(); + + if (!objs.found(fieldName)) + { + volumeFields.erase(fieldIter); + } + } + } } diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/foamToEnsightParts.C b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/foamToEnsightParts.C index af2dee175a9351de1d961dc4b37d5061cc2858be..651224d17ce932249d74aa279103f46f3bab6364 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/foamToEnsightParts.C +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/foamToEnsightParts.C @@ -83,23 +83,19 @@ int main(int argc, char *argv[]) argList::validOptions.insert("index", "start"); argList::validOptions.insert("noMesh", ""); - const word volFieldTypes[] = - { - volScalarField::typeName, - volVectorField::typeName, - volSphericalTensorField::typeName, - volSymmTensorField::typeName, - volTensorField::typeName, - word::null - }; - - const word sprayFieldTypes[] = - { - scalarIOField::typeName, - vectorIOField::typeName, - tensorIOField::typeName, - word::null - }; + // the volume field types that we handle + wordHashSet volFieldTypes; + volFieldTypes.insert(volScalarField::typeName); + volFieldTypes.insert(volVectorField::typeName); + volFieldTypes.insert(volSphericalTensorField::typeName); + volFieldTypes.insert(volSymmTensorField::typeName); + volFieldTypes.insert(volTensorField::typeName); + + // the lagrangian field types that we handle + wordHashSet cloudFieldTypes; + cloudFieldTypes.insert(scalarIOField::typeName); + cloudFieldTypes.insert(vectorIOField::typeName); + cloudFieldTypes.insert(tensorIOField::typeName); const char* geometryName = "geometry"; @@ -168,7 +164,6 @@ int main(int argc, char *argv[]) # include "checkHasMovingMesh.H" # include "findFields.H" -# include "validateFields.H" if (hasMovingMesh && optNoMesh) { diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/moveMesh.H b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/moveMesh.H index 546148c7cf2ed907b9ea3b1fcc11a50a9339ce17..284a0df35bba33901eda224f1dffe7eeb3954f96 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/moveMesh.H +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/moveMesh.H @@ -11,8 +11,6 @@ { // Read new points io.readOpt() = IOobject::MUST_READ; - pointIOField newPoints(io); - - mesh.movePoints(newPoints); + mesh.movePoints(pointIOField(io)); } } diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/validateFields.H b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/validateFields.H deleted file mode 100644 index 6c640b41fa57efee651b694891cf819d460caeac..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/validateFields.H +++ /dev/null @@ -1,105 +0,0 @@ -// ignore special fields or fields that we don't handle -// -forAllIter(HashTable<word>, volumeFields, fieldIter) -{ - const word& fieldName = fieldIter.key(); - const word& fieldType = fieldIter(); - - // ignore _0 fields - if (fieldName.size() > 2 && fieldName(fieldName.size() - 2, 2) == "_0") - { - volumeFields.erase(fieldIter); - } - else - { - // remove types that we don't handle: - bool invalid = true; - for (label typeI=0; invalid && volFieldTypes[typeI].size(); ++typeI) - { - if (fieldType == volFieldTypes[typeI]) - { - invalid = false; - } - } - - if (invalid) - { - Info<< "ignoring " << fieldType << ": " << fieldName << endl; - volumeFields.erase(fieldIter); - } - } -} - -// verify that the variable is present for all times -// -for (label i=0; volumeFields.size() && i < timeDirs.size(); ++i) -{ - IOobjectList objs(mesh, timeDirs[i].name()); - - forAllIter(HashTable<word>, volumeFields, fieldIter) - { - const word& fieldName = fieldIter.key(); - - if (!objs.found(fieldName)) - { - volumeFields.erase(fieldIter); - } - } -} - - - -// ignore fields that we don't handle -// -forAllIter(HashTable<HashTable<word> >, cloudFields, cloudIter) -{ - const word& cloudName = cloudIter.key(); - - forAllIter(HashTable<word>, cloudIter(), fieldIter) - { - const word& fieldName = fieldIter.key(); - const word& fieldType = fieldIter(); - - // remove types that we don't handle: - bool invalid = true; - for (label typeI=0; invalid && sprayFieldTypes[typeI].size(); ++typeI) - { - if (fieldType == sprayFieldTypes[typeI]) - { - invalid = false; - } - } - - if (invalid) - { - Info<< "ignoring " << fieldType << ": " << fieldName << endl; - cloudIter().erase(fieldIter); - } - } - - if (cloudIter().empty()) - { - Info<< "removing cloud " << cloudName << endl; - cloudFields.erase(cloudIter); - } -} - -// DEBUGGING -// Info<<"final fields ("; -// forAllConstIter(HashTable<word>, volumeFields, fieldIter) -// { -// Info<< " " << fieldIter.key(); -// } -// -// Info<< " )\n"; -// -// forAllConstIter(HashTable<HashTable<word> >, cloudFields, cloudIter) -// { -// Info<<"final fields for lagrangian/" << cloudIter.key() << " ("; -// forAllConstIter(HashTable<word>, cloudIter(), fieldIter) -// { -// Info<< " " << fieldIter.key(); -// } -// Info<< " )\n"; -// } -