dictionary.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2015-2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "dictionary.H"
30 #include "error.H"
31 #include "JobInfo.H"
32 #include "primitiveEntry.H"
33 #include "dictionaryEntry.H"
34 #include "regExp.H"
35 #include "OSHA1stream.H"
36 #include "argList.H"
37 #include "registerSwitch.H"
38 
39 /* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
40 
41 namespace Foam
42 {
43  defineTypeNameAndDebug(dictionary, 0);
44 }
45 
47 
49 (
50  Foam::debug::infoSwitch("writeOptionalEntries", 0)
51 );
52 
53 
55 (
56  "writeOptionalEntries",
57  int,
59 );
60 
61 
62 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
63 
64 Foam::fileName Foam::dictionary::relativeName(const bool caseTag) const
65 {
66  const fileName caseDir(argList::envGlobalPath());
67 
68  if (!caseDir.empty() && name().isAbsolute())
69  {
70  return name().relative(caseDir, caseTag);
71  }
72  else
73  {
74  return name();
75  }
76 }
77 
78 
79 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
80 
82 :
83  name_(),
84  parent_(dictionary::null)
85 {}
86 
87 
89 :
90  name_(name),
91  parent_(dictionary::null)
92 {}
93 
94 
96 (
97  const dictionary& parentDict,
98  const dictionary& dict
99 )
100 :
101  parent_type(dict, *this),
102  name_(dict.name()),
103  parent_(parentDict)
104 {
105  for (entry& e : *this)
106  {
107  hashedEntries_.insert(e.keyword(), &e);
108 
109  if (e.keyword().isPattern())
110  {
111  patterns_.insert(&e);
112  regexps_.insert(autoPtr<regExp>::New(e.keyword()));
113  }
114  }
115 }
116 
117 
119 (
120  const dictionary& dict
121 )
122 :
123  parent_type(dict, *this),
124  name_(dict.name()),
125  parent_(dictionary::null)
126 {
127  for (entry& e : *this)
128  {
129  hashedEntries_.insert(e.keyword(), &e);
130 
131  if (e.keyword().isPattern())
132  {
133  patterns_.insert(&e);
134  regexps_.insert(autoPtr<regExp>::New(e.keyword()));
135  }
136  }
137 }
138 
139 
141 :
142  name_(),
143  parent_(dictionary::null)
144 {
145  if (dict)
146  {
147  operator=(*dict);
148  }
149 }
150 
151 
153 (
154  const dictionary& parentDict,
155  dictionary&& dict
156 )
157 :
158  name_(),
159  parent_(parentDict)
160 {
161  transfer(dict);
162  name() = fileName::concat(parentDict.name(), name(), '.');
163 }
164 
165 
167 (
168  dictionary&& dict
169 )
170 :
171  name_(),
172  parent_(dictionary::null)
173 {
174  transfer(dict);
175 }
176 
177 
179 {
180  return autoPtr<dictionary>::New(*this);
181 }
182 
183 
184 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
185 
187 {}
188 
189 
190 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
191 
193 {
194  const dictionary& p = parent();
195 
196  if (&p != this && !p.name().empty())
197  {
198  return p.topDict();
199  }
200 
201  return *this;
202 }
203 
204 
206 {
207  if (size())
208  {
209  return first()->startLineNumber();
210  }
211 
212  return -1;
213 }
214 
215 
217 {
218  if (size())
219  {
220  return last()->endLineNumber();
221  }
222 
223  return -1;
224 }
225 
226 
228 {
229  OSHA1stream os;
230 
231  // Process entries
232  for (const entry& e : *this)
233  {
234  os << e;
235  }
236 
237  return os.digest();
238 }
239 
240 
242 {
243  // Serialize dictionary entries into a string
244  OStringStream os;
245 
246  // Process entries
247  for (const entry& e : *this)
248  {
249  os << e;
250  }
251 
252  // String re-parsed as a list of tokens
253  return ITstream::parse(os.str());
254 }
255 
256 
258 (
259  const ITstream& is,
260  const word& keyword
261 ) const
262 {
263  if (is.nRemainingTokens())
264  {
265  const label remaining = is.nRemainingTokens();
266 
267  // Similar to SafeFatalIOError
269  {
270  OSstream& err =
272  (
273  "", // functionName
274  "", // sourceFileName
275  0, // sourceFileLineNumber
276  this->name(), // ioFileName
277  is.lineNumber() // ioStartLineNumber
278  );
279 
280  err << "Entry '" << keyword << "' has "
281  << remaining << " excess tokens in stream" << nl << nl
282  << " ";
283  is.writeList(err, 0);
284 
285  err << exit(FatalIOError);
286  }
287  else
288  {
289  std::cerr
290  << nl
291  << "--> FOAM FATAL IO ERROR:" << nl;
292 
293  std::cerr
294  << "Entry '" << keyword << "' has "
295  << remaining << " excess tokens in stream" << nl << nl;
296 
297  std::cerr
298  << "file: " << this->name()
299  << " at line " << is.lineNumber() << '.' << nl
300  << std::endl;
301 
302  std::exit(1);
303  }
304  }
305  else if (!is.size())
306  {
307  // Similar to SafeFatalIOError
309  {
311  (
312  "", // functionName
313  "", // sourceFileName
314  0, // sourceFileLineNumber
315  this->name(), // ioFileName
316  is.lineNumber() // ioStartLineNumber
317  )
318  << "Entry '" << keyword
319  << "' had no tokens in stream" << nl << nl
320  << exit(FatalIOError);
321  }
322  else
323  {
324  std::cerr
325  << nl
326  << "--> FOAM FATAL IO ERROR:" << nl
327  << "Entry '" << keyword
328  << "' had no tokens in stream" << nl << nl;
329 
330  std::cerr
331  << "file: " << this->name()
332  << " at line " << is.lineNumber() << '.' << nl
333  << std::endl;
334 
335  std::exit(1);
336  }
337  }
338 }
339 
340 
341 void Foam::dictionary::raiseBadInput
342 (
343  const ITstream& is,
344  const word& keyword
345 ) const
346 {
347  // Can use FatalIOError instead of SafeFatalIOError
348  // since predicate checks are not used at the earliest stages
350  (
351  "", // functionName
352  "", // sourceFileName
353  0, // sourceFileLineNumber
354  this->name(), // ioFileName
355  is.lineNumber(), // ioStartLineNumber
356  -1 // ioEndLineNumber
357  )
358  << "Entry '" << keyword << "' with invalid input" << nl
359  << exit(FatalIOError);
360 }
361 
362 
364 (
365  const word& keyword,
366  enum keyType::option matchOpt
367 ) const
368 {
369  return csearch(keyword, matchOpt).good();
370 }
371 
372 
374 (
375  const word& keyword,
376  enum keyType::option matchOpt
377 )
378 {
379  return search(keyword, matchOpt).ptr();
380 }
381 
382 
384 (
385  const word& keyword,
386  enum keyType::option matchOpt
387 ) const
388 {
389  return csearch(keyword, matchOpt).ptr();
390 }
391 
392 
394 (
395  const word& keyword,
396  enum keyType::option matchOpt
397 ) const
398 {
399  return csearchScoped(keyword, matchOpt).ptr();
400 }
401 
402 
404 (
405  const word& keyword,
406  enum keyType::option matchOpt
407 ) const
408 {
409  const const_searcher finder(csearch(keyword, matchOpt));
410 
411  if (!finder.good())
412  {
414  << "Entry '" << keyword << "' not found in dictionary "
415  << name() << nl
416  << exit(FatalIOError);
417  }
418 
419  return finder.ref();
420 }
421 
422 
424 (
425  const word& keyword,
426  enum keyType::option matchOpt
427 ) const
428 {
429  return lookupEntry(keyword, matchOpt).stream();
430 }
431 
432 
434 (
435  const word& keyword,
436  bool mergeEntry
437 )
438 {
439  if (keyword.size() < 2)
440  {
441  return false;
442  }
443 
444  // Drop leading '$' to get the var-name, already validated as word.
445  const word varName(keyword.substr(1), false);
446 
447  // Lookup the variable name in the given dictionary
448  const const_searcher finder(csearch(varName, keyType::REGEX_RECURSIVE));
449 
450  // If defined insert its entries into this dictionary
451  if (finder.good())
452  {
453  for (const entry& e : finder.dict())
454  {
455  add(e, mergeEntry);
456  }
457 
458  return true;
459  }
460 
461  return false;
462 }
463 
464 
466 (
467  const word& keyword,
468  bool mergeEntry
469 )
470 {
471  if (keyword.size() < 2)
472  {
473  return false;
474  }
475 
476  // Drop leading '$' to get the var-name, already validated as word.
477  const word varName(keyword.substr(1), false);
478 
479  // Lookup the variable name in the given dictionary
480  const auto finder(csearchScoped(varName, keyType::REGEX_RECURSIVE));
481 
482  // If defined insert its entries into this dictionary
483  if (finder.good())
484  {
485  for (const entry& e : finder.dict())
486  {
487  add(e, mergeEntry);
488  }
489 
490  return true;
491  }
492 
493  return false;
494 }
495 
496 
498 (
499  const word& keyword,
500  enum keyType::option matchOpt
501 ) const
502 {
503  return csearch(keyword, matchOpt).isDict();
504 }
505 
506 
508 (
509  const word& keyword,
510  enum keyType::option matchOpt
511 )
512 {
513  return search(keyword, matchOpt).dictPtr();
514 }
515 
516 
518 (
519  const word& keyword,
520  enum keyType::option matchOpt
521 ) const
522 {
523  return csearch(keyword, matchOpt).dictPtr();
524 }
525 
526 
528 (
529  const word& keyword,
530  enum keyType::option matchOpt
531 ) const
532 {
533  const const_searcher finder(csearch(keyword, matchOpt));
534 
535  if (!finder.good())
536  {
538  << "Entry '" << keyword << "' not found in dictionary "
539  << name() << nl
540  << exit(FatalIOError);
541  }
542 
543  return finder.dict();
544 }
545 
546 
548 (
549  const word& keyword,
550  enum keyType::option matchOpt
551 )
552 {
553  searcher finder(search(keyword, matchOpt));
554 
555  if (!finder.good())
556  {
558  << "Entry '" << keyword << "' not found in dictionary "
559  << name() << nl
560  << exit(FatalIOError);
561  }
562 
563  return finder.dict();
564 }
565 
566 
568 (
569  const word& keyword,
570  enum keyType::option matchOpt
571 )
572 {
573  searcher finder(search(keyword, matchOpt));
574 
575  dictionary* ptr = finder.dictPtr();
576 
577  if (ptr)
578  {
579  // Found and a sub-dictionary
580  return *ptr;
581  }
582 
583  if (finder.good())
584  {
586  << "Entry '" << keyword
587  << "' is not a sub-dictionary in dictionary "
588  << name() << nl
589  << exit(FatalIOError);
590  }
591 
592  ptr = this->set(keyword, dictionary())->dictPtr();
593 
594  if (!ptr)
595  {
597  << "Failed to insert sub-dictionary '" << keyword
598  << "' in dictionary "
599  << name() << nl
600  << exit(FatalIOError);
601  }
602 
603  return *ptr;
604 }
605 
606 
608 (
609  const word& keyword,
610  enum keyType::option matchOpt,
611  const bool mandatory
612 ) const
613 {
614  const const_searcher finder(csearch(keyword, matchOpt));
615 
616  if (finder.isDict())
617  {
618  // Found and a sub-dictionary
619  return finder.dict();
620  }
621 
622  if (mandatory)
623  {
625  << "Entry '" << keyword
626  << "' is not a sub-dictionary in dictionary "
627  << name() << nl
628  << exit(FatalIOError);
629  }
630 
631  if (finder.good())
632  {
633  IOWarningInFunction(*this)
634  << "Entry '" << keyword
635  << "' found but not a sub-dictionary in dictionary "
636  << name() << endl;
637  }
638 
639  // The move constructor properly qualifies the dictionary name
640  return dictionary(*this, dictionary(fileName(keyword)));
641 }
642 
643 
645 (
646  const word& keyword,
647  enum keyType::option matchOpt
648 ) const
649 {
650  const const_searcher finder(csearch(keyword, matchOpt));
651 
652  if (finder.isDict())
653  {
654  // Found and a sub-dictionary
655  return finder.dict();
656  }
657 
658  if (finder.good())
659  {
660  IOWarningInFunction(*this)
661  << "Entry '" << keyword
662  << "' found but not a sub-dictionary in dictionary "
663  << name() << endl;
664  }
665 
666  return *this;
667 }
668 
669 
671 {
672  wordList list(size());
673 
674  label n = 0;
675  for (const entry& e : *this)
676  {
677  list[n++] = e.keyword();
678  }
679 
680  return list;
681 }
682 
683 
685 {
686  return hashedEntries_.sortedToc();
687 }
688 
689 
691 {
692  List<keyType> list(size());
693 
694  label n = 0;
695  for (const entry& e : *this)
696  {
697  if (e.keyword().isPattern() ? patterns : !patterns)
698  {
699  list[n++] = e.keyword();
700  }
701  }
702  list.resize(n);
703 
704  return list;
705 }
706 
707 
708 Foam::entry* Foam::dictionary::add(entry* entryPtr, bool mergeEntry)
709 {
710  if (!entryPtr)
711  {
712  return nullptr;
713  }
714 
715  auto iter = hashedEntries_.find(entryPtr->keyword());
716 
717  if (mergeEntry && iter.good())
718  {
719  // Merge dictionary with dictionary
720  if (iter()->isDict() && entryPtr->isDict())
721  {
722  iter()->dict().merge(entryPtr->dict());
723 
724  delete entryPtr;
725  return iter(); // pointer to existing dictionary
726  }
727 
728 
729  // Replace existing dictionary with entry or vice versa
730  parent_type::replace(iter(), entryPtr);
731  delete iter();
732  hashedEntries_.erase(iter);
733 
734  if (hashedEntries_.insert(entryPtr->keyword(), entryPtr))
735  {
736  entryPtr->name() =
737  fileName::concat(name(), entryPtr->keyword(), '.');
738 
739  if (entryPtr->keyword().isPattern())
740  {
741  patterns_.insert(entryPtr);
742  regexps_.insert(autoPtr<regExp>::New(entryPtr->keyword()));
743  }
744 
745  return entryPtr; // now an entry in the dictionary
746  }
747 
748 
749  IOWarningInFunction(*this)
750  << "Problem replacing entry "<< entryPtr->keyword()
751  << " in dictionary " << name() << endl;
752 
753  parent_type::remove(entryPtr);
754 
755  delete entryPtr;
756  return nullptr;
757  }
758 
759 
760  if (hashedEntries_.insert(entryPtr->keyword(), entryPtr))
761  {
762  entryPtr->name() =
763  fileName::concat(name(), entryPtr->keyword(), '.');
764 
765  parent_type::append(entryPtr);
766 
767  if (entryPtr->keyword().isPattern())
768  {
769  patterns_.insert(entryPtr);
770  regexps_.insert(autoPtr<regExp>::New(entryPtr->keyword()));
771  }
772 
773  return entryPtr; // now an entry in the dictionary
774  }
775 
776 
777  IOWarningInFunction(*this)
778  << "Attempt to add entry " << entryPtr->keyword()
779  << " which already exists in dictionary " << name() << endl;
780 
781  delete entryPtr;
782  return nullptr;
783 }
784 
785 
786 Foam::entry* Foam::dictionary::add(const entry& e, bool mergeEntry)
787 {
788  return add(e.clone(*this).ptr(), mergeEntry);
789 }
790 
791 
793 (
794  const keyType& k,
795  const word& v,
796  bool overwrite
797 )
798 {
799  return add(new primitiveEntry(k, token(v)), overwrite);
800 }
801 
802 
804 (
805  const keyType& k,
806  const Foam::string& v,
807  bool overwrite
808 )
809 {
810  return add(new primitiveEntry(k, token(v)), overwrite);
811 }
812 
813 
815 (
816  const keyType& k,
817  const label v,
818  bool overwrite
819 )
820 {
821  return add(new primitiveEntry(k, token(v)), overwrite);
822 }
823 
824 
826 (
827  const keyType& k,
828  const scalar v,
829  bool overwrite
830 )
831 {
832  return add(new primitiveEntry(k, token(v)), overwrite);
833 }
834 
835 
837 (
838  const keyType& k,
839  const dictionary& v,
840  bool mergeEntry
841 )
842 {
843  return add(new dictionaryEntry(k, *this, v), mergeEntry);
844 }
845 
846 
848 {
849  if (!entryPtr)
850  {
851  return nullptr;
852  }
853 
854  // Find non-recursive with patterns
855  searcher finder(search(entryPtr->keyword(), keyType::REGEX));
856 
857  // Clear dictionary so merge acts like overwrite
858  if (finder.isDict())
859  {
860  finder.dict().clear();
861  }
862 
863  return add(entryPtr, true);
864 }
865 
866 
868 {
869  return set(e.clone(*this).ptr());
870 }
871 
872 
874 {
875  return set(new dictionaryEntry(k, *this, v));
876 }
877 
878 
880 {
881  if (this == &dict)
882  {
884  << "Attempted merge to self, for dictionary "
885  << name() << nl
886  << abort(FatalIOError);
887  }
888 
889  bool changed = false;
890 
891  for (const entry& e : dict)
892  {
893  auto fnd = hashedEntries_.find(e.keyword());
894 
895  if (fnd.good())
896  {
897  // Recursively merge sub-dictionaries
898  // TODO: merge without copying
899  if (fnd()->isDict() && e.isDict())
900  {
901  if (fnd()->dict().merge(e.dict()))
902  {
903  changed = true;
904  }
905  }
906  else
907  {
908  add(e.clone(*this).ptr(), true);
909  changed = true;
910  }
911  }
912  else
913  {
914  // Not found - just add
915  add(e.clone(*this).ptr());
916  changed = true;
917  }
918  }
919 
920  return changed;
921 }
922 
923 
925 {
927  hashedEntries_.clear();
928  patterns_.clear();
929  regexps_.clear();
930 }
931 
932 
934 {
935  // Changing parents probably doesn't make much sense,
936  // but what about the names?
937  name() = dict.name();
938 
939  parent_type::transfer(dict);
940  hashedEntries_.transfer(dict.hashedEntries_);
941  patterns_.transfer(dict.patterns_);
942  regexps_.transfer(dict.regexps_);
943 }
944 
945 
946 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
947 
949 {
950  if (this == &rhs)
951  {
952  return; // Self-assignment is a no-op
953  }
954 
955  name() = rhs.name();
956  clear();
957 
958  // Create clones of the entries in the given dictionary
959  // resetting the parentDict to this dictionary
960 
961  for (const entry& e : rhs)
962  {
963  add(e.clone(*this).ptr());
964  }
965 }
966 
967 
969 {
970  if (this == &rhs)
971  {
973  << "Attempted addition to self, for dictionary "
974  << name() << nl
975  << abort(FatalIOError);
976  }
977 
978  for (const entry& e : rhs)
979  {
980  add(e.clone(*this).ptr());
981  }
982 }
983 
984 
986 {
987  if (this == &rhs)
988  {
990  << "Attempted |= merging to self, for dictionary "
991  << name() << nl
992  << abort(FatalIOError);
993  }
994 
995  for (const entry& e : rhs)
996  {
997  if (!found(e.keyword()))
998  {
999  add(e.clone(*this).ptr());
1000  }
1001  }
1002 }
1003 
1004 
1006 {
1007  if (this == &rhs)
1008  {
1009  FatalIOErrorInFunction(*this)
1010  << "Attempted addition to self, for dictionary "
1011  << name() << nl
1012  << abort(FatalIOError);
1013  }
1014 
1015  for (const entry& e : rhs)
1016  {
1017  set(e.clone(*this).ptr());
1018  }
1019 }
1020 
1021 
1022 /* * * * * * * * * * * * * * * * Global operators * * * * * * * * * * * * * */
1023 
1024 Foam::dictionary Foam::operator+
1026  const dictionary& dict1,
1027  const dictionary& dict2
1028 )
1029 {
1030  dictionary sum(dict1);
1031  sum += dict2;
1032  return sum;
1033 }
1034 
1035 
1036 Foam::dictionary Foam::operator|
1038  const dictionary& dict1,
1039  const dictionary& dict2
1040 )
1041 {
1042  dictionary sum(dict1);
1043  sum |= dict2;
1044  return sum;
1045 }
1046 
1047 
1048 // ************************************************************************* //
Foam::entry
A keyword and a list of tokens is an 'entry'.
Definition: entry.H:67
Foam::dictionary::findDict
dictionary * findDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find and return a sub-dictionary pointer if present.
Definition: dictionary.C:508
Foam::autoPtr::New
static autoPtr< T > New(Args &&... args)
Construct autoPtr of T with forwarding arguments.
Foam::dictionaryEntry
A keyword and a list of tokens is a 'dictionaryEntry'.
Definition: dictionaryEntry.H:65
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::BitOps::set
void set(List< bool > &bools, const labelRange &range)
Set the specified range 'on' in a boolList.
Definition: BitOps.C:37
Foam::primitiveEntry
A keyword and a list of tokens comprise a primitiveEntry. A primitiveEntry can be read,...
Definition: primitiveEntry.H:63
primitiveEntry.H
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::dictionary::Searcher::dictPtr
dict_pointer dictPtr() const
Pointer to the found entry as a dictionary or nullptr otherwise.
Definition: dictionary.H:234
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::entry::keyword
const keyType & keyword() const
Return keyword.
Definition: entry.H:187
Foam::argList::envGlobalPath
static fileName envGlobalPath()
Global case (directory) from environment variable.
Definition: argList.C:537
Foam::dictionary::found
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search for an entry (const access) with the given keyword.
Definition: dictionary.C:364
Foam::keyType::isPattern
bool isPattern() const
The keyType is treated as a pattern, not as literal string.
Definition: keyTypeI.H:128
Foam::dictionary::checkITstream
void checkITstream(const ITstream &is, const word &keyword) const
Definition: dictionary.C:258
Foam::dictionary::dictionary
dictionary()
Default construct, a top-level empty dictionary.
Definition: dictionary.C:81
Foam::ITstream::nRemainingTokens
label nRemainingTokens() const
The number of remaining tokens.
Definition: ITstream.H:244
Foam::dictionary::operator|=
void operator|=(const dictionary &rhs)
Conditionally include entries from the given dictionary.
Definition: dictionary.C:985
Foam::FatalIOError
IOerror FatalIOError
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
Foam::token
A token holds an item read from Istream.
Definition: token.H:68
Foam::string
A class for handling character strings derived from std::string.
Definition: string.H:73
Foam::dictionary::set
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
Definition: dictionary.C:847
append
rAUs append(new volScalarField(IOobject::groupName("rAU", phase1.name()), 1.0/(U1Eqn.A()+byDt(max(phase1.residualAlpha() - alpha1, scalar(0)) *rho1))))
Foam::dictionary::lookupEntry
const entry & lookupEntry(const word &keyword, enum keyType::option matchOpt) const
Search for an entry (const access) with the given keyword.
Definition: dictionary.C:404
Foam::fileName::relative
fileName relative(const fileName &parent, const bool caseTag=false) const
Definition: fileName.C:431
Foam::dictionary::operator+=
void operator+=(const dictionary &rhs)
Include entries from the given dictionary.
Definition: dictionary.C:968
Foam::dictionary::subDictOrAdd
dictionary & subDictOrAdd(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find and return a sub-dictionary for manipulation.
Definition: dictionary.C:568
Foam::dictionary::substituteKeyword
bool substituteKeyword(const word &keyword, bool mergeEntry=false)
Substitute the given keyword (which is prefixed by '$')
Definition: dictionary.C:434
Foam::dictionary::transfer
void transfer(dictionary &dict)
Transfer the contents of the argument and annul the argument.
Definition: dictionary.C:933
Foam::dictionary::null
static const dictionary null
An empty dictionary, which is also the parent for all dictionaries.
Definition: dictionary.H:385
Foam::debug::infoSwitch
int infoSwitch(const char *name, const int deflt=0)
Lookup info switch or add default value.
Definition: debug.C:231
Foam::dictionary::keys
List< keyType > keys(bool patterns=false) const
Return the list of available keys or patterns.
Definition: dictionary.C:690
Foam::dictionary::Searcher
Generic const/non-const dictionary entry searcher.
Definition: dictionary.H:138
Foam::keyType
A class for handling keywords in dictionaries.
Definition: keyType.H:60
n
label n
Definition: TABSMDCalcMethod2.H:31
Foam::dictionary::operator<<=
void operator<<=(const dictionary &rhs)
Unconditionally include entries from the given dictionary.
Definition: dictionary.C:1005
Foam::dictionary::merge
bool merge(const dictionary &dict)
Merge entries from the given dictionary.
Definition: dictionary.C:879
Foam::dictionary::name
const fileName & name() const
The dictionary name.
Definition: dictionary.H:446
error.H
Foam::entry::isDict
virtual bool isDict() const
Return true if this entry is a dictionary.
Definition: entry.H:222
Foam::ITstream
An input stream of tokens.
Definition: ITstream.H:55
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
argList.H
Foam::dictionary::~dictionary
virtual ~dictionary()
Destructor.
Definition: dictionary.C:186
Foam::dictionary::startLineNumber
label startLineNumber() const
Return line number of first token in dictionary.
Definition: dictionary.C:205
Foam::dictionary::subDict
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Definition: dictionary.C:528
Foam::dictionary::endLineNumber
label endLineNumber() const
Return line number of last token in dictionary.
Definition: dictionary.C:216
Foam::dictionary::Searcher::good
bool good() const
True if entry was found.
Definition: dictionary.H:198
Foam::OSstream
Generic output stream using a standard (STL) stream.
Definition: OSstream.H:54
Foam::dictionary::Searcher::dict
dict_reference dict() const
Reference the found entry as a dictionary.
Definition: dictionary.H:241
Foam::dictionary::topDict
const dictionary & topDict() const
Return the top of the tree.
Definition: dictionary.C:192
Foam::List::resize
void resize(const label newSize)
Adjust allocated size of list.
Definition: ListI.H:139
Foam::OSHA1stream
The output stream for calculating SHA1 digests.
Definition: OSHA1stream.H:183
Foam::dictionary::lookup
ITstream & lookup(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionary.C:424
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::ILList
Template class for intrusive linked lists.
Definition: ILList.H:52
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::add
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
Definition: FieldFieldFunctions.C:939
Foam::ITstream::parse
static tokenList parse(const UList< char > &input, streamFormat format=ASCII)
Definition: ITstream.C:56
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
Foam::entry::dict
virtual const dictionary & dict() const =0
Return dictionary, if entry is a dictionary.
Foam::dictionary::writeOptionalEntries
static int writeOptionalEntries
Report optional keywords and values if not present in dictionary.
Definition: dictionary.H:382
dictionaryEntry.H
Foam::SHA1Digest
The SHA1 message digest.
Definition: SHA1Digest.H:60
Foam::dictionary::subOrEmptyDict
dictionary subOrEmptyDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX, const bool mandatory=false) const
Definition: dictionary.C:608
Foam::entry::name
virtual const fileName & name() const =0
Return the dictionary name.
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::dictionary::isDict
bool isDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Check if entry is found and is a sub-dictionary.
Definition: dictionary.C:498
found
bool found
Definition: TABSMDCalcMethod2.H:32
Foam::Detail::StringStreamAllocator::str
Foam::string str() const
Get the string - as Foam::string rather than std::string.
Definition: StringStream.H:91
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::dictionary::findScoped
const entry * findScoped(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search for a scoped entry (const access) with the given keyword.
Definition: dictionary.C:394
clear
patchWriters clear()
Foam::nl
constexpr char nl
Definition: Ostream.H:385
Foam::JobInfo::constructed
static bool constructed
Global value for constructed job info.
Definition: JobInfo.H:80
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::OStringStream
Output to string buffer, using a OSstream.
Definition: StringStream.H:196
Foam::dictionary::operator=
void operator=(const dictionary &rhs)
Copy assignment.
Definition: dictionary.C:948
Foam::dictionary::findEntry
entry * findEntry(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find for an entry (non-const access) with the given keyword.
Definition: dictionary.C:374
k
label k
Boltzmann constant.
Definition: LISASMDCalcMethod2.H:41
Foam::constant::electromagnetic::e
const dimensionedScalar e
Elementary charge.
Definition: createFields.H:11
Foam::dictionary::clone
autoPtr< dictionary > clone() const
Construct and return clone.
Definition: dictionary.C:178
Foam::keyType::REGEX
Regular expression.
Definition: keyType.H:74
dictionary.H
Foam::sum
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
Definition: DimensionedFieldFunctions.C:327
Foam::search
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
Definition: fileName.C:576
Foam::dictionary::Searcher::isDict
bool isDict() const
True if found entry is a dictionary.
Definition: dictionary.H:228
Foam::fileName::concat
static fileName concat(const std::string &s1, const std::string &s2, const char delim='/')
Join two strings with a path separator ('/' by default).
Definition: fileName.C:126
Foam::dictionary::substituteScopedKeyword
bool substituteScopedKeyword(const word &keyword, bool mergeEntry=false)
Substitute the given scoped keyword (which is prefixed by '$')
Definition: dictionary.C:466
Foam::dictionary::optionalSubDict
const dictionary & optionalSubDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary, otherwise return this dictionary.
Definition: dictionary.C:645
OSHA1stream.H
JobInfo.H
Foam::IOstream::lineNumber
label lineNumber() const
Const access to the current stream line number.
Definition: IOstream.H:309
Foam::dictionary::add
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
Definition: dictionary.C:708
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:401
registerSwitch.H
Foam::dictionary::tokens
tokenList tokens() const
Return the dictionary as a list of tokens.
Definition: dictionary.C:241
Foam::dictionary::toc
wordList toc() const
Return the table of contents.
Definition: dictionary.C:670
Foam::dictionary::digest
SHA1Digest digest() const
Return the SHA1 digest of the dictionary contents.
Definition: dictionary.C:227
IOWarningInFunction
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
Definition: messageStream.H:315
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::dictionary::clear
void clear()
Clear the dictionary.
Definition: dictionary.C:924
Foam::dictionary::sortedToc
wordList sortedToc() const
Return the sorted table of contents.
Definition: dictionary.C:684
Foam::dictionary::Searcher::ref
reference ref() const
A reference to the entry (Error if not found)
Definition: dictionary.H:222
Foam::fileName::isAbsolute
static bool isAbsolute(const std::string &str)
Return true if string starts with a '/'.
Definition: fileNameI.H:136
registerInfoSwitch
registerInfoSwitch("writeOptionalEntries", int, Foam::dictionary::writeOptionalEntries)
Foam::keyType::option
option
Enumeration for the data type and search/match modes (bitmask)
Definition: keyType.H:70
Foam::Detail::OSHA1streamAllocator::digest
SHA1Digest digest()
Return SHA1::Digest for the data processed until now.
Definition: OSHA1stream.H:161
Foam::keyType::REGEX_RECURSIVE
Definition: keyType.H:79