changeDictionary: Simplified by removing the need for the superfluous dictionaryReplacement sub-dictionary

Added the option '-subDict' to specify a sub-dictionary if multiple
replacement sets are present in the same file.  This also provides
backward compatibility by setting '-subDict dictionaryReplacement'
This commit is contained in:
Henry Weller
2016-06-15 09:03:05 +01:00
parent a1cc51b116
commit 685afaafbf
25 changed files with 1653 additions and 1711 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -33,8 +33,6 @@ Description
\em Walls a zeroGradient boundary condition, the \em Walls a zeroGradient boundary condition, the
\c system/changeDictionaryDict would contain the following: \c system/changeDictionaryDict would contain the following:
\verbatim \verbatim
dictionaryReplacement
{
p // field to change p // field to change
{ {
boundaryField boundaryField
@ -50,23 +48,25 @@ Description
} }
} }
} }
}
\endverbatim \endverbatim
Replacement entries starting with '~' will remove the entry. Replacement entries starting with '~' will remove the entry.
Usage Usage
- changeDictionary [OPTION] changeDictionary [OPTION]
\param -subDict \n
Specify the subDict name of the replacements dictionary.
\param -literalRE \n \param -literalRE \n
Do not interpret regular expressions or patchGroups; Do not interpret regular expressions or patchGroups; treat them as any
treat them as any other keyword. other keyword.
\param -enableFunctionEntries \n \param -enableFunctionEntries \n
By default all dictionary preprocessing of fields is disabled Enable function entries (default: disabled)
\param -disablePatchGroups \n \param -disablePatchGroups \n
By default all keys are also checked for being patchGroups Disable the default checking for keys being patchGroups
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -89,7 +89,7 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Extract groupPatch (= shortcut) info from boundary file info // Extract groupPatch info from boundary file info
HashTable<wordList, word> extractPatchGroups(const dictionary& boundaryDict) HashTable<wordList, word> extractPatchGroups(const dictionary& boundaryDict)
{ {
HashTable<wordList, word> groupToPatch; HashTable<wordList, word> groupToPatch;
@ -268,7 +268,6 @@ bool merge
if (entryPtr) if (entryPtr)
{ {
// Mark thisDict entry as having been match for wildcard // Mark thisDict entry as having been match for wildcard
// handling later on. // handling later on.
thisKeysSet.erase(entryPtr->keyword()); thisKeysSet.erase(entryPtr->keyword());
@ -386,6 +385,12 @@ int main(int argc, char *argv[])
{ {
#include "addDictOption.H" #include "addDictOption.H"
argList::addOption argList::addOption
(
"subDict",
"name",
"specify the subDict name of the replacements dictionary"
);
argList::addOption
( (
"instance", "instance",
"name", "name",
@ -479,7 +484,16 @@ int main(int argc, char *argv[])
#include "setSystemMeshDictionaryIO.H" #include "setSystemMeshDictionaryIO.H"
IOdictionary dict(dictIO); IOdictionary dict(dictIO);
const dictionary& replaceDicts = dict.subDict("dictionaryReplacement"); const dictionary* replaceDictsPtr = &dict;
if (args.optionFound("subDict"))
{
word subDictName(args.optionLookup("subDict")());
replaceDictsPtr = &dict.subDict(subDictName);
}
const dictionary& replaceDicts = *replaceDictsPtr;
Info<< "Read dictionary " << dict.name() Info<< "Read dictionary " << dict.name()
<< " with replacements for dictionaries " << " with replacements for dictionaries "
<< replaceDicts.toc() << endl; << replaceDicts.toc() << endl;
@ -514,6 +528,7 @@ int main(int argc, char *argv[])
) )
); );
const_cast<word&>(IOPtrList<entry>::typeName) = oldTypeName; const_cast<word&>(IOPtrList<entry>::typeName) = oldTypeName;
// Fake type back to what was in field // Fake type back to what was in field
const_cast<word&>(dictList.type()) = dictList.headerClassName(); const_cast<word&>(dictList.type()) = dictList.headerClassName();
@ -632,6 +647,7 @@ int main(int argc, char *argv[])
); );
const_cast<word&>(IOdictionary::typeName) = oldTypeName; const_cast<word&>(IOdictionary::typeName) = oldTypeName;
// Fake type back to what was in field // Fake type back to what was in field
const_cast<word&>(fieldDict.type()) = fieldDict.headerClassName(); const_cast<word&>(fieldDict.type()) = fieldDict.headerClassName();
@ -652,9 +668,7 @@ int main(int argc, char *argv[])
entry::disableFunctionEntries = oldFlag; entry::disableFunctionEntries = oldFlag;
Info<< endl; Info<< "\nEnd\n" << endl;
Info<< "End\n" << endl;
return 0; return 0;
} }

View File

