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;
364 explicit ParmParse (std::string prefix = std::string(),
365 std::string parser_prefix = std::string());
368 [[nodiscard]]
bool contains (std::string_view name)
const;
374 [[nodiscard]]
int countval (std::string_view name,
int n =
LAST)
const;
379 [[nodiscard]]
int countname (std::string_view name)
const;
391 void getkth (std::string_view name,
394 int ival =
FIRST)
const;
396 void get (std::string_view name,
398 int ival =
FIRST)
const;
406 int querykth (std::string_view name,
409 int ival =
FIRST)
const;
411 int query (std::string_view name,
413 int ival =
FIRST)
const;
415 void add (std::string_view name,
bool val);
425 void getkth (std::string_view name,
428 int ival =
FIRST)
const;
431 void get (std::string_view name,
433 int ival =
FIRST)
const;
441 int querykth (std::string_view name,
444 int ival =
FIRST)
const;
446 int query (std::string_view name,
448 int ival =
FIRST)
const;
450 void add (std::string_view name,
int val);
460 void getkth (std::string_view name,
463 int ival =
FIRST)
const;
465 void get (std::string_view name,
467 int ival =
FIRST)
const;
475 int querykth (std::string_view name,
478 int ival =
FIRST)
const;
480 int query (std::string_view name,
482 int ival =
FIRST)
const;
484 void add (std::string_view name,
long val);
494 void getkth (std::string_view name,
497 int ival =
FIRST)
const;
499 void get (std::string_view name,
501 int ival =
FIRST)
const;
509 int querykth (std::string_view name,
512 int ival =
FIRST)
const;
514 int query (std::string_view name,
516 int ival =
FIRST)
const;
518 void add (std::string_view name,
long long val);
528 void getkth (std::string_view name,
531 int ival =
FIRST)
const;
533 void get (std::string_view name,
535 int ival =
FIRST)
const;
543 int querykth (std::string_view name,
546 int ival =
FIRST)
const;
548 int query (std::string_view name,
550 int ival =
FIRST)
const;
552 void add (std::string_view name,
float val);
562 void getkth (std::string_view name,
565 int ival =
FIRST)
const;
567 void get (std::string_view name,
569 int ival =
FIRST)
const;
577 int querykth (std::string_view name,
580 int ival =
FIRST)
const;
582 int query (std::string_view name,
584 int ival =
FIRST)
const;
586 void add (std::string_view name,
double val);
596 void getkth (std::string_view name,
599 int ival =
FIRST)
const;
602 void get (std::string_view name,
604 int ival =
FIRST)
const;
612 int querykth (std::string_view name,
615 int ival =
FIRST)
const;
617 int query (std::string_view name,
619 int ival =
FIRST)
const;
621 void add (std::string_view name,
const std::string& val);
624 void add (std::string_view name,
const char* val) {
add(name, std::string(val)); }
634 void getline (std::string_view name, std::string& ref)
const;
644 int queryline (std::string_view name, std::string& ref)
const;
655 void getkth (std::string_view name,
658 int ival =
FIRST)
const;
660 void get (std::string_view name,
662 int ival =
FIRST)
const;
670 int querykth (std::string_view name,
673 int ival =
FIRST)
const;
675 int query (std::string_view name,
677 int ival =
FIRST)
const;
679 void add (std::string_view name,
const IntVect& val);
689 void getkth (std::string_view name,
692 int ival =
FIRST)
const;
694 void get (std::string_view name,
696 int ival =
FIRST)
const;
704 int querykth (std::string_view name,
707 int ival =
FIRST)
const;
709 int query (std::string_view name,
711 int ival =
FIRST)
const;
713 void add (std::string_view name,
const Box& val);
729 std::vector<int>& ref,
730 int start_ix =
FIRST,
731 int num_val =
ALL)
const;
733 void getarr (std::string_view name,
734 std::vector<int>& ref,
735 int start_ix =
FIRST,
736 int num_val =
ALL)
const;
740 std::vector<int>& ref,
741 int start_ix =
FIRST,
742 int num_val =
ALL)
const;
744 int queryarr (std::string_view name,
745 std::vector<int>& ref,
746 int start_ix =
FIRST,
747 int num_val =
ALL)
const;
749 void addarr (std::string_view name,
const std::vector<int>& ref);
766 std::vector<long>& ref,
767 int start_ix =
FIRST,
768 int num_val =
ALL)
const;
770 void getarr (std::string_view name,
771 std::vector<long>& ref,
772 int start_ix =
FIRST,
773 int num_val =
ALL)
const;
777 std::vector<long>& ref,
778 int start_ix =
FIRST,
779 int num_val =
ALL)
const;
781 int queryarr (std::string_view name,
782 std::vector<long>& ref,
783 int start_ix =
FIRST,
784 int num_val =
ALL)
const;
786 void addarr (std::string_view name,
const std::vector<long>& ref);
803 std::vector<long long>& ref,
804 int start_ix =
FIRST,
805 int num_val =
ALL)
const;
807 void getarr (std::string_view name,
808 std::vector<long long>& ref,
809 int start_ix =
FIRST,
810 int num_val =
ALL)
const;
814 std::vector<long long>& ref,
815 int start_ix =
FIRST,
816 int num_val =
ALL)
const;
818 int queryarr (std::string_view name,
819 std::vector<long long>& ref,
820 int start_ix =
FIRST,
821 int num_val =
ALL)
const;
823 void addarr (std::string_view name,
const std::vector<long long>& ref);
840 std::vector<float>& ref,
841 int start_ix =
FIRST,
842 int num_val =
ALL)
const;
844 void getarr (std::string_view name,
845 std::vector<float>& ref,
846 int start_ix =
FIRST,
847 int num_val =
ALL)
const;
851 std::vector<float>& ref,
852 int start_ix =
FIRST,
853 int num_val =
ALL)
const;
855 int queryarr (std::string_view name,
856 std::vector<float>& ref,
857 int start_ix =
FIRST,
858 int num_val =
ALL)
const;
860 void addarr (std::string_view name,
const std::vector<float>& ref);
876 std::vector<double>& ref,
877 int start_ix =
FIRST,
878 int num_val =
ALL)
const;
880 void getarr (std::string_view name,
881 std::vector<double>& ref,
882 int start_ix =
FIRST,
883 int num_val =
ALL)
const;
887 std::vector<double>& ref,
888 int start_ix =
FIRST,
889 int num_val =
ALL)
const;
891 int queryarr (std::string_view name,
892 std::vector<double>& ref,
893 int start_ix =
FIRST,
894 int num_val =
ALL)
const;
896 void addarr (std::string_view name,
const std::vector<double>& ref);
913 std::vector<std::string>& ref,
914 int start_ix =
FIRST,
915 int num_val =
ALL)
const;
917 void getarr (std::string_view name,
918 std::vector<std::string>& ref,
919 int start_ix =
FIRST,
920 int num_val =
ALL)
const;
924 std::vector<std::string>& ref,
925 int start_ix =
FIRST,
926 int num_val =
ALL)
const;
928 int queryarr (std::string_view name,
929 std::vector<std::string>& ref,
930 int start_ix =
FIRST,
931 int num_val =
ALL)
const;
933 void addarr (std::string_view name,
const std::vector<std::string>& ref);
950 std::vector<IntVect>& ref,
951 int start_ix =
FIRST,
952 int num_val =
ALL)
const;
954 void getarr (std::string_view name,
955 std::vector<IntVect>& ref,
956 int start_ix =
FIRST,
957 int num_val =
ALL)
const;
961 std::vector<IntVect>& ref,
962 int start_ix =
FIRST,
963 int num_val =
ALL)
const;
965 int queryarr (std::string_view name,
966 std::vector<IntVect>& ref,
967 int start_ix =
FIRST,
968 int num_val =
ALL)
const;
970 void addarr (std::string_view name,
const std::vector<IntVect>& ref);
987 std::vector<Box>& ref,
988 int start_ix =
FIRST,
989 int num_val =
ALL)
const;
991 void getarr (std::string_view name,
992 std::vector<Box>& ref,
993 int start_ix =
FIRST,
994 int num_val =
ALL)
const;
998 std::vector<Box>& ref,
999 int start_ix =
FIRST,
1000 int num_val =
ALL)
const;
1002 int queryarr (std::string_view name,
1003 std::vector<Box>& ref,
1004 int start_ix =
FIRST,
1005 int num_val =
ALL)
const;
1007 void addarr (std::string_view name,
const std::vector<Box>& ref);
1031 template <
typename T, std::
size_t N>
1032 void get (std::string_view name, std::array<T,N>& ref)
const {
1036 for (std::size_t i = 0; i < N; ++i) {
1041 template <
typename T, std::
size_t N>
1042 int query (std::string_view name, std::array<T,N>& ref)
const {
1044 int exist = this->
queryarr(name, v);
1047 for (std::size_t i = 0; i < N; ++i) {
1060 template <
typename T>
1062 int exist = this->
query(name, ref);
1064 this->
add(name, ref);
1069 int queryAdd (std::string_view name, std::string& ref) {
1070 int exist = this->
query(name, ref);
1071 if (!exist && !ref.empty()) {
1072 this->
add(name, ref);
1086 template <
typename T>
1087 int queryAdd (std::string_view name, std::vector<T>& ref) {
1088 std::vector<T> empty;
1089 int exist = this->
queryarr(name, empty);
1091 ref = std::move(empty);
1093 if (!exist && !ref.empty()) {
1099 template <
typename T>
1101 return this->
queryAdd(name,
static_cast<std::vector<T>&
>(ref));
1110 template <
typename T>
1111 int queryAdd (std::string_view name, std::vector<T>& ref,
int num_val) {
1112 int exist = this->
queryarr(name, ref, 0, num_val);
1125 template <
typename T, std::
size_t N>
1126 int queryAdd (std::string_view name, std::array<T,N>& ref) {
1128 int exist = this->
queryarr(name, v);
1131 for (std::size_t i = 0; i < N; ++i) {
1136 for (std::size_t i = 0; i < N; ++i) {
1169 template <
typename T>
1170 requires (std::same_as<T,bool> ||
1171 std::same_as<T,int> ||
1172 std::same_as<T,long> ||
1173 std::same_as<T,long long> ||
1174 std::same_as<T,float> ||
1175 std::same_as<T,double>)
1179 if (
int(ref.size()) < nvals) { ref.resize(nvals); }
1192 template <
typename T>
1193 requires (std::same_as<T,bool> ||
1194 std::same_as<T,int> ||
1195 std::same_as<T,long> ||
1196 std::same_as<T,long long> ||
1197 std::same_as<T,float> ||
1198 std::same_as<T,double>)
1203 this->
add(name, ref);
1213 template <
typename T>
1214 requires (std::same_as<T,bool> ||
1215 std::same_as<T,int> ||
1216 std::same_as<T,long> ||
1217 std::same_as<T,long long> ||
1218 std::same_as<T,float> ||
1219 std::same_as<T,double>)
1224 amrex::Error(std::string(
"ParmParse::getWithParser: failed to get ")+std::string(name));
1233 template <
typename T>
1234 requires (std::same_as<T,bool> ||
1235 std::same_as<T,int> ||
1236 std::same_as<T,long> ||
1237 std::same_as<T,long long> ||
1238 std::same_as<T,float> ||
1239 std::same_as<T,double>)
1244 amrex::Error(std::string(
"ParmParse::getarrWithParser: failed to get ")+std::string(name));
1253 template <
typename T>
1254 requires (std::same_as<T,bool> ||
1255 std::same_as<T,int> ||
1256 std::same_as<T,long> ||
1257 std::same_as<T,long long> ||
1258 std::same_as<T,float> ||
1259 std::same_as<T,double>)
1264 amrex::Error(std::string(
"ParmParse::getarrWithParser: failed to get ")+std::string(name));
1273 template <
typename T>
1274 requires (std::same_as<T,bool> ||
1275 std::same_as<T,int> ||
1276 std::same_as<T,long> ||
1277 std::same_as<T,long long> ||
1278 std::same_as<T,float> ||
1279 std::same_as<T,double>)
1280 T
eval (std::string
const& expr)
const
1282 if constexpr (std::is_integral_v<T>) {
1285 return static_cast<T
>(exe());
1287 auto const parser = this->
makeParser(expr, {});
1289 return static_cast<T
>(exe());
1299 template <
typename T>
1300 int query (
const char* new_name,
const char* old_name, T& ref)
1302 return (this->
query(new_name, ref) ||
1303 this->
query(old_name, ref));
1313 template <
typename T>
1314 void get (
const char* new_name,
const char* old_name, T& ref)
1316 auto exist = this->
query(new_name, old_name, ref);
1319 << new_name <<
" and " << old_name <<
'\n';
1333 template <
typename T,
typename ET = amrex_enum_traits<T>>
1334 requires (ET::value)
1335 int query (std::string_view name, T& ref,
int ival =
FIRST)
const
1338 int exist = this->
query(name,
s, ival);
1341 ref = amrex::getEnum<T>(
s);
1344 amrex::Print() <<
"amrex::ParmParse::query (input name: "
1356 template <
typename T,
typename ET = amrex_enum_traits<T>>
1357 requires (ET::value)
1358 void add (std::string_view name, T
const& val)
1371 template <
typename T,
typename ET = amrex_enum_traits<T>>
1372 requires (ET::value)
1373 void get (std::string_view name, T& ref,
int ival =
FIRST)
const
1376 this->
get(name,
s, ival);
1378 ref = amrex::getEnum<T>(
s);
1381 amrex::Print() <<
"amrex::ParmParse::get (input name: "
1389 template <
typename T,
typename ET = amrex_enum_traits<T>>
1390 requires (ET::value)
1392 std::vector<T>& ref,
1393 int start_ix =
FIRST,
1394 int num_val =
ALL)
const
1396 std::vector<std::string>
s;
1397 int exist = this->
queryarr(name,
s, start_ix, num_val);
1399 ref.resize(
s.size());
1400 for (std::size_t i = 0; i <
s.size(); ++i) {
1402 ref[i] = amrex::getEnum<T>(
s[i]);
1405 amrex::Print() <<
"amrex::ParmParse::queryarr (input name: "
1416 template <
typename T,
typename ET = amrex_enum_traits<T>>
1417 requires (ET::value)
1419 std::vector<T>& ref,
1420 int start_ix =
FIRST,
1421 int num_val =
ALL)
const
1423 std::vector<std::string>
s;
1424 this->
getarr(name,
s, start_ix, num_val);
1425 ref.resize(
s.size());
1426 for (std::size_t i = 0; i <
s.size(); ++i) {
1428 ref[i] = amrex::getEnum<T>(
s[i]);
1431 amrex::Print() <<
"amrex::ParmParse::getarr (input name: "
1449 template <
typename T,
typename ET = amrex_enum_traits<T>>
1450 requires (ET::value)
1454 int exist = this->
query(name,
s, ival);
1457 ref = amrex::getEnumCaseInsensitive<T>(
s);
1460 amrex::Print() <<
"amrex::ParmParse::query_enum_case_insensitive (input name: "
1479 template <
typename T,
typename ET = amrex_enum_traits<T>>
1480 requires (ET::value)
1485 std::string msg(
"get_enum_case_insensitive(\"");
1486 msg.append(name).append(
"\",").append(amrex::getEnumClassName<T>())
1487 .append(
"&) failed.");
1504 template <
typename T,
typename ET = amrex_enum_traits<T>>
1505 requires (ET::value)
1507 int ival =
FIRST)
const
1510 int exist = this->
query(name,
s, ival);
1513 std::erase_if(
s, [&] (
auto const& c) {
1514 return ignores.find(c) != std::string_view::npos;
1516 ref = amrex::getEnumCaseInsensitive<T>(
s);
1519 amrex::Print() <<
"amrex::ParmParse::query_enum_sloppy (input name: "
1540 template <
typename T,
typename ET = amrex_enum_traits<T>>
1541 requires (ET::value)
1543 int ival =
FIRST)
const
1547 std::string msg(
"get_enum_sloppy(\"");
1548 msg.append(name).append(
"\",").append(amrex::getEnumClassName<T>())
1549 .append(
"&) failed.");
1562 template <
typename T>
1563 requires (ppdetail::IsArithmeticOptional_v<T>)
1566 using value_type = ppdetail::underlying_type_t<T>;
1570 if constexpr (std::is_integral_v<value_type>) {
1571 dref = std::round(dref);
1573 if constexpr (std::is_integral_v<value_type> && !std::is_same_v<value_type,bool>) {
1576 constexpr double upper = 2.0 *
static_cast<double>(std::numeric_limits<value_type>::max()/2 + 1);
1577 if (!(dref >=
static_cast<double>(std::numeric_limits<value_type>::lowest()) &&
1582 ref =
static_cast<value_type
>(dref);
1595 template <
typename T>
1596 requires (ppdetail::IsArithmeticOptional_v<T>)
1599 using value_type = ppdetail::underlying_type_t<T>;
1600 std::vector<double> dref(nvals);
1603 for (
int i = 0; i < nvals; ++i) {
1604 if constexpr (std::is_integral_v<value_type>) {
1605 dref[i] = std::round(dref[i]);
1607 if constexpr (std::is_integral_v<value_type> && !std::is_same_v<value_type,bool>) {
1609 constexpr double upper = 2.0 *
static_cast<double>(std::numeric_limits<value_type>::max()/2 + 1);
1610 if (!(dref[i] >=
static_cast<double>(std::numeric_limits<value_type>::lowest()) &&
1612 amrex::Abort(
"ParmParse:: queryarrAsDouble is not safe");
1615 ptr[i] =
static_cast<value_type
>(dref[i]);
1629 template <
typename T>
1630 requires (ppdetail::IsArithmeticOptional_v<T>)
1635 amrex::Error(std::string(
"ParmParse::getAsDouble: failed to get ")+std::string(name));
1647 template <
typename T>
1648 requires (ppdetail::IsArithmeticOptional_v<T>)
1653 amrex::Error(std::string(
"ParmParse::getarrAsDouble: failed to get ")+std::string(name));
1658 int remove (std::string_view name);
1677 int querytable (std::string_view name, std::vector<std::vector<double>>& ref)
const;
1678 int querytable (std::string_view name, std::vector<std::vector<float>>& ref)
const;
1679 int querytable (std::string_view name, std::vector<std::vector<int>>& ref)
const;
1686 template <
typename T>
1687 void gettable (std::string_view name, std::vector<std::vector<T>>& ref)
const
1691 <<
" not found in database\n";
1702 int queryarr (std::string_view name, std::vector<std::vector<double>>& ref)
const;
1703 int queryarr (std::string_view name, std::vector<std::vector<float>>& ref)
const;
1704 int queryarr (std::string_view name, std::vector<std::vector<int>>& ref)
const;
1705 int queryarr (std::string_view name, std::vector<std::vector<std::string>>& ref)
const;
1711 template <
typename T>
1712 void getarr (std::string_view name, std::vector<std::vector<T>>& ref)
const
1714 if (this->
queryarr(name, ref) == 0) {
1716 <<
" not found in database\n";
1729 static void Initialize (
int argc,
char** argv,
const char* parfile);
1730 static void Initialize (
int argc,
char** argv,
const std::string& parfile) {
1748 static void dumpTable (std::ostream& os,
bool prettyPrint =
false);
1766 static void addfile (std::string
const& filename);
1771 [[nodiscard]]
static bool hasUnusedInputs (
const std::string& prefix = std::string());
1774 [[nodiscard]]
static std::vector<std::string>
getUnusedInputs (
const std::string& prefix = std::string());
1777 [[nodiscard]]
static std::set<std::string>
getEntries (
const std::string& prefix = std::string());
1790 std::vector<std::vector<std::string>>
m_vals;
1793 mutable std::variant<
1804 mutable std::vector<std::variant<bool, int, long, long long, float, double>>
m_last_vals;
1807 using Table = std::unordered_map<std::string, PP_entry>;
1819 [[nodiscard]] std::string
const&
getPrefix ()
const;
1821 [[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.
GpuArray< MultiArray4< Real const >, 3 > s
Definition AMReX_MLEBNodeFDLaplacian.cpp:214
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:354
QuoteType
Definition AMReX_ParmParse.H:1779
int queryline(std::string_view name, std::string &ref) const
Definition AMReX_ParmParse.cpp:2779
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:2794
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:1087
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:1061
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:1687
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:3079
int query(std::string_view name, std::array< T, N > &ref) const
Definition AMReX_ParmParse.H:1042
static std::string const UnsetKeyword
keyword for removing entries from the table
Definition AMReX_ParmParse.H:1815
static void prettyPrintTable(std::ostream &os)
Definition AMReX_ParmParse.cpp:1913
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:1711
static void addfile(std::string const &filename)
Definition AMReX_ParmParse.cpp:1681
static std::string const FileKeyword
keyword for files to load
Definition AMReX_ParmParse.H:1812
static std::string ParserPrefix
Definition AMReX_ParmParse.H:1817
static int Verbose()
Definition AMReX_ParmParse.cpp:1792
static void SetVerbose(int v)
Definition AMReX_ParmParse.cpp:1805
void get(const char *new_name, const char *old_name, T &ref)
Get using two names.
Definition AMReX_ParmParse.H:1314
static bool hasUnusedInputs(const std::string &prefix=std::string())
Any unused [prefix.]* parameters?
Definition AMReX_ParmParse.cpp:1743
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:1597
Parser makeParser(std::string const &func, Vector< std::string > const &vars) const
Definition AMReX_ParmParse.cpp:2997
int queryAdd(std::string_view name, std::string &ref)
Definition AMReX_ParmParse.H:1069
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:2086
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:1649
static bool QueryUnusedInputs()
Definition AMReX_ParmParse.cpp:1728
void getline(std::string_view name, std::string &ref) const
Definition AMReX_ParmParse.cpp:2771
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:2077
void add(std::string_view name, const char *val)
Convert const char * to string, to prevent auto-conversion to bool.
Definition AMReX_ParmParse.H:624
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:1984
bool contains(std::string_view name) const
Returns true if name is in table.
Definition AMReX_ParmParse.cpp:2810
void get(std::string_view name, std::array< T, N > &ref) const
Definition AMReX_ParmParse.H:1032
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:1712
static void prettyPrintUsedInputs(std::ostream &os)
Definition AMReX_ParmParse.cpp:1925
static void Finalize()
The destructor. The internal static table will only be deleted if there are no other ParmParse object...
Definition AMReX_ParmParse.cpp:1811
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:1111
std::string m_prefix
Definition AMReX_ParmParse.H:1825
const Table & table() const
Definition AMReX_ParmParse.H:1809
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:1199
T eval(std::string const &expr) const
Definition AMReX_ParmParse.H:1280
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:2001
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:1542
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:1451
static void SetParserPrefix(std::string a_prefix)
Set prefix used by math expression Parser.
Definition AMReX_ParmParse.cpp:1841
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:2925
static std::vector< std::string > getUnusedInputs(const std::string &prefix=std::string())
Returns unused [prefix.]* parameters.
Definition AMReX_ParmParse.cpp:1749
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:2105
std::string const & getPrefix() const
Definition AMReX_ParmParse.cpp:1661
int remove(std::string_view name)
Remove given name from the table.
Definition AMReX_ParmParse.cpp:2826
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:2096
@ FIRST
Definition AMReX_ParmParse.H:356
@ LAST
Definition AMReX_ParmParse.H:356
@ ALL
Definition AMReX_ParmParse.H:356
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:1506
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:1481
static void Initialize(int argc, char **argv, const std::string &parfile)
Definition AMReX_ParmParse.H:1730
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:1126
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:1240
int query(const char *new_name, const char *old_name, T &ref)
Definition AMReX_ParmParse.H:1300
Table * m_table
Definition AMReX_ParmParse.H:1827
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:2961
std::string m_parser_prefix
Definition AMReX_ParmParse.H:1826
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:2018
static void dumpTable(std::ostream &os, bool prettyPrint=false)
Definition AMReX_ParmParse.cpp:1849
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:2067
static void prettyPrintUnusedInputs(std::ostream &os)
Definition AMReX_ParmParse.cpp:1919
static std::set< std::string > getEntries(const std::string &prefix=std::string())
Returns [prefix.]* parameters.
Definition AMReX_ParmParse.cpp:1779
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:1564
std::string prefixedName(std::string_view str) const
Definition AMReX_ParmParse.cpp:1667
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:1631
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:2010
int queryAdd(std::string_view name, Vector< T > &ref)
Definition AMReX_ParmParse.H:1100
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:1993
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:1220
std::unordered_map< std::string, PP_entry > Table
Definition AMReX_ParmParse.H:1807
IParser makeIParser(std::string const &func, Vector< std::string > const &vars) const
Definition AMReX_ParmParse.cpp:3004
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:1931
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:994
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:238
int Verbose() noexcept
Return the verbosity level configured via ParmParse or SetVerbose().
Definition AMReX.cpp:184
void Abort(const std::string &msg)
Print a fatal-error message to stderr and abort execution.
Definition AMReX.cpp:244
Definition AMReX_ParmParse.H:1785
std::variant< std::string *, bool *, int *, long *, long long *, amrex::IntVect *, amrex::Box *, float *, double * > m_typehint
Definition AMReX_ParmParse.H:1803
std::vector< std::vector< std::string > > m_vals
Definition AMReX_ParmParse.H:1790
std::vector< std::vector< QuoteType > > m_quotes
Definition AMReX_ParmParse.H:1791
Long m_count
Definition AMReX_ParmParse.H:1792
std::vector< std::variant< bool, int, long, long long, float, double > > m_last_vals
Definition AMReX_ParmParse.H:1804
bool m_parsed
Definition AMReX_ParmParse.H:1805