From 00f23290c24d964ce289cbfd933153635089e772 Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Wed, 5 Dec 2012 15:10:08 +0000 Subject: [PATCH] ENH: addDictOption: consistent dict option handling --- src/OpenFOAM/include/addDictOption.H | 10 ++++++ .../include/setConstantMeshDictionaryIO.H | 33 +++++++++++++++++++ .../include/setSystemMeshDictionaryIO.H | 33 +++++++++++++++++++ .../include/setSystemRunTimeDictionaryIO.H | 33 +++++++++++++++++++ 4 files changed, 109 insertions(+) create mode 100644 src/OpenFOAM/include/addDictOption.H create mode 100644 src/OpenFOAM/include/setConstantMeshDictionaryIO.H create mode 100644 src/OpenFOAM/include/setSystemMeshDictionaryIO.H create mode 100644 src/OpenFOAM/include/setSystemRunTimeDictionaryIO.H diff --git a/src/OpenFOAM/include/addDictOption.H b/src/OpenFOAM/include/addDictOption.H new file mode 100644 index 00000000000..f538e572948 --- /dev/null +++ b/src/OpenFOAM/include/addDictOption.H @@ -0,0 +1,10 @@ +// +// addDictOption.H +// ~~~~~~~~~~~~~~~~~ + + Foam::argList::addOption + ( + "dict", + "file", + "read control dictionary from specified location" + ); diff --git a/src/OpenFOAM/include/setConstantMeshDictionaryIO.H b/src/OpenFOAM/include/setConstantMeshDictionaryIO.H new file mode 100644 index 00000000000..4f97cf16940 --- /dev/null +++ b/src/OpenFOAM/include/setConstantMeshDictionaryIO.H @@ -0,0 +1,33 @@ +// +// setConstantMeshDictionaryIO.H +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + fileName dictPath = ""; + if (args.optionFound("dict")) + { + dictPath = args["dict"]; + if (isDir(dictPath)) + { + dictPath = dictPath / dictName; + } + } + + IOobject dictIO + ( + dictName, + runTime.constant(), + mesh, + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE + ); + + if (dictPath.size()) + { + dictIO = IOobject + ( + dictPath, + mesh, + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE + ); + } diff --git a/src/OpenFOAM/include/setSystemMeshDictionaryIO.H b/src/OpenFOAM/include/setSystemMeshDictionaryIO.H new file mode 100644 index 00000000000..6e89f94c33f --- /dev/null +++ b/src/OpenFOAM/include/setSystemMeshDictionaryIO.H @@ -0,0 +1,33 @@ +// +// setSystemMeshDictionaryIO.H +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + fileName dictPath = ""; + if (args.optionFound("dict")) + { + dictPath = args["dict"]; + if (isDir(dictPath)) + { + dictPath = dictPath / dictName; + } + } + + IOobject dictIO + ( + dictName, + runTime.system(), + mesh, + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE + ); + + if (dictPath.size()) + { + dictIO = IOobject + ( + dictPath, + mesh, + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE + ); + } diff --git a/src/OpenFOAM/include/setSystemRunTimeDictionaryIO.H b/src/OpenFOAM/include/setSystemRunTimeDictionaryIO.H new file mode 100644 index 00000000000..e594e83d960 --- /dev/null +++ b/src/OpenFOAM/include/setSystemRunTimeDictionaryIO.H @@ -0,0 +1,33 @@ +// +// setSystemRunTimeDictionaryIO.H +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + fileName dictPath = ""; + if (args.optionFound("dict")) + { + dictPath = args["dict"]; + if (isDir(dictPath)) + { + dictPath = dictPath / dictName; + } + } + + IOobject dictIO + ( + dictName, + runTime.system(), + runTime, + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE + ); + + if (dictPath.size()) + { + dictIO = IOobject + ( + dictPath, + runTime, + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE + ); + } -- GitLab