@ -14,8 +14,6 @@ FoamFile
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dictionaryReplacement
{
boundary boundary
{ {
".*" ".*"
@ -84,6 +82,5 @@ dictionaryReplacement
} }
} }
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -14,8 +14,6 @@ FoamFile
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dictionaryReplacement
{
p p
{ {
boundaryField boundaryField
@ -460,6 +458,5 @@ dictionaryReplacement
} }
} }
} }
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -14,8 +14,6 @@ FoamFile
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dictionaryReplacement
{
boundary boundary
{ {
region0_to_filmRegion_coupledWall region0_to_filmRegion_coupledWall
@ -23,7 +21,5 @@ dictionaryReplacement
samplePatch region0_to_pyrolysisRegion_coupledWall; samplePatch region0_to_pyrolysisRegion_coupledWall;
} }
} }
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -14,8 +14,6 @@ FoamFile
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dictionaryReplacement
{
U U
{ {
internalField uniform (0.001 0 0); internalField uniform (0.001 0 0);
@ -167,6 +165,5 @@ dictionaryReplacement
} }
} }
} }
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -14,8 +14,6 @@ FoamFile
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dictionaryReplacement
{
boundary boundary
{ {
minY minY
@ -68,6 +66,5 @@ dictionaryReplacement
} }
} }
} }
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -14,8 +14,6 @@ FoamFile
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dictionaryReplacement
{
boundary boundary
{ {
minZ minZ
@ -58,6 +56,5 @@ dictionaryReplacement
} }
} }
} }
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -14,8 +14,6 @@ FoamFile
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dictionaryReplacement
{
boundary boundary
{ {
minZ minZ
@ -48,6 +46,5 @@ dictionaryReplacement
} }
} }
} }
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -14,8 +14,6 @@ FoamFile
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dictionaryReplacement
{
U U
{ {
internalField uniform (0.1 0 0); internalField uniform (0.1 0 0);
@ -165,6 +163,5 @@ dictionaryReplacement
} }
} }
} }
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -14,8 +14,6 @@ FoamFile
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dictionaryReplacement
{
boundary boundary
{ {
minX minX
@ -120,6 +118,5 @@ dictionaryReplacement
} }
} }
} }
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -14,8 +14,6 @@ FoamFile
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dictionaryReplacement
{
boundary boundary
{ {
minY minY
@ -57,6 +55,5 @@ dictionaryReplacement
} }
} }
} }
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -14,8 +14,6 @@ FoamFile
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dictionaryReplacement
{
boundary boundary
{ {
minZ minZ
@ -48,6 +46,5 @@ dictionaryReplacement
} }
} }
} }
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -14,8 +14,6 @@ FoamFile
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dictionaryReplacement
{
boundary boundary
{ {
minZ minZ
@ -48,6 +46,5 @@ dictionaryReplacement
} }
} }
} }
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -14,8 +14,6 @@ FoamFile
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dictionaryReplacement
{
U U
{ {
internalField uniform (0.1 0 0); internalField uniform (0.1 0 0);
@ -165,6 +163,5 @@ dictionaryReplacement
} }
} }
} }
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -14,8 +14,6 @@ FoamFile
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dictionaryReplacement
{
boundary boundary
{ {
minX minX
@ -183,7 +181,4 @@ dictionaryReplacement
} }
} }
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -14,8 +14,6 @@ FoamFile
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dictionaryReplacement
{
boundary boundary
{ {
minY minY
@ -78,6 +76,5 @@ dictionaryReplacement
} }
} }
} }
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -14,8 +14,6 @@ FoamFile
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dictionaryReplacement
{
boundary boundary
{ {
minZ minZ
@ -69,6 +67,5 @@ dictionaryReplacement
} }
} }
} }
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -14,8 +14,6 @@ FoamFile
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dictionaryReplacement
{
boundary boundary
{ {
minZ minZ
@ -69,6 +67,5 @@ dictionaryReplacement
} }
} }
} }
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -14,8 +14,6 @@ FoamFile
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dictionaryReplacement
{
U U
{ {
internalField uniform (0.1 0 0); internalField uniform (0.1 0 0);
@ -229,6 +227,5 @@ dictionaryReplacement
} }
} }
} }
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -14,8 +14,6 @@ FoamFile
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dictionaryReplacement
{
mirrorMeshDict mirrorMeshDict
{ {
pointAndNormalDict pointAndNormalDict
@ -24,5 +22,5 @@ dictionaryReplacement
normalVector (0 -1 0); normalVector (0 -1 0);
} }
} }
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -14,8 +14,6 @@ FoamFile
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dictionaryReplacement
{
mirrorMeshDict mirrorMeshDict
{ {
pointAndNormalDict pointAndNormalDict
@ -24,5 +22,5 @@ dictionaryReplacement
normalVector (-1 0 0); normalVector (-1 0 0);
} }
} }
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -14,8 +14,6 @@ FoamFile
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dictionaryReplacement
{
mirrorMeshDict mirrorMeshDict
{ {
pointAndNormalDict pointAndNormalDict
@ -24,5 +22,5 @@ dictionaryReplacement
normalVector (0 -1 0); normalVector (0 -1 0);
} }
} }
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -14,8 +14,6 @@ FoamFile
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dictionaryReplacement
{
T T
{ {
boundaryField boundaryField
@ -67,6 +65,5 @@ dictionaryReplacement
} }
} }
} }
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -14,8 +14,6 @@ FoamFile
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dictionaryReplacement
{
alphat alphat
{ {
boundaryField boundaryField
@ -192,6 +190,5 @@ dictionaryReplacement
} }
} }
} }
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -14,8 +14,6 @@ FoamFile
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dictionaryReplacement
{
p_rgh p_rgh
{ {
boundaryField boundaryField
@ -42,6 +40,5 @@ dictionaryReplacement
} }
} }
} }
}
// ************************************************************************* // // ************************************************************************* //