1#ifndef AMREX_PARMPARSE_H_
2#define AMREX_PARMPARSE_H_
3#include <AMReX_Config.H>
21#include <unordered_map>
29using Box = BoxND<AMREX_SPACEDIM>;
32using IntVect = IntVectND<AMREX_SPACEDIM>;
38 template <
class T,
class Enable =
void>
50 std::enable_if_t<std::is_arithmetic_v<T>>>
353 explicit ParmParse (std::string prefix = std::string(),
354 std::string parser_prefix = std::string());
357 [[nodiscard]]
bool contains (std::string_view name)
const;
363 [[nodiscard]]
int countval (std::string_view name,
int n =
LAST)
const;
368 [[nodiscard]]
int countname (std::string_view name)
const;
380 void getkth (std::string_view name,
383 int ival =
FIRST)
const;
385 void get (std::string_view name,
387 int ival =
FIRST)
const;
395 int querykth (std::string_view name,
398 int ival =
FIRST)
const;
400 int query (std::string_view name,
402 int ival =
FIRST)
const;
404 void add (std::string_view name,
bool val);
414 void getkth (std::string_view name,
417 int ival =
FIRST)
const;
420 void get (std::string_view name,
422 int ival =
FIRST)
const;
430 int querykth (std::string_view name,
433 int ival =
FIRST)
const;
435 int query (std::string_view name,
437 int ival =
FIRST)
const;
439 void add (std::string_view name,
int val);
449 void getkth (std::string_view name,
452 int ival =
FIRST)
const;
454 void get (std::string_view name,
456 int ival =
FIRST)
const;
464 int querykth (std::string_view name,
467 int ival =
FIRST)
const;
469 int query (std::string_view name,
471 int ival =
FIRST)
const;
473 void add (std::string_view name,
long val);
483 void getkth (std::string_view name,
486 int ival =
FIRST)
const;
488 void get (std::string_view name,
490 int ival =
FIRST)
const;
498 int querykth (std::string_view name,
501 int ival =
FIRST)
const;
503 int query (std::string_view name,
505 int ival =
FIRST)
const;
507 void add (std::string_view name,
long long val);
517 void getkth (std::string_view name,
520 int ival =
FIRST)
const;
522 void get (std::string_view name,
524 int ival =
FIRST)
const;
532 int querykth (std::string_view name,
535 int ival =
FIRST)
const;
537 int query (std::string_view name,
539 int ival =
FIRST)
const;
541 void add (std::string_view name,
float val);
551 void getkth (std::string_view name,
554 int ival =
FIRST)
const;
556 void get (std::string_view name,
558 int ival =
FIRST)
const;
566 int querykth (std::string_view name,
569 int ival =
FIRST)
const;
571 int query (std::string_view name,
573 int ival =
FIRST)
const;
575 void add (std::string_view name,
double val);
585 void getkth (std::string_view name,
588 int ival =
FIRST)
const;
591 void get (std::string_view name,
593 int ival =
FIRST)
const;
601 int querykth (std::string_view name,
604 int ival =
FIRST)
const;
606 int query (std::string_view name,
608 int ival =
FIRST)
const;
610 void add (std::string_view name,
const std::string& val);
621 void getline (std::string_view name, std::string& ref)
const;
631 int queryline (std::string_view name, std::string& ref)
const;
642 void getkth (std::string_view name,
645 int ival =
FIRST)
const;
647 void get (std::string_view name,
649 int ival =
FIRST)
const;
657 int querykth (std::string_view name,
660 int ival =
FIRST)
const;
662 int query (std::string_view name,
664 int ival =
FIRST)
const;
666 void add (std::string_view name,
const IntVect& val);
676 void getkth (std::string_view name,
679 int ival =
FIRST)
const;
681 void get (std::string_view name,
683 int ival =
FIRST)
const;
691 int querykth (std::string_view name,
694 int ival =
FIRST)
const;
696 int query (std::string_view name,
698 int ival =
FIRST)
const;
700 void add (std::string_view name,
const Box& val);
715 std::vector<int>& ref,
716 int start_ix =
FIRST,
717 int num_val =
ALL)
const;
719 void getarr (std::string_view name,
720 std::vector<int>& ref,
721 int start_ix =
FIRST,
722 int num_val =
ALL)
const;
726 std::vector<int>& ref,
727 int start_ix =
FIRST,
728 int num_val =
ALL)
const;
730 int queryarr (std::string_view name,
731 std::vector<int>& ref,
732 int start_ix =
FIRST,
733 int num_val =
ALL)
const;
735 void addarr (std::string_view name,
const std::vector<int>& ref);
751 std::vector<long>& ref,
752 int start_ix =
FIRST,
753 int num_val =
ALL)
const;
755 void getarr (std::string_view name,
756 std::vector<long>& ref,
757 int start_ix =
FIRST,
758 int num_val =
ALL)
const;
762 std::vector<long>& ref,
763 int start_ix =
FIRST,
764 int num_val =
ALL)
const;
766 int queryarr (std::string_view name,
767 std::vector<long>& ref,
768 int start_ix =
FIRST,
769 int num_val =
ALL)
const;
771 void addarr (std::string_view name,
const std::vector<long>& ref);
787 std::vector<long long>& ref,
788 int start_ix =
FIRST,
789 int num_val =
ALL)
const;
791 void getarr (std::string_view name,
792 std::vector<long long>& ref,
793 int start_ix =
FIRST,
794 int num_val =
ALL)
const;
798 std::vector<long long>& ref,
799 int start_ix =
FIRST,
800 int num_val =
ALL)
const;
802 int queryarr (std::string_view name,
803 std::vector<long long>& ref,
804 int start_ix =
FIRST,
805 int num_val =
ALL)
const;
807 void addarr (std::string_view name,
const std::vector<long long>& ref);
823 std::vector<float>& ref,
824 int start_ix =
FIRST,
825 int num_val =
ALL)
const;
827 void getarr (std::string_view name,
828 std::vector<float>& ref,
829 int start_ix =
FIRST,
830 int num_val =
ALL)
const;
834 std::vector<float>& ref,
835 int start_ix =
FIRST,
836 int num_val =
ALL)
const;
838 int queryarr (std::string_view name,
839 std::vector<float>& ref,
840 int start_ix =
FIRST,
841 int num_val =
ALL)
const;
843 void addarr (std::string_view name,
const std::vector<float>& ref);
858 std::vector<double>& ref,
859 int start_ix =
FIRST,
860 int num_val =
ALL)
const;
862 void getarr (std::string_view name,
863 std::vector<double>& ref,
864 int start_ix =
FIRST,
865 int num_val =
ALL)
const;
869 std::vector<double>& ref,
870 int start_ix =
FIRST,
871 int num_val =
ALL)
const;
873 int queryarr (std::string_view name,
874 std::vector<double>& ref,
875 int start_ix =
FIRST,
876 int num_val =
ALL)
const;
878 void addarr (std::string_view name,
const std::vector<double>& ref);
893 std::vector<std::string>& ref,
894 int start_ix =
FIRST,
895 int num_val =
ALL)
const;
897 void getarr (std::string_view name,
898 std::vector<std::string>& ref,
899 int start_ix =
FIRST,
900 int num_val =
ALL)
const;
904 std::vector<std::string>& ref,
905 int start_ix =
FIRST,
906 int num_val =
ALL)
const;
908 int queryarr (std::string_view name,
909 std::vector<std::string>& ref,
910 int start_ix =
FIRST,
911 int num_val =
ALL)
const;
913 void addarr (std::string_view name,
const std::vector<std::string>& ref);
928 std::vector<IntVect>& ref,
929 int start_ix =
FIRST,
930 int num_val =
ALL)
const;
932 void getarr (std::string_view name,
933 std::vector<IntVect>& ref,
934 int start_ix =
FIRST,
935 int num_val =
ALL)
const;
939 std::vector<IntVect>& ref,
940 int start_ix =
FIRST,
941 int num_val =
ALL)
const;
943 int queryarr (std::string_view name,
944 std::vector<IntVect>& ref,
945 int start_ix =
FIRST,
946 int num_val =
ALL)
const;
948 void addarr (std::string_view name,
const std::vector<IntVect>& ref);
963 std::vector<Box>& ref,
964 int start_ix =
FIRST,
965 int num_val =
ALL)
const;
967 void getarr (std::string_view name,
968 std::vector<Box>& ref,
969 int start_ix =
FIRST,
970 int num_val =
ALL)
const;
974 std::vector<Box>& ref,
975 int start_ix =
FIRST,
976 int num_val =
ALL)
const;
978 int queryarr (std::string_view name,
979 std::vector<Box>& ref,
980 int start_ix =
FIRST,
981 int num_val =
ALL)
const;
983 void addarr (std::string_view name,
const std::vector<Box>& ref);
1007 template <
typename T, std::
size_t N>
1008 void get (std::string_view name, std::array<T,N>& ref)
const {
1012 for (std::size_t i = 0; i < N; ++i) {
1017 template <
typename T, std::
size_t N>
1018 int query (std::string_view name, std::array<T,N>& ref)
const {
1020 int exist = this->
queryarr(name, v);
1023 for (std::size_t i = 0; i < N; ++i) {
1036 template <typename T, std::enable_if_t<!IsStdVector<T>::value,
int> = 0>
1038 int exist = this->
query(name, ref);
1040 this->
add(name, ref);
1045 int queryAdd (std::string_view name, std::string& ref) {
1046 int exist = this->
query(name, ref);
1047 if (!exist && !ref.empty()) {
1048 this->
add(name, ref);
1062 template <
typename T>
1063 int queryAdd (std::string_view name, std::vector<T>& ref) {
1064 std::vector<T> empty;
1065 int exist = this->
queryarr(name, empty);
1067 ref = std::move(empty);
1069 if (!exist && !ref.empty()) {
1081 template <
typename T>
1082 int queryAdd (std::string_view name, std::vector<T>& ref,
int num_val) {
1083 int exist = this->
queryarr(name, ref, 0, num_val);
1096 template <
typename T, std::
size_t N>
1097 int queryAdd (std::string_view name, std::array<T,N>& ref) {
1099 int exist = this->
queryarr(name, v);
1102 for (std::size_t i = 0; i < N; ++i) {
1107 for (std::size_t i = 0; i < N; ++i) {
1140 template <
typename T, std::enable_if_t<std::is_same_v<T,
bool> ||
1141 std::is_same_v<T,
int> ||
1142 std::is_same_v<T,
long> ||
1143 std::is_same_v<T,
long long> ||
1144 std::is_same_v<T,
float> ||
1145 std::is_same_v<T,
double>,
int> = 0>
1149 if (
int(ref.size()) < nvals) { ref.resize(nvals); }
1162 template <
typename T, std::enable_if_t<std::is_same_v<T,
bool> ||
1163 std::is_same_v<T,
int> ||
1164 std::is_same_v<T,
long> ||
1165 std::is_same_v<T,
long long> ||
1166 std::is_same_v<T,
float> ||
1167 std::is_same_v<T,
double>,
int> = 0>
1172 this->
add(name, ref);
1182 template <
typename T, std::enable_if_t<std::is_same_v<T,
bool> ||
1183 std::is_same_v<T,
int> ||
1184 std::is_same_v<T,
long> ||
1185 std::is_same_v<T,
long long> ||
1186 std::is_same_v<T,
float> ||
1187 std::is_same_v<T,
double>,
int> = 0>
1192 amrex::Error(std::string(
"ParmParse::getWithParser: failed to get ")+std::string(name));
1201 template <
typename T, std::enable_if_t<std::is_same_v<T,
bool> ||
1202 std::is_same_v<T,
int> ||
1203 std::is_same_v<T,
long> ||
1204 std::is_same_v<T,
long long> ||
1205 std::is_same_v<T,
float> ||
1206 std::is_same_v<T,
double>,
int> = 0>
1211 amrex::Error(std::string(
"ParmParse::getarrWithParser: failed to get ")+std::string(name));
1220 template <
typename T, std::enable_if_t<std::is_same_v<T,
bool> ||
1221 std::is_same_v<T,
int> ||
1222 std::is_same_v<T,
long> ||
1223 std::is_same_v<T,
long long> ||
1224 std::is_same_v<T,
float> ||
1225 std::is_same_v<T,
double>,
int> = 0>
1230 amrex::Error(std::string(
"ParmParse::getarrWithParser: failed to get ")+std::string(name));
1239 template <
typename T, std::enable_if_t<std::is_same_v<T,
bool> ||
1240 std::is_same_v<T,
int> ||
1241 std::is_same_v<T,
long> ||
1242 std::is_same_v<T,
long long> ||
1243 std::is_same_v<T,
float> ||
1244 std::is_same_v<T,
double>,
int> = 0>
1245 T
eval (std::string
const& expr)
const
1247 if constexpr (std::is_integral_v<T>) {
1250 return static_cast<T
>(exe());
1252 auto const parser = this->
makeParser(expr, {});
1254 return static_cast<T
>(exe());
1264 template <
typename T>
1265 int query (
const char* new_name,
const char* old_name, T& ref)
1267 return (this->
query(new_name, ref) ||
1268 this->
query(old_name, ref));
1278 template <
typename T>
1279 void get (
const char* new_name,
const char* old_name, T& ref)
1281 auto exist = this->
query(new_name, old_name, ref);
1284 << new_name <<
" and " << old_name <<
'\n';
1298 template <
typename T,
typename ET = amrex_enum_traits<T>,
1299 std::enable_if_t<ET::value,
int> = 0>
1300 int query (std::string_view name, T& ref,
int ival =
FIRST)
const
1303 int exist = this->
query(name, s, ival);
1306 ref = amrex::getEnum<T>(s);
1309 amrex::Print() <<
"amrex::ParmParse::query (input name: "
1321 template <
typename T,
typename ET = amrex_enum_traits<T>,
1322 std::enable_if_t<ET::value,
int> = 0>
1323 void add (std::string_view name, T
const& val)
1336 template <
typename T,
typename ET = amrex_enum_traits<T>,
1337 std::enable_if_t<ET::value,
int> = 0>
1338 void get (std::string_view name, T& ref,
int ival =
FIRST)
const
1341 this->
get(name, s, ival);
1343 ref = amrex::getEnum<T>(s);
1346 amrex::Print() <<
"amrex::ParmParse::get (input name: "
1354 template <
typename T,
typename ET = amrex_enum_traits<T>,
1355 std::enable_if_t<ET::value,
int> = 0>
1357 std::vector<T>& ref,
1358 int start_ix =
FIRST,
1359 int num_val =
ALL)
const
1361 std::vector<std::string> s;
1362 int exist = this->
queryarr(name, s, start_ix, num_val);
1364 ref.resize(s.size());
1365 for (std::size_t i = 0; i < s.size(); ++i) {
1367 ref[i] = amrex::getEnum<T>(s[i]);
1370 amrex::Print() <<
"amrex::ParmParse::queryarr (input name: "
1381 template <
typename T,
typename ET = amrex_enum_traits<T>,
1382 std::enable_if_t<ET::value,
int> = 0>
1384 std::vector<T>& ref,
1385 int start_ix =
FIRST,
1386 int num_val =
ALL)
const
1388 std::vector<std::string> s;
1389 this->
getarr(name, s, start_ix, num_val);
1390 ref.resize(s.size());
1391 for (std::size_t i = 0; i < s.size(); ++i) {
1393 ref[i] = amrex::getEnum<T>(s[i]);
1396 amrex::Print() <<
"amrex::ParmParse::getarr (input name: "
1414 template <
typename T,
typename ET = amrex_enum_traits<T>,
1415 std::enable_if_t<ET::value,
int> = 0>
1419 int exist = this->
query(name, s, ival);
1422 ref = amrex::getEnumCaseInsensitive<T>(s);
1425 amrex::Print() <<
"amrex::ParmParse::query_enum_case_insensitive (input name: "
1444 template <
typename T,
typename ET = amrex_enum_traits<T>,
1445 std::enable_if_t<ET::value,
int> = 0>
1450 std::string msg(
"get_enum_case_insensitive(\"");
1451 msg.append(name).append(
"\",").append(amrex::getEnumClassName<T>())
1452 .append(
"&) failed.");
1469 template <
typename T,
typename ET = amrex_enum_traits<T>,
1470 std::enable_if_t<ET::value,
int> = 0>
1472 int ival =
FIRST)
const
1475 int exist = this->
query(name, s, ival);
1478 s.erase(std::remove_if(s.begin(), s.end(),
1479 [&] (
auto const& c) {
1480 return ignores.find(c) != std::string_view::npos; }),
1482 ref = amrex::getEnumCaseInsensitive<T>(s);
1485 amrex::Print() <<
"amrex::ParmParse::query_enum_sloppy (input name: "
1506 template <
typename T,
typename ET = amrex_enum_traits<T>,
1507 std::enable_if_t<ET::value,
int> = 0>
1509 int ival =
FIRST)
const
1513 std::string msg(
"get_enum_sloppy(\"");
1514 msg.append(name).append(
"\",").append(amrex::getEnumClassName<T>())
1515 .append(
"&) failed.");
1528 template <
typename T, std::enable_if_t<ppdetail::IsArithmeticOptional_v<T>,
int> = 0>
1535 if (std::is_integral_v<value_type>) {
1536 dref = std::round(dref);
1538 auto vref =
static_cast<value_type
>(dref);
1539 if constexpr (std::is_integral_v<value_type> && !std::is_same_v<value_type,bool>) {
1540 if (
static_cast<double>(vref) != dref) {
1557 template <
typename T, std::enable_if_t<ppdetail::IsArithmeticOptional_v<T>,
int> = 0>
1561 std::vector<double> dref(nvals);
1564 for (
int i = 0; i < nvals; ++i) {
1565 if (std::is_integral_v<value_type>) {
1566 dref[i] = std::round(dref[i]);
1568 auto vref =
static_cast<value_type
>(dref[i]);
1569 if constexpr (std::is_integral_v<value_type> && !std::is_same_v<value_type,bool>) {
1570 if (
static_cast<double>(vref) != dref[i]) {
1571 amrex::Abort(
"ParmParse:: queryarrAsDouble is not safe");
1588 template <
typename T, std::enable_if_t<ppdetail::IsArithmeticOptional_v<T>,
int> = 0>
1593 amrex::Error(std::string(
"ParmParse::getAsDouble: failed to get ")+std::string(name));
1605 template <
typename T, std::enable_if_t<ppdetail::IsArithmeticOptional_v<T>,
int> = 0>
1610 amrex::Error(std::string(
"ParmParse::getarrAsDouble: failed to get ")+std::string(name));
1615 int remove (std::string_view name);
1634 int querytable (std::string_view name, std::vector<std::vector<double>>& ref)
const;
1635 int querytable (std::string_view name, std::vector<std::vector<float>>& ref)
const;
1636 int querytable (std::string_view name, std::vector<std::vector<int>>& ref)
const;
1643 template <
typename T>
1644 void gettable (std::string_view name, std::vector<std::vector<T>>& ref)
const
1648 <<
" not found in database\n";
1661 static void Initialize (
int argc,
char** argv,
const char* parfile);
1662 static void Initialize (
int argc,
char** argv,
const std::string& parfile) {
1663 return Initialize(argc, argv, parfile.c_str());
1678 static void dumpTable (std::ostream& os,
bool prettyPrint =
false);
1693 static void addfile (std::string
const& filename);
1698 [[nodiscard]]
static bool hasUnusedInputs (
const std::string& prefix = std::string());
1701 [[nodiscard]]
static std::vector<std::string>
getUnusedInputs (
const std::string& prefix = std::string());
1704 [[nodiscard]]
static std::set<std::string>
getEntries (
const std::string& prefix = std::string());
1711 std::vector<std::vector<std::string>>
m_vals;
1725 using Table = std::unordered_map<std::string, PP_entry>;
1734 [[nodiscard]] std::string
const&
getPrefix ()
const;
1736 [[nodiscard]] std::string
prefixedName (std::string_view str)
const;
#define AMREX_ALWAYS_ASSERT(EX)
Definition AMReX_BLassert.H:50
Definition AMReX_IParser.H:58
IParserExecutor< N > compileHost() const
This compiles for CPU only.
Definition AMReX_IParser.H:111
Parse Parameters From Command Line and Input Files.
Definition AMReX_ParmParse.H:343
int queryline(std::string_view name, std::string &ref) const
Definition AMReX_ParmParse.cpp:2162
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:2177
int queryarrWithParser(std::string_view name, int nvals, std::vector< T > &ref) const
Definition AMReX_ParmParse.H:1146
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:1063
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:1188
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:1644
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:2411
int query(std::string_view name, std::array< T, N > &ref) const
Definition AMReX_ParmParse.H:1018
static void prettyPrintTable(std::ostream &os)
Definition AMReX_ParmParse.cpp:1337
void get(std::string_view name, T &ref, int ival=FIRST) const
. Get enum value using given name.
Definition AMReX_ParmParse.H:1338
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:1140
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:1383
static void addfile(std::string const &filename)
Add keys and values from a file to the end of the PP table.
Definition AMReX_ParmParse.cpp:1115
static std::string const FileKeyword
keyword for files to load
Definition AMReX_ParmParse.H:1730
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:1508
static std::string ParserPrefix
Definition AMReX_ParmParse.H:1732
static int Verbose()
Definition AMReX_ParmParse.cpp:1221
static void SetVerbose(int v)
Definition AMReX_ParmParse.cpp:1234
int query(std::string_view name, T &ref, int ival=FIRST) const
. Query enum value using given name.
Definition AMReX_ParmParse.H:1300
void get(const char *new_name, const char *old_name, T &ref)
Get using two names.
Definition AMReX_ParmParse.H:1279
static bool hasUnusedInputs(const std::string &prefix=std::string())
Any unused [prefix.]* parameters?
Definition AMReX_ParmParse.cpp:1172
Parser makeParser(std::string const &func, Vector< std::string > const &vars) const
Definition AMReX_ParmParse.cpp:2329
int queryAdd(std::string_view name, std::string &ref)
Definition AMReX_ParmParse.H:1045
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:1416
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:1469
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:1529
static bool QueryUnusedInputs()
Definition AMReX_ParmParse.cpp:1157
void getline(std::string_view name, std::string &ref) const
Definition AMReX_ParmParse.cpp:2154
T eval(std::string const &expr) const
Definition AMReX_ParmParse.H:1245
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:1460
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:1207
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:1367
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:1589
bool contains(std::string_view name) const
Returns true if name is in table.
Definition AMReX_ParmParse.cpp:2193
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:1558
void get(std::string_view name, std::array< T, N > &ref) const
Definition AMReX_ParmParse.H:1008
static void prettyPrintUsedInputs(std::ostream &os)
Definition AMReX_ParmParse.cpp:1349
static void Finalize()
The destructor. The internal static table will only be deleted if there are no other ParmParse object...
Definition AMReX_ParmParse.cpp:1240
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:1082
std::string m_prefix
Definition AMReX_ParmParse.H:1740
const Table & table() const
Definition AMReX_ParmParse.H:1727
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:1168
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:1384
static void SetParserPrefix(std::string a_prefix)
Set prefix used by math expression Parser.
Definition AMReX_ParmParse.cpp:1267
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:2257
static std::vector< std::string > getUnusedInputs(const std::string &prefix=std::string())
Returns unused [prefix.]* parameters.
Definition AMReX_ParmParse.cpp:1178
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:1037
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:1488
std::string const & getPrefix() const
Definition AMReX_ParmParse.cpp:1095
int remove(std::string_view name)
Remove given name from the table.
Definition AMReX_ParmParse.cpp:2209
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:1479
@ FIRST
Definition AMReX_ParmParse.H:345
@ LAST
Definition AMReX_ParmParse.H:345
@ ALL
Definition AMReX_ParmParse.H:345
void add(std::string_view name, T const &val)
Definition AMReX_ParmParse.H:1323
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:1356
static void Initialize(int argc, char **argv, const std::string &parfile)
Definition AMReX_ParmParse.H:1662
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:1097
int query(const char *new_name, const char *old_name, T &ref)
Definition AMReX_ParmParse.H:1265
Table * m_table
Definition AMReX_ParmParse.H:1742
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:2293
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:1606
std::string m_parser_prefix
Definition AMReX_ParmParse.H:1741
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:1401
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:1446
static void dumpTable(std::ostream &os, bool prettyPrint=false)
Write the contents of the table in ASCII to the ostream.
Definition AMReX_ParmParse.cpp:1273
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:1450
static void prettyPrintUnusedInputs(std::ostream &os)
Definition AMReX_ParmParse.cpp:1343
static std::set< std::string > getEntries(const std::string &prefix=std::string())
Returns [prefix.]* parameters.
Definition AMReX_ParmParse.cpp:1208
std::string prefixedName(std::string_view str) const
Definition AMReX_ParmParse.cpp:1101
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:1226
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:1393
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:1471
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:1376
std::unordered_map< std::string, PP_entry > Table
Definition AMReX_ParmParse.H:1725
IParser makeIParser(std::string const &func, Vector< std::string > const &vars) const
Definition AMReX_ParmParse.cpp:2336
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:1355
Definition AMReX_Parser.H:70
ParserExecutor< N > compileHost() const
This compiles for CPU only.
Definition AMReX_Parser.H:143
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
typename ArithmeticOptional_TT< T >::value_type underlying_type_t
Definition AMReX_ParmParse.H:60
constexpr bool IsArithmeticOptional_v
Definition AMReX_ParmParse.H:57
Definition AMReX_Amr.cpp:49
std::ostream & ErrorStream()
Definition AMReX.cpp:931
std::string getEnumNameString(T const &v)
Definition AMReX_Enum.H:154
BoxND< 3 > Box
Definition AMReX_BaseFwd.H:27
__host__ __device__ RealVectND(Real, Real, Args...) -> RealVectND< sizeof...(Args)+2 >
IntVectND< 3 > IntVect
Definition AMReX_BaseFwd.H:30
void Error(const std::string &msg)
Print out message to cerr and exit via amrex::Abort().
Definition AMReX.cpp:224
__host__ __device__ IntVectND(const Array< int, dim > &) -> IntVectND< dim >
int Verbose() noexcept
Definition AMReX.cpp:169
void Abort(const std::string &msg)
Print out message to cerr and exit via abort().
Definition AMReX.cpp:230
Definition AMReX_ParmParse.H:1706
std::variant< std::string *, bool *, int *, long *, long long *, amrex::IntVect *, amrex::Box *, float *, double * > m_typehint
Definition AMReX_ParmParse.H:1723
std::vector< std::vector< std::string > > m_vals
Definition AMReX_ParmParse.H:1711
Long m_count
Definition AMReX_ParmParse.H:1712
T value_type
Definition AMReX_ParmParse.H:45
T value_type
Definition AMReX_ParmParse.H:53
Definition AMReX_ParmParse.H:39