changeDictionary.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
6  \\/ M anipulation |
7  -------------------------------------------------------------------------------
8  License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24  Application
25  changeDictionary
26 
27  Description
28  Utility to change dictionary entries, e.g. can be used to change the patch
29  type in the field and polyMesh/boundary files.
30 
31  Reads dictionaries (fields) and entries to change from a dictionary.
32  E.g. to make the \em movingWall a \em fixedValue for \em p but all other
33  \em Walls a zeroGradient boundary condition, the
34  \c system/changeDictionaryDict would contain the following:
35  \verbatim
36  dictionaryReplacement
37  {
38  p // field to change
39  {
40  boundaryField
41  {
42  ".*Wall" // entry to change
43  {
44  type zeroGradient;
45  }
46  movingWall // entry to change
47  {
48  type fixedValue;
49  value uniform 123.45;
50  }
51  }
52  }
53  }
54  \endverbatim
55  Replacement entries starting with '~' will remove the entry.
56 
57  Usage
58 
59  - changeDictionary [OPTION]
60 
61  \param -literalRE \n
62  Do not interpret regular expressions or patchGroups;
63  treat them as any other keyword.
64 
65  \param -enableFunctionEntries \n
66  By default all dictionary preprocessing of fields is disabled
67 
68  \param -disablePatchGroups \n
69  By default all keys are also checked for being patchGroups
70 
71  \*---------------------------------------------------------------------------*/
72 
73 #include "argList.H"
74 #include "IOobjectList.H"
75 #include "IOPtrList.H"
76 #include "volFields.H"
77 #include "stringListOps.H"
78 #include "timeSelector.H"
79 #include <vector>
80 using namespace Foam;
81 
82 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
83 
84 namespace Foam
85 {
87 }
88 
89 
90 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
91 
92 // Extract groupPatch (= shortcut) info from boundary file info
94 {
95  HashTable<wordList, word> groupToPatch;
96 
97  forAllConstIter(dictionary, boundaryDict, iter)
98  {
99  const word& patchName = iter().keyword();
100  const dictionary& patchDict = iter().dict();
101 
102  wordList groups;
103  if (patchDict.readIfPresent("inGroups", groups))
104  {
105  forAll(groups, i)
106  {
107  HashTable<wordList, word>::iterator fndGroup = groupToPatch.find
108  (
109  groups[i]
110  );
111  if (fndGroup == groupToPatch.end())
112  {
113  groupToPatch.insert(groups[i], wordList(1, patchName));
114  }
115  else
116  {
117  fndGroup().append(patchName);
118  }
119  }
120  }
121  }
122  return groupToPatch;
123 }
124 
125 
126 bool merge
127 (
128  dictionary&,
129  const dictionary&,
130  const bool,
132  );
133 
134 
135 // Add thisEntry to dictionary thisDict.
136  bool addEntry
137 (
138  dictionary& thisDict,
139  entry& thisEntry,
140  const entry& mergeEntry,
141  const bool literalRE,
142  const HashTable<wordList, word>& shortcuts
143  )
144 {
145  bool changed = false;
146 
147  // Recursively merge sub-dictionaries
148  // TODO: merge without copying
149  if (thisEntry.isDict() && mergeEntry.isDict())
150  {
151  if
152  (
153  merge
154  (
155  const_cast<dictionary&>(thisEntry.dict()),
156  mergeEntry.dict(),
157  literalRE,
158  shortcuts
159  )
160  )
161  {
162  changed = true;
163  }
164  }
165  else
166  {
167  // Should use in-place modification instead of adding
168  thisDict.add(mergeEntry.clone(thisDict).ptr(), true);
169  changed = true;
170  }
171 
172  return changed;
173 }
174 
175 
176 
177 // List of indices into thisKeys
179 (
180  const HashTable<wordList, word>& shortcuts,
181  const wordList& shortcutNames,
182  const wordList& thisKeys,
183  const keyType& key
184  )
185 {
186  labelList matches;
187 
188  if (key.isPattern())
189  {
190  // Wildcard match
191  matches = findStrings(key, thisKeys);
192 
193  }
194  else if (shortcuts.size())
195  {
196  // See if patchGroups expand to valid thisKeys
197  labelList indices = findStrings(key, shortcutNames);
198  forAll(indices, i)
199  {
200  const word& name = shortcutNames[indices[i]];
201  const wordList& keys = shortcuts[name];
202  forAll(keys, j)
203  {
204  label index = findIndex(thisKeys, keys[j]);
205  if (index != -1)
206  {
207  matches.append(index);
208  }
209  }
210  }
211  }
212  return matches;
213 }
214 
215 
216 // Dictionary merging/editing.
217 // literalRE:
218 // - true: behave like dictionary::merge, i.e. add regexps just like
219 // any other key.
220 // - false : interpret wildcard as a rule for items to be matched.
221  bool merge
222 (
223  dictionary& thisDict,
224  const dictionary& mergeDict,
225  const bool literalRE,
226  const HashTable<wordList, word>& shortcuts
227  )
228 {
229  const wordList shortcutNames(shortcuts.toc());
230 
231  bool changed = false;
232 
233  // Save current (non-wildcard) keys before adding items.
234  HashSet<word> thisKeysSet;
235  {
236  List<keyType> keys = thisDict.keys(false);
237  forAll(keys, i)
238  {
239  thisKeysSet.insert(keys[i]);
240  }
241  }
242 
243  // Pass 1. All literal matches
244 
245  forAllConstIter(IDLList<entry>, mergeDict, mergeIter)
246  {
247  const keyType& key = mergeIter().keyword();
248 
249  if (key[0] == '~')
250  {
251  word eraseKey = key(1, key.size()-1);
252  if (thisDict.remove(eraseKey))
253  {
254  // Mark thisDict entry as having been match for wildcard
255  // handling later on.
256  thisKeysSet.erase(eraseKey);
257  }
258  changed = true;
259  }
260  else if (literalRE || !(key.isPattern() || shortcuts.found(key)))
261  {
262  entry* entryPtr = thisDict.lookupEntryPtr
263  (
264  key,
265  false, // recursive
266  false // patternMatch
267  );
268 
269  if (entryPtr)
270  {
271 
272  // Mark thisDict entry as having been match for wildcard
273  // handling later on.
274  thisKeysSet.erase(entryPtr->keyword());
275 
276  if
277  (
278  addEntry
279  (
280  thisDict,
281  *entryPtr,
282  mergeIter(),
283  literalRE,
284  shortcuts
285  )
286  )
287  {
288  changed = true;
289  }
290  }
291  else
292  {
293  // not found - just add
294  thisDict.add(mergeIter().clone(thisDict).ptr());
295  changed = true;
296  }
297  }
298  }
299 
300 
301  // Pass 2. Wildcard or shortcut matches (if any) on any non-match keys.
302 
303  if (!literalRE && thisKeysSet.size() > 0)
304  {
305  // Pick up remaining dictionary entries
306  wordList thisKeys(thisKeysSet.toc());
307 
308  forAllConstIter(IDLList<entry>, mergeDict, mergeIter)
309  {
310  const keyType& key = mergeIter().keyword();
311 
312  if (key[0] == '~')
313  {
314  word eraseKey = key(1, key.size()-1);
315 
316  // List of indices into thisKeys
317  labelList matches
318  (
320  (
321  shortcuts,
322  shortcutNames,
323  thisKeys,
324  eraseKey
325  )
326  );
327 
328  // Remove all matches
329  forAll(matches, i)
330  {
331  const word& thisKey = thisKeys[matches[i]];
332  thisKeysSet.erase(thisKey);
333  }
334  changed = true;
335  }
336  else
337  {
338  // List of indices into thisKeys
339  labelList matches
340  (
342  (
343  shortcuts,
344  shortcutNames,
345  thisKeys,
346  key
347  )
348  );
349 
350  // Add all matches
351  forAll(matches, i)
352  {
353  const word& thisKey = thisKeys[matches[i]];
354 
355  entry& thisEntry = const_cast<entry&>
356  (
357  thisDict.lookupEntry(thisKey, false, false)
358  );
359 
360  if
361  (
362  addEntry
363  (
364  thisDict,
365  thisEntry,
366  mergeIter(),
367  literalRE,
368  HashTable<wordList, word>(0) // no shortcuts
369  // at deeper levels
370  )
371  )
372  {
373  changed = true;
374  }
375  }
376  }
377  }
378  }
379 
380  return changed;
381 }
382 
383 
384 std::string trim(std::string s)
385 {
386 
387 
388  if (s.empty())
389  {
390  return s;
391  }
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);
396  return s;
397 
398 }
399 std::vector<std::string> splitstring (std::string SourceString, std::string strSplit = " ", int nSkip = 0 )
400 {
401  std::vector<std::string> vecStr;
403 
404  char aa = '{';
405  char bb = '}';
406  char cc = '"';
407  char dd = '\'';
408  std::string stringsource_new;
409  for (int i = 0; i < (int)SourceString.length(); i++)
410  {
411  if (SourceString[i] == aa || SourceString[i] == bb || SourceString[i] == cc || SourceString[i] == dd)// || SourceString[i] == ee || SourceString[i] == ff)
412  {
413  }//std::cout << "add nothing" << std::endl;
414  else
415  stringsource_new.push_back(SourceString[i]);
416  }
417 
418  std::vector<std::string>::size_type ePos = stringsource_new.find(strSplit, sPos);
419 
420  while (ePos != std::string::npos)
421  {
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);
425  }
426  if (sPos < stringsource_new.size()) vecStr.push_back(trim(stringsource_new.substr(sPos, stringsource_new.size() - sPos)).c_str());
427 
428  return vecStr;
429 }
430 
431 
432 
433 
434 
435 int main(int argc, char *argv[])
436 {
437 #include "addDictOption.H"
439  (
440  "instance",
441  "name",
442  "override instance setting (default is the time name)"
443  );
444 
445  // Add explicit time option
447 
449  (
450  "literalRE",
451  "treat regular expressions literally (i.e., as a keyword)"
452  );
454  (
455  "enableFunctionEntries",
456  "enable expansion of dictionary directives - #include, #codeStream etc"
457  );
459  (
460  "disablePatchGroups",
461  "disable matching keys to patch groups"
462  );
463 
464 #include "addRegionOption.H"
465 
466 #include "setRootCase.H"
467 #include "createTime.H"
468 
469  // Optionally override controlDict time with -time options
471  if (times.size() < 1)
472  {
474  << "No times selected." << exit(FatalError);
475  }
476  runTime.setTime(times[0], 0);
477  word instance = args.optionLookupOrDefault("instance", runTime.timeName());
478 
479 #include "createNamedMesh.H"
480 
481  const bool literalRE = args.optionFound("literalRE");
482  if (literalRE)
483  {
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;
488  }
489 
490  const bool enableEntries = args.optionFound("enableFunctionEntries");
491  if (enableEntries)
492  {
493  Info<< "Allowing dictionary preprocessing ('#include', '#codeStream')."
494  << endl;
495  }
496 
497  int oldFlag = entry::disableFunctionEntries;
498  if (!enableEntries)
499  {
500  // By default disable dictionary expansion for fields
502  }
503 
504 
505  const bool disablePatchGroups = args.optionFound("disablePatchGroups");
506  if (disablePatchGroups)
507  {
508  Info<< "Not interpreting any keys in the changeDictionary"
509  << " as patchGroups"
510  << endl;
511  }
512 
513 
514  fileName regionPrefix = "";
516  {
517  regionPrefix = regionName;
518  }
519 
520 
521  // Make sure we do not use the master-only reading since we read
522  // fields (different per processor) as dictionaries.
524 
525 
526  // Get the replacement rules from a dictionary
527  Info << "begin read dict!!!" << endl;
528  //=====================================================================================
529  std::string dictPara = "";
530  dictionary dictChangeDict,dictDictReplacement, dictDictBoundary, dictBoundaryEntry;
531  if (args.optionFound("dict"))
532  {
533  dictPara = args["dict"];
534 
535  std::vector<std::string> paraList = splitstring(dictPara);
536 
537  if (paraList[1] == "patch")
538  {
539  dictBoundaryEntry.add("type",(word)paraList[1]);
540  dictBoundaryEntry.add("~inGroups",(word)" ");
541  }
542  else
543  {
544  dictBoundaryEntry.add("type",(word)paraList[1]);
545  dictBoundaryEntry.add("inGroups",(word)paraList[2]);
546  }
547 
548  dictDictBoundary.add((word)paraList[0],dictBoundaryEntry);
549  dictDictReplacement.add("boundary",dictDictBoundary);
550  dictChangeDict.add("dictionaryReplacement",dictDictReplacement);
551  }
552 
553  Info << "DictA = " << endl << dictChangeDict << endl;
554 
555  //=====================================================================================
556  // const word dictName("changeDictionaryDict");
557  //#include "setSystemMeshDictionaryIO.H"
558  // IOdictionary dict(dictIO);
559 
560  //const dictionary& replaceDicts = dict.subDict("dictionaryReplacement");
561  const dictionary& replaceDicts = dictChangeDict.subDict("dictionaryReplacement");
562 
563  Info<< "Read dictionary " << dictChangeDict.name()
564  << " with replacements for dictionaries "
565  << replaceDicts.toc() << endl;
566 
567 
568 
569  // Always read boundary to get patch groups
570  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
571 
572  Info<< "Reading polyMesh/boundary file to extract patch names"
573  << endl;
574 
575  // Read PtrList of dictionary as dictionary.
576  const word oldTypeName = IOPtrList<entry>::typeName;
578  IOPtrList<entry> dictList
579  (
580  IOobject
581  (
582  "boundary",
583  runTime.findInstance
584  (
585  regionPrefix/polyMesh::meshSubDir,
586  "boundary",
588  ),
590  mesh,
593  false
594  )
595  );
596 
597 
598 
599 
600  const_cast<word&>(IOPtrList<entry>::typeName) = oldTypeName;
601  // Fake type back to what was in field
602  const_cast<word&>(dictList.type()) = dictList.headerClassName();
603 
604  // Temporary convert to dictionary
605  dictionary fieldDict;
606  forAll(dictList, i)
607  {
608  fieldDict.add(dictList[i].keyword(), dictList[i].dict());
609  }
610 
611  if (dictList.size())
612  {
613  Info<< "Loaded dictionary " << dictList.name()
614  << " with entries " << fieldDict.toc() << endl;
615  }
616 
617  // Extract any patchGroups information (= shortcut for set of
618  // patches)
619  HashTable<wordList, word> patchGroups;
620  if (!disablePatchGroups)
621  {
622  patchGroups = extractPatchGroups(fieldDict);
623  if (patchGroups.size())
624  {
625  Info<< "Extracted patch groups:" << endl;
626  wordList groups(patchGroups.sortedToc());
627  forAll(groups, i)
628  {
629  Info<< " group " << groups[i] << " with patches "
630  << patchGroups[groups[i]] << endl;
631  }
632  }
633  }
634 
635 
636  // Every replacement is a dictionary name and a keyword in this
637 
638  forAllConstIter(dictionary, replaceDicts, fieldIter)
639  {
640  const word& fieldName = fieldIter().keyword();
641  Info<< "Replacing entries in dictionary " << fieldName << endl;
642 
643  // Handle 'boundary' specially:
644  // - is PtrList of dictionaries
645  // - is in polyMesh/
646  if (fieldName == "boundary")
647  {
648  Info<< "Special handling of " << fieldName
649  << " as polyMesh/boundary file." << endl;
650 
651  // Get the replacement dictionary for the field
652  const dictionary& replaceDict = fieldIter().dict();
653  Info<< "Merging entries from " << replaceDict.toc() << endl;
654 
655  // Merge the replacements in
656  merge(fieldDict, replaceDict, literalRE, patchGroups);
657 
658  Info<< "fieldDict:" << fieldDict << endl;
659 
660  // Convert back into dictList
661  wordList doneKeys(dictList.size());
662 
663  label nEntries = fieldDict.size();
664 
665  forAll(dictList, i)
666  {
667  doneKeys[i] = dictList[i].keyword();
668  dictList.set
669  (
670  i,
671  fieldDict.lookupEntry
672  (
673  doneKeys[i],
674  false,
675  true
676  ).clone()
677  );
678  fieldDict.remove(doneKeys[i]);
679  }
680 
681  // Add remBaining entries
682  label sz = dictList.size();
683  dictList.setSize(nEntries);
684  forAllConstIter(dictionary, fieldDict, iter)
685  {
686  dictList.set(sz++, iter().clone());
687  }
688 
689  Info<< "Writing modified " << fieldName << endl;
690  dictList.writeObject
691  (
692  runTime.writeFormat(),
693  runTime.writeFormat(),
695  );
696  }
697  else
698  {
699  // Read dictionary
700  // Note: disable class type checking so we can load field
701  Info<< "Loading dictionary " << fieldName << endl;
702  const word oldTypeName = IOdictionary::typeName;
703  const_cast<word&>(IOdictionary::typeName) = word::null;
704 
705  IOobject fieldHeader
706  (
707  fieldName,
708  instance,
709  mesh,
712  false
713  );
714 
715  if (fieldHeader.headerOk())
716  {
717  IOdictionary fieldDict(fieldHeader);
718 
719  const_cast<word&>(IOdictionary::typeName) = oldTypeName;
720 
721  // Fake type back to what was in field
722  const_cast<word&>(fieldDict.type()) =
723  fieldDict.headerClassName();
724 
725  Info<< "Loaded dictionary " << fieldName
726  << " with entries " << fieldDict.toc() << endl;
727 
728  // Get the replacement dictionary for the field
729  const dictionary& replaceDict = fieldIter().dict();
730  Info<< "Merging entries from " << replaceDict.toc() << endl;
731 
732  // Merge the replacements in
733  merge(fieldDict, replaceDict, literalRE, patchGroups);
734 
735  Info<< "Writing modified fieldDict " << fieldName << endl;
736  fieldDict.regIOobject::write();
737  }
738  else
739  {
741  << "Requested field to change " << fieldName
742  << " does not exist in " << fieldHeader.path() << endl;
743  }
744  }
745  }
746 
748 
749  Info<< endl;
750 
751  Info<< "End\n" << endl;
752 
753  return 0;
754 }
755 
756 
757 // ************************************************************************* //
Foam::entry
A keyword and a list of tokens is an 'entry'.
Definition: entry.H:65
volFields.H
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:53
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::dictionary::lookupEntry
const entry & lookupEntry(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream if present otherwise error.
Definition: dictionary.C:426
Foam::regIOobject::writeObject
virtual bool writeObject(IOstream::streamFormat, IOstream::versionNumber, IOstream::compressionType) const
Write using given format, version and compression.
Definition: regIOobjectWrite.C:37
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::IOPtrList
A PtrList of objects of type <T> with automated input and output.
Definition: IOPtrList.H:50
Foam::HashTable::iterator
An STL-conforming iterator.
Definition: HashTable.H:415
Foam::entry::keyword
const keyType & keyword() const
Return keyword.
Definition: entry.H:120
Foam::HashTable::toc
List< Key > toc() const
Return the table of contents.
Definition: HashTable.C:201
Foam::argList::addOption
static void addOption(const word &opt, const string &param="", const string &usage="")
Add to an option to validOptions with usage information.
Definition: argList.C:108
Foam::polyMesh::defaultRegion
static word defaultRegion
Return the default region name.
Definition: polyMesh.H:306
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::findIndex
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
Foam::dictionaryName::name
const fileName & name() const
Return the dictionary name.
Definition: dictionary.H:103
Foam::keyType::isPattern
bool isPattern() const
Should be treated as a match rather than a literal string.
Definition: keyTypeI.H:76
Foam::dictionary::readIfPresent
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
Definition: dictionaryTemplates.C:94
splitstring
std::vector< std::string > splitstring(std::string SourceString, std::string strSplit=" ", int nSkip=0)
Definition: changeDictionary.C:399
Foam::polyMesh::meshSubDir
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
Definition: polyMesh.H:309
Foam::argList::addBoolOption
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
Definition: argList.C:98
Foam::HashTable::insert
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
Definition: HashTableI.H:80
Foam::dictionary::remove
bool remove(const word &)
Remove an entry specified by keyword.
Definition: dictionary.C:881
IOobjectList.H
extractPatchGroups
HashTable< wordList, word > extractPatchGroups(const dictionary &boundaryDict)
Definition: changeDictionary.C:93
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::HashSet
A HashTable with keys but without contents.
Definition: HashSet.H:59
Foam::IOobject::NO_WRITE
@ NO_WRITE
Definition: IOobject.H:118
forAllConstIter
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:39
addDictOption.H
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:54
Foam::dictionary::keys
List< keyType > keys(bool patterns=false) const
Return the list of available keys or patterns.
Definition: dictionary.C:711
Foam::IOobject::headerOk
bool headerOk()
Read and check header info.
Definition: IOobject.C:439
Foam::IOobject::MUST_READ_IF_MODIFIED
@ MUST_READ_IF_MODIFIED
Definition: IOobject.H:109
Foam::keyType
A class for handling keywords in dictionaries.
Definition: keyType.H:56
regionName
Foam::word regionName
Definition: createNamedDynamicFvMesh.H:1
Foam::regIOobject::timeStamp
@ timeStamp
Definition: regIOobject.H:70
Foam::PtrList< T >::set
bool set(const label) const
Is element set.
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::IDLList< entry >
Foam::entry::isDict
virtual bool isDict() const
Return true if this entry is a dictionary.
Definition: entry.H:153
Foam::List::append
void append(const T &)
Append an element at the end of the list.
IOPtrList.H
Foam::IOobject::headerClassName
const word & headerClassName() const
Return name of the class name read from header.
Definition: IOobject.H:279
Foam::Info
messageStream Info
argList.H
trim
std::string trim(std::string s)
Definition: changeDictionary.C:384
addRegionOption.H
Foam::HashTable< nil, word, string::hash >::erase
bool erase(const iterator &)
Erase a hashedEntry specified by given iterator.
Foam::IOobject::name
const word & name() const
Return name.
Definition: IOobject.H:273
size_type
graph_traits< Graph >::vertices_size_type size_type
Definition: SloanRenumber.C:73
Foam::timeSelector::selectIfPresent
static instantList selectIfPresent(Time &runTime, const argList &args)
If any time option provided return the set of times (as select0)
Definition: timeSelector.C:284
Foam::argList::optionLookupOrDefault
T optionLookupOrDefault(const word &opt, const T &deflt) const
Read a value from the named option if present.
Definition: argListI.H:237
main
int main(int argc, char *argv[])
Definition: changeDictionary.C:435
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::HashTable::size
label size() const
Return number of elements in table.
Definition: HashTableI.H:65
createNamedMesh.H
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::HashTable::found
bool found(const Key &) const
Return true if hashedEntry is found in table.
Definition: HashTable.C:109
addEntry
bool addEntry(dictionary &thisDict, entry &thisEntry, const entry &mergeEntry, const bool literalRE, const HashTable< wordList, word > &shortcuts)
Definition: changeDictionary.C:137
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::entry::disableFunctionEntries
static int disableFunctionEntries
Definition: entry.H:83
Foam::entry::dict
virtual const dictionary & dict() const =0
Return dictionary if this entry is a dictionary.
Foam::HashTable::sortedToc
List< Key > sortedToc() const
Return the table of contents as a sorted list.
Definition: HashTable.C:216
s
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))
Foam::HashTable::find
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Foam::HashTable
An STL-conforming hash table.
Definition: HashTable.H:61
Foam::regIOobject::fileModificationChecking
static fileCheckTypes fileModificationChecking
Definition: regIOobject.H:128
setRootCase.H
Foam::findStrings
bool findStrings(const wordReListMatcher &matcher, const std::string &str)
Return true if string matches one of the regular expressions.
Definition: stringListOps.H:52
Foam::dictionary::lookupEntryPtr
const entry * lookupEntryPtr(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream pointer if present.
Definition: dictionary.C:343
findMatches
labelList findMatches(const HashTable< wordList, word > &shortcuts, const wordList &shortcutNames, const wordList &thisKeys, const keyType &key)
Definition: changeDictionary.C:179
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::timeSelector::addOptions
static void addOptions(const bool constant=true, const bool withZero=false)
Add the options handled by timeSelector to argList::validOptions.
Definition: timeSelector.C:114
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::PtrList< T >::size
label size() const
Return the number of elements in the PtrList.
Definition: PtrListI.H:32
Foam::HashSet::insert
bool insert(const Key &key)
Insert a new entry.
Definition: HashSet.H:116
Foam::PtrList< T >::setSize
void setSize(const label)
Reset size of PtrList. If extending the PtrList, new entries are.
Definition: PtrList.C:142
Foam::word::null
static const word null
An empty word.
Definition: word.H:77
timeSelector.H
createTime.H
Foam::argList::optionFound
bool optionFound(const word &opt) const
Return true if the named option is found.
Definition: argListI.H:108
Foam::IOstream::UNCOMPRESSED
@ UNCOMPRESSED
Definition: IOstream.H:195
stringListOps.H
Operations on lists of strings.
Foam::entry::clone
virtual autoPtr< entry > clone(const dictionary &parentDict) const =0
Construct on freestore as copy with reference to the.
Foam::dictionary::toc
wordList toc() const
Return the table of contents.
Definition: dictionary.C:697
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
Foam::defineTemplateTypeNameAndDebug
defineTemplateTypeNameAndDebug(IOPtrList< ensightPart >, 0)
Foam::dictionary::subDict
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:631
args
Foam::argList args(argc, argv)
Foam::IOobject::READ_IF_PRESENT
@ READ_IF_PRESENT
Definition: IOobject.H:110
Foam::IOobject::path
fileName path() const
Return complete path.
Definition: IOobject.C:293
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:259
merge
bool merge(dictionary &, const dictionary &, const bool, const HashTable< wordList, word > &)
Definition: changeDictionary.C:222
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
Foam::dictionary::add
bool add(entry *, bool mergeEntry=false)
Add a new entry.
Definition: dictionary.C:729