foamInfoExec.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "argList.H"
00031 #include "Time.H"
00032 #include "dictionary.H"
00033 #include "IFstream.H"
00034
00035 using namespace Foam;
00036
00037
00038
00039
00040 int main(int argc, char *argv[])
00041 {
00042 argList::noParallel();
00043 argList::validOptions.insert("times", "");
00044 argList::validOptions.insert("dictionary", "dictionary name");
00045 argList::validOptions.insert("keywords", "");
00046 argList::validOptions.insert("entry", "entry name");
00047
00048 # include "setRootCase.H"
00049
00050 Info<< endl;
00051
00052 if (args.optionFound("times"))
00053 {
00054 instantList times
00055 (
00056 Foam::Time::findTimes(args.rootPath()/args.caseName())
00057 );
00058
00059 forAll (times, i)
00060 {
00061 Info<< times[i].name() << endl;
00062 }
00063 }
00064
00065 if (args.optionFound("dictionary"))
00066 {
00067 fileName dictFileName
00068 (
00069 args.rootPath()/args.caseName()/args.option("dictionary")
00070 );
00071
00072 IFstream dictFile(dictFileName);
00073
00074 if (dictFile.good())
00075 {
00076 dictionary dict(dictFile);
00077
00078 if (args.optionFound("keywords") && !args.optionFound("entry"))
00079 {
00080 for
00081 (
00082 IDLList<entry>::iterator iter = dict.begin();
00083 iter != dict.end();
00084 ++iter
00085 )
00086 {
00087 Info<< iter().keyword() << endl;
00088 }
00089 }
00090 else if (args.optionFound("entry"))
00091 {
00092 wordList entryNames
00093 (
00094 fileName(args.option("entry")).components(':')
00095 );
00096
00097 if (dict.found(entryNames[0]))
00098 {
00099 const entry* entPtr = &dict.lookupEntry
00100 (
00101 entryNames[0],
00102 false,
00103 true
00104 );
00105
00106 for (int i=1; i<entryNames.size(); i++)
00107 {
00108 if (entPtr->dict().found(entryNames[i]))
00109 {
00110 entPtr = &entPtr->dict().lookupEntry
00111 (
00112 entryNames[i],
00113 false,
00114 true
00115 );
00116 }
00117 else
00118 {
00119 FatalErrorIn(args.executable())
00120 << "Cannot find sub-entry " << entryNames[i]
00121 << " in entry " << args.option("entry")
00122 << " in dictionary " << dictFileName;
00123 FatalError.exit(3);
00124 }
00125 }
00126
00127 if (args.optionFound("keywords"))
00128 {
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141 const dictionary& dict(entPtr->dict());
00142 for
00143 (
00144 IDLList<entry>::const_iterator iter = dict.begin();
00145 iter != dict.end();
00146 ++iter
00147 )
00148 {
00149 Info<< iter().keyword() << endl;
00150 }
00151 }
00152 else
00153 {
00154 Info<< *entPtr << endl;
00155 }
00156 }
00157 else
00158 {
00159 FatalErrorIn(args.executable())
00160 << "Cannot find entry "
00161 << entryNames[0]
00162 << " in dictionary " << dictFileName;
00163 FatalError.exit(2);
00164 }
00165 }
00166 else
00167 {
00168 Info<< dict;
00169 }
00170 }
00171 else
00172 {
00173 FatalErrorIn(args.executable())
00174 << "Cannot open file " << dictFileName;
00175 FatalError.exit(1);
00176 }
00177 }
00178
00179 return 0;
00180 }
00181
00182
00183
Copyright © 2000-2009 OpenCFD Ltd