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;
358 explicit ParmParse (std::string prefix = std::string(),
359 std::string parser_prefix = std::string());
362 [[nodiscard]]
bool contains (std::string_view name)
const;
368 [[nodiscard]]
int countval (std::string_view name,
int n =
LAST)
const;
373 [[nodiscard]]
int countname (std::string_view name)
const;
385 void getkth (std::string_view name,
388 int ival =
FIRST)
const;
390 void get (std::string_view name,
392 int ival =
FIRST)
const;
400 int querykth (std::string_view name,
403 int ival =
FIRST)
const;
405 int query (std::string_view name,
407 int ival =
FIRST)
const;
409 void add (std::string_view name,
bool val);
419 void getkth (std::string_view name,
422 int ival =
FIRST)
const;
425 void get (std::string_view name,
427 int ival =
FIRST)
const;
435 int querykth (std::string_view name,
438 int ival =
FIRST)
const;
440 int query (std::string_view name,
442 int ival =
FIRST)
const;
444 void add (std::string_view name,
int val);
454 void getkth (std::string_view name,
457 int ival =
FIRST)
const;
459 void get (std::string_view name,
461 int ival =
FIRST)
const;
469 int querykth (std::string_view name,
472 int ival =
FIRST)
const;
474 int query (std::string_view name,
476 int ival =
FIRST)
const;
478 void add (std::string_view name,
long val);
488 void getkth (std::string_view name,
491 int ival =
FIRST)
const;
493 void get (std::string_view name,
495 int ival =
FIRST)
const;
503 int querykth (std::string_view name,
506 int ival =
FIRST)
const;
508 int query (std::string_view name,
510 int ival =
FIRST)
const;
512 void add (std::string_view name,
long long val);
522 void getkth (std::string_view name,
525 int ival =
FIRST)
const;
527 void get (std::string_view name,
529 int ival =
FIRST)
const;
537 int querykth (std::string_view name,
540 int ival =
FIRST)
const;
542 int query (std::string_view name,
544 int ival =
FIRST)
const;
546 void add (std::string_view name,
float val);
556 void getkth (std::string_view name,
559 int ival =
FIRST)
const;
561 void get (std::string_view name,
563 int ival =
FIRST)
const;
571 int querykth (std::string_view name,
574 int ival =
FIRST)
const;
576 int query (std::string_view name,
578 int ival =
FIRST)
const;
580 void add (std::string_view name,
double val);
590 void getkth (std::string_view name,
593 int ival =
FIRST)
const;
596 void get (std::string_view name,
598 int ival =
FIRST)
const;
606 int querykth (std::string_view name,
609 int ival =
FIRST)
const;
611 int query (std::string_view name,
613 int ival =
FIRST)
const;
615 void add (std::string_view name,
const std::string& val);
618 void add (std::string_view name,
const char* val) {
add(name, std::string(val)); }
628 void getline (std::string_view name, std::string& ref)
const;
638 int queryline (std::string_view name, std::string& ref)
const;
649 void getkth (std::string_view name,
652 int ival =
FIRST)
const;
654 void get (std::string_view name,
656 int ival =
FIRST)
const;
664 int querykth (std::string_view name,
667 int ival =
FIRST)
const;
669 int query (std::string_view name,
671 int ival =
FIRST)
const;
673 void add (std::string_view name,
const IntVect& val);
683 void getkth (std::string_view name,
686 int ival =
FIRST)
const;
688 void get (std::string_view name,
690 int ival =
FIRST)
const;
698 int querykth (std::string_view name,
701 int ival =
FIRST)
const;
703 int query (std::string_view name,
705 int ival =
FIRST)
const;
707 void add (std::string_view name,
const Box& val);
722 std::vector<int>& ref,
723 int start_ix =
FIRST,
724 int num_val =
ALL)
const;
726 void getarr (std::string_view name,
727 std::vector<int>& ref,
728 int start_ix =
FIRST,
729 int num_val =
ALL)
const;
733 std::vector<int>& ref,
734 int start_ix =
FIRST,
735 int num_val =
ALL)
const;
737 int queryarr (std::string_view name,
738 std::vector<int>& ref,
739 int start_ix =
FIRST,
740 int num_val =
ALL)
const;
742 void addarr (std::string_view name,
const std::vector<int>& ref);
758 std::vector<long>& ref,
759 int start_ix =
FIRST,
760 int num_val =
ALL)
const;
762 void getarr (std::string_view name,
763 std::vector<long>& ref,
764 int start_ix =
FIRST,
765 int num_val =
ALL)
const;
769 std::vector<long>& ref,
770 int start_ix =
FIRST,
771 int num_val =
ALL)
const;
773 int queryarr (std::string_view name,
774 std::vector<long>& ref,
775 int start_ix =
FIRST,
776 int num_val =
ALL)
const;
778 void addarr (std::string_view name,
const std::vector<long>& ref);
794 std::vector<long long>& ref,
795 int start_ix =
FIRST,
796 int num_val =
ALL)
const;
798 void getarr (std::string_view name,
799 std::vector<long long>& ref,
800 int start_ix =
FIRST,
801 int num_val =
ALL)
const;
805 std::vector<long long>& ref,
806 int start_ix =
FIRST,
807 int num_val =
ALL)
const;
809 int queryarr (std::string_view name,
810 std::vector<long long>& ref,
811 int start_ix =
FIRST,
812 int num_val =
ALL)
const;
814 void addarr (std::string_view name,
const std::vector<long long>& ref);
830 std::vector<float>& ref,
831 int start_ix =
FIRST,
832 int num_val =
ALL)
const;
834 void getarr (std::string_view name,
835 std::vector<float>& ref,
836 int start_ix =
FIRST,
837 int num_val =
ALL)
const;
841 std::vector<float>& ref,
842 int start_ix =
FIRST,
843 int num_val =
ALL)
const;
845 int queryarr (std::string_view name,
846 std::vector<float>& ref,
847 int start_ix =
FIRST,
848 int num_val =
ALL)
const;
850 void addarr (std::string_view name,
const std::vector<float>& ref);
865 std::vector<double>& ref,
866 int start_ix =
FIRST,
867 int num_val =
ALL)
const;
869 void getarr (std::string_view name,
870 std::vector<double>& ref,
871 int start_ix =
FIRST,
872 int num_val =
ALL)
const;
876 std::vector<double>& ref,
877 int start_ix =
FIRST,
878 int num_val =
ALL)
const;
880 int queryarr (std::string_view name,
881 std::vector<double>& ref,
882 int start_ix =
FIRST,
883 int num_val =
ALL)
const;
885 void addarr (std::string_view name,
const std::vector<double>& ref);
900 std::vector<std::string>& ref,
901 int start_ix =
FIRST,
902 int num_val =
ALL)
const;
904 void getarr (std::string_view name,
905 std::vector<std::string>& ref,
906 int start_ix =
FIRST,
907 int num_val =
ALL)
const;
911 std::vector<std::string>& ref,
912 int start_ix =
FIRST,
913 int num_val =
ALL)
const;
915 int queryarr (std::string_view name,
916 std::vector<std::string>& ref,
917 int start_ix =
FIRST,
918 int num_val =
ALL)
const;
920 void addarr (std::string_view name,
const std::vector<std::string>& ref);
935 std::vector<IntVect>& ref,
936 int start_ix =
FIRST,
937 int num_val =
ALL)
const;
939 void getarr (std::string_view name,
940 std::vector<IntVect>& ref,
941 int start_ix =
FIRST,
942 int num_val =
ALL)
const;
946 std::vector<IntVect>& ref,
947 int start_ix =
FIRST,
948 int num_val =
ALL)
const;
950 int queryarr (std::string_view name,
951 std::vector<IntVect>& ref,
952 int start_ix =
FIRST,
953 int num_val =
ALL)
const;
955 void addarr (std::string_view name,
const std::vector<IntVect>& ref);
970 std::vector<Box>& ref,
971 int start_ix =
FIRST,
972 int num_val =
ALL)
const;
974 void getarr (std::string_view name,
975 std::vector<Box>& ref,
976 int start_ix =
FIRST,
977 int num_val =
ALL)
const;
981 std::vector<Box>& ref,
982 int start_ix =
FIRST,
983 int num_val =
ALL)
const;
985 int queryarr (std::string_view name,
986 std::vector<Box>& ref,
987 int start_ix =
FIRST,
988 int num_val =
ALL)
const;
990 void addarr (std::string_view name,
const std::vector<Box>& ref);
1014 template <
typename T, std::
size_t N>
1015 void get (std::string_view name, std::array<T,N>& ref)
const {
1019 for (std::size_t i = 0; i < N; ++i) {
1024 template <
typename T, std::
size_t N>
1025 int query (std::string_view name, std::array<T,N>& ref)
const {
1027 int exist = this->
queryarr(name, v);
1030 for (std::size_t i = 0; i < N; ++i) {
1043 template <typename T, std::enable_if_t<!IsStdVector<T>::value,
int> = 0>
1045 int exist = this->
query(name, ref);
1047 this->
add(name, ref);
1052 int queryAdd (std::string_view name, std::string& ref) {
1053 int exist = this->
query(name, ref);
1054 if (!exist && !ref.empty()) {
1055 this->
add(name, ref);
1069 template <
typename T>
1070 int queryAdd (std::string_view name, std::vector<T>& ref) {
1071 std::vector<T> empty;
1072 int exist = this->
queryarr(name, empty);
1074 ref = std::move(empty);
1076 if (!exist && !ref.empty()) {
1088 template <
typename T>
1089 int queryAdd (std::string_view name, std::vector<T>& ref,
int num_val) {
1090 int exist = this->
queryarr(name, ref, 0, num_val);
1103 template <
typename T, std::
size_t N>
1104 int queryAdd (std::string_view name, std::array<T,N>& ref) {
1106 int exist = this->
queryarr(name, v);
1109 for (std::size_t i = 0; i < N; ++i) {
1114 for (std::size_t i = 0; i < N; ++i) {
1147 template <
typename T, std::enable_if_t<std::is_same_v<T,
bool> ||
1148 std::is_same_v<T,
int> ||
1149 std::is_same_v<T,
long> ||
1150 std::is_same_v<T,
long long> ||
1151 std::is_same_v<T,
float> ||
1152 std::is_same_v<T,
double>,
int> = 0>
1156 if (
int(ref.size()) < nvals) { ref.resize(nvals); }
1169 template <
typename T, std::enable_if_t<std::is_same_v<T,
bool> ||
1170 std::is_same_v<T,
int> ||
1171 std::is_same_v<T,
long> ||
1172 std::is_same_v<T,
long long> ||
1173 std::is_same_v<T,
float> ||
1174 std::is_same_v<T,
double>,
int> = 0>
1179 this->
add(name, ref);
1189 template <
typename T, std::enable_if_t<std::is_same_v<T,
bool> ||
1190 std::is_same_v<T,
int> ||
1191 std::is_same_v<T,
long> ||
1192 std::is_same_v<T,
long long> ||
1193 std::is_same_v<T,
float> ||
1194 std::is_same_v<T,
double>,
int> = 0>
1199 amrex::Error(std::string(
"ParmParse::getWithParser: failed to get ")+std::string(name));
1208 template <
typename T, std::enable_if_t<std::is_same_v<T,
bool> ||
1209 std::is_same_v<T,
int> ||
1210 std::is_same_v<T,
long> ||
1211 std::is_same_v<T,
long long> ||
1212 std::is_same_v<T,
float> ||
1213 std::is_same_v<T,
double>,
int> = 0>
1218 amrex::Error(std::string(
"ParmParse::getarrWithParser: failed to get ")+std::string(name));
1227 template <
typename T, std::enable_if_t<std::is_same_v<T,
bool> ||
1228 std::is_same_v<T,
int> ||
1229 std::is_same_v<T,
long> ||
1230 std::is_same_v<T,
long long> ||
1231 std::is_same_v<T,
float> ||
1232 std::is_same_v<T,
double>,
int> = 0>
1237 amrex::Error(std::string(
"ParmParse::getarrWithParser: failed to get ")+std::string(name));
1246 template <
typename T, std::enable_if_t<std::is_same_v<T,
bool> ||
1247 std::is_same_v<T,
int> ||
1248 std::is_same_v<T,
long> ||
1249 std::is_same_v<T,
long long> ||
1250 std::is_same_v<T,
float> ||
1251 std::is_same_v<T,
double>,
int> = 0>
1252 T
eval (std::string
const& expr)
const
1254 if constexpr (std::is_integral_v<T>) {
1257 return static_cast<T
>(exe());
1259 auto const parser = this->
makeParser(expr, {});
1261 return static_cast<T
>(exe());
1271 template <
typename T>
1272 int query (
const char* new_name,
const char* old_name, T& ref)
1274 return (this->
query(new_name, ref) ||
1275 this->
query(old_name, ref));
1285 template <
typename T>
1286 void get (
const char* new_name,
const char* old_name, T& ref)
1288 auto exist = this->
query(new_name, old_name, ref);
1291 << new_name <<
" and " << old_name <<
'\n';
1305 template <
typename T,
typename ET = amrex_enum_traits<T>,
1306 std::enable_if_t<ET::value,
int> = 0>
1307 int query (std::string_view name, T& ref,
int ival =
FIRST)
const
1310 int exist = this->
query(name, s, ival);
1313 ref = amrex::getEnum<T>(s);
1316 amrex::Print() <<
"amrex::ParmParse::query (input name: "
1328 template <
typename T,
typename ET = amrex_enum_traits<T>,
1329 std::enable_if_t<ET::value,
int> = 0>
1330 void add (std::string_view name, T
const& val)
1343 template <
typename T,
typename ET = amrex_enum_traits<T>,
1344 std::enable_if_t<ET::value,
int> = 0>
1345 void get (std::string_view name, T& ref,
int ival =
FIRST)
const
1348 this->
get(name, s, ival);
1350 ref = amrex::getEnum<T>(s);
1353 amrex::Print() <<
"amrex::ParmParse::get (input name: "
1361 template <
typename T,
typename ET = amrex_enum_traits<T>,
1362 std::enable_if_t<ET::value,
int> = 0>
1364 std::vector<T>& ref,
1365 int start_ix =
FIRST,
1366 int num_val =
ALL)
const
1368 std::vector<std::string> s;
1369 int exist = this->
queryarr(name, s, start_ix, num_val);
1371 ref.resize(s.size());
1372 for (std::size_t i = 0; i < s.size(); ++i) {
1374 ref[i] = amrex::getEnum<T>(s[i]);
1377 amrex::Print() <<
"amrex::ParmParse::queryarr (input name: "
1388 template <
typename T,
typename ET = amrex_enum_traits<T>,
1389 std::enable_if_t<ET::value,
int> = 0>
1391 std::vector<T>& ref,
1392 int start_ix =
FIRST,
1393 int num_val =
ALL)
const
1395 std::vector<std::string> s;
1396 this->
getarr(name, s, start_ix, num_val);
1397 ref.resize(s.size());
1398 for (std::size_t i = 0; i < s.size(); ++i) {
1400 ref[i] = amrex::getEnum<T>(s[i]);
1403 amrex::Print() <<
"amrex::ParmParse::getarr (input name: "
1421 template <
typename T,
typename ET = amrex_enum_traits<T>,
1422 std::enable_if_t<ET::value,
int> = 0>
1426 int exist = this->
query(name, s, ival);
1429 ref = amrex::getEnumCaseInsensitive<T>(s);
1432 amrex::Print() <<
"amrex::ParmParse::query_enum_case_insensitive (input name: "
1451 template <
typename T,
typename ET = amrex_enum_traits<T>,
1452 std::enable_if_t<ET::value,
int> = 0>
1457 std::string msg(
"get_enum_case_insensitive(\"");
1458 msg.append(name).append(
"\",").append(amrex::getEnumClassName<T>())
1459 .append(
"&) failed.");
1476 template <
typename T,
typename ET = amrex_enum_traits<T>,
1477 std::enable_if_t<ET::value,
int> = 0>
1479 int ival =
FIRST)
const
1482 int exist = this->
query(name, s, ival);
1485 s.erase(std::remove_if(s.begin(), s.end(),
1486 [&] (
auto const& c) {
1487 return ignores.find(c) != std::string_view::npos; }),
1489 ref = amrex::getEnumCaseInsensitive<T>(s);
1492 amrex::Print() <<
"amrex::ParmParse::query_enum_sloppy (input name: "
1513 template <
typename T,
typename ET = amrex_enum_traits<T>,
1514 std::enable_if_t<ET::value,
int> = 0>
1516 int ival =
FIRST)
const
1520 std::string msg(
"get_enum_sloppy(\"");
1521 msg.append(name).append(
"\",").append(amrex::getEnumClassName<T>())
1522 .append(
"&) failed.");
1535 template <
typename T, std::enable_if_t<ppdetail::IsArithmeticOptional_v<T>,
int> = 0>
1538 using value_type = ppdetail::underlying_type_t<T>;
1542 if (std::is_integral_v<value_type>) {
1543 dref = std::round(dref);
1545 auto vref =
static_cast<value_type
>(dref);
1546 if constexpr (std::is_integral_v<value_type> && !std::is_same_v<value_type,bool>) {
1547 if (
static_cast<double>(vref) != dref) {
1564 template <
typename T, std::enable_if_t<ppdetail::IsArithmeticOptional_v<T>,
int> = 0>
1567 using value_type = ppdetail::underlying_type_t<T>;
1568 std::vector<double> dref(nvals);
1571 for (
int i = 0; i < nvals; ++i) {
1572 if (std::is_integral_v<value_type>) {
1573 dref[i] = std::round(dref[i]);
1575 auto vref =
static_cast<value_type
>(dref[i]);
1576 if constexpr (std::is_integral_v<value_type> && !std::is_same_v<value_type,bool>) {
1577 if (
static_cast<double>(vref) != dref[i]) {
1578 amrex::Abort(
"ParmParse:: queryarrAsDouble is not safe");
1595 template <
typename T, std::enable_if_t<ppdetail::IsArithmeticOptional_v<T>,
int> = 0>
1600 amrex::Error(std::string(
"ParmParse::getAsDouble: failed to get ")+std::string(name));
1612 template <
typename T, std::enable_if_t<ppdetail::IsArithmeticOptional_v<T>,
int> = 0>
1617 amrex::Error(std::string(
"ParmParse::getarrAsDouble: failed to get ")+std::string(name));
1622 int remove (std::string_view name);
1641 int querytable (std::string_view name, std::vector<std::vector<double>>& ref)
const;
1642 int querytable (std::string_view name, std::vector<std::vector<float>>& ref)
const;
1643 int querytable (std::string_view name, std::vector<std::vector<int>>& ref)
const;
1650 template <
typename T>
1651 void gettable (std::string_view name, std::vector<std::vector<T>>& ref)
const
1655 <<
" not found in database\n";
1668 static void Initialize (
int argc,
char** argv,
const char* parfile);
1669 static void Initialize (
int argc,
char** argv,
const std::string& parfile) {
1685 static void dumpTable (std::ostream& os,
bool prettyPrint =
false);
1700 static void addfile (std::string
const& filename);
1705 [[nodiscard]]
static bool hasUnusedInputs (
const std::string& prefix = std::string());
1708 [[nodiscard]]
static std::vector<std::string>
getUnusedInputs (
const std::string& prefix = std::string());
1711 [[nodiscard]]
static std::set<std::string>
getEntries (
const std::string& prefix = std::string());
1718 std::vector<std::vector<std::string>>
m_vals;
1720 mutable std::variant<
1731 mutable std::vector<std::variant<bool, int, long, long long, float, double>>
m_last_vals;
1734 using Table = std::unordered_map<std::string, PP_entry>;
1743 [[nodiscard]] std::string
const&
getPrefix ()
const;
1745 [[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:348
int queryline(std::string_view name, std::string &ref) const
Definition AMReX_ParmParse.cpp:2239
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:2254
int queryarrWithParser(std::string_view name, int nvals, std::vector< T > &ref) const
Definition AMReX_ParmParse.H:1153
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:1070
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:1195
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:1651
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:2539
int query(std::string_view name, std::array< T, N > &ref) const
Definition AMReX_ParmParse.H:1025
static void prettyPrintTable(std::ostream &os)
Definition AMReX_ParmParse.cpp:1414
void get(std::string_view name, T &ref, int ival=FIRST) const
. Get enum value using given name.
Definition AMReX_ParmParse.H:1345
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:1224
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:1390
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:1199
static std::string const FileKeyword
keyword for files to load
Definition AMReX_ParmParse.H:1739
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:1515
static std::string ParserPrefix
Definition AMReX_ParmParse.H:1741
static int Verbose()
Definition AMReX_ParmParse.cpp:1305
static void SetVerbose(int v)
Definition AMReX_ParmParse.cpp:1318
int query(std::string_view name, T &ref, int ival=FIRST) const
. Query enum value using given name.
Definition AMReX_ParmParse.H:1307
void get(const char *new_name, const char *old_name, T &ref)
Get using two names.
Definition AMReX_ParmParse.H:1286
static bool hasUnusedInputs(const std::string &prefix=std::string())
Any unused [prefix.]* parameters?
Definition AMReX_ParmParse.cpp:1256
Parser makeParser(std::string const &func, Vector< std::string > const &vars) const
Definition AMReX_ParmParse.cpp:2457
int queryAdd(std::string_view name, std::string &ref)
Definition AMReX_ParmParse.H:1052
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:1423
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:1546
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:1536
static bool QueryUnusedInputs()
Definition AMReX_ParmParse.cpp:1241
void getline(std::string_view name, std::string &ref) const
Definition AMReX_ParmParse.cpp:2231
T eval(std::string const &expr) const
Definition AMReX_ParmParse.H:1252
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:1537
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:1214
void add(std::string_view name, const char *val)
Convert const char * to string, to prevent auto-conversion to bool.
Definition AMReX_ParmParse.H:618
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:1444
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:1596
bool contains(std::string_view name) const
Returns true if name is in table.
Definition AMReX_ParmParse.cpp:2270
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:1565
void get(std::string_view name, std::array< T, N > &ref) const
Definition AMReX_ParmParse.H:1015
static void prettyPrintUsedInputs(std::ostream &os)
Definition AMReX_ParmParse.cpp:1426
static void Finalize()
The destructor. The internal static table will only be deleted if there are no other ParmParse object...
Definition AMReX_ParmParse.cpp:1324
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:1089
std::string m_prefix
Definition AMReX_ParmParse.H:1749
const Table & table() const
Definition AMReX_ParmParse.H:1736
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:1175
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:1461
static void SetParserPrefix(std::string a_prefix)
Set prefix used by math expression Parser.
Definition AMReX_ParmParse.cpp:1351
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:2385
static std::vector< std::string > getUnusedInputs(const std::string &prefix=std::string())
Returns unused [prefix.]* parameters.
Definition AMReX_ParmParse.cpp:1262
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:1044
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:1565
std::string const & getPrefix() const
Definition AMReX_ParmParse.cpp:1179
int remove(std::string_view name)
Remove given name from the table.
Definition AMReX_ParmParse.cpp:2286
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:1556
@ FIRST
Definition AMReX_ParmParse.H:350
@ LAST
Definition AMReX_ParmParse.H:350
@ ALL
Definition AMReX_ParmParse.H:350
void add(std::string_view name, T const &val)
Definition AMReX_ParmParse.H:1330
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:1363
static void Initialize(int argc, char **argv, const std::string &parfile)
Definition AMReX_ParmParse.H:1669
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:1104
int query(const char *new_name, const char *old_name, T &ref)
Definition AMReX_ParmParse.H:1272
Table * m_table
Definition AMReX_ParmParse.H:1751
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:2421
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:1613
std::string m_parser_prefix
Definition AMReX_ParmParse.H:1750
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:1478
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:1453
static void dumpTable(std::ostream &os, bool prettyPrint=false)
Write the contents of the table in ASCII to the ostream.
Definition AMReX_ParmParse.cpp:1357
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:1527
static void prettyPrintUnusedInputs(std::ostream &os)
Definition AMReX_ParmParse.cpp:1420
static std::set< std::string > getEntries(const std::string &prefix=std::string())
Returns [prefix.]* parameters.
Definition AMReX_ParmParse.cpp:1292
std::string prefixedName(std::string_view str) const
Definition AMReX_ParmParse.cpp:1185
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:1233
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:1470
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:1478
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:1453
std::unordered_map< std::string, PP_entry > Table
Definition AMReX_ParmParse.H:1734
IParser makeIParser(std::string const &func, Vector< std::string > const &vars) const
Definition AMReX_ParmParse.cpp:2464
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:1432
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:1713
std::variant< std::string *, bool *, int *, long *, long long *, amrex::IntVect *, amrex::Box *, float *, double * > m_typehint
Definition AMReX_ParmParse.H:1730
std::vector< std::vector< std::string > > m_vals
Definition AMReX_ParmParse.H:1718
Long m_count
Definition AMReX_ParmParse.H:1719
std::vector< std::variant< bool, int, long, long long, float, double > > m_last_vals
Definition AMReX_ParmParse.H:1731
bool m_parsed
Definition AMReX_ParmParse.H:1732