99 const word& patchName = iter().keyword();
111 if (fndGroup == groupToPatch.
end())
117 fndGroup().append(patchName);
140 const entry& mergeEntry,
141 const bool literalRE,
145 bool changed =
false;
155 const_cast<dictionary&>(thisEntry.
dict()),
168 thisDict.
add(mergeEntry.
clone(thisDict).ptr(),
true);
194 else if (shortcuts.
size())
200 const word&
name = shortcutNames[indices[i]];
225 const bool literalRE,
231 bool changed =
false;
239 thisKeysSet.
insert(keys[i]);
247 const keyType& key = mergeIter().keyword();
251 word eraseKey = key(1, key.size()-1);
252 if (thisDict.
remove(eraseKey))
256 thisKeysSet.
erase(eraseKey);
293 thisDict.
add(mergeIter().clone(thisDict).ptr());
302 if (!literalRE && thisKeysSet.
size() > 0)
309 const keyType& key = mergeIter().keyword();
313 word eraseKey = key(1, key.size()-1);
330 const word& thisKey = thisKeys[matches[i]];
331 thisKeysSet.
erase(thisKey);
352 const word& thisKey = thisKeys[matches[i]];
384 int main(
int argc,
char *argv[])
391 "specify the subDict name of the replacements dictionary" 397 "override instance setting (default is the time name)" 406 "treat regular expressions literally (i.e., as a keyword)" 410 "enableFunctionEntries",
411 "enable expansion of dictionary directives - #include, #codeStream etc" 415 "disablePatchGroups",
416 "disable matching keys to patch groups" 426 if (times.
size() < 1)
431 runTime.setTime(times[0], 0);
439 Info<<
"Not interpreting any regular expressions (RE)" 440 <<
" in the changeDictionaryDict." << endl
441 <<
"Instead they are handled as any other entry, i.e. added if" 442 <<
" not present." <<
endl;
448 Info<<
"Allowing dictionary preprocessing ('#include', '#codeStream')." 460 const bool disablePatchGroups =
args.
optionFound(
"disablePatchGroups");
461 if (disablePatchGroups)
463 Info<<
"Not interpreting any keys in the changeDictionary" 495 const dictionary& replaceDicts = *replaceDictsPtr;
498 <<
" with replacements for dictionaries " 506 Info<<
"Reading polyMesh/boundary file to extract patch names" 533 const_cast<word&
>(dictList.type()) = dictList.headerClassName();
539 fieldDict.
add(dictList[i].keyword(), dictList[i].
dict());
544 Info<<
"Loaded dictionary " << dictList.name()
545 <<
" with entries " << fieldDict.
toc() <<
endl;
551 if (!disablePatchGroups)
553 patchGroups = extractPatchGroups(fieldDict);
554 if (patchGroups.
size())
556 Info<<
"Extracted patch groups:" <<
endl;
560 Info<<
" group " << groups[i] <<
" with patches " 561 << patchGroups[groups[i]] <<
endl;
571 const word& fieldName = fieldIter().keyword();
572 Info<<
"Replacing entries in dictionary " << fieldName <<
endl;
577 if (fieldName ==
"boundary")
579 Info<<
"Special handling of " << fieldName
580 <<
" as polyMesh/boundary file." <<
endl;
583 const dictionary& replaceDict = fieldIter().dict();
584 Info<<
"Merging entries from " << replaceDict.
toc() <<
endl;
587 merge(fieldDict, replaceDict, literalRE, patchGroups);
589 Info<<
"fieldDict:" << fieldDict <<
endl;
598 doneKeys[i] = dictList[i].keyword();
609 fieldDict.
remove(doneKeys[i]);
613 label sz = dictList.size();
614 dictList.setSize(nEntries);
617 dictList.set(sz++, iter().clone());
620 Info<<
"Writing modified " << fieldName <<
endl;
623 runTime.writeFormat(),
624 runTime.writeFormat(),
632 Info<<
"Loading dictionary " << fieldName <<
endl;
633 const word oldTypeName = IOdictionary::typeName;
649 const_cast<word&
>(IOdictionary::typeName) = oldTypeName;
652 const_cast<word&
>(fieldDict.type()) = fieldDict.headerClassName();
654 Info<<
"Loaded dictionary " << fieldName
655 <<
" with entries " << fieldDict.
toc() <<
endl;
658 const dictionary& replaceDict = fieldIter().dict();
659 Info<<
"Merging entries from " << replaceDict.
toc() <<
endl;
662 merge(fieldDict, replaceDict, literalRE, patchGroups);
664 Info<<
"Writing modified fieldDict " << fieldName <<
endl;
665 fieldDict.regIOobject::write();
A class for handling keywords in dictionaries.
virtual autoPtr< entry > clone(const dictionary &parentDict) const =0
Construct on freestore as copy with reference to the.
A HashTable with keys but without contents.
wordList toc() const
Return the table of contents.
#define forAll(list, i)
Loop across all elements in list.
bool remove(const word &)
Remove an entry specified by keyword.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
A class for handling file names.
errorManipArg< error, int > exit(error &err, const int errNo=1)
static iteratorEnd end()
iteratorEnd set to beyond the end of any HashTable
List< keyType > keys(bool patterns=false) const
Return the list of available keys or patterns.
A list of keyword definitions, which are a keyword followed by any number of values (e...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
void size(const label)
Override size to be inconsistent with allocated storage.
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
static word defaultRegion
Return the default region name.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const entry * lookupEntryPtr(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream pointer if present.
virtual const dictionary & dict() const =0
Return dictionary if this entry is a dictionary.
label size() const
Return number of elements in table.
Operations on lists of strings.
const fileName & name() const
Return the dictionary name.
label size() const
Return number of elements in list.
bool insert(const Key &key)
Insert a new entry.
T optionLookupOrDefault(const word &opt, const T &deflt) const
Read a value from the named option if present.
bool add(entry *, bool mergeEntry=false)
Add a new entry.
bool erase(const iterator &)
Erase a hashedEntry specified by given iterator.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
bool findStrings(const wordReListMatcher &matcher, const std::string &str)
Return true if string matches one of the regular expressions.
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
static fileCheckTypes fileModificationChecking
An STL-conforming iterator.
static int disableFunctionEntries
bool optionFound(const word &opt) const
Return true if the named option is found.
A class for handling words, derived from string.
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
const keyType & keyword() const
Return keyword.
void append(const T &)
Append an element at the end of the list.
static void addOption(const word &opt, const string ¶m="", const string &usage="")
Add to an option to validOptions with usage information.
static const word null
An empty word.
static instantList selectIfPresent(Time &runTime, const argList &args)
If any time option provided return the set of times (as select0)
An STL-conforming hash table.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
List< Key > toc() const
Return the table of contents.
defineTemplateTypeNameAndDebug(IOPtrList< ensightPart >, 0)
bool found(const Key &) const
Return true if hashedEntry is found in table.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
word name(const complex &)
Return a string representation of a complex.
IOobject dictIO(dictName, runTime.constant(), mesh, IOobject::MUST_READ_IF_MODIFIED, IOobject::NO_WRITE)
List< word > wordList
A List of words.
A PtrList of objects of type <T> with automated input and output.
word dictName("noiseDict")
List< Key > sortedToc() const
Return the table of contents as a sorted list.
IStringStream optionLookup(const word &opt) const
Return an IStringStream from the named option.
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
const entry & lookupEntry(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream if present otherwise error.
Foam::argList args(argc, argv)
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
virtual bool isDict() const
Return true if this entry is a dictionary.
bool isPattern() const
Should be treated as a match rather than a literal string.
static void addOptions(const bool constant=true, const bool withZero=false)
Add the options handled by timeSelector to argList::validOptions.
A keyword and a list of tokens is an 'entry'.