1#ifndef AMREX_PARMPARSE_H_
2#define AMREX_PARMPARSE_H_
3#include <AMReX_Config.H>
23#include <unordered_map>
31using Box = BoxND<AMREX_SPACEDIM>;
34using IntVect = IntVectND<AMREX_SPACEDIM>;
41 template <
class T,
class Enable =
void>
42 struct ArithmeticOptional_TT : std::false_type {};
45 requires (std::is_arithmetic_v<T>)
46 struct ArithmeticOptional_TT<T>
53 requires (std::is_arithmetic_v<T>)
54 struct ArithmeticOptional_TT<std::optional<T>>
61 inline constexpr bool IsArithmeticOptional_v = ArithmeticOptional_TT<T>::value;
64 using underlying_type_t =
typename ArithmeticOptional_TT<T>::value_type;
361 explicit ParmParse (std::string prefix = std::string(),
362 std::string parser_prefix = std::string());
365 [[nodiscard]]
bool contains (std::string_view name)
const;
371 [[nodiscard]]
int countval (std::string_view name,
int n =
LAST)
const;
376 [[nodiscard]]
int countname (std::string_view name)
const;
388 void getkth (std::string_view name,
391 int ival =
FIRST)
const;
393 void get (std::string_view name,
395 int ival =
FIRST)
const;
403 int querykth (std::string_view name,
406 int ival =
FIRST)
const;
408 int query (std::string_view name,
410 int ival =
FIRST)
const;
412 void add (std::string_view name,
bool val);
422 void getkth (std::string_view name,
425 int ival =
FIRST)
const;
428 void get (std::string_view name,
430 int ival =
FIRST)
const;
438 int querykth (std::string_view name,
441 int ival =
FIRST)
const;
443 int query (std::string_view name,
445 int ival =
FIRST)
const;
447 void add (std::string_view name,
int val);
457 void getkth (std::string_view name,
460 int ival =
FIRST)
const;
462 void get (std::string_view name,
464 int ival =
FIRST)
const;
472 int querykth (std::string_view name,
475 int ival =
FIRST)
const;
477 int query (std::string_view name,
479 int ival =
FIRST)
const;
481 void add (std::string_view name,
long val);
491 void getkth (std::string_view name,
494 int ival =
FIRST)
const;
496 void get (std::string_view name,
498 int ival =
FIRST)
const;
506 int querykth (std::string_view name,
509 int ival =
FIRST)
const;
511 int query (std::string_view name,
513 int ival =
FIRST)
const;
515 void add (std::string_view name,
long long val);
525 void getkth (std::string_view name,
528 int ival =
FIRST)
const;
530 void get (std::string_view name,
532 int ival =
FIRST)
const;
540 int querykth (std::string_view name,
543 int ival =
FIRST)
const;
545 int query (std::string_view name,
547 int ival =
FIRST)
const;
549 void add (std::string_view name,
float val);
559 void getkth (std::string_view name,
562 int ival =
FIRST)
const;
564 void get (std::string_view name,
566 int ival =
FIRST)
const;
574 int querykth (std::string_view name,
577 int ival =
FIRST)
const;
579 int query (std::string_view name,
581 int ival =
FIRST)
const;
583 void add (std::string_view name,
double val);
593 void getkth (std::string_view name,
596 int ival =
FIRST)
const;
599 void get (std::string_view name,
601 int ival =
FIRST)
const;
609 int querykth (std::string_view name,
612 int ival =
FIRST)
const;
614 int query (std::string_view name,
616 int ival =
FIRST)
const;
618 void add (std::string_view name,
const std::string& val);
621 void add (std::string_view name,
const char* val) {
add(name, std::string(val)); }
631 void getline (std::string_view name, std::string& ref)
const;
641 int queryline (std::string_view name, std::string& ref)
const;
652 void getkth (std::string_view name,
655 int ival =
FIRST)
const;
657 void get (std::string_view name,
659 int ival =
FIRST)
const;
667 int querykth (std::string_view name,
670 int ival =
FIRST)
const;
672 int query (std::string_view name,
674 int ival =
FIRST)
const;
676 void add (std::string_view name,
const IntVect& val);
686 void getkth (std::string_view name,
689 int ival =
FIRST)
const;
691 void get (std::string_view name,
693 int ival =
FIRST)
const;
701 int querykth (std::string_view name,
704 int ival =
FIRST)
const;
706 int query (std::string_view name,
708 int ival =
FIRST)
const;
710 void add (std::string_view name,
const Box& val);
725 std::vector<int>& ref,
726 int start_ix =
FIRST,
727 int num_val =
ALL)
const;
729 void getarr (std::string_view name,
730 std::vector<int>& ref,
731 int start_ix =
FIRST,
732 int num_val =
ALL)
const;
736 std::vector<int>& ref,
737 int start_ix =
FIRST,
738 int num_val =
ALL)
const;
740 int queryarr (std::string_view name,
741 std::vector<int>& ref,
742 int start_ix =
FIRST,
743 int num_val =
ALL)
const;
745 void addarr (std::string_view name,
const std::vector<int>& ref);
761 std::vector<long>& ref,
762 int start_ix =
FIRST,
763 int num_val =
ALL)
const;
765 void getarr (std::string_view name,
766 std::vector<long>& ref,
767 int start_ix =
FIRST,
768 int num_val =
ALL)
const;
772 std::vector<long>& ref,
773 int start_ix =
FIRST,
774 int num_val =
ALL)
const;
776 int queryarr (std::string_view name,
777 std::vector<long>& ref,
778 int start_ix =
FIRST,
779 int num_val =
ALL)
const;
781 void addarr (std::string_view name,
const std::vector<long>& ref);
797 std::vector<long long>& ref,
798 int start_ix =
FIRST,
799 int num_val =
ALL)
const;
801 void getarr (std::string_view name,
802 std::vector<long long>& ref,
803 int start_ix =
FIRST,
804 int num_val =
ALL)
const;
808 std::vector<long long>& ref,
809 int start_ix =
FIRST,
810 int num_val =
ALL)
const;
812 int queryarr (std::string_view name,
813 std::vector<long long>& ref,
814 int start_ix =
FIRST,
815 int num_val =
ALL)
const;
817 void addarr (std::string_view name,
const std::vector<long long>& ref);
833 std::vector<float>& ref,
834 int start_ix =
FIRST,
835 int num_val =
ALL)
const;
837 void getarr (std::string_view name,
838 std::vector<float>& ref,
839 int start_ix =
FIRST,
840 int num_val =
ALL)
const;
844 std::vector<float>& ref,
845 int start_ix =
FIRST,
846 int num_val =
ALL)
const;
848 int queryarr (std::string_view name,
849 std::vector<float>& ref,
850 int start_ix =
FIRST,
851 int num_val =
ALL)
const;
853 void addarr (std::string_view name,
const std::vector<float>& ref);
868 std::vector<double>& ref,
869 int start_ix =
FIRST,
870 int num_val =
ALL)
const;
872 void getarr (std::string_view name,
873 std::vector<double>& ref,
874 int start_ix =
FIRST,
875 int num_val =
ALL)
const;
879 std::vector<double>& ref,
880 int start_ix =
FIRST,
881 int num_val =
ALL)
const;
883 int queryarr (std::string_view name,
884 std::vector<double>& ref,
885 int start_ix =
FIRST,
886 int num_val =
ALL)
const;
888 void addarr (std::string_view name,
const std::vector<double>& ref);
903 std::vector<std::string>& ref,
904 int start_ix =
FIRST,
905 int num_val =
ALL)
const;
907 void getarr (std::string_view name,
908 std::vector<std::string>& ref,
909 int start_ix =
FIRST,
910 int num_val =
ALL)
const;
914 std::vector<std::string>& ref,
915 int start_ix =
FIRST,
916 int num_val =
ALL)
const;
918 int queryarr (std::string_view name,
919 std::vector<std::string>& ref,
920 int start_ix =
FIRST,
921 int num_val =
ALL)
const;
923 void addarr (std::string_view name,
const std::vector<std::string>& ref);
938 std::vector<IntVect>& ref,
939 int start_ix =
FIRST,
940 int num_val =
ALL)
const;
942 void getarr (std::string_view name,
943 std::vector<IntVect>& ref,
944 int start_ix =
FIRST,
945 int num_val =
ALL)
const;
949 std::vector<IntVect>& ref,
950 int start_ix =
FIRST,
951 int num_val =
ALL)
const;
953 int queryarr (std::string_view name,
954 std::vector<IntVect>& ref,
955 int start_ix =
FIRST,
956 int num_val =
ALL)
const;
958 void addarr (std::string_view name,
const std::vector<IntVect>& ref);
973 std::vector<Box>& ref,
974 int start_ix =
FIRST,
975 int num_val =
ALL)
const;
977 void getarr (std::string_view name,
978 std::vector<Box>& ref,
979 int start_ix =
FIRST,
980 int num_val =
ALL)
const;
984 std::vector<Box>& ref,
985 int start_ix =
FIRST,
986 int num_val =
ALL)
const;
988 int queryarr (std::string_view name,
989 std::vector<Box>& ref,
990 int start_ix =
FIRST,
991 int num_val =
ALL)
const;
993 void addarr (std::string_view name,
const std::vector<Box>& ref);
1017 template <
typename T, std::
size_t N>
1018 void get (std::string_view name, std::array<T,N>& ref)
const {
1022 for (std::size_t i = 0; i < N; ++i) {
1027 template <
typename T, std::
size_t N>
1028 int query (std::string_view name, std::array<T,N>& ref)
const {
1030 int exist = this->
queryarr(name, v);
1033 for (std::size_t i = 0; i < N; ++i) {
1046 template <
typename T>
1048 int exist = this->
query(name, ref);
1050 this->
add(name, ref);
1055 int queryAdd (std::string_view name, std::string& ref) {
1056 int exist = this->
query(name, ref);
1057 if (!exist && !ref.empty()) {
1058 this->
add(name, ref);
1072 template <
typename T>
1073 int queryAdd (std::string_view name, std::vector<T>& ref) {
1074 std::vector<T> empty;
1075 int exist = this->
queryarr(name, empty);
1077 ref = std::move(empty);
1079 if (!exist && !ref.empty()) {
1085 template <
typename T>
1087 return this->
queryAdd(name,
static_cast<std::vector<T>&
>(ref));
1096 template <
typename T>
1097 int queryAdd (std::string_view name, std::vector<T>& ref,
int num_val) {
1098 int exist = this->
queryarr(name, ref, 0, num_val);
1111 template <
typename T, std::
size_t N>
1112 int queryAdd (std::string_view name, std::array<T,N>& ref) {
1114 int exist = this->
queryarr(name, v);
1117 for (std::size_t i = 0; i < N; ++i) {
1122 for (std::size_t i = 0; i < N; ++i) {
1155 template <
typename T>
1156 requires (std::same_as<T,bool> ||
1157 std::same_as<T,int> ||
1158 std::same_as<T,long> ||
1159 std::same_as<T,long long> ||
1160 std::same_as<T,float> ||
1161 std::same_as<T,double>)
1165 if (
int(ref.size()) < nvals) { ref.resize(nvals); }
1178 template <
typename T>
1179 requires (std::same_as<T,bool> ||
1180 std::same_as<T,int> ||
1181 std::same_as<T,long> ||
1182 std::same_as<T,long long> ||
1183 std::same_as<T,float> ||
1184 std::same_as<T,double>)
1189 this->
add(name, ref);
1199 template <
typename T>
1200 requires (std::same_as<T,bool> ||
1201 std::same_as<T,int> ||
1202 std::same_as<T,long> ||
1203 std::same_as<T,long long> ||
1204 std::same_as<T,float> ||
1205 std::same_as<T,double>)
1210 amrex::Error(std::string(
"ParmParse::getWithParser: failed to get ")+std::string(name));
1219 template <
typename T>
1220 requires (std::same_as<T,bool> ||
1221 std::same_as<T,int> ||
1222 std::same_as<T,long> ||
1223 std::same_as<T,long long> ||
1224 std::same_as<T,float> ||
1225 std::same_as<T,double>)
1230 amrex::Error(std::string(
"ParmParse::getarrWithParser: failed to get ")+std::string(name));
1239 template <
typename T>
1240 requires (std::same_as<T,bool> ||
1241 std::same_as<T,int> ||
1242 std::same_as<T,long> ||
1243 std::same_as<T,long long> ||
1244 std::same_as<T,float> ||
1245 std::same_as<T,double>)
1250 amrex::Error(std::string(
"ParmParse::getarrWithParser: failed to get ")+std::string(name));
1259 template <
typename T>
1260 requires (std::same_as<T,bool> ||
1261 std::same_as<T,int> ||
1262 std::same_as<T,long> ||
1263 std::same_as<T,long long> ||
1264 std::same_as<T,float> ||
1265 std::same_as<T,double>)
1266 T
eval (std::string
const& expr)
const
1268 if constexpr (std::is_integral_v<T>) {
1271 return static_cast<T
>(exe());
1273 auto const parser = this->
makeParser(expr, {});
1275 return static_cast<T
>(exe());
1285 template <
typename T>
1286 int query (
const char* new_name,
const char* old_name, T& ref)
1288 return (this->
query(new_name, ref) ||
1289 this->
query(old_name, ref));
1299 template <
typename T>
1300 void get (
const char* new_name,
const char* old_name, T& ref)
1302 auto exist = this->
query(new_name, old_name, ref);
1305 << new_name <<
" and " << old_name <<
'\n';
1319 template <
typename T,
typename ET = amrex_enum_traits<T>>
1320 requires (ET::value)
1321 int query (std::string_view name, T& ref,
int ival =
FIRST)
const
1324 int exist = this->
query(name, s, ival);
1327 ref = amrex::getEnum<T>(s);
1330 amrex::Print() <<
"amrex::ParmParse::query (input name: "
1342 template <
typename T,
typename ET = amrex_enum_traits<T>>
1343 requires (ET::value)
1344 void add (std::string_view name, T
const& val)
1357 template <
typename T,
typename ET = amrex_enum_traits<T>>
1358 requires (ET::value)
1359 void get (std::string_view name, T& ref,
int ival =
FIRST)
const
1362 this->
get(name, s, ival);
1364 ref = amrex::getEnum<T>(s);
1367 amrex::Print() <<
"amrex::ParmParse::get (input name: "
1375 template <
typename T,
typename ET = amrex_enum_traits<T>>
1376 requires (ET::value)
1378 std::vector<T>& ref,
1379 int start_ix =
FIRST,
1380 int num_val =
ALL)
const
1382 std::vector<std::string> s;
1383 int exist = this->
queryarr(name, s, start_ix, num_val);
1385 ref.resize(s.size());
1386 for (std::size_t i = 0; i < s.size(); ++i) {
1388 ref[i] = amrex::getEnum<T>(s[i]);
1391 amrex::Print() <<
"amrex::ParmParse::queryarr (input name: "
1402 template <
typename T,
typename ET = amrex_enum_traits<T>>
1403 requires (ET::value)
1405 std::vector<T>& ref,
1406 int start_ix =
FIRST,
1407 int num_val =
ALL)
const
1409 std::vector<std::string> s;
1410 this->
getarr(name, s, start_ix, num_val);
1411 ref.resize(s.size());
1412 for (std::size_t i = 0; i < s.size(); ++i) {
1414 ref[i] = amrex::getEnum<T>(s[i]);
1417 amrex::Print() <<
"amrex::ParmParse::getarr (input name: "
1435 template <
typename T,
typename ET = amrex_enum_traits<T>>
1436 requires (ET::value)
1440 int exist = this->
query(name, s, ival);
1443 ref = amrex::getEnumCaseInsensitive<T>(s);
1446 amrex::Print() <<
"amrex::ParmParse::query_enum_case_insensitive (input name: "
1465 template <
typename T,
typename ET = amrex_enum_traits<T>>
1466 requires (ET::value)
1471 std::string msg(
"get_enum_case_insensitive(\"");
1472 msg.append(name).append(
"\",").append(amrex::getEnumClassName<T>())
1473 .append(
"&) failed.");
1490 template <
typename T,
typename ET = amrex_enum_traits<T>>
1491 requires (ET::value)
1493 int ival =
FIRST)
const
1496 int exist = this->
query(name, s, ival);
1499 s.erase(std::remove_if(s.begin(), s.end(),
1500 [&] (
auto const& c) {
1501 return ignores.find(c) != std::string_view::npos; }),
1503 ref = amrex::getEnumCaseInsensitive<T>(s);
1506 amrex::Print() <<
"amrex::ParmParse::query_enum_sloppy (input name: "
1527 template <
typename T,
typename ET = amrex_enum_traits<T>>
1528 requires (ET::value)
1530 int ival =
FIRST)
const
1534 std::string msg(
"get_enum_sloppy(\"");
1535 msg.append(name).append(
"\",").append(amrex::getEnumClassName<T>())
1536 .append(
"&) failed.");
1549 template <
typename T>
1550 requires (ppdetail::IsArithmeticOptional_v<T>)
1553 using value_type = ppdetail::underlying_type_t<T>;
1557 if (std::is_integral_v<value_type>) {
1558 dref = std::round(dref);
1560 auto vref =
static_cast<value_type
>(dref);
1561 if constexpr (std::is_integral_v<value_type> && !std::is_same_v<value_type,bool>) {
1562 if (
static_cast<double>(vref) != dref) {
1579 template <
typename T>
1580 requires (ppdetail::IsArithmeticOptional_v<T>)
1583 using value_type = ppdetail::underlying_type_t<T>;
1584 std::vector<double> dref(nvals);
1587 for (
int i = 0; i < nvals; ++i) {
1588 if (std::is_integral_v<value_type>) {
1589 dref[i] = std::round(dref[i]);
1591 auto vref =
static_cast<value_type
>(dref[i]);
1592 if constexpr (std::is_integral_v<value_type> && !std::is_same_v<value_type,bool>) {
1593 if (
static_cast<double>(vref) != dref[i]) {
1594 amrex::Abort(
"ParmParse:: queryarrAsDouble is not safe");
1611 template <
typename T>
1612 requires (ppdetail::IsArithmeticOptional_v<T>)
1617 amrex::Error(std::string(
"ParmParse::getAsDouble: failed to get ")+std::string(name));
1629 template <
typename T>
1630 requires (ppdetail::IsArithmeticOptional_v<T>)
1635 amrex::Error(std::string(
"ParmParse::getarrAsDouble: failed to get ")+std::string(name));
1640 int remove (std::string_view name);
1659 int querytable (std::string_view name, std::vector<std::vector<double>>& ref)
const;
1660 int querytable (std::string_view name, std::vector<std::vector<float>>& ref)
const;
1661 int querytable (std::string_view name, std::vector<std::vector<int>>& ref)
const;
1668 template <
typename T>
1669 void gettable (std::string_view name, std::vector<std::vector<T>>& ref)
const
1673 <<
" not found in database\n";
1684 int queryarr (std::string_view name, std::vector<std::vector<double>>& ref)
const;
1685 int queryarr (std::string_view name, std::vector<std::vector<float>>& ref)
const;
1686 int queryarr (std::string_view name, std::vector<std::vector<int>>& ref)
const;
1687 int queryarr (std::string_view name, std::vector<std::vector<std::string>>& ref)
const;
1693 template <
typename T>
1694 void getarr (std::string_view name, std::vector<std::vector<T>>& ref)
const
1696 if (this->
queryarr(name, ref) == 0) {
1698 <<
" not found in database\n";
1711 static void Initialize (
int argc,
char** argv,
const char* parfile);
1712 static void Initialize (
int argc,
char** argv,
const std::string& parfile) {
1730 static void dumpTable (std::ostream& os,
bool prettyPrint =
false);
1748 static void addfile (std::string
const& filename);
1753 [[nodiscard]]
static bool hasUnusedInputs (
const std::string& prefix = std::string());
1756 [[nodiscard]]
static std::vector<std::string>
getUnusedInputs (
const std::string& prefix = std::string());
1759 [[nodiscard]]
static std::set<std::string>
getEntries (
const std::string& prefix = std::string());
1772 std::vector<std::vector<std::string>>
m_vals;
1775 mutable std::variant<
1786 mutable std::vector<std::variant<bool, int, long, long long, float, double>>
m_last_vals;
1789 using Table = std::unordered_map<std::string, PP_entry>;
1801 [[nodiscard]] std::string
const&
getPrefix ()
const;
1803 [[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:93
IParserExecutor< N > compileHost() const
Compile the expression into a host-only executor.
Definition AMReX_IParser.H:191
Parse Parameters From Command Line and Input Files.
Definition AMReX_ParmParse.H:351
QuoteType
Definition AMReX_ParmParse.H:1761
int queryline(std::string_view name, std::string &ref) const
Definition AMReX_ParmParse.cpp:2717
int countname(std::string_view name) const
Returns the number of times the given name (prepended with prefix) appears in the table.
Definition AMReX_ParmParse.cpp:2732
int queryAdd(std::string_view name, std::vector< T > &ref)
If name is found, the value in the ParmParse database will be stored in the ref argument....
Definition AMReX_ParmParse.H:1073
int queryAdd(std::string_view name, T &ref)
If name is found, the value in the ParmParse database will be stored in the ref argument....
Definition AMReX_ParmParse.H:1047
void gettable(std::string_view name, std::vector< std::vector< T > > &ref) const
Get vector of vector. It's an error if it is not found. The table (i.e., vector of vector) is in the ...
Definition AMReX_ParmParse.H:1669
int querytable(std::string_view name, std::vector< std::vector< double > > &ref) const
Query vector of vector. The return value indicates whether it's found. The table (i....
Definition AMReX_ParmParse.cpp:3017
int query(std::string_view name, std::array< T, N > &ref) const
Definition AMReX_ParmParse.H:1028
static std::string const UnsetKeyword
keyword for removing entries from the table
Definition AMReX_ParmParse.H:1797
static void prettyPrintTable(std::ostream &os)
Definition AMReX_ParmParse.cpp:1851
static void Initialize(int argc, char **argv, const char *parfile)
Construct an initial ParmParse object from the argc and argv passed in to main(). An error will be si...
Definition AMReX_ParmParse.cpp:1652
static void addfile(std::string const &filename)
Definition AMReX_ParmParse.cpp:1622
static std::string const FileKeyword
keyword for files to load
Definition AMReX_ParmParse.H:1794
static std::string ParserPrefix
Definition AMReX_ParmParse.H:1799
static int Verbose()
Definition AMReX_ParmParse.cpp:1733
static void SetVerbose(int v)
Definition AMReX_ParmParse.cpp:1746
void get(const char *new_name, const char *old_name, T &ref)
Get using two names.
Definition AMReX_ParmParse.H:1300
static bool hasUnusedInputs(const std::string &prefix=std::string())
Any unused [prefix.]* parameters?
Definition AMReX_ParmParse.cpp:1684
int queryarrAsDouble(std::string_view name, int nvals, T *ptr) const
Query T array with Parser, but treat the number as double precision during parsing.
Definition AMReX_ParmParse.H:1581
Parser makeParser(std::string const &func, Vector< std::string > const &vars) const
Definition AMReX_ParmParse.cpp:2935
int queryAdd(std::string_view name, std::string &ref)
Definition AMReX_ParmParse.H:1055
int queryktharr(std::string_view name, int k, std::vector< int > &ref, int start_ix=FIRST, int num_val=ALL) const
queryktharr() is to querykth() as getktharr() is to getkth().
Definition AMReX_ParmParse.cpp:2024
void getarrAsDouble(std::string_view name, int nvals, T *ptr) const
Get T array with Parser, but treat the number as double precision during parsing.
Definition AMReX_ParmParse.H:1631
static bool QueryUnusedInputs()
Definition AMReX_ParmParse.cpp:1669
void getline(std::string_view name, std::string &ref) const
Definition AMReX_ParmParse.cpp:2709
void getarr(std::string_view name, std::vector< int > &ref, int start_ix=FIRST, int num_val=ALL) const
Same as getktharr() but searches for last occurrence of name.
Definition AMReX_ParmParse.cpp:2015
void add(std::string_view name, const char *val)
Convert const char * to string, to prevent auto-conversion to bool.
Definition AMReX_ParmParse.H:621
void getkth(std::string_view name, int k, bool &ref, int ival=FIRST) const
Get the ival'th value of kth occurrence of the requested name. If successful, the value is converted ...
Definition AMReX_ParmParse.cpp:1922
bool contains(std::string_view name) const
Returns true if name is in table.
Definition AMReX_ParmParse.cpp:2748
void get(std::string_view name, std::array< T, N > &ref) const
Definition AMReX_ParmParse.H:1018
void getarr(std::string_view name, std::vector< std::vector< T > > &ref) const
Get vector of vector. It's an error if it is not found. The vector of vector is in the format of [[a0...
Definition AMReX_ParmParse.H:1694
static void prettyPrintUsedInputs(std::ostream &os)
Definition AMReX_ParmParse.cpp:1863
static void Finalize()
The destructor. The internal static table will only be deleted if there are no other ParmParse object...
Definition AMReX_ParmParse.cpp:1752
int queryAdd(std::string_view name, std::vector< T > &ref, int num_val)
If name is found, the value in the ParmParse database will be stored in the ref argument....
Definition AMReX_ParmParse.H:1097
std::string m_prefix
Definition AMReX_ParmParse.H:1807
const Table & table() const
Definition AMReX_ParmParse.H:1791
int queryAddWithParser(std::string_view name, T &ref)
Query with Parser. If name is found, this uses amrex::Parser to parse the entire list of empty space ...
Definition AMReX_ParmParse.H:1185
T eval(std::string const &expr) const
Definition AMReX_ParmParse.H:1266
int querykth(std::string_view name, int k, bool &ref, int ival=FIRST) const
Similar to getkth() but returns 0 if there is no kth occurrence of name. If successful,...
Definition AMReX_ParmParse.cpp:1939
void get_enum_sloppy(std::string_view name, T &ref, std::string_view const &ignores, int ival=FIRST) const
. Get enum value using given name.
Definition AMReX_ParmParse.H:1529
int query_enum_case_insensitive(std::string_view name, T &ref, int ival=FIRST) const
. Query enum value using given name.
Definition AMReX_ParmParse.H:1437
static void SetParserPrefix(std::string a_prefix)
Set prefix used by math expression Parser.
Definition AMReX_ParmParse.cpp:1779
int queryWithParser(std::string_view name, bool &ref) const
Query with Parser. If name is found, this uses amrex::Parser to parse the entire list of empty space ...
Definition AMReX_ParmParse.cpp:2863
static std::vector< std::string > getUnusedInputs(const std::string &prefix=std::string())
Returns unused [prefix.]* parameters.
Definition AMReX_ParmParse.cpp:1690
void addarr(std::string_view name, const std::vector< int > &ref)
Add a key 'name' with vector of values 'ref' to the end of the PP table.
Definition AMReX_ParmParse.cpp:2043
std::string const & getPrefix() const
Definition AMReX_ParmParse.cpp:1602
int remove(std::string_view name)
Remove given name from the table.
Definition AMReX_ParmParse.cpp:2764
int queryarr(std::string_view name, std::vector< int > &ref, int start_ix=FIRST, int num_val=ALL) const
Same as queryktharr() but searches for last occurrence of name.
Definition AMReX_ParmParse.cpp:2034
@ FIRST
Definition AMReX_ParmParse.H:353
@ LAST
Definition AMReX_ParmParse.H:353
@ ALL
Definition AMReX_ParmParse.H:353
int query_enum_sloppy(std::string_view name, T &ref, std::string_view const &ignores, int ival=FIRST) const
. Query enum value using given name.
Definition AMReX_ParmParse.H:1492
void get_enum_case_insensitive(std::string_view name, T &ref, int ival=FIRST) const
. Get enum value using given name.
Definition AMReX_ParmParse.H:1467
static void Initialize(int argc, char **argv, const std::string &parfile)
Definition AMReX_ParmParse.H:1712
int queryAdd(std::string_view name, std::array< T, N > &ref)
If name is found, the value in the ParmParse database will be stored in the ref argument....
Definition AMReX_ParmParse.H:1112
void getarrWithParser(std::string_view name, int nvals, T *ptr) const
Get with Parser. If name is not found, it's a runtime error. If the number of elements does not equal...
Definition AMReX_ParmParse.H:1226
int query(const char *new_name, const char *old_name, T &ref)
Definition AMReX_ParmParse.H:1286
Table * m_table
Definition AMReX_ParmParse.H:1809
int queryarrWithParser(std::string_view name, int nvals, bool *ptr) const
Query with Parser. The return value indicates whether it's found. Note that queryWithParser will be u...
Definition AMReX_ParmParse.cpp:2899
std::string m_parser_prefix
Definition AMReX_ParmParse.H:1808
void add(std::string_view name, bool val)
Add a key 'name' with value 'val' to the end of the PP table.
Definition AMReX_ParmParse.cpp:1956
static void dumpTable(std::ostream &os, bool prettyPrint=false)
Definition AMReX_ParmParse.cpp:1787
void getktharr(std::string_view name, int k, std::vector< int > &ref, int start_ix=FIRST, int num_val=ALL) const
Gets an std::vector<int> of num_val values from kth occurrence of given name. If successful,...
Definition AMReX_ParmParse.cpp:2005
static void prettyPrintUnusedInputs(std::ostream &os)
Definition AMReX_ParmParse.cpp:1857
static std::set< std::string > getEntries(const std::string &prefix=std::string())
Returns [prefix.]* parameters.
Definition AMReX_ParmParse.cpp:1720
int queryAsDouble(std::string_view name, T &ref) const
Query T with Parser, but treat the number as double precision during parsing.
Definition AMReX_ParmParse.H:1551
std::string prefixedName(std::string_view str) const
Definition AMReX_ParmParse.cpp:1608
void getAsDouble(std::string_view name, T &ref) const
Get T with Parser, but treat the number as double precision during parsing.
Definition AMReX_ParmParse.H:1613
int query(std::string_view name, bool &ref, int ival=FIRST) const
Same as querykth() but searches for the last occurrence of name.
Definition AMReX_ParmParse.cpp:1948
int queryAdd(std::string_view name, Vector< T > &ref)
Definition AMReX_ParmParse.H:1086
void get(std::string_view name, bool &ref, int ival=FIRST) const
Same as getkth() but searches for the last occurrence of name.
Definition AMReX_ParmParse.cpp:1931
void getWithParser(std::string_view name, T &ref) const
Get with Parser. If name is found, this uses amrex::Parser to parse the entire list of empty space se...
Definition AMReX_ParmParse.H:1206
std::unordered_map< std::string, PP_entry > Table
Definition AMReX_ParmParse.H:1789
IParser makeIParser(std::string const &func, Vector< std::string > const &vars) const
Definition AMReX_ParmParse.cpp:2942
int countval(std::string_view name, int n=LAST) const
Returns the number of values associated with nth occurrence of name (prepended with the prefix) in th...
Definition AMReX_ParmParse.cpp:1869
Front-end for parsing scalar expressions into GPU/CPU executors.
Definition AMReX_Parser.H:126
ParserExecutor< N > compileHost() const
Compile the current expression into a host-only executor.
Definition AMReX_Parser.H:272
This class provides the user with a few print options.
Definition AMReX_Print.H:35
This class is a thin wrapper around std::vector. Unlike vector, Vector::operator[] provides bound che...
Definition AMReX_Vector.H:29
amrex_long Long
Definition AMReX_INT.H:30
Definition AMReX_Amr.cpp:50
std::ostream & ErrorStream()
Definition AMReX.cpp:970
BoxND< 3 > Box
Box is an alias for amrex::BoxND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:30
std::string getEnumNameString(T const &v)
Definition AMReX_Enum.H:157
IntVectND< 3 > IntVect
IntVect is an alias for amrex::IntVectND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:33
void Error(const std::string &msg)
Print out message to cerr and exit via amrex::Abort().
Definition AMReX.cpp:235
__host__ __device__ IntVectND(const Array< int, dim > &) -> IntVectND< dim >
int Verbose() noexcept
Definition AMReX.cpp:181
void Abort(const std::string &msg)
Print out message to cerr and exit via abort().
Definition AMReX.cpp:241
__host__ __device__ RealVectND(Real, Real, Args...) -> RealVectND< sizeof...(Args)+2 >
Definition AMReX_ParmParse.H:1767
std::variant< std::string *, bool *, int *, long *, long long *, amrex::IntVect *, amrex::Box *, float *, double * > m_typehint
Definition AMReX_ParmParse.H:1785
std::vector< std::vector< std::string > > m_vals
Definition AMReX_ParmParse.H:1772
std::vector< std::vector< QuoteType > > m_quotes
Definition AMReX_ParmParse.H:1773
Long m_count
Definition AMReX_ParmParse.H:1774
std::vector< std::variant< bool, int, long, long long, float, double > > m_last_vals
Definition AMReX_ParmParse.H:1786
bool m_parsed
Definition AMReX_ParmParse.H:1787