diff --git a/applications/utilities/preProcessing/changeDictionary/FoamX/foamInfoExec.cfg b/applications/utilities/preProcessing/changeDictionary/FoamX/foamInfoExec.cfg new file mode 100644 index 0000000000..6b9347d91b --- /dev/null +++ b/applications/utilities/preProcessing/changeDictionary/FoamX/foamInfoExec.cfg @@ -0,0 +1,32 @@ +/*---------------------------------------------------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.0 | +| \\ / A nd | Web: http://www.openfoam.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +// foamInfoExec tool definition + +description "Interrogates a case and prints information to screen"; + +foamInfoExecDict +{ + type dictionary; + description "foamInfoExec control dictionary"; + dictionaryPath "system"; + + entries + { + arguments + { + type rootCaseArguments; + entries + { + include "$FOAMX_CONFIG/entries/arguments/times.cfg"; + include "$FOAMX_CONFIG/entries/arguments/dictionary.cfg"; + } + } + } +} + +// ************************************************************************* // diff --git a/applications/utilities/preProcessing/changeDictionary/Make/files b/applications/utilities/preProcessing/changeDictionary/Make/files new file mode 100644 index 0000000000..c6cfab6613 --- /dev/null +++ b/applications/utilities/preProcessing/changeDictionary/Make/files @@ -0,0 +1,3 @@ +changeDictionary.C + +EXE = $(FOAM_APPBIN)/changeDictionary diff --git a/applications/utilities/preProcessing/changeDictionary/Make/options b/applications/utilities/preProcessing/changeDictionary/Make/options new file mode 100644 index 0000000000..9b8c3dea8c --- /dev/null +++ b/applications/utilities/preProcessing/changeDictionary/Make/options @@ -0,0 +1,9 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude + +EXE_LIBS = \ + -lfiniteVolume \ + -ldynamicMesh \ + -lmeshTools diff --git a/applications/utilities/preProcessing/changeDictionary/changeDictionary.C b/applications/utilities/preProcessing/changeDictionary/changeDictionary.C new file mode 100644 index 0000000000..0d30936779 --- /dev/null +++ b/applications/utilities/preProcessing/changeDictionary/changeDictionary.C @@ -0,0 +1,133 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Description + Simple dictionary changing tool. Can be used to e.g. change the patch + type. Reads dictionaries (fields) and entries to change from a dictionary. + E.g. to make the @em movingWall a @em fixedValue for @em p, the + @c system/changeDictionaryDict would contain the following: + @verbatim + dictionaryReplacement + { + p // field to change + { + boundaryField + { + movingWall // entry to change + { + type fixedValue; + value uniform 123.45; + } + } + } + } + @endverbatim + +\*---------------------------------------------------------------------------*/ + +#include "argList.H" +#include "IOobjectList.H" +#include "volFields.H" + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +// Main program: + +int main(int argc, char *argv[]) +{ +# include "addRegionOption.H" +# include "setRootCase.H" +# include "createTime.H" +# include "createNamedMesh.H" + + // Get the replacement rules from a dictionary + IOdictionary dict + ( + IOobject + ( + "changeDictionaryDict", + runTime.system(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ); + const dictionary& replaceDicts = dict.subDict("dictionaryReplacement"); + Info<< "Read dictionary " << dict.name() + << " with replacements for dictionaries " + << replaceDicts.toc() << endl; + + + // Every replacement is a dictionary name and a keyword in this + + forAllConstIter(dictionary, replaceDicts, fieldIter) + { + const word& fieldName = fieldIter().keyword(); + Info<< "Replacing entries in dictionary " << fieldName << endl; + + // Read dictionary. (disable class type checking so we can load field) + Info<< "Loading dictionary " << fieldName << endl; + const word oldTypeName = IOdictionary::typeName; + const_cast(IOdictionary::typeName) = word::null; + IOdictionary fieldDict + ( + IOobject + ( + fieldName, + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ) + ); + const_cast(IOdictionary::typeName) = oldTypeName; + // Fake type back to what was in field + const_cast(fieldDict.type()) = fieldDict.headerClassName(); + + Info<< "Loaded dictionary " << fieldName + << " with entries " << fieldDict.toc() << endl; + + // Get the replacement dictionary for the field + const dictionary& replaceDict = fieldIter().dict(); + Info<< "Merging entries from " << replaceDict.toc() << endl; + + // Merge the replacements in + fieldDict.merge(replaceDict); + + Info<< "Writing modified fieldDict " << fieldName << endl; + fieldDict.regIOobject::write(); + } + + Info<< endl; + + Info<< "End\n" << endl; + + return 0; +} + +// ************************************************************************* // diff --git a/applications/utilities/preProcessing/changeDictionary/changeDictionaryDict b/applications/utilities/preProcessing/changeDictionary/changeDictionaryDict new file mode 100644 index 0000000000..93935af025 --- /dev/null +++ b/applications/utilities/preProcessing/changeDictionary/changeDictionaryDict @@ -0,0 +1,109 @@ +FoamFile +{ + version 2.0; + format ascii; + + root "/home/warhol/chris/foam/chris2.1/run/tutorials/interFoam"; + case "damBreak"; + instance "system"; + local ""; + + class dictionary; + object changePatchTypeDict; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +dictionaryReplacement +{ + T + { + internalField uniform 300; + + boundaryField + { + minY + { + type fixedValue; + value uniform 500; + } + + minZ + { + type zeroGradient; + } + maxZ + { + type zeroGradient; + } + } + } + + rho + { + internalField uniform 8000; + + boundaryField + { + minY + { + type zeroGradient; + } + minZ + { + type zeroGradient; + } + maxZ + { + type zeroGradient; + } + } + } + + + K + { + internalField uniform 80; + + boundaryField + { + minY + { + type zeroGradient; + } + minZ + { + type zeroGradient; + } + maxZ + { + type zeroGradient; + } + } + } + + + cp + { + internalField uniform 450; + + boundaryField + { + minY + { + type zeroGradient; + } + minZ + { + type zeroGradient; + } + maxZ + { + type zeroGradient; + } + } + } +} + +// ************************************************************************* //