1#ifndef AMREX_PARMPARSE_H_
2#define AMREX_PARMPARSE_H_
3#include <AMReX_Config.H>
25#include <unordered_map>
33using Box = BoxND<AMREX_SPACEDIM>;
36using IntVect = IntVectND<AMREX_SPACEDIM>;
43 template <
class T,
class Enable =
void>
44 struct ArithmeticOptional_TT : std::false_type {};
47 requires (std::is_arithmetic_v<T>)
48 struct ArithmeticOptional_TT<T>
55 requires (std::is_arithmetic_v<T>)
56 struct ArithmeticOptional_TT<std::optional<T>>
63 inline constexpr bool IsArithmeticOptional_v = ArithmeticOptional_TT<T>::value;
66 using underlying_type_t =
typename ArithmeticOptional_TT<T>::value_type;
363 explicit ParmParse (std::string prefix = std::string(),
364 std::string parser_prefix = std::string());
367 [[nodiscard]]
bool contains (std::string_view name)
const;
373 [[nodiscard]]
int countval (std::string_view name,
int n =
LAST)
const;
378 [[nodiscard]]
int countname (std::string_view name)
const;
390 void getkth (std::string_view name,
393 int ival =
FIRST)
const;
395 void get (std::string_view name,
397 int ival =
FIRST)
const;
405 int querykth (std::string_view name,
408 int ival =
FIRST)
const;
410 int query (std::string_view name,
412 int ival =
FIRST)
const;
414 void add (std::string_view name,
bool val);
424 void getkth (std::string_view name,
427 int ival =
FIRST)
const;
430 void get (std::string_view name,
432 int ival =
FIRST)
const;
440 int querykth (std::string_view name,
443 int ival =
FIRST)
const;
445 int query (std::string_view name,
447 int ival =
FIRST)
const;
449 void add (std::string_view name,
int val);
459 void getkth (std::string_view name,
462 int ival =
FIRST)
const;
464 void get (std::string_view name,
466 int ival =
FIRST)
const;
474 int querykth (std::string_view name,
477 int ival =
FIRST)
const;
479 int query (std::string_view name,
481 int ival =
FIRST)
const;
483 void add (std::string_view name,
long val);
493 void getkth (std::string_view name,
496 int ival =
FIRST)
const;
498 void get (std::string_view name,
500 int ival =
FIRST)
const;
508 int querykth (std::string_view name,
511 int ival =
FIRST)
const;
513 int query (std::string_view name,
515 int ival =
FIRST)
const;
517 void add (std::string_view name,
long long val);
527 void getkth (std::string_view name,
530 int ival =
FIRST)
const;
532 void get (std::string_view name,
534 int ival =
FIRST)
const;
542 int querykth (std::string_view name,
545 int ival =
FIRST)
const;
547 int query (std::string_view name,
549 int ival =
FIRST)
const;
551 void add (std::string_view name,
float val);
561 void getkth (std::string_view name,
564 int ival =
FIRST)
const;
566 void get (std::string_view name,
568 int ival =
FIRST)
const;
576 int querykth (std::string_view name,
579 int ival =
FIRST)
const;
581 int query (std::string_view name,
583 int ival =
FIRST)
const;
585 void add (std::string_view name,
double val);
595 void getkth (std::string_view name,
598 int ival =
FIRST)
const;
601 void get (std::string_view name,
603 int ival =
FIRST)
const;
611 int querykth (std::string_view name,
614 int ival =
FIRST)
const;
616 int query (std::string_view name,
618 int ival =
FIRST)
const;
620 void add (std::string_view name,
const std::string& val);
623 void add (std::string_view name,
const char* val) {
add(name, std::string(val)); }
633 void getline (std::string_view name, std::string& ref)
const;
643 int queryline (std::string_view name, std::string& ref)
const;
654 void getkth (std::string_view name,
657 int ival =
FIRST)
const;
659 void get (std::string_view name,
661 int ival =
FIRST)
const;
669 int querykth (std::string_view name,
672 int ival =
FIRST)
const;
674 int query (std::string_view name,
676 int ival =
FIRST)
const;
678 void add (std::string_view name,
const IntVect& val);
688 void getkth (std::string_view name,
691 int ival =
FIRST)
const;
693 void get (std::string_view name,
695 int ival =
FIRST)
const;
703 int querykth (std::string_view name,
706 int ival =
FIRST)
const;
708 int query (std::string_view name,
710 int ival =
FIRST)
const;
712 void add (std::string_view name,
const Box& val);
727 std::vector<int>& ref,
728 int start_ix =
FIRST,
729 int num_val =
ALL)
const;
731 void getarr (std::string_view name,
732 std::vector<int>& ref,
733 int start_ix =
FIRST,
734 int num_val =
ALL)
const;
738 std::vector<int>& ref,
739 int start_ix =
FIRST,
740 int num_val =
ALL)
const;
742 int queryarr (std::string_view name,
743 std::vector<int>& ref,
744 int start_ix =
FIRST,
745 int num_val =
ALL)
const;
747 void addarr (std::string_view name,
const std::vector<int>& ref);
763 std::vector<long>& ref,
764 int start_ix =
FIRST,
765 int num_val =
ALL)
const;
767 void getarr (std::string_view name,
768 std::vector<long>& ref,
769 int start_ix =
FIRST,
770 int num_val =
ALL)
const;
774 std::vector<long>& ref,
775 int start_ix =
FIRST,
776 int num_val =
ALL)
const;
778 int queryarr (std::string_view name,
779 std::vector<long>& ref,
780 int start_ix =
FIRST,
781 int num_val =
ALL)
const;
783 void addarr (std::string_view name,
const std::vector<long>& ref);
799 std::vector<long long>& ref,
800 int start_ix =
FIRST,
801 int num_val =
ALL)
const;
803 void getarr (std::string_view name,
804 std::vector<long long>& ref,
805 int start_ix =
FIRST,
806 int num_val =
ALL)
const;
810 std::vector<long long>& ref,
811 int start_ix =
FIRST,
812 int num_val =
ALL)
const;
814 int queryarr (std::string_view name,
815 std::vector<long long>& ref,
816 int start_ix =
FIRST,
817 int num_val =
ALL)
const;
819 void addarr (std::string_view name,
const std::vector<long long>& ref);
835 std::vector<float>& ref,
836 int start_ix =
FIRST,
837 int num_val =
ALL)
const;
839 void getarr (std::string_view name,
840 std::vector<float>& ref,
841 int start_ix =
FIRST,
842 int num_val =
ALL)
const;
846 std::vector<float>& ref,
847 int start_ix =
FIRST,
848 int num_val =
ALL)
const;
850 int queryarr (std::string_view name,
851 std::vector<float>& ref,
852 int start_ix =
FIRST,
853 int num_val =
ALL)
const;
855 void addarr (std::string_view name,
const std::vector<float>& ref);
870 std::vector<double>& ref,
871 int start_ix =
FIRST,
872 int num_val =
ALL)
const;
874 void getarr (std::string_view name,
875 std::vector<double>& ref,
876 int start_ix =
FIRST,
877 int num_val =
ALL)
const;
881 std::vector<double>& ref,
882 int start_ix =
FIRST,
883 int num_val =
ALL)
const;
885 int queryarr (std::string_view name,
886 std::vector<double>& ref,
887 int start_ix =
FIRST,
888 int num_val =
ALL)
const;
890 void addarr (std::string_view name,
const std::vector<double>& ref);
905 std::vector<std::string>& ref,
906 int start_ix =
FIRST,
907 int num_val =
ALL)
const;
909 void getarr (std::string_view name,
910 std::vector<std::string>& ref,
911 int start_ix =
FIRST,
912 int num_val =
ALL)
const;
916 std::vector<std::string>& ref,
917 int start_ix =
FIRST,
918 int num_val =
ALL)
const;
920 int queryarr (std::string_view name,
921 std::vector<std::string>& ref,
922 int start_ix =
FIRST,
923 int num_val =
ALL)
const;
925 void addarr (std::string_view name,
const std::vector<std::string>& ref);
940 std::vector<IntVect>& ref,
941 int start_ix =
FIRST,
942 int num_val =
ALL)
const;
944 void getarr (std::string_view name,
945 std::vector<IntVect>& ref,
946 int start_ix =
FIRST,
947 int num_val =
ALL)
const;
951 std::vector<IntVect>& ref,
952 int start_ix =
FIRST,
953 int num_val =
ALL)
const;
955 int queryarr (std::string_view name,
956 std::vector<IntVect>& ref,
957 int start_ix =
FIRST,
958 int num_val =
ALL)
const;
960 void addarr (std::string_view name,
const std::vector<IntVect>& ref);
975 std::vector<Box>& ref,
976 int start_ix =
FIRST,
977 int num_val =
ALL)
const;
979 void getarr (std::string_view name,
980 std::vector<Box>& ref,
981 int start_ix =
FIRST,
982 int num_val =
ALL)
const;
986 std::vector<Box>& ref,
987 int start_ix =
FIRST,
988 int num_val =
ALL)
const;
990 int queryarr (std::string_view name,
991 std::vector<Box>& ref,
992 int start_ix =
FIRST,
993 int num_val =
ALL)
const;
995 void addarr (std::string_view name,
const std::vector<Box>& ref);
1019 template <
typename T, std::
size_t N>
1020 void get (std::string_view name, std::array<T,N>& ref)
const {
1024 for (std::size_t i = 0; i < N; ++i) {
1029 template <
typename T, std::
size_t N>
1030 int query (std::string_view name, std::array<T,N>& ref)
const {
1032 int exist = this->
queryarr(name, v);
1035 for (std::size_t i = 0; i < N; ++i) {
1048 template <
typename T>
1050 int exist = this->
query(name, ref);
1052 this->
add(name, ref);
1057 int queryAdd (std::string_view name, std::string& ref) {
1058 int exist = this->
query(name, ref);
1059 if (!exist && !ref.empty()) {
1060 this->
add(name, ref);
1074 template <
typename T>
1075 int queryAdd (std::string_view name, std::vector<T>& ref) {
1076 std::vector<T> empty;
1077 int exist = this->
queryarr(name, empty);
1079 ref = std::move(empty);
1081 if (!exist && !ref.empty()) {
1087 template <
typename T>
1089 return this->
queryAdd(name,
static_cast<std::vector<T>&
>(ref));
1098 template <
typename T>
1099 int queryAdd (std::string_view name, std::vector<T>& ref,
int num_val) {
1100 int exist = this->
queryarr(name, ref, 0, num_val);
1113 template <
typename T, std::
size_t N>
1114 int queryAdd (std::string_view name, std::array<T,N>& ref) {
1116 int exist = this->
queryarr(name, v);
1119 for (std::size_t i = 0; i < N; ++i) {
1124 for (std::size_t i = 0; i < N; ++i) {
1157 template <
typename T>
1158 requires (std::same_as<T,bool> ||
1159 std::same_as<T,int> ||
1160 std::same_as<T,long> ||
1161 std::same_as<T,long long> ||
1162 std::same_as<T,float> ||
1163 std::same_as<T,double>)
1167 if (
int(ref.size()) < nvals) { ref.resize(nvals); }
1180 template <
typename T>
1181 requires (std::same_as<T,bool> ||
1182 std::same_as<T,int> ||
1183 std::same_as<T,long> ||
1184 std::same_as<T,long long> ||
1185 std::same_as<T,float> ||
1186 std::same_as<T,double>)
1191 this->
add(name, ref);
1201 template <
typename T>
1202 requires (std::same_as<T,bool> ||
1203 std::same_as<T,int> ||
1204 std::same_as<T,long> ||
1205 std::same_as<T,long long> ||
1206 std::same_as<T,float> ||
1207 std::same_as<T,double>)
1212 amrex::Error(std::string(
"ParmParse::getWithParser: failed to get ")+std::string(name));
1221 template <
typename T>
1222 requires (std::same_as<T,bool> ||
1223 std::same_as<T,int> ||
1224 std::same_as<T,long> ||
1225 std::same_as<T,long long> ||
1226 std::same_as<T,float> ||
1227 std::same_as<T,double>)
1232 amrex::Error(std::string(
"ParmParse::getarrWithParser: failed to get ")+std::string(name));
1241 template <
typename T>
1242 requires (std::same_as<T,bool> ||
1243 std::same_as<T,int> ||
1244 std::same_as<T,long> ||
1245 std::same_as<T,long long> ||
1246 std::same_as<T,float> ||
1247 std::same_as<T,double>)
1252 amrex::Error(std::string(
"ParmParse::getarrWithParser: failed to get ")+std::string(name));
1261 template <
typename T>
1262 requires (std::same_as<T,bool> ||
1263 std::same_as<T,int> ||
1264 std::same_as<T,long> ||
1265 std::same_as<T,long long> ||
1266 std::same_as<T,float> ||
1267 std::same_as<T,double>)
1268 T
eval (std::string
const& expr)
const
1270 if constexpr (std::is_integral_v<T>) {
1273 return static_cast<T
>(exe());
1275 auto const parser = this->
makeParser(expr, {});
1277 return static_cast<T
>(exe());
1287 template <
typename T>
1288 int query (
const char* new_name,
const char* old_name, T& ref)
1290 return (this->
query(new_name, ref) ||
1291 this->
query(old_name, ref));
1301 template <
typename T>
1302 void get (
const char* new_name,
const char* old_name, T& ref)
1304 auto exist = this->
query(new_name, old_name, ref);
1307 << new_name <<
" and " << old_name <<
'\n';
1321 template <
typename T,
typename ET = amrex_enum_traits<T>>
1322 requires (ET::value)
1323 int query (std::string_view name, T& ref,
int ival =
FIRST)
const
1326 int exist = this->
query(name, s, ival);
1329 ref = amrex::getEnum<T>(s);
1332 amrex::Print() <<
"amrex::ParmParse::query (input name: "
1344 template <
typename T,
typename ET = amrex_enum_traits<T>>
1345 requires (ET::value)
1346 void add (std::string_view name, T
const& val)
1359 template <
typename T,
typename ET = amrex_enum_traits<T>>
1360 requires (ET::value)
1361 void get (std::string_view name, T& ref,
int ival =
FIRST)
const
1364 this->
get(name, s, ival);
1366 ref = amrex::getEnum<T>(s);
1369 amrex::Print() <<
"amrex::ParmParse::get (input name: "
1377 template <
typename T,
typename ET = amrex_enum_traits<T>>
1378 requires (ET::value)
1380 std::vector<T>& ref,
1381 int start_ix =
FIRST,
1382 int num_val =
ALL)
const
1384 std::vector<std::string> s;
1385 int exist = this->
queryarr(name, s, start_ix, num_val);
1387 ref.resize(s.size());
1388 for (std::size_t i = 0; i < s.size(); ++i) {
1390 ref[i] = amrex::getEnum<T>(s[i]);
1393 amrex::Print() <<
"amrex::ParmParse::queryarr (input name: "
1404 template <
typename T,
typename ET = amrex_enum_traits<T>>
1405 requires (ET::value)
1407 std::vector<T>& ref,
1408 int start_ix =
FIRST,
1409 int num_val =
ALL)
const
1411 std::vector<std::string> s;
1412 this->
getarr(name, s, start_ix, num_val);
1413 ref.resize(s.size());
1414 for (std::size_t i = 0; i < s.size(); ++i) {
1416 ref[i] = amrex::getEnum<T>(s[i]);
1419 amrex::Print() <<
"amrex::ParmParse::getarr (input name: "
1437 template <
typename T,
typename ET = amrex_enum_traits<T>>
1438 requires (ET::value)
1442 int exist = this->
query(name, s, ival);
1445 ref = amrex::getEnumCaseInsensitive<T>(s);
1448 amrex::Print() <<
"amrex::ParmParse::query_enum_case_insensitive (input name: "
1467 template <
typename T,
typename ET = amrex_enum_traits<T>>
1468 requires (ET::value)
1473 std::string msg(
"get_enum_case_insensitive(\"");
1474 msg.append(name).append(
"\",").append(amrex::getEnumClassName<T>())
1475 .append(
"&) failed.");
1492 template <
typename T,
typename ET = amrex_enum_traits<T>>
1493 requires (ET::value)
1495 int ival =
FIRST)
const
1498 int exist = this->
query(name, s, ival);
1501 std::erase_if(s, [&] (
auto const& c) {
1502 return ignores.find(c) != std::string_view::npos;
1504 ref = amrex::getEnumCaseInsensitive<T>(s);
1507 amrex::Print() <<
"amrex::ParmParse::query_enum_sloppy (input name: "
1528 template <
typename T,
typename ET = amrex_enum_traits<T>>
1529 requires (ET::value)
1531 int ival =
FIRST)
const
1535 std::string msg(
"get_enum_sloppy(\"");
1536 msg.append(name).append(
"\",").append(amrex::getEnumClassName<T>())
1537 .append(
"&) failed.");
1550 template <
typename T>
1551 requires (ppdetail::IsArithmeticOptional_v<T>)
1554 using value_type = ppdetail::underlying_type_t<T>;
1558 if (std::is_integral_v<value_type>) {
1559 dref = std::round(dref);
1561 if constexpr (std::is_integral_v<value_type> && !std::is_same_v<value_type,bool>) {
1563 if (!(dref >=
static_cast<double>(std::numeric_limits<value_type>::lowest()) &&
1564 dref < std::ldexp(1.0, std::numeric_limits<value_type>::digits))) {
1568 ref =
static_cast<value_type
>(dref);
1581 template <
typename T>
1582 requires (ppdetail::IsArithmeticOptional_v<T>)
1585 using value_type = ppdetail::underlying_type_t<T>;
1586 std::vector<double> dref(nvals);
1589 for (
int i = 0; i < nvals; ++i) {
1590 if (std::is_integral_v<value_type>) {
1591 dref[i] = std::round(dref[i]);
1593 if constexpr (std::is_integral_v<value_type> && !std::is_same_v<value_type,bool>) {
1594 if (!(dref[i] >=
static_cast<double>(std::numeric_limits<value_type>::lowest()) &&
1595 dref[i] < std::ldexp(1.0, std::numeric_limits<value_type>::digits))) {
1596 amrex::Abort(
"ParmParse:: queryarrAsDouble is not safe");
1599 ptr[i] =
static_cast<value_type
>(dref[i]);
1613 template <
typename T>
1614 requires (ppdetail::IsArithmeticOptional_v<T>)
1619 amrex::Error(std::string(
"ParmParse::getAsDouble: failed to get ")+std::string(name));
1631 template <
typename T>
1632 requires (ppdetail::IsArithmeticOptional_v<T>)
1637 amrex::Error(std::string(
"ParmParse::getarrAsDouble: failed to get ")+std::string(name));
1642 int remove (std::string_view name);
1661 int querytable (std::string_view name, std::vector<std::vector<double>>& ref)
const;
1662 int querytable (std::string_view name, std::vector<std::vector<float>>& ref)
const;
1663 int querytable (std::string_view name, std::vector<std::vector<int>>& ref)
const;
1670 template <
typename T>
1671 void gettable (std::string_view name, std::vector<std::vector<T>>& ref)
const
1675 <<
" not found in database\n";
1686 int queryarr (std::string_view name, std::vector<std::vector<double>>& ref)
const;
1687 int queryarr (std::string_view name, std::vector<std::vector<float>>& ref)
const;
1688 int queryarr (std::string_view name, std::vector<std::vector<int>>& ref)
const;
1689 int queryarr (std::string_view name, std::vector<std::vector<std::string>>& ref)
const;
1695 template <
typename T>
1696 void getarr (std::string_view name, std::vector<std::vector<T>>& ref)
const
1698 if (this->
queryarr(name, ref) == 0) {
1700 <<
" not found in database\n";
1713 static void Initialize (
int argc,
char** argv,
const char* parfile);
1714 static void Initialize (
int argc,
char** argv,
const std::string& parfile) {
1732 static void dumpTable (std::ostream& os,
bool prettyPrint =
false);
1750 static void addfile (std::string
const& filename);
1755 [[nodiscard]]
static bool hasUnusedInputs (
const std::string& prefix = std::string());
1758 [[nodiscard]]
static std::vector<std::string>
getUnusedInputs (
const std::string& prefix = std::string());
1761 [[nodiscard]]
static std::set<std::string>
getEntries (
const std::string& prefix = std::string());
1774 std::vector<std::vector<std::string>>
m_vals;
1777 mutable std::variant<
1788 mutable std::vector<std::variant<bool, int, long, long long, float, double>>
m_last_vals;
1791 using Table = std::unordered_map<std::string, PP_entry>;
1803 [[nodiscard]] std::string
const&
getPrefix ()
const;
1805 [[nodiscard]] std::string
prefixedName (std::string_view str)
const;
Assertion macros used across AMReX for runtime consistency checks.
#define AMREX_ALWAYS_ASSERT(EX)
Definition AMReX_BLassert.H:50
Integer-lattice boxes and helpers for defining index-space regions.
Enum reflection utilities and the AMREX_ENUM macro.
Integer-only runtime expression parser and executor helpers.
Runtime expression parser front-end and compiled executor helpers.
Integer-only variant of amrex::Parser.
Definition AMReX_IParser.H:93
IParserExecutor< N > compileHost() const
Compile the expression into a host-only executor.
Definition AMReX_IParser.H:192
Parse Parameters From Command Line and Input Files.
Definition AMReX_ParmParse.H:353
QuoteType
Definition AMReX_ParmParse.H:1763
int queryline(std::string_view name, std::string &ref) const
Definition AMReX_ParmParse.cpp:2745
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:2760
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:1075
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:1049
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:1671
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:3045
int query(std::string_view name, std::array< T, N > &ref) const
Definition AMReX_ParmParse.H:1030
static std::string const UnsetKeyword
keyword for removing entries from the table
Definition AMReX_ParmParse.H:1799
static void prettyPrintTable(std::ostream &os)
Definition AMReX_ParmParse.cpp:1879
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:1677
static void addfile(std::string const &filename)
Definition AMReX_ParmParse.cpp:1647
static std::string const FileKeyword
keyword for files to load
Definition AMReX_ParmParse.H:1796
static std::string ParserPrefix
Definition AMReX_ParmParse.H:1801
static int Verbose()
Definition AMReX_ParmParse.cpp:1758
static void SetVerbose(int v)
Definition AMReX_ParmParse.cpp:1771
void get(const char *new_name, const char *old_name, T &ref)
Get using two names.
Definition AMReX_ParmParse.H:1302
static bool hasUnusedInputs(const std::string &prefix=std::string())
Any unused [prefix.]* parameters?
Definition AMReX_ParmParse.cpp:1709
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:1583
Parser makeParser(std::string const &func, Vector< std::string > const &vars) const
Definition AMReX_ParmParse.cpp:2963
int queryAdd(std::string_view name, std::string &ref)
Definition AMReX_ParmParse.H:1057
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:2052
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:1633
static bool QueryUnusedInputs()
Definition AMReX_ParmParse.cpp:1694
void getline(std::string_view name, std::string &ref) const
Definition AMReX_ParmParse.cpp:2737
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:2043
void add(std::string_view name, const char *val)
Convert const char * to string, to prevent auto-conversion to bool.
Definition AMReX_ParmParse.H:623
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:1950
bool contains(std::string_view name) const
Returns true if name is in table.
Definition AMReX_ParmParse.cpp:2776
void get(std::string_view name, std::array< T, N > &ref) const
Definition AMReX_ParmParse.H:1020
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:1696
static void prettyPrintUsedInputs(std::ostream &os)
Definition AMReX_ParmParse.cpp:1891
static void Finalize()
The destructor. The internal static table will only be deleted if there are no other ParmParse object...
Definition AMReX_ParmParse.cpp:1777
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:1099
std::string m_prefix
Definition AMReX_ParmParse.H:1809
const Table & table() const
Definition AMReX_ParmParse.H:1793
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:1187
T eval(std::string const &expr) const
Definition AMReX_ParmParse.H:1268
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:1967
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:1530
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:1439
static void SetParserPrefix(std::string a_prefix)
Set prefix used by math expression Parser.
Definition AMReX_ParmParse.cpp:1807
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:2891
static std::vector< std::string > getUnusedInputs(const std::string &prefix=std::string())
Returns unused [prefix.]* parameters.
Definition AMReX_ParmParse.cpp:1715
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:2071
std::string const & getPrefix() const
Definition AMReX_ParmParse.cpp:1627
int remove(std::string_view name)
Remove given name from the table.
Definition AMReX_ParmParse.cpp:2792
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:2062
@ FIRST
Definition AMReX_ParmParse.H:355
@ LAST
Definition AMReX_ParmParse.H:355
@ ALL
Definition AMReX_ParmParse.H:355
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:1494
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:1469
static void Initialize(int argc, char **argv, const std::string &parfile)
Definition AMReX_ParmParse.H:1714
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:1114
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:1228
int query(const char *new_name, const char *old_name, T &ref)
Definition AMReX_ParmParse.H:1288
Table * m_table
Definition AMReX_ParmParse.H:1811
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:2927
std::string m_parser_prefix
Definition AMReX_ParmParse.H:1810
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:1984
static void dumpTable(std::ostream &os, bool prettyPrint=false)
Definition AMReX_ParmParse.cpp:1815
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:2033
static void prettyPrintUnusedInputs(std::ostream &os)
Definition AMReX_ParmParse.cpp:1885
static std::set< std::string > getEntries(const std::string &prefix=std::string())
Returns [prefix.]* parameters.
Definition AMReX_ParmParse.cpp:1745
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:1552
std::string prefixedName(std::string_view str) const
Definition AMReX_ParmParse.cpp:1633
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:1615
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:1976
int queryAdd(std::string_view name, Vector< T > &ref)
Definition AMReX_ParmParse.H:1088
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:1959
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:1208
std::unordered_map< std::string, PP_entry > Table
Definition AMReX_ParmParse.H:1791
IParser makeIParser(std::string const &func, Vector< std::string > const &vars) const
Definition AMReX_ParmParse.cpp:2970
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:1897
Front-end for parsing scalar expressions into GPU/CPU executors.
Definition AMReX_Parser.H:126
ParserExecutor< N > compileHost() const
Compile the current expression into a host-only executor.
Definition AMReX_Parser.H:273
This class provides the user with a few print options.
Definition AMReX_Print.H:35
This class is a thin wrapper around std::vector. Unlike vector, Vector::operator[] provides bound che...
Definition AMReX_Vector.H:29
amrex_long Long
Definition AMReX_INT.H:30
std::string getEnumNameString(T const &v)
Get the name string of an enum value.
Definition AMReX_Enum.H:190
Definition AMReX_Amr.cpp:50
std::ostream & ErrorStream()
Stream that receives diagnostic output (defaults to std::cerr).
Definition AMReX.cpp:973
BoxND< 3 > Box
Box is an alias for amrex::BoxND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:35
IntVectND(const Array< int, dim > &) -> IntVectND< dim >
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:38
void Error(const std::string &msg)
Print a message to stderr and abort the program.
Definition AMReX.cpp:236
int Verbose() noexcept
Return the verbosity level configured via ParmParse or SetVerbose().
Definition AMReX.cpp:182
void Abort(const std::string &msg)
Print a fatal-error message to stderr and abort execution.
Definition AMReX.cpp:242
Definition AMReX_ParmParse.H:1769
std::variant< std::string *, bool *, int *, long *, long long *, amrex::IntVect *, amrex::Box *, float *, double * > m_typehint
Definition AMReX_ParmParse.H:1787
std::vector< std::vector< std::string > > m_vals
Definition AMReX_ParmParse.H:1774
std::vector< std::vector< QuoteType > > m_quotes
Definition AMReX_ParmParse.H:1775
Long m_count
Definition AMReX_ParmParse.H:1776
std::vector< std::variant< bool, int, long, long long, float, double > > m_last_vals
Definition AMReX_ParmParse.H:1788
bool m_parsed
Definition AMReX_ParmParse.H:1789