diff --git a/applications/solvers/lagrangian/reactingParcelFoam/LTSReactingParcelFoam/LTSReactingParcelFoam.C b/applications/solvers/lagrangian/reactingParcelFoam/LTSReactingParcelFoam/LTSReactingParcelFoam.C index 0841d458b4..fabb0bba60 100644 --- a/applications/solvers/lagrangian/reactingParcelFoam/LTSReactingParcelFoam/LTSReactingParcelFoam.C +++ b/applications/solvers/lagrangian/reactingParcelFoam/LTSReactingParcelFoam/LTSReactingParcelFoam.C @@ -59,7 +59,6 @@ int main(int argc, char *argv[]) pimpleControl pimple(mesh); #include "readTimeControls.H" - #include "readAdditionalSolutionControls.H" #include "createFields.H" #include "createRDeltaT.H" #include "createRadiationModel.H" @@ -74,7 +73,6 @@ int main(int argc, char *argv[]) while (runTime.run()) { - #include "readAdditionalSolutionControls.H" #include "readTimeControls.H" runTime++; diff --git a/applications/solvers/lagrangian/reactingParcelFoam/YEqn.H b/applications/solvers/lagrangian/reactingParcelFoam/YEqn.H index 8ef6c610dd..a22267d9be 100644 --- a/applications/solvers/lagrangian/reactingParcelFoam/YEqn.H +++ b/applications/solvers/lagrangian/reactingParcelFoam/YEqn.H @@ -9,11 +9,9 @@ tmp > mvConvection ) ); -combustion->correct(); -dQ = combustion->dQ(); - -if (solveSpecies) { + combustion->correct(); + dQ = combustion->dQ(); label inertIndex = -1; volScalarField Yt(0.0*Y[0]); diff --git a/applications/solvers/lagrangian/reactingParcelFoam/reactingParcelFoam.C b/applications/solvers/lagrangian/reactingParcelFoam/reactingParcelFoam.C index d1c735f658..8ef6838c59 100644 --- a/applications/solvers/lagrangian/reactingParcelFoam/reactingParcelFoam.C +++ b/applications/solvers/lagrangian/reactingParcelFoam/reactingParcelFoam.C @@ -78,7 +78,6 @@ int main(int argc, char *argv[]) while (runTime.run()) { #include "readTimeControls.H" - #include "readAdditionalSolutionControls.H" #include "compressibleCourantNo.H" #include "setDeltaT.H" diff --git a/applications/solvers/lagrangian/reactingParcelFoam/readAdditionalSolutionControls.H b/applications/solvers/lagrangian/reactingParcelFoam/readAdditionalSolutionControls.H deleted file mode 100644 index d04dfc406d..0000000000 --- a/applications/solvers/lagrangian/reactingParcelFoam/readAdditionalSolutionControls.H +++ /dev/null @@ -1,4 +0,0 @@ -dictionary additional = mesh.solutionDict().subDict("additional"); - -// flag to activate solve transport for each specie (Y vector) -bool solveSpecies = additional.lookupOrDefault("solveSpecies", true); diff --git a/applications/solvers/lagrangian/sprayFoam/sprayEngineFoam/sprayEngineFoam.C b/applications/solvers/lagrangian/sprayFoam/sprayEngineFoam/sprayEngineFoam.C index 06ed6e1c2b..1b4f46289f 100644 --- a/applications/solvers/lagrangian/sprayFoam/sprayEngineFoam/sprayEngineFoam.C +++ b/applications/solvers/lagrangian/sprayFoam/sprayEngineFoam/sprayEngineFoam.C @@ -60,7 +60,6 @@ int main(int argc, char *argv[]) #include "startSummary.H" pimpleControl pimple(mesh); - bool solveSpecies = true; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/solvers/lagrangian/sprayFoam/sprayFoam.C b/applications/solvers/lagrangian/sprayFoam/sprayFoam.C index 78713032f3..02739bda71 100644 --- a/applications/solvers/lagrangian/sprayFoam/sprayFoam.C +++ b/applications/solvers/lagrangian/sprayFoam/sprayFoam.C @@ -57,7 +57,6 @@ int main(int argc, char *argv[]) #include "setInitialDeltaT.H" pimpleControl pimple(mesh); - bool solveSpecies = true; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/utilities/miscellaneous/foamHelp/Allwmake b/applications/utilities/miscellaneous/foamHelp/Allwmake new file mode 100755 index 0000000000..4724935b92 --- /dev/null +++ b/applications/utilities/miscellaneous/foamHelp/Allwmake @@ -0,0 +1,8 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # run from this directory + +wmake libso helpTypes +wmake + + +# ----------------------------------------------------------------- end-of-file diff --git a/applications/utilities/miscellaneous/foamHelp/Make/files b/applications/utilities/miscellaneous/foamHelp/Make/files new file mode 100644 index 0000000000..263901fe72 --- /dev/null +++ b/applications/utilities/miscellaneous/foamHelp/Make/files @@ -0,0 +1,3 @@ +foamHelp.C + +EXE = $(FOAM_APPBIN)/foamHelp diff --git a/applications/utilities/miscellaneous/foamHelp/Make/options b/applications/utilities/miscellaneous/foamHelp/Make/options new file mode 100644 index 0000000000..41ca9e9b57 --- /dev/null +++ b/applications/utilities/miscellaneous/foamHelp/Make/options @@ -0,0 +1,15 @@ +EXE_INC = \ + -IhelpTypes/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude + +EXE_LIBS = \ + -lhelpTypes \ + -lfiniteVolume \ + -lincompressibleTurbulenceModel \ + -lcompressibleTurbulenceModel \ + -lincompressibleRASModels \ + -lcompressibleRASModels \ + -lincompressibleLESModels \ + -lcompressibleLESModels \ + -lradiationModels \ + -lfluidThermophysicalModels diff --git a/applications/utilities/miscellaneous/foamHelp/foamHelp.C b/applications/utilities/miscellaneous/foamHelp/foamHelp.C new file mode 100644 index 0000000000..39e0cb9130 --- /dev/null +++ b/applications/utilities/miscellaneous/foamHelp/foamHelp.C @@ -0,0 +1,68 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 + foamHelp + +Description + Top level wrapper utility around foam help utilities + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "helpType.H" + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + #include "addRegionOption.H" + if (argc < 2) + { + FatalError + << "No help utility has been supplied" << nl + << exit(FatalError); + } + + const word utilityName = argv[1]; + + Foam::autoPtr utility + ( + helpType::New(utilityName) + ); + + utility().init(); + + #include "setRootCase.H" + #include "createTime.H" + #include "createNamedMesh.H" + + utility().execute(args, mesh); + + Info<< "End\n" << endl; +} + + +// ************************************************************************* // diff --git a/applications/utilities/miscellaneous/foamHelp/helpTypes/Make/files b/applications/utilities/miscellaneous/foamHelp/helpTypes/Make/files new file mode 100644 index 0000000000..1f7de8d62e --- /dev/null +++ b/applications/utilities/miscellaneous/foamHelp/helpTypes/Make/files @@ -0,0 +1,8 @@ +helpType/helpType.C +helpType/helpTypeNew.C +helpBoundary/helpBoundary.C +helpFunctionObject/helpFunctionObject.C + +doxygenXmlParser/doxygenXmlParser.C + +LIB = $(FOAM_LIBBIN)/libhelpTypes diff --git a/applications/utilities/miscellaneous/foamHelp/helpTypes/Make/options b/applications/utilities/miscellaneous/foamHelp/helpTypes/Make/options new file mode 100644 index 0000000000..1c130c5eb1 --- /dev/null +++ b/applications/utilities/miscellaneous/foamHelp/helpTypes/Make/options @@ -0,0 +1,13 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude + +EXE_LIBS = \ + -lfiniteVolume \ + -lincompressibleTurbulenceModel \ + -lcompressibleTurbulenceModel \ + -lincompressibleRASModels \ + -lcompressibleRASModels \ + -lincompressibleLESModels \ + -lcompressibleLESModels \ + -lradiationModels \ + -lbasicThermophysicalModels diff --git a/applications/utilities/miscellaneous/foamHelp/helpTypes/doxygenXmlParser/doxygenXmlParser.C b/applications/utilities/miscellaneous/foamHelp/helpTypes/doxygenXmlParser/doxygenXmlParser.C new file mode 100644 index 0000000000..acf9a72d24 --- /dev/null +++ b/applications/utilities/miscellaneous/foamHelp/helpTypes/doxygenXmlParser/doxygenXmlParser.C @@ -0,0 +1,246 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 . + +\*---------------------------------------------------------------------------*/ + +#include "doxygenXmlParser.H" +#include "wordRe.H" + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::doxygenXmlParser::doxygenXmlParser +( + const fileName& fName, + const string& startTag, + const string& searchStr, + const bool exactMatch +) +: + dictionary(dictionary::null) +{ + IFstream is(fName); + + char c; + + // skip forward to entry name + skipForward(is, startTag); + + while (is.get(c)) + { + if (c == '<') + { + // if in block, read block name + string blockName = ""; + string params = ""; + bool readingParam = false; + while (is.get(c) && c != '>') + { + if (c == ' ') + { + readingParam = true; + } + else + { + if (readingParam) + { + params = params + c; + } + else + { + blockName = blockName + c; + } + } + } + + if (blockName == '/' + startTag) + { + break; + } + + if ((blockName == "compound") && (params == "kind=\"file\"")) + { + // keep entry + word name = ""; + fileName path = ""; + word fName = ""; + bool foundName = false; + bool foundPath = false; + bool foundFName = false; + bool earlyExit = false; + while (!foundName || !foundPath || !foundFName) + { + word entryName; + getEntry(is, entryName); + if (entryName == "name") + { + getValue(is, name); + if (wordRe(".*.H", wordRe::DETECT).match(name)) + { + foundName = true; + } + else + { + // not interested in this compound + break; + } + } + else if (entryName == "path") + { + getValue(is, path); + + // filter path on regExp + if (wordRe(searchStr, wordRe::DETECT).match(path)) + { + foundPath = true; + } + else + { + // not interested in this compound + break; + } + } + else if (entryName == "filename") + { + getValue(is, fName); + foundFName = true; + } + else + { + skipBlock(is, entryName); + } + } + + if (foundPath && !earlyExit) + { + word tName(path.components().last()); + + // only insert if type is not already known + // NOTE: not ideal for cases where there are multiple types + // but contained within different namespaces + // preferentially take exact match if it exists + if (exactMatch && (tName + ".H") == name) + { + dictionary dict(dictionary::null); + dict.add("name", name); + dict.add("filename", fName + ".html"); + dict.add("path", path); + this->add(tName, dict); + } + else if + ( + !exactMatch + && !found(tName) + && wordRe(".*" + tName + ".*", wordRe::DETECT).match(name) + ) + { + dictionary dict(dictionary::null); + dict.add("name", name); + dict.add("filename", fName + ".html"); + dict.add("path", path); + this->add(tName, dict); + } + } + + // skip remanining entries + skipBlock(is, blockName); + } + else + { + skipBlock(is, blockName); + } + } + } +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::doxygenXmlParser::skipBlock(IFstream& is, const word blockName) const +{ + // recurse to move forward in 'is' until come across + + string closeName = ""; + + // fast-forward until we reach a '<' + char c; + while (is.get(c) && c != '<') + {} + + // check to see if this is a closing block + if (is.get(c) && c == '/') + { + while (is.get(c) && c != '>') + { + closeName += c; + } + + if (closeName == blockName) + { + // finished reading block + return; + } + else + { + skipBlock(is, blockName); + } + } + else + { + skipBlock(is, blockName); + } +} + + +void Foam::doxygenXmlParser::skipForward +( + IFstream& is, + const word blockName +) const +{ + // recurse to move forward in 'is' until come across + + // fast-forward until we reach a '<' + char c; + while (is.get(c) && c != '<') + {} + + string entryName = ""; + while (is.get(c) && c != '>') + { + entryName = entryName + c; + } + + if (entryName == blockName) + { + return; + } + else + { + skipForward(is, blockName); + } +} + + +// ************************************************************************* // + diff --git a/applications/utilities/miscellaneous/foamHelp/helpTypes/doxygenXmlParser/doxygenXmlParser.H b/applications/utilities/miscellaneous/foamHelp/helpTypes/doxygenXmlParser/doxygenXmlParser.H new file mode 100644 index 0000000000..f2abdaee8d --- /dev/null +++ b/applications/utilities/miscellaneous/foamHelp/helpTypes/doxygenXmlParser/doxygenXmlParser.H @@ -0,0 +1,97 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 . + +Class + Foam::doxygenXmlParser + +Description + +SourceFiles + +\*---------------------------------------------------------------------------*/ + +#ifndef doxygenXmlParser_H +#define doxygenXmlParser_H + +#include "dictionary.H" +#include "IFstream.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class doxygenXmlParser Declaration +\*---------------------------------------------------------------------------*/ + +class doxygenXmlParser +: + public dictionary +{ + +public: + + //- Construct from components + doxygenXmlParser + ( + const fileName& fName, + const string& startTag, + const string& searchStr, + const bool exactMatch + ); + + + // Member functions + + //- Skip past a block + void skipBlock(IFstream& is, const word blockName) const; + + //- Skip forward to block + void skipForward(IFstream& is, const word blockName) const; + + //- Return the entry + template + void getEntry(IFstream& is, Type& entry) const; + + //- Return the entry value + template + void getValue(IFstream& is, Type& entry) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "doxygenXmlParserTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/utilities/miscellaneous/foamHelp/helpTypes/doxygenXmlParser/doxygenXmlParserTemplates.C b/applications/utilities/miscellaneous/foamHelp/helpTypes/doxygenXmlParser/doxygenXmlParserTemplates.C new file mode 100644 index 0000000000..0ab6632da8 --- /dev/null +++ b/applications/utilities/miscellaneous/foamHelp/helpTypes/doxygenXmlParser/doxygenXmlParserTemplates.C @@ -0,0 +1,67 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 . + +\*---------------------------------------------------------------------------*/ + +#include "doxygenXmlParser.H" + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +void Foam::doxygenXmlParser::getEntry(IFstream& is, Type& entry) const +{ + char c; + while (is.get(c) && c != '<') + {} + + entry = ""; + if (is.get(c) && c == '/') + { + return; + } + else + { + entry = entry + c; + } + + while (is.get(c) && c != '>') + { + entry = entry + c; + } +} + + +template +void Foam::doxygenXmlParser::getValue(IFstream& is, Type& entry) const +{ + char c; + + entry = ""; + while (is.get(c) && c != '<') + { + entry = entry + c; + } +} + + +// ************************************************************************* // diff --git a/applications/utilities/miscellaneous/foamHelp/helpTypes/helpBoundary/helpBoundary.C b/applications/utilities/miscellaneous/foamHelp/helpTypes/helpBoundary/helpBoundary.C new file mode 100644 index 0000000000..9fd46f35c1 --- /dev/null +++ b/applications/utilities/miscellaneous/foamHelp/helpTypes/helpBoundary/helpBoundary.C @@ -0,0 +1,192 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 . + +\*---------------------------------------------------------------------------*/ + +#include "helpBoundary.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + namespace helpTypes + { + defineTypeNameAndDebug(helpBoundary, 0); + addNamedToRunTimeSelectionTable + ( + helpType, + helpBoundary, + dictionary, + boundary + ); + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::helpTypes::helpBoundary::helpBoundary() +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::helpTypes::helpBoundary::~helpBoundary() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::helpTypes::helpBoundary::init() +{ + helpType::init(); + + argList::validArgs.append("boundary"); + + argList::addOption + ( + "field", + "word", + "list available conditions for field" + ); + argList::addBoolOption + ( + "constraint", + "list constraint patches" + ); + argList::addBoolOption + ( + "fixedValue", + "list fixed value patches (use with -field option)" + ); +} + + +void Foam::helpTypes::helpBoundary::execute +( + const argList& args, + const fvMesh& mesh +) +{ + bool abortVar(env("FOAM_ABORT")); + if (abortVar) + { + FatalErrorIn + ( + "void Foam::helpTypes::helpBoundary::execute" + "(" + "const argList&, " + "const fvMesh&" + ")" + ) + << "Please unset FOAM_ABORT to use this utlity" + << exit(FatalError); + } + + word condition(word::null); + word fieldName(word::null); + + if (args.optionReadIfPresent("browse", condition)) + { + // TODO: strip scoping info if present? + // e.g. conditions with leading "compressible::" will not be found + // ".*[fF]vPatchField.*" + className + ".*" + displayDoc(condition, ".*[fF]vPatchField.*", false); + } + else if (args.optionFound("constraint")) + { + HashSet constraintTypes(fvPatch::constraintTypes()); + Info<< "Constraint types:" << nl; + forAllConstIter(HashSet, constraintTypes, iter) + { + Info<< " " << iter.key() << nl; + } + Info<< endl; + } + else if (args.optionReadIfPresent("field", fieldName)) + { + IOobject fieldHeader + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::MUST_READ + ); + + if (fieldHeader.headerOk()) + { + if (args.optionFound("fixedValue")) + { + fixedValueFieldConditions(fieldHeader); + fixedValueFieldConditions(fieldHeader); + fixedValueFieldConditions(fieldHeader); + fixedValueFieldConditions(fieldHeader); + fixedValueFieldConditions(fieldHeader); + } + else + { + (void)fieldConditions(fieldHeader, true); + (void)fieldConditions(fieldHeader, true); + (void)fieldConditions(fieldHeader, true); + (void)fieldConditions(fieldHeader, true); + (void)fieldConditions(fieldHeader, true); + } + } + else + { + FatalErrorIn + ( + "void Foam::helpTypes::helpBoundary::execute" + "(" + "const argList&, " + "const fvMesh&" + ")" + ) + << "Unable to read field " << fieldName << exit(FatalError); + } + } + else if (args.optionReadIfPresent("fixedValue", fieldName)) + { + FatalErrorIn + ( + "void Foam::helpTypes::helpBoundary::execute" + "(" + "const argList&, " + "const fvMesh&" + ")" + ) + << "-field option must be specified when using the -fixedValue " + << "option" << exit(FatalError); + } + else + { + // TODO: strip scoping info if present? + // e.g. conditions with leading "compressible::" will not be found + // ".*[fF]vPatchField.*" + className + ".*" + displayDocOptions(".*[fF]vPatchField.*", false); + } +} + + +// ************************************************************************* // diff --git a/applications/utilities/miscellaneous/foamHelp/helpTypes/helpBoundary/helpBoundary.H b/applications/utilities/miscellaneous/foamHelp/helpTypes/helpBoundary/helpBoundary.H new file mode 100644 index 0000000000..6166e8e1f3 --- /dev/null +++ b/applications/utilities/miscellaneous/foamHelp/helpTypes/helpBoundary/helpBoundary.H @@ -0,0 +1,126 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 . + +Class + Foam::helpBoundary + +Description + This class provides help for boundary conditions (patch fields). When no + additional arguments are given, the utility outputs all known boundary + conditions. + + Usage: + \plaintable + \c -browse \ | open documentation for patch in browser + \c -field \ | boundary conditions for a given field + \c -constraint | list constraint boundary conditions + \c -fixedValue | list \c fixedValue type boundary conditions + \endplaintable + +Note + To use the \c -fixedValue option, the \c -field option should also be used + +SeeAlso + Foam::helpType + Foam::fvPatchField + +SourceFiles + helpBoundary.C + helpBoundaryTemplates.C + +\*---------------------------------------------------------------------------*/ + +#ifndef helpBoundary_H +#define helpBoundary_H + +#include "helpType.H" +#include "IOobject.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace helpTypes +{ + +/*---------------------------------------------------------------------------*\ + Class helpBoundary Declaration +\*---------------------------------------------------------------------------*/ + +class helpBoundary +: + public helpType +{ + +protected: + + // Protected Member Functions + + //- Return/output the available boundary conditions for fields of Type + template + wordList fieldConditions(const IOobject& io, const bool write) const; + + //- Output the available fixed boundary conditions for fields of Type + template + void fixedValueFieldConditions(const IOobject& io) const; + + +public: + + //- Runtime type information + TypeName("helpBoundary"); + + //- Constructor + helpBoundary(); + + //- Destructor + virtual ~helpBoundary(); + + + // Member Functions + + //- Initialise - typically setting static variables, + // e.g. command line arguments + virtual void init(); + + //- Execute the help + virtual void execute(const argList& args, const fvMesh& mesh); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace helpTypes +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "helpBoundaryTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/utilities/miscellaneous/foamHelp/helpTypes/helpBoundary/helpBoundaryTemplates.C b/applications/utilities/miscellaneous/foamHelp/helpTypes/helpBoundary/helpBoundaryTemplates.C new file mode 100644 index 0000000000..f2ce4a0f00 --- /dev/null +++ b/applications/utilities/miscellaneous/foamHelp/helpTypes/helpBoundary/helpBoundaryTemplates.C @@ -0,0 +1,161 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 . + + +\*---------------------------------------------------------------------------*/ + +#include "GeometricField.H" +#include "fvPatchField.H" +#include "volMesh.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template +Foam::wordList Foam::helpTypes::helpBoundary::fieldConditions +( + const IOobject& io, + const bool write +) const +{ + typedef GeometricField fieldType; + + if (io.headerClassName() == fieldType::typeName) + { + wordList types + ( + fvPatchField::dictionaryConstructorTablePtr_->sortedToc() + ); + + if (write) + { + Info<< "Available boundary conditions for " + << pTraits::typeName << " field: " << io.name() << nl; + + forAll(types, i) + { + Info<< " " << types[i] << nl; + } + + Info<< endl; + } + + return types; + } + + return wordList(); +} + + +template +void Foam::helpTypes::helpBoundary::fixedValueFieldConditions +( + const IOobject& io +) const +{ + wordList types(fieldConditions(io, false)); + + if (!types.size()) + { + return; + } + + typedef GeometricField fieldType; + + const fvMesh& mesh = dynamic_cast(io.db()); + + fieldType fld + ( + IOobject + ( + "dummy", + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + mesh, + dimensioned("zero", dimless, pTraits::zero) + ); + + + Info<< "Fixed value boundary conditions for " + << pTraits::typeName << " field: " << io.name() << nl; + + // throw exceptions to avoid fatal errors when casting from generic patch + // type to incompatible patch type + FatalIOError.throwExceptions(); + FatalError.throwExceptions(); + + bool foundFixed = false; + forAll(types, i) + { + const word& patchType = types[i]; + + try + { + polyPatch pp + ( + "defaultFaces", + 0, + mesh.nInternalFaces(), + 0, + mesh.boundaryMesh(), + patchType + ); + + fvPatch fvp(pp, mesh.boundary()); + + tmp > pf + ( + fvPatchField::New + ( + patchType, + fvp, + fld + ) + ); + + if (pf().fixesValue()) + { + Info<< " " << patchType << nl; + foundFixed = true; + } + } + catch (...) + { + // do nothing + } + } + + if (!foundFixed) + { + // no conditions??? + Info<< " none" << nl; + } + + Info<< endl; +} + + +// ************************************************************************* // diff --git a/applications/utilities/miscellaneous/foamHelp/helpTypes/helpFunctionObject/helpFunctionObject.C b/applications/utilities/miscellaneous/foamHelp/helpTypes/helpFunctionObject/helpFunctionObject.C new file mode 100644 index 0000000000..631a1210ff --- /dev/null +++ b/applications/utilities/miscellaneous/foamHelp/helpTypes/helpFunctionObject/helpFunctionObject.C @@ -0,0 +1,88 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 . + +\*---------------------------------------------------------------------------*/ + +#include "helpFunctionObject.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + namespace helpTypes + { + defineTypeNameAndDebug(helpFunctionObject, 0); + addNamedToRunTimeSelectionTable + ( + helpType, + helpFunctionObject, + dictionary, + functionObject + ); + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::helpTypes::helpFunctionObject::helpFunctionObject() +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::helpTypes::helpFunctionObject::~helpFunctionObject() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::helpTypes::helpFunctionObject::init() +{ + helpType::init(); + + argList::validArgs.append("functionObject"); +} + + +void Foam::helpTypes::helpFunctionObject::execute +( + const argList& args, + const fvMesh& mesh +) +{ + word function(word::null); + + if (args.optionReadIfPresent("browse", function)) + { + displayDoc(function, ".*[fF]unctionObject.*", true); + } + else + { + displayDocOptions(".*[fF]unctionObject.*", true); + } +} + + +// ************************************************************************* // diff --git a/applications/utilities/miscellaneous/foamHelp/helpTypes/helpFunctionObject/helpFunctionObject.H b/applications/utilities/miscellaneous/foamHelp/helpTypes/helpFunctionObject/helpFunctionObject.H new file mode 100644 index 0000000000..4e8276bcdb --- /dev/null +++ b/applications/utilities/miscellaneous/foamHelp/helpTypes/helpFunctionObject/helpFunctionObject.H @@ -0,0 +1,98 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 . + +Class + Foam::helpFunctionObject + +Description + This class provides help for functionObjects. When no additional arguments + are given, the utility outputs all known function objects. + + Usage: + \plaintable + \c -browse \ | open documentation for object in browser + \endplaintable + +SeeAlso + Foam::helpType + Foam::functionObject + +SourceFiles + helpFunctionObject.C + +\*---------------------------------------------------------------------------*/ + +#ifndef helpFunctionObject_H +#define helpFunctionObject_H + +#include "helpType.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace helpTypes +{ + +/*---------------------------------------------------------------------------*\ + Class helpFunctionObject Declaration +\*---------------------------------------------------------------------------*/ + +class helpFunctionObject +: + public helpType +{ + +public: + + //- Runtime type information + TypeName("helpFunctionObject"); + + //- Constructor + helpFunctionObject(); + + //- Destructor + virtual ~helpFunctionObject(); + + + // Member Functions + + //- Initialise - typically setting static variables, + // e.g. command line arguments + virtual void init(); + + //- Execute the help + virtual void execute(const argList& args, const fvMesh& mesh); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace helpTypes +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/utilities/miscellaneous/foamHelp/helpTypes/helpType/helpType.C b/applications/utilities/miscellaneous/foamHelp/helpTypes/helpType/helpType.C new file mode 100644 index 0000000000..0b982e76a7 --- /dev/null +++ b/applications/utilities/miscellaneous/foamHelp/helpTypes/helpType/helpType.C @@ -0,0 +1,185 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 . + +\*---------------------------------------------------------------------------*/ + +#include "helpType.H" +#include "doxygenXmlParser.H" +#include "SortableList.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(helpType, 0); + defineRunTimeSelectionTable(helpType, dictionary); +} + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +Foam::fileName Foam::helpType::doxygenPath() const +{ + const dictionary& docDict = debug::controlDict().subDict("Documentation"); + List docDirs(docDict.lookup("doxyDocDirs")); + + label dirI = -1; + forAll(docDirs, i) + { + if (isDir(docDirs[i].expand())) + { + dirI = i; + break; + } + } + + if (dirI == -1) + { + Info<< "No Doxygen sources found under search paths: " + << docDirs << endl; + return fileName(); + } + + return docDirs[dirI]; +} + + +void Foam::helpType::displayDocOptions +( + const string& searchStr, + const bool exactMatch +) const +{ + fileName doxyPath(doxygenPath()); + + if (doxyPath.empty()) + { + return; + } + + Info<< "Found doxygen help in " << doxyPath.c_str() << nl << endl; + + doxygenXmlParser parser + ( + doxyPath/"../DTAGS", + "tagfile", + searchStr, + exactMatch + ); + + Info<< "Valid types include:" << nl << SortableList(parser.toc()); +} + + +void Foam::helpType::displayDoc +( + const word& className, + const string& searchStr, + const bool exactMatch +) const +{ + fileName doxyPath(doxygenPath()); + + if (doxyPath.empty()) + { + return; + } + + Info<< "Found doxygen help in " << doxyPath.c_str() << nl << endl; + + string docBrowser = getEnv("FOAM_DOC_BROWSER"); + if (docBrowser.empty()) + { + const dictionary& docDict = + debug::controlDict().subDict("Documentation"); + docDict.lookup("docBrowser") >> docBrowser; + } + + doxygenXmlParser parser + ( + doxyPath/"../DTAGS", + "tagfile", + searchStr, + exactMatch + ); + + if (debug) + { + Info<< parser; + } + + if (parser.found(className)) + { + fileName docFile(doxyPath/parser.subDict(className).lookup("filename")); + + // can use FOAM_DOC_BROWSER='application file://%f' if required + docBrowser.replaceAll("%f", docFile); + + fileName classFolder(parser.subDict(className).lookup("path")); + word classFile(parser.subDict(className).lookup("name")); + + Info<< "Showing documentation for type " << className << nl << endl; + + Info<< "Source file: " << classFolder.c_str() << classFile << nl + << endl; + + system(docBrowser); + } + else + { + FatalErrorIn + ( + "void Foam::helpType::displayDoc(const word, const string)" + ) + << "No help for type " << className << " found." + << " Valid options include:" << SortableList(parser.toc()) + << exit(FatalError); + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::helpType::helpType() +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::helpType::~helpType() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::helpType::init() +{ + argList::addOption + ( + "browse", + "word", + "display documentation for boundary condition in browser" + ); +} + + +// ************************************************************************* // diff --git a/applications/utilities/miscellaneous/foamHelp/helpTypes/helpType/helpType.H b/applications/utilities/miscellaneous/foamHelp/helpTypes/helpType/helpType.H new file mode 100644 index 0000000000..f5e65709c6 --- /dev/null +++ b/applications/utilities/miscellaneous/foamHelp/helpTypes/helpType/helpType.H @@ -0,0 +1,125 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 . + +Class + Foam::helpType + +Description + Base class for foam help classes + +SourceFiles + helpType.C + helpTypeNew.C + +\*---------------------------------------------------------------------------*/ + +#ifndef helpType_H +#define helpType_H + +#include "runTimeSelectionTables.H" +#include "autoPtr.H" +#include "argList.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// forward declaration of classes + +class fvMesh; + +/*---------------------------------------------------------------------------*\ + Class helpType Declaration +\*---------------------------------------------------------------------------*/ + +class helpType +{ + +protected: + + //- Return file path to the Doxygen sources (if available) + fileName doxygenPath() const; + + //- Display the list of documentation options + void displayDocOptions + ( + const string& searchStr, + const bool exactMatch + ) const; + + //- Display the help documentation in a browser + void displayDoc + ( + const word& className, + const string& searchStr, + const bool exactMatch + ) const; + + +public: + + //- Runtime type information + TypeName("helpType"); + + // Declare runtime constructor selection table + declareRunTimeSelectionTable + ( + autoPtr, + helpType, + dictionary, + (), + () + ); + + + //- Constructor + helpType(); + + //- Selector + static autoPtr New(const word& helpTypeName); + + //- Destructor + virtual ~helpType(); + + + // Member Functions + + //- Initialise - typically setting static variables, + // e.g. command line arguments + virtual void init(); + + //- Execute the help + virtual void execute(const argList& args, const fvMesh& mesh) = 0; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/utilities/miscellaneous/foamHelp/helpTypes/helpType/helpTypeNew.C b/applications/utilities/miscellaneous/foamHelp/helpTypes/helpType/helpTypeNew.C new file mode 100644 index 0000000000..607ca9b435 --- /dev/null +++ b/applications/utilities/miscellaneous/foamHelp/helpTypes/helpType/helpTypeNew.C @@ -0,0 +1,65 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 . + +\*---------------------------------------------------------------------------*/ + +#include "helpType.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +Foam::autoPtr Foam::helpType::New +( + const word& helpTypeName +) +{ + Info<< "Selecting helpType " << helpTypeName << endl; + + dictionaryConstructorTable::iterator cstrIter = + dictionaryConstructorTablePtr_->find(helpTypeName); + + if (cstrIter == dictionaryConstructorTablePtr_->end()) + { + // special treatment for -help + // exit without stack trace + if (helpTypeName == "-help") + { + FatalErrorIn("helpType::New()") + << "Valid helpType selections are:" << nl + << dictionaryConstructorTablePtr_->sortedToc() << nl + << exit(FatalError); + } + else + { + FatalErrorIn("helpType::New()") + << "Unknown helpType type " << helpTypeName << nl + << "Valid helpType selections are:" << nl + << dictionaryConstructorTablePtr_->sortedToc() << nl + << abort(FatalError); + } + } + + return autoPtr(cstrIter()()); +} + + +// ************************************************************************* // diff --git a/applications/utilities/parallelProcessing/decomposePar/Make/options b/applications/utilities/parallelProcessing/decomposePar/Make/options index 7194eb1bce..5d5d67f989 100644 --- a/applications/utilities/parallelProcessing/decomposePar/Make/options +++ b/applications/utilities/parallelProcessing/decomposePar/Make/options @@ -3,7 +3,8 @@ EXE_INC = \ -I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/lagrangian/basic/lnInclude \ - -I$(LIB_SRC)/meshTools/lnInclude + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/regionModels/regionModel/lnInclude EXE_LIBS = \ -lfiniteVolume \ @@ -11,4 +12,5 @@ EXE_LIBS = \ -lgenericPatchFields \ -ldecompositionMethods -L$(FOAM_LIBBIN)/dummy -lmetisDecomp -lscotchDecomp \ -llagrangian \ - -lmeshTools + -lmeshTools \ + -lregionModels diff --git a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C index 26d3813004..257c31df53 100644 --- a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C +++ b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C @@ -39,6 +39,10 @@ Usage \param -region regionName \n Decompose named region. Does not check for existence of processor*. + \param -allRegions \n + Decompose all regions in regionProperties. Does not check for + existence of processor*. + \param -copyUniform \n Copy any \a uniform directories too. @@ -82,6 +86,7 @@ Usage #include "tensorIOField.H" #include "tensorFieldIOField.H" #include "pointFields.H" +#include "regionProperties.H" #include "readFields.H" #include "dimFieldDecomposer.H" @@ -101,6 +106,11 @@ int main(int argc, char *argv[]) argList::noParallel(); #include "addRegionOption.H" argList::addBoolOption + ( + "allRegions", + "operate on all regions in regionProperties" + ); + argList::addBoolOption ( "cellDist", "write cell distribution as a labelList - for use with 'manual' " @@ -132,15 +142,7 @@ int main(int argc, char *argv[]) #include "setRootCase.H" - word regionName = fvMesh::defaultRegion; - word regionDir = word::null; - - if (args.optionReadIfPresent("region", regionName)) - { - regionDir = regionName; - Info<< "Decomposing mesh " << regionName << nl << endl; - } - + bool allRegions = args.optionFound("allRegions"); bool writeCellDist = args.optionFound("cellDist"); bool copyUniform = args.optionFound("copyUniform"); bool decomposeFieldsOnly = args.optionFound("fields"); @@ -152,756 +154,659 @@ int main(int argc, char *argv[]) // Allow override of time instantList times = timeSelector::selectIfPresent(runTime, args); - // determine the existing processor count directly - label nProcs = 0; - while - ( - isDir - ( - runTime.path() - / (word("processor") + name(nProcs)) - / runTime.constant() - / regionDir - / polyMesh::meshSubDir - ) - ) + + wordList regionNames; + wordList regionDirs; + if (allRegions) { - ++nProcs; - } - - // get requested numberOfSubdomains - const label nDomains = readLabel - ( - IOdictionary - ( - IOobject - ( - "decomposeParDict", - runTime.time().system(), - regionDir, // use region if non-standard - runTime, - IOobject::MUST_READ_IF_MODIFIED, - IOobject::NO_WRITE, - false - ) - ).lookup("numberOfSubdomains") - ); - - if (decomposeFieldsOnly) - { - // Sanity check on previously decomposed case - if (nProcs != nDomains) + Info<< "Decomposing all regions in regionProperties" << nl << endl; + regionProperties rp(runTime); + forAllConstIter(HashTable, rp, iter) { - FatalErrorIn(args.executable()) - << "Specified -fields, but the case was decomposed with " - << nProcs << " domains" - << nl - << "instead of " << nDomains - << " domains as specified in decomposeParDict" - << nl - << exit(FatalError); - } - } - else if (nProcs) - { - bool procDirsProblem = true; - - if (ifRequiredDecomposition && nProcs == nDomains) - { - // we can reuse the decomposition - decomposeFieldsOnly = true; - procDirsProblem = false; - forceOverwrite = false; - - Info<< "Using existing processor directories" << nl; - } - - if (forceOverwrite) - { - Info<< "Removing " << nProcs - << " existing processor directories" << endl; - - // remove existing processor dirs - // reverse order to avoid gaps if someone interrupts the process - for (label procI = nProcs-1; procI >= 0; --procI) + const wordList& regions = iter(); + forAll(regions, i) { - fileName procDir - ( - runTime.path()/(word("processor") + name(procI)) - ); - - rmDir(procDir); - } - - procDirsProblem = false; - } - - if (procDirsProblem) - { - FatalErrorIn(args.executable()) - << "Case is already decomposed with " << nProcs - << " domains, use the -force option or manually" << nl - << "remove processor directories before decomposing. e.g.," - << nl - << " rm -rf " << runTime.path().c_str() << "/processor*" - << nl - << exit(FatalError); - } - } - - Info<< "Create mesh" << endl; - domainDecomposition mesh - ( - IOobject - ( - regionName, - runTime.timeName(), - runTime - ) - ); - - // Decompose the mesh - if (!decomposeFieldsOnly) - { - mesh.decomposeMesh(); - - mesh.writeDecomposition(); - - if (writeCellDist) - { - const labelList& procIds = mesh.cellToProc(); - - // Write the decomposition as labelList for use with 'manual' - // decomposition method. - labelIOList cellDecomposition - ( - IOobject - ( - "cellDecomposition", - mesh.facesInstance(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE, - false - ), - procIds - ); - cellDecomposition.write(); - - Info<< nl << "Wrote decomposition to " - << cellDecomposition.objectPath() - << " for use in manual decomposition." << endl; - - // Write as volScalarField for postprocessing. - volScalarField cellDist - ( - IOobject - ( - "cellDist", - runTime.timeName(), - mesh, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - mesh, - dimensionedScalar("cellDist", dimless, 0), - zeroGradientFvPatchScalarField::typeName - ); - - forAll(procIds, celli) - { - cellDist[celli] = procIds[celli]; - } - - cellDist.write(); - - Info<< nl << "Wrote decomposition as volScalarField to " - << cellDist.name() << " for use in postprocessing." - << endl; - } - } - - - - // Caches - // ~~~~~~ - // Cached processor meshes and maps. These are only preserved if running - // with multiple times. - PtrList