Block-Structured AMR Software Framework
 
Loading...
Searching...
No Matches
AMReX_ParmParse.H
Go to the documentation of this file.
1#ifndef AMREX_PARMPARSE_H_
2#define AMREX_PARMPARSE_H_
3#include <AMReX_Config.H>
4
5#include <AMReX_BLassert.H>
6#include <AMReX_Box.H>
7#include <AMReX_Enum.H>
8#include <AMReX_INT.H>
9#include <AMReX_IntVect.H>
10#include <AMReX_IParser.H>
11#include <AMReX_Parser.H>
12#include <AMReX_TypeTraits.H>
13
14#include <array>
15#include <iosfwd>
16#include <optional>
17#include <set>
18#include <string>
19#include <string_view>
20#include <type_traits>
21#include <unordered_map>
22#include <variant>
23#include <vector>
24
25namespace amrex {
26
27template<int dim>
28class BoxND;
29using Box = BoxND<AMREX_SPACEDIM>;
30template<int dim>
31class IntVectND;
32using IntVect = IntVectND<AMREX_SPACEDIM>;
33template<int dim>
34class RealVectND;
36
37namespace ppdetail {
38 template <class T, class Enable = void>
39 struct ArithmeticOptional_TT : std::false_type {};
40
41 template <class T>
42 struct ArithmeticOptional_TT<T, std::enable_if_t<std::is_arithmetic_v<T>>>
43 : std::true_type
44 {
45 using value_type = T;
46 };
47
48 template <class T>
49 struct ArithmeticOptional_TT<std::optional<T>,
50 std::enable_if_t<std::is_arithmetic_v<T>>>
51 : std::true_type
52 {
53 using value_type = T;
54 };
55
56 template <class T>
58
59 template <class T>
61}
62
63//
64// ParmParse class implements a simple database for the storage and
65// retrieval of command-line and input-file arguments. The entries are
66// stored in a static table in (name,value_list) pairs.
67//
68// The format of the input file is a series of DEFINITIONS.
69//
70// A DEFINITION is of the form <name> = <value> <value> ...
71// The equal sign is important since the list of values can span multiple
72// lines.
73//
74// Comments in an input file include all text from a '#' character to the
75// end of the line. Here is an example input file:
76/*
77 niter = 100 # niter is an integer
78 title = "Double Wammy" # example of a string with spaces
79 cell_size = 0.5 0.75 # cell spacing in each dimension
80 plot.var = Density 1 10 # a list of values
81 plot.var = Energy 5 12 # another list of values
82 bigarray = 1 2 3 4 5 6 7 8 \
83 9 10 11 12 # continuation of bigarray
84 multi_line_string = "This is a
85 multi-line string."
86 my_2d_table = \
87 # col 1 2 3
88 {{ 11.0, 12.0, 13.0 } # row 1
89 { 21.0, 22.0, 23.0 } # row 2
90 { 31.0, 32.0, 33.0 } # row 3
91 { 41.0, 42.0, 43.0 } } # row 4
92 test = apple "boy blue" 10 20 30 40
93 FILE = prob_file # insert contents of this "prob_file" here
94*/
95// For values spanning multiple lines except for table, one must use '\' at
96// the end of a line
97// for continuation, otherwise it's a runtime error. Note that there must be
98// at least one space before the continuation character `\`. Multiple lines
99// inside a pair of double quotes are considered a single string containing
100// '\n's. The "FILE = <filename>" definition is special. Rather than just
101// adding this entry to the database, it reads the contents of <filename>
102// into the database.
103// For CI/CD workflows and out-of-source tests, the environment variable
104// AMREX_INPUTS_FILE_PREFIX can be set to prefix every FILE = <filename>
105// with a custom path.
106//
107// ParmParse stores all entries in a static table which is built the
108// first time a ParmParse object is constructed (usually in main()).
109// Subsequent invocations have access to this table.
110// A ParmParse constructor has an optional "prefix" argument that will
111// limit the searches to only those entries of the table with this prefix
112// in name. For example:
113// ParmParse pp("plot");
114// will find only those entries with name given by "plot.<string>".
115//
116// All values in the table are stored as strings. For example, the
117// values of "cell_size" in the above input file are stored as the
118// strings "0.5" and "0.75". These strings can be returned as either
119// strings or numeric values by the query functions.
120// Character strings with spaces must be delimited by double quotes
121// in the input file but the quotes are stripped before they are entered
122// into the table. For example, 'title' in the above input file has a
123// single value, the string 'Double Wammy' (without the quotes).
124// Each value in the list associated with a definition can be referred to
125// by its index number. The index numbers start at 0 just like an array
126// in the C programming language. Consider the definition of "test" in
127// the above input file. The first value 'apple'is a string with index
128// 0. The second value 'boy blue' is a string with index 1. The
129// remaining four values are integers indexed 2, 3, 4, and 5.
130//
131// For a string value to represent an integer or float it must fit the
132// following regular expression:
133// Sign ::= '+' | '-'
134// Digit ::= '0' | '1' | ... | '9'
135// Integer ::= [Sign]Digit+
136// Exp ::= ('e'|'E')Integer
137// Float ::= ( Integer[.Digit*][Exp] | [Integer].Digit+[Exp] )
138//
139// Where '+' indicates one or more occurrences, '*' represents zero or
140// more occurrences, '|' means one or the other and '[]' represents zero
141// or one occurrence.
142//
143// Note that floats and doubles have the same string representation and
144// that the FORTRAN "double" exponent format is not supported.
145// That is, 1.0d+3 is not a valid representation of a floating point
146// number but that 1.0e+3 is acceptable.
147//
148// There are a host of functions allowing the user to query the database
149// and retrieve values. Here are some general rules about the names of
150// the member functions:
151//
152// * Functions with the string "get" in their names attempt to get a
153// value or an array of values from the table. They generate a
154// run-time error if they are not successful.
155//
156// * Functions with the string "query" in their names attempt to get a
157// value or an array of values from the table. They return the value 1
158// (true) if they are successful and 0 (false) if not.
159//
160// * Functions with the string "kth" in their names get values from
161// the Kth entry with the given name in the database. This is
162// necessary since there may be multiple definitions with the same
163// name in the database.
164//
165// * Functions without the string "kth" in their names get values from
166// the last entry with the given name in the database. Note that the
167// definitions from the command line are appended to the database table
168// and hence will be the last entries.
169//
170// * Functions with the string "arr" in their names get an Array of
171// values from the given entry in the table. The array argument is
172// resized (if necessary) to hold all the values requested.
173//
174// * Functions without the string "arr" in their names get single
175// values from the given entry in the table.
176//
177// The following is a code sample showing how to use ParmParse:
178//
179// main(int argc, char **argv)
180// {
181// char* in_file_name = argv[1];
182// ParmParse::Initialize(argc-2, argv+2, in_file_name);
183//
184// // Query table for value of "niter". If not in table
185// // then set to default value
186// if (!pp.query("niter",niter)) niter = 20;
187//
188// // read array of cell sizes if in table
189// Vector<float> dx;
190// if (nx=pp.countval("cell_size")) {
191// // get nx values starting at index 0 and store in dx.
192// // dx is automatically resized here.
193// pp.getarr("cell_size",dx,0,nx);
194// }
195// ParmParse::Finalize();
196// }
197//
198// void do_graphics()
199// {
200// //
201// // Will only query entries with the "plot" prefix:
202// //
203// ParmParse pp("plot");
204// //
205// // Read all variables with "plot.var" keyword.
206// //
207// std::string var_name;
208// Vector<int> range;
209// int num = pp.countname("var");
210// for (int k = 0; k < num; k++)
211// {
212// //
213// // Element 0 in list is a string.
214// //
215// pp.getkth("var",k,var_name,0);
216// //
217// // Elements 1 and 2 are integers.
218// // Note that "range" will be resized to hold 2 elements.
219// //
220// pp.getktharr("var",k,range,1,2);
221// cout << "variable = " << var_name << "lo, hi = ",
222// << range[0] << " " << range[1] << endl;
223// }
224// }
225// -----------------------------------------------------------------
226// ----------------------- END COMMENTS ---------------------------
227// -----------------------------------------------------------------
228
229
343{
344public:
345 enum { LAST = -1, FIRST = 0, ALL = -1 };
353 explicit ParmParse (std::string prefix = std::string(),
354 std::string parser_prefix = std::string());
355
357 [[nodiscard]] bool contains (std::string_view name) const;
363 [[nodiscard]] int countval (std::string_view name, int n = LAST) const;
368 [[nodiscard]] int countname (std::string_view name) const;
380 void getkth (std::string_view name,
381 int k,
382 bool& ref,
383 int ival = FIRST) const;
385 void get (std::string_view name,
386 bool& ref,
387 int ival = FIRST) const;
395 int querykth (std::string_view name,
396 int k,
397 bool& ref,
398 int ival = FIRST) const;
400 int query (std::string_view name,
401 bool& ref,
402 int ival = FIRST) const;
404 void add (std::string_view name, bool val);
414 void getkth (std::string_view name,
415 int k,
416 int& ref,
417 int ival = FIRST) const;
418
420 void get (std::string_view name,
421 int& ref,
422 int ival = FIRST) const;
430 int querykth (std::string_view name,
431 int k,
432 int& ref,
433 int ival = FIRST) const;
435 int query (std::string_view name,
436 int& ref,
437 int ival = FIRST) const;
439 void add (std::string_view name, int val);
449 void getkth (std::string_view name,
450 int k,
451 long& ref,
452 int ival = FIRST) const;
454 void get (std::string_view name,
455 long& ref,
456 int ival = FIRST) const;
464 int querykth (std::string_view name,
465 int k,
466 long& ref,
467 int ival = FIRST) const;
469 int query (std::string_view name,
470 long& ref,
471 int ival = FIRST) const;
473 void add (std::string_view name, long val);
483 void getkth (std::string_view name,
484 int k,
485 long long& ref,
486 int ival = FIRST) const;
488 void get (std::string_view name,
489 long long& ref,
490 int ival = FIRST) const;
498 int querykth (std::string_view name,
499 int k,
500 long long& ref,
501 int ival = FIRST) const;
503 int query (std::string_view name,
504 long long& ref,
505 int ival = FIRST) const;
507 void add (std::string_view name, long long val);
517 void getkth (std::string_view name,
518 int k,
519 float& ref,
520 int ival = FIRST) const;
522 void get (std::string_view name,
523 float& ref,
524 int ival = FIRST) const;
532 int querykth (std::string_view name,
533 int k,
534 float& ref,
535 int ival = FIRST) const;
537 int query (std::string_view name,
538 float& ref,
539 int ival = FIRST) const;
541 void add (std::string_view name, float val);
551 void getkth (std::string_view name,
552 int k,
553 double& ref,
554 int ival = FIRST) const;
556 void get (std::string_view name,
557 double& ref,
558 int ival = FIRST) const;
566 int querykth (std::string_view name,
567 int k,
568 double& ref,
569 int ival = FIRST) const;
571 int query (std::string_view name,
572 double& ref,
573 int ival = FIRST) const;
575 void add (std::string_view name, double val);
585 void getkth (std::string_view name,
586 int k,
587 std::string& ref,
588 int ival = FIRST) const;
589
591 void get (std::string_view name,
592 std::string& ref,
593 int ival = FIRST) const;
601 int querykth (std::string_view name,
602 int k,
603 std::string& ref,
604 int ival = FIRST) const;
606 int query (std::string_view name,
607 std::string& ref,
608 int ival = FIRST) const;
610 void add (std::string_view name, const std::string& val);
611
612
621 void getline (std::string_view name, std::string& ref) const;
622
631 int queryline (std::string_view name, std::string& ref) const;
632
642 void getkth (std::string_view name,
643 int k,
644 IntVect& ref,
645 int ival = FIRST) const;
647 void get (std::string_view name,
648 IntVect& ref,
649 int ival = FIRST) const;
657 int querykth (std::string_view name,
658 int k,
659 IntVect& ref,
660 int ival = FIRST) const;
662 int query (std::string_view name,
663 IntVect& ref,
664 int ival = FIRST) const;
666 void add (std::string_view name, const IntVect& val);
676 void getkth (std::string_view name,
677 int k,
678 Box& ref,
679 int ival = FIRST) const;
681 void get (std::string_view name,
682 Box& ref,
683 int ival = FIRST) const;
691 int querykth (std::string_view name,
692 int k,
693 Box& ref,
694 int ival = FIRST) const;
696 int query (std::string_view name,
697 Box& ref,
698 int ival = FIRST) const;
700 void add (std::string_view name, const Box& val);
713 void getktharr (std::string_view name,
714 int k,
715 std::vector<int>& ref,
716 int start_ix = FIRST,
717 int num_val = ALL) const;
719 void getarr (std::string_view name,
720 std::vector<int>& ref,
721 int start_ix = FIRST,
722 int num_val = ALL) const;
724 int queryktharr (std::string_view name,
725 int k,
726 std::vector<int>& ref,
727 int start_ix = FIRST,
728 int num_val = ALL) const;
730 int queryarr (std::string_view name,
731 std::vector<int>& ref,
732 int start_ix = FIRST,
733 int num_val = ALL) const;
735 void addarr (std::string_view name, const std::vector<int>& ref);
736
749 void getktharr (std::string_view name,
750 int k,
751 std::vector<long>& ref,
752 int start_ix = FIRST,
753 int num_val = ALL) const;
755 void getarr (std::string_view name,
756 std::vector<long>& ref,
757 int start_ix = FIRST,
758 int num_val = ALL) const;
760 int queryktharr (std::string_view name,
761 int k,
762 std::vector<long>& ref,
763 int start_ix = FIRST,
764 int num_val = ALL) const;
766 int queryarr (std::string_view name,
767 std::vector<long>& ref,
768 int start_ix = FIRST,
769 int num_val = ALL) const;
771 void addarr (std::string_view name, const std::vector<long>& ref);
772
785 void getktharr (std::string_view name,
786 int k,
787 std::vector<long long>& ref,
788 int start_ix = FIRST,
789 int num_val = ALL) const;
791 void getarr (std::string_view name,
792 std::vector<long long>& ref,
793 int start_ix = FIRST,
794 int num_val = ALL) const;
796 int queryktharr (std::string_view name,
797 int k,
798 std::vector<long long>& ref,
799 int start_ix = FIRST,
800 int num_val = ALL) const;
802 int queryarr (std::string_view name,
803 std::vector<long long>& ref,
804 int start_ix = FIRST,
805 int num_val = ALL) const;
807 void addarr (std::string_view name, const std::vector<long long>& ref);
808
821 void getktharr (std::string_view name,
822 int k,
823 std::vector<float>& ref,
824 int start_ix = FIRST,
825 int num_val = ALL) const;
827 void getarr (std::string_view name,
828 std::vector<float>& ref,
829 int start_ix = FIRST,
830 int num_val = ALL) const;
832 int queryktharr (std::string_view name,
833 int k,
834 std::vector<float>& ref,
835 int start_ix = FIRST,
836 int num_val = ALL) const;
838 int queryarr (std::string_view name,
839 std::vector<float>& ref,
840 int start_ix = FIRST,
841 int num_val = ALL) const;
843 void addarr (std::string_view name, const std::vector<float>& ref);
856 void getktharr (std::string_view name,
857 int k,
858 std::vector<double>& ref,
859 int start_ix = FIRST,
860 int num_val = ALL) const;
862 void getarr (std::string_view name,
863 std::vector<double>& ref,
864 int start_ix = FIRST,
865 int num_val = ALL) const;
867 int queryktharr (std::string_view name,
868 int k,
869 std::vector<double>& ref,
870 int start_ix = FIRST,
871 int num_val = ALL) const;
873 int queryarr (std::string_view name,
874 std::vector<double>& ref,
875 int start_ix = FIRST,
876 int num_val = ALL) const;
878 void addarr (std::string_view name, const std::vector<double>& ref);
891 void getktharr (std::string_view name,
892 int k,
893 std::vector<std::string>& ref,
894 int start_ix = FIRST,
895 int num_val = ALL) const;
897 void getarr (std::string_view name,
898 std::vector<std::string>& ref,
899 int start_ix = FIRST,
900 int num_val = ALL) const;
902 int queryktharr (std::string_view name,
903 int k,
904 std::vector<std::string>& ref,
905 int start_ix = FIRST,
906 int num_val = ALL) const;
908 int queryarr (std::string_view name,
909 std::vector<std::string>& ref,
910 int start_ix = FIRST,
911 int num_val = ALL) const;
913 void addarr (std::string_view name, const std::vector<std::string>& ref);
926 void getktharr (std::string_view name,
927 int k,
928 std::vector<IntVect>& ref,
929 int start_ix = FIRST,
930 int num_val = ALL) const;
932 void getarr (std::string_view name,
933 std::vector<IntVect>& ref,
934 int start_ix = FIRST,
935 int num_val = ALL) const;
937 int queryktharr (std::string_view name,
938 int k,
939 std::vector<IntVect>& ref,
940 int start_ix = FIRST,
941 int num_val = ALL) const;
943 int queryarr (std::string_view name,
944 std::vector<IntVect>& ref,
945 int start_ix = FIRST,
946 int num_val = ALL) const;
948 void addarr (std::string_view name, const std::vector<IntVect>& ref);
961 void getktharr (std::string_view name,
962 int k,
963 std::vector<Box>& ref,
964 int start_ix = FIRST,
965 int num_val = ALL) const;
967 void getarr (std::string_view name,
968 std::vector<Box>& ref,
969 int start_ix = FIRST,
970 int num_val = ALL) const;
972 int queryktharr (std::string_view name,
973 int k,
974 std::vector<Box>& ref,
975 int start_ix = FIRST,
976 int num_val = ALL) const;
978 int queryarr (std::string_view name,
979 std::vector<Box>& ref,
980 int start_ix = FIRST,
981 int num_val = ALL) const;
983 void addarr (std::string_view name, const std::vector<Box>& ref);
984
985 /*
986 * \brief Query IntVect from array
987 *
988 * This reads IntVect from an array (e.g., `8 16 8`), not the format
989 * using parentheses (e.g., `(8,16,8)`).
990 */
991 int queryarr (std::string_view name, IntVect& ref) const;
992
993 /*
994 * \brief Get IntVect from array
995 *
996 * This reads IntVect from an array (e.g., `8 16 8`), not the format
997 * using parentheses (e.g., `(8,16,8)`).
998 */
999 void getarr (std::string_view name, IntVect& ref) const;
1000
1002 int queryarr (std::string_view name, RealVect& ref) const;
1003
1005 void getarr (std::string_view name, RealVect& ref) const;
1006
1007 template <typename T, std::size_t N>
1008 void get (std::string_view name, std::array<T,N>& ref) const {
1009 std::vector<T> v;
1010 this->getarr(name, v);
1011 AMREX_ALWAYS_ASSERT(v.size() >= N);
1012 for (std::size_t i = 0; i < N; ++i) {
1013 ref[i] = v[i];
1014 }
1015 }
1016
1017 template <typename T, std::size_t N>
1018 int query (std::string_view name, std::array<T,N>& ref) const {
1019 std::vector<T> v;
1020 int exist = this->queryarr(name, v);
1021 if (exist) {
1022 AMREX_ALWAYS_ASSERT(v.size() >= N);
1023 for (std::size_t i = 0; i < N; ++i) {
1024 ref[i] = v[i];
1025 }
1026 }
1027 return exist;
1028 }
1029
1036 template <typename T, std::enable_if_t<!IsStdVector<T>::value, int> = 0>
1037 int queryAdd (std::string_view name, T& ref) {
1038 int exist = this->query(name, ref);
1039 if (!exist) {
1040 this->add(name, ref);
1041 }
1042 return exist;
1043 }
1044
1045 int queryAdd (std::string_view name, std::string& ref) {
1046 int exist = this->query(name, ref);
1047 if (!exist && !ref.empty()) {
1048 this->add(name, ref);
1049 }
1050 return exist;
1051 }
1052
1062 template <typename T>
1063 int queryAdd (std::string_view name, std::vector<T>& ref) {
1064 std::vector<T> empty;
1065 int exist = this->queryarr(name, empty);
1066 if (exist) {
1067 ref = std::move(empty);
1068 }
1069 if (!exist && !ref.empty()) {
1070 this->addarr(name, ref);
1071 }
1072 return exist;
1073 }
1074
1081 template <typename T>
1082 int queryAdd (std::string_view name, std::vector<T>& ref, int num_val) {
1083 int exist = this->queryarr(name, ref, 0, num_val);
1084 if (!exist) {
1085 this->addarr(name, ref);
1086 }
1087 return exist;
1088 }
1089
1096 template <typename T, std::size_t N>
1097 int queryAdd (std::string_view name, std::array<T,N>& ref) {
1098 std::vector<T> v;
1099 int exist = this->queryarr(name, v);
1100 if (exist) {
1101 AMREX_ALWAYS_ASSERT(v.size() >= N);
1102 for (std::size_t i = 0; i < N; ++i) {
1103 ref[i] = v[i];
1104 }
1105 } else {
1106 v.resize(N);
1107 for (std::size_t i = 0; i < N; ++i) {
1108 v[i] = ref[i];
1109 }
1110 this->addarr(name, v);
1111 }
1112 return exist;
1113 }
1114
1121 int queryWithParser (std::string_view name, bool& ref) const;
1122 int queryWithParser (std::string_view name, int& ref) const;
1123 int queryWithParser (std::string_view name, long& ref) const;
1124 int queryWithParser (std::string_view name, long long& ref) const;
1125 int queryWithParser (std::string_view name, float& ref) const;
1126 int queryWithParser (std::string_view name, double& ref) const;
1127
1134 int queryarrWithParser (std::string_view name, int nvals, bool* ptr) const;
1135 int queryarrWithParser (std::string_view name, int nvals, int* ptr) const;
1136 int queryarrWithParser (std::string_view name, int nvals, long* ptr) const;
1137 int queryarrWithParser (std::string_view name, int nvals, long long* ptr) const;
1138 int queryarrWithParser (std::string_view name, int nvals, float* ptr) const;
1139 int queryarrWithParser (std::string_view name, int nvals, double* ptr) const;
1140 template <typename T, std::enable_if_t<std::is_same_v<T,bool> ||
1141 std::is_same_v<T,int> ||
1142 std::is_same_v<T,long> ||
1143 std::is_same_v<T,long long> ||
1144 std::is_same_v<T,float> ||
1145 std::is_same_v<T,double>,int> = 0>
1146 int queryarrWithParser (std::string_view name, int nvals, std::vector<T>& ref) const
1147 {
1148 if (this->contains(name)) {
1149 if (int(ref.size()) < nvals) { ref.resize(nvals); }
1150 return this->queryarrWithParser(name, nvals, ref.data());
1151 } else {
1152 return 0;
1153 }
1154 }
1155
1162 template <typename T, std::enable_if_t<std::is_same_v<T,bool> ||
1163 std::is_same_v<T,int> ||
1164 std::is_same_v<T,long> ||
1165 std::is_same_v<T,long long> ||
1166 std::is_same_v<T,float> ||
1167 std::is_same_v<T,double>,int> = 0>
1168 int queryAddWithParser (std::string_view name, T& ref)
1169 {
1170 int exist = this->queryWithParser(name, ref);
1171 if (!exist) {
1172 this->add(name, ref);
1173 }
1174 return exist;
1175 }
1176
1182 template <typename T, std::enable_if_t<std::is_same_v<T,bool> ||
1183 std::is_same_v<T,int> ||
1184 std::is_same_v<T,long> ||
1185 std::is_same_v<T,long long> ||
1186 std::is_same_v<T,float> ||
1187 std::is_same_v<T,double>,int> = 0>
1188 void getWithParser (std::string_view name, T& ref) const
1189 {
1190 int exist = this->queryWithParser(name, ref);
1191 if (!exist) {
1192 amrex::Error(std::string("ParmParse::getWithParser: failed to get ")+std::string(name));
1193 }
1194 }
1195
1201 template <typename T, std::enable_if_t<std::is_same_v<T,bool> ||
1202 std::is_same_v<T,int> ||
1203 std::is_same_v<T,long> ||
1204 std::is_same_v<T,long long> ||
1205 std::is_same_v<T,float> ||
1206 std::is_same_v<T,double>,int> = 0>
1207 void getarrWithParser (std::string_view name, int nvals, T* ptr) const
1208 {
1209 int exist = this->queryarrWithParser(name, nvals, ptr);
1210 if (!exist) {
1211 amrex::Error(std::string("ParmParse::getarrWithParser: failed to get ")+std::string(name));
1212 }
1213 }
1214
1220 template <typename T, std::enable_if_t<std::is_same_v<T,bool> ||
1221 std::is_same_v<T,int> ||
1222 std::is_same_v<T,long> ||
1223 std::is_same_v<T,long long> ||
1224 std::is_same_v<T,float> ||
1225 std::is_same_v<T,double>,int> = 0>
1226 void getarrWithParser (std::string_view name, int nvals, std::vector<T>& ref) const
1227 {
1228 int exist = this->queryarrWithParser(name, nvals, ref);
1229 if (!exist) {
1230 amrex::Error(std::string("ParmParse::getarrWithParser: failed to get ")+std::string(name));
1231 }
1232 }
1233
1234 /*
1235 * \brief Evaluate given string as math expression
1236 *
1237 * For unknown symbols, ParmParse database will be queried.
1238 */
1239 template <typename T, std::enable_if_t<std::is_same_v<T,bool> ||
1240 std::is_same_v<T,int> ||
1241 std::is_same_v<T,long> ||
1242 std::is_same_v<T,long long> ||
1243 std::is_same_v<T,float> ||
1244 std::is_same_v<T,double>,int> = 0>
1245 T eval (std::string const& expr) const
1246 {
1247 if constexpr (std::is_integral_v<T>) {
1248 auto const parser = this->makeIParser(expr, {});
1249 auto const exe = parser.compileHost<0>();
1250 return static_cast<T>(exe()); // In the future, we might add safety check.
1251 } else {
1252 auto const parser = this->makeParser(expr, {});
1253 auto const exe = parser.compileHost<0>();
1254 return static_cast<T>(exe());
1255 }
1256 }
1257
1258 /*
1259 * \brief Query two names.
1260 *
1261 * This function queries with `new_name` first. If it's not found, it
1262 * will try again with `old_name`.
1263 */
1264 template <typename T>
1265 int query (const char* new_name, const char* old_name, T& ref)
1266 {
1267 return (this->query(new_name, ref) ||
1268 this->query(old_name, ref));
1269 }
1270
1278 template <typename T>
1279 void get (const char* new_name, const char* old_name, T& ref)
1280 {
1281 auto exist = this->query(new_name, old_name, ref);
1282 if (!exist) {
1283 amrex::ErrorStream() << "ParmParse::get failed to find "
1284 << new_name << " and " << old_name << '\n';
1286 amrex::Abort();
1287 }
1288 }
1289
1298 template <typename T, typename ET = amrex_enum_traits<T>,
1299 std::enable_if_t<ET::value,int> = 0>
1300 int query (std::string_view name, T& ref, int ival = FIRST) const
1301 {
1302 std::string s;
1303 int exist = this->query(name, s, ival);
1304 if (exist) {
1305 try {
1306 ref = amrex::getEnum<T>(s);
1307 } catch (...) {
1308 if (amrex::Verbose() > 0 ) {
1309 amrex::Print() << "amrex::ParmParse::query (input name: "
1310 << this->prefixedName(name) << "):\n";
1311 }
1312 throw;
1313 }
1314 }
1315 return exist;
1316 }
1317
1318
1321 template <typename T, typename ET = amrex_enum_traits<T>,
1322 std::enable_if_t<ET::value,int> = 0>
1323 void add (std::string_view name, T const& val)
1324 {
1325 this->add(name, amrex::getEnumNameString(val));
1326 }
1327
1336 template <typename T, typename ET = amrex_enum_traits<T>,
1337 std::enable_if_t<ET::value,int> = 0>
1338 void get (std::string_view name, T& ref, int ival = FIRST) const
1339 {
1340 std::string s;
1341 this->get(name, s, ival);
1342 try {
1343 ref = amrex::getEnum<T>(s);
1344 } catch (...) {
1345 if (amrex::Verbose() > 0 ) {
1346 amrex::Print() << "amrex::ParmParse::get (input name: "
1347 << this->prefixedName(name) << "):\n";
1348 }
1349 throw;
1350 }
1351 }
1352
1354 template <typename T, typename ET = amrex_enum_traits<T>,
1355 std::enable_if_t<ET::value,int> = 0>
1356 int queryarr (std::string_view name,
1357 std::vector<T>& ref,
1358 int start_ix = FIRST,
1359 int num_val = ALL) const
1360 {
1361 std::vector<std::string> s;
1362 int exist = this->queryarr(name, s, start_ix, num_val);
1363 if (exist) {
1364 ref.resize(s.size());
1365 for (std::size_t i = 0; i < s.size(); ++i) {
1366 try {
1367 ref[i] = amrex::getEnum<T>(s[i]);
1368 } catch (...) {
1369 if (amrex::Verbose() > 0 ) {
1370 amrex::Print() << "amrex::ParmParse::queryarr (input name: "
1371 << this->prefixedName(name) << "):\n";
1372 }
1373 throw;
1374 }
1375 }
1376 }
1377 return exist;
1378 }
1379
1381 template <typename T, typename ET = amrex_enum_traits<T>,
1382 std::enable_if_t<ET::value,int> = 0>
1383 void getarr (std::string_view name,
1384 std::vector<T>& ref,
1385 int start_ix = FIRST,
1386 int num_val = ALL) const
1387 {
1388 std::vector<std::string> s;
1389 this->getarr(name, s, start_ix, num_val);
1390 ref.resize(s.size());
1391 for (std::size_t i = 0; i < s.size(); ++i) {
1392 try {
1393 ref[i] = amrex::getEnum<T>(s[i]);
1394 } catch (...) {
1395 if (amrex::Verbose() > 0 ) {
1396 amrex::Print() << "amrex::ParmParse::getarr (input name: "
1397 << this->prefixedName(name) << "):\n";
1398 }
1399 throw;
1400 }
1401 }
1402 }
1403
1414 template <typename T, typename ET = amrex_enum_traits<T>,
1415 std::enable_if_t<ET::value,int> = 0>
1416 int query_enum_case_insensitive (std::string_view name, T& ref, int ival = FIRST) const
1417 {
1418 std::string s;
1419 int exist = this->query(name, s, ival);
1420 if (exist) {
1421 try {
1422 ref = amrex::getEnumCaseInsensitive<T>(s);
1423 } catch (...) {
1424 if (amrex::Verbose() > 0) {
1425 amrex::Print() << "amrex::ParmParse::query_enum_case_insensitive (input name: "
1426 << this->prefixedName(name) << "):\n";
1427 }
1428 throw;
1429 }
1430 }
1431 return exist;
1432 }
1433
1444 template <typename T, typename ET = amrex_enum_traits<T>,
1445 std::enable_if_t<ET::value,int> = 0>
1446 void get_enum_case_insensitive (std::string_view name, T& ref, int ival = FIRST) const
1447 {
1448 int exist = this->query_enum_case_insensitive(name, ref, ival);
1449 if (!exist) {
1450 std::string msg("get_enum_case_insensitive(\"");
1451 msg.append(name).append("\",").append(amrex::getEnumClassName<T>())
1452 .append("&) failed.");
1453 amrex::Abort(msg);
1454 }
1455 }
1456
1469 template <typename T, typename ET = amrex_enum_traits<T>,
1470 std::enable_if_t<ET::value,int> = 0>
1471 int query_enum_sloppy (std::string_view name, T& ref, std::string_view const& ignores,
1472 int ival = FIRST) const
1473 {
1474 std::string s;
1475 int exist = this->query(name, s, ival);
1476 if (exist) {
1477 try {
1478 s.erase(std::remove_if(s.begin(), s.end(),
1479 [&] (auto const& c) {
1480 return ignores.find(c) != std::string_view::npos; }),
1481 s.end());
1482 ref = amrex::getEnumCaseInsensitive<T>(s);
1483 } catch (...) {
1484 if (amrex::Verbose() > 0) {
1485 amrex::Print() << "amrex::ParmParse::query_enum_sloppy (input name: "
1486 << this->prefixedName(name) << "):\n";
1487 }
1488 throw;
1489 }
1490 }
1491 return exist;
1492 }
1493
1506 template <typename T, typename ET = amrex_enum_traits<T>,
1507 std::enable_if_t<ET::value,int> = 0>
1508 void get_enum_sloppy (std::string_view name, T& ref, std::string_view const& ignores,
1509 int ival = FIRST) const
1510 {
1511 int exist = this->query_enum_sloppy(name, ref, ignores, ival);
1512 if (!exist) {
1513 std::string msg("get_enum_sloppy(\"");
1514 msg.append(name).append("\",").append(amrex::getEnumClassName<T>())
1515 .append("&) failed.");
1516 amrex::Abort(msg);
1517 }
1518 }
1519
1528 template <typename T, std::enable_if_t<ppdetail::IsArithmeticOptional_v<T>, int> = 0>
1529 int queryAsDouble (std::string_view name, T& ref) const
1530 {
1531 using value_type = ppdetail::underlying_type_t<T>;
1532 double dref;
1533 int exist = queryWithParser(name, dref);
1534 if (exist) {
1535 if (std::is_integral_v<value_type>) {
1536 dref = std::round(dref);
1537 }
1538 auto vref = static_cast<value_type>(dref);
1539 if constexpr (std::is_integral_v<value_type> && !std::is_same_v<value_type,bool>) {
1540 if (static_cast<double>(vref) != dref) {
1541 amrex::Abort("ParmParse:: queryAsDouble is not safe");
1542 }
1543 }
1544 ref = vref;
1545 }
1546 return exist;
1547 }
1548
1557 template <typename T, std::enable_if_t<ppdetail::IsArithmeticOptional_v<T>, int> = 0>
1558 int queryarrAsDouble (std::string_view name, int nvals, T* ptr) const
1559 {
1560 using value_type = ppdetail::underlying_type_t<T>;
1561 std::vector<double> dref(nvals);
1562 int exist = queryarrWithParser(name, nvals, dref.data());
1563 if (exist) {
1564 for (int i = 0; i < nvals; ++i) {
1565 if (std::is_integral_v<value_type>) {
1566 dref[i] = std::round(dref[i]);
1567 }
1568 auto vref = static_cast<value_type>(dref[i]);
1569 if constexpr (std::is_integral_v<value_type> && !std::is_same_v<value_type,bool>) {
1570 if (static_cast<double>(vref) != dref[i]) {
1571 amrex::Abort("ParmParse:: queryarrAsDouble is not safe");
1572 }
1573 }
1574 ptr[i] = vref;
1575 }
1576 }
1577 return exist;
1578 }
1579
1588 template <typename T, std::enable_if_t<ppdetail::IsArithmeticOptional_v<T>, int> = 0>
1589 void getAsDouble (std::string_view name, T& ref) const
1590 {
1591 int exist = this->queryAsDouble(name, ref);
1592 if (!exist) {
1593 amrex::Error(std::string("ParmParse::getAsDouble: failed to get ")+std::string(name));
1594 }
1595 }
1596
1605 template <typename T, std::enable_if_t<ppdetail::IsArithmeticOptional_v<T>, int> = 0>
1606 void getarrAsDouble (std::string_view name, int nvals, T* ptr) const
1607 {
1608 int exist = this->queryarrAsDouble(name, nvals, ptr);
1609 if (!exist) {
1610 amrex::Error(std::string("ParmParse::getarrAsDouble: failed to get ")+std::string(name));
1611 }
1612 }
1613
1615 int remove (std::string_view name);
1616
1620 [[nodiscard]] Parser makeParser (std::string const& func,
1621 Vector<std::string> const& vars) const;
1622
1626 [[nodiscard]] IParser makeIParser (std::string const& func,
1627 Vector<std::string> const& vars) const;
1628
1634 int querytable (std::string_view name, std::vector<std::vector<double>>& ref) const;
1635 int querytable (std::string_view name, std::vector<std::vector<float>>& ref) const;
1636 int querytable (std::string_view name, std::vector<std::vector<int>>& ref) const;
1637
1643 template <typename T>
1644 void gettable (std::string_view name, std::vector<std::vector<T>>& ref) const
1645 {
1646 if (this->querytable(name, ref) == 0) {
1647 amrex::ErrorStream() << "ParmParse::gettable: " << name
1648 << " not found in database\n";
1650 amrex::Abort();
1651 }
1652 }
1653
1661 static void Initialize (int argc, char** argv, const char* parfile);
1662 static void Initialize (int argc, char** argv, const std::string& parfile) {
1663 return Initialize(argc, argv, parfile.c_str());
1664 }
1669 static void Finalize ();
1670
1672 static void SetParserPrefix (std::string a_prefix);
1673
1674 static int Verbose ();
1675 static void SetVerbose (int v);
1676
1678 static void dumpTable (std::ostream& os, bool prettyPrint = false);
1679
1682 static void prettyPrintTable (std::ostream& os);
1683
1686 static void prettyPrintUnusedInputs (std::ostream& os);
1687
1690 static void prettyPrintUsedInputs (std::ostream& os);
1691
1693 static void addfile (std::string const& filename);
1694
1695 static bool QueryUnusedInputs ();
1696
1698 [[nodiscard]] static bool hasUnusedInputs (const std::string& prefix = std::string());
1699
1701 [[nodiscard]] static std::vector<std::string> getUnusedInputs (const std::string& prefix = std::string());
1702
1704 [[nodiscard]] static std::set<std::string> getEntries (const std::string& prefix = std::string());
1705
1706 struct PP_entry {
1707 // There can be multiple occurrences for a given name (e.g.,
1708 // multiple lines starting with `foo =` in inputs. For each
1709 // occurrence, there can be multiple values. Thus, the use of
1710 // vector<vector<std::string>>.
1711 std::vector<std::vector<std::string>> m_vals;
1712 mutable Long m_count = 0;
1713 std::variant<
1714 std::string*,
1715 bool*,
1716 int*,
1717 long*,
1718 long long*,
1720 amrex::Box*,
1721 float*,
1722 double*
1723 > m_typehint = static_cast<std::string*>(nullptr);
1724 };
1725 using Table = std::unordered_map<std::string, PP_entry>;
1726
1727 [[nodiscard]] const Table& table() const {return *m_table;}
1728
1730 static std::string const FileKeyword;
1731
1732 static std::string ParserPrefix;
1733
1734 [[nodiscard]] std::string const& getPrefix () const;
1735
1736 [[nodiscard]] std::string prefixedName (std::string_view str) const;
1737
1738protected:
1739
1740 std::string m_prefix; // Prefix used in keyword search
1741 std::string m_parser_prefix; // Prefix used by Parser
1743};
1744
1745}
1746
1747#endif /* AMREX_PARMPARSE_H_ */
#define AMREX_ALWAYS_ASSERT(EX)
Definition AMReX_BLassert.H:50
Definition AMReX_IParser.H:58
IParserExecutor< N > compileHost() const
This compiles for CPU only.
Definition AMReX_IParser.H:111
Parse Parameters From Command Line and Input Files.
Definition AMReX_ParmParse.H:343
int queryline(std::string_view name, std::string &ref) const
Definition AMReX_ParmParse.cpp:2162
int countname(std::string_view name) const
Returns the number of times the given name (prepended with prefix) appears in the table.
Definition AMReX_ParmParse.cpp:2177
int queryarrWithParser(std::string_view name, int nvals, std::vector< T > &ref) const
Definition AMReX_ParmParse.H:1146
int queryAdd(std::string_view name, std::vector< T > &ref)
If name is found, the value in the ParmParse database will be stored in the ref argument....
Definition AMReX_ParmParse.H:1063
void getWithParser(std::string_view name, T &ref) const
Get with Parser. If name is found, this uses amrex::Parser to parse the entire list of empty space se...
Definition AMReX_ParmParse.H:1188
void gettable(std::string_view name, std::vector< std::vector< T > > &ref) const
Get vector of vector. It's an error if it is not found. The table (i.e., vector of vector) is in the ...
Definition AMReX_ParmParse.H:1644
int querytable(std::string_view name, std::vector< std::vector< double > > &ref) const
Query vector of vector. The return value indicates whether it's found. The table (i....
Definition AMReX_ParmParse.cpp:2411
int query(std::string_view name, std::array< T, N > &ref) const
Definition AMReX_ParmParse.H:1018
static void prettyPrintTable(std::ostream &os)
Definition AMReX_ParmParse.cpp:1337
void get(std::string_view name, T &ref, int ival=FIRST) const
. Get enum value using given name.
Definition AMReX_ParmParse.H:1338
static void Initialize(int argc, char **argv, const char *parfile)
Construct an initial ParmParse object from the argc and argv passed in to main(). An error will be si...
Definition AMReX_ParmParse.cpp:1140
void getarr(std::string_view name, std::vector< T > &ref, int start_ix=FIRST, int num_val=ALL) const
Get an array of enum values using given name.
Definition AMReX_ParmParse.H:1383
static void addfile(std::string const &filename)
Add keys and values from a file to the end of the PP table.
Definition AMReX_ParmParse.cpp:1115
static std::string const FileKeyword
keyword for files to load
Definition AMReX_ParmParse.H:1730
void get_enum_sloppy(std::string_view name, T &ref, std::string_view const &ignores, int ival=FIRST) const
. Get enum value using given name.
Definition AMReX_ParmParse.H:1508
static std::string ParserPrefix
Definition AMReX_ParmParse.H:1732
static int Verbose()
Definition AMReX_ParmParse.cpp:1221
static void SetVerbose(int v)
Definition AMReX_ParmParse.cpp:1234
int query(std::string_view name, T &ref, int ival=FIRST) const
. Query enum value using given name.
Definition AMReX_ParmParse.H:1300
void get(const char *new_name, const char *old_name, T &ref)
Get using two names.
Definition AMReX_ParmParse.H:1279
static bool hasUnusedInputs(const std::string &prefix=std::string())
Any unused [prefix.]* parameters?
Definition AMReX_ParmParse.cpp:1172
Parser makeParser(std::string const &func, Vector< std::string > const &vars) const
Definition AMReX_ParmParse.cpp:2329
int queryAdd(std::string_view name, std::string &ref)
Definition AMReX_ParmParse.H:1045
int query_enum_case_insensitive(std::string_view name, T &ref, int ival=FIRST) const
. Query enum value using given name.
Definition AMReX_ParmParse.H:1416
int queryktharr(std::string_view name, int k, std::vector< int > &ref, int start_ix=FIRST, int num_val=ALL) const
queryktharr() is to querykth() as getktharr() is to getkth().
Definition AMReX_ParmParse.cpp:1469
int queryAsDouble(std::string_view name, T &ref) const
Query T with Parser, but treat the number as double precision during parsing.
Definition AMReX_ParmParse.H:1529
static bool QueryUnusedInputs()
Definition AMReX_ParmParse.cpp:1157
void getline(std::string_view name, std::string &ref) const
Definition AMReX_ParmParse.cpp:2154
T eval(std::string const &expr) const
Definition AMReX_ParmParse.H:1245
void getarr(std::string_view name, std::vector< int > &ref, int start_ix=FIRST, int num_val=ALL) const
Same as getktharr() but searches for last occurrence of name.
Definition AMReX_ParmParse.cpp:1460
void getarrWithParser(std::string_view name, int nvals, T *ptr) const
Get with Parser. If name is not found, it's a runtime error. If the number of elements does not equal...
Definition AMReX_ParmParse.H:1207
void getkth(std::string_view name, int k, bool &ref, int ival=FIRST) const
Get the ival'th value of kth occurrence of the requested name. If successful, the value is converted ...
Definition AMReX_ParmParse.cpp:1367
void getAsDouble(std::string_view name, T &ref) const
Get T with Parser, but treat the number as double precision during parsing.
Definition AMReX_ParmParse.H:1589
bool contains(std::string_view name) const
Returns true if name is in table.
Definition AMReX_ParmParse.cpp:2193
int queryarrAsDouble(std::string_view name, int nvals, T *ptr) const
Query T array with Parser, but treat the number as double precision during parsing.
Definition AMReX_ParmParse.H:1558
void get(std::string_view name, std::array< T, N > &ref) const
Definition AMReX_ParmParse.H:1008
static void prettyPrintUsedInputs(std::ostream &os)
Definition AMReX_ParmParse.cpp:1349
static void Finalize()
The destructor. The internal static table will only be deleted if there are no other ParmParse object...
Definition AMReX_ParmParse.cpp:1240
int queryAdd(std::string_view name, std::vector< T > &ref, int num_val)
If name is found, the value in the ParmParse database will be stored in the ref argument....
Definition AMReX_ParmParse.H:1082
std::string m_prefix
Definition AMReX_ParmParse.H:1740
const Table & table() const
Definition AMReX_ParmParse.H:1727
int queryAddWithParser(std::string_view name, T &ref)
Query with Parser. If name is found, this uses amrex::Parser to parse the entire list of empty space ...
Definition AMReX_ParmParse.H:1168
int querykth(std::string_view name, int k, bool &ref, int ival=FIRST) const
Similar to getkth() but returns 0 if there is no kth occurrence of name. If successful,...
Definition AMReX_ParmParse.cpp:1384
static void SetParserPrefix(std::string a_prefix)
Set prefix used by math expression Parser.
Definition AMReX_ParmParse.cpp:1267
int queryWithParser(std::string_view name, bool &ref) const
Query with Parser. If name is found, this uses amrex::Parser to parse the entire list of empty space ...
Definition AMReX_ParmParse.cpp:2257
static std::vector< std::string > getUnusedInputs(const std::string &prefix=std::string())
Returns unused [prefix.]* parameters.
Definition AMReX_ParmParse.cpp:1178
int queryAdd(std::string_view name, T &ref)
If name is found, the value in the ParmParse database will be stored in the ref argument....
Definition AMReX_ParmParse.H:1037
void addarr(std::string_view name, const std::vector< int > &ref)
Add a key 'name' with vector of values 'ref' to the end of the PP table.
Definition AMReX_ParmParse.cpp:1488
std::string const & getPrefix() const
Definition AMReX_ParmParse.cpp:1095
int remove(std::string_view name)
Remove given name from the table.
Definition AMReX_ParmParse.cpp:2209
int queryarr(std::string_view name, std::vector< int > &ref, int start_ix=FIRST, int num_val=ALL) const
Same as queryktharr() but searches for last occurrence of name.
Definition AMReX_ParmParse.cpp:1479
@ FIRST
Definition AMReX_ParmParse.H:345
@ LAST
Definition AMReX_ParmParse.H:345
@ ALL
Definition AMReX_ParmParse.H:345
void add(std::string_view name, T const &val)
Definition AMReX_ParmParse.H:1323
int queryarr(std::string_view name, std::vector< T > &ref, int start_ix=FIRST, int num_val=ALL) const
Query an array of enum values using given name.
Definition AMReX_ParmParse.H:1356
static void Initialize(int argc, char **argv, const std::string &parfile)
Definition AMReX_ParmParse.H:1662
int queryAdd(std::string_view name, std::array< T, N > &ref)
If name is found, the value in the ParmParse database will be stored in the ref argument....
Definition AMReX_ParmParse.H:1097
int query(const char *new_name, const char *old_name, T &ref)
Definition AMReX_ParmParse.H:1265
Table * m_table
Definition AMReX_ParmParse.H:1742
int queryarrWithParser(std::string_view name, int nvals, bool *ptr) const
Query with Parser. The return value indicates whether it's found. Note that queryWithParser will be u...
Definition AMReX_ParmParse.cpp:2293
void getarrAsDouble(std::string_view name, int nvals, T *ptr) const
Get T array with Parser, but treat the number as double precision during parsing.
Definition AMReX_ParmParse.H:1606
std::string m_parser_prefix
Definition AMReX_ParmParse.H:1741
void add(std::string_view name, bool val)
Add a key 'name' with value 'val' to the end of the PP table.
Definition AMReX_ParmParse.cpp:1401
void get_enum_case_insensitive(std::string_view name, T &ref, int ival=FIRST) const
. Get enum value using given name.
Definition AMReX_ParmParse.H:1446
static void dumpTable(std::ostream &os, bool prettyPrint=false)
Write the contents of the table in ASCII to the ostream.
Definition AMReX_ParmParse.cpp:1273
void getktharr(std::string_view name, int k, std::vector< int > &ref, int start_ix=FIRST, int num_val=ALL) const
Gets an std::vector<int> of num_val values from kth occurrence of given name. If successful,...
Definition AMReX_ParmParse.cpp:1450
static void prettyPrintUnusedInputs(std::ostream &os)
Definition AMReX_ParmParse.cpp:1343
static std::set< std::string > getEntries(const std::string &prefix=std::string())
Returns [prefix.]* parameters.
Definition AMReX_ParmParse.cpp:1208
std::string prefixedName(std::string_view str) const
Definition AMReX_ParmParse.cpp:1101
void getarrWithParser(std::string_view name, int nvals, std::vector< T > &ref) const
Get with Parser. If name is not found, it's a runtime error. If the number of elements does not equal...
Definition AMReX_ParmParse.H:1226
int query(std::string_view name, bool &ref, int ival=FIRST) const
Same as querykth() but searches for the last occurrence of name.
Definition AMReX_ParmParse.cpp:1393
int query_enum_sloppy(std::string_view name, T &ref, std::string_view const &ignores, int ival=FIRST) const
. Query enum value using given name.
Definition AMReX_ParmParse.H:1471
void get(std::string_view name, bool &ref, int ival=FIRST) const
Same as getkth() but searches for the last occurrence of name.
Definition AMReX_ParmParse.cpp:1376
std::unordered_map< std::string, PP_entry > Table
Definition AMReX_ParmParse.H:1725
IParser makeIParser(std::string const &func, Vector< std::string > const &vars) const
Definition AMReX_ParmParse.cpp:2336
int countval(std::string_view name, int n=LAST) const
Returns the number of values associated with nth occurrence of name (prepended with the prefix) in th...
Definition AMReX_ParmParse.cpp:1355
Definition AMReX_Parser.H:70
ParserExecutor< N > compileHost() const
This compiles for CPU only.
Definition AMReX_Parser.H:143
This class provides the user with a few print options.
Definition AMReX_Print.H:35
This class is a thin wrapper around std::vector. Unlike vector, Vector::operator[] provides bound che...
Definition AMReX_Vector.H:28
typename ArithmeticOptional_TT< T >::value_type underlying_type_t
Definition AMReX_ParmParse.H:60
constexpr bool IsArithmeticOptional_v
Definition AMReX_ParmParse.H:57
Definition AMReX_Amr.cpp:49
std::ostream & ErrorStream()
Definition AMReX.cpp:931
std::string getEnumNameString(T const &v)
Definition AMReX_Enum.H:154
BoxND< 3 > Box
Definition AMReX_BaseFwd.H:27
__host__ __device__ RealVectND(Real, Real, Args...) -> RealVectND< sizeof...(Args)+2 >
IntVectND< 3 > IntVect
Definition AMReX_BaseFwd.H:30
void Error(const std::string &msg)
Print out message to cerr and exit via amrex::Abort().
Definition AMReX.cpp:224
__host__ __device__ IntVectND(const Array< int, dim > &) -> IntVectND< dim >
int Verbose() noexcept
Definition AMReX.cpp:169
void Abort(const std::string &msg)
Print out message to cerr and exit via abort().
Definition AMReX.cpp:230
Definition AMReX_ParmParse.H:1706
std::variant< std::string *, bool *, int *, long *, long long *, amrex::IntVect *, amrex::Box *, float *, double * > m_typehint
Definition AMReX_ParmParse.H:1723
std::vector< std::vector< std::string > > m_vals
Definition AMReX_ParmParse.H:1711
Long m_count
Definition AMReX_ParmParse.H:1712
Definition AMReX_ParmParse.H:39