int main(int argc, char *argv[]) { # include "addRegionOption.H" # include "addLoadFunctionPlugins.H" argList::validOptions.insert("overwrite", ""); argList::validOptions.insert("expression","expression to write"); argList::validOptions.insert("dictExt","Extension to the dictionary"); argList::validOptions.insert("relative", ""); argList::validOptions.insert("allowFunctionObjects",""); # include "setRootCase.H" printSwakVersion(); # include "createTime.H" Foam::instantList timeDirs = Foam::timeSelector::select0(runTime, args); # include "createNamedMesh.H" # include "loadFunctionPlugins.H" if(!args.options().found("allowFunctionObjects")) { runTime.functionObjects().off(); } else { runTime.functionObjects().start(); } const word oldInstance = mesh.pointsInstance(); bool overwrite = args.optionFound("overwrite"); bool relative = false; pointField newPoints; if (!overwrite) { runTime++; } if(args.optionFound("expression")) { if(args.optionFound("dictExt")) { FatalErrorIn(args.executable()) << "Can't specify 'dictExt' and 'expression' at the same time" << endl << exit(FatalError); } relative=args.optionFound("relative"); exprString expression( args.options()["expression"], dictionary::null ); FieldValueExpressionDriver driver( runTime.timeName(), runTime, mesh ); // no clearVariables needed here driver.parse(expression); if(!driver.resultIsTyp<pointVectorField>()) { FatalErrorIn(args.executable()) << "Expression " << expression << " does not evaluate to a pointVectorField but a " << driver.typ() << endl << exit(FatalError); } newPoints=driver.getResult<pointVectorField>().internalField(); } else { Info << "Dictionary mode" << nl << endl; if(args.optionFound("relative")) { FatalErrorIn(args.executable()) << "Option 'relative' not allowed in dictionary-mode" << endl << exit(FatalError); } word dictName("funkyWarpMeshDict"); if(args.optionFound("dictExt")) { dictName+="."+word(args.options()["dictExt"]); } IOdictionary warpDict ( IOobject ( dictName, runTime.system(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE ) ); const word mode(warpDict.lookup("mode")); if(mode=="set") { relative=readBool(warpDict.lookup("relative")); exprString expression( warpDict.lookup("expression"), warpDict ); FieldValueExpressionDriver driver( runTime.timeName(), runTime, mesh ); driver.readVariablesAndTables(warpDict); driver.clearVariables(); driver.parse(expression); if(!driver.resultIsTyp<pointVectorField>()) { FatalErrorIn(args.executable()) << "Expression " << expression << " does not evaluate to a pointVectorField but a " << driver.typ() << endl << exit(FatalError); } newPoints=driver.getResult<pointVectorField>().internalField(); } else if (mode=="move") { notImplemented(args.executable()+" mode: move"); } else { FatalErrorIn(args.executable()) << "Possible values for 'mode' are 'set' or 'move'" << endl << exit(FatalError); } } if(relative) { newPoints += mesh.points(); } mesh.movePoints(newPoints); // Write mesh if (overwrite) { mesh.setInstance(oldInstance); } Info << nl << "Writing polyMesh to time " << runTime.timeName() << endl; IOstream::defaultPrecision(15); // Bypass runTime write (since only writes at outputTime) if ( !runTime.objectRegistry::writeObject ( runTime.writeFormat(), IOstream::currentVersion, runTime.writeCompression() #ifdef FOAM_REGIOOBJECT_WRITEOBJECT_WITH_VALID ,true #endif ) ) { FatalErrorIn(args.executable()) << "Failed writing polyMesh." << exit(FatalError); } // Write points goes here // Write fields runTime.write(); Info << "End\n" << endl; Info << nl << "Now run 'checkMesh' before you do anything else" << nl << endl; return 0; }
int main(int argc, char *argv[]) { Foam::timeSelector::addOptions(false); Foam::argList::validArgs.append("expressionDict"); # include "addRegionOption.H" argList::validOptions.insert("noDimensionChecking",""); argList::validOptions.insert("foreignMeshesThatFollowTime", "<list of mesh names>"); # include "setRootCase.H" printSwakVersion(); IFstream theFile(args.args()[1]); dictionary theExpressions(theFile); wordList foreignMeshesThatFollowTime(0); if (!args.options().found("time") && !args.options().found("latestTime")) { FatalErrorIn("main()") << args.executable() << ": time/latestTime option is required" << endl << exit(FatalError); } if(args.options().found("noDimensionChecking")) { dimensionSet::debug=0; } if(args.options().found("foreignMeshesThatFollowTime")) { string followMeshes( args.options()["foreignMeshesThatFollowTime"] ); IStringStream followStream("("+followMeshes+")"); foreignMeshesThatFollowTime=wordList(followStream); } # include "createTime.H" Foam::instantList timeDirs = Foam::timeSelector::select0(runTime, args); # include "createNamedMesh.H" forAllConstIter(IDLList<entry>, theExpressions, iter) { const dictionary &dict=iter().dict(); CommonValueExpressionDriver::readForeignMeshInfo(dict); } forAll(timeDirs, timeI) { runTime.setTime(timeDirs[timeI], timeI); Foam::Info << "\nTime = " << runTime.timeName() << Foam::endl; mesh.readUpdate(); forAll(foreignMeshesThatFollowTime,i) { const word &name=foreignMeshesThatFollowTime[i]; if(MeshesRepository::getRepository().hasMesh(name)) { Info << "Setting mesh " << name << " to current Time" << endl; MeshesRepository::getRepository().setTime( name, runTime.value() ); } else { FatalErrorIn(args.executable()) << "No mesh with name " << name << " declared. " << nl << "Can't follow current time" << endl << exit(FatalError); } } forAllConstIter(IDLList<entry>, theExpressions, iter) { Info << iter().keyword() << " : " << flush; const dictionary &dict=iter().dict(); autoPtr<CommonValueExpressionDriver> driver= CommonValueExpressionDriver::New(dict,mesh); wordList accumulations(dict.lookup("accumulations")); driver->setSearchBehaviour( true, true, true // search on disc ); driver->clearVariables(); driver->parse(string(dict.lookup("expression"))); word rType=driver->CommonValueExpressionDriver::getResultType(); if(rType==pTraits<scalar>::typeName) { writeData<scalar>(driver(),accumulations); } else if(rType==pTraits<vector>::typeName) { writeData<vector>(driver(),accumulations); } else if(rType==pTraits<tensor>::typeName) { writeData<tensor>(driver(),accumulations); } else if(rType==pTraits<symmTensor>::typeName) { writeData<symmTensor>(driver(),accumulations); } else if(rType==pTraits<sphericalTensor>::typeName) { writeData<sphericalTensor>(driver(),accumulations); } else { WarningIn(args.executable()) << "Don't know how to handle type " << rType << endl; } Info << endl; }