From 6ffd5a3358def57d4f8a9ee25df404b3e7610f89 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 5 Aug 2008 20:32:23 +0200 Subject: [PATCH 01/18] foamToEnsightParts updated - handle new cloud locations, got missed before the release - handle multiple clouds - more efficient checking of fields etc. - write case file at the end, thus we can potentially do something more intelligent about the time set handling --- .../foamToEnsightParts/checkHasLagrangian.H | 19 - .../foamToEnsightParts/checkHasSprayField.H | 15 - .../foamToEnsightParts/checkHasValidField.H | 23 - .../foamToEnsightParts/ensightCaseTimes.H | 91 ---- .../foamToEnsightParts/ensightOutputCase.H | 224 ++++++++ .../ensightOutputFunctions.C | 63 ++- .../ensightOutputFunctions.H | 16 +- .../foamToEnsightParts/findFields.H | 88 ++++ .../foamToEnsightParts/foamToEnsightParts.C | 485 +++++++----------- .../foamToEnsightParts/validateFields.H | 104 ++++ 10 files changed, 655 insertions(+), 473 deletions(-) delete mode 100644 applications/utilities/postProcessing/dataConversion/foamToEnsightParts/checkHasLagrangian.H delete mode 100644 applications/utilities/postProcessing/dataConversion/foamToEnsightParts/checkHasSprayField.H delete mode 100644 applications/utilities/postProcessing/dataConversion/foamToEnsightParts/checkHasValidField.H delete mode 100644 applications/utilities/postProcessing/dataConversion/foamToEnsightParts/ensightCaseTimes.H create mode 100644 applications/utilities/postProcessing/dataConversion/foamToEnsightParts/ensightOutputCase.H create mode 100644 applications/utilities/postProcessing/dataConversion/foamToEnsightParts/findFields.H create mode 100644 applications/utilities/postProcessing/dataConversion/foamToEnsightParts/validateFields.H diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/checkHasLagrangian.H b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/checkHasLagrangian.H deleted file mode 100644 index 18f9ddf805..0000000000 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/checkHasLagrangian.H +++ /dev/null @@ -1,19 +0,0 @@ -// check for lagrangian/positions information in the final directory - -bool hasLagrangian = false; -if (timeDirs.size() > 1) -{ - IOobject io - ( - "positions", - timeDirs[timeDirs.size() - 1].name(), - "lagrangian", - mesh, - IOobject::NO_READ - ); - - if (io.headerOk()) - { - hasLagrangian = true; - } -} diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/checkHasSprayField.H b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/checkHasSprayField.H deleted file mode 100644 index e6601f7191..0000000000 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/checkHasSprayField.H +++ /dev/null @@ -1,15 +0,0 @@ -// check that the spray variable is present for this time -// -bool hasSprayField = true; -{ - IOobject ioHeader - ( - fieldName, - mesh.time().timeName(), - "lagrangian", - mesh, - IOobject::NO_READ - ); - - hasSprayField = ioHeader.headerOk(); -} diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/checkHasValidField.H b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/checkHasValidField.H deleted file mode 100644 index 9973a7a5fb..0000000000 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/checkHasValidField.H +++ /dev/null @@ -1,23 +0,0 @@ -// check that the variable is present for all times -// -bool hasValidField = true; -{ - for (label i=0; i < timeDirs.size() && hasValidField; ++i) - { - if (fieldName.size() > 2 && fieldName(fieldName.size() - 2, 2) == "_0") - { - hasValidField = false; - break; - } - - IOobject ioHeader - ( - fieldName, - timeDirs[i].name(), - mesh, - IOobject::NO_READ - ); - - hasValidField = ioHeader.headerOk(); - } -} diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/ensightCaseTimes.H b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/ensightCaseTimes.H deleted file mode 100644 index ab7f4de531..0000000000 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/ensightCaseTimes.H +++ /dev/null @@ -1,91 +0,0 @@ -// write time values to case file -{ - scalar timeCorrection = 0; - if (timeDirs[0].value() < 0) - { - timeCorrection = - timeDirs[0].value(); - Info<< "Correcting time values. Adding " << timeCorrection << endl; - } - - caseFile.setf(ios_base::scientific, ios_base::floatfield); - caseFile.precision(5); - - // time set 1 - geometry and volume fields - if (fieldFileNumbers.size()) - { - caseFile - << "time set: " << 1 << nl - << "number of steps: " << fieldFileNumbers.size() << nl - << "filename numbers:" << nl; - - label count = 0; - forAll (fieldFileNumbers, i) - { - caseFile - << " " << setw(12) << fieldFileNumbers[i]; - - if (++count % 6 == 0) - { - caseFile << nl; - } - } - - caseFile - << nl << "time values:" << nl; - - count = 0; - forAll (fieldFileNumbers, i) - { - caseFile - << " " << setw(12) - << timeIndices[fieldFileNumbers[i]] + timeCorrection; - - if (++count % 6 == 0) - { - caseFile << nl; - } - } - caseFile << nl << nl; - } - - // time set 2 - lagrangian fields - if (hasLagrangian && sprayFileNumbers.size()) - { - caseFile - << "time set: " << 2 << nl - << "number of steps: " << sprayFileNumbers.size() << nl - << "filename numbers:" << nl; - - label count = 0; - forAll (sprayFileNumbers, i) - { - caseFile - << " " << setw(12) << sprayFileNumbers[i]; - - if (++count % 6 == 0) - { - caseFile << nl; - } - } - - caseFile - << nl << "time values:" << nl; - - count = 0; - forAll (sprayFileNumbers, i) - { - caseFile - << " " << setw(12) - << timeIndices[sprayFileNumbers[i]] + timeCorrection; - - if (++count % 6 == 0) - { - caseFile << nl; - } - } - caseFile << nl << nl; - } - - - caseFile << "# end" << nl; -} diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/ensightOutputCase.H b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/ensightOutputCase.H new file mode 100644 index 0000000000..d8f079ea6d --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/ensightOutputCase.H @@ -0,0 +1,224 @@ +// write time values to case file + +scalar timeCorrection = 0; +if (timeDirs[0].value() < 0) +{ + timeCorrection = - timeDirs[0].value(); + Info<< "Correcting time values. Adding " << timeCorrection << endl; +} + +// the case file is always ASCII +Info << "write case: " << caseFileName.c_str() << endl; + +OFstream caseFile(ensightDir/caseFileName, IOstream::ASCII); +caseFile.setf(ios_base::left); + +caseFile.setf(ios_base::scientific, ios_base::floatfield); +caseFile.precision(5); + +caseFile + << "FORMAT" << nl + << setw(16) << "type:" << "ensight gold" << nl << nl; + +if (hasMovingMesh) +{ + caseFile + << "GEOMETRY" << nl + << setw(16) << "model: 1" << (dataMask/geometryName).c_str() << nl; +} +else +{ + caseFile + << "GEOMETRY" << nl + << setw(16) << "model:" << geometryName << nl; +} + + +// add information for clouds +// multiple clouds currently require the same time index +forAllConstIter(HashTable >, cloudFields, cloudIter) +{ + const word& cloudName = cloudIter.key(); + + caseFile + << setw(16) << "measured: 2" + << fileName(dataMask/"lagrangian"/cloudName/"positions").c_str() + << nl; +} +caseFile + << nl << "VARIABLE" << nl; + +forAllConstIter(HashTable, volumeFields, fieldIter) +{ + const word& fieldName = fieldIter.key(); + const word& fieldType = fieldIter(); + string ensightType; + + if (fieldType == volScalarField::typeName) + { + ensightType = "scalar"; + } + else if (fieldType == volVectorField::typeName) + { + ensightType = "vector"; + } + else if (fieldType == volSphericalTensorField::typeName) + { + ensightType = "tensor symm"; + } + else if (fieldType == volSymmTensorField::typeName) + { + ensightType = "tensor symm"; + } + else if (fieldType == volTensorField::typeName) + { + ensightType = "tensor asym"; + } + + if (ensightType.size()) + { + ensightCaseEntry + ( + caseFile, + ensightType, + fieldName, + dataMask + ); + } +} + +// TODO: allow similar/different time-steps for each cloud + + +label cloudNo = 0; +forAllConstIter(HashTable >, cloudFields, cloudIter) +{ + const word& cloudName = cloudIter.key(); + + forAllConstIter(HashTable, cloudIter(), fieldIter) + { + const word& fieldName = fieldIter.key(); + const word& fieldType = fieldIter(); + string ensightType; + + if (fieldType == scalarIOField::typeName) + { + ensightType = "scalar"; + } + else if (fieldType == vectorIOField::typeName) + { + ensightType = "vector"; + } + else if (fieldType == tensorIOField::typeName) + { + ensightType = "tensor"; + } + + if (ensightType.size()) + { + ensightCaseEntry + ( + caseFile, + ensightType, + fieldName, + dataMask, + "lagrangian"/cloudName, + cloudNo, + 2 + ); + } + } + cloudNo++; +} + + +// add time values +caseFile << nl << "TIME" << nl; + +// time set 1 - geometry and volume fields +if (fieldTimesUsed.size()) +{ + caseFile + << "time set: " << 1 << nl + << "number of steps: " << fieldTimesUsed.size() << nl + << "filename numbers:" << nl; + + label count = 0; + forAll (fieldTimesUsed, i) + { + caseFile + << " " << setw(12) << fieldTimesUsed[i]; + + if (++count % 6 == 0) + { + caseFile << nl; + } + } + + caseFile + << nl << "time values:" << nl; + + count = 0; + forAll (fieldTimesUsed, i) + { + caseFile + << " " << setw(12) + << timeIndices[fieldTimesUsed[i]] + timeCorrection; + + if (++count % 6 == 0) + { + caseFile << nl; + } + } + caseFile << nl << nl; +} + +// TODO: allow similar/different time-steps for each cloud +cloudNo = 0; +forAllConstIter(HashTable >, cloudTimesUsed, cloudIter) +{ + // const word& cloudName = cloudIter.key(); + const DynamicList