From a4e755c0dc27d8531edfa8e79f12a9aaa1db8f0e Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Sat, 10 Jun 2017 21:34:27 +0100 Subject: [PATCH] Replace foamList utility with -list.* options Provides better context for the available boundary conditions, fvOptions, functionObjects etc. and thus returns only those available to and compatible with the particular application. e.g. pimpleFoam -help Usage: pimpleFoam [OPTIONS] options: -case specify alternate case directory, default is the cwd -listFunctionObjects List functionObjects -listFvOptions List fvOptions -listRegisteredSwitches List switches registered for run-time modification -listScalarBCs List scalar field boundary conditions (fvPatchField) -listSwitches List switches declared in libraries but not set in etc/controlDict -listTurbulenceModels List turbulenceModels -listUnsetSwitches List switches declared in libraries but not set in etc/controlDict -listVectorBCs List vector field boundary conditions (fvPatchField) -noFunctionObjects do not execute functionObjects -parallel run in parallel -postProcess Execute functionObjects only -roots <(dir1 .. dirN)> slave root directories for distributed running -srcDoc display source code in browser -doc display application documentation in browser -help print the usage pimpleFoam listTurbulenceModels pimpleFoam -listTurbulenceModels /*---------------------------------------------------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: dev | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ Build : dev-39c46019e44f Exec : pimpleFoam -listTurbulenceModels Date : Jun 10 2017 Time : 21:37:49 Host : "dm" PID : 675 Case : /home/dm2/henry/OpenFOAM/OpenFOAM-dev nProcs : 1 sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE). SetNaN : Initialising allocated memory to NaN (FOAM_SETNAN). fileModificationChecking : Monitoring run-time modified files using timeStampMaster (fileModificationSkew 10) allowSystemOperations : Allowing user-supplied system call operations // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Turbulence models 3 ( LES RAS laminar ) RAS models 18 ( LRR LamBremhorstKE LaunderSharmaKE LienCubicKE LienLeschziner RNGkEpsilon SSG ShihQuadraticKE SpalartAllmaras kEpsilon kOmega kOmegaSST kOmegaSSTLM kOmegaSSTSAS kkLOmega qZeta realizableKE v2f ) LES models 10 ( DeardorffDiffStress Smagorinsky SpalartAllmarasDDES SpalartAllmarasDES SpalartAllmarasIDDES WALE dynamicKEqn dynamicLagrangian kEqn kOmegaSSTDES ) Further work will be needed to support the -listTurbulenceModels option in multiphase solvers. --- .../miscellaneous/foamList/Make/files | 3 - .../miscellaneous/foamList/Make/options | 98 ------ .../miscellaneous/foamList/foamList.C | 282 ------------------ src/OpenFOAM/global/argList/argList.C | 86 ++++++ src/OpenFOAM/global/argList/argList.H | 17 +- src/OpenFOAM/include/listOptions.H | 52 ++++ src/OpenFOAM/include/listOutput.H | 102 +++++++ src/OpenFOAM/include/setRootCase.H | 4 + 8 files changed, 260 insertions(+), 384 deletions(-) delete mode 100644 applications/utilities/miscellaneous/foamList/Make/files delete mode 100644 applications/utilities/miscellaneous/foamList/Make/options delete mode 100644 applications/utilities/miscellaneous/foamList/foamList.C create mode 100644 src/OpenFOAM/include/listOptions.H create mode 100644 src/OpenFOAM/include/listOutput.H diff --git a/applications/utilities/miscellaneous/foamList/Make/files b/applications/utilities/miscellaneous/foamList/Make/files deleted file mode 100644 index 92bda5e25..000000000 --- a/applications/utilities/miscellaneous/foamList/Make/files +++ /dev/null @@ -1,3 +0,0 @@ -foamList.C - -EXE = $(FOAM_APPBIN)/foamList diff --git a/applications/utilities/miscellaneous/foamList/Make/options b/applications/utilities/miscellaneous/foamList/Make/options deleted file mode 100644 index 96e74a80a..000000000 --- a/applications/utilities/miscellaneous/foamList/Make/options +++ /dev/null @@ -1,98 +0,0 @@ -EXE_INC = \ - -I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \ - -I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \ - -I$(LIB_SRC)/transportModels \ - -I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \ - -I$(LIB_SRC)/transportModels/compressible/lnInclude \ - -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ - -I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \ - -I$(LIB_SRC)/finiteVolume/lnInclude \ - -I$(LIB_SRC)/meshTools/lnInclude - -EXE_LIBS = \ - -lbarotropicCompressibilityModel \ - -lblockMesh \ - -lchemistryModel \ - -lcoalCombustion \ - -lcombustionModels \ - -lcompressibleTransportModels \ - -lcompressibleTurbulenceModels \ - -lconversion \ - -ldecompose \ - -ldecompositionMethods \ - -ldistributed \ - -ldistributionModels \ - -lDPMTurbulenceModels \ - -ldriftFluxRelativeVelocityModels \ - -ldriftFluxTransportModels \ - -lDSMC \ - -ldynamicFvMesh \ - -ldynamicMesh \ - -lengine \ - -lextrudeModel \ - -lfieldFunctionObjects \ - -lfileFormats \ - -lfiniteVolume \ - -lfluidThermophysicalModels \ - -lforces \ - -lfvMotionSolvers \ - -lfvOptions \ - -lgenericPatchFields \ - -limmiscibleIncompressibleTwoPhaseMixture \ - -lincompressibleTransportModels \ - -lincompressibleTurbulenceModels \ - -linterfaceProperties \ - -llagrangianFunctionObjects \ - -llagrangianIntermediate \ - -llagrangian \ - -llagrangianSpray \ - -llagrangianTurbulence \ - -llaminarFlameSpeedModels \ - -lthermophysicalProperties \ - -lmeshTools \ - -lmolecularMeasurements \ - -lmolecule \ - -lODE \ - -lOpenFOAM \ - -lpairPatchAgglomeration \ - -lphaseChangeTwoPhaseMixtures \ - -lpotential \ - -lpyrolysisModels \ - -lradiationModels \ - -lrandomProcesses \ - -lreactingEulerianInterfacialCompositionModels \ - -lreactingEulerianInterfacialModels \ - -lreactingPhaseSystem \ - -lreactingTwoPhaseSystem \ - -lreactionThermophysicalModels \ - -lreconstruct \ - -lregionCoupled \ - -lregionCoupling \ - -lregionModels \ - -lrenumberMethods \ - -lrhoCentralFoam \ - -lrigidBodyDynamics \ - -lrigidBodyMeshMotion \ - -lsampling \ - -lscotchDecomp \ - -lsixDoFRigidBodyMotion \ - -lSLGThermo \ - -lsnappyHexMesh \ - -lsolidChemistryModel \ - -lsolidParticle \ - -lsolidSpecie \ - -lsolidThermo \ - -lsolverFunctionObjects \ - -lspecie \ - -lsurfaceFilmDerivedFvPatchFields \ - -lsurfaceFilmModels \ - -lsurfMesh \ - -lthermalBaffleModels \ - -ltopoChangerFvMesh \ - -ltriSurface \ - -lturbulenceModels \ - -ltwoPhaseMixture \ - -ltwoPhaseMixtureThermo \ - -ltwoPhaseProperties \ - -ltwoPhaseReactingTurbulenceModels \ - -lutilityFunctionObjects diff --git a/applications/utilities/miscellaneous/foamList/foamList.C b/applications/utilities/miscellaneous/foamList/foamList.C deleted file mode 100644 index 5ad9c0218..000000000 --- a/applications/utilities/miscellaneous/foamList/foamList.C +++ /dev/null @@ -1,282 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -Application - foamList - -Description - Print the table of contents of selectable switches, classes etc. in the - OpenFOAM libraries - -Usage - \b foamList [OPTION] - - Options: - - \par -switches - Print the DebugSwitches, InfoSwitches and OptimisationSwitches - - - \par -registeredSwitches - Print the registered DebugSwitches, InfoSwitches and - OptimisationSwitches supporting run-time modification - - - \par -unset - print switches declared in libraries but not set in etc/controlDict - -\*---------------------------------------------------------------------------*/ - -#include "argList.H" -#include "dictionary.H" -#include "simpleObjectRegistry.H" -#include "IFstream.H" -#include "IOobject.H" -#include "HashSet.H" -#include "etcFiles.H" -#include "fvPatchField.H" -#include "functionObject.H" -#include "fvOption.H" -#include "turbulentTransportModel.H" -#include "turbulentFluidThermoModel.H" - -using namespace Foam; - -void listSwitches -( - const wordList& debugSwitches, - const wordList& infoSwitches, - const wordList& optSwitches, - const bool unset -) -{ - if (unset) - { - fileNameList controlDictFiles = findEtcFiles("controlDict", true); - dictionary controlDict; - forAllReverse(controlDictFiles, cdfi) - { - controlDict.merge(dictionary(IFstream(controlDictFiles[cdfi])())); - } - - wordHashSet controlDictDebug - ( - controlDict.subDict("DebugSwitches").sortedToc() - ); - - wordHashSet controlDictInfo - ( - controlDict.subDict("InfoSwitches").sortedToc() - ); - - wordHashSet controlDictOpt - ( - controlDict.subDict("OptimisationSwitches").sortedToc() - ); - - - IOobject::writeDivider(Info); - - wordHashSet hashset; - hashset = debugSwitches; - hashset -= controlDictDebug; - Info<< "Unset DebugSwitches" << hashset.sortedToc() << endl; - - hashset = infoSwitches; - hashset -= controlDictInfo; - Info<< "Unset InfoSwitches" << hashset.sortedToc() << endl; - - hashset = optSwitches; - hashset -= controlDictOpt; - Info<< "Unset OptimisationSwitches" << hashset.sortedToc() << endl; - } - else - { - IOobject::writeDivider(Info); - Info<< "DebugSwitches" << debugSwitches << endl; - Info<< "InfoSwitches" << infoSwitches << endl; - Info<< "OptimisationSwitches" << optSwitches << endl; - } -} - - -void listSwitches(const argList& args) -{ - if (args.optionFound("registeredSwitches")) - { - listSwitches - ( - debug::debugObjects().sortedToc(), - debug::infoObjects().sortedToc(), - debug::optimisationObjects().sortedToc(), - args.optionFound("unset") - ); - } - else - { - listSwitches - ( - debug::debugSwitches().sortedToc(), - debug::infoSwitches().sortedToc(), - debug::optimisationSwitches().sortedToc(), - args.optionFound("unset") - ); - } -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -int main(int argc, char *argv[]) -{ - argList::noParallel(); - argList::addBoolOption - ( - "switches", - "List switches declared in libraries but not set in etc/controlDict" - ); - argList::addBoolOption - ( - "registeredSwitches", - "List switches registered for run-time modification" - ); - argList::addBoolOption - ( - "unset", - "List switches declared in libraries but not set in etc/controlDict" - ); - argList::addBoolOption - ( - "scalarBCs", - "List scalar field boundary conditions (fvPatchField)" - ); - argList::addBoolOption - ( - "vectorBCs", - "List vector field boundary conditions (fvPatchField)" - ); - argList::addBoolOption - ( - "functionObjects", - "List functionObjects" - ); - argList::addBoolOption - ( - "fvOptions", - "List fvOptions" - ); - argList::addBoolOption - ( - "incompressibleTurbulenceModels", - "List incompressible turbulenceModels" - ); - argList::addBoolOption - ( - "compressibleTurbulenceModels", - "List compressible turbulenceModels" - ); - - argList args(argc, argv); - - if (!args.options().size()) - { - args.printUsage(); - return 0; - } - - if - ( - args.optionFound("switches") - || args.optionFound("registeredSwitches") - ) - { - listSwitches(args); - } - - if (args.optionFound("scalarBCs")) - { - Info<< "scalarBCs" - << fvPatchField::dictionaryConstructorTablePtr_->sortedToc() - << endl; - } - - if (args.optionFound("vectorBCs")) - { - Info<< "vectorBCs" - << fvPatchField::dictionaryConstructorTablePtr_->sortedToc() - << endl; - } - - if (args.optionFound("functionObjects")) - { - Info<< "functionObjects" - << functionObject::dictionaryConstructorTablePtr_->sortedToc() - << endl; - } - - if (args.optionFound("fvOptions")) - { - Info<< "fvOptions" - << fv::option::dictionaryConstructorTablePtr_->sortedToc() - << endl; - } - - if (args.optionFound("incompressibleTurbulenceModels")) - { - Info<< "Turbulence models" - << incompressible::turbulenceModel:: - dictionaryConstructorTablePtr_->sortedToc() - << endl; - - Info<< "RAS models" - << incompressible::RASModel:: - dictionaryConstructorTablePtr_->sortedToc() - << endl; - - Info<< "LES models" - << incompressible::LESModel:: - dictionaryConstructorTablePtr_->sortedToc() - << endl; - } - - if (args.optionFound("compressibleTurbulenceModels")) - { - Info<< "Turbulence models" - << compressible::turbulenceModel:: - dictionaryConstructorTablePtr_->sortedToc() - << endl; - - Info<< "RAS models" - << compressible::RASModel:: - dictionaryConstructorTablePtr_->sortedToc() - << endl; - - Info<< "LES models" - << compressible::LESModel:: - dictionaryConstructorTablePtr_->sortedToc() - << endl; - } - - - return 0; -} - - -// ************************************************************************* // diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C index c28814f59..2c8fba02f 100644 --- a/src/OpenFOAM/global/argList/argList.C +++ b/src/OpenFOAM/global/argList/argList.C @@ -34,6 +34,10 @@ License #include "regIOobject.H" #include "dynamicCode.H" +#include "simpleObjectRegistry.H" +#include "HashSet.H" +#include "etcFiles.H" + #include // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -1207,6 +1211,88 @@ void Foam::argList::displayDoc(bool source) const } +void Foam::argList::listSwitches +( + const wordList& debugSwitches, + const wordList& infoSwitches, + const wordList& optSwitches, + const bool unset +) +{ + if (unset) + { + fileNameList controlDictFiles = findEtcFiles("controlDict", true); + dictionary controlDict; + forAllReverse(controlDictFiles, cdfi) + { + controlDict.merge(dictionary(IFstream(controlDictFiles[cdfi])())); + } + + wordHashSet controlDictDebug + ( + controlDict.subDict("DebugSwitches").sortedToc() + ); + + wordHashSet controlDictInfo + ( + controlDict.subDict("InfoSwitches").sortedToc() + ); + + wordHashSet controlDictOpt + ( + controlDict.subDict("OptimisationSwitches").sortedToc() + ); + + + IOobject::writeDivider(Info); + + wordHashSet hashset; + hashset = debugSwitches; + hashset -= controlDictDebug; + Info<< "Unset DebugSwitches" << hashset.sortedToc() << endl; + + hashset = infoSwitches; + hashset -= controlDictInfo; + Info<< "Unset InfoSwitches" << hashset.sortedToc() << endl; + + hashset = optSwitches; + hashset -= controlDictOpt; + Info<< "Unset OptimisationSwitches" << hashset.sortedToc() << endl; + } + else + { + IOobject::writeDivider(Info); + Info<< "DebugSwitches" << debugSwitches << endl; + Info<< "InfoSwitches" << infoSwitches << endl; + Info<< "OptimisationSwitches" << optSwitches << endl; + } +} + + +void Foam::argList::listSwitches(const bool unset) const +{ + listSwitches + ( + debug::debugSwitches().sortedToc(), + debug::infoSwitches().sortedToc(), + debug::optimisationSwitches().sortedToc(), + unset + ); +} + + +void Foam::argList::listRegisteredSwitches(const bool unset) const +{ + listSwitches + ( + debug::debugObjects().sortedToc(), + debug::infoObjects().sortedToc(), + debug::optimisationObjects().sortedToc(), + unset + ); +} + + bool Foam::argList::check(bool checkArgs, bool checkOpts) const { bool ok = true; diff --git a/src/OpenFOAM/global/argList/argList.H b/src/OpenFOAM/global/argList/argList.H index cdbf34bf3..ba1e27109 100644 --- a/src/OpenFOAM/global/argList/argList.H +++ b/src/OpenFOAM/global/argList/argList.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -146,6 +146,15 @@ class argList // return true if any "(" ... ")" sequences were captured bool regroupArgv(int& argc, char**& argv); + //- List debug switches + static void listSwitches + ( + const wordList& debugSwitches, + const wordList& infoSwitches, + const wordList& optSwitches, + const bool unset + ); + public: @@ -390,6 +399,12 @@ public: // Optionally display the application source code void displayDoc(bool source=false) const; + //- List debug switches + void listSwitches(const bool unset) const; + + //- List registered debug switches + void listRegisteredSwitches(const bool unset) const; + // Check diff --git a/src/OpenFOAM/include/listOptions.H b/src/OpenFOAM/include/listOptions.H new file mode 100644 index 000000000..49131de76 --- /dev/null +++ b/src/OpenFOAM/include/listOptions.H @@ -0,0 +1,52 @@ +argList::addBoolOption +( + "listSwitches", + "List switches declared in libraries but not set in etc/controlDict" +); +argList::addBoolOption +( + "listRegisteredSwitches", + "List switches registered for run-time modification" +); +argList::addBoolOption +( + "listUnsetSwitches", + "List switches declared in libraries but not set in etc/controlDict" +); + +#ifdef fvPatchField_H +argList::addBoolOption +( + "listScalarBCs", + "List scalar field boundary conditions (fvPatchField)" +); +argList::addBoolOption +( + "listVectorBCs", + "List vector field boundary conditions (fvPatchField)" +); +#endif + +#ifdef functionObject_H +argList::addBoolOption +( + "listFunctionObjects", + "List functionObjects" +); +#endif + +#ifdef fvOption_H +argList::addBoolOption +( + "listFvOptions", + "List fvOptions" +); +#endif + +#if defined(turbulentTransportModel_H) || defined(turbulentFluidThermoModel_H) +argList::addBoolOption +( + "listTurbulenceModels", + "List turbulenceModels" +); +#endif diff --git a/src/OpenFOAM/include/listOutput.H b/src/OpenFOAM/include/listOutput.H new file mode 100644 index 000000000..ca852a6b6 --- /dev/null +++ b/src/OpenFOAM/include/listOutput.H @@ -0,0 +1,102 @@ +bool listOptions = false ; + +if +( + args.optionFound("listSwitches") +) +{ + args.listSwitches(args.optionFound("includeUnsetSwitches")); + listOptions = true; +} + +if +( + args.optionFound("listRegisteredSwitches") +) +{ + args.listRegisteredSwitches(args.optionFound("includeUnsetSwitches")); + listOptions = true; +} + +#ifdef fvPatchField_H +if (args.optionFound("listScalarBCs")) +{ + Info<< "scalarBCs" + << fvPatchField::dictionaryConstructorTablePtr_->sortedToc() + << endl; + listOptions = true; +} + +if (args.optionFound("listVectorBCs")) +{ + Info<< "vectorBCs" + << fvPatchField::dictionaryConstructorTablePtr_->sortedToc() + << endl; + listOptions = true; +} +#endif + +#ifdef functionObject_H +if (args.optionFound("listFunctionObjects")) +{ + Info<< "functionObjects" + << functionObject::dictionaryConstructorTablePtr_->sortedToc() + << endl; + listOptions = true; +} +#endif + +#ifdef fvOption_H +if (args.optionFound("listFvOptions")) +{ + Info<< "fvOptions" + << fv::option::dictionaryConstructorTablePtr_->sortedToc() + << endl; + listOptions = true; +} +#endif + +#ifdef turbulentTransportModel_H +if (args.optionFound("listTurbulenceModels")) +{ + Info<< "Turbulence models" + << incompressible::turbulenceModel:: + dictionaryConstructorTablePtr_->sortedToc() + << endl; + + Info<< "RAS models" + << incompressible::RASModel:: + dictionaryConstructorTablePtr_->sortedToc() + << endl; + + Info<< "LES models" + << incompressible::LESModel:: + dictionaryConstructorTablePtr_->sortedToc() + << endl; + listOptions = true; +} +#elif defined(turbulentFluidThermoModel_H) +if (args.optionFound("listTurbulenceModels")) +{ + Info<< "Turbulence models" + << compressible::turbulenceModel:: + dictionaryConstructorTablePtr_->sortedToc() + << endl; + + Info<< "RAS models" + << compressible::RASModel:: + dictionaryConstructorTablePtr_->sortedToc() + << endl; + + Info<< "LES models" + << compressible::LESModel:: + dictionaryConstructorTablePtr_->sortedToc() + << endl; + listOptions = true; +} +#endif + +if (listOptions) +{ + exit(0); +} diff --git a/src/OpenFOAM/include/setRootCase.H b/src/OpenFOAM/include/setRootCase.H index e1b76cfe6..270d92235 100644 --- a/src/OpenFOAM/include/setRootCase.H +++ b/src/OpenFOAM/include/setRootCase.H @@ -1,5 +1,9 @@ +#include "listOptions.H" + Foam::argList args(argc, argv); if (!args.checkRootCase()) { Foam::FatalError.exit(); } + +#include "listOutput.H"