1 #ifndef AMREX_PARSER_Y_H_
2 #define AMREX_PARSER_Y_H_
3 #include <AMReX_Config.H>
17 #include <string_view>
18 #include <type_traits>
50 #if defined(__INTEL_COMPILER) && defined(__EDG__)
100 #if defined(__INTEL_COMPILER) && defined(__EDG__)
129 #if defined(__INTEL_COMPILER) && defined(__EDG__)
154 #if defined(__INTEL_COMPILER) && defined(__EDG__)
229 static_assert(
sizeof(
parser_f3) <=
sizeof(
parser_node),
"amrex parser: sizeof parser_node too small");
281 std::set<std::string>& local_symbols);
291 template <
typename T>
295 template <
typename T>
299 template <
typename T>
303 template <
typename T>
307 template <
typename T>
311 template <
typename T>
315 template <
typename T>
319 template <
typename T>
323 template <
typename T>
327 template <
typename T>
331 template <
typename T>
335 template <
typename T>
339 template <
typename T>
343 template <
typename T>
347 template <
typename T>
351 template <
typename T>
355 #if defined(__GNUC__) && !defined(__clang__) && !defined(__CUDA_ARCH__) && !defined(__NVCOMPILER)
358 return amrex::Math::comp_ellint_1<T>(k);
362 template <
typename T>
366 #if defined(__GNUC__) && !defined(__clang__) && !defined(__CUDA_ARCH__) && !defined(__NVCOMPILER)
369 return amrex::Math::comp_ellint_2<T>(k);
373 template <
typename T>
380 template <
typename T>
384 template <
typename T>
388 template <
typename T>
392 #if defined AMREX_USE_SYCL || defined __MINGW32__
408 case PARSER_EXP:
return parser_math_exp<double>(a);
409 case PARSER_LOG:
return parser_math_log<double>(a);
411 case PARSER_SIN:
return parser_math_sin<double>(a);
412 case PARSER_COS:
return parser_math_cos<double>(a);
413 case PARSER_TAN:
return parser_math_tan<double>(a);
414 case PARSER_ASIN:
return parser_math_asin<double>(a);
415 case PARSER_ACOS:
return parser_math_acos<double>(a);
416 case PARSER_ATAN:
return parser_math_atan<double>(a);
417 case PARSER_SINH:
return parser_math_sinh<double>(a);
418 case PARSER_COSH:
return parser_math_cosh<double>(a);
419 case PARSER_TANH:
return parser_math_tanh<double>(a);
428 case PARSER_ERF:
return parser_math_erf<double>(a);
440 return parser_math_pow<double>(a,
b);
442 return parser_math_atan2<double>(a,
b);
444 return (a >
b) ? 1.0 : 0.0;
446 return (a <
b) ? 1.0 : 0.0;
448 return (a >=
b) ? 1.0 : 0.0;
450 return (a <=
b) ? 1.0 : 0.0;
452 return (a ==
b) ? 1.0 : 0.0;
454 return (a !=
b) ? 1.0 : 0.0;
456 return ((a != 0.0) && (
b != 0.0)) ? 1.0 : 0.0;
458 return ((a != 0.0) || (
b != 0.0)) ? 1.0 : 0.0;
460 return (a < 0.0) ? 0.0 : ((a > 0.0) ? 1.0 :
b);
462 return parser_math_jn<double>(
int(a),
b);
464 return (a <
b) ? a :
b;
466 return (a >
b) ? a :
b;
468 return std::fmod(a,
b);
479 return (a != 0.0) ?
b : c;
#define AMREX_ALWAYS_ASSERT_WITH_MESSAGE(EX, MSG)
Definition: AMReX_BLassert.H:49
#define AMREX_NO_INLINE
Definition: AMReX_Extension.H:136
#define AMREX_FORCE_INLINE
Definition: AMReX_Extension.H:119
#define AMREX_GPU_HOST_DEVICE
Definition: AMReX_GpuQualifiers.H:20
void amrex_parsererror(char const *s,...)
Definition: AMReX_Parser_Y.cpp:10
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T comp_ellint_1(T k)
Definition: AMReX_Math.H:231
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T comp_ellint_2(T k)
Definition: AMReX_Math.H:256
Definition: AMReX_Amr.cpp:49
parser_f2_t
Definition: AMReX_Parser_Y.H:81
@ PARSER_LT
Definition: AMReX_Parser_Y.H:85
@ PARSER_AND
Definition: AMReX_Parser_Y.H:90
@ PARSER_NEQ
Definition: AMReX_Parser_Y.H:89
@ PARSER_OR
Definition: AMReX_Parser_Y.H:91
@ PARSER_ATAN2
Definition: AMReX_Parser_Y.H:83
@ PARSER_LEQ
Definition: AMReX_Parser_Y.H:87
@ PARSER_GEQ
Definition: AMReX_Parser_Y.H:86
@ PARSER_POW
Definition: AMReX_Parser_Y.H:82
@ PARSER_JN
Definition: AMReX_Parser_Y.H:93
@ PARSER_MIN
Definition: AMReX_Parser_Y.H:94
@ PARSER_GT
Definition: AMReX_Parser_Y.H:84
@ PARSER_MAX
Definition: AMReX_Parser_Y.H:95
@ PARSER_FMOD
Definition: AMReX_Parser_Y.H:96
@ PARSER_HEAVISIDE
Definition: AMReX_Parser_Y.H:92
@ PARSER_EQ
Definition: AMReX_Parser_Y.H:88
void parser_set_number(struct parser_node *node, double v)
Definition: AMReX_Parser_Y.cpp:1665
struct parser_node * parser_newf2(enum parser_f2_t ftype, struct parser_node *l, struct parser_node *r)
Definition: AMReX_Parser_Y.cpp:99
void parser_regvar(struct amrex_parser *parser, char const *name, int i)
Definition: AMReX_Parser_Y.cpp:1619
AMREX_GPU_HOST_DEVICE AMREX_NO_INLINE T parser_math_cosh(T a)
Definition: AMReX_Parser_Y.H:333
AMREX_GPU_HOST_DEVICE AMREX_NO_INLINE T parser_math_sinh(T a)
Definition: AMReX_Parser_Y.H:329
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE double parser_call_f1(enum parser_f1_t type, double a)
Definition: AMReX_Parser_Y.H:404
parser_f3_t
Definition: AMReX_Parser_Y.H:124
@ PARSER_IF
Definition: AMReX_Parser_Y.H:125
AMREX_GPU_HOST_DEVICE AMREX_NO_INLINE T parser_math_atan(T a)
Definition: AMReX_Parser_Y.H:325
void amrex_parser_delete(struct amrex_parser *parser)
Definition: AMReX_Parser_Y.cpp:170
void parser_ast_sort(struct parser_node *node)
Definition: AMReX_Parser_Y.cpp:1456
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE GpuComplex< T > log(const GpuComplex< T > &a_z) noexcept
Complex natural logarithm function.
Definition: AMReX_GpuComplex.H:408
parser_f1_t
Definition: AMReX_Parser_Y.H:24
@ PARSER_ASINH
Definition: AMReX_Parser_Y.H:38
@ PARSER_TANH
Definition: AMReX_Parser_Y.H:37
@ PARSER_COS
Definition: AMReX_Parser_Y.H:30
@ PARSER_COSH
Definition: AMReX_Parser_Y.H:36
@ PARSER_COMP_ELLINT_1
Definition: AMReX_Parser_Y.H:44
@ PARSER_SQRT
Definition: AMReX_Parser_Y.H:25
@ PARSER_COMP_ELLINT_2
Definition: AMReX_Parser_Y.H:45
@ PARSER_TAN
Definition: AMReX_Parser_Y.H:31
@ PARSER_ACOS
Definition: AMReX_Parser_Y.H:33
@ PARSER_ATANH
Definition: AMReX_Parser_Y.H:40
@ PARSER_EXP
Definition: AMReX_Parser_Y.H:26
@ PARSER_LOG
Definition: AMReX_Parser_Y.H:27
@ PARSER_SIN
Definition: AMReX_Parser_Y.H:29
@ PARSER_ERF
Definition: AMReX_Parser_Y.H:46
@ PARSER_ASIN
Definition: AMReX_Parser_Y.H:32
@ PARSER_CEIL
Definition: AMReX_Parser_Y.H:43
@ PARSER_ATAN
Definition: AMReX_Parser_Y.H:34
@ PARSER_ABS
Definition: AMReX_Parser_Y.H:41
@ PARSER_ACOSH
Definition: AMReX_Parser_Y.H:39
@ PARSER_LOG10
Definition: AMReX_Parser_Y.H:28
@ PARSER_FLOOR
Definition: AMReX_Parser_Y.H:42
@ PARSER_SINH
Definition: AMReX_Parser_Y.H:35
void parser_setconst(struct amrex_parser *parser, char const *name, double c)
Definition: AMReX_Parser_Y.cpp:1625
void parser_ast_setconst(struct parser_node *node, char const *name, double c)
Definition: AMReX_Parser_Y.cpp:1539
AMREX_GPU_HOST_DEVICE AMREX_NO_INLINE T parser_math_jn(int a, T b)
Definition: AMReX_Parser_Y.H:390
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T abs(const GpuComplex< T > &a_z) noexcept
Return the absolute value of a complex number.
Definition: AMReX_GpuComplex.H:356
int parser_depth(struct amrex_parser *parser)
Definition: AMReX_Parser_Y.cpp:1654
void parser_print(struct amrex_parser *parser)
Definition: AMReX_Parser_Y.cpp:1633
struct parser_node * parser_newnode(enum parser_node_t type, struct parser_node *l, struct parser_node *r)
Definition: AMReX_Parser_Y.cpp:46
struct parser_node * parser_newneg(struct parser_node *n)
Definition: AMReX_Parser_Y.cpp:62
void parser_ast_optimize(struct parser_node *node)
Definition: AMReX_Parser_Y.cpp:678
AMREX_GPU_HOST_DEVICE AMREX_NO_INLINE T parser_math_tan(T a)
Definition: AMReX_Parser_Y.H:313
struct parser_node * parser_newassign(struct parser_symbol *sym, struct parser_node *v)
Definition: AMReX_Parser_Y.cpp:123
AMREX_GPU_HOST_DEVICE AMREX_NO_INLINE T parser_math_sin(T a)
Definition: AMReX_Parser_Y.H:305
struct parser_node * parser_newf3(enum parser_f3_t ftype, struct parser_node *n1, struct parser_node *n2, struct parser_node *n3)
Definition: AMReX_Parser_Y.cpp:110
int parser_ast_depth(struct parser_node *node)
Definition: AMReX_Parser_Y.cpp:1413
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T parser_math_comp_ellint_1(T k)
Definition: AMReX_Parser_Y.H:353
static constexpr std::string_view parser_f3_s[]
Definition: AMReX_Parser_Y.H:134
std::size_t parser_ast_size(struct parser_node *node)
Definition: AMReX_Parser_Y.cpp:211
void parser_ast_print(struct parser_node *node, std::string const &space, std::ostream &printer)
Definition: AMReX_Parser_Y.cpp:1371
static constexpr std::string_view parser_node_s[]
Definition: AMReX_Parser_Y.H:159
AMREX_GPU_HOST_DEVICE AMREX_NO_INLINE T parser_math_exp(T a)
Definition: AMReX_Parser_Y.H:293
AMREX_GPU_HOST_DEVICE AMREX_NO_INLINE T parser_math_asin(T a)
Definition: AMReX_Parser_Y.H:317
double parser_get_number(struct parser_node *node)
Definition: AMReX_Parser_Y.cpp:1659
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void ignore_unused(const Ts &...)
This shuts up the compiler about unused variables.
Definition: AMReX.H:111
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE double parser_call_f2(enum parser_f2_t type, double a, double b)
Definition: AMReX_Parser_Y.H:436
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T parser_math_comp_ellint_2(T k)
Definition: AMReX_Parser_Y.H:364
AMREX_GPU_HOST_DEVICE AMREX_NO_INLINE T parser_math_tanh(T a)
Definition: AMReX_Parser_Y.H:337
std::set< std::string > parser_get_symbols(struct amrex_parser *parser)
Definition: AMReX_Parser_Y.cpp:1642
AMREX_GPU_HOST_DEVICE AMREX_NO_INLINE T parser_math_pow(T a, T b)
Definition: AMReX_Parser_Y.H:382
bool parser_node_equal(struct parser_node *a, struct parser_node *b)
Definition: AMReX_Parser_Y.cpp:636
AMREX_GPU_HOST_DEVICE AMREX_NO_INLINE T parser_math_log10(T a)
Definition: AMReX_Parser_Y.H:301
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE GpuComplex< T > pow(const GpuComplex< T > &a_z, const T &a_y) noexcept
Raise a complex number to a (real) power.
Definition: AMReX_GpuComplex.H:418
AMREX_GPU_HOST_DEVICE AMREX_NO_INLINE T parser_math_log(T a)
Definition: AMReX_Parser_Y.H:297
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE double parser_call_f3(enum parser_f3_t, double a, double b, double c)
Definition: AMReX_Parser_Y.H:476
AMREX_GPU_HOST_DEVICE AMREX_NO_INLINE T parser_math_atanh(T a)
Definition: AMReX_Parser_Y.H:349
void Abort(const std::string &msg)
Print out message to cerr and exit via abort().
Definition: AMReX.cpp:225
struct parser_node * parser_ast_dup(struct amrex_parser *my_parser, struct parser_node *node, int move)
Definition: AMReX_Parser_Y.cpp:260
AMREX_GPU_HOST_DEVICE AMREX_NO_INLINE T parser_math_asinh(T a)
Definition: AMReX_Parser_Y.H:341
void parser_defexpr(struct parser_node *body)
Definition: AMReX_Parser_Y.cpp:28
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE GpuComplex< T > exp(const GpuComplex< T > &a_z) noexcept
Complex expotential function.
Definition: AMReX_GpuComplex.H:334
struct parser_node * parser_newsymbol(struct parser_symbol *symbol)
Definition: AMReX_Parser_Y.cpp:83
parser_node_t
Definition: AMReX_Parser_Y.H:139
@ PARSER_SYMBOL
Definition: AMReX_Parser_Y.H:141
@ PARSER_MUL
Definition: AMReX_Parser_Y.H:144
@ PARSER_SUB
Definition: AMReX_Parser_Y.H:143
@ PARSER_F1
Definition: AMReX_Parser_Y.H:146
@ PARSER_LIST
Definition: AMReX_Parser_Y.H:150
@ PARSER_DIV
Definition: AMReX_Parser_Y.H:145
@ PARSER_ADD
Definition: AMReX_Parser_Y.H:142
@ PARSER_ASSIGN
Definition: AMReX_Parser_Y.H:149
@ PARSER_F3
Definition: AMReX_Parser_Y.H:148
@ PARSER_NUMBER
Definition: AMReX_Parser_Y.H:140
@ PARSER_F2
Definition: AMReX_Parser_Y.H:147
AMREX_GPU_HOST_DEVICE AMREX_NO_INLINE T parser_math_erf(T a)
Definition: AMReX_Parser_Y.H:375
AMREX_GPU_HOST_DEVICE AMREX_NO_INLINE T parser_math_cos(T a)
Definition: AMReX_Parser_Y.H:309
AMREX_GPU_HOST_DEVICE AMREX_NO_INLINE T parser_math_acosh(T a)
Definition: AMReX_Parser_Y.H:345
void parser_ast_get_symbols(struct parser_node *node, std::set< std::string > &symbols, std::set< std::string > &local_symbols)
Definition: AMReX_Parser_Y.cpp:1579
struct parser_symbol * parser_makesymbol(char *name)
Definition: AMReX_Parser_Y.cpp:34
static constexpr std::string_view parser_f2_s[]
Definition: AMReX_Parser_Y.H:105
AMREX_GPU_HOST_DEVICE AMREX_NO_INLINE T parser_math_atan2(T a, T b)
Definition: AMReX_Parser_Y.H:386
struct amrex_parser * amrex_parser_new()
Definition: AMReX_Parser_Y.cpp:149
static constexpr std::string_view parser_f1_s[]
Definition: AMReX_Parser_Y.H:55
void parser_ast_regvar(struct parser_node *node, char const *name, int i)
Definition: AMReX_Parser_Y.cpp:1500
AMREX_GPU_HOST_DEVICE AMREX_NO_INLINE T parser_math_acos(T a)
Definition: AMReX_Parser_Y.H:321
struct amrex_parser * parser_dup(struct amrex_parser *source)
Definition: AMReX_Parser_Y.cpp:198
struct parser_node * parser_newnumber(double d)
Definition: AMReX_Parser_Y.cpp:72
struct parser_node * parser_newf1(enum parser_f1_t ftype, struct parser_node *l)
Definition: AMReX_Parser_Y.cpp:89
struct parser_node * parser_newlist(struct parser_node *nl, struct parser_node *nr)
Definition: AMReX_Parser_Y.cpp:133
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE GpuComplex< T > sqrt(const GpuComplex< T > &a_z) noexcept
Return the square root of a complex number.
Definition: AMReX_GpuComplex.H:373
Definition: AMReX_Parser_Y.H:255
void * p_root
Definition: AMReX_Parser_Y.H:256
void * p_free
Definition: AMReX_Parser_Y.H:257
std::size_t sz_mempool
Definition: AMReX_Parser_Y.H:259
struct parser_node * ast
Definition: AMReX_Parser_Y.H:258
Definition: AMReX_Parser_Y.H:223
struct parser_node * v
Definition: AMReX_Parser_Y.H:226
struct parser_symbol * s
Definition: AMReX_Parser_Y.H:225
Definition: AMReX_Parser_Y.H:199
struct parser_node * padding1
Definition: AMReX_Parser_Y.H:203
struct parser_node * l
Definition: AMReX_Parser_Y.H:202
Definition: AMReX_Parser_Y.H:207
struct parser_node * l
Definition: AMReX_Parser_Y.H:210
struct parser_node * r
Definition: AMReX_Parser_Y.H:211
Definition: AMReX_Parser_Y.H:215
struct parser_node * n3
Definition: AMReX_Parser_Y.H:220
struct parser_node * n1
Definition: AMReX_Parser_Y.H:218
struct parser_node * n2
Definition: AMReX_Parser_Y.H:219
Definition: AMReX_Parser_Y.H:180
struct parser_node * l
Definition: AMReX_Parser_Y.H:183
struct parser_node * padding2
Definition: AMReX_Parser_Y.H:185
enum parser_node_t padding
Definition: AMReX_Parser_Y.H:182
struct parser_node * r
Definition: AMReX_Parser_Y.H:184
enum parser_node_t type
Definition: AMReX_Parser_Y.H:181
Definition: AMReX_Parser_Y.H:188
Definition: AMReX_Parser_Y.H:193
char * name
Definition: AMReX_Parser_Y.H:195