diff --git a/applications/utilities/errorEstimation/estimateScalarError/estimateScalarError.C b/applications/utilities/errorEstimation/estimateScalarError/estimateScalarError.C index c90594ff24ce90d46bb254e3ab40092437fb3054..9fb3a646d651fd9e49bda17cc88cb4217d295915 100644 --- a/applications/utilities/errorEstimation/estimateScalarError/estimateScalarError.C +++ b/applications/utilities/errorEstimation/estimateScalarError/estimateScalarError.C @@ -39,24 +39,17 @@ Description int main(int argc, char *argv[]) { + timeSelector::addOptions(); -# include "addTimeOptions.H" # include "setRootCase.H" - - Info<< "\nEstimating error in scalar transport equation\n" << endl; - # include "createTime.H" - // Get times list - instantList Times = runTime.times(); - -# include "checkTimeOptions.H" - - runTime.setTime(Times[startTime], startTime); + instantList timeDirs = timeSelector::select0(runTime, args); # include "createMesh.H" - Info<< "Reading transportProperties\n" << endl; + Info<< "\nEstimating error in scalar transport equation\n" + << "Reading transportProperties\n" << endl; IOdictionary transportProperties ( @@ -79,9 +72,9 @@ int main(int argc, char *argv[]) ); - for (label i=startTime; i<endTime; i++) + forAll(timeDirs, timeI) { - runTime.setTime(Times[i], i); + runTime.setTime(timeDirs[timeI], timeI); Info<< "Time = " << runTime.timeName() << endl; diff --git a/applications/utilities/errorEstimation/icoErrorEstimate/icoErrorEstimate.C b/applications/utilities/errorEstimation/icoErrorEstimate/icoErrorEstimate.C index 5ce860640d4ba212db7c55db684fd8ce2f0fccf1..c236b76eb4077d3ac58404f393fb49bc12c0f931 100644 --- a/applications/utilities/errorEstimation/icoErrorEstimate/icoErrorEstimate.C +++ b/applications/utilities/errorEstimation/icoErrorEstimate/icoErrorEstimate.C @@ -38,25 +38,17 @@ Description int main(int argc, char *argv[]) { + timeSelector::addOptions(); -# include "addTimeOptions.H" # include "setRootCase.H" - - Info<< "\nEstimating error in the incompressible momentum equation\n" - << endl; - # include "createTime.H" - // Get times list - instantList Times = runTime.times(); - -# include "checkTimeOptions.H" - - runTime.setTime(Times[startTime], startTime); + instantList timeDirs = timeSelector::select0(runTime, args); # include "createMesh.H" - Info<< "Reading transportProperties\n" << endl; + Info<< "\nEstimating error in the incompressible momentum equation\n" + << "Reading transportProperties\n" << endl; IOdictionary transportProperties ( @@ -75,9 +67,9 @@ int main(int argc, char *argv[]) transportProperties.lookup("nu") ); - for (label i=startTime; i<endTime; i++) + forAll(timeDirs, timeI) { - runTime.setTime(Times[i], i); + runTime.setTime(timeDirs[timeI], timeI); Info<< "Time = " << runTime.timeName() << endl; diff --git a/applications/utilities/errorEstimation/icoMomentError/icoMomentError.C b/applications/utilities/errorEstimation/icoMomentError/icoMomentError.C index 5810d64ca783a3f97f1c690ff648d025801f9cf5..67551e1eeccc631b48d02a815307f9f52e309748 100644 --- a/applications/utilities/errorEstimation/icoMomentError/icoMomentError.C +++ b/applications/utilities/errorEstimation/icoMomentError/icoMomentError.C @@ -39,25 +39,17 @@ Description int main(int argc, char *argv[]) { + timeSelector::addOptions(); -# include "addTimeOptions.H" # include "setRootCase.H" - - Info<< "\nEstimating error in the incompressible momentum equation\n" - << endl; - # include "createTime.H" - // Get times list - instantList Times = runTime.times(); - -# include "checkTimeOptions.H" - - runTime.setTime(Times[startTime], startTime); + instantList timeDirs = timeSelector::select0(runTime, args); # include "createMesh.H" - Info<< "Reading transportProperties\n" << endl; + Info<< "\nEstimating error in the incompressible momentum equation\n" + << "Reading transportProperties\n" << endl; IOdictionary transportProperties ( @@ -76,9 +68,9 @@ int main(int argc, char *argv[]) transportProperties.lookup("nu") ); - for (label i=startTime; i<endTime; i++) + forAll(timeDirs, timeI) { - runTime.setTime(Times[i], i); + runTime.setTime(timeDirs[timeI], timeI); Info<< "Time = " << runTime.timeName() << endl; diff --git a/applications/utilities/errorEstimation/momentScalarError/momentScalarError.C b/applications/utilities/errorEstimation/momentScalarError/momentScalarError.C index b1e1395bda026c9b727397af2940c97d37581d0b..f1767e75b01e6f2aa025bf39be577c686f2effa4 100644 --- a/applications/utilities/errorEstimation/momentScalarError/momentScalarError.C +++ b/applications/utilities/errorEstimation/momentScalarError/momentScalarError.C @@ -40,24 +40,17 @@ Description int main(int argc, char *argv[]) { + timeSelector::addOptions(); -# include "addTimeOptions.H" # include "setRootCase.H" - - Info<< "\nEstimating error in scalar transport equation\n" << endl; - # include "createTime.H" - // Get times list - instantList Times = runTime.times(); - -# include "checkTimeOptions.H" - - runTime.setTime(Times[startTime], startTime); + instantList timeDirs = timeSelector::select0(runTime, args); # include "createMesh.H" - Info<< "Reading transportProperties\n" << endl; + Info<< "\nEstimating error in scalar transport equation\n" + << "Reading transportProperties\n" << endl; IOdictionary transportProperties ( @@ -80,9 +73,9 @@ int main(int argc, char *argv[]) ); - for (label i=startTime; i<endTime; i++) + forAll(timeDirs, timeI) { - runTime.setTime(Times[i], i); + runTime.setTime(timeDirs[timeI], timeI); Info<< "Time = " << runTime.timeName() << endl; diff --git a/applications/utilities/mesh/conversion/foamToStarMesh/foamToStarMesh.C b/applications/utilities/mesh/conversion/foamToStarMesh/foamToStarMesh.C index 0a4f6d6027ba736196029f74e64715d021b91a5f..5cdbcb77e89f0d4a47aefdc6e2a80b90fc217492 100644 --- a/applications/utilities/mesh/conversion/foamToStarMesh/foamToStarMesh.C +++ b/applications/utilities/mesh/conversion/foamToStarMesh/foamToStarMesh.C @@ -61,6 +61,7 @@ See Also \*---------------------------------------------------------------------------*/ #include "argList.H" +#include "timeSelector.H" #include "Time.H" #include "polyMesh.H" #include "STARCDMeshWriter.H" @@ -73,20 +74,17 @@ using namespace Foam; int main(int argc, char *argv[]) { argList::noParallel(); + timeSelector::addOptions(); + argList::validOptions.insert("scale", "scale"); argList::validOptions.insert("noBnd", ""); argList::validOptions.insert("tri", ""); argList::validOptions.insert("surface", ""); -# include "addTimeOptions.H" # include "setRootCase.H" # include "createTime.H" - // Get times list - instantList Times = runTime.times(); - // set startTime and endTime depending on -time and -latestTime options -# include "checkTimeOptions.H" - runTime.setTime(Times[startTime], startTime); + instantList timeDirs = timeSelector::select0(runTime, args); bool surfaceOnly = false; if (args.options().found("surface") or args.options().found("tri")) @@ -118,17 +116,16 @@ int main(int argc, char *argv[]) # include "createPolyMesh.H" - // bool firstCheck = true; - for (label timeI = startTime; timeI < endTime; ++timeI) + forAll(timeDirs, timeI) { - runTime.setTime(Times[timeI], timeI); + runTime.setTime(timeDirs[timeI], timeI); # include "getTimeIndex.H" polyMesh::readUpdateState state = mesh.readUpdate(); - if (timeI == startTime || state != polyMesh::UNCHANGED) + if (!timeI || state != polyMesh::UNCHANGED) { meshWriters::STARCD writer(mesh, scaleFactor); diff --git a/applications/utilities/mesh/conversion/polyDualMesh/Make/files b/applications/utilities/mesh/conversion/polyDualMesh/Make/files index 752da5cfddb22955af52029c6b36312a2fedfc45..189fc19ec52d3e73eaa7009c42801334e8929793 100644 --- a/applications/utilities/mesh/conversion/polyDualMesh/Make/files +++ b/applications/utilities/mesh/conversion/polyDualMesh/Make/files @@ -1,4 +1,4 @@ meshDualiser.C -makePolyDualMesh.C +polyDualMeshApp.C EXE = $(FOAM_APPBIN)/polyDualMesh diff --git a/applications/utilities/mesh/conversion/polyDualMesh/makePolyDualMesh.C b/applications/utilities/mesh/conversion/polyDualMesh/polyDualMeshApp.C similarity index 99% rename from applications/utilities/mesh/conversion/polyDualMesh/makePolyDualMesh.C rename to applications/utilities/mesh/conversion/polyDualMesh/polyDualMeshApp.C index ab55305402154b07b5ae68e8275ddd23cd0558c9..8b03d895422f5fb09bea09eb6d814829d4ac2f23 100644 --- a/applications/utilities/mesh/conversion/polyDualMesh/makePolyDualMesh.C +++ b/applications/utilities/mesh/conversion/polyDualMesh/polyDualMeshApp.C @@ -348,8 +348,10 @@ int main(int argc, char *argv[]) # include "setRootCase.H" # include "createTime.H" + // Get times list instantList Times = runTime.times(); + # include "checkTimeOptions.H" runTime.setTime(Times[startTime], startTime); @@ -509,7 +511,7 @@ int main(int argc, char *argv[]) Info<< "Writing dual mesh to " << runTime.timeName() << endl; mesh.write(); - + Info<< "End\n" << endl; return 0; diff --git a/applications/utilities/mesh/conversion/writeMeshObj/writeMeshObj.C b/applications/utilities/mesh/conversion/writeMeshObj/writeMeshObj.C index e6c2560b38ebf02b02932c10bad79486f309831d..d8042fdaa8a2b522f332592793817d67e50b4e1e 100644 --- a/applications/utilities/mesh/conversion/writeMeshObj/writeMeshObj.C +++ b/applications/utilities/mesh/conversion/writeMeshObj/writeMeshObj.C @@ -37,6 +37,7 @@ Description \*---------------------------------------------------------------------------*/ #include "argList.H" +#include "timeSelector.H" #include "Time.H" #include "polyMesh.H" #include "OFstream.H" @@ -336,6 +337,7 @@ void writePointCells int main(int argc, char *argv[]) { + timeSelector::addOptions(); argList::validOptions.insert("patchFaces", ""); argList::validOptions.insert("cell", "cellI"); argList::validOptions.insert("face", "faceI"); @@ -343,7 +345,6 @@ int main(int argc, char *argv[]) argList::validOptions.insert("cellSet", "setName"); argList::validOptions.insert("faceSet", "setName"); -# include "addTimeOptions.H" # include "setRootCase.H" # include "createTime.H" runTime.functionObjects().off(); @@ -361,31 +362,23 @@ int main(int argc, char *argv[]) << "(for points, faces, cells) is consistent with" << " Foam numbering (starting from 0)." << endl << endl; - // Get times list - instantList Times = runTime.times(); - -# include "checkTimeOptions.H" - - runTime.setTime(Times[startTime], startTime); + instantList timeDirs = timeSelector::select0(runTime, args); # include "createPolyMesh.H" - bool firstCheck = true; - - for (label i=startTime; i<endTime; i++) + forAll(timeDirs, timeI) { - runTime.setTime(Times[i], i); + runTime.setTime(timeDirs[timeI], timeI); Info<< "Time = " << runTime.timeName() << endl; polyMesh::readUpdateState state = mesh.readUpdate(); - if (firstCheck || state != polyMesh::UNCHANGED) + if (!timeI || state != polyMesh::UNCHANGED) { if (patchFaces) { writePatchFaces(mesh, runTime.timeName()); - } else if (doCell) { @@ -487,9 +480,7 @@ int main(int argc, char *argv[]) Info << "No mesh." << endl; } - firstCheck = false; - - Info << endl << endl; + Info << nl << endl; } diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C b/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C index 74ab53432af98dd691cb6aab1a89cf18a597b486..d226008f5cd47b64772426b6ee2272c6a9e0a68c 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C @@ -31,7 +31,9 @@ Description \*---------------------------------------------------------------------------*/ #include "argList.H" +#include "timeSelector.H" #include "Time.H" + #include "polyMesh.H" #include "globalMeshData.H" @@ -45,48 +47,34 @@ using namespace Foam; int main(int argc, char *argv[]) { + timeSelector::addOptions(false); // no constant # include "addRegionOption.H" - -# include "addTimeOptionsNoConstant.H" - argList::validOptions.insert("noTopology", ""); argList::validOptions.insert("allGeometry", ""); argList::validOptions.insert("allTopology", ""); # include "setRootCase.H" - - const bool noTopology = args.options().found("noTopology"); - const bool allGeometry = args.options().found("allGeometry"); - const bool allTopology = args.options().found("allTopology"); - # include "createTime.H" - - // Get times list - instantList Times = runTime.times(); - -# include "checkTimeOptionsNoConstant.H" - - runTime.setTime(Times[startTime], startTime); - + instantList timeDirs = timeSelector::select0(runTime, args); # include "createNamedPolyMesh.H" - bool firstCheck = true; + const bool noTopology = args.options().found("noTopology"); + const bool allGeometry = args.options().found("allGeometry"); + const bool allTopology = args.options().found("allTopology"); - for (label i=startTime; i<endTime; i++) + forAll(timeDirs, timeI) { - runTime.setTime(Times[i], i); + runTime.setTime(timeDirs[timeI], timeI); polyMesh::readUpdateState state = mesh.readUpdate(); if ( - firstCheck + !timeI || state == polyMesh::TOPO_CHANGE || state == polyMesh::TOPO_PATCH_CHANGE ) { - firstCheck = false; - Info<< "Time = " << runTime.timeName() << nl << endl; // Clear mesh before checking @@ -110,32 +98,30 @@ int main(int argc, char *argv[]) if (noFailedChecks == 0) { - Info<< "\nMesh OK." - << nl << endl; + Info<< "\nMesh OK.\n" << endl; } else { - Info<< "\nFailed " << noFailedChecks << " mesh checks." - << nl << endl; + Info<< "\nFailed " << noFailedChecks << " mesh checks.\n" + << endl; } } else if (state == polyMesh::POINTS_MOVED) { Info<< "Time = " << runTime.timeName() << nl << endl; - label noFailedChecks = checkGeometry(mesh, allGeometry); + label nFailedChecks = checkGeometry(mesh, allGeometry); - reduce(noFailedChecks, sumOp<label>()); + reduce(nFailedChecks, sumOp<label>()); - if (noFailedChecks == 0) + if (nFailedChecks) { - Info << "\nMesh OK." - << nl << endl; + Info<< "\nFailed " << nFailedChecks << " mesh checks.\n" + << endl; } else { - Info<< "\nFailed " << noFailedChecks << " mesh checks." - << nl << endl; + Info << "\nMesh OK.\n" << endl; } } } diff --git a/applications/utilities/mesh/manipulation/rotateMesh/rotateMesh.C b/applications/utilities/mesh/manipulation/rotateMesh/rotateMesh.C index 317799312cabe66657a6de4ace4cb4803acdafa7..d7a84ee45a88d7cf9bbe91dd50a8ac728ecd65f6 100644 --- a/applications/utilities/mesh/manipulation/rotateMesh/rotateMesh.C +++ b/applications/utilities/mesh/manipulation/rotateMesh/rotateMesh.C @@ -31,6 +31,7 @@ Description \*---------------------------------------------------------------------------*/ #include "argList.H" +#include "timeSelector.H" #include "Time.H" #include "fvMesh.H" #include "volFields.H" @@ -66,7 +67,8 @@ void RotateFields int main(int argc, char *argv[]) { -# include "addTimeOptions.H" + timeSelector::addOptions(); + argList::validArgs.append("n1"); argList::validArgs.append("n2"); @@ -105,19 +107,15 @@ int main(int argc, char *argv[]) points.write(); } - // Get times list - instantList Times = runTime.times(); - - // set startTime and endTime depending on -time and -latestTime options -# include "checkTimeOptions.H" - runTime.setTime(Times[startTime], startTime); + instantList timeDirs = timeSelector::select0(runTime, args); # include "createMesh.H" - for (label i=startTime; i<endTime; i++) + + forAll(timeDirs, timeI) { - runTime.setTime(Times[i], i); + runTime.setTime(timeDirs[timeI], timeI); Info<< "Time = " << runTime.timeName() << endl; diff --git a/applications/utilities/mesh/manipulation/setSet/setSet.C b/applications/utilities/mesh/manipulation/setSet/setSet.C index a5909c398ab77f69b9dcefb1842266d06cac3101..ff6d576b0abb121cdc58bd7b4cd730e0431d9052 100644 --- a/applications/utilities/mesh/manipulation/setSet/setSet.C +++ b/applications/utilities/mesh/manipulation/setSet/setSet.C @@ -48,8 +48,8 @@ Description #if READLINE != 0 -#include <readline/readline.h> -#include <readline/history.h> +# include <readline/readline.h> +# include <readline/history.h> #endif using namespace Foam; diff --git a/applications/utilities/miscellaneous/patchSummary/patchSummary.C b/applications/utilities/miscellaneous/patchSummary/patchSummary.C index 8195e4d9dc69bd9a3f59048bcf863fb067693356..67ae5270274bc6a6dd84d0fc510ae9979ae954a4 100644 --- a/applications/utilities/miscellaneous/patchSummary/patchSummary.C +++ b/applications/utilities/miscellaneous/patchSummary/patchSummary.C @@ -40,25 +40,19 @@ Description int main(int argc, char *argv[]) { + timeSelector::addOptions(); -# include "addTimeOptions.H" # include "addRegionOption.H" # include "setRootCase.H" # include "createTime.H" - // Get times list - instantList Times = runTime.times(); - - // set startTime and endTime depending on -time and -latestTime options -# include "checkTimeOptions.H" - - runTime.setTime(Times[startTime], startTime); + instantList timeDirs = timeSelector::select0(runTime, args); # include "createNamedMesh.H" - for (label i=startTime; i<endTime; i++) + forAll(timeDirs, timeI) { - runTime.setTime(Times[i], i); + runTime.setTime(timeDirs[timeI], timeI); Info<< "Time = " << runTime.timeName() << nl << endl; diff --git a/applications/utilities/postProcessing/dataConversion/foamDataToFluent/foamDataToFluent.C b/applications/utilities/postProcessing/dataConversion/foamDataToFluent/foamDataToFluent.C index 7f5a8e29174168fee94e47981034bb200b006d8e..4a63948f422eb9f7d7d028158b8be41f93012795 100644 --- a/applications/utilities/postProcessing/dataConversion/foamDataToFluent/foamDataToFluent.C +++ b/applications/utilities/postProcessing/dataConversion/foamDataToFluent/foamDataToFluent.C @@ -38,26 +38,22 @@ Description int main(int argc, char *argv[]) { argList::noParallel(); -# include "addTimeOptions.H" + timeSelector::addOptions(false); // no constant # include "setRootCase.H" # include "createTime.H" - instantList Times = runTime.times(); - - // set startTime and endTime depending on -time and -latestTime options -# include "checkTimeOptionsNoConstant.H" - - runTime.setTime(Times[startTime], startTime); + instantList timeDirs = timeSelector::select0(runTime, args); # include "createMesh.H" // make a directory called proInterface in the case mkDir(runTime.rootPath()/runTime.caseName()/"fluentInterface"); - for (label timeI = startTime; timeI < endTime; timeI++) + forAll(timeDirs, timeI) { - runTime.setTime(Times[timeI], timeI); + runTime.setTime(timeDirs[timeI], timeI); + Info<< "Time = " << runTime.timeName() << endl; if (mesh.readUpdate()) diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C index 793e18c05b7d6fcfada208a5b6e52ae7a41477f7..2d5e7479906befdf04c420de5409f1db7c274328 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C @@ -225,8 +225,10 @@ labelList getSelectedPatches int main(int argc, char *argv[]) { -# include "addTimeOptions.H" + timeSelector::addOptions(); + # include "addRegionOption.H" + argList::validOptions.insert("fields", "fields"); argList::validOptions.insert("cellSet", "cellSet name"); argList::validOptions.insert("faceSet", "faceSet name"); @@ -244,7 +246,6 @@ int main(int argc, char *argv[]) # include "setRootCase.H" # include "createTime.H" - bool doWriteInternal = !args.options().found("noInternal"); bool doFaceZones = !args.options().found("noFaceZones"); bool doLinks = !args.options().found("noLinks"); @@ -312,14 +313,8 @@ int main(int argc, char *argv[]) } - instantList Times = runTime.times(); - - // set startTime and endTime depending on -time and -latestTime options -# include "checkTimeOptions.H" - - runTime.setTime(Times[startTime], startTime); + instantList timeDirs = timeSelector::select0(runTime, args); - // Current mesh. # include "createNamedMesh.H" // VTK/ directory in the case @@ -359,11 +354,11 @@ int main(int argc, char *argv[]) // mesh wrapper; does subsetting and decomposition vtkMesh vMesh(mesh, cellSetName); - for (label timeI = startTime; timeI < endTime; timeI++) + forAll(timeDirs, timeI) { - runTime.setTime(Times[timeI], timeI); + runTime.setTime(timeDirs[timeI], timeI); - Info<< "Time " << Times[timeI].name() << endl; + Info<< "Time: " << runTime.timeName() << endl; // Check for new polyMesh/ and update mesh, fvMeshSubset and cell // decomposition. diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.cxx b/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.cxx index c824ec7e3c16aa0b1214a6282d623a57c480b658..0d99f3e95b34be1b5cbb1684248104e4aaf8d127 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.cxx +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.cxx @@ -52,8 +52,7 @@ vtkPV3FoamReader::vtkPV3FoamReader() // Add second output for the Lagrangian this->SetNumberOfOutputPorts(2); - vtkMultiBlockDataSet *lagrangian; - lagrangian = vtkMultiBlockDataSet::New(); + vtkMultiBlockDataSet *lagrangian = vtkMultiBlockDataSet::New(); lagrangian->ReleaseData(); this->GetExecutive()->SetOutputData(1, lagrangian); @@ -204,9 +203,9 @@ int vtkPV3FoamReader::RequestInformation ); } - double timeRange[2]; if (nTimeSteps) { + double timeRange[2]; timeRange[0] = timeSteps[0]; timeRange[1] = timeSteps[nTimeSteps-1]; @@ -273,19 +272,53 @@ int vtkPV3FoamReader::RequestData } } - // take port0 as the lead for other outputs - vtkInformation *outInfo = outputVector->GetInformationObject(0); + // Get the requested time step. + // We only support requests for a single time step + + int nRequestTime = 0; + double requestTime[nInfo]; + + // taking port0 as the lead for other outputs would be nice, but fails when + // a filter is added - we need to check everything + // but since PREVIOUS_UPDATE_TIME_STEPS() is protected, relay the logic + // to the vtkPV3Foam::setTime() method + for (int infoI = 0; infoI < nInfo; ++infoI) + { + vtkInformation *outInfo = outputVector->GetInformationObject(infoI); + + if + ( + outInfo->Has + ( + vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS() + ) + && outInfo->Length + ( + vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS() + ) >= 1 + ) + { + requestTime[nRequestTime++] = outInfo->Get + ( + vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS() + )[0]; + } + } + + if (nRequestTime) + { + foamData_->setTime(nRequestTime, requestTime); + } vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::SafeDownCast ( - outInfo->Get + outputVector->GetInformationObject(0)->Get ( vtkMultiBlockDataSet::DATA_OBJECT() ) ); - vtkMultiBlockDataSet* lagrangianOutput = vtkMultiBlockDataSet::SafeDownCast ( outputVector->GetInformationObject(1)->Get @@ -294,24 +327,6 @@ int vtkPV3FoamReader::RequestData ) ); - if (outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS())) - { - // Get the requested time step. - // We only support requests for a single time step - int nRequestedTimeSteps = outInfo->Length - ( - vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS() - ); - if (nRequestedTimeSteps >= 1) - { - double *requestedTimeSteps = outInfo->Get - ( - vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS() - ); - - foamData_->setTime(requestedTimeSteps[0]); - } - } if (Foam::vtkPV3Foam::debug) { diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C index 4c4016c364a378cc1edda61bcff4729fae463db2..624358b4a0dcb39fd26e885c8597a6672b787bf2 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C @@ -90,12 +90,21 @@ void Foam::vtkPV3Foam::reduceMemory() -int Foam::vtkPV3Foam::setTime(const double& requestedTime) +int Foam::vtkPV3Foam::setTime(int nRequest, const double requestTimes[]) { if (debug) { - Info<< "<beg> Foam::vtkPV3Foam::setTime(" << requestedTime << ")" - << endl; + Info<< "<beg> Foam::vtkPV3Foam::setTime("; + for (int requestI = 0; requestI < nRequest; ++requestI) + { + if (requestI) + { + Info<< ", "; + } + + Info<< requestTimes[requestI]; + } + Info << ") - previousIndex = " << timeIndex_ << endl; } Time& runTime = dbPtr_(); @@ -103,12 +112,26 @@ int Foam::vtkPV3Foam::setTime(const double& requestedTime) // Get times list instantList Times = runTime.times(); - int nearestIndex = Time::findClosestTimeIndex(Times, requestedTime); + int nearestIndex = timeIndex_; + + for (int requestI = 0; requestI < nRequest; ++requestI) + { + int index = Time::findClosestTimeIndex(Times, requestTimes[requestI]); + + if (index >= 0 && index != timeIndex_) + { + nearestIndex = index; + break; + } + } + + if (nearestIndex < 0) { nearestIndex = 0; } + // see what has changed if (timeIndex_ != nearestIndex) { @@ -138,10 +161,11 @@ int Foam::vtkPV3Foam::setTime(const double& requestedTime) if (debug) { - Info<< "<end> Foam::vtkPV3Foam::setTime() - selected time " - << Times[nearestIndex].name() << " index=" << nearestIndex - << " meshChanged=" << meshChanged_ - << " fieldsChanged=" << fieldsChanged_ << endl; + Info<< "<end> Foam::vtkPV3Foam::setTime() - selectedTime=" + << Times[nearestIndex].name() << " index=" << timeIndex_ + << "/" << Times.size() + << " meshChanged=" << Switch(meshChanged_) + << " fieldsChanged=" << Switch(fieldsChanged_) << endl; } return nearestIndex; diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H index 59e7e86b59a593ad0ec5b5186b9790bbe16d4de4..c6dd65af9ecfe79c8f16e14af1a8a48ecd93b440 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H @@ -133,6 +133,7 @@ class vtkPV3Foam return block_; } + //- Assign block number, return previous value int block(int blockNo) { int prev = block_; @@ -718,9 +719,11 @@ public: //- Remove patch names from the display void removePatchNames(vtkRenderer* renderer); - //- set the runTime to the requested time, returns the timeIndex - // sets to "constant" on error and returns -1 - int setTime(const double& requestedTime); + //- set the runTime to the first plausible request time, + // returns the timeIndex + // sets to "constant" on error + int setTime(int count, const double requestTimes[]); + //- The current time index int timeIndex() const diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfoFields.H b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfoFields.H index 8ef698872d37b2b0046886abaa76fd1e773e378e..7e28460a465c74ffb690359aff588df63accc756 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfoFields.H +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfoFields.H @@ -40,7 +40,10 @@ void Foam::vtkPV3Foam::updateInfoFields { if (debug) { - Info<< "<beg> Foam::vtkPV3Foam::updateInfoFields" << endl; + Info<< "<beg> Foam::vtkPV3Foam::updateInfoFields <" + << meshType::Mesh::typeName + << "> [meshPtr=" << (meshPtr_ ? "set" : "NULL") << "]" + << endl; } stringList enabledEntries; diff --git a/applications/utilities/postProcessing/miscellaneous/engineCompRatio/engineCompRatio.C b/applications/utilities/postProcessing/miscellaneous/engineCompRatio/engineCompRatio.C index 34ebbc75dcab101e2d95655ba63dc0a3002b0de0..65356b382b26678e2db9db3a7d3ce511ce61972f 100644 --- a/applications/utilities/postProcessing/miscellaneous/engineCompRatio/engineCompRatio.C +++ b/applications/utilities/postProcessing/miscellaneous/engineCompRatio/engineCompRatio.C @@ -40,57 +40,50 @@ Description int main(int argc, char *argv[]) { + #include "setRootCase.H" + #include "createEngineTime.H" + #include "createEngineMesh.H" -# include "setRootCase.H" -# include "createEngineTime.H" -# include "createEngineMesh.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // scalar eps = 1.0e-10; scalar fullCycle = 360.0; scalar ca0 = -180.0; scalar ca1 = 0.0; - scalar ca = runTime.theta(); - while (ca > ca0) + while (runTime.theta() > ca0) { ca0 += fullCycle; ca1 += fullCycle; } - if (mag(ca - ca0) > eps) + while (mag(runTime.theta() - ca0) > eps) { - while(mag(ca - ca0) > eps) - { - ca = runTime.theta(); - scalar t0 = runTime.userTimeToTime(ca0 - ca); - runTime.setDeltaT(t0); - runTime++; - Info << "CA = " << ca << endl; - mesh.move(); - } + scalar t0 = runTime.userTimeToTime(ca0 - runTime.theta()); + runTime.setDeltaT(t0); + runTime++; + Info<< "CA = " << runTime.theta() << endl; + mesh.move(); } scalar Vmax = sum(mesh.V().field()); - while(mag(ca-ca1) > eps) + while (mag(runTime.theta()-ca1) > eps) { - ca = runTime.theta(); - scalar t1 = runTime.userTimeToTime(ca1-ca); + scalar t1 = runTime.userTimeToTime(ca1-runTime.theta()); runTime.setDeltaT(t1); runTime++; - Info << "CA = " << runTime.theta() << endl; + Info<< "CA = " << runTime.theta() << endl; mesh.move(); } scalar Vmin = sum(mesh.V().field()); - Info << "\nVmax = " << Vmax; - Info << ", Vmin = " << Vmin << endl; - Info << "Vmax/Vmin = " << Vmax/Vmin << endl; - Info << "\n end\n"; + Info<< "\nVmax = " << Vmax; + Info<< ", Vmin = " << Vmin << endl; + Info<< "Vmax/Vmin = " << Vmax/Vmin << endl; + Info<< "\nEnd" << endl; return 0; } diff --git a/applications/utilities/postProcessing/miscellaneous/ptot/ptot.C b/applications/utilities/postProcessing/miscellaneous/ptot/ptot.C index bb41fb60d46bfaf18ba6fa32bbe5c5d13f310bc2..26d66de83e85c048d5cc96fca511ab896d873c53 100644 --- a/applications/utilities/postProcessing/miscellaneous/ptot/ptot.C +++ b/applications/utilities/postProcessing/miscellaneous/ptot/ptot.C @@ -36,25 +36,18 @@ Description int main(int argc, char *argv[]) { + timeSelector::addOptions(); -# include "addTimeOptions.H" # include "setRootCase.H" - # include "createTime.H" - // Get times list - instantList Times = runTime.times(); - - // set startTime and endTime depending on -time and -latestTime options -# include "checkTimeOptions.H" - - runTime.setTime(Times[startTime], startTime); + instantList timeDirs = timeSelector::select0(runTime, args); # include "createMesh.H" - for (label i=startTime; i<endTime; i++) + forAll(timeDirs, timeI) { - runTime.setTime(Times[i], i); + runTime.setTime(timeDirs[timeI], timeI); Info<< "Time = " << runTime.timeName() << endl; diff --git a/applications/utilities/postProcessing/miscellaneous/wdot/wdot.C b/applications/utilities/postProcessing/miscellaneous/wdot/wdot.C index 79f23de3e790b0818cd45de8a847dc59d951f736..81a0c469794f1c7121e65cc79aa8088cd2519522 100644 --- a/applications/utilities/postProcessing/miscellaneous/wdot/wdot.C +++ b/applications/utilities/postProcessing/miscellaneous/wdot/wdot.C @@ -37,25 +37,18 @@ Description int main(int argc, char *argv[]) { + timeSelector::addOptions(); -# include "addTimeOptions.H" # include "setRootCase.H" - # include "createTime.H" - // Get times list - instantList Times = runTime.times(); - - // set startTime and endTime depending on -time and -latestTime options -# include "checkTimeOptions.H" - - runTime.setTime(Times[startTime], startTime); + instantList timeDirs = timeSelector::select0(runTime, args); # include "createMesh.H" - for (label i=startTime; i<endTime; i++) + forAll(timeDirs, timeI) { - runTime.setTime(Times[i], i); + runTime.setTime(timeDirs[timeI], timeI); mesh.readUpdate(); diff --git a/applications/utilities/postProcessing/miscellaneous/writeCellCentres/writeCellCentres.C b/applications/utilities/postProcessing/miscellaneous/writeCellCentres/writeCellCentres.C index f420edf6adad10881efc55f0954a7eb4340fbaa2..bc26ec509fbe6cc9a8dca2792aeef1373c2dccce 100644 --- a/applications/utilities/postProcessing/miscellaneous/writeCellCentres/writeCellCentres.C +++ b/applications/utilities/postProcessing/miscellaneous/writeCellCentres/writeCellCentres.C @@ -29,6 +29,8 @@ Description \*---------------------------------------------------------------------------*/ #include "argList.H" +#include "timeSelector.H" +#include "Time.H" #include "fvMesh.H" #include "vectorIOField.H" #include "volFields.H" @@ -41,23 +43,18 @@ using namespace Foam; int main(int argc, char *argv[]) { -# include "addTimeOptions.H" + timeSelector::addOptions(); + # include "setRootCase.H" # include "createTime.H" - - // Get times list - instantList Times = runTime.times(); - -# include "checkTimeOptions.H" - - runTime.setTime(Times[startTime], startTime); + instantList timeDirs = timeSelector::select0(runTime, args); # include "createMesh.H" - for (label i=startTime; i<endTime; i++) + forAll(timeDirs, timeI) { - runTime.setTime(Times[i], i); + runTime.setTime(timeDirs[timeI], timeI); Info<< "Time = " << runTime.timeName() << endl; @@ -77,10 +74,10 @@ int main(int argc, char *argv[]) mesh.C() ); - //Info<< "Writing cellCentre positions to " << cc.name() << " in " - // << runTime.timeName() << endl; + // Info<< "Writing cellCentre positions to " << cc.name() << " in " + // << runTime.timeName() << endl; // - //cc.write(); + // cc.write(); Info<< "Writing components of cellCentre positions to volScalarFields" << " ccx, ccy, ccz in " << runTime.timeName() << endl; @@ -104,7 +101,7 @@ int main(int argc, char *argv[]) } } - Info << nl << "End" << endl; + Info<< "\nEnd" << endl; return 0; } diff --git a/applications/utilities/postProcessing/scalarField/pPrime2/pPrime2.C b/applications/utilities/postProcessing/scalarField/pPrime2/pPrime2.C index 6729389218f5ab7d2183eb622e8569451e8cf6bb..54a7b53c461a55f77fc3a8d698bb89dce87aeac4 100644 --- a/applications/utilities/postProcessing/scalarField/pPrime2/pPrime2.C +++ b/applications/utilities/postProcessing/scalarField/pPrime2/pPrime2.C @@ -38,23 +38,16 @@ Description int main(int argc, char *argv[]) { + timeSelector::addOptions(); -# include "addTimeOptions.H" # include "setRootCase.H" - # include "createTime.H" - // Get times list - instantList Times = runTime.times(); - - // set startTime and endTime depending on -time and -latestTime options -# include "checkTimeOptions.H" - - runTime.setTime(Times[startTime], startTime); + instantList timeDirs = timeSelector::select0(runTime, args); # include "createMesh.H" - runTime.setTime(Times[endTime-1], endTime-1); + runTime.setTime(timeDirs[timeDirs.size()-1], timeDirs.size()-1); volScalarField pMean ( @@ -68,9 +61,9 @@ int main(int argc, char *argv[]) mesh ); - for (label i=startTime; i<endTime; i++) + forAll(timeDirs, timeI) { - runTime.setTime(Times[i], i); + runTime.setTime(timeDirs[timeI], timeI); Info<< "Time = " << runTime.timeName() << endl; diff --git a/applications/utilities/postProcessing/stressField/stressComponents/stressComponents.C b/applications/utilities/postProcessing/stressField/stressComponents/stressComponents.C index 2c481b89278566272af3de09f3b39e69fba0db47..aa26a0e0c08e2a2bce2216314e1bc1f910233934 100644 --- a/applications/utilities/postProcessing/stressField/stressComponents/stressComponents.C +++ b/applications/utilities/postProcessing/stressField/stressComponents/stressComponents.C @@ -35,30 +35,22 @@ Description #include "incompressible/singlePhaseTransportModel/singlePhaseTransportModel.H" #include "zeroGradientFvPatchFields.H" - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // int main(int argc, char *argv[]) { + timeSelector::addOptions(); -# include "addTimeOptions.H" # include "setRootCase.H" - # include "createTime.H" - // Get times list - instantList Times = runTime.times(); - - // set startTime and endTime depending on -time and -latestTime options -# include "checkTimeOptions.H" - - runTime.setTime(Times[startTime], startTime); + instantList timeDirs = timeSelector::select0(runTime, args); # include "createMesh.H" - for (label i=startTime; i<endTime; i++) + forAll(timeDirs, timeI) { - runTime.setTime(Times[i], i); + runTime.setTime(timeDirs[timeI], timeI); Info<< "Time = " << runTime.timeName() << endl; diff --git a/applications/utilities/postProcessing/turbulence/createTurbulenceFields/createTurbulenceFields.C b/applications/utilities/postProcessing/turbulence/createTurbulenceFields/createTurbulenceFields.C index 5e15aff046e3b2e56a336d465d86072a8268ba15..c4a556f21fbdab829a0ca36c649b92cb6cb0c60c 100644 --- a/applications/utilities/postProcessing/turbulence/createTurbulenceFields/createTurbulenceFields.C +++ b/applications/utilities/postProcessing/turbulence/createTurbulenceFields/createTurbulenceFields.C @@ -42,24 +42,19 @@ Source files: int main(int argc, char *argv[]) { - #include "addTimeOptions.H" + timeSelector::addOptions(); + #include "setRootCase.H" #include "createTime.H" - // Get times list - instantList Times = runTime.times(); - - // set startTime and endTime depending on -time and -latestTime options - #include "checkTimeOptions.H" + instantList timeDirs = timeSelector::select0(runTime, args); - runTime.setTime(Times[startTime], startTime); #include "createMesh.H" - #include "createFields.H" - for (label i=startTime; i<endTime; i++) + forAll(timeDirs, timeI) { - runTime.setTime(Times[i], i); + runTime.setTime(timeDirs[timeI], timeI); Info<< "Time = " << runTime.timeName() << endl; diff --git a/applications/utilities/postProcessing/velocityField/streamFunction/streamFunction.C b/applications/utilities/postProcessing/velocityField/streamFunction/streamFunction.C index 98c044ca3e16d7685174a57fb20e69e21b493598..68d4c8d6980891bb15dd73206a01a82c2e47804f 100644 --- a/applications/utilities/postProcessing/velocityField/streamFunction/streamFunction.C +++ b/applications/utilities/postProcessing/velocityField/streamFunction/streamFunction.C @@ -26,7 +26,7 @@ Application streamFunction Description - Calculates and writes the stream function of velocity field U at each time + Calculates and writes the stream function of velocity field U at each time \*---------------------------------------------------------------------------*/ @@ -42,27 +42,20 @@ Description int main(int argc, char *argv[]) { + timeSelector::addOptions(); -# include "addTimeOptions.H" # include "setRootCase.H" - # include "createTime.H" - // Get times list - instantList Times = runTime.times(); - - // set startTime and endTime depending on -time and -latestTime options -# include "checkTimeOptions.H" - - runTime.setTime(Times[startTime], startTime); + instantList timeDirs = timeSelector::select0(runTime, args); # include "createMeshNoClear.H" pointMesh pMesh(mesh); - for (label i=startTime; i<endTime; i++) + forAll(timeDirs, timeI) { - runTime.setTime(Times[i], i); + runTime.setTime(timeDirs[timeI], timeI); Info<< nl << "Time: " << runTime.timeName() << endl; diff --git a/src/OpenFOAM/primitives/bools/Switch/Switch.C b/src/OpenFOAM/primitives/bools/Switch/Switch.C index 9b7b449a226452dab9f93d65966c3f472659bc2d..8648532a32d30d5609cccee44d57677d8bc13cbb 100644 --- a/src/OpenFOAM/primitives/bools/Switch/Switch.C +++ b/src/OpenFOAM/primitives/bools/Switch/Switch.C @@ -38,20 +38,20 @@ const char* Foam::Switch::names[Foam::Switch::INVALID+1] = "off", "on", "no", "yes", "n", "y", + "none", "true", // is there a reasonable counterpart to "none"? "invalid" }; // * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * // -Foam::Switch::switchType Foam::Switch::asEnum(const bool val) +Foam::Switch::switchType Foam::Switch::asEnum(const bool b) { - return val ? Switch::TRUE : Switch::FALSE; + return b ? Switch::TRUE : Switch::FALSE; } -Foam::Switch::switchType -Foam::Switch::asEnum +Foam::Switch::switchType Foam::Switch::asEnum ( const std::string& str, const bool allowInvalid @@ -61,8 +61,8 @@ Foam::Switch::asEnum { if (str == names[sw]) { - // convert y/n to yes/no (perhaps should deprecate y/n) - if (sw == Switch::NO_1) + // convert n/y to no/yes (perhaps should deprecate y/n) + if (sw == Switch::NO_1 || sw == Switch::NONE) { return Switch::NO; } @@ -90,6 +90,7 @@ Foam::Switch::asEnum bool Foam::Switch::asBool(const switchType sw) { + // relies on (INVALID & 0x1) evaluating to false return (sw & 0x1); } @@ -103,13 +104,19 @@ bool Foam::Switch::asBool // allow invalid values, but catch after for correct error message switchType sw = asEnum(str, true); - if (sw == Switch::INVALID && !allowInvalid) + if (sw == Switch::INVALID) { - FatalErrorIn("Switch::asBool(const std::string&)") - << "unknown switch word " << str << nl - << abort(FatalError); + if (!allowInvalid) + { + FatalErrorIn("Switch::asBool(const std::string&)") + << "unknown switch word " << str << nl + << abort(FatalError); + } + + return false; } + return (sw & 0x1); } diff --git a/src/OpenFOAM/primitives/bools/Switch/Switch.H b/src/OpenFOAM/primitives/bools/Switch/Switch.H index 4eaa2dd12b532e9618e6489ff29d2b23d01d92f3..adda09cf4ecfa2895f61f167f3d66d300b79b845 100644 --- a/src/OpenFOAM/primitives/bools/Switch/Switch.H +++ b/src/OpenFOAM/primitives/bools/Switch/Switch.H @@ -27,7 +27,7 @@ Class Description A simple wrapper around bool so that it can be read as a word: - true/false, on/off, yes/no or y/n. + true/false, on/off, yes/no or y/n or none. SourceFiles Switch.C @@ -80,6 +80,7 @@ public: OFF = 2, ON = 3, NO = 4, YES = 5, NO_1 = 6, YES_1 = 7, + NONE = 8, PLACEHOLDER = 9, INVALID }; diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/displacementFvMotionSolver/displacementFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/displacement/displacementFvMotionSolver/displacementFvMotionSolver.C index aee52c717ce6d7bf6f685ef8a2fac395f65807ba..aa3d51bd4f6cabf8167496fe942bb04e46aa948f 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/displacementFvMotionSolver/displacementFvMotionSolver.C +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/displacementFvMotionSolver/displacementFvMotionSolver.C @@ -32,23 +32,13 @@ License namespace Foam { -// defineTypeNameAndDebug(displacementFvMotionSolver, 0); -// -// addToRunTimeSelectionTable -// ( -// fvMotionSolver, -// displacementFvMotionSolver, -// dictionary -// ); + defineTypeNameAndDebug(displacementFvMotionSolver, 0); } -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::displacementFvMotionSolver:: -displacementFvMotionSolver +Foam::displacementFvMotionSolver::displacementFvMotionSolver ( const polyMesh& mesh, Istream&