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]];
392 s.erase(0,
s.find_first_not_of(
" "));
393 s.erase(
s.find_last_not_of(
" ") + 1);
394 s.erase(0,
s.find_first_not_of(
"\t"));
395 s.erase(
s.find_last_not_of(
"\t") + 1);
399 std::vector<std::string>
splitstring (std::string SourceString, std::string strSplit =
" ",
int nSkip = 0 )
401 std::vector<std::string> vecStr;
408 std::string stringsource_new;
409 for (
int i = 0; i < (int)SourceString.length(); i++)
411 if (SourceString[i] == aa || SourceString[i] == bb || SourceString[i] == cc || SourceString[i] == dd)
415 stringsource_new.push_back(SourceString[i]);
420 while (ePos != std::string::npos)
422 if (sPos != ePos) vecStr.push_back(stringsource_new.substr(sPos, ePos - sPos).c_str());
423 sPos = ePos + strSplit.size();
424 ePos = stringsource_new.find(strSplit, sPos);
426 if (sPos < stringsource_new.size()) vecStr.push_back(
trim(stringsource_new.substr(sPos, stringsource_new.size() - sPos)).c_str());
435 int main(
int argc,
char *argv[])
442 "override instance setting (default is the time name)"
451 "treat regular expressions literally (i.e., as a keyword)"
455 "enableFunctionEntries",
456 "enable expansion of dictionary directives - #include, #codeStream etc"
460 "disablePatchGroups",
461 "disable matching keys to patch groups"
471 if (times.
size() < 1)
476 runTime.setTime(times[0], 0);
484 Info<<
"Not interpreting any regular expressions (RE)"
485 <<
" in the changeDictionaryDict." <<
endl
486 <<
"Instead they are handled as any other entry, i.e. added if"
487 <<
" not present." <<
endl;
493 Info<<
"Allowing dictionary preprocessing ('#include', '#codeStream')."
505 const bool disablePatchGroups =
args.
optionFound(
"disablePatchGroups");
506 if (disablePatchGroups)
508 Info<<
"Not interpreting any keys in the changeDictionary"
527 Info <<
"begin read dict!!!" <<
endl;
529 std::string dictPara =
"";
530 dictionary dictChangeDict,dictDictReplacement, dictDictBoundary, dictBoundaryEntry;
533 dictPara =
args[
"dict"];
535 std::vector<std::string> paraList =
splitstring(dictPara);
537 if (paraList[1] ==
"patch")
539 dictBoundaryEntry.
add(
"type",(
word)paraList[1]);
540 dictBoundaryEntry.
add(
"~inGroups",(
word)
" ");
544 dictBoundaryEntry.
add(
"type",(
word)paraList[1]);
545 dictBoundaryEntry.
add(
"inGroups",(
word)paraList[2]);
548 dictDictBoundary.
add((
word)paraList[0],dictBoundaryEntry);
549 dictDictReplacement.
add(
"boundary",dictDictBoundary);
550 dictChangeDict.
add(
"dictionaryReplacement",dictDictReplacement);
561 const dictionary& replaceDicts = dictChangeDict.
subDict(
"dictionaryReplacement");
563 Info<<
"Read dictionary " << dictChangeDict.
name()
564 <<
" with replacements for dictionaries "
572 Info<<
"Reading polyMesh/boundary file to extract patch names"
608 fieldDict.
add(dictList[i].keyword(), dictList[i].
dict());
613 Info<<
"Loaded dictionary " << dictList.
name()
614 <<
" with entries " << fieldDict.
toc() <<
endl;
620 if (!disablePatchGroups)
623 if (patchGroups.
size())
625 Info<<
"Extracted patch groups:" <<
endl;
629 Info<<
" group " << groups[i] <<
" with patches "
630 << patchGroups[groups[i]] <<
endl;
640 const word& fieldName = fieldIter().keyword();
641 Info<<
"Replacing entries in dictionary " << fieldName <<
endl;
646 if (fieldName ==
"boundary")
648 Info<<
"Special handling of " << fieldName
649 <<
" as polyMesh/boundary file." <<
endl;
652 const dictionary& replaceDict = fieldIter().dict();
653 Info<<
"Merging entries from " << replaceDict.
toc() <<
endl;
656 merge(fieldDict, replaceDict, literalRE, patchGroups);
658 Info<<
"fieldDict:" << fieldDict <<
endl;
663 label nEntries = fieldDict.size();
667 doneKeys[i] = dictList[i].keyword();
678 fieldDict.
remove(doneKeys[i]);
686 dictList.
set(sz++, iter().clone());
689 Info<<
"Writing modified " << fieldName <<
endl;
692 runTime.writeFormat(),
693 runTime.writeFormat(),
701 Info<<
"Loading dictionary " << fieldName <<
endl;
702 const word oldTypeName = IOdictionary::typeName;
719 const_cast<word&
>(IOdictionary::typeName) = oldTypeName;
722 const_cast<word&
>(fieldDict.type()) =
725 Info<<
"Loaded dictionary " << fieldName
726 <<
" with entries " << fieldDict.
toc() <<
endl;
729 const dictionary& replaceDict = fieldIter().dict();
730 Info<<
"Merging entries from " << replaceDict.
toc() <<
endl;
733 merge(fieldDict, replaceDict, literalRE, patchGroups);
735 Info<<
"Writing modified fieldDict " << fieldName <<
endl;
736 fieldDict.regIOobject::write();
741 <<
"Requested field to change " << fieldName
742 <<
" 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.
virtual bool writeObject(IOstream::streamFormat, IOstream::versionNumber, IOstream::compressionType) const
Write using given format, version and compression.
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.
std::vector< std::string > splitstring(std::string SourceString, std::string strSplit=" ", int nSkip=0)
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.
bool headerOk()
Read and check header info.
A class for handling keywords in dictionaries.
bool set(const label) const
Is element set.
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.
const word & headerClassName() const
Return name of the class name read from header.
std::string trim(std::string s)
bool erase(const iterator &)
Erase a hashedEntry specified by given iterator.
const word & name() const
Return name.
graph_traits< Graph >::vertices_size_type size_type
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.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
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...
label size() const
Return the number of elements in the PtrList.
bool insert(const Key &key)
Insert a new entry.
void setSize(const label)
Reset size of PtrList. If extending the PtrList, new entries are.
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)
fileName path() const
Return complete path.
#define WarningInFunction
Report a warning using Foam::Warning.
bool merge(dictionary &, const dictionary &, const bool, const HashTable< wordList, word > &)
word name(const complex &)
Return a string representation of a complex.
bool add(entry *, bool mergeEntry=false)
Add a new entry.