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#include <AMReX_Vector.H>
14
15#include <array>
16#include <concepts>
17#include <iosfwd>
18#include <optional>
19#include <set>
20#include <string>
21#include <string_view>
22#include <type_traits>
23#include <unordered_map>
24#include <variant>
25#include <vector>
26
27namespace amrex {
28
29template<int dim>
30class BoxND;
31using Box = BoxND<AMREX_SPACEDIM>;
32template<int dim>
33class IntVectND;
34using IntVect = IntVectND<AMREX_SPACEDIM>;
35template<int dim>
36class RealVectND;
38
40namespace ppdetail {
41 template <class T, class Enable = void>
42 struct ArithmeticOptional_TT : std::false_type {};
43
44 template <class T>
45 requires (std::is_arithmetic_v<T>)
46 struct ArithmeticOptional_TT<T>
47 : std::true_type
48 {
49 using value_type = T;
50 };
51
52 template <class T>
53 requires (std::is_arithmetic_v<T>)
54 struct ArithmeticOptional_TT<std::optional<T>>
55 : std::true_type
56 {
57 using value_type = T;
58 };
59
60 template <class T>
61 inline constexpr bool IsArithmeticOptional_v = ArithmeticOptional_TT<T>::value;
62
63 template <class T>
64 using underlying_type_t = typename ArithmeticOptional_TT<T>::value_type;
65}
67
68//
69// ParmParse class implements a simple database for the storage and
70// retrieval of command-line and input-file arguments. The entries are
71// stored in a static table in (name,value_list) pairs.
72//
73// The format of the input file is a series of DEFINITIONS.
74//
75// A DEFINITION is of the form <name> = <value> <value> ...
76// The equal sign is important since the list of values can span multiple
77// lines.
78//
79// Comments in an input file include all text from a '#' character to the
80// end of the line. Here is an example input file:
81/*
82 niter = 100 # niter is an integer
83 title = "Double Wammy" # example of a string with spaces
84 cell_size = 0.5 0.75 # cell spacing in each dimension
85 plot.var = Density 1 10 # a list of values
86 plot.var = Energy 5 12 # another list of values
87 bigarray = 1 2 3 4 5 6 7 8 \
88 9 10 11 12 # continuation of bigarray
89 multi_line_string = "This is a
90 multi-line string."
91 my_2d_table = \
92 # col 1 2 3
93 {{ 11.0, 12.0, 13.0 } # row 1
94 { 21.0, 22.0, 23.0 } # row 2
95 { 31.0, 32.0, 33.0 } # row 3
96 { 41.0, 42.0, 43.0 } } # row 4
97 test = apple "boy blue" 10 20 30 40
98 FILE = prob_file # insert contents of this "prob_file" here
99*/
100// For values spanning multiple lines except for table, one must use '\' at
101// the end of a line
102// for continuation, otherwise it's a runtime error. Note that there must be
103// at least one space before the continuation character `\`. Multiple lines
104// inside a pair of double quotes are considered a single string containing
105// '\n's. The "FILE = <filename>" definition is special. Rather than just
106// adding this entry to the database, it reads the contents of <filename>
107// into the database.
108// For CI/CD workflows and out-of-source tests, the environment variable
109// AMREX_INPUTS_FILE_PREFIX can be set to prefix every FILE = <filename>
110// with a custom path.
111//
112// ParmParse stores all entries in a static table which is built the
113// first time a ParmParse object is constructed (usually in main()).
114// Subsequent invocations have access to this table.
115// A ParmParse constructor has an optional "prefix" argument that will
116// limit the searches to only those entries of the table with this prefix
117// in name. For example:
118// ParmParse pp("plot");
119// will find only those entries with name given by "plot.<string>".
120//
121// All values in the table are stored as strings. For example, the
122// values of "cell_size" in the above input file are stored as the
123// strings "0.5" and "0.75". These strings can be returned as either
124// strings or numeric values by the query functions.
125// Character strings with spaces must be delimited by double quotes
126// in the input file but the quotes are stripped before they are entered
127// into the table. For example, 'title' in the above input file has a
128// single value, the string 'Double Wammy' (without the quotes).
129// Each value in the list associated with a definition can be referred to
130// by its index number. The index numbers start at 0 just like an array
131// in the C programming language. Consider the definition of "test" in
132// the above input file. The first value 'apple'is a string with index
133// 0. The second value 'boy blue' is a string with index 1. The
134// remaining four values are integers indexed 2, 3, 4, and 5.
135//
136// For a string value to represent an integer or float it must fit the
137// following regular expression:
138// Sign ::= '+' | '-'
139// Digit ::= '0' | '1' | ... | '9'
140// Integer ::= [Sign]Digit+
141// Exp ::= ('e'|'E')Integer
142// Float ::= ( Integer[.Digit*][Exp] | [Integer].Digit+[Exp] )
143//
144// Where '+' indicates one or more occurrences, '*' represents zero or
145// more occurrences, '|' means one or the other and '[]' represents zero
146// or one occurrence.
147//
148// Note that floats and doubles have the same string representation and
149// that the FORTRAN "double" exponent format is not supported.
150// That is, 1.0d+3 is not a valid representation of a floating point
151// number but that 1.0e+3 is acceptable.
152//
153// There are a host of functions allowing the user to query the database
154// and retrieve values. Here are some general rules about the names of
155// the member functions:
156//
157// * Functions with the string "get" in their names attempt to get a
158// value or an array of values from the table. They generate a
159// run-time error if they are not successful.
160//
161// * Functions with the string "query" in their names attempt to get a
162// value or an array of values from the table. They return the value 1
163// (true) if they are successful and 0 (false) if not.
164//
165// * Functions with the string "kth" in their names get values from
166// the Kth entry with the given name in the database. This is
167// necessary since there may be multiple definitions with the same
168// name in the database.
169//
170// * Functions without the string "kth" in their names get values from
171// the last entry with the given name in the database. Note that the
172// definitions from the command line are appended to the database table
173// and hence will be the last entries.
174//
175// * Functions with the string "arr" in their names get an Array of
176// values from the given entry in the table. The array argument is
177// resized (if necessary) to hold all the values requested.
178//
179// * Functions without the string "arr" in their names get single
180// values from the given entry in the table.
181//
182// The following is a code sample showing how to use ParmParse:
183//
184// main(int argc, char **argv)
185// {
186// char* in_file_name = argv[1];
187// ParmParse::Initialize(argc-2, argv+2, in_file_name);
188//
189// // Query table for value of "niter". If not in table
190// // then set to default value
191// if (!pp.query("niter",niter)) niter = 20;
192//
193// // read array of cell sizes if in table
194// Vector<float> dx;
195// if (nx=pp.countval("cell_size")) {
196// // get nx values starting at index 0 and store in dx.
197// // dx is automatically resized here.
198// pp.getarr("cell_size",dx,0,nx);
199// }
200// ParmParse::Finalize();
201// }
202//
203// void do_graphics()
204// {
205// //
206// // Will only query entries with the "plot" prefix:
207// //
208// ParmParse pp("plot");
209// //
210// // Read all variables with "plot.var" keyword.
211// //
212// std::string var_name;
213// Vector<int> range;
214// int num = pp.countname("var");
215// for (int k = 0; k < num; k++)
216// {
217// //
218// // Element 0 in list is a string.
219// //
220// pp.getkth("var",k,var_name,0);
221// //
222// // Elements 1 and 2 are integers.
223// // Note that "range" will be resized to hold 2 elements.
224// //
225// pp.getktharr("var",k,range,1,2);
226// cout << "variable = " << var_name << "lo, hi = ",
227// << range[0] << " " << range[1] << endl;
228// }
229// }
230// -----------------------------------------------------------------
231// ----------------------- END COMMENTS ---------------------------
232// -----------------------------------------------------------------
233
234
351{
352public:
353 enum { LAST = -1, FIRST = 0, ALL = -1 };
361 explicit ParmParse (std::string prefix = std::string(),
362 std::string parser_prefix = std::string());
363
365 [[nodiscard]] bool contains (std::string_view name) const;
371 [[nodiscard]] int countval (std::string_view name, int n = LAST) const;
376 [[nodiscard]] int countname (std::string_view name) const;
388 void getkth (std::string_view name,
389 int k,
390 bool& ref,
391 int ival = FIRST) const;
393 void get (std::string_view name,
394 bool& ref,
395 int ival = FIRST) const;
403 int querykth (std::string_view name,
404 int k,
405 bool& ref,
406 int ival = FIRST) const;
408 int query (std::string_view name,
409 bool& ref,
410 int ival = FIRST) const;
412 void add (std::string_view name, bool val);
422 void getkth (std::string_view name,
423 int k,
424 int& ref,
425 int ival = FIRST) const;
426
428 void get (std::string_view name,
429 int& ref,
430 int ival = FIRST) const;
438 int querykth (std::string_view name,
439 int k,
440 int& ref,
441 int ival = FIRST) const;
443 int query (std::string_view name,
444 int& ref,
445 int ival = FIRST) const;
447 void add (std::string_view name, int val);
457 void getkth (std::string_view name,
458 int k,
459 long& ref,
460 int ival = FIRST) const;
462 void get (std::string_view name,
463 long& ref,
464 int ival = FIRST) const;
472 int querykth (std::string_view name,
473 int k,
474 long& ref,
475 int ival = FIRST) const;
477 int query (std::string_view name,
478 long& ref,
479 int ival = FIRST) const;
481 void add (std::string_view name, long val);
491 void getkth (std::string_view name,
492 int k,
493 long long& ref,
494 int ival = FIRST) const;
496 void get (std::string_view name,
497 long long& ref,
498 int ival = FIRST) const;
506 int querykth (std::string_view name,
507 int k,
508 long long& ref,
509 int ival = FIRST) const;
511 int query (std::string_view name,
512 long long& ref,
513 int ival = FIRST) const;
515 void add (std::string_view name, long long val);
525 void getkth (std::string_view name,
526 int k,
527 float& ref,
528 int ival = FIRST) const;
530 void get (std::string_view name,
531 float& ref,
532 int ival = FIRST) const;
540 int querykth (std::string_view name,
541 int k,
542 float& ref,
543 int ival = FIRST) const;
545 int query (std::string_view name,
546 float& ref,
547 int ival = FIRST) const;
549 void add (std::string_view name, float val);
559 void getkth (std::string_view name,
560 int k,
561 double& ref,
562 int ival = FIRST) const;
564 void get (std::string_view name,
565 double& ref,
566 int ival = FIRST) const;
574 int querykth (std::string_view name,
575 int k,
576 double& ref,
577 int ival = FIRST) const;
579 int query (std::string_view name,
580 double& ref,
581 int ival = FIRST) const;
583 void add (std::string_view name, double val);
593 void getkth (std::string_view name,
594 int k,
595 std::string& ref,
596 int ival = FIRST) const;
597
599 void get (std::string_view name,
600 std::string& ref,
601 int ival = FIRST) const;
609 int querykth (std::string_view name,
610 int k,
611 std::string& ref,
612 int ival = FIRST) const;
614 int query (std::string_view name,
615 std::string& ref,
616 int ival = FIRST) const;
618 void add (std::string_view name, const std::string& val);
619
621 void add (std::string_view name, const char* val) { add(name, std::string(val)); }
622
631 void getline (std::string_view name, std::string& ref) const;
632
641 int queryline (std::string_view name, std::string& ref) const;
642
652 void getkth (std::string_view name,
653 int k,
654 IntVect& ref,
655 int ival = FIRST) const;
657 void get (std::string_view name,
658 IntVect& ref,
659 int ival = FIRST) const;
667 int querykth (std::string_view name,
668 int k,
669 IntVect& ref,
670 int ival = FIRST) const;
672 int query (std::string_view name,
673 IntVect& ref,
674 int ival = FIRST) const;
676 void add (std::string_view name, const IntVect& val);
686 void getkth (std::string_view name,
687 int k,
688 Box& ref,
689 int ival = FIRST) const;
691 void get (std::string_view name,
692 Box& ref,
693 int ival = FIRST) const;
701 int querykth (std::string_view name,
702 int k,
703 Box& ref,
704 int ival = FIRST) const;
706 int query (std::string_view name,
707 Box& ref,
708 int ival = FIRST) const;
710 void add (std::string_view name, const Box& val);
723 void getktharr (std::string_view name,
724 int k,
725 std::vector<int>& ref,
726 int start_ix = FIRST,
727 int num_val = ALL) const;
729 void getarr (std::string_view name,
730 std::vector<int>& ref,
731 int start_ix = FIRST,
732 int num_val = ALL) const;
734 int queryktharr (std::string_view name,
735 int k,
736 std::vector<int>& ref,
737 int start_ix = FIRST,
738 int num_val = ALL) const;
740 int queryarr (std::string_view name,
741 std::vector<int>& ref,
742 int start_ix = FIRST,
743 int num_val = ALL) const;
745 void addarr (std::string_view name, const std::vector<int>& ref);
746
759 void getktharr (std::string_view name,
760 int k,
761 std::vector<long>& ref,
762 int start_ix = FIRST,
763 int num_val = ALL) const;
765 void getarr (std::string_view name,
766 std::vector<long>& ref,
767 int start_ix = FIRST,
768 int num_val = ALL) const;
770 int queryktharr (std::string_view name,
771 int k,
772 std::vector<long>& ref,
773 int start_ix = FIRST,
774 int num_val = ALL) const;
776 int queryarr (std::string_view name,
777 std::vector<long>& ref,
778 int start_ix = FIRST,
779 int num_val = ALL) const;
781 void addarr (std::string_view name, const std::vector<long>& ref);
782
795 void getktharr (std::string_view name,
796 int k,
797 std::vector<long long>& ref,
798 int start_ix = FIRST,
799 int num_val = ALL) const;
801 void getarr (std::string_view name,
802 std::vector<long long>& ref,
803 int start_ix = FIRST,
804 int num_val = ALL) const;
806 int queryktharr (std::string_view name,
807 int k,
808 std::vector<long long>& ref,
809 int start_ix = FIRST,
810 int num_val = ALL) const;
812 int queryarr (std::string_view name,
813 std::vector<long long>& ref,
814 int start_ix = FIRST,
815 int num_val = ALL) const;
817 void addarr (std::string_view name, const std::vector<long long>& ref);
818
831 void getktharr (std::string_view name,
832 int k,
833 std::vector<float>& ref,
834 int start_ix = FIRST,
835 int num_val = ALL) const;
837 void getarr (std::string_view name,
838 std::vector<float>& ref,
839 int start_ix = FIRST,
840 int num_val = ALL) const;
842 int queryktharr (std::string_view name,
843 int k,
844 std::vector<float>& ref,
845 int start_ix = FIRST,
846 int num_val = ALL) const;
848 int queryarr (std::string_view name,
849 std::vector<float>& ref,
850 int start_ix = FIRST,
851 int num_val = ALL) const;
853 void addarr (std::string_view name, const std::vector<float>& ref);
866 void getktharr (std::string_view name,
867 int k,
868 std::vector<double>& ref,
869 int start_ix = FIRST,
870 int num_val = ALL) const;
872 void getarr (std::string_view name,
873 std::vector<double>& ref,
874 int start_ix = FIRST,
875 int num_val = ALL) const;
877 int queryktharr (std::string_view name,
878 int k,
879 std::vector<double>& ref,
880 int start_ix = FIRST,
881 int num_val = ALL) const;
883 int queryarr (std::string_view name,
884 std::vector<double>& ref,
885 int start_ix = FIRST,
886 int num_val = ALL) const;
888 void addarr (std::string_view name, const std::vector<double>& ref);
901 void getktharr (std::string_view name,
902 int k,
903 std::vector<std::string>& ref,
904 int start_ix = FIRST,
905 int num_val = ALL) const;
907 void getarr (std::string_view name,
908 std::vector<std::string>& ref,
909 int start_ix = FIRST,
910 int num_val = ALL) const;
912 int queryktharr (std::string_view name,
913 int k,
914 std::vector<std::string>& ref,
915 int start_ix = FIRST,
916 int num_val = ALL) const;
918 int queryarr (std::string_view name,
919 std::vector<std::string>& ref,
920 int start_ix = FIRST,
921 int num_val = ALL) const;
923 void addarr (std::string_view name, const std::vector<std::string>& ref);
936 void getktharr (std::string_view name,
937 int k,
938 std::vector<IntVect>& ref,
939 int start_ix = FIRST,
940 int num_val = ALL) const;
942 void getarr (std::string_view name,
943 std::vector<IntVect>& ref,
944 int start_ix = FIRST,
945 int num_val = ALL) const;
947 int queryktharr (std::string_view name,
948 int k,
949 std::vector<IntVect>& ref,
950 int start_ix = FIRST,
951 int num_val = ALL) const;
953 int queryarr (std::string_view name,
954 std::vector<IntVect>& ref,
955 int start_ix = FIRST,
956 int num_val = ALL) const;
958 void addarr (std::string_view name, const std::vector<IntVect>& ref);
971 void getktharr (std::string_view name,
972 int k,
973 std::vector<Box>& ref,
974 int start_ix = FIRST,
975 int num_val = ALL) const;
977 void getarr (std::string_view name,
978 std::vector<Box>& ref,
979 int start_ix = FIRST,
980 int num_val = ALL) const;
982 int queryktharr (std::string_view name,
983 int k,
984 std::vector<Box>& ref,
985 int start_ix = FIRST,
986 int num_val = ALL) const;
988 int queryarr (std::string_view name,
989 std::vector<Box>& ref,
990 int start_ix = FIRST,
991 int num_val = ALL) const;
993 void addarr (std::string_view name, const std::vector<Box>& ref);
994
995 /*
996 * \brief Query IntVect from array
997 *
998 * This reads IntVect from an array (e.g., `8 16 8`), not the format
999 * using parentheses (e.g., `(8,16,8)`).
1000 */
1001 int queryarr (std::string_view name, IntVect& ref) const;
1002
1003 /*
1004 * \brief Get IntVect from array
1005 *
1006 * This reads IntVect from an array (e.g., `8 16 8`), not the format
1007 * using parentheses (e.g., `(8,16,8)`).
1008 */
1009 void getarr (std::string_view name, IntVect& ref) const;
1010
1012 int queryarr (std::string_view name, RealVect& ref) const;
1013
1015 void getarr (std::string_view name, RealVect& ref) const;
1016
1017 template <typename T, std::size_t N>
1018 void get (std::string_view name, std::array<T,N>& ref) const {
1019 std::vector<T> v;
1020 this->getarr(name, v);
1021 AMREX_ALWAYS_ASSERT(v.size() >= N);
1022 for (std::size_t i = 0; i < N; ++i) {
1023 ref[i] = v[i];
1024 }
1025 }
1026
1027 template <typename T, std::size_t N>
1028 int query (std::string_view name, std::array<T,N>& ref) const {
1029 std::vector<T> v;
1030 int exist = this->queryarr(name, v);
1031 if (exist) {
1032 AMREX_ALWAYS_ASSERT(v.size() >= N);
1033 for (std::size_t i = 0; i < N; ++i) {
1034 ref[i] = v[i];
1035 }
1036 }
1037 return exist;
1038 }
1039
1046 template <typename T>
1047 int queryAdd (std::string_view name, T& ref) {
1048 int exist = this->query(name, ref);
1049 if (!exist) {
1050 this->add(name, ref);
1051 }
1052 return exist;
1053 }
1054
1055 int queryAdd (std::string_view name, std::string& ref) {
1056 int exist = this->query(name, ref);
1057 if (!exist && !ref.empty()) {
1058 this->add(name, ref);
1059 }
1060 return exist;
1061 }
1062
1072 template <typename T>
1073 int queryAdd (std::string_view name, std::vector<T>& ref) {
1074 std::vector<T> empty;
1075 int exist = this->queryarr(name, empty);
1076 if (exist) {
1077 ref = std::move(empty);
1078 }
1079 if (!exist && !ref.empty()) {
1080 this->addarr(name, ref);
1081 }
1082 return exist;
1083 }
1084
1085 template <typename T>
1086 int queryAdd (std::string_view name, Vector<T>& ref) {
1087 return this->queryAdd(name, static_cast<std::vector<T>&>(ref));
1088 }
1089
1096 template <typename T>
1097 int queryAdd (std::string_view name, std::vector<T>& ref, int num_val) {
1098 int exist = this->queryarr(name, ref, 0, num_val);
1099 if (!exist) {
1100 this->addarr(name, ref);
1101 }
1102 return exist;
1103 }
1104
1111 template <typename T, std::size_t N>
1112 int queryAdd (std::string_view name, std::array<T,N>& ref) {
1113 std::vector<T> v;
1114 int exist = this->queryarr(name, v);
1115 if (exist) {
1116 AMREX_ALWAYS_ASSERT(v.size() >= N);
1117 for (std::size_t i = 0; i < N; ++i) {
1118 ref[i] = v[i];
1119 }
1120 } else {
1121 v.resize(N);
1122 for (std::size_t i = 0; i < N; ++i) {
1123 v[i] = ref[i];
1124 }
1125 this->addarr(name, v);
1126 }
1127 return exist;
1128 }
1129
1136 int queryWithParser (std::string_view name, bool& ref) const;
1137 int queryWithParser (std::string_view name, int& ref) const;
1138 int queryWithParser (std::string_view name, long& ref) const;
1139 int queryWithParser (std::string_view name, long long& ref) const;
1140 int queryWithParser (std::string_view name, float& ref) const;
1141 int queryWithParser (std::string_view name, double& ref) const;
1142
1149 int queryarrWithParser (std::string_view name, int nvals, bool* ptr) const;
1150 int queryarrWithParser (std::string_view name, int nvals, int* ptr) const;
1151 int queryarrWithParser (std::string_view name, int nvals, long* ptr) const;
1152 int queryarrWithParser (std::string_view name, int nvals, long long* ptr) const;
1153 int queryarrWithParser (std::string_view name, int nvals, float* ptr) const;
1154 int queryarrWithParser (std::string_view name, int nvals, double* ptr) const;
1155 template <typename T>
1156 requires (std::same_as<T,bool> ||
1157 std::same_as<T,int> ||
1158 std::same_as<T,long> ||
1159 std::same_as<T,long long> ||
1160 std::same_as<T,float> ||
1161 std::same_as<T,double>)
1162 int queryarrWithParser (std::string_view name, int nvals, std::vector<T>& ref) const
1163 {
1164 if (this->contains(name)) {
1165 if (int(ref.size()) < nvals) { ref.resize(nvals); }
1166 return this->queryarrWithParser(name, nvals, ref.data());
1167 } else {
1168 return 0;
1169 }
1170 }
1171
1178 template <typename T>
1179 requires (std::same_as<T,bool> ||
1180 std::same_as<T,int> ||
1181 std::same_as<T,long> ||
1182 std::same_as<T,long long> ||
1183 std::same_as<T,float> ||
1184 std::same_as<T,double>)
1185 int queryAddWithParser (std::string_view name, T& ref)
1186 {
1187 int exist = this->queryWithParser(name, ref);
1188 if (!exist) {
1189 this->add(name, ref);
1190 }
1191 return exist;
1192 }
1193
1199 template <typename T>
1200 requires (std::same_as<T,bool> ||
1201 std::same_as<T,int> ||
1202 std::same_as<T,long> ||
1203 std::same_as<T,long long> ||
1204 std::same_as<T,float> ||
1205 std::same_as<T,double>)
1206 void getWithParser (std::string_view name, T& ref) const
1207 {
1208 int exist = this->queryWithParser(name, ref);
1209 if (!exist) {
1210 amrex::Error(std::string("ParmParse::getWithParser: failed to get ")+std::string(name));
1211 }
1212 }
1213
1219 template <typename T>
1220 requires (std::same_as<T,bool> ||
1221 std::same_as<T,int> ||
1222 std::same_as<T,long> ||
1223 std::same_as<T,long long> ||
1224 std::same_as<T,float> ||
1225 std::same_as<T,double>)
1226 void getarrWithParser (std::string_view name, int nvals, T* ptr) const
1227 {
1228 int exist = this->queryarrWithParser(name, nvals, ptr);
1229 if (!exist) {
1230 amrex::Error(std::string("ParmParse::getarrWithParser: failed to get ")+std::string(name));
1231 }
1232 }
1233
1239 template <typename T>
1240 requires (std::same_as<T,bool> ||
1241 std::same_as<T,int> ||
1242 std::same_as<T,long> ||
1243 std::same_as<T,long long> ||
1244 std::same_as<T,float> ||
1245 std::same_as<T,double>)
1246 void getarrWithParser (std::string_view name, int nvals, std::vector<T>& ref) const
1247 {
1248 int exist = this->queryarrWithParser(name, nvals, ref);
1249 if (!exist) {
1250 amrex::Error(std::string("ParmParse::getarrWithParser: failed to get ")+std::string(name));
1251 }
1252 }
1253
1254 /*
1255 * \brief Evaluate given string as math expression
1256 *
1257 * For unknown symbols, ParmParse database will be queried.
1258 */
1259 template <typename T>
1260 requires (std::same_as<T,bool> ||
1261 std::same_as<T,int> ||
1262 std::same_as<T,long> ||
1263 std::same_as<T,long long> ||
1264 std::same_as<T,float> ||
1265 std::same_as<T,double>)
1266 T eval (std::string const& expr) const
1267 {
1268 if constexpr (std::is_integral_v<T>) {
1269 auto const parser = this->makeIParser(expr, {});
1270 auto const exe = parser.compileHost<0>();
1271 return static_cast<T>(exe()); // In the future, we might add safety check.
1272 } else {
1273 auto const parser = this->makeParser(expr, {});
1274 auto const exe = parser.compileHost<0>();
1275 return static_cast<T>(exe());
1276 }
1277 }
1278
1279 /*
1280 * \brief Query two names.
1281 *
1282 * This function queries with `new_name` first. If it's not found, it
1283 * will try again with `old_name`.
1284 */
1285 template <typename T>
1286 int query (const char* new_name, const char* old_name, T& ref)
1287 {
1288 return (this->query(new_name, ref) ||
1289 this->query(old_name, ref));
1290 }
1291
1299 template <typename T>
1300 void get (const char* new_name, const char* old_name, T& ref)
1301 {
1302 auto exist = this->query(new_name, old_name, ref);
1303 if (!exist) {
1304 amrex::ErrorStream() << "ParmParse::get failed to find "
1305 << new_name << " and " << old_name << '\n';
1307 amrex::Abort();
1308 }
1309 }
1310
1319 template <typename T, typename ET = amrex_enum_traits<T>>
1320 requires (ET::value)
1321 int query (std::string_view name, T& ref, int ival = FIRST) const
1322 {
1323 std::string s;
1324 int exist = this->query(name, s, ival);
1325 if (exist) {
1326 try {
1327 ref = amrex::getEnum<T>(s);
1328 } catch (...) {
1329 if (amrex::Verbose() > 0 ) {
1330 amrex::Print() << "amrex::ParmParse::query (input name: "
1331 << this->prefixedName(name) << "):\n";
1332 }
1333 throw;
1334 }
1335 }
1336 return exist;
1337 }
1338
1339
1342 template <typename T, typename ET = amrex_enum_traits<T>>
1343 requires (ET::value)
1344 void add (std::string_view name, T const& val)
1345 {
1346 this->add(name, amrex::getEnumNameString(val));
1347 }
1348
1357 template <typename T, typename ET = amrex_enum_traits<T>>
1358 requires (ET::value)
1359 void get (std::string_view name, T& ref, int ival = FIRST) const
1360 {
1361 std::string s;
1362 this->get(name, s, ival);
1363 try {
1364 ref = amrex::getEnum<T>(s);
1365 } catch (...) {
1366 if (amrex::Verbose() > 0 ) {
1367 amrex::Print() << "amrex::ParmParse::get (input name: "
1368 << this->prefixedName(name) << "):\n";
1369 }
1370 throw;
1371 }
1372 }
1373
1375 template <typename T, typename ET = amrex_enum_traits<T>>
1376 requires (ET::value)
1377 int queryarr (std::string_view name,
1378 std::vector<T>& ref,
1379 int start_ix = FIRST,
1380 int num_val = ALL) const
1381 {
1382 std::vector<std::string> s;
1383 int exist = this->queryarr(name, s, start_ix, num_val);
1384 if (exist) {
1385 ref.resize(s.size());
1386 for (std::size_t i = 0; i < s.size(); ++i) {
1387 try {
1388 ref[i] = amrex::getEnum<T>(s[i]);
1389 } catch (...) {
1390 if (amrex::Verbose() > 0 ) {
1391 amrex::Print() << "amrex::ParmParse::queryarr (input name: "
1392 << this->prefixedName(name) << "):\n";
1393 }
1394 throw;
1395 }
1396 }
1397 }
1398 return exist;
1399 }
1400
1402 template <typename T, typename ET = amrex_enum_traits<T>>
1403 requires (ET::value)
1404 void getarr (std::string_view name,
1405 std::vector<T>& ref,
1406 int start_ix = FIRST,
1407 int num_val = ALL) const
1408 {
1409 std::vector<std::string> s;
1410 this->getarr(name, s, start_ix, num_val);
1411 ref.resize(s.size());
1412 for (std::size_t i = 0; i < s.size(); ++i) {
1413 try {
1414 ref[i] = amrex::getEnum<T>(s[i]);
1415 } catch (...) {
1416 if (amrex::Verbose() > 0 ) {
1417 amrex::Print() << "amrex::ParmParse::getarr (input name: "
1418 << this->prefixedName(name) << "):\n";
1419 }
1420 throw;
1421 }
1422 }
1423 }
1424
1435 template <typename T, typename ET = amrex_enum_traits<T>>
1436 requires (ET::value)
1437 int query_enum_case_insensitive (std::string_view name, T& ref, int ival = FIRST) const
1438 {
1439 std::string s;
1440 int exist = this->query(name, s, ival);
1441 if (exist) {
1442 try {
1443 ref = amrex::getEnumCaseInsensitive<T>(s);
1444 } catch (...) {
1445 if (amrex::Verbose() > 0) {
1446 amrex::Print() << "amrex::ParmParse::query_enum_case_insensitive (input name: "
1447 << this->prefixedName(name) << "):\n";
1448 }
1449 throw;
1450 }
1451 }
1452 return exist;
1453 }
1454
1465 template <typename T, typename ET = amrex_enum_traits<T>>
1466 requires (ET::value)
1467 void get_enum_case_insensitive (std::string_view name, T& ref, int ival = FIRST) const
1468 {
1469 int exist = this->query_enum_case_insensitive(name, ref, ival);
1470 if (!exist) {
1471 std::string msg("get_enum_case_insensitive(\"");
1472 msg.append(name).append("\",").append(amrex::getEnumClassName<T>())
1473 .append("&) failed.");
1474 amrex::Abort(msg);
1475 }
1476 }
1477
1490 template <typename T, typename ET = amrex_enum_traits<T>>
1491 requires (ET::value)
1492 int query_enum_sloppy (std::string_view name, T& ref, std::string_view const& ignores,
1493 int ival = FIRST) const
1494 {
1495 std::string s;
1496 int exist = this->query(name, s, ival);
1497 if (exist) {
1498 try {
1499 s.erase(std::remove_if(s.begin(), s.end(),
1500 [&] (auto const& c) {
1501 return ignores.find(c) != std::string_view::npos; }),
1502 s.end());
1503 ref = amrex::getEnumCaseInsensitive<T>(s);
1504 } catch (...) {
1505 if (amrex::Verbose() > 0) {
1506 amrex::Print() << "amrex::ParmParse::query_enum_sloppy (input name: "
1507 << this->prefixedName(name) << "):\n";
1508 }
1509 throw;
1510 }
1511 }
1512 return exist;
1513 }
1514
1527 template <typename T, typename ET = amrex_enum_traits<T>>
1528 requires (ET::value)
1529 void get_enum_sloppy (std::string_view name, T& ref, std::string_view const& ignores,
1530 int ival = FIRST) const
1531 {
1532 int exist = this->query_enum_sloppy(name, ref, ignores, ival);
1533 if (!exist) {
1534 std::string msg("get_enum_sloppy(\"");
1535 msg.append(name).append("\",").append(amrex::getEnumClassName<T>())
1536 .append("&) failed.");
1537 amrex::Abort(msg);
1538 }
1539 }
1540
1549 template <typename T>
1550 requires (ppdetail::IsArithmeticOptional_v<T>)
1551 int queryAsDouble (std::string_view name, T& ref) const
1552 {
1553 using value_type = ppdetail::underlying_type_t<T>;
1554 double dref;
1555 int exist = queryWithParser(name, dref);
1556 if (exist) {
1557 if (std::is_integral_v<value_type>) {
1558 dref = std::round(dref);
1559 }
1560 auto vref = static_cast<value_type>(dref);
1561 if constexpr (std::is_integral_v<value_type> && !std::is_same_v<value_type,bool>) {
1562 if (static_cast<double>(vref) != dref) {
1563 amrex::Abort("ParmParse:: queryAsDouble is not safe");
1564 }
1565 }
1566 ref = vref;
1567 }
1568 return exist;
1569 }
1570
1579 template <typename T>
1580 requires (ppdetail::IsArithmeticOptional_v<T>)
1581 int queryarrAsDouble (std::string_view name, int nvals, T* ptr) const
1582 {
1583 using value_type = ppdetail::underlying_type_t<T>;
1584 std::vector<double> dref(nvals);
1585 int exist = queryarrWithParser(name, nvals, dref.data());
1586 if (exist) {
1587 for (int i = 0; i < nvals; ++i) {
1588 if (std::is_integral_v<value_type>) {
1589 dref[i] = std::round(dref[i]);
1590 }
1591 auto vref = static_cast<value_type>(dref[i]);
1592 if constexpr (std::is_integral_v<value_type> && !std::is_same_v<value_type,bool>) {
1593 if (static_cast<double>(vref) != dref[i]) {
1594 amrex::Abort("ParmParse:: queryarrAsDouble is not safe");
1595 }
1596 }
1597 ptr[i] = vref;
1598 }
1599 }
1600 return exist;
1601 }
1602
1611 template <typename T>
1612 requires (ppdetail::IsArithmeticOptional_v<T>)
1613 void getAsDouble (std::string_view name, T& ref) const
1614 {
1615 int exist = this->queryAsDouble(name, ref);
1616 if (!exist) {
1617 amrex::Error(std::string("ParmParse::getAsDouble: failed to get ")+std::string(name));
1618 }
1619 }
1620
1629 template <typename T>
1630 requires (ppdetail::IsArithmeticOptional_v<T>)
1631 void getarrAsDouble (std::string_view name, int nvals, T* ptr) const
1632 {
1633 int exist = this->queryarrAsDouble(name, nvals, ptr);
1634 if (!exist) {
1635 amrex::Error(std::string("ParmParse::getarrAsDouble: failed to get ")+std::string(name));
1636 }
1637 }
1638
1640 int remove (std::string_view name);
1641
1645 [[nodiscard]] Parser makeParser (std::string const& func,
1646 Vector<std::string> const& vars) const;
1647
1651 [[nodiscard]] IParser makeIParser (std::string const& func,
1652 Vector<std::string> const& vars) const;
1653
1659 int querytable (std::string_view name, std::vector<std::vector<double>>& ref) const;
1660 int querytable (std::string_view name, std::vector<std::vector<float>>& ref) const;
1661 int querytable (std::string_view name, std::vector<std::vector<int>>& ref) const;
1662
1668 template <typename T>
1669 void gettable (std::string_view name, std::vector<std::vector<T>>& ref) const
1670 {
1671 if (this->querytable(name, ref) == 0) {
1672 amrex::ErrorStream() << "ParmParse::gettable: " << name
1673 << " not found in database\n";
1675 amrex::Abort();
1676 }
1677 }
1678
1684 int queryarr (std::string_view name, std::vector<std::vector<double>>& ref) const;
1685 int queryarr (std::string_view name, std::vector<std::vector<float>>& ref) const;
1686 int queryarr (std::string_view name, std::vector<std::vector<int>>& ref) const;
1687 int queryarr (std::string_view name, std::vector<std::vector<std::string>>& ref) const;
1688
1693 template <typename T>
1694 void getarr (std::string_view name, std::vector<std::vector<T>>& ref) const
1695 {
1696 if (this->queryarr(name, ref) == 0) {
1697 amrex::ErrorStream() << "ParmParse::getarr: " << name
1698 << " not found in database\n";
1700 amrex::Abort();
1701 }
1702 }
1703
1711 static void Initialize (int argc, char** argv, const char* parfile);
1712 static void Initialize (int argc, char** argv, const std::string& parfile) {
1713 Initialize(argc, argv, parfile.c_str());
1714 }
1719 static void Finalize ();
1720
1722 static void SetParserPrefix (std::string a_prefix);
1723
1724 static int Verbose ();
1725 static void SetVerbose (int v);
1726
1730 static void dumpTable (std::ostream& os, bool prettyPrint = false);
1731
1735 static void prettyPrintTable (std::ostream& os);
1736
1739 static void prettyPrintUnusedInputs (std::ostream& os);
1740
1743 static void prettyPrintUsedInputs (std::ostream& os);
1744
1748 static void addfile (std::string const& filename);
1749
1750 static bool QueryUnusedInputs ();
1751
1753 [[nodiscard]] static bool hasUnusedInputs (const std::string& prefix = std::string());
1754
1756 [[nodiscard]] static std::vector<std::string> getUnusedInputs (const std::string& prefix = std::string());
1757
1759 [[nodiscard]] static std::set<std::string> getEntries (const std::string& prefix = std::string());
1760
1761 enum class QuoteType : unsigned char {
1762 None = 0,
1763 Double,
1764 Triple
1765 };
1766
1767 struct PP_entry {
1768 // There can be multiple occurrences for a given name (e.g.,
1769 // multiple lines starting with `foo =` in inputs. For each
1770 // occurrence, there can be multiple values. Thus, the use of
1771 // vector<vector<std::string>>.
1772 std::vector<std::vector<std::string>> m_vals;
1773 std::vector<std::vector<QuoteType>> m_quotes;
1774 mutable Long m_count = 0;
1775 mutable std::variant<
1776 std::string*,
1777 bool*,
1778 int*,
1779 long*,
1780 long long*,
1782 amrex::Box*,
1783 float*,
1784 double*
1785 > m_typehint = static_cast<std::string*>(nullptr);
1786 mutable std::vector<std::variant<bool, int, long, long long, float, double>> m_last_vals;
1787 mutable bool m_parsed = false;
1788 };
1789 using Table = std::unordered_map<std::string, PP_entry>;
1790
1791 [[nodiscard]] const Table& table() const {return *m_table;}
1792
1794 static std::string const FileKeyword;
1795
1797 static std::string const UnsetKeyword;
1798
1799 static std::string ParserPrefix;
1800
1801 [[nodiscard]] std::string const& getPrefix () const;
1802
1803 [[nodiscard]] std::string prefixedName (std::string_view str) const;
1804
1805protected:
1806
1807 std::string m_prefix; // Prefix used in keyword search
1808 std::string m_parser_prefix; // Prefix used by Parser
1810};
1811
1812}
1813
1814#endif /* AMREX_PARMPARSE_H_ */
#define AMREX_ALWAYS_ASSERT(EX)
Definition AMReX_BLassert.H:50
Integer-only runtime expression parser and executor helpers.
Runtime expression parser front-end and compiled executor helpers.
Integer-only variant of amrex::Parser.
Definition AMReX_IParser.H:93
IParserExecutor< N > compileHost() const
Compile the expression into a host-only executor.
Definition AMReX_IParser.H:191
Parse Parameters From Command Line and Input Files.
Definition AMReX_ParmParse.H:351
QuoteType
Definition AMReX_ParmParse.H:1761
int queryline(std::string_view name, std::string &ref) const
Definition AMReX_ParmParse.cpp:2717
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:2732
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:1073
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:1047
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:1669
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:3017
int query(std::string_view name, std::array< T, N > &ref) const
Definition AMReX_ParmParse.H:1028
static std::string const UnsetKeyword
keyword for removing entries from the table
Definition AMReX_ParmParse.H:1797
static void prettyPrintTable(std::ostream &os)
Definition AMReX_ParmParse.cpp:1851
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:1652
static void addfile(std::string const &filename)
Definition AMReX_ParmParse.cpp:1622
static std::string const FileKeyword
keyword for files to load
Definition AMReX_ParmParse.H:1794
static std::string ParserPrefix
Definition AMReX_ParmParse.H:1799
static int Verbose()
Definition AMReX_ParmParse.cpp:1733
static void SetVerbose(int v)
Definition AMReX_ParmParse.cpp:1746
void get(const char *new_name, const char *old_name, T &ref)
Get using two names.
Definition AMReX_ParmParse.H:1300
static bool hasUnusedInputs(const std::string &prefix=std::string())
Any unused [prefix.]* parameters?
Definition AMReX_ParmParse.cpp:1684
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:1581
Parser makeParser(std::string const &func, Vector< std::string > const &vars) const
Definition AMReX_ParmParse.cpp:2935
int queryAdd(std::string_view name, std::string &ref)
Definition AMReX_ParmParse.H:1055
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:2024
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:1631
static bool QueryUnusedInputs()
Definition AMReX_ParmParse.cpp:1669
void getline(std::string_view name, std::string &ref) const
Definition AMReX_ParmParse.cpp:2709
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:2015
void add(std::string_view name, const char *val)
Convert const char * to string, to prevent auto-conversion to bool.
Definition AMReX_ParmParse.H:621
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:1922
bool contains(std::string_view name) const
Returns true if name is in table.
Definition AMReX_ParmParse.cpp:2748
void get(std::string_view name, std::array< T, N > &ref) const
Definition AMReX_ParmParse.H:1018
void getarr(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 vector of vector is in the format of [[a0...
Definition AMReX_ParmParse.H:1694
static void prettyPrintUsedInputs(std::ostream &os)
Definition AMReX_ParmParse.cpp:1863
static void Finalize()
The destructor. The internal static table will only be deleted if there are no other ParmParse object...
Definition AMReX_ParmParse.cpp:1752
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:1097
std::string m_prefix
Definition AMReX_ParmParse.H:1807
const Table & table() const
Definition AMReX_ParmParse.H:1791
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:1185
T eval(std::string const &expr) const
Definition AMReX_ParmParse.H:1266
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:1939
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:1529
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:1437
static void SetParserPrefix(std::string a_prefix)
Set prefix used by math expression Parser.
Definition AMReX_ParmParse.cpp:1779
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:2863
static std::vector< std::string > getUnusedInputs(const std::string &prefix=std::string())
Returns unused [prefix.]* parameters.
Definition AMReX_ParmParse.cpp:1690
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:2043
std::string const & getPrefix() const
Definition AMReX_ParmParse.cpp:1602
int remove(std::string_view name)
Remove given name from the table.
Definition AMReX_ParmParse.cpp:2764
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:2034
@ FIRST
Definition AMReX_ParmParse.H:353
@ LAST
Definition AMReX_ParmParse.H:353
@ ALL
Definition AMReX_ParmParse.H:353
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:1492
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:1467
static void Initialize(int argc, char **argv, const std::string &parfile)
Definition AMReX_ParmParse.H:1712
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:1112
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:1226
int query(const char *new_name, const char *old_name, T &ref)
Definition AMReX_ParmParse.H:1286
Table * m_table
Definition AMReX_ParmParse.H:1809
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:2899
std::string m_parser_prefix
Definition AMReX_ParmParse.H:1808
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:1956
static void dumpTable(std::ostream &os, bool prettyPrint=false)
Definition AMReX_ParmParse.cpp:1787
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:2005
static void prettyPrintUnusedInputs(std::ostream &os)
Definition AMReX_ParmParse.cpp:1857
static std::set< std::string > getEntries(const std::string &prefix=std::string())
Returns [prefix.]* parameters.
Definition AMReX_ParmParse.cpp:1720
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:1551
std::string prefixedName(std::string_view str) const
Definition AMReX_ParmParse.cpp:1608
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:1613
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:1948
int queryAdd(std::string_view name, Vector< T > &ref)
Definition AMReX_ParmParse.H:1086
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:1931
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:1206
std::unordered_map< std::string, PP_entry > Table
Definition AMReX_ParmParse.H:1789
IParser makeIParser(std::string const &func, Vector< std::string > const &vars) const
Definition AMReX_ParmParse.cpp:2942
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:1869
Front-end for parsing scalar expressions into GPU/CPU executors.
Definition AMReX_Parser.H:126
ParserExecutor< N > compileHost() const
Compile the current expression into a host-only executor.
Definition AMReX_Parser.H:272
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:29
amrex_long Long
Definition AMReX_INT.H:30
Definition AMReX_Amr.cpp:50
std::ostream & ErrorStream()
Definition AMReX.cpp:970
BoxND< 3 > Box
Box is an alias for amrex::BoxND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:30
std::string getEnumNameString(T const &v)
Definition AMReX_Enum.H:157
IntVectND< 3 > IntVect
IntVect is an alias for amrex::IntVectND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:33
void Error(const std::string &msg)
Print out message to cerr and exit via amrex::Abort().
Definition AMReX.cpp:235
__host__ __device__ IntVectND(const Array< int, dim > &) -> IntVectND< dim >
int Verbose() noexcept
Definition AMReX.cpp:181
void Abort(const std::string &msg)
Print out message to cerr and exit via abort().
Definition AMReX.cpp:241
__host__ __device__ RealVectND(Real, Real, Args...) -> RealVectND< sizeof...(Args)+2 >
Definition AMReX_ParmParse.H:1767
std::variant< std::string *, bool *, int *, long *, long long *, amrex::IntVect *, amrex::Box *, float *, double * > m_typehint
Definition AMReX_ParmParse.H:1785
std::vector< std::vector< std::string > > m_vals
Definition AMReX_ParmParse.H:1772
std::vector< std::vector< QuoteType > > m_quotes
Definition AMReX_ParmParse.H:1773
Long m_count
Definition AMReX_ParmParse.H:1774
std::vector< std::variant< bool, int, long, long long, float, double > > m_last_vals
Definition AMReX_ParmParse.H:1786
bool m_parsed
Definition AMReX_ParmParse.H:1787