diff --git a/applications/utilities/miscellaneous/foamDictionary/foamDictionary.C b/applications/utilities/miscellaneous/foamDictionary/foamDictionary.C index 8e66cbcc9a..94125194f4 100644 --- a/applications/utilities/miscellaneous/foamDictionary/foamDictionary.C +++ b/applications/utilities/miscellaneous/foamDictionary/foamDictionary.C @@ -79,12 +79,16 @@ Usage (or sub entry if -entry specified) - \par -expand - Read the specified dictionary file, expand the macros etc. and write - the resulting dictionary to standard output. + Read the specified dictionary file, expand the macros etc. + Writes the expanded dictionary to the output dictionary if specified + otherwise to standard output - \par -includes List the \c #include and \c #includeIfPresent files to standard output + - \par -output + Path name of the output dictionary, defaults to the input dictionary + Example usage: - Change simulation to run for one timestep only: \verbatim @@ -327,8 +331,7 @@ int main(int argc, char *argv[]) argList::addBoolOption ( "expand", - "Read the specified dictionary file, expand the macros etc. and write " - "the resulting dictionary to standard output" + "Read the specified dictionary file and expand the macros etc." ); argList::addOption ( @@ -336,6 +339,12 @@ int main(int argc, char *argv[]) "label", "Write with the specified precision" ); + argList::addOption + ( + "output", + "path name", + "Path name of the output dictionary" + ); argList args(argc, argv); @@ -432,24 +441,31 @@ int main(int argc, char *argv[]) } else if (args.optionFound("expand") && !args.optionFound("entry")) { - IOobject::writeBanner(Info) - <<"//\n// " << dictPath << "\n//\n"; - - // Change the format to ASCII - if (dict.found(IOobject::foamFile)) + if (!args.optionFound("output")) { - dict.subDict(IOobject::foamFile).add - ( - "format", - IOstream::ASCII, - true - ); + IOobject::writeBanner(Info) + <<"//\n// " << dictPath << "\n//\n"; + + // Change the format to ASCII + if (dict.found(IOobject::foamFile)) + { + dict.subDict(IOobject::foamFile).add + ( + "format", + IOstream::ASCII, + true + ); + } + + dict.dictionary::write(Info, false); + IOobject::writeEndDivider(Info); + + return 0; + } + else + { + changed = true; } - - dict.dictionary::write(Info, false); - IOobject::writeEndDivider(Info); - - return 0; } @@ -635,7 +651,7 @@ int main(int argc, char *argv[]) remove(dict, diffDict); dict.dictionary::write(Info, false); } - else + else if (!args.optionFound("output")) { dict.dictionary::write(Info, false); } @@ -648,7 +664,13 @@ int main(int argc, char *argv[]) } else if (dictPtr) { - OFstream os(args.path()/dictPath, dictFormat); + // Set output dict name, defaults to the name of the input dict + const fileName outputDictPath + ( + args.optionLookupOrDefault("output", dictPath) + ); + + OFstream os(args.path()/outputDictPath, dictFormat); IOobject::writeBanner(os); if (dictPtr->found(IOobject::foamFile)) {