From 577babc72bf32ea2a7ec8d151b396c94321d3050 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Thu, 22 Nov 2018 15:51:05 +0100 Subject: [PATCH] ENH: reject bad time values for blockMesh -time (closes #1093) --- .../mesh/generation/blockMesh/blockMesh.C | 31 +++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/applications/utilities/mesh/generation/blockMesh/blockMesh.C b/applications/utilities/mesh/generation/blockMesh/blockMesh.C index 227e9dffa76..e4cb0fad35c 100644 --- a/applications/utilities/mesh/generation/blockMesh/blockMesh.C +++ b/applications/utilities/mesh/generation/blockMesh/blockMesh.C @@ -150,6 +150,31 @@ int main(int argc, char *argv[]) } + // Instance for resulting mesh + bool useTime = false; + word meshInstance(runTime.constant()); + + if + ( + args.readIfPresent("time", meshInstance) + && runTime.constant() != meshInstance + ) + { + // Verify that the value is actually good + scalar timeValue; + + useTime = readScalar(meshInstance, timeValue); + if (!useTime) + { + FatalErrorInFunction + << "Bad input value: " << meshInstance + << "Should be a scalar or 'constant'" + << nl << endl + << exit(FatalError); + } + } + + // Locate appropriate blockMeshDict #include "findBlockMeshDict.H" @@ -203,13 +228,13 @@ int main(int argc, char *argv[]) // Instance for resulting mesh - word meshInstance(runTime.constant()); - if (args.readIfPresent("time", meshInstance)) + if (useTime) { Info<< "Writing polyMesh to " << meshInstance << nl << endl; + // Make sure that the time is seen to be the current time. This // is the logic inside regIOobject which resets the instance to the - // current time before writting + // current time before writing runTime.setTime(instant(meshInstance), 0); } -- GitLab