From 72362de6b1c64917bede6e1b112a7362be516dcb Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 12 May 2009 12:37:25 +0200 Subject: [PATCH 01/10] 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 --- .../dataConversion/foamToEnsight/checkData.H | 27 +- .../foamToEnsight/checkMeshMoving.H | 26 +- .../foamToEnsight/ensightCaseHeader.H | 5 - .../foamToEnsight/ensightField.C | 66 ++-- .../foamToEnsight/ensightMesh.C | 317 +++++++++--------- .../foamToEnsight/ensightMesh.H | 13 +- .../foamToEnsight/foamToEnsight.C | 246 +++++++------- .../foamToEnsightParts/checkHasMovingMesh.H | 6 +- .../foamToEnsightParts/findFields.H | 77 +++-- .../foamToEnsightParts/foamToEnsightParts.C | 29 +- .../foamToEnsightParts/moveMesh.H | 4 +- .../foamToEnsightParts/validateFields.H | 105 ------ 12 files changed, 420 insertions(+), 501 deletions(-) delete mode 100644 applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightCaseHeader.H delete mode 100644 applications/utilities/postProcessing/dataConversion/foamToEnsightParts/validateFields.H diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/checkData.H b/applications/utilities/postProcessing/dataConversion/foamToEnsight/checkData.H index 59be3c5dc9..1144833a01 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 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 e6e46c8f86..123036f63a 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 bool writePatchField ( const Foam::Field& 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 bool writePatchFieldBinary ( const Foam::Field& 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& 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::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(), -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(), -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(), -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 b69a9264c1..94f8c19c3f 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,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