ENH: changeDictionary: do not allow adding to boundary file (as a special case).

Fixes #103
This commit is contained in:
mattijs
2016-04-20 11:01:48 +01:00
parent 1e2ddab4e6
commit 49ddb1d1a8

View File

@ -2,8 +2,8 @@
========= | ========= |
\\ / 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 | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -125,6 +125,7 @@ HashTable<wordList, word> extractPatchGroups(const dictionary& boundaryDict)
bool merge bool merge
( (
const bool addNonExisting,
dictionary&, dictionary&,
const dictionary&, const dictionary&,
const bool, const bool,
@ -152,6 +153,7 @@ bool addEntry
( (
merge merge
( (
true,
const_cast<dictionary&>(thisEntry.dict()), const_cast<dictionary&>(thisEntry.dict()),
mergeEntry.dict(), mergeEntry.dict(),
literalRE, literalRE,
@ -220,6 +222,7 @@ labelList findMatches
// - false : interpret wildcard as a rule for items to be matched. // - false : interpret wildcard as a rule for items to be matched.
bool merge bool merge
( (
const bool addNonExisting,
dictionary& thisDict, dictionary& thisDict,
const dictionary& mergeDict, const dictionary& mergeDict,
const bool literalRE, const bool literalRE,
@ -290,9 +293,18 @@ bool merge
} }
else else
{ {
// not found - just add if (addNonExisting)
thisDict.add(mergeIter().clone(thisDict).ptr()); {
changed = true; // not found - just add
thisDict.add(mergeIter().clone(thisDict).ptr());
changed = true;
}
else
{
IOWarningInFunction(mergeDict)
<< "Ignoring non-existing entry " << key
<< endl;
}
} }
} }
} }
@ -568,8 +580,8 @@ int main(int argc, char *argv[])
const dictionary& replaceDict = fieldIter().dict(); const dictionary& replaceDict = fieldIter().dict();
Info<< "Merging entries from " << replaceDict.toc() << endl; Info<< "Merging entries from " << replaceDict.toc() << endl;
// Merge the replacements in // Merge the replacements in. Do not add non-existing entries.
merge(fieldDict, replaceDict, literalRE, patchGroups); merge(false, fieldDict, replaceDict, literalRE, patchGroups);
Info<< "fieldDict:" << fieldDict << endl; Info<< "fieldDict:" << fieldDict << endl;
@ -645,8 +657,8 @@ int main(int argc, char *argv[])
const dictionary& replaceDict = fieldIter().dict(); const dictionary& replaceDict = fieldIter().dict();
Info<< "Merging entries from " << replaceDict.toc() << endl; Info<< "Merging entries from " << replaceDict.toc() << endl;
// Merge the replacements in // Merge the replacements in (allow adding)
merge(fieldDict, replaceDict, literalRE, patchGroups); merge(true, fieldDict, replaceDict, literalRE, patchGroups);
Info<< "Writing modified fieldDict " << fieldName << endl; Info<< "Writing modified fieldDict " << fieldName << endl;
fieldDict.regIOobject::write(); fieldDict.regIOobject::write();