00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. 00006 \\/ M anipulation | 00007 ------------------------------------------------------------------------------- 00008 License 00009 This file is part of OpenFOAM. 00010 00011 OpenFOAM is free software: you can redistribute it and/or modify it 00012 under the terms of the GNU General Public License as published by 00013 the Free Software Foundation, either version 3 of the License, or 00014 (at your option) any later version. 00015 00016 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00018 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00019 for more details. 00020 00021 You should have received a copy of the GNU General Public License 00022 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. 00023 00024 Application 00025 foamCalc 00026 00027 Description 00028 Generic wrapper for calculating a quantity at each time. 00029 00030 Split into four phases: 00031 1. Intialise 00032 2. Pre-time calculation loop 00033 3. Calculation loop 00034 4. Post-calculation loop 00035 00036 Usage 00037 00038 - foamCalc [OPTIONS] <operation> <fields> 00039 00040 @param <operation> \n 00041 @todo Detailed description of argument. 00042 00043 @param <fields> \n 00044 @todo Detailed description of argument. 00045 00046 @param -noWrite \n 00047 Suppress output to files. 00048 00049 @param -dictionary <dictionary name>\n 00050 Use specified dictionary. 00051 00052 @param -noZero \n 00053 Ignore timestep 0. 00054 00055 @param -constant \n 00056 Include the constant directory. 00057 00058 @param -time <time>\n 00059 Apply only to specific time. 00060 00061 @param -latestTime \n 00062 Only apply to latest time step. 00063 00064 @param -case <dir>\n 00065 Case directory. 00066 00067 @param -parallel \n 00068 Run in parallel. 00069 00070 @param -help \n 00071 Display help message. 00072 00073 @param -doc \n 00074 Display Doxygen API documentation page for this application. 00075 00076 @param -srcDoc \n 00077 Display Doxygen source documentation page for this application. 00078 00079 \*---------------------------------------------------------------------------*/ 00080 00081 #include <OpenFOAM/timeSelector.H> 00082 #include <foamCalcFunctions/calcType.H> 00083 00084 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00085 00086 int main(int argc, char *argv[]) 00087 { 00088 Foam::timeSelector::addOptions(); 00089 Foam::argList::validOptions.insert("noWrite", ""); 00090 Foam::argList::validOptions.insert("dict", "dictionary name"); 00091 Foam::argList::validArgs.append("operation"); 00092 Foam::argList::validArgs.append("field"); 00093 00094 if (argc < 2) 00095 { 00096 FatalError 00097 << "No utility has been supplied" << nl 00098 << exit(FatalError); 00099 } 00100 00101 Foam::argList args(argc, argv, false); 00102 if (!args.checkRootCase()) 00103 { 00104 Foam::FatalError.exit(); 00105 } 00106 # include <OpenFOAM/createTime.H> 00107 Foam::instantList timeDirs = Foam::timeSelector::select0(runTime, args); 00108 # include <OpenFOAM/createMesh.H> 00109 00110 word utilityName = args.additionalArgs()[0]; 00111 00112 Foam::autoPtr<Foam::calcType> utility 00113 ( 00114 calcType::New(utilityName) 00115 ); 00116 00117 utility().tryInit(); 00118 00119 utility().tryPreCalc(args, runTime, mesh); 00120 00121 forAll(timeDirs, timeI) 00122 { 00123 runTime.setTime(timeDirs[timeI], timeI); 00124 00125 Foam::Info<< "Time = " << runTime.timeName() << Foam::endl; 00126 00127 mesh.readUpdate(); 00128 00129 utility().tryCalc(args, runTime, mesh); 00130 00131 Foam::Info<< Foam::endl; 00132 } 00133 00134 utility().tryPostCalc(args, runTime, mesh); 00135 00136 Info<< "End\n" << endl; 00137 00138 return 0; 00139 } 00140 00141 00142 // ************************ vim: set sw=4 sts=4 et: ************************ //