104 const word& patchName = iter().keyword();
116 if (fndGroup == groupToPatch.
end())
122 fndGroup().append(patchName);
145 const entry& mergeEntry,
146 const bool literalRE,
150 bool changed =
false;
173 thisDict.
add(mergeEntry.
clone(thisDict).ptr(),
true);
199 else if (shortcuts.
size())
205 const word&
name = shortcutNames[indices[i]];
230 const bool literalRE,
236 bool changed =
false;
244 thisKeysSet.
insert(keys[i]);
252 const keyType& key = mergeIter().keyword();
256 word eraseKey = key(1, key.size()-1);
257 if (thisDict.
remove(eraseKey))
261 thisKeysSet.
erase(eraseKey);
298 thisDict.
add(mergeIter().
clone(thisDict).ptr());
307 if (!literalRE && thisKeysSet.
size() > 0)
314 const keyType& key = mergeIter().keyword();
318 word eraseKey = key(1, key.size()-1);
335 const word& thisKey = thisKeys[matches[i]];
336 thisKeysSet.
erase(thisKey);
357 const word& thisKey = thisKeys[matches[i]];
389 int main(
int argc,
char *argv[])
396 "specify the subDict name of the replacements dictionary"
402 "override instance setting (default is the time name)"
411 "treat regular expressions literally (i.e., as a keyword)"
415 "enableFunctionEntries",
416 "enable expansion of dictionary directives - #include, #codeStream etc"
420 "disablePatchGroups",
421 "disable matching keys to patch groups"
430 <<
"changeDictionary has been superseded by foamDictionary"
431 " and is now deprecated."
438 if (times.
size() < 1)
448 if (times.
size() > 1)
451 <<
"Multiple times selected with 'instance' option"
459 runTime.setTime(times[timei], timei);
460 instance = runTime.name();
468 Info<<
"Not interpreting any regular expressions (RE)"
469 <<
" in the changeDictionaryDict." <<
endl
470 <<
"Instead they are handled as any other entry, i.e. added if"
471 <<
" not present." <<
endl;
477 Info<<
"Allowing dictionary preprocessing "
478 "('#include', '#codeStream')."
490 const bool disablePatchGroups =
args.
optionFound(
"disablePatchGroups");
491 if (disablePatchGroups)
493 Info<<
"Not interpreting any keys in the changeDictionary"
522 const dictionary& replaceDicts = *replaceDictsPtr;
525 <<
" with replacements for dictionaries "
533 Info<<
"Reading polyMesh/boundary file to extract patch names"
560 const_cast<word&
>(dictList.type()) = dictList.headerClassName();
566 fieldDict.
add(dictList[i].keyword(), dictList[i].
dict());
571 Info<<
"Loaded dictionary " << dictList.name()
572 <<
" with entries " << fieldDict.
toc() <<
endl;
578 if (!disablePatchGroups)
580 patchGroups = extractPatchGroups(fieldDict);
581 if (patchGroups.
size())
583 Info<<
"Extracted patch groups:" <<
endl;
587 Info<<
" group " << groups[i] <<
" with patches "
588 << patchGroups[groups[i]] <<
endl;
598 const word& fieldName = fieldIter().keyword();
599 Info<<
"Replacing entries in dictionary " << fieldName <<
endl;
604 if (fieldName ==
"boundary")
606 Info<<
"Special handling of " << fieldName
607 <<
" as polyMesh/boundary file." <<
endl;
610 const dictionary& replaceDict = fieldIter().dict();
611 Info<<
"Merging entries from " << replaceDict.
toc() <<
endl;
614 merge(fieldDict, replaceDict, literalRE, patchGroups);
616 Info<<
"fieldDict:" << fieldDict <<
endl;
621 label nEntries = fieldDict.size();
625 doneKeys[i] = dictList[i].keyword();
636 fieldDict.
remove(doneKeys[i]);
640 label sz = dictList.size();
641 dictList.setSize(nEntries);
644 dictList.set(sz++, iter().
clone());
647 Info<<
"Writing modified " << fieldName <<
endl;
650 runTime.writeFormat(),
651 runTime.writeFormat(),
660 Info<<
"Loading dictionary " << fieldName <<
endl;
661 const word oldTypeName = localIOdictionary::typeName;
677 const_cast<word&
>(localIOdictionary::typeName) = oldTypeName;
680 const_cast<word&
>(fieldDict.type()) =
681 fieldDict.headerClassName();
683 Info<<
"Loaded dictionary " << fieldName
684 <<
" with entries " << fieldDict.
toc() <<
endl;
687 const dictionary& replaceDict = fieldIter().dict();
688 Info<<
"Merging entries from " << replaceDict.
toc() <<
endl;
691 merge(fieldDict, replaceDict, literalRE, patchGroups);
693 Info<<
"Writing modified fieldDict " << fieldName <<
endl;
694 fieldDict.regIOobject::write();
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
A HashTable with keys but without contents.
bool insert(const Key &key)
Insert a new entry.
An STL-conforming iterator.
An STL-conforming hash table.
List< Key > sortedToc() const
Return the table of contents as a sorted list.
bool erase(const iterator &)
Erase a hashedEntry specified by given iterator.
List< Key > toc() const
Return the table of contents.
label size() const
Return number of elements in table.
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
bool found(const Key &) const
Return true if hashedEntry is found in table.
Template class for intrusive linked lists.
A PtrList of objects of type <Type> with automated input and output.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
static fileCheckTypes fileModificationChecking
Type of file modification checking.
void append(const T &)
Append an element at the end of the list.
void size(const label)
Override size to be inconsistent with allocated storage.
static void addOption(const word &opt, const string ¶m="", const string &usage="")
Add to an option to validOptions with usage information.
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
bool optionFound(const word &opt) const
Return true if the named option is found.
IStringStream optionLookup(const word &opt) const
Return an IStringStream from the named option.
const fileName & name() const
Return the dictionary name.
A list of keyword definitions, which are a keyword followed by any number of values (e....
const entry * lookupEntryPtr(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream pointer if present.
const entry & lookupEntry(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream if present otherwise error.
List< keyType > keys(bool patterns=false) const
Return the list of available keys or patterns.
bool remove(const word &)
Remove an entry specified by keyword.
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
bool add(entry *, bool mergeEntry=false)
Add a new entry.
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
wordList toc() const
Return the table of contents.
A keyword and a list of tokens is an 'entry'.
virtual bool isDict() const
Return true if this entry is a dictionary.
const keyType & keyword() const
Return keyword.
virtual const dictionary & dict() const =0
Return dictionary if this entry is a dictionary.
virtual autoPtr< entry > clone(const dictionary &parentDict) const =0
Construct on freestore as copy with reference to the.
static int disableFunctionEntries
A class for handling file names.
A class for handling keywords in dictionaries.
bool isPattern() const
Should be treated as a match rather than a literal string.
localIOdictionary derived from IOdictionary with global set false to disable parallel master reading.
static word defaultRegion
Return the default region name.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
static void addOptions(const bool constant=true, const bool withZero=false)
Add the options handled by timeSelector to argList::validOptions.
static instantList selectIfPresent(Time &runTime, const argList &args)
If any time option provided return the set of times (as select0)
A class for handling words, derived from string.
static const word null
An empty word.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
int main(int argc, char *argv[])
errorManipArg< error, int > exit(error &err, const int errNo=1)
List< word > wordList
A List of words.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
bool findStrings(const wordReListMatcher &matcher, const std::string &str)
Return true if string matches one of the regular expressions.
IOdictionary systemDict(const word &dictName, const argList &args, const objectRegistry &ob, const word ®ionName=polyMesh::defaultRegion)
Ostream & endl(Ostream &os)
Add newline and flush stream.
word name(const bool)
Return a word representation of a bool.
const word & regionName(const solver ®ion)
defineTemplateTypeNameAndDebug(prghPressure, 0)
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
Foam::argList args(argc, argv)
Operations on lists of strings.
static iteratorEnd end()
iteratorEnd set to beyond the end of any HashTable