diff --git a/Docs/sphinx_documentation/source/Basics.rst b/Docs/sphinx_documentation/source/Basics.rst index 2de0afae59..2eea502d2c 100644 --- a/Docs/sphinx_documentation/source/Basics.rst +++ b/Docs/sphinx_documentation/source/Basics.rst @@ -595,7 +595,7 @@ numbers can be computed with ``min`` and ``max``, respectively. It supports the Heaviside step function, ``heaviside(x1,x2)`` that gives ``0``, ``x2``, ``1``, for ``x1 < 0``, ``x1 = 0`` and ``x1 > 0``, respectively. It supports the Bessel function of the first kind of order ``n`` -``jn(n,x)``. Complete elliptic integrals of the first and second kind, ``comp_ellint_1(k)`` and ``comp_ellint_2(k)``, +``jn(n,x)``, and the Bessel function of the second kind of order ``n`` ``yn(n,x)``. Complete elliptic integrals of the first and second kind, ``comp_ellint_1(k)`` and ``comp_ellint_2(k)``, are supported. There is ``if(a,b,c)`` that gives ``b`` or ``c`` depending on the value of ``a``. A number of comparison operators are supported, including ``<``, diff --git a/Src/Base/Parser/AMReX_Parser_Y.H b/Src/Base/Parser/AMReX_Parser_Y.H index 0f4f4470b0..ac6023cf26 100644 --- a/Src/Base/Parser/AMReX_Parser_Y.H +++ b/Src/Base/Parser/AMReX_Parser_Y.H @@ -91,6 +91,7 @@ enum parser_f2_t { // Built-in functions with two arguments PARSER_OR, PARSER_HEAVISIDE, PARSER_JN, + PARSER_YN, PARSER_MIN, PARSER_MAX, PARSER_FMOD @@ -116,6 +117,7 @@ std::string_view parser_f2_s[] = "or", "heaviside", "jn", + "yn", "min", "max", "fmod" @@ -400,6 +402,21 @@ T parser_math_jn (int a, T b) #endif } +template +AMREX_GPU_HOST_DEVICE AMREX_NO_INLINE +T parser_math_yn (int a, T b) +{ +#if defined AMREX_USE_SYCL || defined __MINGW32__ + amrex::ignore_unused(a,b); + // neither yn(f) nor std::cyl_bessel_y work yet + // https://github.com/oneapi-src/oneAPI-spec/issues/308 + AMREX_ALWAYS_ASSERT_WITH_MESSAGE(false, "parser: yn in SYCL not supported yet"); + return 0.0; +#else + return yn(a, b); +#endif +} + AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE double parser_call_f1 (enum parser_f1_t type, double a) { @@ -460,6 +477,8 @@ parser_call_f2 (enum parser_f2_t type, double a, double b) return (a < 0.0) ? 0.0 : ((a > 0.0) ? 1.0 : b); case PARSER_JN: return parser_math_jn(int(a),b); + case PARSER_YN: + return parser_math_yn(int(a),b); case PARSER_MIN: return (a < b) ? a : b; case PARSER_MAX: diff --git a/Src/Base/Parser/amrex_parser.l b/Src/Base/Parser/amrex_parser.l index e619bd077f..a9b05093e9 100644 --- a/Src/Base/Parser/amrex_parser.l +++ b/Src/Base/Parser/amrex_parser.l @@ -70,6 +70,7 @@ EXP ([Ee][-+]?[0-9]+) "pow" { amrex_parserlval.f2 = amrex::PARSER_POW; return F2; } "heaviside" { amrex_parserlval.f2 = amrex::PARSER_HEAVISIDE; return F2; } "jn" { amrex_parserlval.f2 = amrex::PARSER_JN; return F2; } +"yn" { amrex_parserlval.f2 = amrex::PARSER_YN; return F2; } "min" { amrex_parserlval.f2 = amrex::PARSER_MIN; return F2; } "max" { amrex_parserlval.f2 = amrex::PARSER_MAX; return F2; } "fmod" { amrex_parserlval.f2 = amrex::PARSER_FMOD; return F2; } diff --git a/Src/Base/Parser/amrex_parser.lex.nolint.H b/Src/Base/Parser/amrex_parser.lex.nolint.H index a3cb9ad883..904c5c6547 100644 --- a/Src/Base/Parser/amrex_parser.lex.nolint.H +++ b/Src/Base/Parser/amrex_parser.lex.nolint.H @@ -611,8 +611,8 @@ static void yynoreturn yy_fatal_error ( const char* msg ); (yy_hold_char) = *yy_cp; \ *yy_cp = '\0'; \ (yy_c_buf_p) = yy_cp; -#define YY_NUM_RULES 59 -#define YY_END_OF_BUFFER 60 +#define YY_NUM_RULES 60 +#define YY_END_OF_BUFFER 61 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -620,23 +620,23 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static const flex_int16_t yy_accept[136] = +static const flex_int16_t yy_accept[138] = { 0, - 0, 0, 60, 58, 55, 57, 58, 10, 11, 3, - 1, 6, 2, 58, 4, 53, 9, 7, 5, 8, - 51, 58, 36, 51, 51, 51, 51, 51, 51, 51, - 51, 51, 51, 51, 51, 51, 41, 35, 53, 54, - 52, 53, 0, 39, 40, 38, 51, 56, 51, 51, - 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, - 51, 50, 46, 51, 51, 51, 43, 51, 51, 51, - 51, 54, 52, 0, 0, 53, 28, 51, 42, 51, - 51, 51, 51, 17, 34, 13, 51, 51, 51, 51, - 14, 48, 47, 44, 16, 51, 18, 0, 52, 20, - - 19, 21, 31, 51, 23, 29, 51, 49, 51, 51, - 22, 12, 24, 26, 25, 37, 27, 51, 30, 51, - 15, 51, 51, 51, 51, 51, 51, 51, 45, 51, - 51, 51, 32, 33, 0 + 0, 0, 61, 59, 56, 58, 59, 10, 11, 3, + 1, 6, 2, 59, 4, 54, 9, 7, 5, 8, + 52, 59, 36, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 41, 35, 54, + 55, 53, 54, 0, 39, 40, 38, 52, 57, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 51, 46, 52, 52, 52, 43, 52, 52, + 52, 52, 47, 55, 53, 0, 0, 54, 28, 52, + 42, 52, 52, 52, 52, 17, 34, 13, 52, 52, + 52, 52, 14, 49, 48, 44, 16, 52, 18, 0, + + 53, 20, 19, 21, 31, 52, 23, 29, 52, 50, + 52, 52, 22, 12, 24, 26, 25, 37, 27, 52, + 30, 52, 15, 52, 52, 52, 52, 52, 52, 52, + 45, 52, 52, 52, 32, 33, 0 } ; static const YY_CHAR yy_ec[256] = @@ -654,7 +654,7 @@ static const YY_CHAR yy_ec[256] = 30, 31, 32, 33, 34, 35, 21, 36, 37, 38, 39, 40, 41, 42, 43, 44, 21, 45, 46, 47, - 21, 21, 1, 1, 1, 1, 1, 1, 1, 1, + 48, 21, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -671,113 +671,115 @@ static const YY_CHAR yy_ec[256] = 1, 1, 1, 1, 1 } ; -static const YY_CHAR yy_meta[48] = +static const YY_CHAR yy_meta[49] = { 0, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 3, 1, 3, 3, 3, 3, 1, 1, 1, 1, 3, 3, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3 + 3, 3, 3, 3, 3, 3, 3, 3 } ; -static const flex_int16_t yy_base[138] = +static const flex_int16_t yy_base[140] = { 0, - 0, 0, 201, 202, 202, 202, 181, 202, 202, 192, - 202, 202, 202, 35, 186, 41, 202, 178, 177, 176, - 0, 191, 202, 31, 23, 18, 40, 163, 161, 153, - 151, 38, 147, 149, 27, 161, 202, 202, 65, 0, - 69, 87, 97, 202, 202, 202, 0, 202, 143, 146, - 155, 149, 156, 147, 30, 149, 139, 151, 138, 137, - 149, 0, 0, 142, 126, 134, 0, 125, 132, 127, - 130, 0, 105, 115, 123, 127, 0, 124, 0, 128, - 127, 128, 123, 129, 0, 0, 118, 121, 130, 113, - 143, 0, 0, 0, 123, 111, 120, 131, 135, 101, - - 100, 55, 0, 107, 0, 0, 84, 0, 90, 109, - 0, 0, 0, 0, 0, 0, 0, 86, 0, 72, - 0, 78, 74, 70, 75, 63, 66, 56, 0, 49, - 67, 75, 0, 0, 202, 83, 151 + 0, 0, 203, 204, 204, 204, 183, 204, 204, 194, + 204, 204, 204, 36, 188, 42, 204, 180, 179, 178, + 0, 193, 204, 32, 24, 19, 41, 165, 163, 155, + 153, 39, 149, 151, 28, 163, 150, 204, 204, 66, + 0, 70, 88, 98, 204, 204, 204, 0, 204, 144, + 147, 156, 150, 157, 148, 31, 150, 140, 152, 139, + 138, 150, 0, 0, 143, 127, 135, 0, 126, 133, + 128, 131, 0, 0, 106, 116, 124, 128, 0, 125, + 0, 129, 128, 129, 124, 130, 0, 0, 119, 122, + 131, 114, 144, 0, 0, 0, 124, 112, 121, 132, + + 136, 102, 101, 56, 0, 108, 0, 0, 85, 0, + 91, 110, 0, 0, 0, 0, 0, 0, 0, 87, + 0, 73, 0, 79, 75, 71, 76, 64, 67, 57, + 0, 50, 68, 76, 0, 0, 204, 84, 152 } ; -static const flex_int16_t yy_def[138] = +static const flex_int16_t yy_def[140] = { 0, - 135, 1, 135, 135, 135, 135, 135, 135, 135, 135, - 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, - 136, 135, 135, 136, 136, 136, 136, 136, 136, 136, - 136, 136, 136, 136, 136, 136, 135, 135, 135, 137, - 135, 135, 135, 135, 135, 135, 136, 135, 136, 136, - 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, - 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, - 136, 137, 135, 135, 135, 135, 136, 136, 136, 136, - 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, - 136, 136, 136, 136, 136, 136, 136, 135, 135, 136, - - 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, - 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, - 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, - 136, 136, 136, 136, 0, 135, 135 + 137, 1, 137, 137, 137, 137, 137, 137, 137, 137, + 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, + 138, 137, 137, 138, 138, 138, 138, 138, 138, 138, + 138, 138, 138, 138, 138, 138, 138, 137, 137, 137, + 139, 137, 137, 137, 137, 137, 137, 138, 137, 138, + 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, + 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, + 138, 138, 138, 139, 137, 137, 137, 137, 138, 138, + 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, + 138, 138, 138, 138, 138, 138, 138, 138, 138, 137, + + 137, 138, 138, 138, 138, 138, 138, 138, 138, 138, + 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, + 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, + 138, 138, 138, 138, 138, 138, 0, 137, 137 } ; -static const flex_int16_t yy_nxt[250] = +static const flex_int16_t yy_nxt[253] = { 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 16, 16, 16, 17, 18, 19, 20, 21, 21, 22, 23, 21, 24, 21, 25, 21, 26, 27, 21, 28, 29, 30, 31, 32, 21, 33, 34, - 21, 21, 35, 36, 21, 21, 21, 39, 39, 39, - 39, 41, 54, 42, 42, 42, 42, 49, 50, 56, - 69, 55, 43, 65, 57, 58, 83, 70, 51, 116, - 43, 66, 84, 52, 53, 59, 60, 39, 39, 39, - 39, 73, 73, 73, 73, 47, 43, 117, 133, 134, - 74, 132, 131, 130, 43, 129, 128, 41, 74, 42, - - 42, 42, 42, 127, 75, 126, 75, 125, 43, 76, - 76, 76, 76, 124, 123, 122, 43, 73, 73, 73, - 73, 121, 98, 120, 98, 119, 74, 99, 99, 99, - 99, 118, 115, 114, 74, 76, 76, 76, 76, 76, - 76, 76, 76, 99, 99, 99, 99, 99, 99, 99, - 99, 72, 113, 72, 112, 111, 110, 109, 108, 107, - 106, 105, 104, 103, 102, 101, 100, 97, 96, 95, - 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, - 82, 81, 80, 79, 78, 77, 71, 68, 67, 64, - 63, 62, 61, 48, 46, 45, 44, 40, 38, 37, - - 135, 3, 135, 135, 135, 135, 135, 135, 135, 135, - 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, - 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, - 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, - 135, 135, 135, 135, 135, 135, 135, 135, 135 + 21, 21, 35, 36, 21, 21, 21, 37, 40, 40, + 40, 40, 42, 55, 43, 43, 43, 43, 50, 51, + 57, 70, 56, 44, 66, 58, 59, 85, 71, 52, + 118, 44, 67, 86, 53, 54, 60, 61, 40, 40, + 40, 40, 75, 75, 75, 75, 48, 44, 119, 135, + 136, 76, 134, 133, 132, 44, 131, 130, 42, 76, + + 43, 43, 43, 43, 129, 77, 128, 77, 127, 44, + 78, 78, 78, 78, 126, 125, 124, 44, 75, 75, + 75, 75, 123, 100, 122, 100, 121, 76, 101, 101, + 101, 101, 120, 117, 116, 76, 78, 78, 78, 78, + 78, 78, 78, 78, 101, 101, 101, 101, 101, 101, + 101, 101, 74, 115, 74, 114, 113, 112, 111, 110, + 109, 108, 107, 106, 105, 104, 103, 102, 99, 98, + 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, + 87, 84, 83, 82, 81, 80, 79, 73, 72, 69, + 68, 65, 64, 63, 62, 49, 47, 46, 45, 41, + + 39, 38, 137, 3, 137, 137, 137, 137, 137, 137, + 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, + 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, + 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, + 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, + 137, 137 } ; -static const flex_int16_t yy_chk[250] = +static const flex_int16_t yy_chk[253] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 14, 14, 14, - 14, 16, 25, 16, 16, 16, 16, 24, 24, 26, - 35, 25, 16, 32, 26, 27, 55, 35, 24, 102, - 16, 32, 55, 24, 24, 27, 27, 39, 39, 39, - 39, 41, 41, 41, 41, 136, 39, 102, 132, 132, - 41, 131, 130, 128, 39, 127, 126, 42, 41, 42, - - 42, 42, 42, 125, 43, 124, 43, 123, 42, 43, - 43, 43, 43, 122, 120, 118, 42, 73, 73, 73, - 73, 110, 74, 109, 74, 107, 73, 74, 74, 74, - 74, 104, 101, 100, 73, 75, 75, 75, 75, 76, - 76, 76, 76, 98, 98, 98, 98, 99, 99, 99, - 99, 137, 97, 137, 96, 95, 91, 90, 89, 88, - 87, 84, 83, 82, 81, 80, 78, 71, 70, 69, - 68, 66, 65, 64, 61, 60, 59, 58, 57, 56, - 54, 53, 52, 51, 50, 49, 36, 34, 33, 31, - 30, 29, 28, 22, 20, 19, 18, 15, 10, 7, - - 3, 135, 135, 135, 135, 135, 135, 135, 135, 135, - 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, - 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, - 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, - 135, 135, 135, 135, 135, 135, 135, 135, 135 + 1, 1, 1, 1, 1, 1, 1, 1, 14, 14, + 14, 14, 16, 25, 16, 16, 16, 16, 24, 24, + 26, 35, 25, 16, 32, 26, 27, 56, 35, 24, + 104, 16, 32, 56, 24, 24, 27, 27, 40, 40, + 40, 40, 42, 42, 42, 42, 138, 40, 104, 134, + 134, 42, 133, 132, 130, 40, 129, 128, 43, 42, + + 43, 43, 43, 43, 127, 44, 126, 44, 125, 43, + 44, 44, 44, 44, 124, 122, 120, 43, 75, 75, + 75, 75, 112, 76, 111, 76, 109, 75, 76, 76, + 76, 76, 106, 103, 102, 75, 77, 77, 77, 77, + 78, 78, 78, 78, 100, 100, 100, 100, 101, 101, + 101, 101, 139, 99, 139, 98, 97, 93, 92, 91, + 90, 89, 86, 85, 84, 83, 82, 80, 72, 71, + 70, 69, 67, 66, 65, 62, 61, 60, 59, 58, + 57, 55, 54, 53, 52, 51, 50, 37, 36, 34, + 33, 31, 30, 29, 28, 22, 20, 19, 18, 15, + + 10, 7, 3, 137, 137, 137, 137, 137, 137, 137, + 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, + 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, + 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, + 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, + 137, 137 } ; static yy_state_type yy_last_accepting_state; @@ -1043,13 +1045,13 @@ yy_match: while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 136 ) + if ( yy_current_state >= 138 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; ++yy_cp; } - while ( yy_current_state != 135 ); + while ( yy_current_state != 137 ); yy_cp = (yy_last_accepting_cpos); yy_current_state = (yy_last_accepting_state); @@ -1227,56 +1229,60 @@ YY_RULE_SETUP YY_BREAK case 47: YY_RULE_SETUP -{ amrex_parserlval.f2 = amrex::PARSER_MIN; return F2; } +{ amrex_parserlval.f2 = amrex::PARSER_YN; return F2; } YY_BREAK case 48: YY_RULE_SETUP -{ amrex_parserlval.f2 = amrex::PARSER_MAX; return F2; } +{ amrex_parserlval.f2 = amrex::PARSER_MIN; return F2; } YY_BREAK case 49: YY_RULE_SETUP -{ amrex_parserlval.f2 = amrex::PARSER_FMOD; return F2; } +{ amrex_parserlval.f2 = amrex::PARSER_MAX; return F2; } YY_BREAK case 50: YY_RULE_SETUP +{ amrex_parserlval.f2 = amrex::PARSER_FMOD; return F2; } + YY_BREAK +case 51: +YY_RULE_SETUP { amrex_parserlval.f3 = amrex::PARSER_IF; return F3; } YY_BREAK /* We use SYMBOL to hold variables and constants */ -case 51: +case 52: YY_RULE_SETUP { amrex_parserlval.s = amrex::parser_makesymbol(amrex_parsertext); return SYMBOL; } YY_BREAK /* Number */ -case 52: case 53: +case 54: YY_RULE_SETUP { amrex_parserlval.d = std::atof(amrex_parsertext); return NUMBER; } YY_BREAK /* Special characters */ -case 54: +case 55: YY_RULE_SETUP YY_BREAK -case 55: +case 56: YY_RULE_SETUP /* ignore white space */ YY_BREAK -case 56: -/* rule 56 can match eol */ +case 57: +/* rule 57 can match eol */ YY_RULE_SETUP /* ignore line continuation */ YY_BREAK -case 57: -/* rule 57 can match eol */ +case 58: +/* rule 58 can match eol */ YY_RULE_SETUP { return EOL; } YY_BREAK /* everything else */ -case 58: +case 59: YY_RULE_SETUP { amrex_parsererror("Unknown character %c", *amrex_parsertext); } YY_BREAK -case 59: +case 60: YY_RULE_SETUP YY_FATAL_ERROR( "flex scanner jammed" ); YY_BREAK @@ -1577,7 +1583,7 @@ static int yy_get_next_buffer (void) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 136 ) + if ( yy_current_state >= 138 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; @@ -1605,11 +1611,11 @@ static int yy_get_next_buffer (void) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 136 ) + if ( yy_current_state >= 138 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - yy_is_jam = (yy_current_state == 135); + yy_is_jam = (yy_current_state == 137); return yy_is_jam ? 0 : yy_current_state; }