From 037f819e0e15417fc4aff10eca164ee34aa5c1cc Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Sun, 15 Dec 2024 14:03:58 -0800 Subject: [PATCH 1/5] enable dev and unit tests in GitLab CI --- .gitlab/build_and_test.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab/build_and_test.sh b/.gitlab/build_and_test.sh index 2c0de8a06a..abb4da925c 100755 --- a/.gitlab/build_and_test.sh +++ b/.gitlab/build_and_test.sh @@ -175,6 +175,7 @@ then $cmake_exe \ -C "${hostconfig_path}" \ -DCMAKE_INSTALL_PREFIX=${install_dir} \ + -DSUNDIALS_TEST_ENABLE_DEV_TESTS=ON \ -DSUNDIALS_TEST_ENABLE_DIFF_OUTPUT=OFF \ -DSUNDIALS_TEST_ENABLE_UNIT_TESTS=ON \ -DMPIEXEC_EXECUTABLE=$(which $MPIEXEC_EXECUTABLE) \ @@ -188,6 +189,7 @@ then $cmake_exe \ -C "${hostconfig_path}" \ -DCMAKE_INSTALL_PREFIX=${install_dir} \ + -DSUNDIALS_TEST_ENABLE_DEV_TESTS=ON \ -DSUNDIALS_TEST_ENABLE_DIFF_OUTPUT=OFF \ -DSUNDIALS_TEST_ENABLE_UNIT_TESTS=ON \ -DMPIEXEC_EXECUTABLE=$(which $MPIEXEC_EXECUTABLE) \ From 9612e635cdbc7adb5ee9e77514cae9a9c2ef5027 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Mon, 23 Dec 2024 23:11:13 -0600 Subject: [PATCH 2/5] do not use isnan to check if input set --- .../arkode/CXX_serial/ark_kpr_nestedmri.cpp | 139 +++++++++--------- examples/utilities/example_utilities.hpp | 32 +++- 2 files changed, 94 insertions(+), 77 deletions(-) diff --git a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp index aa042dbad1..b1dc8e886f 100644 --- a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp +++ b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp @@ -195,6 +195,18 @@ struct Options sunrealtype htol_minfac = NAN; sunrealtype htol_maxfac = NAN; sunrealtype slow_safety = NAN; + + bool set_k1s = false; + bool set_k2s = false; + bool set_k3s = false; + bool set_k1f = false; + bool set_k2f = false; + bool set_k3f = false; + bool set_bias = false; + bool set_htol_relch = false; + bool set_htol_minfac = false; + bool set_htol_maxfac = false; + bool set_slow_safety = false; }; // User-supplied functions called by the solver @@ -355,7 +367,7 @@ int main(int argc, char* argv[]) case (1): fcontrol = SUNAdaptController_I(sunctx); if (check_ptr((void*)fcontrol, "SUNAdaptController_I")) return 1; - if (!std::isnan(opts.k1f)) + if (opts.set_k1f) { retval = SUNAdaptController_SetParams_I(fcontrol, opts.k1f); if (check_flag(retval, "SUNAdaptController_SetParams_I")) return 1; @@ -364,7 +376,7 @@ int main(int argc, char* argv[]) case (2): fcontrol = SUNAdaptController_PI(sunctx); if (check_ptr((void*)fcontrol, "SUNAdaptController_PI")) return 1; - if (!(std::isnan(opts.k1f) || std::isnan(opts.k2f))) + if (opts.set_k1f && opts.set_k2f) { retval = SUNAdaptController_SetParams_PI(fcontrol, opts.k1f, opts.k2f); if (check_flag(retval, "SUNAdaptController_SetParams_PI")) return 1; @@ -373,7 +385,7 @@ int main(int argc, char* argv[]) case (3): fcontrol = SUNAdaptController_PID(sunctx); if (check_ptr((void*)fcontrol, "SUNAdaptController_PID")) return 1; - if (!(std::isnan(opts.k1f) || std::isnan(opts.k2f) || std::isnan(opts.k3f))) + if (opts.set_k1f && opts.set_k2f && opts.set_k3f) { retval = SUNAdaptController_SetParams_PID(fcontrol, opts.k1f, opts.k2f, opts.k3f); @@ -383,7 +395,7 @@ int main(int argc, char* argv[]) case (4): fcontrol = SUNAdaptController_ExpGus(sunctx); if (check_ptr((void*)fcontrol, "SUNAdaptController_ExpGus")) return 1; - if (!(std::isnan(opts.k1f) || std::isnan(opts.k2f))) + if (opts.set_k1f && opts.set_k2f) { retval = SUNAdaptController_SetParams_ExpGus(fcontrol, opts.k1f, opts.k2f); if (check_flag(retval, "SUNAdaptController_SetParams_ExpGus")) return 1; @@ -392,7 +404,7 @@ int main(int argc, char* argv[]) case (5): fcontrol = SUNAdaptController_ImpGus(sunctx); if (check_ptr((void*)fcontrol, "SUNAdaptController_ImpGus")) return 1; - if (!(std::isnan(opts.k1f) || std::isnan(opts.k2f))) + if (opts.set_k1f && opts.set_k2f) { retval = SUNAdaptController_SetParams_ImpGus(fcontrol, opts.k1f, opts.k2f); if (check_flag(retval, "SUNAdaptController_SetParams_ImpGus")) return 1; @@ -403,7 +415,7 @@ int main(int argc, char* argv[]) if (check_ptr((void*)fcontrol, "SUNAdaptController_ImExGus")) return 1; break; } - if (!std::isnan(opts.bias) && (opts.fcontrol > 0)) + if (opts.set_bias && opts.fcontrol > 0) { retval = SUNAdaptController_SetErrorBias(fcontrol, opts.bias); if (check_flag(retval, "SUNAdaptController_SetErrorBias")) return 1; @@ -473,7 +485,7 @@ int main(int argc, char* argv[]) mcontrol_Tol = SUNAdaptController_I(sunctx); if (check_ptr((void*)mcontrol_Tol, "SUNAdaptController_I (mid Tol)")) return 1; - if (!std::isnan(opts.k1s)) + if (opts.set_k1s) { retval = SUNAdaptController_SetParams_I(scontrol_H, opts.k1s); if (check_flag(retval, "SUNAdaptController_SetParams_I")) return 1; @@ -488,8 +500,7 @@ int main(int argc, char* argv[]) if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; mcontrol = SUNAdaptController_MRIHTol(mcontrol_H, mcontrol_Tol, sunctx); if (check_ptr((void*)mcontrol, "SUNAdaptController_MRIHTol")) return 1; - if (!(std::isnan(opts.htol_relch) || std::isnan(opts.htol_minfac) || - std::isnan(opts.htol_maxfac))) + if (opts.set_htol_relch || opts.set_htol_minfac || opts.set_htol_maxfac) { retval = SUNAdaptController_SetParams_MRIHTol(scontrol, opts.htol_relch, opts.htol_minfac, @@ -515,7 +526,7 @@ int main(int argc, char* argv[]) mcontrol_Tol = SUNAdaptController_PI(sunctx); if (check_ptr((void*)mcontrol_Tol, "SUNAdaptController_PI (mid Tol)")) return 1; - if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s))) + if (opts.set_k1s && opts.set_k2s) { retval = SUNAdaptController_SetParams_PI(scontrol_H, opts.k1s, opts.k2s); if (check_flag(retval, "SUNAdaptController_SetParams_PI")) return 1; @@ -530,8 +541,7 @@ int main(int argc, char* argv[]) if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; mcontrol = SUNAdaptController_MRIHTol(mcontrol_H, mcontrol_Tol, sunctx); if (check_ptr((void*)mcontrol, "SUNAdaptController_MRIHTol")) return 1; - if (!(std::isnan(opts.htol_relch) || std::isnan(opts.htol_minfac) || - std::isnan(opts.htol_maxfac))) + if (opts.set_htol_relch || opts.set_htol_minfac || opts.set_htol_maxfac) { retval = SUNAdaptController_SetParams_MRIHTol(scontrol, opts.htol_relch, opts.htol_minfac, @@ -558,7 +568,7 @@ int main(int argc, char* argv[]) mcontrol_Tol = SUNAdaptController_PID(sunctx); if (check_ptr((void*)mcontrol_Tol, "SUNAdaptController_PID (mid Tol)")) return 1; - if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s) || std::isnan(opts.k3s))) + if (opts.set_k1s && opts.set_k2s && opts.set_k3s) { retval = SUNAdaptController_SetParams_PID(scontrol_H, opts.k1s, opts.k2s, opts.k3s); @@ -577,8 +587,7 @@ int main(int argc, char* argv[]) if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; mcontrol = SUNAdaptController_MRIHTol(mcontrol_H, mcontrol_Tol, sunctx); if (check_ptr((void*)mcontrol, "SUNAdaptController_MRIHTol")) return 1; - if (!(std::isnan(opts.htol_relch) || std::isnan(opts.htol_minfac) || - std::isnan(opts.htol_maxfac))) + if (opts.set_htol_relch || opts.set_htol_minfac || opts.set_htol_maxfac) { retval = SUNAdaptController_SetParams_MRIHTol(scontrol, opts.htol_relch, opts.htol_minfac, @@ -605,7 +614,7 @@ int main(int argc, char* argv[]) mcontrol_Tol = SUNAdaptController_ExpGus(sunctx); if (check_ptr((void*)mcontrol_Tol, "SUNAdaptController_ExpGus (mid Tol)")) return 1; - if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s))) + if (opts.set_k1s && opts.set_k2s) { retval = SUNAdaptController_SetParams_ExpGus(scontrol_H, opts.k1s, opts.k2s); @@ -624,8 +633,7 @@ int main(int argc, char* argv[]) if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; mcontrol = SUNAdaptController_MRIHTol(mcontrol_H, mcontrol_Tol, sunctx); if (check_ptr((void*)mcontrol, "SUNAdaptController_MRIHTol")) return 1; - if (!(std::isnan(opts.htol_relch) || std::isnan(opts.htol_minfac) || - std::isnan(opts.htol_maxfac))) + if (opts.set_htol_relch || opts.set_htol_minfac || opts.set_htol_maxfac) { retval = SUNAdaptController_SetParams_MRIHTol(scontrol, opts.htol_relch, opts.htol_minfac, @@ -652,7 +660,7 @@ int main(int argc, char* argv[]) mcontrol_Tol = SUNAdaptController_ImpGus(sunctx); if (check_ptr((void*)mcontrol_Tol, "SUNAdaptController_ImpGus (mid Tol)")) return 1; - if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s))) + if (opts.set_k1s && opts.set_k2s) { retval = SUNAdaptController_SetParams_ImpGus(scontrol_H, opts.k1s, opts.k2s); @@ -671,8 +679,7 @@ int main(int argc, char* argv[]) if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; mcontrol = SUNAdaptController_MRIHTol(mcontrol_H, mcontrol_Tol, sunctx); if (check_ptr((void*)mcontrol, "SUNAdaptController_MRIHTol")) return 1; - if (!(std::isnan(opts.htol_relch) || std::isnan(opts.htol_minfac) || - std::isnan(opts.htol_maxfac))) + if (opts.set_htol_relch || opts.set_htol_minfac || opts.set_htol_maxfac) { retval = SUNAdaptController_SetParams_MRIHTol(scontrol, opts.htol_relch, opts.htol_minfac, @@ -703,8 +710,7 @@ int main(int argc, char* argv[]) if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; mcontrol = SUNAdaptController_MRIHTol(scontrol_H, scontrol_Tol, sunctx); if (check_ptr((void*)mcontrol, "SUNAdaptController_MRIHTol")) return 1; - if (!(std::isnan(opts.htol_relch) || std::isnan(opts.htol_minfac) || - std::isnan(opts.htol_maxfac))) + if (opts.set_htol_relch || opts.set_htol_minfac || opts.set_htol_maxfac) { retval = SUNAdaptController_SetParams_MRIHTol(scontrol, opts.htol_relch, opts.htol_minfac, @@ -723,7 +729,7 @@ int main(int argc, char* argv[]) if (check_ptr((void*)scontrol, "SUNAdaptControllerI (slow)")) return 1; mcontrol = SUNAdaptController_I(sunctx); if (check_ptr((void*)mcontrol, "SUNAdaptControllerI (mid)")) return 1; - if (!std::isnan(opts.k1s)) + if (opts.set_k1s) { retval = SUNAdaptController_SetParams_I(scontrol, opts.k1s); if (check_flag(retval, "SUNAdaptController_SetParams_I")) return 1; @@ -738,7 +744,7 @@ int main(int argc, char* argv[]) if (check_ptr((void*)scontrol, "SUNAdaptController_PI (slow)")) return 1; mcontrol = SUNAdaptController_PI(sunctx); if (check_ptr((void*)mcontrol, "SUNAdaptController_PI (mid)")) return 1; - if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s))) + if (opts.set_k1s && opts.set_k2s) { retval = SUNAdaptController_SetParams_PI(scontrol, opts.k1s, opts.k2s); if (check_flag(retval, "SUNAdaptController_SetParams_PI")) return 1; @@ -753,7 +759,7 @@ int main(int argc, char* argv[]) if (check_ptr((void*)scontrol, "SUNAdaptController_PID (slow)")) return 1; mcontrol = SUNAdaptController_PID(sunctx); if (check_ptr((void*)mcontrol, "SUNAdaptController_PID (mid)")) return 1; - if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s) || std::isnan(opts.k3s))) + if (opts.set_k1s && opts.set_k2s && opts.set_k3s) { retval = SUNAdaptController_SetParams_PID(scontrol, opts.k1s, opts.k2s, opts.k3s); @@ -771,7 +777,7 @@ int main(int argc, char* argv[]) return 1; mcontrol = SUNAdaptController_ExpGus(sunctx); if (check_ptr((void*)mcontrol, "SUNAdaptController_ExpGus (mid)")) return 1; - if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s))) + if (opts.set_k1s && opts.set_k2s) { retval = SUNAdaptController_SetParams_ExpGus(scontrol, opts.k1s, opts.k2s); if (check_flag(retval, "SUNAdaptController_SetParams_ExpGus")) return 1; @@ -787,7 +793,7 @@ int main(int argc, char* argv[]) return 1; mcontrol = SUNAdaptController_ImpGus(sunctx); if (check_ptr((void*)mcontrol, "SUNAdaptController_ImpGus (mid)")) return 1; - if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s))) + if (opts.set_k1s && opts.set_k2s) { retval = SUNAdaptController_SetParams_ImpGus(scontrol, opts.k1s, opts.k2s); if (check_flag(retval, "SUNAdaptController_SetParams_ImpGus")) return 1; @@ -807,7 +813,7 @@ int main(int argc, char* argv[]) break; } } - if (!std::isnan(opts.bias) && (opts.scontrol > 0)) + if (opts.set_bias && opts.scontrol > 0) { retval = SUNAdaptController_SetErrorBias(scontrol, opts.bias); if (check_flag(retval, "SUNAdaptController_SetErrorBias")) return 1; @@ -857,7 +863,7 @@ int main(int argc, char* argv[]) retval = ARKodeSetAdaptivityAdjustment(mid_arkode_mem, 0); if (check_flag(retval, "ARKodeSetAdaptivityAdjustment")) return 1; } - if (!std::isnan(opts.slow_safety)) + if (opts.set_slow_safety) { retval = ARKodeSetSafetyFactor(mid_arkode_mem, opts.slow_safety); if (check_flag(retval, "ARKodeSetSafetyFactor")) return 1; @@ -915,7 +921,7 @@ int main(int argc, char* argv[]) retval = ARKodeSetAdaptivityAdjustment(arkode_mem, 0); if (check_flag(retval, "ARKodeSetAdaptivityAdjustment")) return 1; } - if (!std::isnan(opts.slow_safety)) + if (opts.set_slow_safety) { retval = ARKodeSetSafetyFactor(arkode_mem, opts.slow_safety); if (check_flag(retval, "ARKodeSetSafetyFactor")) return 1; @@ -1609,7 +1615,6 @@ int ReadInputs(std::vector& args, Options& opts, SUNContext ctx) find_arg(args, "--rtol", opts.rtol); find_arg(args, "--atol", opts.atol); find_arg(args, "--fast_rtol", opts.fast_rtol); - find_arg(args, "--safety", opts.slow_safety); find_arg(args, "--mri_method", opts.mri_method); find_arg(args, "--mid_method", opts.mid_method); find_arg(args, "--fast_order", opts.fast_order); @@ -1618,16 +1623,17 @@ int ReadInputs(std::vector& args, Options& opts, SUNContext ctx) find_arg(args, "--faccum", opts.faccum); find_arg(args, "--slow_pq", opts.slow_pq); find_arg(args, "--fast_pq", opts.fast_pq); - find_arg(args, "--k1s", opts.k1s); - find_arg(args, "--k2s", opts.k2s); - find_arg(args, "--k3s", opts.k3s); - find_arg(args, "--k1f", opts.k1f); - find_arg(args, "--k2f", opts.k2f); - find_arg(args, "--k3f", opts.k3f); - find_arg(args, "--bias", opts.bias); - find_arg(args, "--htol_relch", opts.htol_relch); - find_arg(args, "--htol_minfac", opts.htol_minfac); - find_arg(args, "--htol_maxfac", opts.htol_maxfac); + if (find_arg(args, "--k1s", opts.k1s)) { opts.set_k1s = true; } + if (find_arg(args, "--k2s", opts.k2s)) { opts.set_k2s = true; } + if (find_arg(args, "--k3s", opts.k3s)) { opts.set_k3s = true; } + if (find_arg(args, "--k1f", opts.k1f)) { opts.set_k1f = true; } + if (find_arg(args, "--k2f", opts.k2f)) { opts.set_k2f = true; } + if (find_arg(args, "--k3f", opts.k3f)) { opts.set_k3f = true; } + if (find_arg(args, "--bias", opts.bias)) { opts.set_bias = true; } + if (find_arg(args, "--htol_relch", opts.htol_relch)) { opts.set_htol_relch = true; } + if (find_arg(args, "--htol_minfac", opts.htol_minfac)) { opts.set_htol_minfac = true; } + if (find_arg(args, "--htol_maxfac", opts.htol_maxfac)) { opts.set_htol_maxfac = true; } + if (find_arg(args, "--safety", opts.slow_safety)) { opts.set_slow_safety = true; } // Check inputs for validity // 0 < rtol < 1 @@ -1733,13 +1739,12 @@ static void PrintSlowAdaptivity(Options opts) << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; - if (!std::isnan(opts.k1s)) + if (opts.set_k1s) { std::cout << " slow/intermediate controller parameter: " << opts.k1s << "\n"; } - if (!(std::isnan(opts.htol_relch) || std::isnan(opts.htol_minfac) || - std::isnan(opts.htol_maxfac))) + if (opts.set_htol_relch || opts.set_htol_minfac || opts.set_htol_maxfac) { std::cout << " HTol controller parameters: " << opts.htol_relch << " " << opts.htol_minfac << " " << opts.htol_maxfac << "\n"; @@ -1753,13 +1758,12 @@ static void PrintSlowAdaptivity(Options opts) << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; - if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s))) + if (opts.set_k1s && opts.set_k2s) { std::cout << " slow/intermediate controller parameters: " << opts.k1s << " " << opts.k2s << "\n"; } - if (!(std::isnan(opts.htol_relch) || std::isnan(opts.htol_minfac) || - std::isnan(opts.htol_maxfac))) + if (opts.set_htol_relch || opts.set_htol_minfac || opts.set_htol_maxfac) { std::cout << " HTol controller parameters: " << opts.htol_relch << " " << opts.htol_minfac << " " << opts.htol_maxfac << "\n"; @@ -1773,13 +1777,12 @@ static void PrintSlowAdaptivity(Options opts) << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; - if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s) || std::isnan(opts.k3s))) + if (opts.set_k1s && opts.set_k2s && opts.set_k3s) { std::cout << " slow/intermediate controller parameters: " << opts.k1s << " " << opts.k2s << " " << opts.k3s << "\n"; } - if (!(std::isnan(opts.htol_relch) || std::isnan(opts.htol_minfac) || - std::isnan(opts.htol_maxfac))) + if (opts.set_htol_relch || opts.set_htol_minfac || opts.set_htol_maxfac) { std::cout << " HTol controller parameters: " << opts.htol_relch << " " << opts.htol_minfac << " " << opts.htol_maxfac << "\n"; @@ -1793,13 +1796,12 @@ static void PrintSlowAdaptivity(Options opts) << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; - if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s))) + if (opts.set_k1s && opts.set_k2s) { std::cout << " slow/intermediate controller parameters: " << opts.k1s << " " << opts.k2s << "\n"; } - if (!(std::isnan(opts.htol_relch) || std::isnan(opts.htol_minfac) || - std::isnan(opts.htol_maxfac))) + if (opts.set_htol_relch || opts.set_htol_minfac || opts.set_htol_maxfac) { std::cout << " HTol controller parameters: " << opts.htol_relch << " " << opts.htol_minfac << " " << opts.htol_maxfac << "\n"; @@ -1813,13 +1815,12 @@ static void PrintSlowAdaptivity(Options opts) << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; - if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s))) + if (opts.set_k1s && opts.set_k2s) { std::cout << " slow/intermediate controller parameters: " << opts.k1s << " " << opts.k2s << "\n"; } - if (!(std::isnan(opts.htol_relch) || std::isnan(opts.htol_minfac) || - std::isnan(opts.htol_maxfac))) + if (opts.set_htol_relch || opts.set_htol_minfac || opts.set_htol_maxfac) { std::cout << " HTol controller parameters: " << opts.htol_relch << " " << opts.htol_minfac << " " << opts.htol_maxfac << "\n"; @@ -1841,7 +1842,7 @@ static void PrintSlowAdaptivity(Options opts) "order of MRI " << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; - if (!std::isnan(opts.k1s)) + if (opts.set_k1s) { std::cout << " slow/intermediate controller parameter: " << opts.k1s << "\n"; @@ -1854,7 +1855,7 @@ static void PrintSlowAdaptivity(Options opts) "order of MRI " << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; - if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s))) + if (opts.set_k1s && opts.set_k2s) { std::cout << " slow/intermediate controller parameters: " << opts.k1s << " " << opts.k2s << "\n"; @@ -1867,7 +1868,7 @@ static void PrintSlowAdaptivity(Options opts) "order of MRI " << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; - if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s) || std::isnan(opts.k3s))) + if (opts.set_k1s && opts.set_k2s && opts.set_k3s) { std::cout << " slow/intermediate controller parameters: " << opts.k1s << " " << opts.k2s << " " << opts.k3s << "\n"; @@ -1880,7 +1881,7 @@ static void PrintSlowAdaptivity(Options opts) "on order of MRI " << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; - if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s))) + if (opts.set_k1s && opts.set_k2s) { std::cout << " slow/intermediate controller parameters: " << opts.k1s << " " << opts.k2s << "\n"; @@ -1893,7 +1894,7 @@ static void PrintSlowAdaptivity(Options opts) "on order of MRI " << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; - if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s))) + if (opts.set_k1s && opts.set_k2s) { std::cout << " slow/intermediate controller parameters: " << opts.k1s << " " << opts.k2s << "\n"; @@ -1909,11 +1910,11 @@ static void PrintSlowAdaptivity(Options opts) break; } } - if (!std::isnan(opts.bias)) + if (opts.set_bias) { std::cout << " controller bias factor: " << opts.bias << "\n"; } - if (!std::isnan(opts.slow_safety)) + if (opts.set_slow_safety) { std::cout << " slow step safety factor: " << opts.slow_safety << "\n"; } @@ -1936,7 +1937,7 @@ static void PrintFastAdaptivity(Options opts) << ((opts.fast_pq == 1) ? "method\n" : "embedding\n"); std::cout << " fast_rtol = " << opts.fast_rtol << ", atol = " << opts.atol << "\n"; - if (!std::isnan(opts.k1f)) + if (opts.set_k1f) { std::cout << " fast controller parameter: " << opts.k1f << "\n"; } @@ -1948,7 +1949,7 @@ static void PrintFastAdaptivity(Options opts) << ((opts.fast_pq == 1) ? "method\n" : "embedding\n"); std::cout << " fast_rtol = " << opts.fast_rtol << ", atol = " << opts.atol << "\n"; - if (!(std::isnan(opts.k1f) || std::isnan(opts.k2f))) + if (opts.set_k1f && opts.set_k2f) { std::cout << " fast controller parameters: " << opts.k1f << " " << opts.k2f << "\n"; @@ -1961,7 +1962,7 @@ static void PrintFastAdaptivity(Options opts) << ((opts.fast_pq == 1) ? "method\n" : "embedding\n"); std::cout << " fast_rtol = " << opts.fast_rtol << ", atol = " << opts.atol << "\n"; - if (!(std::isnan(opts.k1f) || std::isnan(opts.k2f) || std::isnan(opts.k3f))) + if (opts.set_k1f && opts.set_k2f && opts.set_k3f) { std::cout << " fast controller parameters: " << opts.k1f << " " << opts.k2f << " " << opts.k3f << "\n"; @@ -1975,7 +1976,7 @@ static void PrintFastAdaptivity(Options opts) << ((opts.fast_pq == 1) ? "method\n" : "embedding\n"); std::cout << " fast_rtol = " << opts.fast_rtol << ", atol = " << opts.atol << "\n"; - if (!(std::isnan(opts.k1f) || std::isnan(opts.k2f))) + if (opts.set_k1f && opts.set_k2f) { std::cout << " fast controller parameters: " << opts.k1f << " " << opts.k2f << "\n"; @@ -1989,7 +1990,7 @@ static void PrintFastAdaptivity(Options opts) << ((opts.fast_pq == 1) ? "method\n" : "embedding\n"); std::cout << " fast_rtol = " << opts.fast_rtol << ", atol = " << opts.atol << "\n"; - if (!(std::isnan(opts.k1f) || std::isnan(opts.k2f))) + if (opts.set_k1f && opts.set_k2f) { std::cout << " fast controller parameters: " << opts.k1f << " " << opts.k2f << "\n"; diff --git a/examples/utilities/example_utilities.hpp b/examples/utilities/example_utilities.hpp index d4cdd919b7..9dc47d2fa1 100644 --- a/examples/utilities/example_utilities.hpp +++ b/examples/utilities/example_utilities.hpp @@ -40,7 +40,7 @@ static int check_ptr(const void* ptr, const std::string funcname) } // Functions for parsing vectors of command line inputs -inline void find_arg(std::vector& args, const std::string key, +inline bool find_arg(std::vector& args, const std::string key, float& dest) { auto it = std::find(args.cbegin(), args.cend(), key); @@ -48,10 +48,12 @@ inline void find_arg(std::vector& args, const std::string key, { dest = stof(*(it + 1)); args.erase(it, it + 2); + return true; } + return false; } -inline void find_arg(std::vector& args, const std::string key, +inline bool find_arg(std::vector& args, const std::string key, double& dest) { auto it = std::find(args.cbegin(), args.cend(), key); @@ -59,10 +61,12 @@ inline void find_arg(std::vector& args, const std::string key, { dest = stod(*(it + 1)); args.erase(it, it + 2); + return true; } + return false; } -inline void find_arg(std::vector& args, const std::string key, +inline bool find_arg(std::vector& args, const std::string key, long double& dest) { auto it = std::find(args.cbegin(), args.cend(), key); @@ -70,10 +74,12 @@ inline void find_arg(std::vector& args, const std::string key, { dest = stold(*(it + 1)); args.erase(it, it + 2); + return true; } + return false; } -inline void find_arg(std::vector& args, const std::string key, +inline bool find_arg(std::vector& args, const std::string key, long long& dest) { auto it = std::find(args.cbegin(), args.cend(), key); @@ -81,10 +87,12 @@ inline void find_arg(std::vector& args, const std::string key, { dest = stoll(*(it + 1)); args.erase(it, it + 2); + return true; } + return false; } -inline void find_arg(std::vector& args, const std::string key, +inline bool find_arg(std::vector& args, const std::string key, long int& dest) { auto it = std::find(args.cbegin(), args.cend(), key); @@ -92,10 +100,12 @@ inline void find_arg(std::vector& args, const std::string key, { dest = stol(*(it + 1)); args.erase(it, it + 2); + return true; } + return false; } -inline void find_arg(std::vector& args, const std::string key, +inline bool find_arg(std::vector& args, const std::string key, int& dest) { auto it = std::find(args.cbegin(), args.cend(), key); @@ -103,10 +113,12 @@ inline void find_arg(std::vector& args, const std::string key, { dest = stoi(*(it + 1)); args.erase(it, it + 2); + return true; } + return false; } -inline void find_arg(std::vector& args, const std::string key, +inline bool find_arg(std::vector& args, const std::string key, bool& dest, bool store = true) { auto it = std::find(args.cbegin(), args.cend(), key); @@ -114,10 +126,12 @@ inline void find_arg(std::vector& args, const std::string key, { dest = store; args.erase(it); + return true; } + return false; } -inline void find_arg(std::vector& args, const std::string key, +inline bool find_arg(std::vector& args, const std::string key, std::string& dest) { auto it = std::find(args.cbegin(), args.cend(), key); @@ -125,5 +139,7 @@ inline void find_arg(std::vector& args, const std::string key, { dest = std::move(*(it + 1)); args.erase(it, it + 2); + return true; } + return false; } From e4454aae7c5e174fb194c6c6beda674e9d7c295f Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Mon, 23 Dec 2024 23:32:27 -0600 Subject: [PATCH 3/5] apply formatting --- .../arkode/CXX_serial/ark_kpr_nestedmri.cpp | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp index b1dc8e886f..6d7ffaf25b 100644 --- a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp +++ b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp @@ -1630,10 +1630,22 @@ int ReadInputs(std::vector& args, Options& opts, SUNContext ctx) if (find_arg(args, "--k2f", opts.k2f)) { opts.set_k2f = true; } if (find_arg(args, "--k3f", opts.k3f)) { opts.set_k3f = true; } if (find_arg(args, "--bias", opts.bias)) { opts.set_bias = true; } - if (find_arg(args, "--htol_relch", opts.htol_relch)) { opts.set_htol_relch = true; } - if (find_arg(args, "--htol_minfac", opts.htol_minfac)) { opts.set_htol_minfac = true; } - if (find_arg(args, "--htol_maxfac", opts.htol_maxfac)) { opts.set_htol_maxfac = true; } - if (find_arg(args, "--safety", opts.slow_safety)) { opts.set_slow_safety = true; } + if (find_arg(args, "--htol_relch", opts.htol_relch)) + { + opts.set_htol_relch = true; + } + if (find_arg(args, "--htol_minfac", opts.htol_minfac)) + { + opts.set_htol_minfac = true; + } + if (find_arg(args, "--htol_maxfac", opts.htol_maxfac)) + { + opts.set_htol_maxfac = true; + } + if (find_arg(args, "--safety", opts.slow_safety)) + { + opts.set_slow_safety = true; + } // Check inputs for validity // 0 < rtol < 1 From 9defbc71712d74a246309c154a0ab778e7f71df1 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Sat, 28 Jun 2025 13:53:12 -0700 Subject: [PATCH 4/5] move enable unit tests to separate branch --- .gitlab/build_and_test.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitlab/build_and_test.sh b/.gitlab/build_and_test.sh index abb4da925c..bec3d36f36 100755 --- a/.gitlab/build_and_test.sh +++ b/.gitlab/build_and_test.sh @@ -177,7 +177,6 @@ then -DCMAKE_INSTALL_PREFIX=${install_dir} \ -DSUNDIALS_TEST_ENABLE_DEV_TESTS=ON \ -DSUNDIALS_TEST_ENABLE_DIFF_OUTPUT=OFF \ - -DSUNDIALS_TEST_ENABLE_UNIT_TESTS=ON \ -DMPIEXEC_EXECUTABLE=$(which $MPIEXEC_EXECUTABLE) \ -DMPIEXEC_PREFLAGS=${MPIEXEC_PREFLAGS} \ -DMPIEXEC_POSTFLAGS=${MPIEXEC_POSTFLAGS} \ @@ -191,7 +190,6 @@ then -DCMAKE_INSTALL_PREFIX=${install_dir} \ -DSUNDIALS_TEST_ENABLE_DEV_TESTS=ON \ -DSUNDIALS_TEST_ENABLE_DIFF_OUTPUT=OFF \ - -DSUNDIALS_TEST_ENABLE_UNIT_TESTS=ON \ -DMPIEXEC_EXECUTABLE=$(which $MPIEXEC_EXECUTABLE) \ -DMPIEXEC_PREFLAGS=${MPIEXEC_PREFLAGS} \ -DMPIEXEC_POSTFLAGS=${MPIEXEC_POSTFLAGS} \ From 9d32812a86d0816b2f21c80a0310a1f28dce9013 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Mon, 30 Jun 2025 08:15:23 -0700 Subject: [PATCH 5/5] fix merge --- .gitlab/build_and_test.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab/build_and_test.sh b/.gitlab/build_and_test.sh index bec3d36f36..abb4da925c 100755 --- a/.gitlab/build_and_test.sh +++ b/.gitlab/build_and_test.sh @@ -177,6 +177,7 @@ then -DCMAKE_INSTALL_PREFIX=${install_dir} \ -DSUNDIALS_TEST_ENABLE_DEV_TESTS=ON \ -DSUNDIALS_TEST_ENABLE_DIFF_OUTPUT=OFF \ + -DSUNDIALS_TEST_ENABLE_UNIT_TESTS=ON \ -DMPIEXEC_EXECUTABLE=$(which $MPIEXEC_EXECUTABLE) \ -DMPIEXEC_PREFLAGS=${MPIEXEC_PREFLAGS} \ -DMPIEXEC_POSTFLAGS=${MPIEXEC_POSTFLAGS} \ @@ -190,6 +191,7 @@ then -DCMAKE_INSTALL_PREFIX=${install_dir} \ -DSUNDIALS_TEST_ENABLE_DEV_TESTS=ON \ -DSUNDIALS_TEST_ENABLE_DIFF_OUTPUT=OFF \ + -DSUNDIALS_TEST_ENABLE_UNIT_TESTS=ON \ -DMPIEXEC_EXECUTABLE=$(which $MPIEXEC_EXECUTABLE) \ -DMPIEXEC_PREFLAGS=${MPIEXEC_PREFLAGS} \ -DMPIEXEC_POSTFLAGS=${MPIEXEC_POSTFLAGS} \