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)
436 if (times.
size() > 1)
439 <<
"Multiple times selected with 'instance' option" 456 Info<<
"Not interpreting any regular expressions (RE)" 457 <<
" in the changeDictionaryDict." << endl
458 <<
"Instead they are handled as any other entry, i.e. added if" 459 <<
" not present." <<
endl;
465 Info<<
"Allowing dictionary preprocessing " 466 "('#include', '#codeStream')." 478 const bool disablePatchGroups =
args.
optionFound(
"disablePatchGroups");
479 if (disablePatchGroups)
481 Info<<
"Not interpreting any keys in the changeDictionary" 513 const dictionary& replaceDicts = *replaceDictsPtr;
516 <<
" with replacements for dictionaries " 524 Info<<
"Reading polyMesh/boundary file to extract patch names" 551 const_cast<word&
>(dictList.type()) = dictList.headerClassName();
557 fieldDict.
add(dictList[i].keyword(), dictList[i].
dict());
562 Info<<
"Loaded dictionary " << dictList.name()
563 <<
" with entries " << fieldDict.
toc() <<
endl;
569 if (!disablePatchGroups)
571 patchGroups = extractPatchGroups(fieldDict);
572 if (patchGroups.
size())
574 Info<<
"Extracted patch groups:" <<
endl;
578 Info<<
" group " << groups[i] <<
" with patches " 579 << patchGroups[groups[i]] <<
endl;
589 const word& fieldName = fieldIter().keyword();
590 Info<<
"Replacing entries in dictionary " << fieldName <<
endl;
595 if (fieldName ==
"boundary")
597 Info<<
"Special handling of " << fieldName
598 <<
" as polyMesh/boundary file." <<
endl;
601 const dictionary& replaceDict = fieldIter().dict();
602 Info<<
"Merging entries from " << replaceDict.
toc() <<
endl;
605 merge(fieldDict, replaceDict, literalRE, patchGroups);
607 Info<<
"fieldDict:" << fieldDict <<
endl;
612 label nEntries = fieldDict.size();
616 doneKeys[i] = dictList[i].keyword();
627 fieldDict.
remove(doneKeys[i]);
631 label sz = dictList.size();
632 dictList.setSize(nEntries);
635 dictList.set(sz++, iter().clone());
638 Info<<
"Writing modified " << fieldName <<
endl;
651 Info<<
"Loading dictionary " << fieldName <<
endl;
652 const word oldTypeName = IOdictionary::typeName;
668 const_cast<word&
>(IOdictionary::typeName) = oldTypeName;
671 const_cast<word&
>(fieldDict.type()) =
672 fieldDict.headerClassName();
674 Info<<
"Loaded dictionary " << fieldName
675 <<
" with entries " << fieldDict.
toc() <<
endl;
678 const dictionary& replaceDict = fieldIter().dict();
679 Info<<
"Merging entries from " << replaceDict.
toc() <<
endl;
682 merge(fieldDict, replaceDict, literalRE, patchGroups);
684 Info<<
"Writing modified fieldDict " << fieldName <<
endl;
685 fieldDict.regIOobject::write();
Template class for intrusive linked lists.
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.
#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.
const entry * lookupEntryPtr(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream pointer if present.
const keyType & keyword() const
Return keyword.
errorManipArg< error, int > exit(error &err, const int errNo=1)
static iteratorEnd end()
iteratorEnd set to beyond the end of any HashTable
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.
static word defaultRegion
Return the default region name.
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool optionFound(const word &opt) const
Return true if the named option is found.
word findInstance(const fileName &dir, const word &name=word::null, const IOobject::readOption rOpt=IOobject::MUST_READ, const word &stopInstance=word::null) const
Return the location of "dir" containing the file "name".
virtual const dictionary & dict() const =0
Return dictionary if this entry is a dictionary.
const entry & lookupEntry(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream if present otherwise error.
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
Operations on lists of strings.
bool insert(const Key &key)
Insert a new entry.
label size() const
Return number of elements in table.
wordList toc() const
Return the table of contents.
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.
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
An STL-conforming iterator.
static int disableFunctionEntries
const fileName & name() const
Return the dictionary name.
bool found(const Key &) const
Return true if hashedEntry is found in table.
A class for handling words, derived from string.
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.
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
static const word null
An empty word.
const word dictName("particleTrackDict")
static instantList selectIfPresent(Time &runTime, const argList &args)
If any time option provided return the set of times (as select0)
virtual void setTime(const Time &)
Reset the time and time-index to those of the given time.
An STL-conforming hash table.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
defineTemplateTypeNameAndDebug(IOPtrList< ensightPart >, 0)
virtual bool isDict() const
Return true if this entry is a dictionary.
IOstream::streamFormat writeFormat() const
Default write format.
static fileCheckTypes fileModificationChecking
Type of file modification checking.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence 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< keyType > keys(bool patterns=false) const
Return the list of available keys or patterns.
List< word > wordList
A List of words.
A PtrList of objects of type <T> with automated input and output.
List< Key > sortedToc() const
Return the table of contents as a sorted list.
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
List< Key > toc() const
Return the table of contents.
Foam::argList args(argc, argv)
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
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'.
bool isPattern() const
Should be treated as a match rather than a literal string.
IStringStream optionLookup(const word &opt) const
Return an IStringStream from the named option.