1#ifndef AMREX_PARMPARSE_H_
2#define AMREX_PARMPARSE_H_
3#include <AMReX_Config.H>
21#include <unordered_map>
29using Box = BoxND<AMREX_SPACEDIM>;
32using IntVect = IntVectND<AMREX_SPACEDIM>;
39 template <
class T,
class Enable =
void>
40 struct ArithmeticOptional_TT : std::false_type {};
43 struct ArithmeticOptional_TT<T, std::enable_if_t<std::is_arithmetic_v<T>>>
50 struct ArithmeticOptional_TT<std::optional<T>,
51 std::enable_if_t<std::is_arithmetic_v<T>>>
58 inline constexpr bool IsArithmeticOptional_v = ArithmeticOptional_TT<T>::value;
61 using underlying_type_t =
typename ArithmeticOptional_TT<T>::value_type;
356 explicit ParmParse (std::string prefix = std::string(),
357 std::string parser_prefix = std::string());
360 [[nodiscard]]
bool contains (std::string_view name)
const;
366 [[nodiscard]]
int countval (std::string_view name,
int n =
LAST)
const;
371 [[nodiscard]]
int countname (std::string_view name)
const;
383 void getkth (std::string_view name,
386 int ival =
FIRST)
const;
388 void get (std::string_view name,
390 int ival =
FIRST)
const;
398 int querykth (std::string_view name,
401 int ival =
FIRST)
const;
403 int query (std::string_view name,
405 int ival =
FIRST)
const;
407 void add (std::string_view name,
bool val);
417 void getkth (std::string_view name,
420 int ival =
FIRST)
const;
423 void get (std::string_view name,
425 int ival =
FIRST)
const;
433 int querykth (std::string_view name,
436 int ival =
FIRST)
const;
438 int query (std::string_view name,
440 int ival =
FIRST)
const;
442 void add (std::string_view name,
int val);
452 void getkth (std::string_view name,
455 int ival =
FIRST)
const;
457 void get (std::string_view name,
459 int ival =
FIRST)
const;
467 int querykth (std::string_view name,
470 int ival =
FIRST)
const;
472 int query (std::string_view name,
474 int ival =
FIRST)
const;
476 void add (std::string_view name,
long val);
486 void getkth (std::string_view name,
489 int ival =
FIRST)
const;
491 void get (std::string_view name,
493 int ival =
FIRST)
const;
501 int querykth (std::string_view name,
504 int ival =
FIRST)
const;
506 int query (std::string_view name,
508 int ival =
FIRST)
const;
510 void add (std::string_view name,
long long val);
520 void getkth (std::string_view name,
523 int ival =
FIRST)
const;
525 void get (std::string_view name,
527 int ival =
FIRST)
const;
535 int querykth (std::string_view name,
538 int ival =
FIRST)
const;
540 int query (std::string_view name,
542 int ival =
FIRST)
const;
544 void add (std::string_view name,
float val);
554 void getkth (std::string_view name,
557 int ival =
FIRST)
const;
559 void get (std::string_view name,
561 int ival =
FIRST)
const;
569 int querykth (std::string_view name,
572 int ival =
FIRST)
const;
574 int query (std::string_view name,
576 int ival =
FIRST)
const;
578 void add (std::string_view name,
double val);
588 void getkth (std::string_view name,
591 int ival =
FIRST)
const;
594 void get (std::string_view name,
596 int ival =
FIRST)
const;
604 int querykth (std::string_view name,
607 int ival =
FIRST)
const;
609 int query (std::string_view name,
611 int ival =
FIRST)
const;
613 void add (std::string_view name,
const std::string& val);
624 void getline (std::string_view name, std::string& ref)
const;
634 int queryline (std::string_view name, std::string& ref)
const;
645 void getkth (std::string_view name,
648 int ival =
FIRST)
const;
650 void get (std::string_view name,
652 int ival =
FIRST)
const;
660 int querykth (std::string_view name,
663 int ival =
FIRST)
const;
665 int query (std::string_view name,
667 int ival =
FIRST)
const;
669 void add (std::string_view name,
const IntVect& val);
679 void getkth (std::string_view name,
682 int ival =
FIRST)
const;
684 void get (std::string_view name,
686 int ival =
FIRST)
const;
694 int querykth (std::string_view name,
697 int ival =
FIRST)
const;
699 int query (std::string_view name,
701 int ival =
FIRST)
const;
703 void add (std::string_view name,
const Box& val);
718 std::vector<int>& ref,
719 int start_ix =
FIRST,
720 int num_val =
ALL)
const;
722 void getarr (std::string_view name,
723 std::vector<int>& ref,
724 int start_ix =
FIRST,
725 int num_val =
ALL)
const;
729 std::vector<int>& ref,
730 int start_ix =
FIRST,
731 int num_val =
ALL)
const;
733 int queryarr (std::string_view name,
734 std::vector<int>& ref,
735 int start_ix =
FIRST,
736 int num_val =
ALL)
const;
738 void addarr (std::string_view name,
const std::vector<int>& ref);
754 std::vector<long>& ref,
755 int start_ix =
FIRST,
756 int num_val =
ALL)
const;
758 void getarr (std::string_view name,
759 std::vector<long>& ref,
760 int start_ix =
FIRST,
761 int num_val =
ALL)
const;
765 std::vector<long>& ref,
766 int start_ix =
FIRST,
767 int num_val =
ALL)
const;
769 int queryarr (std::string_view name,
770 std::vector<long>& ref,
771 int start_ix =
FIRST,
772 int num_val =
ALL)
const;
774 void addarr (std::string_view name,
const std::vector<long>& ref);
790 std::vector<long long>& ref,
791 int start_ix =
FIRST,
792 int num_val =
ALL)
const;
794 void getarr (std::string_view name,
795 std::vector<long long>& ref,
796 int start_ix =
FIRST,
797 int num_val =
ALL)
const;
801 std::vector<long long>& ref,
802 int start_ix =
FIRST,
803 int num_val =
ALL)
const;
805 int queryarr (std::string_view name,
806 std::vector<long long>& ref,
807 int start_ix =
FIRST,
808 int num_val =
ALL)
const;
810 void addarr (std::string_view name,
const std::vector<long long>& ref);
826 std::vector<float>& ref,
827 int start_ix =
FIRST,
828 int num_val =
ALL)
const;
830 void getarr (std::string_view name,
831 std::vector<float>& ref,
832 int start_ix =
FIRST,
833 int num_val =
ALL)
const;
837 std::vector<float>& ref,
838 int start_ix =
FIRST,
839 int num_val =
ALL)
const;
841 int queryarr (std::string_view name,
842 std::vector<float>& ref,
843 int start_ix =
FIRST,
844 int num_val =
ALL)
const;
846 void addarr (std::string_view name,
const std::vector<float>& ref);
861 std::vector<double>& ref,
862 int start_ix =
FIRST,
863 int num_val =
ALL)
const;
865 void getarr (std::string_view name,
866 std::vector<double>& ref,
867 int start_ix =
FIRST,
868 int num_val =
ALL)
const;
872 std::vector<double>& ref,
873 int start_ix =
FIRST,
874 int num_val =
ALL)
const;
876 int queryarr (std::string_view name,
877 std::vector<double>& ref,
878 int start_ix =
FIRST,
879 int num_val =
ALL)
const;
881 void addarr (std::string_view name,
const std::vector<double>& ref);
896 std::vector<std::string>& ref,
897 int start_ix =
FIRST,
898 int num_val =
ALL)
const;
900 void getarr (std::string_view name,
901 std::vector<std::string>& ref,
902 int start_ix =
FIRST,
903 int num_val =
ALL)
const;
907 std::vector<std::string>& ref,
908 int start_ix =
FIRST,
909 int num_val =
ALL)
const;
911 int queryarr (std::string_view name,
912 std::vector<std::string>& ref,
913 int start_ix =
FIRST,
914 int num_val =
ALL)
const;
916 void addarr (std::string_view name,
const std::vector<std::string>& ref);
931 std::vector<IntVect>& ref,
932 int start_ix =
FIRST,
933 int num_val =
ALL)
const;
935 void getarr (std::string_view name,
936 std::vector<IntVect>& ref,
937 int start_ix =
FIRST,
938 int num_val =
ALL)
const;
942 std::vector<IntVect>& ref,
943 int start_ix =
FIRST,
944 int num_val =
ALL)
const;
946 int queryarr (std::string_view name,
947 std::vector<IntVect>& ref,
948 int start_ix =
FIRST,
949 int num_val =
ALL)
const;
951 void addarr (std::string_view name,
const std::vector<IntVect>& ref);
966 std::vector<Box>& ref,
967 int start_ix =
FIRST,
968 int num_val =
ALL)
const;
970 void getarr (std::string_view name,
971 std::vector<Box>& ref,
972 int start_ix =
FIRST,
973 int num_val =
ALL)
const;
977 std::vector<Box>& ref,
978 int start_ix =
FIRST,
979 int num_val =
ALL)
const;
981 int queryarr (std::string_view name,
982 std::vector<Box>& ref,
983 int start_ix =
FIRST,
984 int num_val =
ALL)
const;
986 void addarr (std::string_view name,
const std::vector<Box>& ref);
1010 template <
typename T, std::
size_t N>
1011 void get (std::string_view name, std::array<T,N>& ref)
const {
1015 for (std::size_t i = 0; i < N; ++i) {
1020 template <
typename T, std::
size_t N>
1021 int query (std::string_view name, std::array<T,N>& ref)
const {
1023 int exist = this->
queryarr(name, v);
1026 for (std::size_t i = 0; i < N; ++i) {
1039 template <typename T, std::enable_if_t<!IsStdVector<T>::value,
int> = 0>
1041 int exist = this->
query(name, ref);
1043 this->
add(name, ref);
1048 int queryAdd (std::string_view name, std::string& ref) {
1049 int exist = this->
query(name, ref);
1050 if (!exist && !ref.empty()) {
1051 this->
add(name, ref);
1065 template <
typename T>
1066 int queryAdd (std::string_view name, std::vector<T>& ref) {
1067 std::vector<T> empty;
1068 int exist = this->
queryarr(name, empty);
1070 ref = std::move(empty);
1072 if (!exist && !ref.empty()) {
1084 template <
typename T>
1085 int queryAdd (std::string_view name, std::vector<T>& ref,
int num_val) {
1086 int exist = this->
queryarr(name, ref, 0, num_val);
1099 template <
typename T, std::
size_t N>
1100 int queryAdd (std::string_view name, std::array<T,N>& ref) {
1102 int exist = this->
queryarr(name, v);
1105 for (std::size_t i = 0; i < N; ++i) {
1110 for (std::size_t i = 0; i < N; ++i) {
1143 template <
typename T, std::enable_if_t<std::is_same_v<T,
bool> ||
1144 std::is_same_v<T,
int> ||
1145 std::is_same_v<T,
long> ||
1146 std::is_same_v<T,
long long> ||
1147 std::is_same_v<T,
float> ||
1148 std::is_same_v<T,
double>,
int> = 0>
1152 if (
int(ref.size()) < nvals) { ref.resize(nvals); }
1165 template <
typename T, std::enable_if_t<std::is_same_v<T,
bool> ||
1166 std::is_same_v<T,
int> ||
1167 std::is_same_v<T,
long> ||
1168 std::is_same_v<T,
long long> ||
1169 std::is_same_v<T,
float> ||
1170 std::is_same_v<T,
double>,
int> = 0>
1175 this->
add(name, ref);
1185 template <
typename T, std::enable_if_t<std::is_same_v<T,
bool> ||
1186 std::is_same_v<T,
int> ||
1187 std::is_same_v<T,
long> ||
1188 std::is_same_v<T,
long long> ||
1189 std::is_same_v<T,
float> ||
1190 std::is_same_v<T,
double>,
int> = 0>
1195 amrex::Error(std::string(
"ParmParse::getWithParser: failed to get ")+std::string(name));
1204 template <
typename T, std::enable_if_t<std::is_same_v<T,
bool> ||
1205 std::is_same_v<T,
int> ||
1206 std::is_same_v<T,
long> ||
1207 std::is_same_v<T,
long long> ||
1208 std::is_same_v<T,
float> ||
1209 std::is_same_v<T,
double>,
int> = 0>
1214 amrex::Error(std::string(
"ParmParse::getarrWithParser: failed to get ")+std::string(name));
1223 template <
typename T, std::enable_if_t<std::is_same_v<T,
bool> ||
1224 std::is_same_v<T,
int> ||
1225 std::is_same_v<T,
long> ||
1226 std::is_same_v<T,
long long> ||
1227 std::is_same_v<T,
float> ||
1228 std::is_same_v<T,
double>,
int> = 0>
1233 amrex::Error(std::string(
"ParmParse::getarrWithParser: failed to get ")+std::string(name));
1242 template <
typename T, std::enable_if_t<std::is_same_v<T,
bool> ||
1243 std::is_same_v<T,
int> ||
1244 std::is_same_v<T,
long> ||
1245 std::is_same_v<T,
long long> ||
1246 std::is_same_v<T,
float> ||
1247 std::is_same_v<T,
double>,
int> = 0>
1248 T
eval (std::string
const& expr)
const
1250 if constexpr (std::is_integral_v<T>) {
1253 return static_cast<T
>(exe());
1255 auto const parser = this->
makeParser(expr, {});
1257 return static_cast<T
>(exe());
1267 template <
typename T>
1268 int query (
const char* new_name,
const char* old_name, T& ref)
1270 return (this->
query(new_name, ref) ||
1271 this->
query(old_name, ref));
1281 template <
typename T>
1282 void get (
const char* new_name,
const char* old_name, T& ref)
1284 auto exist = this->
query(new_name, old_name, ref);
1287 << new_name <<
" and " << old_name <<
'\n';
1301 template <
typename T,
typename ET = amrex_enum_traits<T>,
1302 std::enable_if_t<ET::value,
int> = 0>
1303 int query (std::string_view name, T& ref,
int ival =
FIRST)
const
1306 int exist = this->
query(name, s, ival);
1309 ref = amrex::getEnum<T>(s);
1312 amrex::Print() <<
"amrex::ParmParse::query (input name: "
1324 template <
typename T,
typename ET = amrex_enum_traits<T>,
1325 std::enable_if_t<ET::value,
int> = 0>
1326 void add (std::string_view name, T
const& val)
1339 template <
typename T,
typename ET = amrex_enum_traits<T>,
1340 std::enable_if_t<ET::value,
int> = 0>
1341 void get (std::string_view name, T& ref,
int ival =
FIRST)
const
1344 this->
get(name, s, ival);
1346 ref = amrex::getEnum<T>(s);
1349 amrex::Print() <<
"amrex::ParmParse::get (input name: "
1357 template <
typename T,
typename ET = amrex_enum_traits<T>,
1358 std::enable_if_t<ET::value,
int> = 0>
1360 std::vector<T>& ref,
1361 int start_ix =
FIRST,
1362 int num_val =
ALL)
const
1364 std::vector<std::string> s;
1365 int exist = this->
queryarr(name, s, start_ix, num_val);
1367 ref.resize(s.size());
1368 for (std::size_t i = 0; i < s.size(); ++i) {
1370 ref[i] = amrex::getEnum<T>(s[i]);
1373 amrex::Print() <<
"amrex::ParmParse::queryarr (input name: "
1384 template <
typename T,
typename ET = amrex_enum_traits<T>,
1385 std::enable_if_t<ET::value,
int> = 0>
1387 std::vector<T>& ref,
1388 int start_ix =
FIRST,
1389 int num_val =
ALL)
const
1391 std::vector<std::string> s;
1392 this->
getarr(name, s, start_ix, num_val);
1393 ref.resize(s.size());
1394 for (std::size_t i = 0; i < s.size(); ++i) {
1396 ref[i] = amrex::getEnum<T>(s[i]);
1399 amrex::Print() <<
"amrex::ParmParse::getarr (input name: "
1417 template <
typename T,
typename ET = amrex_enum_traits<T>,
1418 std::enable_if_t<ET::value,
int> = 0>
1422 int exist = this->
query(name, s, ival);
1425 ref = amrex::getEnumCaseInsensitive<T>(s);
1428 amrex::Print() <<
"amrex::ParmParse::query_enum_case_insensitive (input name: "
1447 template <
typename T,
typename ET = amrex_enum_traits<T>,
1448 std::enable_if_t<ET::value,
int> = 0>
1453 std::string msg(
"get_enum_case_insensitive(\"");
1454 msg.append(name).append(
"\",").append(amrex::getEnumClassName<T>())
1455 .append(
"&) failed.");
1472 template <
typename T,
typename ET = amrex_enum_traits<T>,
1473 std::enable_if_t<ET::value,
int> = 0>
1475 int ival =
FIRST)
const
1478 int exist = this->
query(name, s, ival);
1481 s.erase(std::remove_if(s.begin(), s.end(),
1482 [&] (
auto const& c) {
1483 return ignores.find(c) != std::string_view::npos; }),
1485 ref = amrex::getEnumCaseInsensitive<T>(s);
1488 amrex::Print() <<
"amrex::ParmParse::query_enum_sloppy (input name: "
1509 template <
typename T,
typename ET = amrex_enum_traits<T>,
1510 std::enable_if_t<ET::value,
int> = 0>
1512 int ival =
FIRST)
const
1516 std::string msg(
"get_enum_sloppy(\"");
1517 msg.append(name).append(
"\",").append(amrex::getEnumClassName<T>())
1518 .append(
"&) failed.");
1531 template <
typename T, std::enable_if_t<ppdetail::IsArithmeticOptional_v<T>,
int> = 0>
1534 using value_type = ppdetail::underlying_type_t<T>;
1538 if (std::is_integral_v<value_type>) {
1539 dref = std::round(dref);
1541 auto vref =
static_cast<value_type
>(dref);
1542 if constexpr (std::is_integral_v<value_type> && !std::is_same_v<value_type,bool>) {
1543 if (
static_cast<double>(vref) != dref) {
1560 template <
typename T, std::enable_if_t<ppdetail::IsArithmeticOptional_v<T>,
int> = 0>
1563 using value_type = ppdetail::underlying_type_t<T>;
1564 std::vector<double> dref(nvals);
1567 for (
int i = 0; i < nvals; ++i) {
1568 if (std::is_integral_v<value_type>) {
1569 dref[i] = std::round(dref[i]);
1571 auto vref =
static_cast<value_type
>(dref[i]);
1572 if constexpr (std::is_integral_v<value_type> && !std::is_same_v<value_type,bool>) {
1573 if (
static_cast<double>(vref) != dref[i]) {
1574 amrex::Abort(
"ParmParse:: queryarrAsDouble is not safe");
1591 template <
typename T, std::enable_if_t<ppdetail::IsArithmeticOptional_v<T>,
int> = 0>
1596 amrex::Error(std::string(
"ParmParse::getAsDouble: failed to get ")+std::string(name));
1608 template <
typename T, std::enable_if_t<ppdetail::IsArithmeticOptional_v<T>,
int> = 0>
1613 amrex::Error(std::string(
"ParmParse::getarrAsDouble: failed to get ")+std::string(name));
1618 int remove (std::string_view name);
1637 int querytable (std::string_view name, std::vector<std::vector<double>>& ref)
const;
1638 int querytable (std::string_view name, std::vector<std::vector<float>>& ref)
const;
1639 int querytable (std::string_view name, std::vector<std::vector<int>>& ref)
const;
1646 template <
typename T>
1647 void gettable (std::string_view name, std::vector<std::vector<T>>& ref)
const
1651 <<
" not found in database\n";
1664 static void Initialize (
int argc,
char** argv,
const char* parfile);
1665 static void Initialize (
int argc,
char** argv,
const std::string& parfile) {
1666 return Initialize(argc, argv, parfile.c_str());
1681 static void dumpTable (std::ostream& os,
bool prettyPrint =
false);
1696 static void addfile (std::string
const& filename);
1701 [[nodiscard]]
static bool hasUnusedInputs (
const std::string& prefix = std::string());
1704 [[nodiscard]]
static std::vector<std::string>
getUnusedInputs (
const std::string& prefix = std::string());
1707 [[nodiscard]]
static std::set<std::string>
getEntries (
const std::string& prefix = std::string());
1714 std::vector<std::vector<std::string>>
m_vals;
1716 mutable std::variant<
1727 mutable std::vector<std::variant<bool, int, long, long long, float, double>>
m_last_vals;
1730 using Table = std::unordered_map<std::string, PP_entry>;
1739 [[nodiscard]] std::string
const&
getPrefix ()
const;
1741 [[nodiscard]] std::string
prefixedName (std::string_view str)
const;
#define AMREX_ALWAYS_ASSERT(EX)
Definition AMReX_BLassert.H:50
Definition AMReX_IParser.H:59
IParserExecutor< N > compileHost() const
This compiles for CPU only.
Definition AMReX_IParser.H:114
Parse Parameters From Command Line and Input Files.
Definition AMReX_ParmParse.H:346
int queryline(std::string_view name, std::string &ref) const
Definition AMReX_ParmParse.cpp:2219
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:2234
int queryarrWithParser(std::string_view name, int nvals, std::vector< T > &ref) const
Definition AMReX_ParmParse.H:1149
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:1066
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:1191
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:1647
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:2519
int query(std::string_view name, std::array< T, N > &ref) const
Definition AMReX_ParmParse.H:1021
static void prettyPrintTable(std::ostream &os)
Definition AMReX_ParmParse.cpp:1394
void get(std::string_view name, T &ref, int ival=FIRST) const
. Get enum value using given name.
Definition AMReX_ParmParse.H:1341
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:1204
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:1386
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:1179
static std::string const FileKeyword
keyword for files to load
Definition AMReX_ParmParse.H:1735
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:1511
static std::string ParserPrefix
Definition AMReX_ParmParse.H:1737
static int Verbose()
Definition AMReX_ParmParse.cpp:1285
static void SetVerbose(int v)
Definition AMReX_ParmParse.cpp:1298
int query(std::string_view name, T &ref, int ival=FIRST) const
. Query enum value using given name.
Definition AMReX_ParmParse.H:1303
void get(const char *new_name, const char *old_name, T &ref)
Get using two names.
Definition AMReX_ParmParse.H:1282
static bool hasUnusedInputs(const std::string &prefix=std::string())
Any unused [prefix.]* parameters?
Definition AMReX_ParmParse.cpp:1236
Parser makeParser(std::string const &func, Vector< std::string > const &vars) const
Definition AMReX_ParmParse.cpp:2437
int queryAdd(std::string_view name, std::string &ref)
Definition AMReX_ParmParse.H:1048
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:1419
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:1526
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:1532
static bool QueryUnusedInputs()
Definition AMReX_ParmParse.cpp:1221
void getline(std::string_view name, std::string &ref) const
Definition AMReX_ParmParse.cpp:2211
T eval(std::string const &expr) const
Definition AMReX_ParmParse.H:1248
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:1517
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:1210
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:1424
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:1592
bool contains(std::string_view name) const
Returns true if name is in table.
Definition AMReX_ParmParse.cpp:2250
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:1561
void get(std::string_view name, std::array< T, N > &ref) const
Definition AMReX_ParmParse.H:1011
static void prettyPrintUsedInputs(std::ostream &os)
Definition AMReX_ParmParse.cpp:1406
static void Finalize()
The destructor. The internal static table will only be deleted if there are no other ParmParse object...
Definition AMReX_ParmParse.cpp:1304
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:1085
std::string m_prefix
Definition AMReX_ParmParse.H:1745
const Table & table() const
Definition AMReX_ParmParse.H:1732
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:1171
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:1441
static void SetParserPrefix(std::string a_prefix)
Set prefix used by math expression Parser.
Definition AMReX_ParmParse.cpp:1331
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:2365
static std::vector< std::string > getUnusedInputs(const std::string &prefix=std::string())
Returns unused [prefix.]* parameters.
Definition AMReX_ParmParse.cpp:1242
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:1040
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:1545
std::string const & getPrefix() const
Definition AMReX_ParmParse.cpp:1159
int remove(std::string_view name)
Remove given name from the table.
Definition AMReX_ParmParse.cpp:2266
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:1536
@ FIRST
Definition AMReX_ParmParse.H:348
@ LAST
Definition AMReX_ParmParse.H:348
@ ALL
Definition AMReX_ParmParse.H:348
void add(std::string_view name, T const &val)
Definition AMReX_ParmParse.H:1326
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:1359
static void Initialize(int argc, char **argv, const std::string &parfile)
Definition AMReX_ParmParse.H:1665
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:1100
int query(const char *new_name, const char *old_name, T &ref)
Definition AMReX_ParmParse.H:1268
Table * m_table
Definition AMReX_ParmParse.H:1747
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:2401
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:1609
std::string m_parser_prefix
Definition AMReX_ParmParse.H:1746
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:1458
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:1449
static void dumpTable(std::ostream &os, bool prettyPrint=false)
Write the contents of the table in ASCII to the ostream.
Definition AMReX_ParmParse.cpp:1337
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:1507
static void prettyPrintUnusedInputs(std::ostream &os)
Definition AMReX_ParmParse.cpp:1400
static std::set< std::string > getEntries(const std::string &prefix=std::string())
Returns [prefix.]* parameters.
Definition AMReX_ParmParse.cpp:1272
std::string prefixedName(std::string_view str) const
Definition AMReX_ParmParse.cpp:1165
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:1229
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:1450
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:1474
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:1433
std::unordered_map< std::string, PP_entry > Table
Definition AMReX_ParmParse.H:1730
IParser makeIParser(std::string const &func, Vector< std::string > const &vars) const
Definition AMReX_ParmParse.cpp:2444
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:1412
Definition AMReX_Parser.H:71
ParserExecutor< N > compileHost() const
This compiles for CPU only.
Definition AMReX_Parser.H:146
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
amrex_long Long
Definition AMReX_INT.H:30
Definition AMReX_Amr.cpp:49
std::ostream & ErrorStream()
Definition AMReX.cpp:931
std::string getEnumNameString(T const &v)
Definition AMReX_Enum.H:156
BoxND< 3 > Box
Box is an alias for amrex::BoxND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:30
__host__ __device__ RealVectND(Real, Real, Args...) -> RealVectND< sizeof...(Args)+2 >
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: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:1709
std::variant< std::string *, bool *, int *, long *, long long *, amrex::IntVect *, amrex::Box *, float *, double * > m_typehint
Definition AMReX_ParmParse.H:1726
std::vector< std::vector< std::string > > m_vals
Definition AMReX_ParmParse.H:1714
Long m_count
Definition AMReX_ParmParse.H:1715
std::vector< std::variant< bool, int, long, long long, float, double > > m_last_vals
Definition AMReX_ParmParse.H:1727
bool m_parsed
Definition AMReX_ParmParse.H:1728