1#ifndef AMREX_PARMPARSE_H_
2#define AMREX_PARMPARSE_H_
3#include <AMReX_Config.H>
22#include <unordered_map>
30using Box = BoxND<AMREX_SPACEDIM>;
33using IntVect = IntVectND<AMREX_SPACEDIM>;
40 template <
class T,
class Enable =
void>
41 struct ArithmeticOptional_TT : std::false_type {};
44 struct ArithmeticOptional_TT<T, std::enable_if_t<std::is_arithmetic_v<T>>>
51 struct ArithmeticOptional_TT<std::optional<T>,
52 std::enable_if_t<std::is_arithmetic_v<T>>>
59 inline constexpr bool IsArithmeticOptional_v = ArithmeticOptional_TT<T>::value;
62 using underlying_type_t =
typename ArithmeticOptional_TT<T>::value_type;
359 explicit ParmParse (std::string prefix = std::string(),
360 std::string parser_prefix = std::string());
363 [[nodiscard]]
bool contains (std::string_view name)
const;
369 [[nodiscard]]
int countval (std::string_view name,
int n =
LAST)
const;
374 [[nodiscard]]
int countname (std::string_view name)
const;
386 void getkth (std::string_view name,
389 int ival =
FIRST)
const;
391 void get (std::string_view name,
393 int ival =
FIRST)
const;
401 int querykth (std::string_view name,
404 int ival =
FIRST)
const;
406 int query (std::string_view name,
408 int ival =
FIRST)
const;
410 void add (std::string_view name,
bool val);
420 void getkth (std::string_view name,
423 int ival =
FIRST)
const;
426 void get (std::string_view name,
428 int ival =
FIRST)
const;
436 int querykth (std::string_view name,
439 int ival =
FIRST)
const;
441 int query (std::string_view name,
443 int ival =
FIRST)
const;
445 void add (std::string_view name,
int val);
455 void getkth (std::string_view name,
458 int ival =
FIRST)
const;
460 void get (std::string_view name,
462 int ival =
FIRST)
const;
470 int querykth (std::string_view name,
473 int ival =
FIRST)
const;
475 int query (std::string_view name,
477 int ival =
FIRST)
const;
479 void add (std::string_view name,
long val);
489 void getkth (std::string_view name,
492 int ival =
FIRST)
const;
494 void get (std::string_view name,
496 int ival =
FIRST)
const;
504 int querykth (std::string_view name,
507 int ival =
FIRST)
const;
509 int query (std::string_view name,
511 int ival =
FIRST)
const;
513 void add (std::string_view name,
long long val);
523 void getkth (std::string_view name,
526 int ival =
FIRST)
const;
528 void get (std::string_view name,
530 int ival =
FIRST)
const;
538 int querykth (std::string_view name,
541 int ival =
FIRST)
const;
543 int query (std::string_view name,
545 int ival =
FIRST)
const;
547 void add (std::string_view name,
float val);
557 void getkth (std::string_view name,
560 int ival =
FIRST)
const;
562 void get (std::string_view name,
564 int ival =
FIRST)
const;
572 int querykth (std::string_view name,
575 int ival =
FIRST)
const;
577 int query (std::string_view name,
579 int ival =
FIRST)
const;
581 void add (std::string_view name,
double val);
591 void getkth (std::string_view name,
594 int ival =
FIRST)
const;
597 void get (std::string_view name,
599 int ival =
FIRST)
const;
607 int querykth (std::string_view name,
610 int ival =
FIRST)
const;
612 int query (std::string_view name,
614 int ival =
FIRST)
const;
616 void add (std::string_view name,
const std::string& val);
619 void add (std::string_view name,
const char* val) {
add(name, std::string(val)); }
629 void getline (std::string_view name, std::string& ref)
const;
639 int queryline (std::string_view name, std::string& ref)
const;
650 void getkth (std::string_view name,
653 int ival =
FIRST)
const;
655 void get (std::string_view name,
657 int ival =
FIRST)
const;
665 int querykth (std::string_view name,
668 int ival =
FIRST)
const;
670 int query (std::string_view name,
672 int ival =
FIRST)
const;
674 void add (std::string_view name,
const IntVect& val);
684 void getkth (std::string_view name,
687 int ival =
FIRST)
const;
689 void get (std::string_view name,
691 int ival =
FIRST)
const;
699 int querykth (std::string_view name,
702 int ival =
FIRST)
const;
704 int query (std::string_view name,
706 int ival =
FIRST)
const;
708 void add (std::string_view name,
const Box& val);
723 std::vector<int>& ref,
724 int start_ix =
FIRST,
725 int num_val =
ALL)
const;
727 void getarr (std::string_view name,
728 std::vector<int>& ref,
729 int start_ix =
FIRST,
730 int num_val =
ALL)
const;
734 std::vector<int>& ref,
735 int start_ix =
FIRST,
736 int num_val =
ALL)
const;
738 int queryarr (std::string_view name,
739 std::vector<int>& ref,
740 int start_ix =
FIRST,
741 int num_val =
ALL)
const;
743 void addarr (std::string_view name,
const std::vector<int>& ref);
759 std::vector<long>& ref,
760 int start_ix =
FIRST,
761 int num_val =
ALL)
const;
763 void getarr (std::string_view name,
764 std::vector<long>& ref,
765 int start_ix =
FIRST,
766 int num_val =
ALL)
const;
770 std::vector<long>& ref,
771 int start_ix =
FIRST,
772 int num_val =
ALL)
const;
774 int queryarr (std::string_view name,
775 std::vector<long>& ref,
776 int start_ix =
FIRST,
777 int num_val =
ALL)
const;
779 void addarr (std::string_view name,
const std::vector<long>& ref);
795 std::vector<long long>& ref,
796 int start_ix =
FIRST,
797 int num_val =
ALL)
const;
799 void getarr (std::string_view name,
800 std::vector<long long>& ref,
801 int start_ix =
FIRST,
802 int num_val =
ALL)
const;
806 std::vector<long long>& ref,
807 int start_ix =
FIRST,
808 int num_val =
ALL)
const;
810 int queryarr (std::string_view name,
811 std::vector<long long>& ref,
812 int start_ix =
FIRST,
813 int num_val =
ALL)
const;
815 void addarr (std::string_view name,
const std::vector<long long>& ref);
831 std::vector<float>& ref,
832 int start_ix =
FIRST,
833 int num_val =
ALL)
const;
835 void getarr (std::string_view name,
836 std::vector<float>& ref,
837 int start_ix =
FIRST,
838 int num_val =
ALL)
const;
842 std::vector<float>& ref,
843 int start_ix =
FIRST,
844 int num_val =
ALL)
const;
846 int queryarr (std::string_view name,
847 std::vector<float>& ref,
848 int start_ix =
FIRST,
849 int num_val =
ALL)
const;
851 void addarr (std::string_view name,
const std::vector<float>& ref);
866 std::vector<double>& ref,
867 int start_ix =
FIRST,
868 int num_val =
ALL)
const;
870 void getarr (std::string_view name,
871 std::vector<double>& ref,
872 int start_ix =
FIRST,
873 int num_val =
ALL)
const;
877 std::vector<double>& ref,
878 int start_ix =
FIRST,
879 int num_val =
ALL)
const;
881 int queryarr (std::string_view name,
882 std::vector<double>& ref,
883 int start_ix =
FIRST,
884 int num_val =
ALL)
const;
886 void addarr (std::string_view name,
const std::vector<double>& ref);
901 std::vector<std::string>& ref,
902 int start_ix =
FIRST,
903 int num_val =
ALL)
const;
905 void getarr (std::string_view name,
906 std::vector<std::string>& ref,
907 int start_ix =
FIRST,
908 int num_val =
ALL)
const;
912 std::vector<std::string>& ref,
913 int start_ix =
FIRST,
914 int num_val =
ALL)
const;
916 int queryarr (std::string_view name,
917 std::vector<std::string>& ref,
918 int start_ix =
FIRST,
919 int num_val =
ALL)
const;
921 void addarr (std::string_view name,
const std::vector<std::string>& ref);
936 std::vector<IntVect>& ref,
937 int start_ix =
FIRST,
938 int num_val =
ALL)
const;
940 void getarr (std::string_view name,
941 std::vector<IntVect>& ref,
942 int start_ix =
FIRST,
943 int num_val =
ALL)
const;
947 std::vector<IntVect>& ref,
948 int start_ix =
FIRST,
949 int num_val =
ALL)
const;
951 int queryarr (std::string_view name,
952 std::vector<IntVect>& ref,
953 int start_ix =
FIRST,
954 int num_val =
ALL)
const;
956 void addarr (std::string_view name,
const std::vector<IntVect>& ref);
971 std::vector<Box>& ref,
972 int start_ix =
FIRST,
973 int num_val =
ALL)
const;
975 void getarr (std::string_view name,
976 std::vector<Box>& ref,
977 int start_ix =
FIRST,
978 int num_val =
ALL)
const;
982 std::vector<Box>& ref,
983 int start_ix =
FIRST,
984 int num_val =
ALL)
const;
986 int queryarr (std::string_view name,
987 std::vector<Box>& ref,
988 int start_ix =
FIRST,
989 int num_val =
ALL)
const;
991 void addarr (std::string_view name,
const std::vector<Box>& ref);
1015 template <
typename T, std::
size_t N>
1016 void get (std::string_view name, std::array<T,N>& ref)
const {
1020 for (std::size_t i = 0; i < N; ++i) {
1025 template <
typename T, std::
size_t N>
1026 int query (std::string_view name, std::array<T,N>& ref)
const {
1028 int exist = this->
queryarr(name, v);
1031 for (std::size_t i = 0; i < N; ++i) {
1044 template <
typename T>
1046 int exist = this->
query(name, ref);
1048 this->
add(name, ref);
1053 int queryAdd (std::string_view name, std::string& ref) {
1054 int exist = this->
query(name, ref);
1055 if (!exist && !ref.empty()) {
1056 this->
add(name, ref);
1070 template <
typename T>
1071 int queryAdd (std::string_view name, std::vector<T>& ref) {
1072 std::vector<T> empty;
1073 int exist = this->
queryarr(name, empty);
1075 ref = std::move(empty);
1077 if (!exist && !ref.empty()) {
1083 template <
typename T>
1085 return this->
queryAdd(name,
static_cast<std::vector<T>&
>(ref));
1094 template <
typename T>
1095 int queryAdd (std::string_view name, std::vector<T>& ref,
int num_val) {
1096 int exist = this->
queryarr(name, ref, 0, num_val);
1109 template <
typename T, std::
size_t N>
1110 int queryAdd (std::string_view name, std::array<T,N>& ref) {
1112 int exist = this->
queryarr(name, v);
1115 for (std::size_t i = 0; i < N; ++i) {
1120 for (std::size_t i = 0; i < N; ++i) {
1153 template <
typename T, std::enable_if_t<std::is_same_v<T,
bool> ||
1154 std::is_same_v<T,
int> ||
1155 std::is_same_v<T,
long> ||
1156 std::is_same_v<T,
long long> ||
1157 std::is_same_v<T,
float> ||
1158 std::is_same_v<T,
double>,
int> = 0>
1162 if (
int(ref.size()) < nvals) { ref.resize(nvals); }
1175 template <
typename T, std::enable_if_t<std::is_same_v<T,
bool> ||
1176 std::is_same_v<T,
int> ||
1177 std::is_same_v<T,
long> ||
1178 std::is_same_v<T,
long long> ||
1179 std::is_same_v<T,
float> ||
1180 std::is_same_v<T,
double>,
int> = 0>
1185 this->
add(name, ref);
1195 template <
typename T, std::enable_if_t<std::is_same_v<T,
bool> ||
1196 std::is_same_v<T,
int> ||
1197 std::is_same_v<T,
long> ||
1198 std::is_same_v<T,
long long> ||
1199 std::is_same_v<T,
float> ||
1200 std::is_same_v<T,
double>,
int> = 0>
1205 amrex::Error(std::string(
"ParmParse::getWithParser: failed to get ")+std::string(name));
1214 template <
typename T, std::enable_if_t<std::is_same_v<T,
bool> ||
1215 std::is_same_v<T,
int> ||
1216 std::is_same_v<T,
long> ||
1217 std::is_same_v<T,
long long> ||
1218 std::is_same_v<T,
float> ||
1219 std::is_same_v<T,
double>,
int> = 0>
1224 amrex::Error(std::string(
"ParmParse::getarrWithParser: failed to get ")+std::string(name));
1233 template <
typename T, std::enable_if_t<std::is_same_v<T,
bool> ||
1234 std::is_same_v<T,
int> ||
1235 std::is_same_v<T,
long> ||
1236 std::is_same_v<T,
long long> ||
1237 std::is_same_v<T,
float> ||
1238 std::is_same_v<T,
double>,
int> = 0>
1243 amrex::Error(std::string(
"ParmParse::getarrWithParser: failed to get ")+std::string(name));
1252 template <
typename T, std::enable_if_t<std::is_same_v<T,
bool> ||
1253 std::is_same_v<T,
int> ||
1254 std::is_same_v<T,
long> ||
1255 std::is_same_v<T,
long long> ||
1256 std::is_same_v<T,
float> ||
1257 std::is_same_v<T,
double>,
int> = 0>
1258 T
eval (std::string
const& expr)
const
1260 if constexpr (std::is_integral_v<T>) {
1263 return static_cast<T
>(exe());
1265 auto const parser = this->
makeParser(expr, {});
1267 return static_cast<T
>(exe());
1277 template <
typename T>
1278 int query (
const char* new_name,
const char* old_name, T& ref)
1280 return (this->
query(new_name, ref) ||
1281 this->
query(old_name, ref));
1291 template <
typename T>
1292 void get (
const char* new_name,
const char* old_name, T& ref)
1294 auto exist = this->
query(new_name, old_name, ref);
1297 << new_name <<
" and " << old_name <<
'\n';
1311 template <
typename T,
typename ET = amrex_enum_traits<T>,
1312 std::enable_if_t<ET::value,
int> = 0>
1313 int query (std::string_view name, T& ref,
int ival =
FIRST)
const
1316 int exist = this->
query(name, s, ival);
1319 ref = amrex::getEnum<T>(s);
1322 amrex::Print() <<
"amrex::ParmParse::query (input name: "
1334 template <
typename T,
typename ET = amrex_enum_traits<T>,
1335 std::enable_if_t<ET::value,
int> = 0>
1336 void add (std::string_view name, T
const& val)
1349 template <
typename T,
typename ET = amrex_enum_traits<T>,
1350 std::enable_if_t<ET::value,
int> = 0>
1351 void get (std::string_view name, T& ref,
int ival =
FIRST)
const
1354 this->
get(name, s, ival);
1356 ref = amrex::getEnum<T>(s);
1359 amrex::Print() <<
"amrex::ParmParse::get (input name: "
1367 template <
typename T,
typename ET = amrex_enum_traits<T>,
1368 std::enable_if_t<ET::value,
int> = 0>
1370 std::vector<T>& ref,
1371 int start_ix =
FIRST,
1372 int num_val =
ALL)
const
1374 std::vector<std::string> s;
1375 int exist = this->
queryarr(name, s, start_ix, num_val);
1377 ref.resize(s.size());
1378 for (std::size_t i = 0; i < s.size(); ++i) {
1380 ref[i] = amrex::getEnum<T>(s[i]);
1383 amrex::Print() <<
"amrex::ParmParse::queryarr (input name: "
1394 template <
typename T,
typename ET = amrex_enum_traits<T>,
1395 std::enable_if_t<ET::value,
int> = 0>
1397 std::vector<T>& ref,
1398 int start_ix =
FIRST,
1399 int num_val =
ALL)
const
1401 std::vector<std::string> s;
1402 this->
getarr(name, s, start_ix, num_val);
1403 ref.resize(s.size());
1404 for (std::size_t i = 0; i < s.size(); ++i) {
1406 ref[i] = amrex::getEnum<T>(s[i]);
1409 amrex::Print() <<
"amrex::ParmParse::getarr (input name: "
1427 template <
typename T,
typename ET = amrex_enum_traits<T>,
1428 std::enable_if_t<ET::value,
int> = 0>
1432 int exist = this->
query(name, s, ival);
1435 ref = amrex::getEnumCaseInsensitive<T>(s);
1438 amrex::Print() <<
"amrex::ParmParse::query_enum_case_insensitive (input name: "
1457 template <
typename T,
typename ET = amrex_enum_traits<T>,
1458 std::enable_if_t<ET::value,
int> = 0>
1463 std::string msg(
"get_enum_case_insensitive(\"");
1464 msg.append(name).append(
"\",").append(amrex::getEnumClassName<T>())
1465 .append(
"&) failed.");
1482 template <
typename T,
typename ET = amrex_enum_traits<T>,
1483 std::enable_if_t<ET::value,
int> = 0>
1485 int ival =
FIRST)
const
1488 int exist = this->
query(name, s, ival);
1491 s.erase(std::remove_if(s.begin(), s.end(),
1492 [&] (
auto const& c) {
1493 return ignores.find(c) != std::string_view::npos; }),
1495 ref = amrex::getEnumCaseInsensitive<T>(s);
1498 amrex::Print() <<
"amrex::ParmParse::query_enum_sloppy (input name: "
1519 template <
typename T,
typename ET = amrex_enum_traits<T>,
1520 std::enable_if_t<ET::value,
int> = 0>
1522 int ival =
FIRST)
const
1526 std::string msg(
"get_enum_sloppy(\"");
1527 msg.append(name).append(
"\",").append(amrex::getEnumClassName<T>())
1528 .append(
"&) failed.");
1541 template <
typename T, std::enable_if_t<ppdetail::IsArithmeticOptional_v<T>,
int> = 0>
1544 using value_type = ppdetail::underlying_type_t<T>;
1548 if (std::is_integral_v<value_type>) {
1549 dref = std::round(dref);
1551 auto vref =
static_cast<value_type
>(dref);
1552 if constexpr (std::is_integral_v<value_type> && !std::is_same_v<value_type,bool>) {
1553 if (
static_cast<double>(vref) != dref) {
1570 template <
typename T, std::enable_if_t<ppdetail::IsArithmeticOptional_v<T>,
int> = 0>
1573 using value_type = ppdetail::underlying_type_t<T>;
1574 std::vector<double> dref(nvals);
1577 for (
int i = 0; i < nvals; ++i) {
1578 if (std::is_integral_v<value_type>) {
1579 dref[i] = std::round(dref[i]);
1581 auto vref =
static_cast<value_type
>(dref[i]);
1582 if constexpr (std::is_integral_v<value_type> && !std::is_same_v<value_type,bool>) {
1583 if (
static_cast<double>(vref) != dref[i]) {
1584 amrex::Abort(
"ParmParse:: queryarrAsDouble is not safe");
1601 template <
typename T, std::enable_if_t<ppdetail::IsArithmeticOptional_v<T>,
int> = 0>
1606 amrex::Error(std::string(
"ParmParse::getAsDouble: failed to get ")+std::string(name));
1618 template <
typename T, std::enable_if_t<ppdetail::IsArithmeticOptional_v<T>,
int> = 0>
1623 amrex::Error(std::string(
"ParmParse::getarrAsDouble: failed to get ")+std::string(name));
1628 int remove (std::string_view name);
1647 int querytable (std::string_view name, std::vector<std::vector<double>>& ref)
const;
1648 int querytable (std::string_view name, std::vector<std::vector<float>>& ref)
const;
1649 int querytable (std::string_view name, std::vector<std::vector<int>>& ref)
const;
1656 template <
typename T>
1657 void gettable (std::string_view name, std::vector<std::vector<T>>& ref)
const
1661 <<
" not found in database\n";
1672 int queryarr (std::string_view name, std::vector<std::vector<double>>& ref)
const;
1673 int queryarr (std::string_view name, std::vector<std::vector<float>>& ref)
const;
1674 int queryarr (std::string_view name, std::vector<std::vector<int>>& ref)
const;
1675 int queryarr (std::string_view name, std::vector<std::vector<std::string>>& ref)
const;
1681 template <
typename T>
1682 void getarr (std::string_view name, std::vector<std::vector<T>>& ref)
const
1684 if (this->
queryarr(name, ref) == 0) {
1686 <<
" not found in database\n";
1699 static void Initialize (
int argc,
char** argv,
const char* parfile);
1700 static void Initialize (
int argc,
char** argv,
const std::string& parfile) {
1718 static void dumpTable (std::ostream& os,
bool prettyPrint =
false);
1736 static void addfile (std::string
const& filename);
1741 [[nodiscard]]
static bool hasUnusedInputs (
const std::string& prefix = std::string());
1744 [[nodiscard]]
static std::vector<std::string>
getUnusedInputs (
const std::string& prefix = std::string());
1747 [[nodiscard]]
static std::set<std::string>
getEntries (
const std::string& prefix = std::string());
1760 std::vector<std::vector<std::string>>
m_vals;
1763 mutable std::variant<
1774 mutable std::vector<std::variant<bool, int, long, long long, float, double>>
m_last_vals;
1777 using Table = std::unordered_map<std::string, PP_entry>;
1789 [[nodiscard]] std::string
const&
getPrefix ()
const;
1791 [[nodiscard]] std::string
prefixedName (std::string_view str)
const;
#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:91
IParserExecutor< N > compileHost() const
Compile the expression into a host-only executor.
Definition AMReX_IParser.H:189
Parse Parameters From Command Line and Input Files.
Definition AMReX_ParmParse.H:349
QuoteType
Definition AMReX_ParmParse.H:1749
int queryline(std::string_view name, std::string &ref) const
Definition AMReX_ParmParse.cpp:2715
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:2730
int queryarrWithParser(std::string_view name, int nvals, std::vector< T > &ref) const
Definition AMReX_ParmParse.H:1159
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:1071
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:1045
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:1201
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:1657
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:3015
int query(std::string_view name, std::array< T, N > &ref) const
Definition AMReX_ParmParse.H:1026
static std::string const UnsetKeyword
keyword for removing entries from the table
Definition AMReX_ParmParse.H:1785
static void prettyPrintTable(std::ostream &os)
Definition AMReX_ParmParse.cpp:1849
void get(std::string_view name, T &ref, int ival=FIRST) const
. Get enum value using given name.
Definition AMReX_ParmParse.H:1351
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:1650
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:1396
static void addfile(std::string const &filename)
Definition AMReX_ParmParse.cpp:1620
static std::string const FileKeyword
keyword for files to load
Definition AMReX_ParmParse.H:1782
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:1521
static std::string ParserPrefix
Definition AMReX_ParmParse.H:1787
static int Verbose()
Definition AMReX_ParmParse.cpp:1731
static void SetVerbose(int v)
Definition AMReX_ParmParse.cpp:1744
int query(std::string_view name, T &ref, int ival=FIRST) const
. Query enum value using given name.
Definition AMReX_ParmParse.H:1313
void get(const char *new_name, const char *old_name, T &ref)
Get using two names.
Definition AMReX_ParmParse.H:1292
static bool hasUnusedInputs(const std::string &prefix=std::string())
Any unused [prefix.]* parameters?
Definition AMReX_ParmParse.cpp:1682
Parser makeParser(std::string const &func, Vector< std::string > const &vars) const
Definition AMReX_ParmParse.cpp:2933
int queryAdd(std::string_view name, std::string &ref)
Definition AMReX_ParmParse.H:1053
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:1429
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:2022
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:1542
static bool QueryUnusedInputs()
Definition AMReX_ParmParse.cpp:1667
void getline(std::string_view name, std::string &ref) const
Definition AMReX_ParmParse.cpp:2707
T eval(std::string const &expr) const
Definition AMReX_ParmParse.H:1258
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:2013
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:1220
void add(std::string_view name, const char *val)
Convert const char * to string, to prevent auto-conversion to bool.
Definition AMReX_ParmParse.H:619
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:1920
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:1602
bool contains(std::string_view name) const
Returns true if name is in table.
Definition AMReX_ParmParse.cpp:2746
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:1571
void get(std::string_view name, std::array< T, N > &ref) const
Definition AMReX_ParmParse.H:1016
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:1682
static void prettyPrintUsedInputs(std::ostream &os)
Definition AMReX_ParmParse.cpp:1861
static void Finalize()
The destructor. The internal static table will only be deleted if there are no other ParmParse object...
Definition AMReX_ParmParse.cpp:1750
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:1095
std::string m_prefix
Definition AMReX_ParmParse.H:1795
const Table & table() const
Definition AMReX_ParmParse.H:1779
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:1181
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:1937
static void SetParserPrefix(std::string a_prefix)
Set prefix used by math expression Parser.
Definition AMReX_ParmParse.cpp:1777
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:2861
static std::vector< std::string > getUnusedInputs(const std::string &prefix=std::string())
Returns unused [prefix.]* parameters.
Definition AMReX_ParmParse.cpp:1688
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:2041
std::string const & getPrefix() const
Definition AMReX_ParmParse.cpp:1600
int remove(std::string_view name)
Remove given name from the table.
Definition AMReX_ParmParse.cpp:2762
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:2032
@ FIRST
Definition AMReX_ParmParse.H:351
@ LAST
Definition AMReX_ParmParse.H:351
@ ALL
Definition AMReX_ParmParse.H:351
void add(std::string_view name, T const &val)
Definition AMReX_ParmParse.H:1336
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:1369
static void Initialize(int argc, char **argv, const std::string &parfile)
Definition AMReX_ParmParse.H:1700
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:1110
int query(const char *new_name, const char *old_name, T &ref)
Definition AMReX_ParmParse.H:1278
Table * m_table
Definition AMReX_ParmParse.H:1797
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:2897
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:1619
std::string m_parser_prefix
Definition AMReX_ParmParse.H:1796
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:1954
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:1459
static void dumpTable(std::ostream &os, bool prettyPrint=false)
Definition AMReX_ParmParse.cpp:1785
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:2003
static void prettyPrintUnusedInputs(std::ostream &os)
Definition AMReX_ParmParse.cpp:1855
static std::set< std::string > getEntries(const std::string &prefix=std::string())
Returns [prefix.]* parameters.
Definition AMReX_ParmParse.cpp:1718
std::string prefixedName(std::string_view str) const
Definition AMReX_ParmParse.cpp:1606
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:1239
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:1946
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:1484
int queryAdd(std::string_view name, Vector< T > &ref)
Definition AMReX_ParmParse.H:1084
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:1929
std::unordered_map< std::string, PP_entry > Table
Definition AMReX_ParmParse.H:1777
IParser makeIParser(std::string const &func, Vector< std::string > const &vars) const
Definition AMReX_ParmParse.cpp:2940
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:1867
Front-end for parsing scalar expressions into GPU/CPU executors.
Definition AMReX_Parser.H:122
ParserExecutor< N > compileHost() const
Compile the current expression into a host-only executor.
Definition AMReX_Parser.H:268
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:962
std::string getEnumNameString(T const &v)
Definition AMReX_Enum.H:157
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:234
__host__ __device__ IntVectND(const Array< int, dim > &) -> IntVectND< dim >
int Verbose() noexcept
Definition AMReX.cpp:179
void Abort(const std::string &msg)
Print out message to cerr and exit via abort().
Definition AMReX.cpp:240
Definition AMReX_ParmParse.H:1755
std::variant< std::string *, bool *, int *, long *, long long *, amrex::IntVect *, amrex::Box *, float *, double * > m_typehint
Definition AMReX_ParmParse.H:1773
std::vector< std::vector< std::string > > m_vals
Definition AMReX_ParmParse.H:1760
std::vector< std::vector< QuoteType > > m_quotes
Definition AMReX_ParmParse.H:1761
Long m_count
Definition AMReX_ParmParse.H:1762
std::vector< std::variant< bool, int, long, long long, float, double > > m_last_vals
Definition AMReX_ParmParse.H:1774
bool m_parsed
Definition AMReX_ParmParse.H:1775