Go to the documentation of this file.
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;
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);
294 thisDict.
add(mergeIter().clone(thisDict).ptr());
303 if (!literalRE && thisKeysSet.
size() > 0)
310 const keyType& key = mergeIter().keyword();
314 word eraseKey = key(1, key.size()-1);
331 const word& thisKey = thisKeys[matches[i]];
332 thisKeysSet.
erase(thisKey);
353 const word& thisKey = thisKeys[matches[i]];
385 int main(
int argc,
char *argv[])
392 "override instance setting (default is the time name)"
401 "treat regular expressions literally (i.e., as a keyword)"
405 "enableFunctionEntries",
406 "enable expansion of dictionary directives - #include, #codeStream etc"
410 "disablePatchGroups",
411 "disable matching keys to patch groups"
421 if (times.
size() < 1)
426 runTime.setTime(times[0], 0);
434 Info<<
"Not interpreting any regular expressions (RE)"
435 <<
" in the changeDictionaryDict." <<
endl
436 <<
"Instead they are handled as any other entry, i.e. added if"
437 <<
" not present." <<
endl;
443 Info<<
"Allowing dictionary preprocessing ('#include', '#codeStream')."
455 const bool disablePatchGroups =
args.
optionFound(
"disablePatchGroups");
456 if (disablePatchGroups)
458 Info<<
"Not interpreting any keys in the changeDictionary"
484 <<
" with replacements for dictionaries "
492 Info<<
"Reading polyMesh/boundary file to extract patch names"
518 const_cast<word&
>(dictList.type()) = dictList.headerClassName();
524 fieldDict.
add(dictList[i].keyword(), dictList[i].
dict());
529 Info<<
"Loaded dictionary " << dictList.name()
530 <<
" with entries " << fieldDict.
toc() <<
endl;
536 if (!disablePatchGroups)
539 if (patchGroups.
size())
541 Info<<
"Extracted patch groups:" <<
endl;
545 Info<<
" group " << groups[i] <<
" with patches "
546 << patchGroups[groups[i]] <<
endl;
556 const word& fieldName = fieldIter().keyword();
557 Info<<
"Replacing entries in dictionary " << fieldName <<
endl;
562 if (fieldName ==
"boundary")
564 Info<<
"Special handling of " << fieldName
565 <<
" as polyMesh/boundary file." <<
endl;
568 const dictionary& replaceDict = fieldIter().dict();
569 Info<<
"Merging entries from " << replaceDict.
toc() <<
endl;
572 merge(fieldDict, replaceDict, literalRE, patchGroups);
574 Info<<
"fieldDict:" << fieldDict <<
endl;
579 label nEntries = fieldDict.size();
583 doneKeys[i] = dictList[i].keyword();
594 fieldDict.
remove(doneKeys[i]);
598 label sz = dictList.size();
599 dictList.setSize(nEntries);
602 dictList.set(sz++, iter().clone());
605 Info<<
"Writing modified " << fieldName <<
endl;
608 runTime.writeFormat(),
609 runTime.writeFormat(),
617 Info<<
"Loading dictionary " << fieldName <<
endl;
618 const word oldTypeName = IOdictionary::typeName;
631 if (fieldHeader.headerOk())
635 const_cast<word&
>(IOdictionary::typeName) = oldTypeName;
638 const_cast<word&
>(fieldDict.type()) =
639 fieldDict.headerClassName();
641 Info<<
"Loaded dictionary " << fieldName
642 <<
" with entries " << fieldDict.
toc() <<
endl;
645 const dictionary& replaceDict = fieldIter().dict();
646 Info<<
"Merging entries from " << replaceDict.
toc() <<
endl;
649 merge(fieldDict, replaceDict, literalRE, patchGroups);
651 Info<<
"Writing modified fieldDict " << fieldName <<
endl;
652 fieldDict.regIOobject::write();
657 <<
"Requested field to change " << fieldName
658 <<
" does not exist in " << fieldHeader.path() <<
endl;
A keyword and a list of tokens is an 'entry'.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
const entry & lookupEntry(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream if present otherwise error.
A class for handling words, derived from string.
A class for handling file names.
A PtrList of objects of type <T> with automated input and output.
An STL-conforming iterator.
const keyType & keyword() const
Return keyword.
List< Key > toc() const
Return the table of contents.
static void addOption(const word &opt, const string ¶m="", const string &usage="")
Add to an option to validOptions with usage information.
static word defaultRegion
Return the default region name.
#define forAll(list, i)
Loop across all elements in list.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
const fileName & name() const
Return the dictionary name.
bool isPattern() const
Should be treated as a match rather than a literal string.
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
bool remove(const word &)
Remove an entry specified by keyword.
HashTable< wordList, word > extractPatchGroups(const dictionary &boundaryDict)
Ostream & endl(Ostream &os)
Add newline and flush stream.
A HashTable with keys but without contents.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
List< word > wordList
A List of words.
List< keyType > keys(bool patterns=false) const
Return the list of available keys or patterns.
const word dictName("particleTrackDict")
A class for handling keywords in dictionaries.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
virtual bool isDict() const
Return true if this entry is a dictionary.
void append(const T &)
Append an element at the end of the list.
bool erase(const iterator &)
Erase a hashedEntry specified by given iterator.
static instantList selectIfPresent(Time &runTime, const argList &args)
If any time option provided return the set of times (as select0)
T optionLookupOrDefault(const word &opt, const T &deflt) const
Read a value from the named option if present.
int main(int argc, char *argv[])
A list of keyword definitions, which are a keyword followed by any number of values (e....
label size() const
Return number of elements in table.
bool found(const Key &) const
Return true if hashedEntry is found in table.
bool addEntry(dictionary &thisDict, entry &thisEntry, const entry &mergeEntry, const bool literalRE, const HashTable< wordList, word > &shortcuts)
static int disableFunctionEntries
virtual const dictionary & dict() const =0
Return dictionary if this entry is a dictionary.
List< Key > sortedToc() const
Return the table of contents as a sorted list.
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
errorManipArg< error, int > exit(error &err, const int errNo=1)
An STL-conforming hash table.
static fileCheckTypes fileModificationChecking
bool findStrings(const wordReListMatcher &matcher, const std::string &str)
Return true if string matches one of the regular expressions.
const entry * lookupEntryPtr(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream pointer if present.
labelList findMatches(const HashTable< wordList, word > &shortcuts, const wordList &shortcutNames, const wordList &thisKeys, const keyType &key)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
static void addOptions(const bool constant=true, const bool withZero=false)
Add the options handled by timeSelector to argList::validOptions.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
bool insert(const Key &key)
Insert a new entry.
static const word null
An empty word.
bool optionFound(const word &opt) const
Return true if the named option is found.
Operations on lists of strings.
virtual autoPtr< entry > clone(const dictionary &parentDict) const =0
Construct on freestore as copy with reference to the.
wordList toc() const
Return the table of contents.
void size(const label)
Override size to be inconsistent with allocated storage.
defineTemplateTypeNameAndDebug(IOPtrList< ensightPart >, 0)
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Foam::argList args(argc, argv)
#define WarningInFunction
Report a warning using Foam::Warning.
bool merge(dictionary &, const dictionary &, const bool, const HashTable< wordList, word > &)
IOobject dictIO(dictName, runTime.constant(), mesh, IOobject::MUST_READ_IF_MODIFIED, IOobject::NO_WRITE)
word name(const complex &)
Return a string representation of a complex.
bool add(entry *, bool mergeEntry=false)
Add a new entry.