Commit d848d774 authored by mattijs's avatar mattijs
Browse files

ENH: changeDictionary: allow removal of patches (!). Fixes #1179.

parent c88c39c0
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,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-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2016-2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -628,29 +628,31 @@ int main(int argc, char *argv[]) ...@@ -628,29 +628,31 @@ int main(int argc, char *argv[])
wordList doneKeys(dictList.size()); wordList doneKeys(dictList.size());
label nEntries = fieldDict.size(); label nEntries = fieldDict.size();
nEntries = 0;
forAll(dictList, i) forAll(dictList, i)
{ {
doneKeys[i] = dictList[i].keyword(); doneKeys[i] = dictList[i].keyword();
dictList.set
const entry* ePtr = fieldDict.findEntry
( (
i, doneKeys[i],
fieldDict.lookupEntry keyType::REGEX
(
doneKeys[i],
keyType::REGEX
).clone()
); );
fieldDict.remove(doneKeys[i]); // Check that it hasn't been removed from fieldDict
if (ePtr)
{
dictList.set(nEntries++, ePtr->clone());
fieldDict.remove(doneKeys[i]);
}
} }
// Add remaining entries // Add remaining entries
label sz = dictList.size();
dictList.setSize(nEntries);
for (const entry& e : fieldDict) for (const entry& e : fieldDict)
{ {
dictList.set(sz++, e.clone()); dictList.set(nEntries++, e.clone());
} }
dictList.setSize(nEntries);
Info<< "Writing modified " << fieldName << endl; Info<< "Writing modified " << fieldName << endl;
dictList.writeObject dictList.writeObject
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment