From 442bc8bd22c18a99559afab27bd5592a5b3b1875 Mon Sep 17 00:00:00 2001 From: Steven Roberts Date: Thu, 16 May 2024 22:07:27 -0700 Subject: [PATCH 1/5] Loop over all Butcher tables to test order --- .../arkode/CXX_serial/ark_test_butcher.cpp | 95 ++++++------------ .../arkode/CXX_serial/ark_test_butcher.out | 97 ++++++++++--------- 2 files changed, 84 insertions(+), 108 deletions(-) diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_butcher.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_butcher.cpp index c789fec715..a67dfbff5b 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_butcher.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_butcher.cpp @@ -21,76 +21,43 @@ #include #include #include -#include #include #include +struct ARK_Table +{ + const char* const name; + const char* const erk_table; + const char* const dirk_table; +}; + // Main Program int main() { - // set vectors of individual tables to test - std::vector Tables_ERK = - {"ARKODE_HEUN_EULER_2_1_2", "ARKODE_ARK2_ERK_3_1_2", - "ARKODE_BOGACKI_SHAMPINE_4_2_3", "ARKODE_ARK324L2SA_ERK_4_2_3", - "ARKODE_ZONNEVELD_5_3_4", "ARKODE_ARK436L2SA_ERK_6_3_4", - "ARKODE_SAYFY_ABURUB_6_3_4", "ARKODE_CASH_KARP_6_4_5", - "ARKODE_FEHLBERG_6_4_5", "ARKODE_DORMAND_PRINCE_7_4_5", - "ARKODE_ARK548L2SA_ERK_8_4_5", "ARKODE_VERNER_8_5_6", - "ARKODE_FEHLBERG_13_7_8", "ARKODE_ARK437L2SA_ERK_7_3_4", - "ARKODE_ARK548L2SAb_ERK_8_4_5", "ARKODE_SOFRONIOU_SPALETTA_5_3_4", - "ARKODE_SHU_OSHER_3_2_3", "ARKODE_VERNER_9_5_6", - "ARKODE_VERNER_10_6_7", "ARKODE_VERNER_13_7_8", - "ARKODE_VERNER_16_8_9"}; - std::vector Tables_DIRK = {"ARKODE_SDIRK_2_1_2", - "ARKODE_ARK2_DIRK_3_1_2", - "ARKODE_BILLINGTON_3_3_2", - "ARKODE_TRBDF2_3_3_2", - "ARKODE_KVAERNO_4_2_3", - "ARKODE_ARK324L2SA_DIRK_4_2_3", - "ARKODE_CASH_5_2_4", - "ARKODE_CASH_5_3_4", - "ARKODE_SDIRK_5_3_4", - "ARKODE_KVAERNO_5_3_4", - "ARKODE_ARK436L2SA_DIRK_6_3_4", - "ARKODE_KVAERNO_7_4_5", - "ARKODE_ARK548L2SA_DIRK_8_4_5", - "ARKODE_ARK437L2SA_DIRK_7_3_4", - "ARKODE_ARK548L2SAb_DIRK_8_4_5", - "ARKODE_ESDIRK324L2SA_4_2_3", - "ARKODE_ESDIRK325L2SA_5_2_3", - "ARKODE_ESDIRK32I5L2SA_5_2_3", - "ARKODE_ESDIRK436L2SA_6_3_4", - "ARKODE_ESDIRK43I6L2SA_6_3_4", - "ARKODE_QESDIRK436L2SA_6_3_4", - "ARKODE_ESDIRK437L2SA_7_3_4", - "ARKODE_ESDIRK547L2SA_7_4_5", - "ARKODE_ESDIRK547L2SA2_7_4_5"}; - std::vector Tables_ARK_ERK = {ARKODE_ARK2_ERK_3_1_2, - ARKODE_ARK324L2SA_ERK_4_2_3, - ARKODE_ARK436L2SA_ERK_6_3_4, - ARKODE_ARK437L2SA_ERK_7_3_4, - ARKODE_ARK548L2SA_ERK_8_4_5, - ARKODE_ARK548L2SAb_ERK_8_4_5}; - std::vector Tables_ARK_DIRK = - {ARKODE_ARK2_DIRK_3_1_2, ARKODE_ARK324L2SA_DIRK_4_2_3, - ARKODE_ARK436L2SA_DIRK_6_3_4, ARKODE_ARK437L2SA_DIRK_7_3_4, - ARKODE_ARK548L2SA_DIRK_8_4_5, ARKODE_ARK548L2SAb_DIRK_8_4_5}; - std::vector STables_ARK = {"ARKODE_ARK2_3_1_2", - "ARKODE_ARK324L2SA_4_2_3", - "ARKODE_ARK436L2SA_6_3_4", - "ARKODE_ARK437L2SA_7_3_4", - "ARKODE_ARK548L2SA_8_4_5", - "ARKODE_ARK548L2SAb_8_4_5"}; - int numfails = 0; + std::vector ark_tables = + {{"ARKODE_ARK2_3_1_2", "ARKODE_ARK2_ERK_3_1_2", "ARKODE_ARK2_DIRK_3_1_2"}, + {"ARKODE_ARK324L2SA_4_2_3", "ARKODE_ARK324L2SA_ERK_4_2_3", + "ARKODE_ARK324L2SA_DIRK_4_2_3"}, + {"ARKODE_ARK436L2SA_6_3_4", "ARKODE_ARK436L2SA_ERK_6_3_4", + "ARKODE_ARK436L2SA_DIRK_6_3_4"}, + {"ARKODE_ARK437L2SA_7_3_4", "ARKODE_ARK437L2SA_ERK_7_3_4", + "ARKODE_ARK437L2SA_DIRK_7_3_4"}, + {"ARKODE_ARK548L2SA_8_4_5", "ARKODE_ARK548L2SA_ERK_8_4_5", + "ARKODE_ARK548L2SA_DIRK_8_4_5"}, + {"ARKODE_ARK548L2SAb_8_4_5", "ARKODE_ARK548L2SAb_ERK_8_4_5", + "ARKODE_ARK548L2SAb_DIRK_8_4_5"}}; + + int numfails = 0; // loop over individual ERK tables std::cout << "\nTesting individual ERK methods:\n\n"; - for (std::string table : Tables_ERK) + for (int table = ARKODE_MIN_ERK_NUM; table <= ARKODE_MAX_ERK_NUM; table++) { std::cout << "Testing method " << table << ":"; // load Butcher table - ARKodeButcherTable B = ARKodeButcherTable_LoadERKByName(table.c_str()); + ARKodeButcherTable B = + ARKodeButcherTable_LoadERK(static_cast(table)); if (B == NULL) { std::cout << " error retrieving table, aborting\n"; @@ -123,12 +90,13 @@ int main() // loop over individual DIRK tables std::cout << "\nTesting individual DIRK methods:\n\n"; - for (std::string table : Tables_DIRK) + for (int table = ARKODE_MIN_DIRK_NUM; table <= ARKODE_MAX_DIRK_NUM; table++) { std::cout << "Testing method " << table << ":"; // load Butcher table - ARKodeButcherTable B = ARKodeButcherTable_LoadDIRKByName(table.c_str()); + ARKodeButcherTable B = + ARKodeButcherTable_LoadDIRK(static_cast(table)); if (B == NULL) { std::cout << " error retrieving table, aborting\n"; @@ -161,18 +129,19 @@ int main() // loop over ARK pairs std::cout << "\nTesting ARK pairs:\n\n"; - for (size_t i = 0; i < Tables_ARK_ERK.size(); i++) + for (ARK_Table& ark_table : ark_tables) { - std::cout << "Testing method " << STables_ARK[i] << ":"; + std::cout << "Testing method " << ark_table.name << ":"; // load Butcher tables - ARKodeButcherTable Be = ARKodeButcherTable_LoadERK(Tables_ARK_ERK[i]); + ARKodeButcherTable Be = ARKodeButcherTable_LoadERKByName(ark_table.erk_table); if (Be == NULL) { std::cout << " error retrieving explicit table, aborting\n"; return 1; } - ARKodeButcherTable Bi = ARKodeButcherTable_LoadDIRK(Tables_ARK_DIRK[i]); + ARKodeButcherTable Bi = + ARKodeButcherTable_LoadDIRKByName(ark_table.dirk_table); if (Bi == NULL) { std::cout << " error retrieving implicit table, aborting"; diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_butcher.out b/test/unit_tests/arkode/CXX_serial/ark_test_butcher.out index b7c11bcecf..f3541b86bc 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_butcher.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_butcher.out @@ -1,78 +1,85 @@ Testing individual ERK methods: -Testing method ARKODE_HEUN_EULER_2_1_2: table matches predicted method/embedding orders of 2/1 -Testing method ARKODE_ARK2_ERK_3_1_2: table matches predicted method/embedding orders of 2/1 -Testing method ARKODE_BOGACKI_SHAMPINE_4_2_3: table matches predicted method/embedding orders of 3/2 -Testing method ARKODE_ARK324L2SA_ERK_4_2_3: table matches predicted method/embedding orders of 3/2 -Testing method ARKODE_ZONNEVELD_5_3_4: table matches predicted method/embedding orders of 4/3 -Testing method ARKODE_ARK436L2SA_ERK_6_3_4: table matches predicted method/embedding orders of 4/3 -Testing method ARKODE_SAYFY_ABURUB_6_3_4: table matches predicted method/embedding orders of 4/3 -Testing method ARKODE_CASH_KARP_6_4_5: table matches predicted method/embedding orders of 5/4 -Testing method ARKODE_FEHLBERG_6_4_5: table matches predicted method/embedding orders of 5/4 -Testing method ARKODE_DORMAND_PRINCE_7_4_5: table matches predicted method/embedding orders of 5/4 -Testing method ARKODE_ARK548L2SA_ERK_8_4_5: table matches predicted method/embedding orders of 5/4 -Testing method ARKODE_VERNER_8_5_6: table matches predicted method/embedding orders of 6/5 -Testing method ARKODE_FEHLBERG_13_7_8: WARNING: +Testing method 0: table matches predicted method/embedding orders of 2/1 +Testing method 1: table matches predicted method/embedding orders of 3/2 +Testing method 2: table matches predicted method/embedding orders of 3/2 +Testing method 3: table matches predicted method/embedding orders of 4/3 +Testing method 4: table matches predicted method/embedding orders of 4/3 +Testing method 5: table matches predicted method/embedding orders of 4/3 +Testing method 6: table matches predicted method/embedding orders of 5/4 +Testing method 7: table matches predicted method/embedding orders of 5/4 +Testing method 8: table matches predicted method/embedding orders of 5/4 +Testing method 9: table matches predicted method/embedding orders of 5/4 +Testing method 10: table matches predicted method/embedding orders of 6/5 +Testing method 11: WARNING: ARKodeButcherTable_CheckOrder: method order >= 6; reverting to simplifying assumptions method order = 6 embedding order >= 6; reverting to simplifying assumptions embedding order = 6 -Testing method ARKODE_ARK437L2SA_ERK_7_3_4: table matches predicted method/embedding orders of 4/3 -Testing method ARKODE_ARK548L2SAb_ERK_8_4_5: table matches predicted method/embedding orders of 5/4 -Testing method ARKODE_SOFRONIOU_SPALETTA_5_3_4: table matches predicted method/embedding orders of 4/3 -Testing method ARKODE_SHU_OSHER_3_2_3: table matches predicted method/embedding orders of 3/2 -Testing method ARKODE_VERNER_9_5_6: table matches predicted method/embedding orders of 6/5 -Testing method ARKODE_VERNER_10_6_7: WARNING: +Testing method 12: table matches predicted method/embedding orders of 3/0 +Testing method 13: table matches predicted method/embedding orders of 4/3 +Testing method 14: table matches predicted method/embedding orders of 5/4 +Testing method 15: table matches predicted method/embedding orders of 2/1 +Testing method 16: table matches predicted method/embedding orders of 4/3 +Testing method 17: table matches predicted method/embedding orders of 3/2 +Testing method 18: table matches predicted method/embedding orders of 6/5 +Testing method 19: WARNING: ARKodeButcherTable_CheckOrder: method order >= 6; reverting to simplifying assumptions method order = 6 embedding order >= 6; reverting to simplifying assumptions embedding order = 6 -Testing method ARKODE_VERNER_13_7_8: WARNING: +Testing method 20: WARNING: ARKodeButcherTable_CheckOrder: method order >= 6; reverting to simplifying assumptions method order = 6 embedding order >= 6; reverting to simplifying assumptions embedding order = 6 -Testing method ARKODE_VERNER_16_8_9: WARNING: +Testing method 21: WARNING: ARKodeButcherTable_CheckOrder: method order >= 6; reverting to simplifying assumptions method order = 6 embedding order >= 6; reverting to simplifying assumptions embedding order = 6 +Testing method 22: table matches predicted method/embedding orders of 1/0 +Testing method 23: table matches predicted method/embedding orders of 2/1 +Testing method 24: table matches predicted method/embedding orders of 2/1 Testing individual DIRK methods: -Testing method ARKODE_SDIRK_2_1_2: table matches predicted method/embedding orders of 2/1 -Testing method ARKODE_ARK2_DIRK_3_1_2: table matches predicted method/embedding orders of 2/1 -Testing method ARKODE_BILLINGTON_3_3_2: table matches predicted method/embedding orders of 2/3 -Testing method ARKODE_TRBDF2_3_3_2: table matches predicted method/embedding orders of 2/3 -Testing method ARKODE_KVAERNO_4_2_3: table matches predicted method/embedding orders of 3/2 -Testing method ARKODE_ARK324L2SA_DIRK_4_2_3: table matches predicted method/embedding orders of 3/2 -Testing method ARKODE_CASH_5_2_4: table matches predicted method/embedding orders of 4/2 -Testing method ARKODE_CASH_5_3_4: table matches predicted method/embedding orders of 4/3 -Testing method ARKODE_SDIRK_5_3_4: table matches predicted method/embedding orders of 4/3 -Testing method ARKODE_KVAERNO_5_3_4: table matches predicted method/embedding orders of 4/3 -Testing method ARKODE_ARK436L2SA_DIRK_6_3_4: table matches predicted method/embedding orders of 4/3 -Testing method ARKODE_KVAERNO_7_4_5: table matches predicted method/embedding orders of 5/4 -Testing method ARKODE_ARK548L2SA_DIRK_8_4_5: table matches predicted method/embedding orders of 5/4 -Testing method ARKODE_ARK437L2SA_DIRK_7_3_4: table matches predicted method/embedding orders of 4/3 -Testing method ARKODE_ARK548L2SAb_DIRK_8_4_5: table matches predicted method/embedding orders of 5/4 -Testing method ARKODE_ESDIRK324L2SA_4_2_3: table matches predicted method/embedding orders of 3/2 -Testing method ARKODE_ESDIRK325L2SA_5_2_3: table matches predicted method/embedding orders of 3/2 -Testing method ARKODE_ESDIRK32I5L2SA_5_2_3: table matches predicted method/embedding orders of 3/2 -Testing method ARKODE_ESDIRK436L2SA_6_3_4: table matches predicted method/embedding orders of 4/3 -Testing method ARKODE_ESDIRK43I6L2SA_6_3_4: table matches predicted method/embedding orders of 4/3 -Testing method ARKODE_QESDIRK436L2SA_6_3_4: table matches predicted method/embedding orders of 4/3 -Testing method ARKODE_ESDIRK437L2SA_7_3_4: table matches predicted method/embedding orders of 4/3 -Testing method ARKODE_ESDIRK547L2SA_7_4_5: table matches predicted method/embedding orders of 5/4 -Testing method ARKODE_ESDIRK547L2SA2_7_4_5: table matches predicted method/embedding orders of 5/4 +Testing method 100: table matches predicted method/embedding orders of 2/1 +Testing method 101: table matches predicted method/embedding orders of 2/3 +Testing method 102: table matches predicted method/embedding orders of 2/3 +Testing method 103: table matches predicted method/embedding orders of 3/2 +Testing method 104: table matches predicted method/embedding orders of 3/2 +Testing method 105: table matches predicted method/embedding orders of 4/2 +Testing method 106: table matches predicted method/embedding orders of 4/3 +Testing method 107: table matches predicted method/embedding orders of 4/3 +Testing method 108: table matches predicted method/embedding orders of 4/3 +Testing method 109: table matches predicted method/embedding orders of 4/3 +Testing method 110: table matches predicted method/embedding orders of 5/4 +Testing method 111: table matches predicted method/embedding orders of 5/4 +Testing method 112: table matches predicted method/embedding orders of 4/3 +Testing method 113: table matches predicted method/embedding orders of 5/4 +Testing method 114: table matches predicted method/embedding orders of 3/2 +Testing method 115: table matches predicted method/embedding orders of 3/2 +Testing method 116: table matches predicted method/embedding orders of 3/2 +Testing method 117: table matches predicted method/embedding orders of 4/3 +Testing method 118: table matches predicted method/embedding orders of 4/3 +Testing method 119: table matches predicted method/embedding orders of 4/3 +Testing method 120: table matches predicted method/embedding orders of 4/3 +Testing method 121: table matches predicted method/embedding orders of 5/4 +Testing method 122: table matches predicted method/embedding orders of 5/4 +Testing method 123: table matches predicted method/embedding orders of 2/1 +Testing method 124: table matches predicted method/embedding orders of 1/0 +Testing method 125: table matches predicted method/embedding orders of 2/0 +Testing method 126: table matches predicted method/embedding orders of 2/0 Testing ARK pairs: From d1a4151e75786ef06c3a50ce5e1468504146d22b Mon Sep 17 00:00:00 2001 From: Steven Roberts Date: Fri, 17 May 2024 19:13:56 -0700 Subject: [PATCH 2/5] Add public functions to convert a table ID to its string name --- include/arkode/arkode_butcher_dirk.h | 3 + include/arkode/arkode_butcher_erk.h | 3 + src/arkode/arkode_butcher_dirk.c | 22 ++++ src/arkode/arkode_butcher_erk.c | 24 +++- .../arkode/CXX_serial/ark_test_butcher.cpp | 16 +-- .../arkode/CXX_serial/ark_test_butcher.out | 104 +++++++++--------- 6 files changed, 112 insertions(+), 60 deletions(-) diff --git a/include/arkode/arkode_butcher_dirk.h b/include/arkode/arkode_butcher_dirk.h index ffa4908c91..b6bd01984b 100644 --- a/include/arkode/arkode_butcher_dirk.h +++ b/include/arkode/arkode_butcher_dirk.h @@ -65,6 +65,9 @@ ARKodeButcherTable_LoadDIRK(ARKODE_DIRKTableID imethod); SUNDIALS_EXPORT ARKodeButcherTable ARKodeButcherTable_LoadDIRKByName(const char* imethod); +SUNDIALS_EXPORT const char* +ARKodeButcherTable_DIRKIDToName(ARKODE_DIRKTableID imethod); + #ifdef __cplusplus } #endif diff --git a/include/arkode/arkode_butcher_erk.h b/include/arkode/arkode_butcher_erk.h index 764b67bbfe..f7589de266 100644 --- a/include/arkode/arkode_butcher_erk.h +++ b/include/arkode/arkode_butcher_erk.h @@ -62,6 +62,9 @@ ARKodeButcherTable_LoadERK(ARKODE_ERKTableID emethod); SUNDIALS_EXPORT ARKodeButcherTable ARKodeButcherTable_LoadERKByName(const char* emethod); +SUNDIALS_EXPORT const char* +ARKodeButcherTable_ERKIDToName(ARKODE_ERKTableID emethod); + #ifdef __cplusplus } #endif diff --git a/src/arkode/arkode_butcher_dirk.c b/src/arkode/arkode_butcher_dirk.c index 54026e7ae2..ee3001a2c8 100644 --- a/src/arkode/arkode_butcher_dirk.c +++ b/src/arkode/arkode_butcher_dirk.c @@ -54,6 +54,28 @@ ARKodeButcherTable ARKodeButcherTable_LoadDIRKByName(const char* imethod) return ARKodeButcherTable_LoadDIRK(arkButcherTableDIRKNameToID(imethod)); } +/*--------------------------------------------------------------- + Returns the string name for a pre-set DIRK method by its ID. + + Input: imethod -- integer key for the desired method + ---------------------------------------------------------------*/ +const char* ARKodeButcherTable_DIRKIDToName(ARKODE_DIRKTableID imethod) +{ + /* Use X-macro to test each method name */ + switch (imethod) + { +#define ARK_BUTCHER_TABLE(name, coeff) \ + case name: return #name; +#include "arkode_butcher_dirk.def" +#undef ARK_BUTCHER_TABLE + + default: + arkProcessError(NULL, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "Unknown Butcher table"); + return NULL; + } +} + /*--------------------------------------------------------------- Returns Butcher table ID for pre-set DIRK methods. diff --git a/src/arkode/arkode_butcher_erk.c b/src/arkode/arkode_butcher_erk.c index e15aa6b8b0..10cebbfdf4 100644 --- a/src/arkode/arkode_butcher_erk.c +++ b/src/arkode/arkode_butcher_erk.c @@ -25,7 +25,7 @@ /*--------------------------------------------------------------- Returns Butcher table structure for pre-set Runge Kutta methods. - Input: emthod -- integer key for the desired method + Input: emethod -- integer key for the desired method ---------------------------------------------------------------*/ ARKodeButcherTable ARKodeButcherTable_LoadERK(ARKODE_ERKTableID emethod) { @@ -54,6 +54,28 @@ ARKodeButcherTable ARKodeButcherTable_LoadERKByName(const char* emethod) return ARKodeButcherTable_LoadERK(arkButcherTableERKNameToID(emethod)); } +/*--------------------------------------------------------------- + Returns the string name for a pre-set Runge Kutta method by its ID. + + Input: emethod -- integer key for the desired method + ---------------------------------------------------------------*/ +const char* ARKodeButcherTable_ERKIDToName(ARKODE_ERKTableID emethod) +{ + /* Use X-macro to test each method name */ + switch (emethod) + { +#define ARK_BUTCHER_TABLE(name, coeff) \ + case name: return #name; +#include "arkode_butcher_erk.def" +#undef ARK_BUTCHER_TABLE + + default: + arkProcessError(NULL, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "Unknown Butcher table"); + return NULL; + } +} + /*--------------------------------------------------------------- Returns Butcher table ID for pre-set Runge Kutta methods. diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_butcher.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_butcher.cpp index a67dfbff5b..7ece304277 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_butcher.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_butcher.cpp @@ -23,6 +23,7 @@ #include #include #include +#include "arkode/arkode_impl.h" struct ARK_Table { @@ -51,13 +52,14 @@ int main() // loop over individual ERK tables std::cout << "\nTesting individual ERK methods:\n\n"; - for (int table = ARKODE_MIN_ERK_NUM; table <= ARKODE_MAX_ERK_NUM; table++) + for (int i = ARKODE_MIN_ERK_NUM; i <= ARKODE_MAX_ERK_NUM; i++) { - std::cout << "Testing method " << table << ":"; + ARKODE_ERKTableID id = static_cast(i); + std::cout << "Testing method " << ARKodeButcherTable_ERKIDToName(id) << ":"; // load Butcher table ARKodeButcherTable B = - ARKodeButcherTable_LoadERK(static_cast(table)); + ARKodeButcherTable_LoadERK(id); if (B == NULL) { std::cout << " error retrieving table, aborting\n"; @@ -90,13 +92,13 @@ int main() // loop over individual DIRK tables std::cout << "\nTesting individual DIRK methods:\n\n"; - for (int table = ARKODE_MIN_DIRK_NUM; table <= ARKODE_MAX_DIRK_NUM; table++) + for (int i = ARKODE_MIN_DIRK_NUM; i <= ARKODE_MAX_DIRK_NUM; i++) { - std::cout << "Testing method " << table << ":"; + ARKODE_DIRKTableID id = static_cast(i); + std::cout << "Testing method " << ARKodeButcherTable_DIRKIDToName(id) << ":"; // load Butcher table - ARKodeButcherTable B = - ARKodeButcherTable_LoadDIRK(static_cast(table)); + ARKodeButcherTable B = ARKodeButcherTable_LoadDIRK(id); if (B == NULL) { std::cout << " error retrieving table, aborting\n"; diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_butcher.out b/test/unit_tests/arkode/CXX_serial/ark_test_butcher.out index f3541b86bc..559c92b3ae 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_butcher.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_butcher.out @@ -1,85 +1,85 @@ Testing individual ERK methods: -Testing method 0: table matches predicted method/embedding orders of 2/1 -Testing method 1: table matches predicted method/embedding orders of 3/2 -Testing method 2: table matches predicted method/embedding orders of 3/2 -Testing method 3: table matches predicted method/embedding orders of 4/3 -Testing method 4: table matches predicted method/embedding orders of 4/3 -Testing method 5: table matches predicted method/embedding orders of 4/3 -Testing method 6: table matches predicted method/embedding orders of 5/4 -Testing method 7: table matches predicted method/embedding orders of 5/4 -Testing method 8: table matches predicted method/embedding orders of 5/4 -Testing method 9: table matches predicted method/embedding orders of 5/4 -Testing method 10: table matches predicted method/embedding orders of 6/5 -Testing method 11: WARNING: +Testing method ARKODE_HEUN_EULER_2_1_2: table matches predicted method/embedding orders of 2/1 +Testing method ARKODE_BOGACKI_SHAMPINE_4_2_3: table matches predicted method/embedding orders of 3/2 +Testing method ARKODE_ARK324L2SA_ERK_4_2_3: table matches predicted method/embedding orders of 3/2 +Testing method ARKODE_ZONNEVELD_5_3_4: table matches predicted method/embedding orders of 4/3 +Testing method ARKODE_ARK436L2SA_ERK_6_3_4: table matches predicted method/embedding orders of 4/3 +Testing method ARKODE_SAYFY_ABURUB_6_3_4: table matches predicted method/embedding orders of 4/3 +Testing method ARKODE_CASH_KARP_6_4_5: table matches predicted method/embedding orders of 5/4 +Testing method ARKODE_FEHLBERG_6_4_5: table matches predicted method/embedding orders of 5/4 +Testing method ARKODE_DORMAND_PRINCE_7_4_5: table matches predicted method/embedding orders of 5/4 +Testing method ARKODE_ARK548L2SA_ERK_8_4_5: table matches predicted method/embedding orders of 5/4 +Testing method ARKODE_VERNER_8_5_6: table matches predicted method/embedding orders of 6/5 +Testing method ARKODE_FEHLBERG_13_7_8: WARNING: ARKodeButcherTable_CheckOrder: method order >= 6; reverting to simplifying assumptions method order = 6 embedding order >= 6; reverting to simplifying assumptions embedding order = 6 -Testing method 12: table matches predicted method/embedding orders of 3/0 -Testing method 13: table matches predicted method/embedding orders of 4/3 -Testing method 14: table matches predicted method/embedding orders of 5/4 -Testing method 15: table matches predicted method/embedding orders of 2/1 -Testing method 16: table matches predicted method/embedding orders of 4/3 -Testing method 17: table matches predicted method/embedding orders of 3/2 -Testing method 18: table matches predicted method/embedding orders of 6/5 -Testing method 19: WARNING: +Testing method ARKODE_KNOTH_WOLKE_3_3: table matches predicted method/embedding orders of 3/0 +Testing method ARKODE_ARK437L2SA_ERK_7_3_4: table matches predicted method/embedding orders of 4/3 +Testing method ARKODE_ARK548L2SAb_ERK_8_4_5: table matches predicted method/embedding orders of 5/4 +Testing method ARKODE_ARK2_ERK_3_1_2: table matches predicted method/embedding orders of 2/1 +Testing method ARKODE_SOFRONIOU_SPALETTA_5_3_4: table matches predicted method/embedding orders of 4/3 +Testing method ARKODE_SHU_OSHER_3_2_3: table matches predicted method/embedding orders of 3/2 +Testing method ARKODE_VERNER_9_5_6: table matches predicted method/embedding orders of 6/5 +Testing method ARKODE_VERNER_10_6_7: WARNING: ARKodeButcherTable_CheckOrder: method order >= 6; reverting to simplifying assumptions method order = 6 embedding order >= 6; reverting to simplifying assumptions embedding order = 6 -Testing method 20: WARNING: +Testing method ARKODE_VERNER_13_7_8: WARNING: ARKodeButcherTable_CheckOrder: method order >= 6; reverting to simplifying assumptions method order = 6 embedding order >= 6; reverting to simplifying assumptions embedding order = 6 -Testing method 21: WARNING: +Testing method ARKODE_VERNER_16_8_9: WARNING: ARKodeButcherTable_CheckOrder: method order >= 6; reverting to simplifying assumptions method order = 6 embedding order >= 6; reverting to simplifying assumptions embedding order = 6 -Testing method 22: table matches predicted method/embedding orders of 1/0 -Testing method 23: table matches predicted method/embedding orders of 2/1 -Testing method 24: table matches predicted method/embedding orders of 2/1 +Testing method ARKODE_FORWARD_EULER_1_1: table matches predicted method/embedding orders of 1/0 +Testing method ARKODE_RALSTON_EULER_2_1_2: table matches predicted method/embedding orders of 2/1 +Testing method ARKODE_EXPLICIT_MIDPOINT_EULER_2_1_2: table matches predicted method/embedding orders of 2/1 Testing individual DIRK methods: -Testing method 100: table matches predicted method/embedding orders of 2/1 -Testing method 101: table matches predicted method/embedding orders of 2/3 -Testing method 102: table matches predicted method/embedding orders of 2/3 -Testing method 103: table matches predicted method/embedding orders of 3/2 -Testing method 104: table matches predicted method/embedding orders of 3/2 -Testing method 105: table matches predicted method/embedding orders of 4/2 -Testing method 106: table matches predicted method/embedding orders of 4/3 -Testing method 107: table matches predicted method/embedding orders of 4/3 -Testing method 108: table matches predicted method/embedding orders of 4/3 -Testing method 109: table matches predicted method/embedding orders of 4/3 -Testing method 110: table matches predicted method/embedding orders of 5/4 -Testing method 111: table matches predicted method/embedding orders of 5/4 -Testing method 112: table matches predicted method/embedding orders of 4/3 -Testing method 113: table matches predicted method/embedding orders of 5/4 -Testing method 114: table matches predicted method/embedding orders of 3/2 -Testing method 115: table matches predicted method/embedding orders of 3/2 -Testing method 116: table matches predicted method/embedding orders of 3/2 -Testing method 117: table matches predicted method/embedding orders of 4/3 -Testing method 118: table matches predicted method/embedding orders of 4/3 -Testing method 119: table matches predicted method/embedding orders of 4/3 -Testing method 120: table matches predicted method/embedding orders of 4/3 -Testing method 121: table matches predicted method/embedding orders of 5/4 -Testing method 122: table matches predicted method/embedding orders of 5/4 -Testing method 123: table matches predicted method/embedding orders of 2/1 -Testing method 124: table matches predicted method/embedding orders of 1/0 -Testing method 125: table matches predicted method/embedding orders of 2/0 -Testing method 126: table matches predicted method/embedding orders of 2/0 +Testing method ARKODE_SDIRK_2_1_2: table matches predicted method/embedding orders of 2/1 +Testing method ARKODE_BILLINGTON_3_3_2: table matches predicted method/embedding orders of 2/3 +Testing method ARKODE_TRBDF2_3_3_2: table matches predicted method/embedding orders of 2/3 +Testing method ARKODE_KVAERNO_4_2_3: table matches predicted method/embedding orders of 3/2 +Testing method ARKODE_ARK324L2SA_DIRK_4_2_3: table matches predicted method/embedding orders of 3/2 +Testing method ARKODE_CASH_5_2_4: table matches predicted method/embedding orders of 4/2 +Testing method ARKODE_CASH_5_3_4: table matches predicted method/embedding orders of 4/3 +Testing method ARKODE_SDIRK_5_3_4: table matches predicted method/embedding orders of 4/3 +Testing method ARKODE_KVAERNO_5_3_4: table matches predicted method/embedding orders of 4/3 +Testing method ARKODE_ARK436L2SA_DIRK_6_3_4: table matches predicted method/embedding orders of 4/3 +Testing method ARKODE_KVAERNO_7_4_5: table matches predicted method/embedding orders of 5/4 +Testing method ARKODE_ARK548L2SA_DIRK_8_4_5: table matches predicted method/embedding orders of 5/4 +Testing method ARKODE_ARK437L2SA_DIRK_7_3_4: table matches predicted method/embedding orders of 4/3 +Testing method ARKODE_ARK548L2SAb_DIRK_8_4_5: table matches predicted method/embedding orders of 5/4 +Testing method ARKODE_ESDIRK324L2SA_4_2_3: table matches predicted method/embedding orders of 3/2 +Testing method ARKODE_ESDIRK325L2SA_5_2_3: table matches predicted method/embedding orders of 3/2 +Testing method ARKODE_ESDIRK32I5L2SA_5_2_3: table matches predicted method/embedding orders of 3/2 +Testing method ARKODE_ESDIRK436L2SA_6_3_4: table matches predicted method/embedding orders of 4/3 +Testing method ARKODE_ESDIRK43I6L2SA_6_3_4: table matches predicted method/embedding orders of 4/3 +Testing method ARKODE_QESDIRK436L2SA_6_3_4: table matches predicted method/embedding orders of 4/3 +Testing method ARKODE_ESDIRK437L2SA_7_3_4: table matches predicted method/embedding orders of 4/3 +Testing method ARKODE_ESDIRK547L2SA_7_4_5: table matches predicted method/embedding orders of 5/4 +Testing method ARKODE_ESDIRK547L2SA2_7_4_5: table matches predicted method/embedding orders of 5/4 +Testing method ARKODE_ARK2_DIRK_3_1_2: table matches predicted method/embedding orders of 2/1 +Testing method ARKODE_BACKWARD_EULER_1_1: table matches predicted method/embedding orders of 1/0 +Testing method ARKODE_IMPLICIT_MIDPOINT_1_2: table matches predicted method/embedding orders of 2/0 +Testing method ARKODE_IMPLICIT_TRAPEZOIDAL_2_2: table matches predicted method/embedding orders of 2/0 Testing ARK pairs: From 247af042be4c63c059ee2e2730a57f32d59b3b67 Mon Sep 17 00:00:00 2001 From: Steven Roberts Date: Fri, 17 May 2024 19:16:38 -0700 Subject: [PATCH 3/5] Apply formatter --- include/arkode/arkode_butcher_dirk.h | 4 ++-- include/arkode/arkode_butcher_erk.h | 3 +-- test/unit_tests/arkode/CXX_serial/ark_test_butcher.cpp | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/include/arkode/arkode_butcher_dirk.h b/include/arkode/arkode_butcher_dirk.h index b6bd01984b..c89ea0594f 100644 --- a/include/arkode/arkode_butcher_dirk.h +++ b/include/arkode/arkode_butcher_dirk.h @@ -65,8 +65,8 @@ ARKodeButcherTable_LoadDIRK(ARKODE_DIRKTableID imethod); SUNDIALS_EXPORT ARKodeButcherTable ARKodeButcherTable_LoadDIRKByName(const char* imethod); -SUNDIALS_EXPORT const char* -ARKodeButcherTable_DIRKIDToName(ARKODE_DIRKTableID imethod); +SUNDIALS_EXPORT const char* ARKodeButcherTable_DIRKIDToName( + ARKODE_DIRKTableID imethod); #ifdef __cplusplus } diff --git a/include/arkode/arkode_butcher_erk.h b/include/arkode/arkode_butcher_erk.h index f7589de266..c6c0373510 100644 --- a/include/arkode/arkode_butcher_erk.h +++ b/include/arkode/arkode_butcher_erk.h @@ -62,8 +62,7 @@ ARKodeButcherTable_LoadERK(ARKODE_ERKTableID emethod); SUNDIALS_EXPORT ARKodeButcherTable ARKodeButcherTable_LoadERKByName(const char* emethod); -SUNDIALS_EXPORT const char* -ARKodeButcherTable_ERKIDToName(ARKODE_ERKTableID emethod); +SUNDIALS_EXPORT const char* ARKodeButcherTable_ERKIDToName(ARKODE_ERKTableID emethod); #ifdef __cplusplus } diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_butcher.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_butcher.cpp index 7ece304277..a8013ad472 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_butcher.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_butcher.cpp @@ -23,6 +23,7 @@ #include #include #include + #include "arkode/arkode_impl.h" struct ARK_Table @@ -58,8 +59,7 @@ int main() std::cout << "Testing method " << ARKodeButcherTable_ERKIDToName(id) << ":"; // load Butcher table - ARKodeButcherTable B = - ARKodeButcherTable_LoadERK(id); + ARKodeButcherTable B = ARKodeButcherTable_LoadERK(id); if (B == NULL) { std::cout << " error retrieving table, aborting\n"; From 864d7e7f1abe95210321775c7d9e5ad5a959a8df Mon Sep 17 00:00:00 2001 From: Steven Roberts Date: Sat, 18 May 2024 16:50:13 -0700 Subject: [PATCH 4/5] Add docs for ID to name functions --- .../guide/source/ARKodeButcherTable.rst | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/doc/arkode/guide/source/ARKodeButcherTable.rst b/doc/arkode/guide/source/ARKodeButcherTable.rst index 916641678b..969e1bc23a 100644 --- a/doc/arkode/guide/source/ARKodeButcherTable.rst +++ b/doc/arkode/guide/source/ARKodeButcherTable.rst @@ -83,10 +83,14 @@ ARKodeButcherTable functions +--------------------------------------------------+------------------------------------------------------------+ | :c:func:`ARKodeButcherTable_LoadERKByName()` | Retrieve a given explicit Butcher table by its unique name | +--------------------------------------------------+------------------------------------------------------------+ + | :c:func:`ARKodeButcherTable_ERKIDToName()` | Convert an explicit Butcher table ID to its name | + +--------------------------------------------------+------------------------------------------------------------+ | :c:func:`ARKodeButcherTable_LoadDIRK()` | Retrieve a given implicit Butcher table by its unique ID | +--------------------------------------------------+------------------------------------------------------------+ | :c:func:`ARKodeButcherTable_LoadDIRKByName()` | Retrieve a given implicit Butcher table by its unique name | +--------------------------------------------------+------------------------------------------------------------+ + | :c:func:`ARKodeButcherTable_DIRKIDToName()` | Convert an implicit Butcher table ID to its name | + +--------------------------------------------------+------------------------------------------------------------+ | :c:func:`ARKodeButcherTable_Alloc()` | Allocate an empty Butcher table | +--------------------------------------------------+------------------------------------------------------------+ | :c:func:`ARKodeButcherTable_Create()` | Create a new Butcher table | @@ -138,6 +142,21 @@ ARKodeButcherTable functions **Notes:** This function is case sensitive. +.. c:function:: const char* ARKodeButcherTable_ERKIDToName(ARKODE_ERKTableID emethod) + + Converts a specified explicit Butcher table ID to a string of the same name. + The prototype for this function, as well as the integer names for each + provided method, are defined in the header file + ``arkode/arkode_butcher_erk.h``. For further information on these tables and + their corresponding identifiers, see :numref:`Butcher`. + + **Arguments:** + * *emethod* -- integer input specifying the given Butcher table. + + **Return value:** + * The name associated with *emethod*. + * ``NULL`` pointer if *emethod* was invalid. + .. c:function:: ARKodeButcherTable ARKodeButcherTable_LoadDIRK(ARKODE_DIRKTableID imethod) Retrieves a specified diagonally-implicit Butcher table. The prototype for @@ -172,6 +191,22 @@ ARKodeButcherTable functions This function is case sensitive. +.. c:function:: const char* ARKodeButcherTable_DIRKIDToName(ARKODE_DIRKTableID imethod) + + Converts a specified diagonally-implicit Butcher table ID to a string of the + same name. The prototype for this function, as well as the integer names for + each provided method, are defined in the header file + ``arkode/arkode_butcher_dirk.h``. For further information on these tables + and their corresponding identifiers, see :numref:`Butcher`. + + **Arguments:** + * *imethod* -- integer input specifying the given Butcher table. + + **Return value:** + * The name associated with *imethod*. + * ``NULL`` pointer if *imethod* was invalid. + + .. c:function:: ARKodeButcherTable ARKodeButcherTable_Alloc(int stages, sunbooleantype embedded) Allocates an empty Butcher table. From 3b5ca324d3ef7ca5ae2b12981623046f3758c014 Mon Sep 17 00:00:00 2001 From: Steven Roberts Date: Tue, 21 May 2024 16:36:08 -0700 Subject: [PATCH 5/5] Update answers repo --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index 073b119355..b622a192d5 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit 073b119355058ac88a2e4abc87acfb007bc211f6 +Subproject commit b622a192d52f7982bb6485f0cba5ffd3fc24e622