1#ifndef AMREX_PARMPARSE_H_
2#define AMREX_PARMPARSE_H_
3#include <AMReX_Config.H>
25#include <unordered_map>
44 template <
class T,
class Enable =
void>
45 struct ArithmeticOptional_TT : std::false_type {};
48 requires (std::is_arithmetic_v<T>)
49 struct ArithmeticOptional_TT<T>
56 requires (std::is_arithmetic_v<T>)
57 struct ArithmeticOptional_TT<std::optional<T>>
64 inline constexpr bool IsArithmeticOptional_v = ArithmeticOptional_TT<T>::value;
67 using underlying_type_t =
typename ArithmeticOptional_TT<T>::value_type;
365 explicit ParmParse (std::string prefix = std::string(),
366 std::string parser_prefix = std::string());
369 [[nodiscard]]
bool contains (std::string_view name)
const;
375 [[nodiscard]]
int countval (std::string_view name,
int n =
LAST)
const;
380 [[nodiscard]]
int countname (std::string_view name)
const;
392 void getkth (std::string_view name,
395 int ival =
FIRST)
const;
397 void get (std::string_view name,
399 int ival =
FIRST)
const;
407 int querykth (std::string_view name,
410 int ival =
FIRST)
const;
412 int query (std::string_view name,
414 int ival =
FIRST)
const;
416 void add (std::string_view name,
bool val);
426 void getkth (std::string_view name,
429 int ival =
FIRST)
const;
432 void get (std::string_view name,
434 int ival =
FIRST)
const;
442 int querykth (std::string_view name,
445 int ival =
FIRST)
const;
447 int query (std::string_view name,
449 int ival =
FIRST)
const;
451 void add (std::string_view name,
int val);
461 void getkth (std::string_view name,
464 int ival =
FIRST)
const;
466 void get (std::string_view name,
468 int ival =
FIRST)
const;
476 int querykth (std::string_view name,
479 int ival =
FIRST)
const;
481 int query (std::string_view name,
483 int ival =
FIRST)
const;
485 void add (std::string_view name,
long val);
495 void getkth (std::string_view name,
498 int ival =
FIRST)
const;
500 void get (std::string_view name,
502 int ival =
FIRST)
const;
510 int querykth (std::string_view name,
513 int ival =
FIRST)
const;
515 int query (std::string_view name,
517 int ival =
FIRST)
const;
519 void add (std::string_view name,
long long val);
529 void getkth (std::string_view name,
532 int ival =
FIRST)
const;
534 void get (std::string_view name,
536 int ival =
FIRST)
const;
544 int querykth (std::string_view name,
547 int ival =
FIRST)
const;
549 int query (std::string_view name,
551 int ival =
FIRST)
const;
553 void add (std::string_view name,
float val);
563 void getkth (std::string_view name,
566 int ival =
FIRST)
const;
568 void get (std::string_view name,
570 int ival =
FIRST)
const;
578 int querykth (std::string_view name,
581 int ival =
FIRST)
const;
583 int query (std::string_view name,
585 int ival =
FIRST)
const;
587 void add (std::string_view name,
double val);
597 void getkth (std::string_view name,
600 int ival =
FIRST)
const;
603 void get (std::string_view name,
605 int ival =
FIRST)
const;
613 int querykth (std::string_view name,
616 int ival =
FIRST)
const;
618 int query (std::string_view name,
620 int ival =
FIRST)
const;
622 void add (std::string_view name,
const std::string& val);
625 void add (std::string_view name,
const char* val) {
add(name, std::string(val)); }
635 void getline (std::string_view name, std::string& ref)
const;
645 int queryline (std::string_view name, std::string& ref)
const;
656 void getkth (std::string_view name,
659 int ival =
FIRST)
const;
661 void get (std::string_view name,
663 int ival =
FIRST)
const;
671 int querykth (std::string_view name,
674 int ival =
FIRST)
const;
676 int query (std::string_view name,
678 int ival =
FIRST)
const;
680 void add (std::string_view name,
const IntVect& val);
690 void getkth (std::string_view name,
693 int ival =
FIRST)
const;
695 void get (std::string_view name,
697 int ival =
FIRST)
const;
705 int querykth (std::string_view name,
708 int ival =
FIRST)
const;
710 int query (std::string_view name,
712 int ival =
FIRST)
const;
714 void add (std::string_view name,
const Box& val);
730 std::vector<int>& ref,
731 int start_ix =
FIRST,
732 int num_val =
ALL)
const;
734 void getarr (std::string_view name,
735 std::vector<int>& ref,
736 int start_ix =
FIRST,
737 int num_val =
ALL)
const;
741 std::vector<int>& ref,
742 int start_ix =
FIRST,
743 int num_val =
ALL)
const;
745 int queryarr (std::string_view name,
746 std::vector<int>& ref,
747 int start_ix =
FIRST,
748 int num_val =
ALL)
const;
750 void addarr (std::string_view name,
const std::vector<int>& ref);
767 std::vector<long>& ref,
768 int start_ix =
FIRST,
769 int num_val =
ALL)
const;
771 void getarr (std::string_view name,
772 std::vector<long>& ref,
773 int start_ix =
FIRST,
774 int num_val =
ALL)
const;
778 std::vector<long>& ref,
779 int start_ix =
FIRST,
780 int num_val =
ALL)
const;
782 int queryarr (std::string_view name,
783 std::vector<long>& ref,
784 int start_ix =
FIRST,
785 int num_val =
ALL)
const;
787 void addarr (std::string_view name,
const std::vector<long>& ref);
804 std::vector<long long>& ref,
805 int start_ix =
FIRST,
806 int num_val =
ALL)
const;
808 void getarr (std::string_view name,
809 std::vector<long long>& ref,
810 int start_ix =
FIRST,
811 int num_val =
ALL)
const;
815 std::vector<long long>& ref,
816 int start_ix =
FIRST,
817 int num_val =
ALL)
const;
819 int queryarr (std::string_view name,
820 std::vector<long long>& ref,
821 int start_ix =
FIRST,
822 int num_val =
ALL)
const;
824 void addarr (std::string_view name,
const std::vector<long long>& ref);
841 std::vector<float>& ref,
842 int start_ix =
FIRST,
843 int num_val =
ALL)
const;
845 void getarr (std::string_view name,
846 std::vector<float>& ref,
847 int start_ix =
FIRST,
848 int num_val =
ALL)
const;
852 std::vector<float>& ref,
853 int start_ix =
FIRST,
854 int num_val =
ALL)
const;
856 int queryarr (std::string_view name,
857 std::vector<float>& ref,
858 int start_ix =
FIRST,
859 int num_val =
ALL)
const;
861 void addarr (std::string_view name,
const std::vector<float>& ref);
877 std::vector<double>& ref,
878 int start_ix =
FIRST,
879 int num_val =
ALL)
const;
881 void getarr (std::string_view name,
882 std::vector<double>& ref,
883 int start_ix =
FIRST,
884 int num_val =
ALL)
const;
888 std::vector<double>& ref,
889 int start_ix =
FIRST,
890 int num_val =
ALL)
const;
892 int queryarr (std::string_view name,
893 std::vector<double>& ref,
894 int start_ix =
FIRST,
895 int num_val =
ALL)
const;
897 void addarr (std::string_view name,
const std::vector<double>& ref);
914 std::vector<std::string>& ref,
915 int start_ix =
FIRST,
916 int num_val =
ALL)
const;
918 void getarr (std::string_view name,
919 std::vector<std::string>& ref,
920 int start_ix =
FIRST,
921 int num_val =
ALL)
const;
925 std::vector<std::string>& ref,
926 int start_ix =
FIRST,
927 int num_val =
ALL)
const;
929 int queryarr (std::string_view name,
930 std::vector<std::string>& ref,
931 int start_ix =
FIRST,
932 int num_val =
ALL)
const;
934 void addarr (std::string_view name,
const std::vector<std::string>& ref);
951 std::vector<IntVect>& ref,
952 int start_ix =
FIRST,
953 int num_val =
ALL)
const;
955 void getarr (std::string_view name,
956 std::vector<IntVect>& ref,
957 int start_ix =
FIRST,
958 int num_val =
ALL)
const;
962 std::vector<IntVect>& ref,
963 int start_ix =
FIRST,
964 int num_val =
ALL)
const;
966 int queryarr (std::string_view name,
967 std::vector<IntVect>& ref,
968 int start_ix =
FIRST,
969 int num_val =
ALL)
const;
971 void addarr (std::string_view name,
const std::vector<IntVect>& ref);
988 std::vector<Box>& ref,
989 int start_ix =
FIRST,
990 int num_val =
ALL)
const;
992 void getarr (std::string_view name,
993 std::vector<Box>& ref,
994 int start_ix =
FIRST,
995 int num_val =
ALL)
const;
999 std::vector<Box>& ref,
1000 int start_ix =
FIRST,
1001 int num_val =
ALL)
const;
1003 int queryarr (std::string_view name,
1004 std::vector<Box>& ref,
1005 int start_ix =
FIRST,
1006 int num_val =
ALL)
const;
1008 void addarr (std::string_view name,
const std::vector<Box>& ref);
1032 template <
typename T, std::
size_t N>
1033 void get (std::string_view name, std::array<T,N>& ref)
const {
1037 for (std::size_t i = 0; i < N; ++i) {
1042 template <
typename T, std::
size_t N>
1043 int query (std::string_view name, std::array<T,N>& ref)
const {
1045 int exist = this->
queryarr(name, v);
1048 for (std::size_t i = 0; i < N; ++i) {
1061 template <
typename T>
1063 int exist = this->
query(name, ref);
1065 this->
add(name, ref);
1070 int queryAdd (std::string_view name, std::string& ref) {
1071 int exist = this->
query(name, ref);
1072 if (!exist && !ref.empty()) {
1073 this->
add(name, ref);
1087 template <
typename T>
1088 int queryAdd (std::string_view name, std::vector<T>& ref) {
1089 std::vector<T> empty;
1090 int exist = this->
queryarr(name, empty);
1092 ref = std::move(empty);
1094 if (!exist && !ref.empty()) {
1100 template <
typename T>
1102 return this->
queryAdd(name,
static_cast<std::vector<T>&
>(ref));
1111 template <
typename T>
1112 int queryAdd (std::string_view name, std::vector<T>& ref,
int num_val) {
1113 int exist = this->
queryarr(name, ref, 0, num_val);
1126 template <
typename T, std::
size_t N>
1127 int queryAdd (std::string_view name, std::array<T,N>& ref) {
1129 int exist = this->
queryarr(name, v);
1132 for (std::size_t i = 0; i < N; ++i) {
1137 for (std::size_t i = 0; i < N; ++i) {
1170 template <
typename T>
1171 requires (std::same_as<T,bool> ||
1172 std::same_as<T,int> ||
1173 std::same_as<T,long> ||
1174 std::same_as<T,long long> ||
1175 std::same_as<T,float> ||
1176 std::same_as<T,double>)
1180 if (
int(ref.size()) < nvals) { ref.resize(nvals); }
1193 template <
typename T>
1194 requires (std::same_as<T,bool> ||
1195 std::same_as<T,int> ||
1196 std::same_as<T,long> ||
1197 std::same_as<T,long long> ||
1198 std::same_as<T,float> ||
1199 std::same_as<T,double>)
1204 this->
add(name, ref);
1214 template <
typename T>
1215 requires (std::same_as<T,bool> ||
1216 std::same_as<T,int> ||
1217 std::same_as<T,long> ||
1218 std::same_as<T,long long> ||
1219 std::same_as<T,float> ||
1220 std::same_as<T,double>)
1225 amrex::Error(std::string(
"ParmParse::getWithParser: failed to get ")+std::string(name));
1234 template <
typename T>
1235 requires (std::same_as<T,bool> ||
1236 std::same_as<T,int> ||
1237 std::same_as<T,long> ||
1238 std::same_as<T,long long> ||
1239 std::same_as<T,float> ||
1240 std::same_as<T,double>)
1245 amrex::Error(std::string(
"ParmParse::getarrWithParser: failed to get ")+std::string(name));
1254 template <
typename T>
1255 requires (std::same_as<T,bool> ||
1256 std::same_as<T,int> ||
1257 std::same_as<T,long> ||
1258 std::same_as<T,long long> ||
1259 std::same_as<T,float> ||
1260 std::same_as<T,double>)
1265 amrex::Error(std::string(
"ParmParse::getarrWithParser: failed to get ")+std::string(name));
1274 template <
typename T>
1275 requires (std::same_as<T,bool> ||
1276 std::same_as<T,int> ||
1277 std::same_as<T,long> ||
1278 std::same_as<T,long long> ||
1279 std::same_as<T,float> ||
1280 std::same_as<T,double>)
1281 [[nodiscard]] T
eval (std::string
const& expr)
const
1283 if constexpr (std::is_integral_v<T>) {
1286 auto const v = exe();
1287 if constexpr (!std::same_as<T,bool>) {
1288 if (!std::in_range<T>(v)) {
1289 amrex::Error(
"ParmParse::eval: "+expr+
" evaluates to "+std::to_string(v)
1290 +
", which is out of range for its type");
1293 return static_cast<T
>(v);
1295 auto const parser = this->
makeParser(expr, {});
1297 return static_cast<T
>(exe());
1307 template <
typename T>
1308 int query (
const char* new_name,
const char* old_name, T& ref)
1310 return (this->
query(new_name, ref) ||
1311 this->
query(old_name, ref));
1321 template <
typename T>
1322 void get (
const char* new_name,
const char* old_name, T& ref)
1324 auto exist = this->
query(new_name, old_name, ref);
1327 << new_name <<
" and " << old_name <<
'\n';
1341 template <
typename T,
typename ET = amrex_enum_traits<T>>
1342 requires (ET::value)
1343 int query (std::string_view name, T& ref,
int ival =
FIRST)
const
1346 int exist = this->
query(name, s, ival);
1352 amrex::Print() <<
"amrex::ParmParse::query (input name: "
1364 template <
typename T,
typename ET = amrex_enum_traits<T>>
1365 requires (ET::value)
1366 void add (std::string_view name, T
const& val)
1379 template <
typename T,
typename ET = amrex_enum_traits<T>>
1380 requires (ET::value)
1381 void get (std::string_view name, T& ref,
int ival =
FIRST)
const
1384 this->
get(name, s, ival);
1389 amrex::Print() <<
"amrex::ParmParse::get (input name: "
1398 template <
typename T,
typename ET = amrex_enum_traits<T>>
1399 requires (ET::value)
1401 std::vector<T>& ref,
1402 int start_ix =
FIRST,
1403 int num_val =
ALL)
const
1405 std::vector<std::string> s;
1406 int exist = this->
queryarr(name, s, start_ix, num_val);
1410 if (ref.size() < s.size()) { ref.resize(s.size()); }
1411 for (
auto i = std::size_t(start_ix); i < s.size(); ++i) {
1416 amrex::Print() <<
"amrex::ParmParse::queryarr (input name: "
1428 template <
typename T,
typename ET = amrex_enum_traits<T>>
1429 requires (ET::value)
1431 std::vector<T>& ref,
1432 int start_ix =
FIRST,
1433 int num_val =
ALL)
const
1435 std::vector<std::string> s;
1436 this->
getarr(name, s, start_ix, num_val);
1439 if (ref.size() < s.size()) { ref.resize(s.size()); }
1440 for (
auto i = std::size_t(start_ix); i < s.size(); ++i) {
1445 amrex::Print() <<
"amrex::ParmParse::getarr (input name: "
1463 template <
typename T,
typename ET = amrex_enum_traits<T>>
1464 requires (ET::value)
1468 int exist = this->
query(name, s, ival);
1474 amrex::Print() <<
"amrex::ParmParse::query_enum_case_insensitive (input name: "
1493 template <
typename T,
typename ET = amrex_enum_traits<T>>
1494 requires (ET::value)
1499 std::string msg(
"get_enum_case_insensitive(\"");
1501 .append(
"&) failed.");
1518 template <
typename T,
typename ET = amrex_enum_traits<T>>
1519 requires (ET::value)
1521 int ival =
FIRST)
const
1524 int exist = this->
query(name, s, ival);
1527 std::erase_if(s, [&] (
auto const& c) {
1528 return ignores.find(c) != std::string_view::npos;
1533 amrex::Print() <<
"amrex::ParmParse::query_enum_sloppy (input name: "
1554 template <
typename T,
typename ET = amrex_enum_traits<T>>
1555 requires (ET::value)
1557 int ival =
FIRST)
const
1561 std::string msg(
"get_enum_sloppy(\"");
1563 .append(
"&) failed.");
1576 template <
typename T>
1577 requires (ppdetail::IsArithmeticOptional_v<T>)
1580 using value_type = ppdetail::underlying_type_t<T>;
1584 if constexpr (std::is_integral_v<value_type>) {
1585 dref = std::round(dref);
1587 if constexpr (std::is_integral_v<value_type> && !std::is_same_v<value_type,bool>) {
1590 constexpr double upper = 2.0 *
static_cast<double>(std::numeric_limits<value_type>::max()/2 + 1);
1591 if (!(dref >=
static_cast<double>(std::numeric_limits<value_type>::lowest()) &&
1596 ref =
static_cast<value_type
>(dref);
1609 template <
typename T>
1610 requires (ppdetail::IsArithmeticOptional_v<T>)
1613 using value_type = ppdetail::underlying_type_t<T>;
1614 std::vector<double> dref(nvals);
1617 for (
int i = 0; i < nvals; ++i) {
1618 if constexpr (std::is_integral_v<value_type>) {
1619 dref[i] = std::round(dref[i]);
1621 if constexpr (std::is_integral_v<value_type> && !std::is_same_v<value_type,bool>) {
1623 constexpr double upper = 2.0 *
static_cast<double>(std::numeric_limits<value_type>::max()/2 + 1);
1624 if (!(dref[i] >=
static_cast<double>(std::numeric_limits<value_type>::lowest()) &&
1626 amrex::Abort(
"ParmParse:: queryarrAsDouble is not safe");
1629 ptr[i] =
static_cast<value_type
>(dref[i]);
1643 template <
typename T>
1644 requires (ppdetail::IsArithmeticOptional_v<T>)
1649 amrex::Error(std::string(
"ParmParse::getAsDouble: failed to get ")+std::string(name));
1661 template <
typename T>
1662 requires (ppdetail::IsArithmeticOptional_v<T>)
1667 amrex::Error(std::string(
"ParmParse::getarrAsDouble: failed to get ")+std::string(name));
1672 int remove (std::string_view name);
1691 int querytable (std::string_view name, std::vector<std::vector<double>>& ref)
const;
1692 int querytable (std::string_view name, std::vector<std::vector<float>>& ref)
const;
1693 int querytable (std::string_view name, std::vector<std::vector<int>>& ref)
const;
1700 template <
typename T>
1701 void gettable (std::string_view name, std::vector<std::vector<T>>& ref)
const
1705 <<
" not found in database\n";
1716 int queryarr (std::string_view name, std::vector<std::vector<double>>& ref)
const;
1717 int queryarr (std::string_view name, std::vector<std::vector<float>>& ref)
const;
1718 int queryarr (std::string_view name, std::vector<std::vector<int>>& ref)
const;
1719 int queryarr (std::string_view name, std::vector<std::vector<std::string>>& ref)
const;
1725 template <
typename T>
1726 void getarr (std::string_view name, std::vector<std::vector<T>>& ref)
const
1728 if (this->
queryarr(name, ref) == 0) {
1730 <<
" not found in database\n";
1743 static void Initialize (
int argc,
char** argv,
const char* parfile);
1744 static void Initialize (
int argc,
char** argv,
const std::string& parfile) {
1762 static void dumpTable (std::ostream& os,
bool prettyPrint =
false);
1781 static void addfile (std::string
const& filename);
1786 [[nodiscard]]
static bool hasUnusedInputs (
const std::string& prefix = std::string());
1789 [[nodiscard]]
static std::vector<std::string>
getUnusedInputs (
const std::string& prefix = std::string());
1792 [[nodiscard]]
static std::set<std::string>
getEntries (
const std::string& prefix = std::string());
1805 std::vector<std::vector<std::string>>
m_vals;
1808 mutable std::variant<
1819 mutable std::vector<std::variant<bool, int, long, long long, float, double>>
m_last_vals;
1822 using Table = std::unordered_map<std::string, PP_entry>;
1834 [[nodiscard]] std::string
const&
getPrefix ()
const;
1836 [[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.
A Rectangular Domain on an Integer Lattice.
Definition AMReX_Box.H:54
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
An Integer Vector in dim-Dimensional Space.
Definition AMReX_IntVect.H:156
QuoteType
Definition AMReX_ParmParse.H:1794
@ Triple
Definition AMReX_ParmParse.H:1797
@ None
Definition AMReX_ParmParse.H:1795
@ Double
Definition AMReX_ParmParse.H:1796
int queryline(std::string_view name, std::string &ref) const
Definition AMReX_ParmParse.cpp:2801
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:2816
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:1088
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:1062
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:1701
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:3101
int query(std::string_view name, std::array< T, N > &ref) const
Definition AMReX_ParmParse.H:1043
static std::string const UnsetKeyword
keyword for removing entries from the table
Definition AMReX_ParmParse.H:1830
static void prettyPrintTable(std::ostream &os)
Definition AMReX_ParmParse.cpp:1935
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:1733
static void addfile(std::string const &filename)
Definition AMReX_ParmParse.cpp:1702
@ FIRST
Definition AMReX_ParmParse.H:357
@ LAST
Definition AMReX_ParmParse.H:357
@ ALL
Definition AMReX_ParmParse.H:357
static std::string const FileKeyword
keyword for files to load
Definition AMReX_ParmParse.H:1827
static std::string ParserPrefix
Definition AMReX_ParmParse.H:1832
static int Verbose()
Definition AMReX_ParmParse.cpp:1814
static void SetVerbose(int v)
Definition AMReX_ParmParse.cpp:1827
void get(const char *new_name, const char *old_name, T &ref)
Get using two names.
Definition AMReX_ParmParse.H:1322
static bool hasUnusedInputs(const std::string &prefix=std::string())
Any unused [prefix.]* parameters?
Definition AMReX_ParmParse.cpp:1765
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:1611
Parser makeParser(std::string const &func, Vector< std::string > const &vars) const
Definition AMReX_ParmParse.cpp:3019
int queryAdd(std::string_view name, std::string &ref)
Definition AMReX_ParmParse.H:1070
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:2108
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:1663
static bool QueryUnusedInputs()
Definition AMReX_ParmParse.cpp:1750
void getline(std::string_view name, std::string &ref) const
Definition AMReX_ParmParse.cpp:2793
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:2099
void add(std::string_view name, const char *val)
Convert const char * to string, to prevent auto-conversion to bool.
Definition AMReX_ParmParse.H:625
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:2006
bool contains(std::string_view name) const
Returns true if name is in table.
Definition AMReX_ParmParse.cpp:2832
void get(std::string_view name, std::array< T, N > &ref) const
Definition AMReX_ParmParse.H:1033
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:1726
static void prettyPrintUsedInputs(std::ostream &os)
Definition AMReX_ParmParse.cpp:1947
static void Finalize()
The destructor. The internal static table will only be deleted if there are no other ParmParse object...
Definition AMReX_ParmParse.cpp:1833
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:1112
std::string m_prefix
Definition AMReX_ParmParse.H:1840
const Table & table() const
Definition AMReX_ParmParse.H:1824
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:1200
T eval(std::string const &expr) const
Definition AMReX_ParmParse.H:1281
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:2023
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:1556
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:1465
static void SetParserPrefix(std::string a_prefix)
Set prefix used by math expression Parser.
Definition AMReX_ParmParse.cpp:1863
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:2947
static std::vector< std::string > getUnusedInputs(const std::string &prefix=std::string())
Returns unused [prefix.]* parameters.
Definition AMReX_ParmParse.cpp:1771
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:2127
std::string const & getPrefix() const
Definition AMReX_ParmParse.cpp:1682
int remove(std::string_view name)
Remove given name from the table.
Definition AMReX_ParmParse.cpp:2848
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:2118
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:1520
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:1495
static void Initialize(int argc, char **argv, const std::string &parfile)
Definition AMReX_ParmParse.H:1744
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:1127
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:1241
int query(const char *new_name, const char *old_name, T &ref)
Definition AMReX_ParmParse.H:1308
Table * m_table
Definition AMReX_ParmParse.H:1842
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:2983
std::string m_parser_prefix
Definition AMReX_ParmParse.H:1841
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:2040
static void dumpTable(std::ostream &os, bool prettyPrint=false)
Definition AMReX_ParmParse.cpp:1871
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:2089
static void prettyPrintUnusedInputs(std::ostream &os)
Definition AMReX_ParmParse.cpp:1941
static std::set< std::string > getEntries(const std::string &prefix=std::string())
Returns [prefix.]* parameters.
Definition AMReX_ParmParse.cpp:1801
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:1578
std::string prefixedName(std::string_view str) const
Definition AMReX_ParmParse.cpp:1688
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:1645
ParmParse(std::string prefix=std::string(), std::string parser_prefix=std::string())
Construct an additional ParmParse object sharing the same internal table as any other such objects in...
Definition AMReX_ParmParse.cpp:50
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:2032
int queryAdd(std::string_view name, Vector< T > &ref)
Definition AMReX_ParmParse.H:1101
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:2015
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:1221
std::unordered_map< std::string, PP_entry > Table
Definition AMReX_ParmParse.H:1822
IParser makeIParser(std::string const &func, Vector< std::string > const &vars) const
Definition AMReX_ParmParse.cpp:3026
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:1953
Front-end for parsing scalar expressions into GPU/CPU executors.
Definition AMReX_Parser.H:160
ParserExecutor< N > compileHost() const
Compile the current expression into a host-only executor.
Definition AMReX_Parser.H:307
This class provides the user with a few print options.
Definition AMReX_Print.H:35
A Real vector in dim-dimensional space.
Definition AMReX_RealVect.H:34
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
T getEnum(std::string_view const &s)
Convert a string to an enum value.
Definition AMReX_Enum.H:117
std::string getEnumClassName()
Return the class name string of an AMREX_ENUM-declared enum type.
Definition AMReX_Enum.H:237
std::string getEnumNameString(T const &v)
Get the name string of an enum value.
Definition AMReX_Enum.H:190
T getEnumCaseInsensitive(std::string_view const &s)
Convert a string case-insensitively to an enum value.
Definition AMReX_Enum.H:153
Definition AMReX_Amr.cpp:50
std::ostream & ErrorStream()
Stream that receives diagnostic output (defaults to std::cerr).
Definition AMReX.cpp:966
BoxND< 3 > Box
Box is an alias for amrex::BoxND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:35
void Error(const std::string &msg)
Print a message to stderr and abort the program.
Definition AMReX.cpp:233
IntVectND< 3 > IntVect
IntVect is an alias for amrex::IntVectND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:38
int Verbose() noexcept
Return the verbosity level configured via ParmParse or SetVerbose().
Definition AMReX.cpp:179
void Abort(const std::string &msg)
Print a fatal-error message to stderr and abort execution.
Definition AMReX.cpp:239
RealVectND< 3 > RealVect
Definition AMReX_ParmParse.H:40
Definition AMReX_ParmParse.H:1800
std::variant< std::string *, bool *, int *, long *, long long *, amrex::IntVect *, amrex::Box *, float *, double * > m_typehint
Definition AMReX_ParmParse.H:1818
std::vector< std::vector< std::string > > m_vals
Definition AMReX_ParmParse.H:1805
std::vector< std::vector< QuoteType > > m_quotes
Definition AMReX_ParmParse.H:1806
Long m_count
Definition AMReX_ParmParse.H:1807
std::vector< std::variant< bool, int, long, long long, float, double > > m_last_vals
Definition AMReX_ParmParse.H:1819
bool m_parsed
Definition AMReX_ParmParse.H:1820