From 651aa3108377c9c9aa352b39bae7c31b96382de6 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 17 Apr 2025 09:08:51 -0500 Subject: [PATCH 001/128] Merged changes from dom_eig branch --- include/sundials/sundials_arnoldi.h | 89 ++++++++ src/sundials/CMakeLists.txt | 15 +- src/sundials/sundials_arnoldi.c | 271 ++++++++++++++++++++++++ test/unit_tests/sundials/CMakeLists.txt | 55 +++++ test/unit_tests/sundials/test_arnoldi.c | 264 +++++++++++++++++++++++ 5 files changed, 693 insertions(+), 1 deletion(-) create mode 100644 include/sundials/sundials_arnoldi.h create mode 100644 src/sundials/sundials_arnoldi.c create mode 100644 test/unit_tests/sundials/test_arnoldi.c diff --git a/include/sundials/sundials_arnoldi.h b/include/sundials/sundials_arnoldi.h new file mode 100644 index 0000000000..75e7c64ded --- /dev/null +++ b/include/sundials/sundials_arnoldi.h @@ -0,0 +1,89 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Mustafa Aggul @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2024, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------- + * This is the implementation file for the eigenvalue implementation of + * the SUNLINSOL package. + * -----------------------------------------------------------------*/ + +#ifndef _ARNOLDI_H +#define _ARNOLDI_H + +#include /* serial N_Vector types, fcts., macros */ +#include +#include + +#ifdef __cplusplus /* wrapper to enable C++ usage */ +extern "C" { +#endif + +/* Default ARNOLDI parameters */ +#define ARNOLDI_MAXL_DEFAULT 3 +#define MSG_ARK_NULL_ATIMES "ATimes is null." +#define MSG_ARK_NULL_q "q is null." +#define MSG_ARK_NULL_SUNCTX "sunctx is null." +#define MSG_ARK_BAD_NVECTOR "Bad NVector." +#define MSG_ARNOLDI_MEM_FAIL "ARNOLDI memory fail." + +#define DEFAULT_POWER_OF_A 0 + +/*=============================================================== + ARNOLDI module data structure + ===============================================================*/ + +/*--------------------------------------------------------------- + Types : struct ARNOLDIMemRec, ARNOLDIMem + --------------------------------------------------------------- + The type ARNOLDIMem is type pointer to struct + ARNOLDIMemRec. This structure contains fields to + perform an ARNOLDI iteration. + ---------------------------------------------------------------*/ +typedef struct ARNOLDIMemRec +{ + /* ARNOLDI MEMORY specification */ + SUNATimesFn ATimes; /* User provided ATimes function */ + void* Adata; /* ATimes function data*/ + + N_Vector *V, q; /* Krylov subspace vectors */ + sunrealtype **Hes; /* Hessenberg matrix Hes */ + + int maxl; /* Krylov subspace dimension */ + int power_of_A; /* Power of A in the preprocessing; initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ + +}* ARNOLDIMem; + +// Struct to hold the real and imaginary parts +typedef struct { + sunrealtype real; + sunrealtype imag; +} suncomplextype; + +/* ------------------------------------- + * Exported Functions for ARNOLDI + * ------------------------------------- */ + +/* Creation and Reinitialization functions */ + +SUNDIALS_EXPORT void* ArnoldiCreate(SUNATimesFn ATimes, void* Adata, + N_Vector q, int maxl, SUNContext sunctx); + +SUNDIALS_EXPORT int ArnoldiComputeHess(ARNOLDIMem arnoldi_mem); + +SUNDIALS_EXPORT int ArnoldiPreProcess(ARNOLDIMem arnoldi_mem); + +SUNDIALS_EXPORT suncomplextype ArnoldiEstimate(ARNOLDIMem arnoldi_mem); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/sundials/CMakeLists.txt b/src/sundials/CMakeLists.txt index cf31cb497e..cdf53236ec 100644 --- a/src/sundials/CMakeLists.txt +++ b/src/sundials/CMakeLists.txt @@ -69,6 +69,10 @@ if(ENABLE_SYCL) list(APPEND sundials_HEADERS sundials_sycl_policies.hpp) endif() +if(ENABLE_LAPACK) + list(APPEND sundials_HEADERS sundials_arnoldi.h) +endif() + # If enabled, add the XBraid interface header if(ENABLE_XBRAID) list(APPEND sundials_HEADERS sundials_xbraid.h) @@ -102,6 +106,15 @@ if(ENABLE_MPI) list(APPEND sundials_SOURCES sundials_mpi_errors.c) endif() +if(ENABLE_LAPACK) + list(APPEND sundials_SOURCES sundials_arnoldi.c) + set(_link_lapack_if_needed PUBLIC LAPACK::LAPACK) + if(CMAKE_VERSION VERSION_LESS 3.20) + list(APPEND _link_lapack_if_needed BLAS::BLAS) + endif() +endif() + + # Add prefix with complete path to the source files add_prefix(${SUNDIALS_SOURCE_DIR}/src/sundials/ sundials_SOURCES) @@ -125,7 +138,7 @@ sundials_add_library( SOURCES ${sundials_SOURCES} HEADERS ${sundials_HEADERS} INCLUDE_SUBDIR sundials - LINK_LIBRARIES ${_link_mpi_if_needed} + LINK_LIBRARIES ${_link_mpi_if_needed} ${_link_lapack_if_needed} OUTPUT_NAME sundials_core VERSION ${sundialslib_VERSION} SOVERSION ${sundialslib_SOVERSION}) diff --git a/src/sundials/sundials_arnoldi.c b/src/sundials/sundials_arnoldi.c new file mode 100644 index 0000000000..60059cc282 --- /dev/null +++ b/src/sundials/sundials_arnoldi.c @@ -0,0 +1,271 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Mustafa Aggul @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2024, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------- + * This is the implementation file for the eigenvalue implementation of + * the SUNLINSOL package. + * -----------------------------------------------------------------*/ + +#include +#include +#include +#include + +#define ZERO SUN_RCONST(0.0) + +/* + * ----------------------------------------------------------------- + * internal functions + * ----------------------------------------------------------------- + */ + +sunbooleantype arnoldi_CheckNVector(N_Vector tmpl); +double arnoldi_magnitude(const suncomplextype *c); +int arnoldi_compare(const void *a, const void *b); + +/* + * ----------------------------------------------------------------- + * LAPACK function + * ----------------------------------------------------------------- + */ + +extern void dgeev_(char* jobvl, char* jobvr, int* n, double* a, int* lda, + double* wr, double* wi, double* vl, int* ldvl, double* vr, + int* ldvr, double* work, int* lwork, int* info); + +/* + * ----------------------------------------------------------------- + * exported functions + * ----------------------------------------------------------------- + */ + +void* ArnoldiCreate(SUNATimesFn ATimes, void* Adata, + N_Vector q, int maxl, SUNContext sunctx) +{ + int retval; + ARNOLDIMem arnoldi_mem; + sunbooleantype nvectorOK; + + /* Test if all required vector operations are implemented */ + nvectorOK = arnoldi_CheckNVector(q); + if (!nvectorOK) + { + return NULL; + } + + /* Test if Atimes is provided */ + if (ATimes == NULL) + { + return NULL; + } + + /* Check if maxl > 2 */ + if (maxl < 3) + { + return NULL; + } + + if (sunctx == NULL) + { + return NULL; + } + + + /* Allocate ARNOLDIMem structure, and initialize to zero */ + arnoldi_mem = (ARNOLDIMem)calloc(1, sizeof(*arnoldi_mem)); + + arnoldi_mem->ATimes = ATimes; + arnoldi_mem->Adata = Adata; + arnoldi_mem->q = q; + arnoldi_mem->maxl = maxl; + arnoldi_mem->power_of_A = DEFAULT_POWER_OF_A; + + /* Hessenberg matrix Hes */ + if (arnoldi_mem->Hes == NULL) + { + arnoldi_mem->Hes = + (sunrealtype**)malloc((maxl + 1) * sizeof(sunrealtype*)); + + for (int k = 0; k <= maxl; k++) + { + arnoldi_mem->Hes[k] = NULL; + arnoldi_mem->Hes[k] = (sunrealtype*)malloc(maxl * sizeof(sunrealtype)); + } + } + + /* Krylov subspace vectors */ + if (arnoldi_mem->V == NULL) + { + arnoldi_mem->V = N_VCloneVectorArray(maxl + 1, q); + } + + /* Unitize the initial vector V[0] */ + sunrealtype normq = N_VDotProd(q, q); + normq = SUNRsqrt(normq); + N_VScale(SUN_RCONST(1.0)/normq, arnoldi_mem->q, arnoldi_mem->V[0]); + + return (void*)arnoldi_mem; +} + +/* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ +int ArnoldiPreProcess(ARNOLDIMem arnoldi_mem) +{ + /* Check if Arnoldi memory is allocated */ + if(arnoldi_mem == NULL) + { + printf("Error: Arnoldi memory is not allocated yet!"); + return -1; + } + + /* Check if ATimes is provided */ + if(arnoldi_mem->ATimes == NULL) + { + printf("Error: ATimes function is NULL!"); + return -1; + } + + sunrealtype normq; + + /* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ + for(int i = 0; i < arnoldi_mem->power_of_A; i++) { + arnoldi_mem->ATimes(arnoldi_mem->Adata, arnoldi_mem->V[0], arnoldi_mem->q); + normq = N_VDotProd(arnoldi_mem->q, arnoldi_mem->q); + normq = SUNRsqrt(normq); + N_VScale(SUN_RCONST(1.0)/normq, arnoldi_mem->q, arnoldi_mem->V[0]); + } +} + +/* Compute the Hessenberg matrix Arnoldi_mem->Hes*/ +int ArnoldiComputeHess(ARNOLDIMem arnoldi_mem) +{ + /* Initialize the Hessenberg matrix Hes with zeros */ + for (int i = 0; i < arnoldi_mem->maxl; i++) + { + for (int j = 0; j < arnoldi_mem->maxl; j++) { arnoldi_mem->Hes[i][j] = ZERO; } + } + + for (int i = 0; i < arnoldi_mem->maxl; i++) + { + /* Compute the next Krylov vector */ + arnoldi_mem->ATimes(arnoldi_mem->Adata, arnoldi_mem->V[i], arnoldi_mem->V[i+1]); + SUNModifiedGS(arnoldi_mem->V, arnoldi_mem->Hes, i + 1, arnoldi_mem->maxl, &(arnoldi_mem->Hes[i + 1][i])); + + /* Unitize the computed orthogonal vector */ + N_VScale(SUN_RCONST(1.0)/arnoldi_mem->Hes[i + 1][i], arnoldi_mem->V[i+1], arnoldi_mem->V[i+1]); + } +} + +/* Estimate the dominant eigvalues of the Hessenberg matrix */ +suncomplextype ArnoldiEstimate(ARNOLDIMem arnoldi_mem) { + suncomplextype dom_eig; + dom_eig.real = ZERO; + dom_eig.imag = ZERO; + + int n = arnoldi_mem->maxl; + + /* Create the vector A which holds rows of the Hessenberg matrix in the given order */ + sunrealtype* A; + A = (sunrealtype*)malloc((n*n) * sizeof(sunrealtype)); + int k = 0; + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + A[k] = arnoldi_mem->Hes[i][j]; + k++; + } + } + + double wr[n], wi[n]; // Real and imaginary parts of eigenvalues + double vl[n*n], vr[n*n]; // Left and right eigenvectors (optional, can be NULL) + int lda = n, ldvl = n, ldvr = n; + int info, lwork = 4 * n; + double work[4 * n]; // Workspace array + + char jobvl = 'N'; // Do not compute left eigenvectors + char jobvr = 'N'; // Do not compute right eigenvectors + + // Call LAPACK's dgeev function + dgeev_(&jobvl, &jobvr, &n, A, &lda, wr, wi, vl, &ldvl, vr, &ldvr, work, &lwork, &info); + + if (info != 0) { + printf("Error: LAPACK dgeev failed with info = %d\n", info); + return dom_eig; + } + + //Following part will order the eigenvalues by their magnitude + { + // Create an array of suncomplextype structs + suncomplextype *arr = (suncomplextype *)malloc(n * sizeof(suncomplextype)); + for (int i = 0; i < n; i++) { + arr[i].real = wr[i]; + arr[i].imag = wi[i]; + } + + // Sort the array + qsort(arr, n, sizeof(suncomplextype), arnoldi_compare); + + // Update the original arrays + for (int i = 0; i < n; i++) { + wr[i] = arr[i].real; + wi[i] = arr[i].imag; + } + + // Cleanup + free(arr); + } + + // Print eigenvalues + printf("\nEigenvalues:\n"); + for (int i = 0; i < n; i++) { + if (wi[i] == 0.0) { + printf("%f\n", wr[i]); // sunrealtype eigenvalue + } else { + printf("%f + %fi\n", wr[i], wi[i]); // suncomplextype eigenvalue + } + } + + dom_eig.real = wr[0]; + dom_eig.imag = wi[0]; + + return dom_eig; +} + +/*--------------------------------------------------------------- + arnoldi_CheckNVector: + + This routine checks if all required vector operations are + present. If any of them is missing it returns SUNFALSE. + ---------------------------------------------------------------*/ +sunbooleantype arnoldi_CheckNVector(N_Vector tmpl) +{ // TO DO: check required vector operations + if ((tmpl->ops->nvclone == NULL) || (tmpl->ops->nvdestroy == NULL) || + (tmpl->ops->nvlinearsum == NULL) || (tmpl->ops->nvconst == NULL) || + (tmpl->ops->nvscale == NULL) || (tmpl->ops->nvwrmsnorm == NULL) || + (tmpl->ops->nvspace == NULL)) + { + return SUNFALSE; + } + return SUNTRUE; +} + +// Function to calculate the magnitude of a suncomplextype number +double arnoldi_magnitude(const suncomplextype *c) { + return sqrt(c->real * c->real + c->imag * c->imag); +} + +// Comparison function for qsort +int arnoldi_compare(const void *a, const void *b) { + const suncomplextype *c1 = (const suncomplextype *)a; + const suncomplextype *c2 = (const suncomplextype *)b; + double mag1 = arnoldi_magnitude(c1); + double mag2 = arnoldi_magnitude(c2); + return (mag2 > mag1) - (mag2 < mag1); // Descending order +} \ No newline at end of file diff --git a/test/unit_tests/sundials/CMakeLists.txt b/test/unit_tests/sundials/CMakeLists.txt index 1883aa072b..685f046111 100644 --- a/test/unit_tests/sundials/CMakeLists.txt +++ b/test/unit_tests/sundials/CMakeLists.txt @@ -20,4 +20,59 @@ if(SUNDIALS_ENABLE_ERROR_CHECKS) endif() endif() +# Tests for the arnoldi utility routine (estimates dominant eigenvalue) +if(ENABLE_LAPACK) + set(unit_tests + "test_arnoldi\;100 10\;" + "test_arnoldi\;1000 20\;" + "test_arnoldi\;10000 50\;") + + # Add the build and install targets for each test + foreach(test_tuple ${unit_tests}) + + # parse the test tuple + list(GET test_tuple 0 test) + list(GET test_tuple 1 test_args) + + # check if this test has already been added, only need to add test source + # files once for testing with different inputs + if(NOT TARGET ${test}) + + # test source files + add_executable(${test} ${test}.c) + + set_target_properties(${test} PROPERTIES FOLDER "unit_tests") + + # include location of public and private header files + target_include_directories( + ${test} PRIVATE $ + ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/src) + + # libraries to link against + set(_arnoldi_libs sundials_core sundials_nvecserial LAPACK::LAPACK) + if(CMAKE_VERSION VERSION_LESS 3.20) + list(APPEND _arnoldi_libs BLAS::BLAS) + endif() + target_link_libraries(${test} ${_arnoldi_libs} + ${EXE_EXTRA_LINK_LIBS}) + + endif() + + # check if test args are provided and set the test name + if("${test_args}" STREQUAL "") + set(test_name ${test}) + else() + string(REPLACE " " "_" test_name "${test}_${test_args}") + string(REPLACE " " ";" test_args "${test_args}") + endif() + + # add test to regression tests + add_test(NAME ${test_name} COMMAND ${test} ${test_args}) + + endforeach() + + message(STATUS "Added arnoldi units tests") +endif() + + add_subdirectory(reductions) diff --git a/test/unit_tests/sundials/test_arnoldi.c b/test/unit_tests/sundials/test_arnoldi.c new file mode 100644 index 0000000000..27562c88cb --- /dev/null +++ b/test/unit_tests/sundials/test_arnoldi.c @@ -0,0 +1,264 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Mustafa Aggul @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2024, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------- + * These test functions check some components of an Arnoldi iteration + * module implementation. + * ----------------------------------------------------------------- + */ + +#include +#include +#include /* def. of SUNRsqrt, etc. */ +#include /* definition of type sunrealtype */ +#include + + +#if defined(SUNDIALS_EXTENDED_PRECISION) +#define GSYM "Lg" +#define ESYM "Le" +#define FSYM "Lf" +#else +#define GSYM "g" +#define ESYM "e" +#define FSYM "f" +#endif + +/* constants */ +#define ZERO SUN_RCONST(0.0) + +#define factor (-100.0) +#define realpart (-30000.0) +#define imagpart (+40000.0) + +/* user data structure */ +typedef struct +{ + sunindextype N; /* problem size */ + N_Vector d; /* matrix diagonal */ + sunrealtype real_part; /* nondiagonal entries of the matrix */ + sunrealtype imag_part; /* nondiagonal entries of the matrix */ +} UserData; + +/* private functions */ +/* matrix-vector product */ +int ATimes(void* ProbData, N_Vector v, N_Vector z); +/* checks function return values */ +static int check_flag(void* flagvalue, const char* funcname, int opt); +/* uniform random number generator in [0,1] */ +static int check_vector(N_Vector X, N_Vector Y, sunrealtype tol); + +/* global copy of the problem size (for check_vector routine) */ +sunindextype problem_size; + + +/* ---------------------------------------------------------------------- + * Arnoldi Iteration Testing Routine + * --------------------------------------------------------------------*/ +int main(int argc, char* argv[]) +{ + int fails = 0; /* counter for test failures */ + int passfail = 0; /* overall pass/fail flag */ + N_Vector q; /* test vectors */ + UserData ProbData; /* problem data structure */ + int maxl, failure; + SUNContext sunctx; + sunrealtype tolerans = 1.0e-2; + + if (SUNContext_Create(SUN_COMM_NULL, &sunctx)) + { + printf("ERROR: SUNContext_Create failed\n"); + return (-1); + } + + /* check inputs: local problem size */ + if (argc < 3) + { + printf("ERROR: TWO (2) Inputs required:\n"); + printf(" Problem size should be >0\n"); + printf(" Krylov subspace dimension should be >0\n"); + return 1; + } + ProbData.N = (sunindextype)atol(argv[1]); + problem_size = ProbData.N; + if (ProbData.N <= 0) + { + printf("ERROR: Problem size must be a positive integer\n"); + return 1; + } + maxl = atoi(argv[2]); + if (maxl <= 0) + { + printf( + "ERROR: Krylov subspace dimension must be a positive integer\n"); + return 1; + } + + printf("\nArnoldi iteration test:\n"); + printf(" Problem size = %ld\n", (long int)ProbData.N); + printf(" Krylov subspace dimension = %i\n", maxl); + + /* Create vectors */ + q = N_VNew_Serial(ProbData.N, sunctx); + if (check_flag(q, "N_VNew_Serial", 0)) { return 1; } + ProbData.d = N_VClone(q); + if (check_flag(ProbData.d, "N_VClone", 0)) { return 1; } + + /* Fill q vector with 1s */ + N_VConst(SUN_RCONST(1.0), q); + + /* Fill matrix diagonal and problem data */ + // real diag is factor*[3 4 5 ... N 0 0] + // suncomplextype diag is [ realpart imagpart; + // -imagpart realpart] + sunrealtype *v = N_VGetArrayPointer(ProbData.d); + for(int i=0; i < ProbData.N-2; i++) + { + v[i] = factor*(i + 3); + } + + ProbData.real_part = realpart; + ProbData.imag_part = imagpart; + + /* Create ARNOLDI memory structure */ + ARNOLDIMem Arnoldi_mem; + Arnoldi_mem = ArnoldiCreate(ATimes, &ProbData, q, maxl,sunctx); + + /* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ + ArnoldiPreProcess(Arnoldi_mem); + + /* Compute the Hessenberg matrix Hes*/ + ArnoldiComputeHess(Arnoldi_mem); + + /* Print the Hessenberg matrix Hes if N <= 10*/ + if(ProbData.N <= 10){ + printf("\n"); + printf("Hes:\n"); + for (int i = 0; i < Arnoldi_mem->maxl + 1; i++) { + for (int j = 0; j < Arnoldi_mem->maxl; j++) { + printf("%20.2lf ", Arnoldi_mem->Hes[i][j]); + } + printf("\n"); + } + } + + suncomplextype dom_eig = ArnoldiEstimate(Arnoldi_mem); + sunrealtype norm_of_dom_eig = SUNRsqrt(dom_eig.real * dom_eig.real + dom_eig.imag * dom_eig.imag); + if(norm_of_dom_eig < SUN_SMALL_REAL) { + printf("FAIL: Dominant Eigenvalue Test Failed"); + return 1; + } + + suncomplextype true_dom_eig; + /* Identify true_dom_eig based on given parameters*/ + if(SUNRsqrt(realpart * realpart + imagpart * imagpart) > -1.0 * factor * ProbData.N) + { + true_dom_eig.real = realpart; + true_dom_eig.imag = imagpart; + } + else + { + true_dom_eig.real = factor*ProbData.N; + true_dom_eig.imag = ZERO; + } + + printf("\ncomputed dominant eigenvalue = %20.4lf + %20.4lfi\n", dom_eig.real, dom_eig.imag); + printf(" true dominant eigenvalue = %20.4lf + %20.4lfi\n", true_dom_eig.real, true_dom_eig.imag); + + /* Compare the estimated dom_eig with true_dom_eig*/ + sunrealtype error = SUNRsqrt((dom_eig.real - true_dom_eig.real) * (dom_eig.real - true_dom_eig.real) + + (dom_eig.imag - true_dom_eig.imag) * (dom_eig.imag - true_dom_eig.imag)); + + error /= norm_of_dom_eig; + + if(error < tolerans) { + printf("\n\nPASS: relative error = %lf\n", error); + return 0; + } + else { + printf("\n\nFAIL: relative error = %lf\n", error); + return 0; + } + + /* Free solver and vectors */ + N_VDestroy(q); + N_VDestroy(ProbData.d); + SUNContext_Free(&sunctx); + + return (passfail); +} + +/* ---------------------------------------------------------------------- + * Private helper functions + * --------------------------------------------------------------------*/ + +/* matrix-vector product */ +int ATimes(void* Data, N_Vector v_vec, N_Vector z_vec) +{ + /* local variables */ + sunrealtype *v, *z, *diag, real_part, imag_part; + sunindextype i, N; + UserData* ProbData; + + /* access user data structure and vector data */ + ProbData = (UserData*)Data; + v = N_VGetArrayPointer(v_vec); + if (check_flag(v, "N_VGetArrayPointer", 0)) { return 1; } + z = N_VGetArrayPointer(z_vec); + if (check_flag(z, "N_VGetArrayPointer", 0)) { return 1; } + N = ProbData->N; + real_part = ProbData->real_part; + imag_part = ProbData->imag_part; + diag = N_VGetArrayPointer(ProbData->d); + if (check_flag(diag, "N_VGetArrayPointer", 0)) { return 1; } + + /* perform product on the diagonal part of the matrix */ + for (i = 0; i < N - 2; i++) + { + z[i] = diag[i] * v[i]; + } + + /* perform product at the non-diagonal last two rows */ + z[N - 2] = v[N - 2] * real_part + v[N - 1] * imag_part; + z[N - 1] = v[N - 1] * real_part - v[N - 2] * imag_part; + /* return with success */ + return 0; +} + +/* Check function return value based on "opt" input: + 0: function allocates memory so check for NULL pointer + 1: function returns a flag so check for flag != 0 */ +static int check_flag(void* flagvalue, const char* funcname, int opt) +{ + int* errflag; + + /* Check if function returned NULL pointer - no memory allocated */ + if (opt == 0 && flagvalue == NULL) + { + fprintf(stderr, "\nERROR: %s() failed - returned NULL pointer\n\n", funcname); + return 1; + } + + /* Check if flag != 0 */ + if (opt == 1) + { + errflag = (int*)flagvalue; + if (*errflag != 0) + { + fprintf(stderr, "\nERROR: %s() failed with flag = %d\n\n", funcname, + *errflag); + return 1; + } + } + + return 0; +} From 255360379efda83d055456f09a9ab1d2ce29b67b Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 21 Apr 2025 08:29:12 -0500 Subject: [PATCH 002/128] Initial construction of N_VRandom -- still need to add this to a few implementations --- doc/shared/nvectors/NVector_Description.rst | 4 ++ doc/shared/nvectors/NVector_Operations.rst | 19 ++++++ .../nvector/C_openmp/test_nvector_openmp.c | 1 + .../manyvector/test_nvector_manyvector.c | 1 + .../test_nvector_mpimanyvector_parallel1.c | 1 + .../test_nvector_mpimanyvector_parallel2.c | 1 + .../nvector/mpiplusx/test_nvector_mpiplusx.c | 1 + .../openmpdev/test_nvector_openmpdev.c | 1 + examples/nvector/parallel/test_nvector_mpi.c | 1 + examples/nvector/parhyp/test_nvector_parhyp.c | 1 + examples/nvector/petsc/test_nvector_petsc.c | 1 + .../nvector/pthreads/test_nvector_pthreads.c | 1 + examples/nvector/serial/test_nvector_serial.c | 1 + examples/nvector/test_nvector.c | 61 +++++++++++++++++++ examples/nvector/test_nvector.h | 1 + include/nvector/nvector_kokkos.hpp | 12 ++++ include/sundials/sundials_nvector.h | 5 ++ src/nvector/cuda/VectorKernels.cuh | 17 ++++++ src/nvector/cuda/nvector_cuda.cu | 21 +++++++ src/nvector/parallel/nvector_parallel.c | 15 +++++ src/nvector/parhyp/nvector_parhyp.c | 15 +++++ src/nvector/petsc/nvector_petsc.c | 13 ++++ src/nvector/serial/nvector_serial.c | 15 +++++ src/nvector/trilinos/nvector_trilinos.cpp | 19 ++++++ src/sundials/sundials_nvector.c | 20 ++++++ 25 files changed, 248 insertions(+) diff --git a/doc/shared/nvectors/NVector_Description.rst b/doc/shared/nvectors/NVector_Description.rst index c4d5eb7054..7fbf6a7feb 100644 --- a/doc/shared/nvectors/NVector_Description.rst +++ b/doc/shared/nvectors/NVector_Description.rst @@ -214,6 +214,10 @@ The virtual table structure is defined as The function implementing :c:func:`N_VLinearCombinationVectorArray` + .. c:member:: SUNErrCode (*nvrandom)(N_Vector) + + The function implementing :c:func:`N_VRandom` + .. c:member:: sunrealtype (*nvdotprodlocal)(N_Vector, N_Vector) The function implementing :c:func:`N_VDotProdLocal` diff --git a/doc/shared/nvectors/NVector_Operations.rst b/doc/shared/nvectors/NVector_Operations.rst index 475abc4a84..40a8387559 100644 --- a/doc/shared/nvectors/NVector_Operations.rst +++ b/doc/shared/nvectors/NVector_Operations.rst @@ -1036,6 +1036,25 @@ usage. flag = N_VBufUnpack(x, buf) +.. _NVectors.Ops.Random: + +Random number operation +----------------------- + +The following optional vector operation fills a vector data to be uniformly-distributed random numbers between 0 and 1. + +.. c:function:: SUNErrCode N_VRandom(N_Vector x) + + This routine fills *x* with uniformly-distributed random numbers in the + interval :math:`[0,1]`. + + Usage: + + .. code-block:: c + + flag = N_VRandom(x); + + .. _NVectors.Ops.Print: Output operations diff --git a/examples/nvector/C_openmp/test_nvector_openmp.c b/examples/nvector/C_openmp/test_nvector_openmp.c index 65ccdcebe1..fd1892d1ee 100644 --- a/examples/nvector/C_openmp/test_nvector_openmp.c +++ b/examples/nvector/C_openmp/test_nvector_openmp.c @@ -143,6 +143,7 @@ int main(int argc, char* argv[]) fails += Test_N_VInvTest(X, Z, length, 0); fails += Test_N_VConstrMask(X, Y, Z, length, 0); fails += Test_N_VMinQuotient(X, Y, length, 0); + if (X->ops->nvrandom) { fails += Test_N_VRandom(X, 0); } /* Fused and vector array operations tests (disabled) */ printf("\nTesting fused and vector array operations (disabled):\n\n"); diff --git a/examples/nvector/manyvector/test_nvector_manyvector.c b/examples/nvector/manyvector/test_nvector_manyvector.c index 1e6a5b83d6..1a047e07f6 100644 --- a/examples/nvector/manyvector/test_nvector_manyvector.c +++ b/examples/nvector/manyvector/test_nvector_manyvector.c @@ -166,6 +166,7 @@ int main(int argc, char* argv[]) fails += Test_N_VInvTest(X, Z, length, 0); fails += Test_N_VConstrMask(X, Y, Z, length, 0); fails += Test_N_VMinQuotient(X, Y, length, 0); + if (X->ops->nvrandom) { fails += Test_N_VRandom(X, 0); } /* Fused and vector array operations tests (disabled) */ printf("\nTesting fused and vector array operations (disabled):\n\n"); diff --git a/examples/nvector/mpimanyvector/test_nvector_mpimanyvector_parallel1.c b/examples/nvector/mpimanyvector/test_nvector_mpimanyvector_parallel1.c index 40ce5f3a4a..fe65b8e381 100644 --- a/examples/nvector/mpimanyvector/test_nvector_mpimanyvector_parallel1.c +++ b/examples/nvector/mpimanyvector/test_nvector_mpimanyvector_parallel1.c @@ -231,6 +231,7 @@ int main(int argc, char* argv[]) fails += Test_N_VInvTest(X, Z, local_length, myid); fails += Test_N_VConstrMask(X, Y, Z, local_length, myid); fails += Test_N_VMinQuotient(X, Y, local_length, myid); + if (X->ops->nvrandom) { fails += Test_N_VRandom(X, myid); } /* Fused and vector array operations tests (disabled) */ if (myid == 0) diff --git a/examples/nvector/mpimanyvector/test_nvector_mpimanyvector_parallel2.c b/examples/nvector/mpimanyvector/test_nvector_mpimanyvector_parallel2.c index 90308cae82..681163a6bf 100644 --- a/examples/nvector/mpimanyvector/test_nvector_mpimanyvector_parallel2.c +++ b/examples/nvector/mpimanyvector/test_nvector_mpimanyvector_parallel2.c @@ -258,6 +258,7 @@ int main(int argc, char* argv[]) fails += Test_N_VInvTest(X, Z, local_length, myid); fails += Test_N_VConstrMask(X, Y, Z, local_length, myid); fails += Test_N_VMinQuotient(X, Y, local_length, myid); + if (X->ops->nvrandom) { fails += Test_N_VRandom(X, myid); } /* Fused and vector array operations tests (disabled) */ if (myid == 0) diff --git a/examples/nvector/mpiplusx/test_nvector_mpiplusx.c b/examples/nvector/mpiplusx/test_nvector_mpiplusx.c index 404f40bf63..69e682680e 100644 --- a/examples/nvector/mpiplusx/test_nvector_mpiplusx.c +++ b/examples/nvector/mpiplusx/test_nvector_mpiplusx.c @@ -196,6 +196,7 @@ int main(int argc, char* argv[]) fails += Test_N_VInvTest(X, Z, local_length, myid); fails += Test_N_VConstrMask(X, Y, Z, local_length, myid); fails += Test_N_VMinQuotient(X, Y, local_length, myid); + if (X->ops->nvrandom) { fails += Test_N_VRandom(X, myid); } /* Fused and vector array operations tests (disabled) */ if (myid == 0) diff --git a/examples/nvector/openmpdev/test_nvector_openmpdev.c b/examples/nvector/openmpdev/test_nvector_openmpdev.c index 3c640cabcd..aad0a31f4a 100644 --- a/examples/nvector/openmpdev/test_nvector_openmpdev.c +++ b/examples/nvector/openmpdev/test_nvector_openmpdev.c @@ -137,6 +137,7 @@ int main(int argc, char* argv[]) fails += Test_N_VInvTest(X, Z, length, 0); fails += Test_N_VConstrMask(X, Y, Z, length, 0); fails += Test_N_VMinQuotient(X, Y, length, 0); + if (X->ops->nvrandom) { fails += Test_N_VRandom(X, 0); } /* Fused and vector array operations tests (disabled) */ printf("\nTesting fused and vector array operations (disabled):\n\n"); diff --git a/examples/nvector/parallel/test_nvector_mpi.c b/examples/nvector/parallel/test_nvector_mpi.c index 1d9cee5005..8c26efdb17 100644 --- a/examples/nvector/parallel/test_nvector_mpi.c +++ b/examples/nvector/parallel/test_nvector_mpi.c @@ -158,6 +158,7 @@ int main(int argc, char* argv[]) fails += Test_N_VInvTest(X, Z, local_length, myid); fails += Test_N_VConstrMask(X, Y, Z, local_length, myid); fails += Test_N_VMinQuotient(X, Y, local_length, myid); + if (X->ops->nvrandom) { fails += Test_N_VRandom(X, myid); } /* Fused and vector array operations tests (disabled) */ if (myid == 0) diff --git a/examples/nvector/parhyp/test_nvector_parhyp.c b/examples/nvector/parhyp/test_nvector_parhyp.c index 6e66901d76..8f3cc8c9d8 100644 --- a/examples/nvector/parhyp/test_nvector_parhyp.c +++ b/examples/nvector/parhyp/test_nvector_parhyp.c @@ -174,6 +174,7 @@ int main(int argc, char* argv[]) fails += Test_N_VInvTest(X, Z, local_length, myid); fails += Test_N_VConstrMask(X, Y, Z, local_length, myid); fails += Test_N_VMinQuotient(X, Y, local_length, myid); + if (X->ops->nvrandom) { fails += Test_N_VRandom(X, myid); } /* Fused and vector array operations tests (disabled) */ if (myid == 0) diff --git a/examples/nvector/petsc/test_nvector_petsc.c b/examples/nvector/petsc/test_nvector_petsc.c index 6b442c29e6..1e7cc1d54e 100644 --- a/examples/nvector/petsc/test_nvector_petsc.c +++ b/examples/nvector/petsc/test_nvector_petsc.c @@ -165,6 +165,7 @@ int main(int argc, char* argv[]) fails += Test_N_VInvTest(X, Z, local_length, myid); fails += Test_N_VConstrMask(X, Y, Z, local_length, myid); fails += Test_N_VMinQuotient(X, Y, local_length, myid); + if (X->ops->nvrandom) { fails += Test_N_VRandom(X, myid); } /* Fused and vector array operations tests (disabled) */ if (myid == 0) diff --git a/examples/nvector/pthreads/test_nvector_pthreads.c b/examples/nvector/pthreads/test_nvector_pthreads.c index 31d4c44826..1125093a8e 100644 --- a/examples/nvector/pthreads/test_nvector_pthreads.c +++ b/examples/nvector/pthreads/test_nvector_pthreads.c @@ -143,6 +143,7 @@ int main(int argc, char* argv[]) fails += Test_N_VInvTest(X, Z, length, 0); fails += Test_N_VConstrMask(X, Y, Z, length, 0); fails += Test_N_VMinQuotient(X, Y, length, 0); + if (X->ops->nvrandom) { fails += Test_N_VRandom(X, 0); } /* Fused and vector array operations tests (disabled) */ printf("\nTesting fused and vector array operations (disabled):\n\n"); diff --git a/examples/nvector/serial/test_nvector_serial.c b/examples/nvector/serial/test_nvector_serial.c index 624044a035..a43bdd18a4 100644 --- a/examples/nvector/serial/test_nvector_serial.c +++ b/examples/nvector/serial/test_nvector_serial.c @@ -139,6 +139,7 @@ int main(int argc, char* argv[]) fails += Test_N_VInvTest(X, Z, length, 0); fails += Test_N_VConstrMask(X, Y, Z, length, 0); fails += Test_N_VMinQuotient(X, Y, length, 0); + if (X->ops->nvrandom) { fails += Test_N_VRandom(X, 0); } /* Fused and vector array operations tests (disabled) */ printf("\nTesting fused and vector array operations (disabled):\n\n"); diff --git a/examples/nvector/test_nvector.c b/examples/nvector/test_nvector.c index a7d5741522..2d5b72d1a7 100644 --- a/examples/nvector/test_nvector.c +++ b/examples/nvector/test_nvector.c @@ -5566,6 +5566,67 @@ int Test_N_VMinQuotientLocal(N_Vector NUM, N_Vector DENOM, return (fails); } +/* ---------------------------------------------------------------------- + * N_VRandom Test + * --------------------------------------------------------------------*/ +int Test_N_VRandom(N_Vector X, int myid) +{ + SUNErrCode ierr = SUN_SUCCESS; + int failure = 0; + sunrealtype ymin, ymax; + + /* create vector for testing */ + N_Vector Y = N_VClone(X); + + /* fill Y with random data in [0,1] */ + ierr = N_VRandom(Y); + + /* routine should pass, and the max/min values should be different and within [0,1] */ + if (ierr != SUN_SUCCESS) + { + printf(">>> FAILED test -- N_VRandom, Proc %d \n", myid); + failure = 1; + } + else + { + ymin = N_VMin(Y); + ymax = N_VMaxNorm(Y); + if (ymin == ymax) + { + printf(">>> FAILED test -- N_VRandom, Proc %d (ymin == ymax = %" FSYM ") \n", myid, ymin); + failure = 1; + } + if (ymin < ZERO) + { + printf(">>> FAILED test -- N_VRandom, Proc %d (ymin = %" FSYM " < 0) \n", myid, ymin); + failure = 1; + } + if (ymin > ONE) + { + printf(">>> FAILED test -- N_VRandom, Proc %d (ymin = %" FSYM " > 1) \n", myid, ymin); + failure = 1; + } + if (ymax < ZERO) + { + printf(">>> FAILED test -- N_VRandom, Proc %d (ymax = %" FSYM " < 0) \n", myid, ymax); + failure = 1; + } + if (ymax > ONE) + { + printf(">>> FAILED test -- N_VRandom, Proc %d (ymax = %" FSYM " > 1) \n", myid, ymax); + failure = 1; + } + } + + if ((failure == 0) && (myid == 0)) + { + printf("PASSED test -- N_VRandom \n"); + } + + N_VDestroy(Y); + return (failure); +} + /* ---------------------------------------------------------------------- * N_VDotProdMultiLocal Test * --------------------------------------------------------------------*/ diff --git a/examples/nvector/test_nvector.h b/examples/nvector/test_nvector.h index 7984712649..60d47860e7 100644 --- a/examples/nvector/test_nvector.h +++ b/examples/nvector/test_nvector.h @@ -98,6 +98,7 @@ int Test_N_VConstrMask(N_Vector C, N_Vector X, N_Vector M, sunindextype local_length, int myid); int Test_N_VMinQuotient(N_Vector NUM, N_Vector DENOM, sunindextype local_length, int myid); +int Test_N_VRandom(N_Vector X, int myid); /* Fused vector operation tests */ int Test_N_VLinearCombination(N_Vector X, sunindextype local_length, int myid); diff --git a/include/nvector/nvector_kokkos.hpp b/include/nvector/nvector_kokkos.hpp index 782587497a..16087b1d1f 100644 --- a/include/nvector/nvector_kokkos.hpp +++ b/include/nvector/nvector_kokkos.hpp @@ -18,6 +18,7 @@ #define _NVECTOR_KOKKOS_HPP #include +#include #include #include @@ -409,6 +410,16 @@ sunrealtype N_VMinQuotient_Kokkos(N_Vector num, N_Vector denom) return gpu_result; } +template +SUNErrCode N_VRandom_Kokkos(N_Vector x) +{ + auto xvec{GetVec(x)}; + auto xdata{xvec->View()}; + Kokkos::Random_XorShift64_Pool<> random_pool(/*seed=*/12345); + Kokkos::fill_random(xdata, random_pool, SUN_RCONST(0.0), SUN_RCONST(1.0)); + return SUN_SUCCESS; +} + template void N_VProd_Kokkos(N_Vector x, N_Vector y, N_Vector z) { @@ -611,6 +622,7 @@ class Vector : public sundials::impl::BaseNVector, this->object_->ops->nvwl2norm = impl::N_VWL2Norm_Kokkos; this->object_->ops->nvwrmsnorm = impl::N_VWrmsNorm_Kokkos; this->object_->ops->nvwrmsnormmask = impl::N_VWrmsNormMask_Kokkos; + this->object_->ops->nvrandom = impl::N_VRandom_Kokkos; /* local reduction operations */ this->object_->ops->nvconstrmasklocal = impl::N_VConstrMask_Kokkos; diff --git a/include/sundials/sundials_nvector.h b/include/sundials/sundials_nvector.h index 1af6aef88b..e3afd7c1d2 100644 --- a/include/sundials/sundials_nvector.h +++ b/include/sundials/sundials_nvector.h @@ -166,6 +166,9 @@ struct _generic_N_Vector_Ops * OPTIONAL operations with no default implementation. */ + /* Fill the vector with uniformly-distributed random numbers from 0 to 1 */ + SUNErrCode (*nvrandom)(N_Vector); + /* Local reduction kernels (no parallel communication) */ sunrealtype (*nvdotprodlocal)(N_Vector, N_Vector); sunrealtype (*nvmaxnormlocal)(N_Vector); @@ -296,6 +299,8 @@ SUNErrCode N_VLinearCombinationVectorArray(int nvec, int nsum, sunrealtype* c, * OPTIONAL operations with no default implementation. */ +SUNDIALS_EXPORT SUNErrCode N_VRandom(N_Vector x); + /* local reduction kernels (no parallel communication) */ SUNDIALS_EXPORT sunrealtype N_VDotProdLocal(N_Vector x, N_Vector y); SUNDIALS_EXPORT sunrealtype N_VMaxNormLocal(N_Vector x); diff --git a/src/nvector/cuda/VectorKernels.cuh b/src/nvector/cuda/VectorKernels.cuh index adce2a7918..02c2cd6beb 100644 --- a/src/nvector/cuda/VectorKernels.cuh +++ b/src/nvector/cuda/VectorKernels.cuh @@ -291,6 +291,23 @@ __global__ void minQuotientKernel(const T MAX_VAL, const T* num, const T* den, GridReducer{}(minimum, Id, min_quotient, device_count); } +/* + * Fills the vector with random numbers. + * + */ + +template +__global__ void randomKernel(T* X, I n) +{ + GRID_STRIDE_XLOOP(I, i, n) { + // Initialize random state + curandState state; + curand_init(clock64(), i, 0, &state); + // Generate random number between 0 and 1 + X[i] = (sunrealtype) curand_uniform(&state) / (sunrealtype) UINT_MAX; + } +} + } // namespace impl } // namespace cuda } // namespace sundials diff --git a/src/nvector/cuda/nvector_cuda.cu b/src/nvector/cuda/nvector_cuda.cu index 5acd83c038..f9dbb396d8 100644 --- a/src/nvector/cuda/nvector_cuda.cu +++ b/src/nvector/cuda/nvector_cuda.cu @@ -63,6 +63,9 @@ static int FusedBuffer_CopyPtrArray2D(N_Vector v, N_Vector** X, int nvec, static int FusedBuffer_CopyToDevice(N_Vector v); static int FusedBuffer_Free(N_Vector v); +// Random number routine +static SUNErrCode N_VRandom_Cuda(N_Vector X); + // Kernel launch parameters static int GetKernelParameters(N_Vector v, sunbooleantype reduction, size_t& grid, size_t& block, size_t& shMemSize, @@ -167,6 +170,7 @@ N_Vector N_VNewEmpty_Cuda(SUNContext sunctx) v->ops->nvwrmsnorm = N_VWrmsNorm_Cuda; v->ops->nvwl2norm = N_VWL2Norm_Cuda; v->ops->nvcompare = N_VCompare_Cuda; + v->ops->nvrandom = N_VRandom_Cuda; /* fused and vector array operations are disabled (NULL) by default */ @@ -1363,6 +1367,23 @@ sunrealtype N_VMinQuotient_Cuda(N_Vector num, N_Vector denom) return gpu_result; } +SUNErrCode N_VRandom_Cuda(N_Vector X) +{ + size_t grid, block, shMemSize; + cudaStream_t stream; + + if (GetKernelParameters(X, false, grid, block, shMemSize, stream)) + { + SUNDIALS_DEBUG_PRINT( + "ERROR in N_VRandom_Cuda: GetKernelParameters returned nonzero\n"); + } + + randomKernel<<>>(NVEC_CUDA_DDATAp(X), + NVEC_CUDA_CONTENT(X)->length); + PostKernelLaunch(); + return SUN_SUCCESS; +} + /* * ----------------------------------------------------------------- * fused vector operations diff --git a/src/nvector/parallel/nvector_parallel.c b/src/nvector/parallel/nvector_parallel.c index eb278bc21d..818cba8ff8 100644 --- a/src/nvector/parallel/nvector_parallel.c +++ b/src/nvector/parallel/nvector_parallel.c @@ -47,6 +47,7 @@ static void VLin2_Parallel(sunrealtype a, N_Vector x, N_Vector y, N_Vector z); /* z=ax-y */ static void Vaxpy_Parallel(sunrealtype a, N_Vector x, N_Vector y); /* y <- ax+y */ static void VScaleBy_Parallel(sunrealtype a, N_Vector x); /* x <- ax */ +static SUNErrCode N_VRandom_Parallel(N_Vector x); /* Private functions for special cases of vector array operations */ static void VSumVectorArray_Parallel(int nvec, N_Vector* X, N_Vector* Y, @@ -137,6 +138,7 @@ N_Vector N_VNewEmpty_Parallel(MPI_Comm comm, sunindextype local_length, v->ops->nvinvtest = N_VInvTest_Parallel; v->ops->nvconstrmask = N_VConstrMask_Parallel; v->ops->nvminquotient = N_VMinQuotient_Parallel; + v->ops->nvrandom = N_VRandom_Parallel; /* fused and vector array operations are disabled (NULL) by default */ @@ -980,6 +982,19 @@ sunrealtype N_VMinQuotient_Parallel(N_Vector num, N_Vector denom) return (gmin); } +SUNErrCode N_VRandom_Parallel(N_Vector x) +{ + SUNFunctionBegin(x->sunctx); + sunrealtype *xd = NULL; + xd = NV_DATA_P(x); + sranddev(); + for (int i = 0; i < NV_LOCLENGTH_P(x); i++) + { + xd[i] = (sunrealtype)rand() / (sunrealtype)RAND_MAX; + } + return SUN_SUCCESS; +} + /* * ----------------------------------------------------------------- * fused vector operations diff --git a/src/nvector/parhyp/nvector_parhyp.c b/src/nvector/parhyp/nvector_parhyp.c index aee1f08450..867a8bf079 100644 --- a/src/nvector/parhyp/nvector_parhyp.c +++ b/src/nvector/parhyp/nvector_parhyp.c @@ -127,6 +127,7 @@ static void VScaleDiff_ParHyp(sunrealtype c, N_Vector x, N_Vector y, N_Vector z) static void VLin1_ParHyp(sunrealtype a, N_Vector x, N_Vector y, N_Vector z); /* z=ax-y */ static void VLin2_ParHyp(sunrealtype a, N_Vector x, N_Vector y, N_Vector z); +static SUNErrCode N_VRandom_ParHyp(N_Vector x); /* * ----------------------------------------------------------------- @@ -189,6 +190,7 @@ N_Vector N_VNewEmpty_ParHyp(MPI_Comm comm, sunindextype local_length, v->ops->nvinvtest = N_VInvTest_ParHyp; v->ops->nvconstrmask = N_VConstrMask_ParHyp; v->ops->nvminquotient = N_VMinQuotient_ParHyp; + v->ops->nvrandom = N_VRandom_ParHyp; /* fused and vector array operations are disabled (NULL) by default */ @@ -944,6 +946,19 @@ sunrealtype N_VMinQuotient_ParHyp(N_Vector num, N_Vector denom) return (gmin); } +SUNErrCode N_VRandom_ParHyp(N_Vector x) +{ + SUNFunctionBegin(x->sunctx); + sunrealtype *xd = NULL; + xd = NV_DATA_PH(x); + sranddev(); + for (int i = 0; i < NV_LOCLENGTH_PH(x); i++) + { + xd[i] = (sunrealtype)rand() / (sunrealtype)RAND_MAX; + } + return SUN_SUCCESS; +} + /* * ----------------------------------------------------------------- * fused vector operations diff --git a/src/nvector/petsc/nvector_petsc.c b/src/nvector/petsc/nvector_petsc.c index f3accf46bd..bb5bc0acd3 100644 --- a/src/nvector/petsc/nvector_petsc.c +++ b/src/nvector/petsc/nvector_petsc.c @@ -37,6 +37,9 @@ #define BAD_N2 "input global length. \n\n" #define BAD_N BAD_N1 BAD_N2 +/* Private functions */ +static SUNErrCode N_VRandom_Petsc(N_Vector x); + /* * ----------------------------------------------------------------- * Simplifying macros NV_CONTENT_PTC, NV_OWN_DATA_PTC, @@ -167,6 +170,7 @@ N_Vector N_VNewEmpty_Petsc(MPI_Comm comm, sunindextype local_length, v->ops->nvinvtest = N_VInvTest_Petsc; v->ops->nvconstrmask = N_VConstrMask_Petsc; v->ops->nvminquotient = N_VMinQuotient_Petsc; + v->ops->nvrandom = N_VRandom_Petsc; /* fused and vector array operations are disabled (NULL) by default */ @@ -866,6 +870,15 @@ sunrealtype N_VMinQuotient_Petsc(N_Vector num, N_Vector denom) return (gmin); } +SUNErrCode N_VRandom_Petsc(N_Vector x) +{ + SUNFunctionBegin(x->sunctx); + Vec xv = NV_PVEC_PTC(x); + PetscErrorCode ierr = VecSetRandom(xv,NULL); + CHKERRABORT(NV_COMM_PTC(x), ierr); + return SUN_SUCCESS; +} + /* * ----------------------------------------------------------------- * fused vector operations diff --git a/src/nvector/serial/nvector_serial.c b/src/nvector/serial/nvector_serial.c index 255aca3fb6..3832609db9 100644 --- a/src/nvector/serial/nvector_serial.c +++ b/src/nvector/serial/nvector_serial.c @@ -33,6 +33,7 @@ #define ONEPT5 SUN_RCONST(1.5) /* Private functions for special cases of vector operations */ +static SUNErrCode N_VRandom_Serial(N_Vector x); static void VCopy_Serial(N_Vector x, N_Vector z); /* z=x */ static void VSum_Serial(N_Vector x, N_Vector y, N_Vector z); /* z=x+y */ static void VDiff_Serial(N_Vector x, N_Vector y, N_Vector z); /* z=x-y */ @@ -120,6 +121,7 @@ N_Vector N_VNewEmpty_Serial(sunindextype length, SUNContext sunctx) v->ops->nvinvtest = N_VInvTest_Serial; v->ops->nvconstrmask = N_VConstrMask_Serial; v->ops->nvminquotient = N_VMinQuotient_Serial; + v->ops->nvrandom = N_VRandom_Serial; /* fused and vector array operations are disabled (NULL) by default */ @@ -869,6 +871,19 @@ sunrealtype N_VMinQuotient_Serial(N_Vector num, N_Vector denom) return (min); } +SUNErrCode N_VRandom_Serial(N_Vector x) +{ + SUNFunctionBegin(x->sunctx); + sunrealtype *xd = NULL; + xd = NV_DATA_S(x); + sranddev(); + for (int i = 0; i < NV_LENGTH_S(x); i++) + { + xd[i] = (sunrealtype)rand() / (sunrealtype)RAND_MAX; + } + return SUN_SUCCESS; +} + /* * ----------------------------------------------------------------- * fused vector operations diff --git a/src/nvector/trilinos/nvector_trilinos.cpp b/src/nvector/trilinos/nvector_trilinos.cpp index 85381e0850..db27573c78 100644 --- a/src/nvector/trilinos/nvector_trilinos.cpp +++ b/src/nvector/trilinos/nvector_trilinos.cpp @@ -54,6 +54,14 @@ using namespace sundials::trilinos::nvector_tpetra; typedef TpetraVectorInterface::vector_type vector_type; +/* + * ----------------------------------------------------------------- + * static functions accessible only within this file + * ----------------------------------------------------------------- + */ + +static SUNErrCode N_VRandom_Trilinos(N_Vector x); + /* ---------------------------------------------------------------- * Returns vector type ID. Used to identify vector implementation * from abstract N_Vector interface. @@ -107,6 +115,7 @@ N_Vector N_VNewEmpty_Trilinos(SUNContext sunctx) v->ops->nvinvtest = N_VInvTest_Trilinos; v->ops->nvconstrmask = N_VConstrMask_Trilinos; v->ops->nvminquotient = N_VMinQuotient_Trilinos; + v->ops->nvrandom = N_VMinRandom_Trilinos; /* fused and vector array operations are disabled (NULL) by default */ @@ -573,3 +582,13 @@ sunrealtype N_VMinQuotientLocal_Trilinos(N_Vector num, N_Vector denom) return minQuotientLocal(*numv, *denv); } + +/* + * Fill vector with random numbers + */ +SUNErrCode N_VRandom_Trilinos(N_Vector x) +{ + Teuchos::RCP xv = N_VGetVector_Trilinos(x); + xv->randomize(); + return SUN_SUCCESS +} diff --git a/src/sundials/sundials_nvector.c b/src/sundials/sundials_nvector.c index 37a15741d9..16b324d935 100644 --- a/src/sundials/sundials_nvector.c +++ b/src/sundials/sundials_nvector.c @@ -124,6 +124,7 @@ N_Vector N_VNewEmpty(SUNContext sunctx) */ ops->nvgetlocallength = NULL; + ops->nvrandom = NULL; /* local reduction operations (optional) */ ops->nvdotprodlocal = NULL; @@ -247,6 +248,8 @@ SUNErrCode N_VCopyOps(N_Vector w, N_Vector v) * OPTIONAL operations with no default implementation. */ + v->ops->nvrandom = w->ops->nvrandom; + /* local reduction operations */ v->ops->nvdotprodlocal = w->ops->nvdotprodlocal; v->ops->nvmaxnormlocal = w->ops->nvmaxnormlocal; @@ -827,6 +830,23 @@ SUNErrCode N_VLinearCombinationVectorArray(int nvec, int nsum, sunrealtype* c, return (ier); } +/* ------------------------------------------------------------- + * OPTIONAL routine to fill a vector with uniformly-distributed + * random numbers in [0,1] + * -------------------------------------------------------------*/ + +SUNErrCode N_VRandom(N_Vector x) +{ + SUNErrCode ier = SUN_SUCCESS; + SUNDIALS_MARK_FUNCTION_BEGIN(getSUNProfiler(x)); + if (x->ops->nvrandom != NULL) + { + ier = (x->ops->nvrandom(x)); + } + SUNDIALS_MARK_FUNCTION_END(getSUNProfiler(x)); + return (ier); +} + /* ----------------------------------------------------------------- * OPTIONAL local reduction kernels (no parallel communication) * -----------------------------------------------------------------*/ From 7e1ac25427dd78f2db90061ca01370775af736cb Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 21 Apr 2025 21:55:33 -0500 Subject: [PATCH 003/128] Updated N_VRandom in vector implementations --- include/nvector/nvector_kokkos.hpp | 2 +- src/nvector/manyvector/nvector_manyvector.c | 51 +++++++++++++++++++++ src/nvector/openmp/nvector_openmp.c | 21 +++++++++ src/nvector/parallel/nvector_parallel.c | 8 +++- src/nvector/parhyp/nvector_parhyp.c | 6 ++- src/nvector/serial/nvector_serial.c | 4 +- 6 files changed, 87 insertions(+), 5 deletions(-) diff --git a/include/nvector/nvector_kokkos.hpp b/include/nvector/nvector_kokkos.hpp index 635316a351..d2efedef91 100644 --- a/include/nvector/nvector_kokkos.hpp +++ b/include/nvector/nvector_kokkos.hpp @@ -415,7 +415,7 @@ SUNErrCode N_VRandom_Kokkos(N_Vector x) { auto xvec{GetVec(x)}; auto xdata{xvec->View()}; - Kokkos::Random_XorShift64_Pool<> random_pool(/*seed=*/12345); + Kokkos::Random_XorShift64_Pool<> random_pool(); Kokkos::fill_random(xdata, random_pool, SUN_RCONST(0.0), SUN_RCONST(1.0)); return SUN_SUCCESS; } diff --git a/src/nvector/manyvector/nvector_manyvector.c b/src/nvector/manyvector/nvector_manyvector.c index edf415a0d2..77ff397c50 100644 --- a/src/nvector/manyvector/nvector_manyvector.c +++ b/src/nvector/manyvector/nvector_manyvector.c @@ -67,6 +67,7 @@ static N_Vector ManyVectorClone(N_Vector w, sunbooleantype cloneempty); #ifdef MANYVECTOR_BUILD_WITH_MPI static int SubvectorMPIRank(N_Vector w); #endif +static SUNErrCode MVAPPEND(N_VRandom)(N_Vector x); /* ----------------------------------------------------------------- ManyVector API routines @@ -230,6 +231,25 @@ N_Vector N_VMake_MPIManyVector(MPI_Comm comm, sunindextype num_subvectors, } else { content->global_length = local_length; } + /* Only attach N_VRandom if it is supported by all subvectors */ + v->ops->nvrandom = N_VRandom_MPIManyVector; + for (i = 0; i < num_subvectors; i++) + { + if (vec_array[i]->ops->nvrandom == NULL) + { + v->ops->nvrandom = NULL; + break; + } + } + + /* Seed random number generator to ensure reproducibility between runs, + with different streams between MPI ranks */ + if (v->ops->nvrandom) + { + rank = SubvectorMPIRank(vec_array[0]); + srand(rank+1); + } + return (v); } #endif @@ -415,6 +435,23 @@ N_Vector N_VNew_ManyVector(sunindextype num_subvectors, N_Vector* vec_array, } content->global_length = local_length; + /* Only attach N_VRandom if it is supported by all subvectors */ + v->ops->nvrandom = N_VRandom_ManyVector; + for (i = 0; i < num_subvectors; i++) + { + if (vec_array[i]->ops->nvrandom == NULL) + { + v->ops->nvrandom = NULL; + break; + } + } + + /* Seed random number generator to ensure reproducibility between runs */ + if (v->ops->nvrandom) + { + srand(1); + } + return (v); } #endif @@ -1462,6 +1499,20 @@ SUNErrCode N_VDotProdMultiAllReduce_MPIManyVector(int nvec_total, N_Vector x, } #endif + +SUNErrCode MVAPPEND(N_VRandom)(N_Vector x) +{ + SUNFunctionBegin(x->sunctx); + sunindextype i; + SUNErrCode retval; + for (i = 0; i < MANYVECTOR_NUM_SUBVECS(x); i++) + { + SUNCheckCall(N_VRandom(MANYVECTOR_SUBVEC(x, i))); + } + return SUN_SUCCESS; +} + + /* ----------------------------------------------------------------- Fused vector operations ----------------------------------------------------------------- */ diff --git a/src/nvector/openmp/nvector_openmp.c b/src/nvector/openmp/nvector_openmp.c index 8aa5d643b8..97a8c12cdf 100644 --- a/src/nvector/openmp/nvector_openmp.c +++ b/src/nvector/openmp/nvector_openmp.c @@ -39,6 +39,7 @@ #define ONEPT5 SUN_RCONST(1.5) /* Private functions for special cases of vector operations */ +static SUNErrCode N_VRandom_OpenMP(N_Vector x); static void VCopy_OpenMP(N_Vector x, N_Vector z); /* z=x */ static void VSum_OpenMP(N_Vector x, N_Vector y, N_Vector z); /* z=x+y */ static void VDiff_OpenMP(N_Vector x, N_Vector y, N_Vector z); /* z=x-y */ @@ -140,6 +141,7 @@ N_Vector N_VNewEmpty_OpenMP(sunindextype length, int num_threads, v->ops->nvinvtest = N_VInvTest_OpenMP; v->ops->nvconstrmask = N_VConstrMask_OpenMP; v->ops->nvminquotient = N_VMinQuotient_OpenMP; + v->ops->nvrandom = N_VRandom_OpenMP; /* fused and vector array operations are disabled (NULL) by default */ @@ -180,6 +182,9 @@ N_Vector N_VNewEmpty_OpenMP(sunindextype length, int num_threads, content->own_data = SUNFALSE; content->data = NULL; + /* Seed random number generator to ensure reproducibility between runs */ + srand(1); + return (v); } @@ -991,6 +996,22 @@ sunrealtype N_VMinQuotient_OpenMP(N_Vector num, N_Vector denom) return (min); } +/* ---------------------------------------------------------------------------- + * Fills the vector with pseudorandom numbers (this is not threaded) + */ + +SUNErrCode N_VRandom_OpenMP(N_Vector x) +{ + SUNFunctionBegin(x->sunctx); + sunrealtype *xd = NULL; + xd = NV_DATA_OMP(x); + for (int i = 0; i < NV_LENGTH_OMP(x); i++) + { + xd[i] = (sunrealtype)rand() / (sunrealtype)RAND_MAX; + } + return SUN_SUCCESS; +} + /* ---------------------------------------------------------------------------- * Computes weighted square sum of a vector */ diff --git a/src/nvector/parallel/nvector_parallel.c b/src/nvector/parallel/nvector_parallel.c index b1d8f6b7ad..9f61518000 100644 --- a/src/nvector/parallel/nvector_parallel.c +++ b/src/nvector/parallel/nvector_parallel.c @@ -83,6 +83,7 @@ N_Vector N_VNewEmpty_Parallel(MPI_Comm comm, sunindextype local_length, N_Vector v; N_VectorContent_Parallel content; sunindextype n, Nsum; + int myid; SUNAssertNull(local_length >= 0, SUN_ERR_ARG_OUTOFRANGE); SUNAssertNull(global_length >= 0, SUN_ERR_ARG_OUTOFRANGE); @@ -181,6 +182,10 @@ N_Vector N_VNewEmpty_Parallel(MPI_Comm comm, sunindextype local_length, content->own_data = SUNFALSE; content->data = NULL; + /* Seed random number generator with MPI rank ID to ensure distinct streams */ + SUNCheckMPICallNull(MPI_Comm_rank(comm, &myid)); + srand(myid+1); + return (v); } @@ -663,7 +668,7 @@ sunrealtype N_VDotProd_Parallel(N_Vector x, N_Vector y) sunrealtype lsum, gsum; lsum = N_VDotProdLocal_Parallel(x, y); SUNCheckLastErrNoRet(); - SUNCheckMPICallNoRet( + SUNCheckMPICallNoRet( MPI_Allreduce(&lsum, &gsum, 1, MPI_SUNREALTYPE, MPI_SUM, NV_COMM_P(x))); return (gsum); } @@ -977,7 +982,6 @@ SUNErrCode N_VRandom_Parallel(N_Vector x) SUNFunctionBegin(x->sunctx); sunrealtype *xd = NULL; xd = NV_DATA_P(x); - sranddev(); for (int i = 0; i < NV_LOCLENGTH_P(x); i++) { xd[i] = (sunrealtype)rand() / (sunrealtype)RAND_MAX; diff --git a/src/nvector/parhyp/nvector_parhyp.c b/src/nvector/parhyp/nvector_parhyp.c index 5f46dcff03..f6c0079d5a 100644 --- a/src/nvector/parhyp/nvector_parhyp.c +++ b/src/nvector/parhyp/nvector_parhyp.c @@ -153,6 +153,7 @@ N_Vector N_VNewEmpty_ParHyp(MPI_Comm comm, sunindextype local_length, { N_Vector v; N_VectorContent_ParHyp content; + int myid; /* Create an empty vector object */ v = NULL; @@ -233,6 +234,10 @@ N_Vector N_VNewEmpty_ParHyp(MPI_Comm comm, sunindextype local_length, content->own_parvector = SUNFALSE; content->x = NULL; + /* Seed random number generator with MPI rank ID to ensure distinct streams */ + SUNCheckMPICallNull(MPI_Comm_rank(comm, &myid)); + srand(myid+1); + return (v); } @@ -941,7 +946,6 @@ SUNErrCode N_VRandom_ParHyp(N_Vector x) SUNFunctionBegin(x->sunctx); sunrealtype *xd = NULL; xd = NV_DATA_PH(x); - sranddev(); for (int i = 0; i < NV_LOCLENGTH_PH(x); i++) { xd[i] = (sunrealtype)rand() / (sunrealtype)RAND_MAX; diff --git a/src/nvector/serial/nvector_serial.c b/src/nvector/serial/nvector_serial.c index 539c90d7b1..838af2bb67 100644 --- a/src/nvector/serial/nvector_serial.c +++ b/src/nvector/serial/nvector_serial.c @@ -161,6 +161,9 @@ N_Vector N_VNewEmpty_Serial(sunindextype length, SUNContext sunctx) content->own_data = SUNFALSE; content->data = NULL; + /* Seed random number generator to ensure reproducibility between runs */ + srand(1); + return (v); } @@ -866,7 +869,6 @@ SUNErrCode N_VRandom_Serial(N_Vector x) SUNFunctionBegin(x->sunctx); sunrealtype *xd = NULL; xd = NV_DATA_S(x); - sranddev(); for (int i = 0; i < NV_LENGTH_S(x); i++) { xd[i] = (sunrealtype)rand() / (sunrealtype)RAND_MAX; From 458c3fcbeae1476581178d623e3a10d6f8aa457b Mon Sep 17 00:00:00 2001 From: maggul Date: Sat, 17 May 2025 03:37:30 -0500 Subject: [PATCH 004/128] arnoldi_Create_Common --- include/sundials/priv/sundials_arnoldi_impl.h | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 include/sundials/priv/sundials_arnoldi_impl.h diff --git a/include/sundials/priv/sundials_arnoldi_impl.h b/include/sundials/priv/sundials_arnoldi_impl.h new file mode 100644 index 0000000000..97878bd417 --- /dev/null +++ b/include/sundials/priv/sundials_arnoldi_impl.h @@ -0,0 +1,68 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Mustafa Aggul @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2024, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------- + * This is the implementation header file for the eigenvalue + * estimation of the SUNARNOLDI package. + * -----------------------------------------------------------------*/ + +#ifndef _ARNOLDI_IMPL_H +#define _ARNOLDI_IMPL_H + +#include +#include + +#ifdef __cplusplus /* wrapper to enable C++ usage */ +extern "C" { +#endif + +/*=============================================================== + ARNOLDI module private function prototypes + ===============================================================*/ + + sunbooleantype arnoldi_CheckNVector(N_Vector tmpl); + sunrealtype arnoldi_Magnitude(const suncomplextype *c); + int arnoldi_Compare(const void *a, const void *b); + void* arnoldi_Create_Common(void* Adata, N_Vector q, int maxl, SUNContext sunctx); + + /* + * ----------------------------------------------------------------- + * LAPACK function + * ----------------------------------------------------------------- + */ + + extern void dgeev_(char* jobvl, char* jobvr, int* n, sunrealtype* a, int* lda, + sunrealtype* wr, sunrealtype* wi, sunrealtype* vl, int* ldvl, sunrealtype* vr, + int* ldvr, sunrealtype* work, int* lwork, int* info); + +/*=============================================================== + Reusable ARNOLDI Error Messages + ===============================================================*/ + +/* Initialization and I/O error messages */ +#define MSG_ARNOLDI_NULL_q "q is null." +#define MSG_ARNOLDI_BAD_NVECTOR "Bad NVector." +#define MSG_ARNOLDI_NULL_ATIMES "ATimes is null." +#define MSG_ARNOLDI_NULL_SUNRHSFN "SUNRhsFn is null." +#define MSG_ARNOLDI_ATIMES_FAIL_REC "Atimes recoverable failure" +#define MSG_ARNOLDI_ATIMES_FAIL_UNREC "Atimes unrecoverable failure" +#define MSG_ARNOLDI_NOT_ENOUGH_ITER "Number of Krylov subspace is not enough (< 3)" +#define MSG_ARNOLDI_NULL_SUNCTX "sunctx is null." +#define MSG_ARNOLDI_MEM_FAIL "ARNOLDI memory fail." +#define MSG_ARNOLDI_GS_FAIL "ARNOLDI Modified GS fail." +#define MSG_ARNOLDI_LAPACK_FAIL "Error: LAPACK dgeev failed with info = %d\n" + +#ifdef __cplusplus +} +#endif + +#endif From acee18415d98289baf11cf1c2cd4c82f755c26c3 Mon Sep 17 00:00:00 2001 From: maggul Date: Sat, 17 May 2025 03:37:55 -0500 Subject: [PATCH 005/128] arnoldi_Create_Common --- include/sundials/sundials_arnoldi.h | 22 +- src/sundials/sundials_arnoldi.c | 351 +++++++++++++++--------- test/unit_tests/sundials/test_arnoldi.c | 2 +- 3 files changed, 232 insertions(+), 143 deletions(-) diff --git a/include/sundials/sundials_arnoldi.h b/include/sundials/sundials_arnoldi.h index 75e7c64ded..83f0b0c775 100644 --- a/include/sundials/sundials_arnoldi.h +++ b/include/sundials/sundials_arnoldi.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: BSD-3-Clause * SUNDIALS Copyright End * ----------------------------------------------------------------- - * This is the implementation file for the eigenvalue implementation of - * the SUNLINSOL package. + * This is the header file for the eigenvalue estimation of + * the SUNARNOLDI package. * -----------------------------------------------------------------*/ #ifndef _ARNOLDI_H @@ -28,13 +28,11 @@ extern "C" { /* Default ARNOLDI parameters */ #define ARNOLDI_MAXL_DEFAULT 3 -#define MSG_ARK_NULL_ATIMES "ATimes is null." -#define MSG_ARK_NULL_q "q is null." -#define MSG_ARK_NULL_SUNCTX "sunctx is null." -#define MSG_ARK_BAD_NVECTOR "Bad NVector." -#define MSG_ARNOLDI_MEM_FAIL "ARNOLDI memory fail." +#define DEFAULT_POWER_OF_A 0 -#define DEFAULT_POWER_OF_A 0 +/* SUNRhsFn type definition */ +typedef int (*SUNRhsFn)(sunrealtype t, N_Vector y, N_Vector ydot, + void* user_data); /*=============================================================== ARNOLDI module data structure @@ -51,6 +49,7 @@ typedef struct ARNOLDIMemRec { /* ARNOLDI MEMORY specification */ SUNATimesFn ATimes; /* User provided ATimes function */ + SUNRhsFn SUNRhs; /* User provided SUNRhs function */ void* Adata; /* ATimes function data*/ N_Vector *V, q; /* Krylov subspace vectors */ @@ -71,11 +70,12 @@ typedef struct { * Exported Functions for ARNOLDI * ------------------------------------- */ -/* Creation and Reinitialization functions */ +/* Creation and Estimation functions */ -SUNDIALS_EXPORT void* ArnoldiCreate(SUNATimesFn ATimes, void* Adata, +SUNDIALS_EXPORT void* ArnoldiCreateATimes(SUNATimesFn ATimes, void* Adata, + N_Vector q, int maxl, SUNContext sunctx); +SUNDIALS_EXPORT void* ArnoldiCreateSUNRhs(SUNRhsFn SUNRhs, void* Adata, N_Vector q, int maxl, SUNContext sunctx); - SUNDIALS_EXPORT int ArnoldiComputeHess(ARNOLDIMem arnoldi_mem); SUNDIALS_EXPORT int ArnoldiPreProcess(ARNOLDIMem arnoldi_mem); diff --git a/src/sundials/sundials_arnoldi.c b/src/sundials/sundials_arnoldi.c index 60059cc282..6179726b9d 100644 --- a/src/sundials/sundials_arnoldi.c +++ b/src/sundials/sundials_arnoldi.c @@ -11,107 +11,63 @@ * SPDX-License-Identifier: BSD-3-Clause * SUNDIALS Copyright End * ----------------------------------------------------------------- - * This is the implementation file for the eigenvalue implementation of - * the SUNLINSOL package. + * This is the implementation file for the eigenvalue estimation of + * the SUNARNOLDI package. * -----------------------------------------------------------------*/ #include #include #include -#include +#include #define ZERO SUN_RCONST(0.0) -/* - * ----------------------------------------------------------------- - * internal functions - * ----------------------------------------------------------------- - */ - -sunbooleantype arnoldi_CheckNVector(N_Vector tmpl); -double arnoldi_magnitude(const suncomplextype *c); -int arnoldi_compare(const void *a, const void *b); - -/* - * ----------------------------------------------------------------- - * LAPACK function - * ----------------------------------------------------------------- - */ - -extern void dgeev_(char* jobvl, char* jobvr, int* n, double* a, int* lda, - double* wr, double* wi, double* vl, int* ldvl, double* vr, - int* ldvr, double* work, int* lwork, int* info); - /* * ----------------------------------------------------------------- * exported functions * ----------------------------------------------------------------- */ -void* ArnoldiCreate(SUNATimesFn ATimes, void* Adata, +void* ArnoldiCreateATimes(SUNATimesFn ATimes, void* Adata, N_Vector q, int maxl, SUNContext sunctx) { - int retval; ARNOLDIMem arnoldi_mem; - sunbooleantype nvectorOK; - - /* Test if all required vector operations are implemented */ - nvectorOK = arnoldi_CheckNVector(q); - if (!nvectorOK) - { - return NULL; - } /* Test if Atimes is provided */ if (ATimes == NULL) { - return NULL; - } + printf(MSG_ARNOLDI_NULL_ATIMES); - /* Check if maxl > 2 */ - if (maxl < 3) - { return NULL; } - if (sunctx == NULL) - { - return NULL; - } + /* Create shared ARNOLDI memory structure */ + arnoldi_mem = arnoldi_Create_Common(Adata, q, maxl, sunctx); + /* Copy ATimes into ARNOLDI memory */ + arnoldi_mem->ATimes = ATimes; - /* Allocate ARNOLDIMem structure, and initialize to zero */ - arnoldi_mem = (ARNOLDIMem)calloc(1, sizeof(*arnoldi_mem)); + return (void*)arnoldi_mem; +} - arnoldi_mem->ATimes = ATimes; - arnoldi_mem->Adata = Adata; - arnoldi_mem->q = q; - arnoldi_mem->maxl = maxl; - arnoldi_mem->power_of_A = DEFAULT_POWER_OF_A; +void* ArnoldiCreateSUNRhs(SUNRhsFn SUNRhs, void* RhsData, + N_Vector q, int maxl, SUNContext sunctx) +{ + ARNOLDIMem arnoldi_mem; - /* Hessenberg matrix Hes */ - if (arnoldi_mem->Hes == NULL) + /* Test if Atimes is provided */ + if (SUNRhs == NULL) { - arnoldi_mem->Hes = - (sunrealtype**)malloc((maxl + 1) * sizeof(sunrealtype*)); + printf(MSG_ARNOLDI_NULL_SUNRHSFN); - for (int k = 0; k <= maxl; k++) - { - arnoldi_mem->Hes[k] = NULL; - arnoldi_mem->Hes[k] = (sunrealtype*)malloc(maxl * sizeof(sunrealtype)); - } + return NULL; } - /* Krylov subspace vectors */ - if (arnoldi_mem->V == NULL) - { - arnoldi_mem->V = N_VCloneVectorArray(maxl + 1, q); - } + /* Create shared ARNOLDI memory structure */ + arnoldi_mem = arnoldi_Create_Common(RhsData, q, maxl, sunctx); - /* Unitize the initial vector V[0] */ - sunrealtype normq = N_VDotProd(q, q); - normq = SUNRsqrt(normq); - N_VScale(SUN_RCONST(1.0)/normq, arnoldi_mem->q, arnoldi_mem->V[0]); + /* Copy SUNRhs into ARNOLDI memory */ + arnoldi_mem->SUNRhs = SUNRhs; return (void*)arnoldi_mem; } @@ -119,17 +75,21 @@ void* ArnoldiCreate(SUNATimesFn ATimes, void* Adata, /* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ int ArnoldiPreProcess(ARNOLDIMem arnoldi_mem) { + int retval; + /* Check if Arnoldi memory is allocated */ if(arnoldi_mem == NULL) { - printf("Error: Arnoldi memory is not allocated yet!"); + printf(MSG_ARNOLDI_MEM_FAIL); + return -1; } /* Check if ATimes is provided */ if(arnoldi_mem->ATimes == NULL) { - printf("Error: ATimes function is NULL!"); + printf(MSG_ARNOLDI_NULL_ATIMES); + return -1; } @@ -137,16 +97,36 @@ int ArnoldiPreProcess(ARNOLDIMem arnoldi_mem) /* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ for(int i = 0; i < arnoldi_mem->power_of_A; i++) { - arnoldi_mem->ATimes(arnoldi_mem->Adata, arnoldi_mem->V[0], arnoldi_mem->q); + retval = arnoldi_mem->ATimes(arnoldi_mem->Adata, arnoldi_mem->V[0], arnoldi_mem->q); + if (retval != 0) + { + (retval < 0) ? + printf(MSG_ARNOLDI_ATIMES_FAIL_UNREC) : + printf(MSG_ARNOLDI_ATIMES_FAIL_REC); + + return ARK_ILL_INPUT; + } normq = N_VDotProd(arnoldi_mem->q, arnoldi_mem->q); normq = SUNRsqrt(normq); N_VScale(SUN_RCONST(1.0)/normq, arnoldi_mem->q, arnoldi_mem->V[0]); } + + return 0; } /* Compute the Hessenberg matrix Arnoldi_mem->Hes*/ int ArnoldiComputeHess(ARNOLDIMem arnoldi_mem) { + int retval; + + /* Check if Arnoldi memory is allocated */ + if(arnoldi_mem == NULL) + { + printf(MSG_ARNOLDI_MEM_FAIL); + + return -1; + } + /* Initialize the Hessenberg matrix Hes with zeros */ for (int i = 0; i < arnoldi_mem->maxl; i++) { @@ -156,93 +136,202 @@ int ArnoldiComputeHess(ARNOLDIMem arnoldi_mem) for (int i = 0; i < arnoldi_mem->maxl; i++) { /* Compute the next Krylov vector */ - arnoldi_mem->ATimes(arnoldi_mem->Adata, arnoldi_mem->V[i], arnoldi_mem->V[i+1]); - SUNModifiedGS(arnoldi_mem->V, arnoldi_mem->Hes, i + 1, arnoldi_mem->maxl, &(arnoldi_mem->Hes[i + 1][i])); + retval = arnoldi_mem->ATimes(arnoldi_mem->Adata, arnoldi_mem->V[i], arnoldi_mem->V[i+1]); + if (retval != 0) + { + (retval < 0) ? + printf(MSG_ARNOLDI_ATIMES_FAIL_UNREC) : + printf(MSG_ARNOLDI_ATIMES_FAIL_REC); + + return ARK_ILL_INPUT; + } + + if(SUNModifiedGS(arnoldi_mem->V, arnoldi_mem->Hes, i + 1, arnoldi_mem->maxl, &(arnoldi_mem->Hes[i + 1][i])) != SUN_SUCCESS) + { + printf(MSG_ARNOLDI_GS_FAIL); + + return -1; + } /* Unitize the computed orthogonal vector */ N_VScale(SUN_RCONST(1.0)/arnoldi_mem->Hes[i + 1][i], arnoldi_mem->V[i+1], arnoldi_mem->V[i+1]); } + + return 0; } /* Estimate the dominant eigvalues of the Hessenberg matrix */ suncomplextype ArnoldiEstimate(ARNOLDIMem arnoldi_mem) { - suncomplextype dom_eig; - dom_eig.real = ZERO; - dom_eig.imag = ZERO; + suncomplextype dom_eig; + dom_eig.real = ZERO; + dom_eig.imag = ZERO; - int n = arnoldi_mem->maxl; + /* Check if Arnoldi memory is allocated */ + if(arnoldi_mem == NULL) + { + printf(MSG_ARNOLDI_MEM_FAIL); - /* Create the vector A which holds rows of the Hessenberg matrix in the given order */ - sunrealtype* A; - A = (sunrealtype*)malloc((n*n) * sizeof(sunrealtype)); - int k = 0; - for (int i = 0; i < n; i++) { - for (int j = 0; j < n; j++) { - A[k] = arnoldi_mem->Hes[i][j]; - k++; - } - } + return dom_eig; + } + + int n = arnoldi_mem->maxl; + + /* Create the vector A which holds rows of the Hessenberg matrix in the given order */ + sunrealtype* A; + A = (sunrealtype*)malloc((n*n) * sizeof(sunrealtype)); + int k = 0; + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + A[k] = arnoldi_mem->Hes[i][j]; + k++; + } + } + + sunrealtype wr[n], wi[n]; // Real and imaginary parts of eigenvalues + sunrealtype vl[n*n], vr[n*n]; // Left and right eigenvectors (optional, can be NULL) + int lda = n, ldvl = n, ldvr = n; + int info, lwork = 4 * n; + sunrealtype work[4 * n]; // Workspace array - double wr[n], wi[n]; // Real and imaginary parts of eigenvalues - double vl[n*n], vr[n*n]; // Left and right eigenvectors (optional, can be NULL) - int lda = n, ldvl = n, ldvr = n; - int info, lwork = 4 * n; - double work[4 * n]; // Workspace array + char jobvl = 'N'; // Do not compute left eigenvectors + char jobvr = 'N'; // Do not compute right eigenvectors - char jobvl = 'N'; // Do not compute left eigenvectors - char jobvr = 'N'; // Do not compute right eigenvectors + // Call LAPACK's dgeev function + dgeev_(&jobvl, &jobvr, &n, A, &lda, wr, wi, vl, &ldvl, vr, &ldvr, work, &lwork, &info); - // Call LAPACK's dgeev function - dgeev_(&jobvl, &jobvr, &n, A, &lda, wr, wi, vl, &ldvl, vr, &ldvr, work, &lwork, &info); + if (info != 0) { + printf(MSG_ARNOLDI_LAPACK_FAIL, info); + return dom_eig; + } - if (info != 0) { - printf("Error: LAPACK dgeev failed with info = %d\n", info); - return dom_eig; + //Following part will order the eigenvalues by their magnitude + { + // Create an array of suncomplextype structs + suncomplextype *arr = (suncomplextype *)malloc(n * sizeof(suncomplextype)); + for (int i = 0; i < n; i++) { + arr[i].real = wr[i]; + arr[i].imag = wi[i]; } - //Following part will order the eigenvalues by their magnitude - { - // Create an array of suncomplextype structs - suncomplextype *arr = (suncomplextype *)malloc(n * sizeof(suncomplextype)); - for (int i = 0; i < n; i++) { - arr[i].real = wr[i]; - arr[i].imag = wi[i]; - } + // Sort the array using qsort + qsort(arr, n, sizeof(suncomplextype), arnoldi_Compare); + + // Update the original arrays + for (int i = 0; i < n; i++) { + wr[i] = arr[i].real; + wi[i] = arr[i].imag; + } - // Sort the array - qsort(arr, n, sizeof(suncomplextype), arnoldi_compare); + // Cleanup + free(arr); + } - // Update the original arrays - for (int i = 0; i < n; i++) { - wr[i] = arr[i].real; - wi[i] = arr[i].imag; + // Print eigenvalues + printf("\nEigenvalues:\n"); + for (int i = 0; i < n; i++) { + if (wi[i] == 0.0) { + printf("%f\n", wr[i]); // sunrealtype eigenvalue + } else { + printf("%f + %fi\n", wr[i], wi[i]); // suncomplextype eigenvalue } + } - // Cleanup - free(arr); - } + dom_eig.real = wr[0]; + dom_eig.imag = wi[0]; - // Print eigenvalues - printf("\nEigenvalues:\n"); - for (int i = 0; i < n; i++) { - if (wi[i] == 0.0) { - printf("%f\n", wr[i]); // sunrealtype eigenvalue - } else { - printf("%f + %fi\n", wr[i], wi[i]); // suncomplextype eigenvalue - } + return dom_eig; +} + +/*=============================================================== + Internal utility routines + ===============================================================*/ + +/*--------------------------------------------------------------- + arnoldi_Create_Common: + + This routine creates common memory for both ATimes and SUNRhsFn. + ---------------------------------------------------------------*/ + +void* arnoldi_Create_Common(void* Adata, N_Vector q, int maxl, SUNContext sunctx) +{ + ARNOLDIMem arnoldi_mem; + sunbooleantype nvectorOK; + + /* Test if q is provided */ + if (q == NULL) + { + printf(MSG_ARNOLDI_NULL_q); + + return NULL; + } + + /* Test if all required vector operations are implemented */ + nvectorOK = arnoldi_CheckNVector(q); + if (!nvectorOK) + { + printf(MSG_ARNOLDI_BAD_NVECTOR); + + return NULL; + } + + /* Check if maxl > 2 */ + if (maxl < 3) + { + printf(MSG_ARNOLDI_NOT_ENOUGH_ITER); + + return NULL; + } + + if (sunctx == NULL) + { + printf(MSG_ARNOLDI_NULL_SUNCTX); + + return NULL; + } + + /* Allocate ARNOLDIMem structure, and initialize to zero */ + arnoldi_mem = (ARNOLDIMem)calloc(1, sizeof(*arnoldi_mem)); + + /* Copy the inputs into ARNOLDI memory */ + arnoldi_mem->Adata = Adata; + arnoldi_mem->q = q; + arnoldi_mem->maxl = maxl; + + /* Set the default power of A to start with (# of warm-ups) */ + arnoldi_mem->power_of_A = DEFAULT_POWER_OF_A; + + /* Hessenberg matrix Hes */ + if (arnoldi_mem->Hes == NULL) + { + arnoldi_mem->Hes = + (sunrealtype**)malloc((maxl + 1) * sizeof(sunrealtype*)); + + for (int k = 0; k <= maxl; k++) + { + arnoldi_mem->Hes[k] = NULL; + arnoldi_mem->Hes[k] = (sunrealtype*)malloc(maxl * sizeof(sunrealtype)); } + } + + /* Krylov subspace vectors */ + if (arnoldi_mem->V == NULL) + { + arnoldi_mem->V = N_VCloneVectorArray(maxl + 1, q); + } - dom_eig.real = wr[0]; - dom_eig.imag = wi[0]; + /* Unitize the initial vector V[0] */ + sunrealtype normq = N_VDotProd(q, q); + normq = SUNRsqrt(normq); + N_VScale(SUN_RCONST(1.0)/normq, arnoldi_mem->q, arnoldi_mem->V[0]); - return dom_eig; + return (void*)arnoldi_mem; } /*--------------------------------------------------------------- arnoldi_CheckNVector: This routine checks if all required vector operations are - present. If any of them is missing it returns SUNFALSE. + present. If any of them is missing it returns SUNFALSE. ---------------------------------------------------------------*/ sunbooleantype arnoldi_CheckNVector(N_Vector tmpl) { // TO DO: check required vector operations @@ -257,15 +346,15 @@ sunbooleantype arnoldi_CheckNVector(N_Vector tmpl) } // Function to calculate the magnitude of a suncomplextype number -double arnoldi_magnitude(const suncomplextype *c) { +sunrealtype arnoldi_Magnitude(const suncomplextype *c) { return sqrt(c->real * c->real + c->imag * c->imag); } // Comparison function for qsort -int arnoldi_compare(const void *a, const void *b) { +int arnoldi_Compare(const void *a, const void *b) { const suncomplextype *c1 = (const suncomplextype *)a; const suncomplextype *c2 = (const suncomplextype *)b; - double mag1 = arnoldi_magnitude(c1); - double mag2 = arnoldi_magnitude(c2); + sunrealtype mag1 = arnoldi_Magnitude(c1); + sunrealtype mag2 = arnoldi_Magnitude(c2); return (mag2 > mag1) - (mag2 < mag1); // Descending order } \ No newline at end of file diff --git a/test/unit_tests/sundials/test_arnoldi.c b/test/unit_tests/sundials/test_arnoldi.c index 27562c88cb..9bbd8d50ed 100644 --- a/test/unit_tests/sundials/test_arnoldi.c +++ b/test/unit_tests/sundials/test_arnoldi.c @@ -131,7 +131,7 @@ int main(int argc, char* argv[]) /* Create ARNOLDI memory structure */ ARNOLDIMem Arnoldi_mem; - Arnoldi_mem = ArnoldiCreate(ATimes, &ProbData, q, maxl,sunctx); + Arnoldi_mem = ArnoldiCreateATimes(ATimes, &ProbData, q, maxl,sunctx); /* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ ArnoldiPreProcess(Arnoldi_mem); From 2c910d2a0b231d080dd6027663dd26eebf49b7ff Mon Sep 17 00:00:00 2001 From: maggul Date: Tue, 20 May 2025 13:46:25 -0500 Subject: [PATCH 006/128] arnoldi_DQJtimes --- include/sundials/priv/sundials_arnoldi_impl.h | 2 +- include/sundials/sundials_arnoldi.h | 18 ++-- src/sundials/sundials_arnoldi.c | 82 +++++++++++++++---- 3 files changed, 79 insertions(+), 23 deletions(-) diff --git a/include/sundials/priv/sundials_arnoldi_impl.h b/include/sundials/priv/sundials_arnoldi_impl.h index 97878bd417..06bdecd971 100644 --- a/include/sundials/priv/sundials_arnoldi_impl.h +++ b/include/sundials/priv/sundials_arnoldi_impl.h @@ -32,7 +32,7 @@ extern "C" { sunbooleantype arnoldi_CheckNVector(N_Vector tmpl); sunrealtype arnoldi_Magnitude(const suncomplextype *c); int arnoldi_Compare(const void *a, const void *b); - void* arnoldi_Create_Common(void* Adata, N_Vector q, int maxl, SUNContext sunctx); + void* arnoldi_Create_Common(void* Data, N_Vector q, int maxl, SUNContext sunctx); /* * ----------------------------------------------------------------- diff --git a/include/sundials/sundials_arnoldi.h b/include/sundials/sundials_arnoldi.h index 83f0b0c775..4cd470af8e 100644 --- a/include/sundials/sundials_arnoldi.h +++ b/include/sundials/sundials_arnoldi.h @@ -29,6 +29,7 @@ extern "C" { /* Default ARNOLDI parameters */ #define ARNOLDI_MAXL_DEFAULT 3 #define DEFAULT_POWER_OF_A 0 +#define MAX_DQITERS 3 /* max. # of attempts to recover in DQ J*v */ /* SUNRhsFn type definition */ typedef int (*SUNRhsFn)(sunrealtype t, N_Vector y, N_Vector ydot, @@ -50,14 +51,15 @@ typedef struct ARNOLDIMemRec /* ARNOLDI MEMORY specification */ SUNATimesFn ATimes; /* User provided ATimes function */ SUNRhsFn SUNRhs; /* User provided SUNRhs function */ - void* Adata; /* ATimes function data*/ + void* Data; /* ATimes function data*/ - N_Vector *V, q; /* Krylov subspace vectors */ - sunrealtype **Hes; /* Hessenberg matrix Hes */ + N_Vector *V, q, w; /* Krylov subspace vectors */ int maxl; /* Krylov subspace dimension */ int power_of_A; /* Power of A in the preprocessing; initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ + int nfeDQ; /* Number of function evaluations */ + sunrealtype **Hes; /* Hessenberg matrix Hes */ }* ARNOLDIMem; // Struct to hold the real and imaginary parts @@ -72,10 +74,14 @@ typedef struct { /* Creation and Estimation functions */ -SUNDIALS_EXPORT void* ArnoldiCreateATimes(SUNATimesFn ATimes, void* Adata, - N_Vector q, int maxl, SUNContext sunctx); -SUNDIALS_EXPORT void* ArnoldiCreateSUNRhs(SUNRhsFn SUNRhs, void* Adata, +SUNDIALS_EXPORT void* ArnoldiCreateATimes(SUNATimesFn ATimes, void* AData, N_Vector q, int maxl, SUNContext sunctx); + +SUNDIALS_EXPORT void* ArnoldiCreateSUNRhs(SUNRhsFn SUNRhs, void* RhsData, + sunrealtype t, N_Vector y, N_Vector fy, + N_Vector q, N_Vector Jq, + int maxl, SUNContext sunctx); + SUNDIALS_EXPORT int ArnoldiComputeHess(ARNOLDIMem arnoldi_mem); SUNDIALS_EXPORT int ArnoldiPreProcess(ARNOLDIMem arnoldi_mem); diff --git a/src/sundials/sundials_arnoldi.c b/src/sundials/sundials_arnoldi.c index 6179726b9d..293169a7d7 100644 --- a/src/sundials/sundials_arnoldi.c +++ b/src/sundials/sundials_arnoldi.c @@ -17,10 +17,12 @@ #include #include -#include + #include #define ZERO SUN_RCONST(0.0) +#define ONE SUN_RCONST(1.0) +#define PT25 SUN_RCONST(0.25) /* * ----------------------------------------------------------------- @@ -28,7 +30,7 @@ * ----------------------------------------------------------------- */ -void* ArnoldiCreateATimes(SUNATimesFn ATimes, void* Adata, +void* ArnoldiCreateATimes(SUNATimesFn ATimes, void* AData, N_Vector q, int maxl, SUNContext sunctx) { ARNOLDIMem arnoldi_mem; @@ -42,7 +44,7 @@ void* ArnoldiCreateATimes(SUNATimesFn ATimes, void* Adata, } /* Create shared ARNOLDI memory structure */ - arnoldi_mem = arnoldi_Create_Common(Adata, q, maxl, sunctx); + arnoldi_mem = arnoldi_Create_Common(AData, q, maxl, sunctx); /* Copy ATimes into ARNOLDI memory */ arnoldi_mem->ATimes = ATimes; @@ -51,7 +53,9 @@ void* ArnoldiCreateATimes(SUNATimesFn ATimes, void* Adata, } void* ArnoldiCreateSUNRhs(SUNRhsFn SUNRhs, void* RhsData, - N_Vector q, int maxl, SUNContext sunctx) + sunrealtype t, N_Vector y, N_Vector fy, + N_Vector q, N_Vector Jq, + int maxl, SUNContext sunctx) { ARNOLDIMem arnoldi_mem; @@ -97,14 +101,14 @@ int ArnoldiPreProcess(ARNOLDIMem arnoldi_mem) /* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ for(int i = 0; i < arnoldi_mem->power_of_A; i++) { - retval = arnoldi_mem->ATimes(arnoldi_mem->Adata, arnoldi_mem->V[0], arnoldi_mem->q); + retval = arnoldi_mem->ATimes(arnoldi_mem->Data, arnoldi_mem->V[0], arnoldi_mem->q); if (retval != 0) { (retval < 0) ? printf(MSG_ARNOLDI_ATIMES_FAIL_UNREC) : printf(MSG_ARNOLDI_ATIMES_FAIL_REC); - return ARK_ILL_INPUT; + return retval; } normq = N_VDotProd(arnoldi_mem->q, arnoldi_mem->q); normq = SUNRsqrt(normq); @@ -136,14 +140,14 @@ int ArnoldiComputeHess(ARNOLDIMem arnoldi_mem) for (int i = 0; i < arnoldi_mem->maxl; i++) { /* Compute the next Krylov vector */ - retval = arnoldi_mem->ATimes(arnoldi_mem->Adata, arnoldi_mem->V[i], arnoldi_mem->V[i+1]); + retval = arnoldi_mem->ATimes(arnoldi_mem->Data, arnoldi_mem->V[i], arnoldi_mem->V[i+1]); if (retval != 0) { (retval < 0) ? printf(MSG_ARNOLDI_ATIMES_FAIL_UNREC) : printf(MSG_ARNOLDI_ATIMES_FAIL_REC); - return ARK_ILL_INPUT; + return retval; } if(SUNModifiedGS(arnoldi_mem->V, arnoldi_mem->Hes, i + 1, arnoldi_mem->maxl, &(arnoldi_mem->Hes[i + 1][i])) != SUN_SUCCESS) @@ -252,7 +256,7 @@ suncomplextype ArnoldiEstimate(ARNOLDIMem arnoldi_mem) { This routine creates common memory for both ATimes and SUNRhsFn. ---------------------------------------------------------------*/ -void* arnoldi_Create_Common(void* Adata, N_Vector q, int maxl, SUNContext sunctx) +void* arnoldi_Create_Common(void* Data, N_Vector q, int maxl, SUNContext sunctx) { ARNOLDIMem arnoldi_mem; sunbooleantype nvectorOK; @@ -293,13 +297,23 @@ void* arnoldi_Create_Common(void* Adata, N_Vector q, int maxl, SUNContext sunctx arnoldi_mem = (ARNOLDIMem)calloc(1, sizeof(*arnoldi_mem)); /* Copy the inputs into ARNOLDI memory */ - arnoldi_mem->Adata = Adata; + arnoldi_mem->ATimes = NULL; + arnoldi_mem->SUNRhs = NULL; + arnoldi_mem->Data = Data; arnoldi_mem->q = q; + N_VConst(ONE, arnoldi_mem->w); arnoldi_mem->maxl = maxl; + arnoldi_mem->nfeDQ = 0; /* Set the default power of A to start with (# of warm-ups) */ arnoldi_mem->power_of_A = DEFAULT_POWER_OF_A; + /* Krylov subspace vectors */ + if (arnoldi_mem->V == NULL) + { + arnoldi_mem->V = N_VCloneVectorArray(maxl + 1, q); + } + /* Hessenberg matrix Hes */ if (arnoldi_mem->Hes == NULL) { @@ -313,12 +327,6 @@ void* arnoldi_Create_Common(void* Adata, N_Vector q, int maxl, SUNContext sunctx } } - /* Krylov subspace vectors */ - if (arnoldi_mem->V == NULL) - { - arnoldi_mem->V = N_VCloneVectorArray(maxl + 1, q); - } - /* Unitize the initial vector V[0] */ sunrealtype normq = N_VDotProd(q, q); normq = SUNRsqrt(normq); @@ -357,4 +365,46 @@ int arnoldi_Compare(const void *a, const void *b) { sunrealtype mag1 = arnoldi_Magnitude(c1); sunrealtype mag2 = arnoldi_Magnitude(c2); return (mag2 > mag1) - (mag2 < mag1); // Descending order +} + +/*--------------------------------------------------------------- + arnoldi_DQJtimes: + + This routine generates a difference quotient approximation to + the Jacobian-vector product f_y(t,y) * v. The approximation is + Jv = [f(y + v*sig) - f(y)]/sig, where sig = 1 / ||v||_WRMS, + i.e. the WRMS norm of v*sig is 1. + ---------------------------------------------------------------*/ +int arnoldi_DQJtimes(N_Vector v, N_Vector Jv, sunrealtype t, N_Vector y, + N_Vector fy, ARNOLDIMem arnoldi_mem, N_Vector work) +{ + sunrealtype sig, siginv; + int iter, retval; + + /* Initialize perturbation to 1/||v|| */ + sig = ONE / N_VWrmsNorm(v, arnoldi_mem->w); + + for (iter = 0; iter < MAX_DQITERS; iter++) + { + /* Set work = y + sig*v */ + N_VLinearSum(sig, v, ONE, y, work); + + /* Set Jv = f(tn, y+sig*v) */ + retval = arnoldi_mem->SUNRhs(t, work, Jv, arnoldi_mem->Data); + arnoldi_mem->nfeDQ++; + if (retval == 0) { break; } + if (retval < 0) { return (-1); } + + /* If SUNRhs failed recoverably, shrink sig and retry */ + sig *= PT25; + } + + /* If retval still isn't 0, return with a recoverable failure */ + if (retval > 0) { return (+1); } + + /* Replace Jv by (Jv - fy)/sig */ + siginv = ONE / sig; + N_VLinearSum(siginv, Jv, -siginv, fy, Jv); + + return (0); } \ No newline at end of file From 45aba8e92d3606c9e6154943aa15a5b0f220844b Mon Sep 17 00:00:00 2001 From: maggul Date: Sat, 24 May 2025 03:14:56 -0500 Subject: [PATCH 007/128] lsrkStep_DQJtimes --- include/sundials/priv/sundials_arnoldi_impl.h | 1 - include/sundials/sundials_arnoldi.h | 14 +- src/arkode/arkode_impl.h | 2 + src/arkode/arkode_lsrkstep.c | 48 ++++ src/arkode/arkode_lsrkstep_impl.h | 5 + src/sundials/sundials_arnoldi.c | 209 +++++------------- test/unit_tests/sundials/test_arnoldi.c | 2 +- 7 files changed, 118 insertions(+), 163 deletions(-) diff --git a/include/sundials/priv/sundials_arnoldi_impl.h b/include/sundials/priv/sundials_arnoldi_impl.h index 06bdecd971..8668cc6368 100644 --- a/include/sundials/priv/sundials_arnoldi_impl.h +++ b/include/sundials/priv/sundials_arnoldi_impl.h @@ -32,7 +32,6 @@ extern "C" { sunbooleantype arnoldi_CheckNVector(N_Vector tmpl); sunrealtype arnoldi_Magnitude(const suncomplextype *c); int arnoldi_Compare(const void *a, const void *b); - void* arnoldi_Create_Common(void* Data, N_Vector q, int maxl, SUNContext sunctx); /* * ----------------------------------------------------------------- diff --git a/include/sundials/sundials_arnoldi.h b/include/sundials/sundials_arnoldi.h index 4cd470af8e..622fa9c767 100644 --- a/include/sundials/sundials_arnoldi.h +++ b/include/sundials/sundials_arnoldi.h @@ -29,7 +29,6 @@ extern "C" { /* Default ARNOLDI parameters */ #define ARNOLDI_MAXL_DEFAULT 3 #define DEFAULT_POWER_OF_A 0 -#define MAX_DQITERS 3 /* max. # of attempts to recover in DQ J*v */ /* SUNRhsFn type definition */ typedef int (*SUNRhsFn)(sunrealtype t, N_Vector y, N_Vector ydot, @@ -50,14 +49,12 @@ typedef struct ARNOLDIMemRec { /* ARNOLDI MEMORY specification */ SUNATimesFn ATimes; /* User provided ATimes function */ - SUNRhsFn SUNRhs; /* User provided SUNRhs function */ - void* Data; /* ATimes function data*/ + void* Adata; /* ATimes function data*/ - N_Vector *V, q, w; /* Krylov subspace vectors */ + N_Vector *V, q; /* Krylov subspace vectors */ int maxl; /* Krylov subspace dimension */ int power_of_A; /* Power of A in the preprocessing; initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ - int nfeDQ; /* Number of function evaluations */ sunrealtype **Hes; /* Hessenberg matrix Hes */ }* ARNOLDIMem; @@ -74,14 +71,9 @@ typedef struct { /* Creation and Estimation functions */ -SUNDIALS_EXPORT void* ArnoldiCreateATimes(SUNATimesFn ATimes, void* AData, +SUNDIALS_EXPORT void* ArnoldiCreate(SUNATimesFn ATimes, void* AData, N_Vector q, int maxl, SUNContext sunctx); -SUNDIALS_EXPORT void* ArnoldiCreateSUNRhs(SUNRhsFn SUNRhs, void* RhsData, - sunrealtype t, N_Vector y, N_Vector fy, - N_Vector q, N_Vector Jq, - int maxl, SUNContext sunctx); - SUNDIALS_EXPORT int ArnoldiComputeHess(ARNOLDIMem arnoldi_mem); SUNDIALS_EXPORT int ArnoldiPreProcess(ARNOLDIMem arnoldi_mem); diff --git a/src/arkode/arkode_impl.h b/src/arkode/arkode_impl.h index 8f207f80df..b7c1977568 100644 --- a/src/arkode/arkode_impl.h +++ b/src/arkode/arkode_impl.h @@ -78,6 +78,8 @@ extern "C" { #define MAXCONSTRFAILS 10 /* max number of t+h==h warnings */ #define MXHNIL 10 +/* max number of attempts to recover in DQ J*v */ +#define MAX_DQITERS 3 /* Numeric constants */ #define ZERO SUN_RCONST(0.0) diff --git a/src/arkode/arkode_lsrkstep.c b/src/arkode/arkode_lsrkstep.c index d86af26b87..bc3972c0d7 100644 --- a/src/arkode/arkode_lsrkstep.c +++ b/src/arkode/arkode_lsrkstep.c @@ -191,12 +191,14 @@ void* lsrkStep_Create_Commons(ARKRhsFn rhs, sunrealtype t0, N_Vector y0, /* Copy the input parameters into ARKODE state */ step_mem->fe = rhs; + step_mem->arnoldi_rhs = rhs; /* Set NULL for dom_eig_fn */ step_mem->dom_eig_fn = NULL; /* Initialize all the counters */ step_mem->nfe = 0; + step_mem->nfeDQ = 0; step_mem->stage_max = 0; step_mem->dom_eig_num_evals = 0; step_mem->stage_max_limit = STAGE_MAX_LIMIT_DEFAULT; @@ -2244,6 +2246,52 @@ int lsrkStep_ComputeNewDomEig(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem) return retval; } +/*--------------------------------------------------------------- + lsrkStep_DQJtimes: + + This routine generates a difference quotient approximation to + the Jacobian-vector product f_y(t,y) * v. The approximation is + Jv = [f(y + v*sig) - f(y)]/sig, where sig = 1 / ||v||_WRMS, + i.e. the WRMS norm of v*sig is 1. + ---------------------------------------------------------------*/ +int lsrkStep_DQJtimes(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem, N_Vector v, N_Vector Jv) +{ + sunrealtype sig, siginv; + int iter, retval; + + sunrealtype t = ark_mem->tn; + N_Vector y = ark_mem->yn; + N_Vector fy = ark_mem->fn; //make sure it is current! + N_Vector work = ark_mem->tempv3; + + /* Initialize perturbation to 1/||v|| */ + sig = ONE / N_VWrmsNorm(v, ark_mem->ewt); + + for (iter = 0; iter < MAX_DQITERS; iter++) + { + /* Set work = y + sig*v */ + N_VLinearSum(sig, v, ONE, y, work); + + /* Set Jv = f(tn, y+sig*v) */ + retval = step_mem->arnoldi_rhs(t, work, Jv, ark_mem->user_data); + step_mem->nfeDQ++; + if (retval == 0) { break; } + if (retval < 0) { return (-1); } + + /* If f failed recoverably, shrink sig and retry */ + sig *= SUN_RCONST(0.25); + } + + /* If retval still isn't 0, return with a recoverable failure */ + if (retval > 0) { return (+1); } + + /* Replace Jv by (Jv - fy)/sig */ + siginv = ONE / sig; + N_VLinearSum(siginv, Jv, -siginv, fy, Jv); + + return (0); +} + /*=============================================================== EOF ===============================================================*/ diff --git a/src/arkode/arkode_lsrkstep_impl.h b/src/arkode/arkode_lsrkstep_impl.h index 98dba553be..923073a32b 100644 --- a/src/arkode/arkode_lsrkstep_impl.h +++ b/src/arkode/arkode_lsrkstep_impl.h @@ -128,6 +128,7 @@ typedef struct ARKodeLSRKStepMemRec { /* LSRK problem specification */ ARKRhsFn fe; + ARKRhsFn arnoldi_rhs; ARKDomEigFn dom_eig_fn; int q; /* method order */ @@ -139,6 +140,7 @@ typedef struct ARKodeLSRKStepMemRec /* Counters and stats*/ long int nfe; /* num fe calls */ + long int nfeDQ; /* num fe calls for difference quotient approximation */ long int dom_eig_num_evals; /* num of dom_eig computations */ int stage_max; /* num of max stages used */ int stage_max_limit; /* max allowed num of stages */ @@ -204,6 +206,9 @@ void lsrkStep_DomEigUpdateLogic(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem, sunrealtype dsm); int lsrkStep_ComputeNewDomEig(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem); +int lsrkStep_DQJtimes(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem, N_Vector v, + N_Vector Jv); + /*=============================================================== Reusable LSRKStep Error Messages ===============================================================*/ diff --git a/src/sundials/sundials_arnoldi.c b/src/sundials/sundials_arnoldi.c index 293169a7d7..acbbb4ec22 100644 --- a/src/sundials/sundials_arnoldi.c +++ b/src/sundials/sundials_arnoldi.c @@ -22,7 +22,6 @@ #define ZERO SUN_RCONST(0.0) #define ONE SUN_RCONST(1.0) -#define PT25 SUN_RCONST(0.25) /* * ----------------------------------------------------------------- @@ -30,7 +29,7 @@ * ----------------------------------------------------------------- */ -void* ArnoldiCreateATimes(SUNATimesFn ATimes, void* AData, +void* ArnoldiCreate(SUNATimesFn ATimes, void* Adata, N_Vector q, int maxl, SUNContext sunctx) { ARNOLDIMem arnoldi_mem; @@ -43,35 +42,72 @@ void* ArnoldiCreateATimes(SUNATimesFn ATimes, void* AData, return NULL; } - /* Create shared ARNOLDI memory structure */ - arnoldi_mem = arnoldi_Create_Common(AData, q, maxl, sunctx); + /* Test if q is provided */ + if (q == NULL) + { + printf(MSG_ARNOLDI_NULL_q); - /* Copy ATimes into ARNOLDI memory */ - arnoldi_mem->ATimes = ATimes; + return NULL; + } - return (void*)arnoldi_mem; -} + /* Check if maxl > 2 */ + if (maxl < 3) + { + printf(MSG_ARNOLDI_NOT_ENOUGH_ITER); -void* ArnoldiCreateSUNRhs(SUNRhsFn SUNRhs, void* RhsData, - sunrealtype t, N_Vector y, N_Vector fy, - N_Vector q, N_Vector Jq, - int maxl, SUNContext sunctx) -{ - ARNOLDIMem arnoldi_mem; + return NULL; + } - /* Test if Atimes is provided */ - if (SUNRhs == NULL) + if (sunctx == NULL) { - printf(MSG_ARNOLDI_NULL_SUNRHSFN); + printf(MSG_ARNOLDI_NULL_SUNCTX); return NULL; } - /* Create shared ARNOLDI memory structure */ - arnoldi_mem = arnoldi_Create_Common(RhsData, q, maxl, sunctx); + /* Test if all required vector operations are implemented */ + if (!arnoldi_CheckNVector(q)) + { + printf(MSG_ARNOLDI_BAD_NVECTOR); + + return NULL; + } - /* Copy SUNRhs into ARNOLDI memory */ - arnoldi_mem->SUNRhs = SUNRhs; + /* Allocate ARNOLDIMem structure, and initialize to zero */ + arnoldi_mem = (ARNOLDIMem)calloc(1, sizeof(*arnoldi_mem)); + + /* Copy the inputs into ARNOLDI memory */ + arnoldi_mem->ATimes = ATimes; + arnoldi_mem->Adata = Adata; + arnoldi_mem->q = q; + arnoldi_mem->maxl = maxl; + + /* Set the default power of A to start with (# of warm-ups) */ + arnoldi_mem->power_of_A = DEFAULT_POWER_OF_A; + + /* Hessenberg matrix Hes */ + if (arnoldi_mem->Hes == NULL) + { + arnoldi_mem->Hes = + (sunrealtype**)malloc((maxl + 1) * sizeof(sunrealtype*)); + + for (int k = 0; k <= maxl; k++) + { + arnoldi_mem->Hes[k] = NULL; + arnoldi_mem->Hes[k] = (sunrealtype*)malloc(maxl * sizeof(sunrealtype)); + } + } + + /* Krylov subspace vectors */ + if (arnoldi_mem->V == NULL) + { + arnoldi_mem->V = N_VCloneVectorArray(maxl + 1, q); + } + + /* Unitize the initial vector V[0] */ + sunrealtype normq = N_VDotProd(q, q); + normq = SUNRsqrt(normq); + N_VScale(SUN_RCONST(1.0)/normq, arnoldi_mem->q, arnoldi_mem->V[0]); return (void*)arnoldi_mem; } @@ -101,7 +137,7 @@ int ArnoldiPreProcess(ARNOLDIMem arnoldi_mem) /* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ for(int i = 0; i < arnoldi_mem->power_of_A; i++) { - retval = arnoldi_mem->ATimes(arnoldi_mem->Data, arnoldi_mem->V[0], arnoldi_mem->q); + retval = arnoldi_mem->ATimes(arnoldi_mem->Adata, arnoldi_mem->V[0], arnoldi_mem->q); if (retval != 0) { (retval < 0) ? @@ -140,7 +176,7 @@ int ArnoldiComputeHess(ARNOLDIMem arnoldi_mem) for (int i = 0; i < arnoldi_mem->maxl; i++) { /* Compute the next Krylov vector */ - retval = arnoldi_mem->ATimes(arnoldi_mem->Data, arnoldi_mem->V[i], arnoldi_mem->V[i+1]); + retval = arnoldi_mem->ATimes(arnoldi_mem->Adata, arnoldi_mem->V[i], arnoldi_mem->V[i+1]); if (retval != 0) { (retval < 0) ? @@ -250,91 +286,6 @@ suncomplextype ArnoldiEstimate(ARNOLDIMem arnoldi_mem) { Internal utility routines ===============================================================*/ -/*--------------------------------------------------------------- - arnoldi_Create_Common: - - This routine creates common memory for both ATimes and SUNRhsFn. - ---------------------------------------------------------------*/ - -void* arnoldi_Create_Common(void* Data, N_Vector q, int maxl, SUNContext sunctx) -{ - ARNOLDIMem arnoldi_mem; - sunbooleantype nvectorOK; - - /* Test if q is provided */ - if (q == NULL) - { - printf(MSG_ARNOLDI_NULL_q); - - return NULL; - } - - /* Test if all required vector operations are implemented */ - nvectorOK = arnoldi_CheckNVector(q); - if (!nvectorOK) - { - printf(MSG_ARNOLDI_BAD_NVECTOR); - - return NULL; - } - - /* Check if maxl > 2 */ - if (maxl < 3) - { - printf(MSG_ARNOLDI_NOT_ENOUGH_ITER); - - return NULL; - } - - if (sunctx == NULL) - { - printf(MSG_ARNOLDI_NULL_SUNCTX); - - return NULL; - } - - /* Allocate ARNOLDIMem structure, and initialize to zero */ - arnoldi_mem = (ARNOLDIMem)calloc(1, sizeof(*arnoldi_mem)); - - /* Copy the inputs into ARNOLDI memory */ - arnoldi_mem->ATimes = NULL; - arnoldi_mem->SUNRhs = NULL; - arnoldi_mem->Data = Data; - arnoldi_mem->q = q; - N_VConst(ONE, arnoldi_mem->w); - arnoldi_mem->maxl = maxl; - arnoldi_mem->nfeDQ = 0; - - /* Set the default power of A to start with (# of warm-ups) */ - arnoldi_mem->power_of_A = DEFAULT_POWER_OF_A; - - /* Krylov subspace vectors */ - if (arnoldi_mem->V == NULL) - { - arnoldi_mem->V = N_VCloneVectorArray(maxl + 1, q); - } - - /* Hessenberg matrix Hes */ - if (arnoldi_mem->Hes == NULL) - { - arnoldi_mem->Hes = - (sunrealtype**)malloc((maxl + 1) * sizeof(sunrealtype*)); - - for (int k = 0; k <= maxl; k++) - { - arnoldi_mem->Hes[k] = NULL; - arnoldi_mem->Hes[k] = (sunrealtype*)malloc(maxl * sizeof(sunrealtype)); - } - } - - /* Unitize the initial vector V[0] */ - sunrealtype normq = N_VDotProd(q, q); - normq = SUNRsqrt(normq); - N_VScale(SUN_RCONST(1.0)/normq, arnoldi_mem->q, arnoldi_mem->V[0]); - - return (void*)arnoldi_mem; -} - /*--------------------------------------------------------------- arnoldi_CheckNVector: @@ -365,46 +316,4 @@ int arnoldi_Compare(const void *a, const void *b) { sunrealtype mag1 = arnoldi_Magnitude(c1); sunrealtype mag2 = arnoldi_Magnitude(c2); return (mag2 > mag1) - (mag2 < mag1); // Descending order -} - -/*--------------------------------------------------------------- - arnoldi_DQJtimes: - - This routine generates a difference quotient approximation to - the Jacobian-vector product f_y(t,y) * v. The approximation is - Jv = [f(y + v*sig) - f(y)]/sig, where sig = 1 / ||v||_WRMS, - i.e. the WRMS norm of v*sig is 1. - ---------------------------------------------------------------*/ -int arnoldi_DQJtimes(N_Vector v, N_Vector Jv, sunrealtype t, N_Vector y, - N_Vector fy, ARNOLDIMem arnoldi_mem, N_Vector work) -{ - sunrealtype sig, siginv; - int iter, retval; - - /* Initialize perturbation to 1/||v|| */ - sig = ONE / N_VWrmsNorm(v, arnoldi_mem->w); - - for (iter = 0; iter < MAX_DQITERS; iter++) - { - /* Set work = y + sig*v */ - N_VLinearSum(sig, v, ONE, y, work); - - /* Set Jv = f(tn, y+sig*v) */ - retval = arnoldi_mem->SUNRhs(t, work, Jv, arnoldi_mem->Data); - arnoldi_mem->nfeDQ++; - if (retval == 0) { break; } - if (retval < 0) { return (-1); } - - /* If SUNRhs failed recoverably, shrink sig and retry */ - sig *= PT25; - } - - /* If retval still isn't 0, return with a recoverable failure */ - if (retval > 0) { return (+1); } - - /* Replace Jv by (Jv - fy)/sig */ - siginv = ONE / sig; - N_VLinearSum(siginv, Jv, -siginv, fy, Jv); - - return (0); } \ No newline at end of file diff --git a/test/unit_tests/sundials/test_arnoldi.c b/test/unit_tests/sundials/test_arnoldi.c index 9bbd8d50ed..27562c88cb 100644 --- a/test/unit_tests/sundials/test_arnoldi.c +++ b/test/unit_tests/sundials/test_arnoldi.c @@ -131,7 +131,7 @@ int main(int argc, char* argv[]) /* Create ARNOLDI memory structure */ ARNOLDIMem Arnoldi_mem; - Arnoldi_mem = ArnoldiCreateATimes(ATimes, &ProbData, q, maxl,sunctx); + Arnoldi_mem = ArnoldiCreate(ATimes, &ProbData, q, maxl,sunctx); /* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ ArnoldiPreProcess(Arnoldi_mem); From 6b6a57e11e069c9ed2a9975a0c9c218d53679541 Mon Sep 17 00:00:00 2001 From: maggul Date: Sat, 24 May 2025 14:24:41 -0500 Subject: [PATCH 008/128] LSRKStepArnoldi --- include/arkode/arkode.h | 2 + include/arkode/arkode_lsrkstep.h | 6 ++ include/sundials/sundials_arnoldi.h | 3 +- src/arkode/arkode_impl.h | 3 + src/arkode/arkode_lsrkstep.c | 107 +++++++++++++++++++++++- src/arkode/arkode_lsrkstep_impl.h | 6 +- src/arkode/arkode_lsrkstep_io.c | 13 +-- src/sundials/sundials_arnoldi.c | 57 +++++++++++-- test/unit_tests/sundials/test_arnoldi.c | 1 + 9 files changed, 178 insertions(+), 20 deletions(-) diff --git a/include/arkode/arkode.h b/include/arkode/arkode.h index a1ea72396a..0a4c96daee 100644 --- a/include/arkode/arkode.h +++ b/include/arkode/arkode.h @@ -152,6 +152,8 @@ extern "C" { #define ARK_ADJ_RECOMPUTE_FAIL -54 #define ARK_SUNADJSTEPPER_ERR -55 +#define ARK_ARNOLDI_FAIL -56 + #define ARK_UNRECOGNIZED_ERROR -99 /* ------------------------------ diff --git a/include/arkode/arkode_lsrkstep.h b/include/arkode/arkode_lsrkstep.h index dd9f19a183..3e6afdfe0a 100644 --- a/include/arkode/arkode_lsrkstep.h +++ b/include/arkode/arkode_lsrkstep.h @@ -18,6 +18,7 @@ #define _LSRKSTEP_H #include +#include #ifdef __cplusplus /* wrapper to enable C++ usage */ extern "C" { @@ -59,6 +60,11 @@ SUNDIALS_EXPORT int LSRKStepReInitSTS(void* arkode_mem, ARKRhsFn rhs, SUNDIALS_EXPORT int LSRKStepReInitSSP(void* arkode_mem, ARKRhsFn rhs, sunrealtype t0, N_Vector y0); +SUNDIALS_EXPORT void* LSRKStepArnoldiCreate(void* arkode_mem); + +SUNDIALS_EXPORT suncomplextype LSRKStepArnoldiEstimate(void* arkode_mem, + ARNOLDIMem Arnoldi_mem); + /* Optional input functions -- must be called AFTER a creation routine above */ SUNDIALS_EXPORT int LSRKStepSetSTSMethod(void* arkode_mem, diff --git a/include/sundials/sundials_arnoldi.h b/include/sundials/sundials_arnoldi.h index 622fa9c767..9c3c05bc49 100644 --- a/include/sundials/sundials_arnoldi.h +++ b/include/sundials/sundials_arnoldi.h @@ -27,7 +27,6 @@ extern "C" { #endif /* Default ARNOLDI parameters */ -#define ARNOLDI_MAXL_DEFAULT 3 #define DEFAULT_POWER_OF_A 0 /* SUNRhsFn type definition */ @@ -80,6 +79,8 @@ SUNDIALS_EXPORT int ArnoldiPreProcess(ARNOLDIMem arnoldi_mem); SUNDIALS_EXPORT suncomplextype ArnoldiEstimate(ARNOLDIMem arnoldi_mem); +SUNDIALS_EXPORT void ArnoldiFree(ARNOLDIMem* arnoldi_mem); + #ifdef __cplusplus } #endif diff --git a/src/arkode/arkode_impl.h b/src/arkode/arkode_impl.h index b7c1977568..36f1805bbf 100644 --- a/src/arkode/arkode_impl.h +++ b/src/arkode/arkode_impl.h @@ -821,6 +821,9 @@ int arkGetLastKFlag(void* arkode_mem, int* last_kflag); "2. To perform ASA w.r.t. parameters, one subvector should be the state " \ "vector, and the other should be the parameter vector." +#define MSG_ARK_ARNOLDI_FAIL \ + "Arnoldi iteration for the dominant eigenvalue estimation failed. " + /*=============================================================== Documentation for internal ARKODE interfaces diff --git a/src/arkode/arkode_lsrkstep.c b/src/arkode/arkode_lsrkstep.c index bc3972c0d7..90084165d9 100644 --- a/src/arkode/arkode_lsrkstep.c +++ b/src/arkode/arkode_lsrkstep.c @@ -105,6 +105,90 @@ int LSRKStepReInitSSP(void* arkode_mem, ARKRhsFn rhs, sunrealtype t0, N_Vector y return retval; } +/*--------------------------------------------------------------- + LSRKStepArnoldiCreate: + + This routine creates the Arnoldi memory and attaches all the relevent + function pointers from arkode_mem. + ---------------------------------------------------------------*/ + +void* LSRKStepArnoldiCreate(void* arkode_mem) +{ + ARNOLDIMem Arnoldi_mem; + ARKodeMem ark_mem; + ARKodeLSRKStepMem step_mem; + int retval; + + /* access ARKodeLSRKStepMem structure */ + retval = lsrkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, + &step_mem); + if (retval != ARK_SUCCESS) { return NULL; } + + /* Check if ark_mem was allocated */ + if (ark_mem->MallocDone == SUNFALSE) + { + arkProcessError(ark_mem, ARK_NO_MALLOC, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MALLOC); + return NULL; + } + + step_mem->arnoldi_rhs = step_mem->fe; + + /* Allocate and fill Arnoldi_q vector TODO: use random vector instead */ + step_mem->Arnoldi_q = N_VClone(ark_mem->yn); + N_VConst(SUN_RCONST(1.0), step_mem->Arnoldi_q); + + Arnoldi_mem = ArnoldiCreate(lsrkStep_DQJtimes, arkode_mem, step_mem->Arnoldi_q, step_mem->Arnoldi_maxl, ark_mem->sunctx); + +} + +/*--------------------------------------------------------------- + LSRKStepArnoldiEstimate: + + This routine estimates the dominant eigenvalue. + ---------------------------------------------------------------*/ +suncomplextype LSRKStepArnoldiEstimate(void* arkode_mem, ARNOLDIMem Arnoldi_mem) +{ + ARKodeMem ark_mem; + + suncomplextype dom_eig; + dom_eig.real = ZERO; + dom_eig.imag = ZERO; + + int retval; + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return dom_eig; + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ + retval = ArnoldiPreProcess(Arnoldi_mem); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_ARNOLDI_FAIL, __LINE__, __func__, __FILE__, + MSG_ARK_ARNOLDI_FAIL); + + return dom_eig; + } + + /* Compute the Hessenberg matrix Hes*/ + retval = ArnoldiComputeHess(Arnoldi_mem); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_ARNOLDI_FAIL, __LINE__, __func__, __FILE__, + MSG_ARK_ARNOLDI_FAIL); + + return dom_eig; + } + + dom_eig = ArnoldiEstimate(Arnoldi_mem); + + return dom_eig; +} + /*=============================================================== Interface routines supplied to ARKODE ===============================================================*/ @@ -191,11 +275,14 @@ void* lsrkStep_Create_Commons(ARKRhsFn rhs, sunrealtype t0, N_Vector y0, /* Copy the input parameters into ARKODE state */ step_mem->fe = rhs; - step_mem->arnoldi_rhs = rhs; + step_mem->arnoldi_rhs = NULL; /* Set NULL for dom_eig_fn */ step_mem->dom_eig_fn = NULL; + /* Set NULL for Arnoldi_q */ + step_mem->Arnoldi_q = NULL; + /* Initialize all the counters */ step_mem->nfe = 0; step_mem->nfeDQ = 0; @@ -2254,11 +2341,27 @@ int lsrkStep_ComputeNewDomEig(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem) Jv = [f(y + v*sig) - f(y)]/sig, where sig = 1 / ||v||_WRMS, i.e. the WRMS norm of v*sig is 1. ---------------------------------------------------------------*/ -int lsrkStep_DQJtimes(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem, N_Vector v, N_Vector Jv) +int lsrkStep_DQJtimes(void* arkode_mem, N_Vector v, N_Vector Jv) { + ARKodeMem ark_mem; + ARKodeLSRKStepMem step_mem; + sunrealtype sig, siginv; int iter, retval; + /* access ARKodeLSRKStepMem structure */ + retval = lsrkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, + &step_mem); + if (retval != ARK_SUCCESS) { return retval; } + + /* Check if ark_mem was allocated */ + if (ark_mem->MallocDone == SUNFALSE) + { + arkProcessError(ark_mem, ARK_NO_MALLOC, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MALLOC); + return ARK_NO_MALLOC; + } + sunrealtype t = ark_mem->tn; N_Vector y = ark_mem->yn; N_Vector fy = ark_mem->fn; //make sure it is current! diff --git a/src/arkode/arkode_lsrkstep_impl.h b/src/arkode/arkode_lsrkstep_impl.h index 923073a32b..c6f0ac8aba 100644 --- a/src/arkode/arkode_lsrkstep_impl.h +++ b/src/arkode/arkode_lsrkstep_impl.h @@ -29,6 +29,7 @@ extern "C" { #define STAGE_MAX_LIMIT_DEFAULT 200 #define DOM_EIG_SAFETY_DEFAULT SUN_RCONST(1.01) #define DOM_EIG_FREQ_DEFAULT 25 +#define ARNOLDI_MAXL_DEFAULT 3 /*=============================================================== LSRK time step module private math function macros @@ -155,6 +156,8 @@ typedef struct ARKodeLSRKStepMemRec sunrealtype spectral_radius_min; /* min spectral radius*/ sunrealtype dom_eig_safety; /* some safety factor for the user provided dom_eig*/ long int dom_eig_freq; /* indicates dom_eig update after dom_eig_freq successful steps*/ + N_Vector Arnoldi_q; /* Arnoldi initial q vector*/ + int Arnoldi_maxl; /* Krylov subspace dimension */ /* Flags */ sunbooleantype dom_eig_update; /* flag indicating new dom_eig is needed */ @@ -206,8 +209,7 @@ void lsrkStep_DomEigUpdateLogic(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem, sunrealtype dsm); int lsrkStep_ComputeNewDomEig(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem); -int lsrkStep_DQJtimes(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem, N_Vector v, - N_Vector Jv); +int lsrkStep_DQJtimes(void* arkode_mem, N_Vector v, N_Vector Jv); /*=============================================================== Reusable LSRKStep Error Messages diff --git a/src/arkode/arkode_lsrkstep_io.c b/src/arkode/arkode_lsrkstep_io.c index 380a26e4d0..2feb7a896e 100644 --- a/src/arkode/arkode_lsrkstep_io.c +++ b/src/arkode/arkode_lsrkstep_io.c @@ -264,10 +264,10 @@ int LSRKStepSetDomEigFrequency(void* arkode_mem, long int nsteps) /*--------------------------------------------------------------- LSRKStepSetMaxNumStages sets the maximum number of stages allowed. - If the combination of the maximum number of stages and the current - time step size in the LSRKStep module does not allow for a stable - step, the step routine returns to ARKODE for an updated (refined) - step size. The number of such returns is tracked in a counter, + If the combination of the maximum number of stages and the current + time step size in the LSRKStep module does not allow for a stable + step, the step routine returns to ARKODE for an updated (refined) + step size. The number of such returns is tracked in a counter, which can be accessed using ARKodeGetNumExpSteps. ---------------------------------------------------------------*/ int LSRKStepSetMaxNumStages(void* arkode_mem, int stage_max_limit) @@ -385,8 +385,8 @@ int LSRKStepSetNumSSPStages(void* arkode_mem, int num_of_stages) break; case ARKODE_LSRK_SSP_S_3: - /* The SSP3 method differs significantly when s = 4. Therefore, the case - where num_of_stages = 4 is considered separately to avoid unnecessary + /* The SSP3 method differs significantly when s = 4. Therefore, the case + where num_of_stages = 4 is considered separately to avoid unnecessary boolean checks and improve computational efficiency. */ /* We check that num_of_stages is a perfect square. Note the call to sqrt @@ -519,6 +519,7 @@ int lsrkStep_SetDefaults(ARKodeMem ark_mem) step_mem->spectral_radius_min = ZERO; step_mem->dom_eig_safety = DOM_EIG_SAFETY_DEFAULT; step_mem->dom_eig_freq = DOM_EIG_FREQ_DEFAULT; + step_mem->Arnoldi_maxl = ARNOLDI_MAXL_DEFAULT; /* Flags */ step_mem->dom_eig_update = SUNTRUE; diff --git a/src/sundials/sundials_arnoldi.c b/src/sundials/sundials_arnoldi.c index acbbb4ec22..33486c980c 100644 --- a/src/sundials/sundials_arnoldi.c +++ b/src/sundials/sundials_arnoldi.c @@ -129,6 +129,7 @@ int ArnoldiPreProcess(ARNOLDIMem arnoldi_mem) if(arnoldi_mem->ATimes == NULL) { printf(MSG_ARNOLDI_NULL_ATIMES); + ArnoldiFree(&arnoldi_mem); return -1; } @@ -143,6 +144,7 @@ int ArnoldiPreProcess(ARNOLDIMem arnoldi_mem) (retval < 0) ? printf(MSG_ARNOLDI_ATIMES_FAIL_UNREC) : printf(MSG_ARNOLDI_ATIMES_FAIL_REC); + ArnoldiFree(&arnoldi_mem); return retval; } @@ -182,6 +184,7 @@ int ArnoldiComputeHess(ARNOLDIMem arnoldi_mem) (retval < 0) ? printf(MSG_ARNOLDI_ATIMES_FAIL_UNREC) : printf(MSG_ARNOLDI_ATIMES_FAIL_REC); + ArnoldiFree(&arnoldi_mem); return retval; } @@ -189,6 +192,7 @@ int ArnoldiComputeHess(ARNOLDIMem arnoldi_mem) if(SUNModifiedGS(arnoldi_mem->V, arnoldi_mem->Hes, i + 1, arnoldi_mem->maxl, &(arnoldi_mem->Hes[i + 1][i])) != SUN_SUCCESS) { printf(MSG_ARNOLDI_GS_FAIL); + ArnoldiFree(&arnoldi_mem); return -1; } @@ -241,6 +245,8 @@ suncomplextype ArnoldiEstimate(ARNOLDIMem arnoldi_mem) { if (info != 0) { printf(MSG_ARNOLDI_LAPACK_FAIL, info); + ArnoldiFree(&arnoldi_mem); + return dom_eig; } @@ -266,15 +272,15 @@ suncomplextype ArnoldiEstimate(ARNOLDIMem arnoldi_mem) { free(arr); } - // Print eigenvalues - printf("\nEigenvalues:\n"); - for (int i = 0; i < n; i++) { - if (wi[i] == 0.0) { - printf("%f\n", wr[i]); // sunrealtype eigenvalue - } else { - printf("%f + %fi\n", wr[i], wi[i]); // suncomplextype eigenvalue - } - } + // // Print eigenvalues + // printf("\nEigenvalues:\n"); + // for (int i = 0; i < n; i++) { + // if (wi[i] == 0.0) { + // printf("%f\n", wr[i]); // sunrealtype eigenvalue + // } else { + // printf("%f + %fi\n", wr[i], wi[i]); // suncomplextype eigenvalue + // } + // } dom_eig.real = wr[0]; dom_eig.imag = wi[0]; @@ -316,4 +322,37 @@ int arnoldi_Compare(const void *a, const void *b) { sunrealtype mag1 = arnoldi_Magnitude(c1); sunrealtype mag2 = arnoldi_Magnitude(c2); return (mag2 > mag1) - (mag2 < mag1); // Descending order +} + +/*--------------------------------------------------------------- + ArnoldiFree frees all Arnoldi memory. + ---------------------------------------------------------------*/ +void ArnoldiFree(ARNOLDIMem* arnoldi_mem) +{ + ARNOLDIMem arn_mem; + + /* nothing to do if arnoldi_mem is already NULL */ + if (arnoldi_mem == NULL) { return; } + + arn_mem = (ARNOLDIMem)(*arnoldi_mem); + + if (arn_mem->q != NULL) + { + N_VDestroy(arn_mem->q); + arn_mem->q = NULL; + } + if (arn_mem->V != NULL) + { + N_VDestroyVectorArray(arn_mem->V, arn_mem->maxl + 1); + arn_mem->V = NULL; + } + + if (arn_mem->Hes != NULL) + { + free(arn_mem->Hes); + arn_mem->Hes = NULL; + } + + free(*arnoldi_mem); + *arnoldi_mem = NULL; } \ No newline at end of file diff --git a/test/unit_tests/sundials/test_arnoldi.c b/test/unit_tests/sundials/test_arnoldi.c index 27562c88cb..8304d03778 100644 --- a/test/unit_tests/sundials/test_arnoldi.c +++ b/test/unit_tests/sundials/test_arnoldi.c @@ -193,6 +193,7 @@ int main(int argc, char* argv[]) N_VDestroy(q); N_VDestroy(ProbData.d); SUNContext_Free(&sunctx); + ArnoldiFree(&Arnoldi_mem); return (passfail); } From fa30f2e59169b31c4ec1baf25b0c25e63fa5f3b6 Mon Sep 17 00:00:00 2001 From: maggul Date: Sat, 24 May 2025 17:05:20 -0500 Subject: [PATCH 009/128] lsrkStep_ComputeNewDomEig --- src/arkode/arkode_lsrkstep.c | 45 +++++++++++++++++++++++-------- src/arkode/arkode_lsrkstep_impl.h | 1 + src/arkode/arkode_lsrkstep_io.c | 10 +++---- 3 files changed, 40 insertions(+), 16 deletions(-) diff --git a/src/arkode/arkode_lsrkstep.c b/src/arkode/arkode_lsrkstep.c index 90084165d9..389ab1d880 100644 --- a/src/arkode/arkode_lsrkstep.c +++ b/src/arkode/arkode_lsrkstep.c @@ -137,6 +137,7 @@ void* LSRKStepArnoldiCreate(void* arkode_mem) /* Allocate and fill Arnoldi_q vector TODO: use random vector instead */ step_mem->Arnoldi_q = N_VClone(ark_mem->yn); N_VConst(SUN_RCONST(1.0), step_mem->Arnoldi_q); + step_mem->Arnoldi_maxl = ARNOLDI_MAXL_DEFAULT; Arnoldi_mem = ArnoldiCreate(lsrkStep_DQJtimes, arkode_mem, step_mem->Arnoldi_q, step_mem->Arnoldi_maxl, ark_mem->sunctx); @@ -280,6 +281,9 @@ void* lsrkStep_Create_Commons(ARKRhsFn rhs, sunrealtype t0, N_Vector y0, /* Set NULL for dom_eig_fn */ step_mem->dom_eig_fn = NULL; + /* Set NULL for arnoldi_mem */ + step_mem->arnoldi_mem = NULL; + /* Set NULL for Arnoldi_q */ step_mem->Arnoldi_q = NULL; @@ -413,10 +417,10 @@ int lsrkStep_Init(ARKodeMem ark_mem, SUNDIALS_MAYBE_UNUSED sunrealtype tout, } /* Check if user has provided dom_eig_fn */ - if (!step_mem->is_SSP && step_mem->dom_eig_fn == NULL) + if (!step_mem->is_SSP && step_mem->dom_eig_fn == NULL && step_mem->arnoldi_mem == NULL) { arkProcessError(ark_mem, ARK_DOMEIG_FAIL, __LINE__, __func__, - __FILE__, "STS methods require a user provided dominant eigenvalue function"); + __FILE__, "STS methods require either a user provided or an internal dominant eigenvalue estimation"); return ARK_DOMEIG_FAIL; } @@ -2283,16 +2287,35 @@ int lsrkStep_ComputeNewDomEig(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem) { int retval = SUN_SUCCESS; - retval = step_mem->dom_eig_fn(ark_mem->tn, ark_mem->ycur, ark_mem->fn, - &step_mem->lambdaR, &step_mem->lambdaI, - ark_mem->user_data, ark_mem->tempv1, - ark_mem->tempv2, ark_mem->tempv3); - step_mem->dom_eig_num_evals++; - if (retval != ARK_SUCCESS) + suncomplextype dom_eig; + + if(step_mem->dom_eig_fn == NULL) { - arkProcessError(ark_mem, ARK_DOMEIG_FAIL, __LINE__, __func__, __FILE__, - "Unable to estimate the dominant eigenvalue"); - return ARK_DOMEIG_FAIL; + dom_eig = LSRKStepArnoldiEstimate(ark_mem, step_mem->arnoldi_mem); + if((dom_eig.real*dom_eig.real + dom_eig.imag*dom_eig.imag) < 0.000000001) // change the small number + { + arkProcessError(ark_mem, ARK_DOMEIG_FAIL, __LINE__, __func__, __FILE__, + "Unable to estimate the dominant eigenvalue: Arnoldi estimation returned an error"); + return ARK_DOMEIG_FAIL; + } + step_mem->dom_eig_num_evals++; + + step_mem->lambdaR = dom_eig.real; + step_mem->lambdaI = dom_eig.imag; + } + else + { + retval = step_mem->dom_eig_fn(ark_mem->tn, ark_mem->ycur, ark_mem->fn, + &step_mem->lambdaR, &step_mem->lambdaI, + ark_mem->user_data, ark_mem->tempv1, + ark_mem->tempv2, ark_mem->tempv3); + step_mem->dom_eig_num_evals++; + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_DOMEIG_FAIL, __LINE__, __func__, __FILE__, + "Unable to estimate the dominant eigenvalue"); + return ARK_DOMEIG_FAIL; + } } if (step_mem->lambdaR * ark_mem->h > ZERO) diff --git a/src/arkode/arkode_lsrkstep_impl.h b/src/arkode/arkode_lsrkstep_impl.h index c6f0ac8aba..6bed6ad614 100644 --- a/src/arkode/arkode_lsrkstep_impl.h +++ b/src/arkode/arkode_lsrkstep_impl.h @@ -156,6 +156,7 @@ typedef struct ARKodeLSRKStepMemRec sunrealtype spectral_radius_min; /* min spectral radius*/ sunrealtype dom_eig_safety; /* some safety factor for the user provided dom_eig*/ long int dom_eig_freq; /* indicates dom_eig update after dom_eig_freq successful steps*/ + void* arnoldi_mem; /* Arnoldi memory */ N_Vector Arnoldi_q; /* Arnoldi initial q vector*/ int Arnoldi_maxl; /* Krylov subspace dimension */ diff --git a/src/arkode/arkode_lsrkstep_io.c b/src/arkode/arkode_lsrkstep_io.c index 2feb7a896e..8490ea0423 100644 --- a/src/arkode/arkode_lsrkstep_io.c +++ b/src/arkode/arkode_lsrkstep_io.c @@ -200,6 +200,7 @@ int LSRKStepSetDomEigFn(void* arkode_mem, ARKDomEigFn dom_eig) { ARKodeMem ark_mem; ARKodeLSRKStepMem step_mem; + int retval; /* access ARKodeMem and ARKodeLSRKStepMem structures */ @@ -207,7 +208,7 @@ int LSRKStepSetDomEigFn(void* arkode_mem, ARKDomEigFn dom_eig) &step_mem); if (retval != ARK_SUCCESS) { return retval; } - /* set the dom_eig routine pointer, and update relevant flags */ + /* set the dom_eig routine pointer, or create internal dom_eig memory */ if (dom_eig != NULL) { step_mem->dom_eig_fn = dom_eig; @@ -218,9 +219,9 @@ int LSRKStepSetDomEigFn(void* arkode_mem, ARKDomEigFn dom_eig) { step_mem->dom_eig_fn = NULL; - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - "Internal dom_eig is not supported yet!"); - return ARK_ILL_INPUT; + step_mem->arnoldi_mem = LSRKStepArnoldiCreate(arkode_mem); + + return ARK_SUCCESS; } } @@ -519,7 +520,6 @@ int lsrkStep_SetDefaults(ARKodeMem ark_mem) step_mem->spectral_radius_min = ZERO; step_mem->dom_eig_safety = DOM_EIG_SAFETY_DEFAULT; step_mem->dom_eig_freq = DOM_EIG_FREQ_DEFAULT; - step_mem->Arnoldi_maxl = ARNOLDI_MAXL_DEFAULT; /* Flags */ step_mem->dom_eig_update = SUNTRUE; From d278d6e86b211515478e49a63b9ea7b6ca27409f Mon Sep 17 00:00:00 2001 From: maggul Date: Sun, 25 May 2025 02:56:06 -0500 Subject: [PATCH 010/128] ArnoldiPowerIteration --- include/sundials/sundials_arnoldi.h | 10 +++- src/sundials/sundials_arnoldi.c | 77 +++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 1 deletion(-) diff --git a/include/sundials/sundials_arnoldi.h b/include/sundials/sundials_arnoldi.h index 9c3c05bc49..9043a965d6 100644 --- a/include/sundials/sundials_arnoldi.h +++ b/include/sundials/sundials_arnoldi.h @@ -27,7 +27,9 @@ extern "C" { #endif /* Default ARNOLDI parameters */ -#define DEFAULT_POWER_OF_A 0 +#define DEFAULT_POWER_OF_A 0 +#define DEFAULT_POWER_ITER_TOL SUN_RCONST(0.01) +#define DEFAULT_MAX_POWER_ITER 100 /* SUNRhsFn type definition */ typedef int (*SUNRhsFn)(sunrealtype t, N_Vector y, N_Vector ydot, @@ -53,8 +55,12 @@ typedef struct ARNOLDIMemRec N_Vector *V, q; /* Krylov subspace vectors */ int maxl; /* Krylov subspace dimension */ + int length; /* Problem dimension */ int power_of_A; /* Power of A in the preprocessing; initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ + sunrealtype powiter_tol; + int max_powiter; + sunrealtype **Hes; /* Hessenberg matrix Hes */ }* ARNOLDIMem; @@ -77,6 +83,8 @@ SUNDIALS_EXPORT int ArnoldiComputeHess(ARNOLDIMem arnoldi_mem); SUNDIALS_EXPORT int ArnoldiPreProcess(ARNOLDIMem arnoldi_mem); +SUNDIALS_EXPORT suncomplextype ArnoldiPowerIteration(ARNOLDIMem arnoldi_mem); + SUNDIALS_EXPORT suncomplextype ArnoldiEstimate(ARNOLDIMem arnoldi_mem); SUNDIALS_EXPORT void ArnoldiFree(ARNOLDIMem* arnoldi_mem); diff --git a/src/sundials/sundials_arnoldi.c b/src/sundials/sundials_arnoldi.c index 33486c980c..98696fff75 100644 --- a/src/sundials/sundials_arnoldi.c +++ b/src/sundials/sundials_arnoldi.c @@ -81,10 +81,17 @@ void* ArnoldiCreate(SUNATimesFn ATimes, void* Adata, arnoldi_mem->Adata = Adata; arnoldi_mem->q = q; arnoldi_mem->maxl = maxl; + arnoldi_mem->length = q->ops->nvgetlength(q); /* Set the default power of A to start with (# of warm-ups) */ arnoldi_mem->power_of_A = DEFAULT_POWER_OF_A; + /* Set the default tolerance of the power iteration */ + arnoldi_mem->powiter_tol = DEFAULT_POWER_ITER_TOL; + + /* Set the default max number of the power iteration */ + arnoldi_mem->max_powiter = DEFAULT_MAX_POWER_ITER; + /* Hessenberg matrix Hes */ if (arnoldi_mem->Hes == NULL) { @@ -204,6 +211,69 @@ int ArnoldiComputeHess(ARNOLDIMem arnoldi_mem) return 0; } +suncomplextype ArnoldiPowerIteration(ARNOLDIMem arnoldi_mem) +{ + int retval; + + suncomplextype dom_eig, dom_eig_old; + dom_eig.real = ZERO; + dom_eig.imag = ZERO; + dom_eig_old.real = ZERO; + dom_eig_old.imag = ZERO; + + /* Check if Arnoldi memory is allocated */ + if(arnoldi_mem == NULL) + { + printf(MSG_ARNOLDI_MEM_FAIL); + + return dom_eig; + } + + /* Check if ATimes is provided */ + if(arnoldi_mem->ATimes == NULL) + { + printf(MSG_ARNOLDI_NULL_ATIMES); + ArnoldiFree(&arnoldi_mem); + + return dom_eig; + } + + int k = 0; + sunrealtype normq; + + for (int k = 0; k < arnoldi_mem->max_powiter; k++) + { + retval = arnoldi_mem->ATimes(arnoldi_mem->Adata, arnoldi_mem->V[0], arnoldi_mem->q); + if (retval != 0) + { + (retval < 0) ? + printf(MSG_ARNOLDI_ATIMES_FAIL_UNREC) : + printf(MSG_ARNOLDI_ATIMES_FAIL_REC); + ArnoldiFree(&arnoldi_mem); + + dom_eig.real = ZERO; + dom_eig.imag = ZERO; + + return dom_eig; + } + + dom_eig.real = N_VDotProd(arnoldi_mem->V[0], arnoldi_mem->q); //Rayleigh quotient + + if(fabs(dom_eig.real - dom_eig_old.real) < arnoldi_mem->powiter_tol) + { + break; + } + + normq = N_VDotProd(arnoldi_mem->q, arnoldi_mem->q); + normq = SUNRsqrt(normq); + N_VScale(SUN_RCONST(1.0)/normq, arnoldi_mem->q, arnoldi_mem->V[0]); + + dom_eig_old.real = dom_eig.real; + } + + return dom_eig; +} + /* Estimate the dominant eigvalues of the Hessenberg matrix */ suncomplextype ArnoldiEstimate(ARNOLDIMem arnoldi_mem) { suncomplextype dom_eig; @@ -218,6 +288,13 @@ suncomplextype ArnoldiEstimate(ARNOLDIMem arnoldi_mem) { return dom_eig; } + if(arnoldi_mem->length < 3) + { + dom_eig = ArnoldiPowerIteration(arnoldi_mem); + + return dom_eig; + } + int n = arnoldi_mem->maxl; /* Create the vector A which holds rows of the Hessenberg matrix in the given order */ From 749b43d6c5ce10b1fff02ee0a7e142f358b427b3 Mon Sep 17 00:00:00 2001 From: maggul Date: Sun, 25 May 2025 15:22:06 -0500 Subject: [PATCH 011/128] an LSRK example with the internal domeig estimation --- examples/arkode/C_serial/CMakeLists.txt | 1 + .../ark_analytic_lsrk_internal_domeig.c | 343 ++++++++++++++++++ .../ark_analytic_lsrk_internal_domeig.out | 44 +++ 3 files changed, 388 insertions(+) create mode 100644 examples/arkode/C_serial/ark_analytic_lsrk_internal_domeig.c create mode 100644 examples/arkode/C_serial/ark_analytic_lsrk_internal_domeig.out diff --git a/examples/arkode/C_serial/CMakeLists.txt b/examples/arkode/C_serial/CMakeLists.txt index e1956028cd..59b870a3e8 100644 --- a/examples/arkode/C_serial/CMakeLists.txt +++ b/examples/arkode/C_serial/CMakeLists.txt @@ -26,6 +26,7 @@ set(ARKODE_examples "ark_advection_diffusion_reaction_splitting\;\;develop" "ark_analytic_lsrk\;\;develop" "ark_analytic_lsrk_varjac\;\;develop" + "ark_analytic_lsrk_internal_domeig\;\;develop" "ark_analytic_mels\;\;develop" "ark_analytic_nonlin\;\;develop" "ark_analytic_partitioned\;forcing\;develop" diff --git a/examples/arkode/C_serial/ark_analytic_lsrk_internal_domeig.c b/examples/arkode/C_serial/ark_analytic_lsrk_internal_domeig.c new file mode 100644 index 0000000000..60f45d690e --- /dev/null +++ b/examples/arkode/C_serial/ark_analytic_lsrk_internal_domeig.c @@ -0,0 +1,343 @@ +/*----------------------------------------------------------------- + * Programmer(s): Mustafa Aggul @ SMU + *--------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2025, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + *--------------------------------------------------------------- + * Example problem: + * + * The following is a simple example problem that solves the ODE + * + * dy/dt = (lambda - alpha*cos((10 - t)/10*pi)*y + 1/(1+t^2) + * - (lambda - alpha*cos((10 - t)/10*pi)*atan(t), + * + * for t in the interval [0.0, 10.0], with an initial condition: y=0. + * This initial value problem has the analytical solution + * + * y(t) = arctan(t). + * + * The stiffness of the problem depends on both lambda and alpha together. + * While lambda determines the center of the stiffness parameter, + * the value of alpha determines the radius of the interval in which + * the stiffness parameter lies. + * + * The value of lambda - alpha*cos((10 - t)/10*pi) should + * be negative to result in a well-posed ODE; for values with magnitude + * larger than 100 the problem becomes quite stiff. + * + * This program solves the problem with the LSRK method using internal + * dominant eigenvalue module for eigenvalue estimation. + * Output is printed every 1.0 units of time (10 total). + * Run statistics (optional outputs) are printed at the end. + *-----------------------------------------------------------------*/ + +/* Header files */ +#include /* prototypes for LSRKStep fcts., consts */ +#include +#include /* serial N_Vector types, fcts., macros */ +#include +#include /* def. of SUNRsqrt, etc. */ +#include /* definition of type sunrealtype */ + +#if defined(SUNDIALS_EXTENDED_PRECISION) +#define GSYM "Lg" +#define ESYM "Le" +#define FSYM "Lf" +#else +#define GSYM "g" +#define ESYM "e" +#define FSYM "f" +#endif + +#if defined(SUNDIALS_DOUBLE_PRECISION) +#define ATAN(x) (atan((x))) +#define ACOS(x) (acos((x))) +#define COS(x) (cos((x))) +#elif defined(SUNDIALS_SINGLE_PRECISION) +#define ATAN(x) (atanf((x))) +#define ACOS(x) (acosf((x))) +#define COS(x) (cosf((x))) +#elif defined(SUNDIALS_EXTENDED_PRECISION) +#define ATAN(x) (atanl((x))) +#define ACOS(x) (acosl((x))) +#define COS(x) (cosl((x))) +#endif + +/* User-supplied Functions Called by the Solver */ +static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); + +/* Private function to check function return values */ +static int check_flag(void* flagvalue, const char* funcname, int opt); + +/* Private function to check computed solution */ +static int check_ans(N_Vector y, sunrealtype t, sunrealtype rtol, + sunrealtype atol); + +/* Private function to compute error */ +static int compute_error(N_Vector y, sunrealtype t); + +/* Main Program */ +int main(void) +{ + /* general problem parameters */ + sunrealtype T0 = SUN_RCONST(0.0); /* initial time */ + sunrealtype Tf = SUN_RCONST(10.0); /* final time */ + sunrealtype dTout = SUN_RCONST(1.0); /* time between outputs */ + sunindextype NEQ = 1; /* number of dependent vars. */ + +#if defined(SUNDIALS_DOUBLE_PRECISION) + sunrealtype reltol = SUN_RCONST(1.0e-8); /* tolerances */ + sunrealtype abstol = SUN_RCONST(1.0e-8); + sunrealtype lambda = SUN_RCONST(-1.0e+6); /* stiffness parameter 1 */ + sunrealtype alpha = SUN_RCONST(1.0e+2); /* stiffness parameter 2 */ +#elif defined(SUNDIALS_SINGLE_PRECISION) + sunrealtype reltol = SUN_RCONST(1.0e-4); /* tolerances */ + sunrealtype abstol = SUN_RCONST(1.0e-8); + sunrealtype lambda = SUN_RCONST(-1.0e+3); /* stiffness parameter 1 */ + sunrealtype alpha = SUN_RCONST(1.0e+1); /* stiffness parameter 2 */ +#elif defined(SUNDIALS_EXTENDED_PRECISION) + sunrealtype reltol = SUN_RCONST(1.0e-8); /* tolerances */ + sunrealtype abstol = SUN_RCONST(1.0e-8); + sunrealtype lambda = SUN_RCONST(-1.0e+6); /* stiffness parameter 1 */ + sunrealtype alpha = SUN_RCONST(1.0e+2); /* stiffness parameter 2 */ +#endif + + sunrealtype UserData[2]; + UserData[0] = lambda; + UserData[1] = alpha; + + /* general problem variables */ + int flag; /* reusable error-checking flag */ + N_Vector y = NULL; /* empty vector for storing solution */ + void* arkode_mem = NULL; /* empty ARKode memory structure */ + FILE *UFID, *FID; + sunrealtype t, tout; + + /* Create the SUNDIALS context object for this simulation */ + SUNContext ctx; + flag = SUNContext_Create(SUN_COMM_NULL, &ctx); + if (check_flag(&flag, "SUNContext_Create", 1)) { return 1; } + + /* Initial diagnostics output */ + printf("\nAnalytical ODE test problem with a variable Jacobian:"); + printf("\nThe stiffness of the problem is directly proportional to"); + printf("\n\"lambda - alpha*cos((10 - t)/10*pi)\"\n\n"); + printf(" lambda = %" GSYM "\n", lambda); + printf(" alpha = %" GSYM "\n", alpha); + printf(" reltol = %.1" ESYM "\n", reltol); + printf(" abstol = %.1" ESYM "\n\n", abstol); + + /* Initialize data structures */ + y = N_VNew_Serial(NEQ, ctx); /* Create serial vector for solution */ + if (check_flag((void*)y, "N_VNew_Serial", 0)) { return 1; } + N_VConst(SUN_RCONST(0.0), y); /* Specify initial condition */ + + /* Call LSRKStepCreateSTS to initialize the ARK timestepper module and + specify the right-hand side function in y'=f(t,y), the initial time + T0, and the initial dependent variable vector y. */ + arkode_mem = LSRKStepCreateSTS(f, T0, y, ctx); + if (check_flag((void*)arkode_mem, "LSRKStepCreateSTS", 0)) { return 1; } + + /* Set routines */ + flag = ARKodeSetUserData(arkode_mem, + (void*)&UserData); /* Pass lambda to user functions */ + if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; } + + /* Specify tolerances */ + flag = ARKodeSStolerances(arkode_mem, reltol, abstol); + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } + + /* Specify NULL spectral radius function */ + flag = LSRKStepSetDomEigFn(arkode_mem, NULL); + if (check_flag(&flag, "LSRKStepSetDomEigFn", 1)) { return 1; } + + /* Specify after how many successful steps dom_eig is recomputed */ + flag = LSRKStepSetDomEigFrequency(arkode_mem, 25); + if (check_flag(&flag, "LSRKStepSetDomEigFrequency", 1)) { return 1; } + + /* Specify max number of stages allowed */ + flag = LSRKStepSetMaxNumStages(arkode_mem, 200); + if (check_flag(&flag, "LSRKStepSetMaxNumStages", 1)) { return 1; } + + /* Specify max number of steps allowed */ + flag = ARKodeSetMaxNumSteps(arkode_mem, 2000); + if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) { return 1; } + + /* Specify safety factor for user provided dom_eig */ + flag = LSRKStepSetDomEigSafetyFactor(arkode_mem, SUN_RCONST(1.01)); + if (check_flag(&flag, "LSRKStepSetDomEigSafetyFactor", 1)) { return 1; } + + /* Specify the Runge--Kutta--Chebyshev LSRK method by name */ + flag = LSRKStepSetSTSMethodByName(arkode_mem, "ARKODE_LSRK_RKC_2"); + if (check_flag(&flag, "LSRKStepSetSTSMethodByName", 1)) { return 1; } + + /* Open output stream for results, output comment line */ + UFID = fopen("solution.txt", "w"); + fprintf(UFID, "# t u\n"); + + /* output initial condition to disk */ + fprintf(UFID, " %.16" ESYM " %.16" ESYM "\n", T0, N_VGetArrayPointer(y)[0]); + + /* Main time-stepping loop: calls ARKodeEvolve to perform the integration, then + prints results. Stops when the final time has been reached */ + t = T0; + tout = T0 + dTout; + printf(" t u\n"); + printf(" ---------------------\n"); + while (Tf - t > SUN_RCONST(1.0e-15)) + { + flag = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); /* call integrator */ + if (check_flag(&flag, "ARKodeEvolve", 1)) { break; } + printf(" %10.6" FSYM " %10.6" FSYM "\n", t, + N_VGetArrayPointer(y)[0]); /* access/print solution */ + fprintf(UFID, " %.16" ESYM " %.16" ESYM "\n", t, N_VGetArrayPointer(y)[0]); + if (flag < 0) + { /* unsuccessful solve: break */ + fprintf(stderr, "Solver failure, stopping integration\n"); + break; + } + else + { /* successful solve: update time */ + tout += dTout; + tout = (tout > Tf) ? Tf : tout; + } + } + printf(" ---------------------\n"); + fclose(UFID); + + /* Print final statistics */ + printf("\nFinal Statistics:\n"); + flag = ARKodePrintAllStats(arkode_mem, stdout, SUN_OUTPUTFORMAT_TABLE); + + /* Print final statistics to a file in CSV format */ + FID = fopen("ark_analytic_nonlin_stats.csv", "w"); + flag = ARKodePrintAllStats(arkode_mem, FID, SUN_OUTPUTFORMAT_CSV); + fclose(FID); + + /* check the solution error */ + flag = check_ans(y, t, reltol, abstol); + flag = compute_error(y, t); + + /* Clean up and return */ + N_VDestroy(y); /* Free y vector */ + ARKodeFree(&arkode_mem); /* Free integrator memory */ + SUNContext_Free(&ctx); /* Free context */ + + return flag; +} + +/*------------------------------- + * Functions called by the solver + *-------------------------------*/ + +/* f routine to compute the ODE RHS function f(t,y). */ +static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +{ + sunrealtype* rdata = (sunrealtype*)user_data; /* cast user_data to sunrealtype */ + sunrealtype lambda = rdata[0]; /* set shortcut for stiffness parameter 1 */ + sunrealtype alpha = rdata[1]; /* set shortcut for stiffness parameter 2 */ + sunrealtype u = N_VGetArrayPointer(y)[0]; /* access current solution value */ + + /* fill in the RHS function: "N_VGetArrayPointer" accesses the 0th entry of ydot */ + N_VGetArrayPointer(ydot)[0] = + (lambda - alpha * COS((SUN_RCONST(10.0) - t) / SUN_RCONST(10.0) * + ACOS(SUN_RCONST(-1.0)))) * + u + + SUN_RCONST(1.0) / (SUN_RCONST(1.0) + t * t) - + (lambda - alpha * COS((SUN_RCONST(10.0) - t) / SUN_RCONST(10.0) * + ACOS(SUN_RCONST(-1.0)))) * + ATAN(t); + + return 0; /* return with success */ +} + +/*------------------------------- + * Private helper functions + *-------------------------------*/ + +/* Check function return value... + opt == 0 means SUNDIALS function allocates memory so check if + returned NULL pointer + opt == 1 means SUNDIALS function returns a flag so check if + flag >= 0 + opt == 2 means function allocates memory so check if returned + NULL pointer +*/ +static int check_flag(void* flagvalue, const char* funcname, int opt) +{ + int* errflag; + + /* Check if SUNDIALS function returned NULL pointer - no memory allocated */ + if (opt == 0 && flagvalue == NULL) + { + fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n", + funcname); + return 1; + } + + /* Check if flag < 0 */ + else if (opt == 1) + { + errflag = (int*)flagvalue; + if (*errflag < 0) + { + fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n", + funcname, *errflag); + return 1; + } + } + + /* Check if function returned NULL pointer - no memory allocated */ + else if (opt == 2 && flagvalue == NULL) + { + fprintf(stderr, "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n", + funcname); + return 1; + } + + return 0; +} + +/* check the computed solution */ +static int check_ans(N_Vector y, sunrealtype t, sunrealtype rtol, sunrealtype atol) +{ + int passfail = 0; /* answer pass (0) or fail (1) flag */ + sunrealtype ans, err, ewt; /* answer data, error, and error weight */ + + /* compute solution error */ + ans = ATAN(t); + ewt = SUN_RCONST(1.0) / (rtol * SUNRabs(ans) + atol); + err = ewt * SUNRabs(N_VGetArrayPointer(y)[0] - ans); + + /* is the solution within the tolerances? */ + passfail = (err < SUN_RCONST(1.0)) ? 0 : 1; + + if (passfail) + { + fprintf(stdout, "\nSUNDIALS_WARNING: check_ans error=%" GSYM "\n\n", err); + } + + return (passfail); +} + +/* check the error */ +static int compute_error(N_Vector y, sunrealtype t) +{ + sunrealtype ans, err; /* answer data, error */ + + /* compute solution error */ + ans = ATAN(t); + err = SUNRabs(N_VGetArrayPointer(y)[0] - ans); + + fprintf(stdout, "\nACCURACY at the final time = %" GSYM "\n", err); + return 0; +} + +/*---- end of file ----*/ diff --git a/examples/arkode/C_serial/ark_analytic_lsrk_internal_domeig.out b/examples/arkode/C_serial/ark_analytic_lsrk_internal_domeig.out new file mode 100644 index 0000000000..050c5258a0 --- /dev/null +++ b/examples/arkode/C_serial/ark_analytic_lsrk_internal_domeig.out @@ -0,0 +1,44 @@ + +Analytical ODE test problem with a variable Jacobian: +The stiffness of the problem is directly proportional to +"lambda - alpha*cos((10 - t)/10*pi)" + + lambda = -1e+06 + alpha = 100 + reltol = 1.0e-08 + abstol = 1.0e-08 + + t u + --------------------- + 1.000000 0.785398 + 2.000000 1.107149 + 3.000000 1.249046 + 4.000000 1.325818 + 5.000000 1.373401 + 6.000000 1.405648 + 7.000000 1.428899 + 8.000000 1.446441 + 9.000000 1.460139 + 10.000000 1.471128 + --------------------- + +Final Statistics: +Current time = 10.0223435625334 +Steps = 1228 +Step attempts = 1293 +Stability limited steps = 100 +Accuracy limited steps = 1293 +Error test fails = 65 +NLS step fails = 0 +Inequality constraint fails = 0 +Initial step size = 1.93010111094261e-10 +Last step size = 0.0231428573546272 +Current step size = 0.0355887084904971 +RHS fn evals = 134016 +Number of dom_eig updates = 85 +Max. num. of stages used = 199 +Max. num. of stages allowed = 200 +Max. spectral radius = 1010101.00085802 +Min. spectral radius = 1009899.00000001 + +ACCURACY at the final time = 2.42251e-13 \ No newline at end of file From 4fe21738b8fa934b368e0fc4004de08a3437e822 Mon Sep 17 00:00:00 2001 From: maggul Date: Tue, 27 May 2025 22:51:01 -0500 Subject: [PATCH 012/128] CI test error fixes --- src/nvector/manyvector/nvector_manyvector.c | 1 - src/sundials/sundials_arnoldi.c | 49 +++++++++------------ test/unit_tests/sundials/test_arnoldi.c | 7 +-- 3 files changed, 26 insertions(+), 31 deletions(-) diff --git a/src/nvector/manyvector/nvector_manyvector.c b/src/nvector/manyvector/nvector_manyvector.c index 77ff397c50..8a1b8e77bd 100644 --- a/src/nvector/manyvector/nvector_manyvector.c +++ b/src/nvector/manyvector/nvector_manyvector.c @@ -1504,7 +1504,6 @@ SUNErrCode MVAPPEND(N_VRandom)(N_Vector x) { SUNFunctionBegin(x->sunctx); sunindextype i; - SUNErrCode retval; for (i = 0; i < MANYVECTOR_NUM_SUBVECS(x); i++) { SUNCheckCall(N_VRandom(MANYVECTOR_SUBVEC(x, i))); diff --git a/src/sundials/sundials_arnoldi.c b/src/sundials/sundials_arnoldi.c index 98696fff75..2c31f93d03 100644 --- a/src/sundials/sundials_arnoldi.c +++ b/src/sundials/sundials_arnoldi.c @@ -21,7 +21,6 @@ #include #define ZERO SUN_RCONST(0.0) -#define ONE SUN_RCONST(1.0) /* * ----------------------------------------------------------------- @@ -95,10 +94,11 @@ void* ArnoldiCreate(SUNATimesFn ATimes, void* Adata, /* Hessenberg matrix Hes */ if (arnoldi_mem->Hes == NULL) { + int k; arnoldi_mem->Hes = (sunrealtype**)malloc((maxl + 1) * sizeof(sunrealtype*)); - for (int k = 0; k <= maxl; k++) + for (k = 0; k <= maxl; k++) { arnoldi_mem->Hes[k] = NULL; arnoldi_mem->Hes[k] = (sunrealtype*)malloc(maxl * sizeof(sunrealtype)); @@ -142,9 +142,10 @@ int ArnoldiPreProcess(ARNOLDIMem arnoldi_mem) } sunrealtype normq; + int i; /* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ - for(int i = 0; i < arnoldi_mem->power_of_A; i++) { + for(i = 0; i < arnoldi_mem->power_of_A; i++) { retval = arnoldi_mem->ATimes(arnoldi_mem->Adata, arnoldi_mem->V[0], arnoldi_mem->q); if (retval != 0) { @@ -176,13 +177,14 @@ int ArnoldiComputeHess(ARNOLDIMem arnoldi_mem) return -1; } + int i, j; /* Initialize the Hessenberg matrix Hes with zeros */ - for (int i = 0; i < arnoldi_mem->maxl; i++) + for (i = 0; i < arnoldi_mem->maxl; i++) { - for (int j = 0; j < arnoldi_mem->maxl; j++) { arnoldi_mem->Hes[i][j] = ZERO; } + for (j = 0; j < arnoldi_mem->maxl; j++) { arnoldi_mem->Hes[i][j] = ZERO; } } - for (int i = 0; i < arnoldi_mem->maxl; i++) + for (i = 0; i < arnoldi_mem->maxl; i++) { /* Compute the next Krylov vector */ retval = arnoldi_mem->ATimes(arnoldi_mem->Adata, arnoldi_mem->V[i], arnoldi_mem->V[i+1]); @@ -238,10 +240,10 @@ suncomplextype ArnoldiPowerIteration(ARNOLDIMem arnoldi_mem) return dom_eig; } - int k = 0; + int k; sunrealtype normq; - for (int k = 0; k < arnoldi_mem->max_powiter; k++) + for (k = 0; k < arnoldi_mem->max_powiter; k++) { retval = arnoldi_mem->ATimes(arnoldi_mem->Adata, arnoldi_mem->V[0], arnoldi_mem->q); if (retval != 0) @@ -300,25 +302,28 @@ suncomplextype ArnoldiEstimate(ARNOLDIMem arnoldi_mem) { /* Create the vector A which holds rows of the Hessenberg matrix in the given order */ sunrealtype* A; A = (sunrealtype*)malloc((n*n) * sizeof(sunrealtype)); - int k = 0; - for (int i = 0; i < n; i++) { - for (int j = 0; j < n; j++) { + int i, j, k = 0; + for (i = 0; i < n; i++) { + for (j = 0; j < n; j++) { A[k] = arnoldi_mem->Hes[i][j]; k++; } } - sunrealtype wr[n], wi[n]; // Real and imaginary parts of eigenvalues - sunrealtype vl[n*n], vr[n*n]; // Left and right eigenvectors (optional, can be NULL) + sunrealtype *wr = malloc(n * sizeof(sunrealtype)); // Real and imaginary parts of eigenvalues + sunrealtype *wi = malloc(n * sizeof(sunrealtype)); + int lda = n, ldvl = n, ldvr = n; int info, lwork = 4 * n; - sunrealtype work[4 * n]; // Workspace array + + sunrealtype *work = malloc(lwork * sizeof(sunrealtype)); // Workspace array + char jobvl = 'N'; // Do not compute left eigenvectors char jobvr = 'N'; // Do not compute right eigenvectors // Call LAPACK's dgeev function - dgeev_(&jobvl, &jobvr, &n, A, &lda, wr, wi, vl, &ldvl, vr, &ldvr, work, &lwork, &info); + dgeev_(&jobvl, &jobvr, &n, A, &lda, wr, wi, NULL, &ldvl, NULL, &ldvr, work, &lwork, &info); if (info != 0) { printf(MSG_ARNOLDI_LAPACK_FAIL, info); @@ -331,7 +336,7 @@ suncomplextype ArnoldiEstimate(ARNOLDIMem arnoldi_mem) { { // Create an array of suncomplextype structs suncomplextype *arr = (suncomplextype *)malloc(n * sizeof(suncomplextype)); - for (int i = 0; i < n; i++) { + for (i = 0; i < n; i++) { arr[i].real = wr[i]; arr[i].imag = wi[i]; } @@ -340,7 +345,7 @@ suncomplextype ArnoldiEstimate(ARNOLDIMem arnoldi_mem) { qsort(arr, n, sizeof(suncomplextype), arnoldi_Compare); // Update the original arrays - for (int i = 0; i < n; i++) { + for (i = 0; i < n; i++) { wr[i] = arr[i].real; wi[i] = arr[i].imag; } @@ -349,16 +354,6 @@ suncomplextype ArnoldiEstimate(ARNOLDIMem arnoldi_mem) { free(arr); } - // // Print eigenvalues - // printf("\nEigenvalues:\n"); - // for (int i = 0; i < n; i++) { - // if (wi[i] == 0.0) { - // printf("%f\n", wr[i]); // sunrealtype eigenvalue - // } else { - // printf("%f + %fi\n", wr[i], wi[i]); // suncomplextype eigenvalue - // } - // } - dom_eig.real = wr[0]; dom_eig.imag = wi[0]; diff --git a/test/unit_tests/sundials/test_arnoldi.c b/test/unit_tests/sundials/test_arnoldi.c index 8304d03778..a09b8a66e2 100644 --- a/test/unit_tests/sundials/test_arnoldi.c +++ b/test/unit_tests/sundials/test_arnoldi.c @@ -121,7 +121,8 @@ int main(int argc, char* argv[]) // suncomplextype diag is [ realpart imagpart; // -imagpart realpart] sunrealtype *v = N_VGetArrayPointer(ProbData.d); - for(int i=0; i < ProbData.N-2; i++) + int i, j; + for(i = 0; i < ProbData.N-2; i++) { v[i] = factor*(i + 3); } @@ -143,8 +144,8 @@ int main(int argc, char* argv[]) if(ProbData.N <= 10){ printf("\n"); printf("Hes:\n"); - for (int i = 0; i < Arnoldi_mem->maxl + 1; i++) { - for (int j = 0; j < Arnoldi_mem->maxl; j++) { + for (i = 0; i < Arnoldi_mem->maxl + 1; i++) { + for (j = 0; j < Arnoldi_mem->maxl; j++) { printf("%20.2lf ", Arnoldi_mem->Hes[i][j]); } printf("\n"); From 6650b901f3c937f3d5707cd4c096b2b90483cb85 Mon Sep 17 00:00:00 2001 From: maggul Date: Wed, 28 May 2025 00:09:44 -0500 Subject: [PATCH 013/128] update lsrkStep_ArnoldiCreate to be implicit --- include/arkode/arkode_lsrkstep.h | 5 - include/sundials/priv/sundials_arnoldi_impl.h | 5 +- include/sundials/sundials_arnoldi.h | 12 +- src/arkode/arkode_lsrkstep.c | 174 +++++++++--------- src/arkode/arkode_lsrkstep_impl.h | 4 +- src/arkode/arkode_lsrkstep_io.c | 2 +- src/sundials/sundials_arnoldi.c | 13 +- test/unit_tests/sundials/test_arnoldi.c | 2 +- 8 files changed, 106 insertions(+), 111 deletions(-) diff --git a/include/arkode/arkode_lsrkstep.h b/include/arkode/arkode_lsrkstep.h index 3e6afdfe0a..ce3b4e59d4 100644 --- a/include/arkode/arkode_lsrkstep.h +++ b/include/arkode/arkode_lsrkstep.h @@ -60,11 +60,6 @@ SUNDIALS_EXPORT int LSRKStepReInitSTS(void* arkode_mem, ARKRhsFn rhs, SUNDIALS_EXPORT int LSRKStepReInitSSP(void* arkode_mem, ARKRhsFn rhs, sunrealtype t0, N_Vector y0); -SUNDIALS_EXPORT void* LSRKStepArnoldiCreate(void* arkode_mem); - -SUNDIALS_EXPORT suncomplextype LSRKStepArnoldiEstimate(void* arkode_mem, - ARNOLDIMem Arnoldi_mem); - /* Optional input functions -- must be called AFTER a creation routine above */ SUNDIALS_EXPORT int LSRKStepSetSTSMethod(void* arkode_mem, diff --git a/include/sundials/priv/sundials_arnoldi_impl.h b/include/sundials/priv/sundials_arnoldi_impl.h index 8668cc6368..3b1a85a932 100644 --- a/include/sundials/priv/sundials_arnoldi_impl.h +++ b/include/sundials/priv/sundials_arnoldi_impl.h @@ -2,7 +2,7 @@ * Programmer(s): Mustafa Aggul @ SMU * ----------------------------------------------------------------- * SUNDIALS Copyright Start - * Copyright (c) 2002-2024, Lawrence Livermore National Security + * Copyright (c) 2002-2025, Lawrence Livermore National Security * and Southern Methodist University. * All rights reserved. * @@ -51,10 +51,9 @@ extern "C" { #define MSG_ARNOLDI_NULL_q "q is null." #define MSG_ARNOLDI_BAD_NVECTOR "Bad NVector." #define MSG_ARNOLDI_NULL_ATIMES "ATimes is null." -#define MSG_ARNOLDI_NULL_SUNRHSFN "SUNRhsFn is null." #define MSG_ARNOLDI_ATIMES_FAIL_REC "Atimes recoverable failure" #define MSG_ARNOLDI_ATIMES_FAIL_UNREC "Atimes unrecoverable failure" -#define MSG_ARNOLDI_NOT_ENOUGH_ITER "Number of Krylov subspace is not enough (< 3)" +#define MSG_ARNOLDI_NOT_ENOUGH_ITER "Number of Krylov subspace is not enough (< 2)" #define MSG_ARNOLDI_NULL_SUNCTX "sunctx is null." #define MSG_ARNOLDI_MEM_FAIL "ARNOLDI memory fail." #define MSG_ARNOLDI_GS_FAIL "ARNOLDI Modified GS fail." diff --git a/include/sundials/sundials_arnoldi.h b/include/sundials/sundials_arnoldi.h index 9043a965d6..4c3a5b7438 100644 --- a/include/sundials/sundials_arnoldi.h +++ b/include/sundials/sundials_arnoldi.h @@ -2,7 +2,7 @@ * Programmer(s): Mustafa Aggul @ SMU * ----------------------------------------------------------------- * SUNDIALS Copyright Start - * Copyright (c) 2002-2024, Lawrence Livermore National Security + * Copyright (c) 2002-2025, Lawrence Livermore National Security * and Southern Methodist University. * All rights reserved. * @@ -31,10 +31,6 @@ extern "C" { #define DEFAULT_POWER_ITER_TOL SUN_RCONST(0.01) #define DEFAULT_MAX_POWER_ITER 100 -/* SUNRhsFn type definition */ -typedef int (*SUNRhsFn)(sunrealtype t, N_Vector y, N_Vector ydot, - void* user_data); - /*=============================================================== ARNOLDI module data structure ===============================================================*/ @@ -43,7 +39,7 @@ typedef int (*SUNRhsFn)(sunrealtype t, N_Vector y, N_Vector ydot, Types : struct ARNOLDIMemRec, ARNOLDIMem --------------------------------------------------------------- The type ARNOLDIMem is type pointer to struct - ARNOLDIMemRec. This structure contains fields to + ARNOLDIMemRec. This structure contains fields to perform an ARNOLDI iteration. ---------------------------------------------------------------*/ typedef struct ARNOLDIMemRec @@ -58,8 +54,8 @@ typedef struct ARNOLDIMemRec int length; /* Problem dimension */ int power_of_A; /* Power of A in the preprocessing; initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ - sunrealtype powiter_tol; - int max_powiter; + sunrealtype powiter_tol; /* Convergence criteria for the power iteration */ + int max_powiter; /* Maximum number of power iterations */ sunrealtype **Hes; /* Hessenberg matrix Hes */ }* ARNOLDIMem; diff --git a/src/arkode/arkode_lsrkstep.c b/src/arkode/arkode_lsrkstep.c index 389ab1d880..4889fc42de 100644 --- a/src/arkode/arkode_lsrkstep.c +++ b/src/arkode/arkode_lsrkstep.c @@ -105,91 +105,6 @@ int LSRKStepReInitSSP(void* arkode_mem, ARKRhsFn rhs, sunrealtype t0, N_Vector y return retval; } -/*--------------------------------------------------------------- - LSRKStepArnoldiCreate: - - This routine creates the Arnoldi memory and attaches all the relevent - function pointers from arkode_mem. - ---------------------------------------------------------------*/ - -void* LSRKStepArnoldiCreate(void* arkode_mem) -{ - ARNOLDIMem Arnoldi_mem; - ARKodeMem ark_mem; - ARKodeLSRKStepMem step_mem; - int retval; - - /* access ARKodeLSRKStepMem structure */ - retval = lsrkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, - &step_mem); - if (retval != ARK_SUCCESS) { return NULL; } - - /* Check if ark_mem was allocated */ - if (ark_mem->MallocDone == SUNFALSE) - { - arkProcessError(ark_mem, ARK_NO_MALLOC, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MALLOC); - return NULL; - } - - step_mem->arnoldi_rhs = step_mem->fe; - - /* Allocate and fill Arnoldi_q vector TODO: use random vector instead */ - step_mem->Arnoldi_q = N_VClone(ark_mem->yn); - N_VConst(SUN_RCONST(1.0), step_mem->Arnoldi_q); - step_mem->Arnoldi_maxl = ARNOLDI_MAXL_DEFAULT; - - Arnoldi_mem = ArnoldiCreate(lsrkStep_DQJtimes, arkode_mem, step_mem->Arnoldi_q, step_mem->Arnoldi_maxl, ark_mem->sunctx); - -} - -/*--------------------------------------------------------------- - LSRKStepArnoldiEstimate: - - This routine estimates the dominant eigenvalue. - ---------------------------------------------------------------*/ -suncomplextype LSRKStepArnoldiEstimate(void* arkode_mem, ARNOLDIMem Arnoldi_mem) -{ - ARKodeMem ark_mem; - - suncomplextype dom_eig; - dom_eig.real = ZERO; - dom_eig.imag = ZERO; - - int retval; - if (arkode_mem == NULL) - { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return dom_eig; - } - ark_mem = (ARKodeMem)arkode_mem; - - /* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ - retval = ArnoldiPreProcess(Arnoldi_mem); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, ARK_ARNOLDI_FAIL, __LINE__, __func__, __FILE__, - MSG_ARK_ARNOLDI_FAIL); - - return dom_eig; - } - - /* Compute the Hessenberg matrix Hes*/ - retval = ArnoldiComputeHess(Arnoldi_mem); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, ARK_ARNOLDI_FAIL, __LINE__, __func__, __FILE__, - MSG_ARK_ARNOLDI_FAIL); - - return dom_eig; - } - - dom_eig = ArnoldiEstimate(Arnoldi_mem); - - return dom_eig; -} - /*=============================================================== Interface routines supplied to ARKODE ===============================================================*/ @@ -2291,8 +2206,8 @@ int lsrkStep_ComputeNewDomEig(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem) if(step_mem->dom_eig_fn == NULL) { - dom_eig = LSRKStepArnoldiEstimate(ark_mem, step_mem->arnoldi_mem); - if((dom_eig.real*dom_eig.real + dom_eig.imag*dom_eig.imag) < 0.000000001) // change the small number + dom_eig = lsrkStep_ArnoldiEstimate(ark_mem, step_mem->arnoldi_mem); + if((dom_eig.real*dom_eig.real + dom_eig.imag*dom_eig.imag) < SUN_SMALL_REAL) { arkProcessError(ark_mem, ARK_DOMEIG_FAIL, __LINE__, __func__, __FILE__, "Unable to estimate the dominant eigenvalue: Arnoldi estimation returned an error"); @@ -2356,6 +2271,91 @@ int lsrkStep_ComputeNewDomEig(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem) return retval; } +/*--------------------------------------------------------------- + lsrkStep_ArnoldiCreate: + + This routine creates the Arnoldi memory and attaches all the relevent + function pointers from arkode_mem. + ---------------------------------------------------------------*/ + +void* lsrkStep_ArnoldiCreate(void* arkode_mem) +{ + ARNOLDIMem Arnoldi_mem; + ARKodeMem ark_mem; + ARKodeLSRKStepMem step_mem; + int retval; + + /* access ARKodeLSRKStepMem structure */ + retval = lsrkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, + &step_mem); + if (retval != ARK_SUCCESS) { return NULL; } + + /* Check if ark_mem was allocated */ + if (ark_mem->MallocDone == SUNFALSE) + { + arkProcessError(ark_mem, ARK_NO_MALLOC, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MALLOC); + return NULL; + } + + step_mem->arnoldi_rhs = step_mem->fe; + + /* Allocate and fill Arnoldi_q vector TODO: use random vector instead */ + step_mem->Arnoldi_q = N_VClone(ark_mem->yn); + N_VConst(SUN_RCONST(1.0), step_mem->Arnoldi_q); + step_mem->Arnoldi_maxl = ARNOLDI_MAXL_DEFAULT; + + Arnoldi_mem = ArnoldiCreate(lsrkStep_DQJtimes, arkode_mem, step_mem->Arnoldi_q, step_mem->Arnoldi_maxl, ark_mem->sunctx); + +} + +/*--------------------------------------------------------------- + lsrkStep_ArnoldiEstimate: + + This routine estimates the dominant eigenvalue. + ---------------------------------------------------------------*/ +suncomplextype lsrkStep_ArnoldiEstimate(void* arkode_mem, ARNOLDIMem Arnoldi_mem) +{ + ARKodeMem ark_mem; + + suncomplextype dom_eig; + dom_eig.real = ZERO; + dom_eig.imag = ZERO; + + int retval; + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return dom_eig; + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ + retval = ArnoldiPreProcess(Arnoldi_mem); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_ARNOLDI_FAIL, __LINE__, __func__, __FILE__, + MSG_ARK_ARNOLDI_FAIL); + + return dom_eig; + } + + /* Compute the Hessenberg matrix Hes*/ + retval = ArnoldiComputeHess(Arnoldi_mem); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_ARNOLDI_FAIL, __LINE__, __func__, __FILE__, + MSG_ARK_ARNOLDI_FAIL); + + return dom_eig; + } + + dom_eig = ArnoldiEstimate(Arnoldi_mem); + + return dom_eig; +} + /*--------------------------------------------------------------- lsrkStep_DQJtimes: diff --git a/src/arkode/arkode_lsrkstep_impl.h b/src/arkode/arkode_lsrkstep_impl.h index 6bed6ad614..4f7312450e 100644 --- a/src/arkode/arkode_lsrkstep_impl.h +++ b/src/arkode/arkode_lsrkstep_impl.h @@ -19,6 +19,7 @@ #define _ARKODE_LSRKSTEP_IMPL_H #include +#include #include "arkode_impl.h" @@ -209,7 +210,8 @@ int lsrkStep_AccessStepMem(ARKodeMem ark_mem, const char* fname, void lsrkStep_DomEigUpdateLogic(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem, sunrealtype dsm); int lsrkStep_ComputeNewDomEig(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem); - +void* lsrkStep_ArnoldiCreate(void* arkode_mem); +suncomplextype lsrkStep_ArnoldiEstimate(void* arkode_mem, ARNOLDIMem Arnoldi_mem); int lsrkStep_DQJtimes(void* arkode_mem, N_Vector v, N_Vector Jv); /*=============================================================== diff --git a/src/arkode/arkode_lsrkstep_io.c b/src/arkode/arkode_lsrkstep_io.c index 8490ea0423..39c62093d8 100644 --- a/src/arkode/arkode_lsrkstep_io.c +++ b/src/arkode/arkode_lsrkstep_io.c @@ -219,7 +219,7 @@ int LSRKStepSetDomEigFn(void* arkode_mem, ARKDomEigFn dom_eig) { step_mem->dom_eig_fn = NULL; - step_mem->arnoldi_mem = LSRKStepArnoldiCreate(arkode_mem); + step_mem->arnoldi_mem = lsrkStep_ArnoldiCreate(arkode_mem); return ARK_SUCCESS; } diff --git a/src/sundials/sundials_arnoldi.c b/src/sundials/sundials_arnoldi.c index 2c31f93d03..749b81df13 100644 --- a/src/sundials/sundials_arnoldi.c +++ b/src/sundials/sundials_arnoldi.c @@ -2,7 +2,7 @@ * Programmer(s): Mustafa Aggul @ SMU * ----------------------------------------------------------------- * SUNDIALS Copyright Start - * Copyright (c) 2002-2024, Lawrence Livermore National Security + * Copyright (c) 2002-2025, Lawrence Livermore National Security * and Southern Methodist University. * All rights reserved. * @@ -49,8 +49,8 @@ void* ArnoldiCreate(SUNATimesFn ATimes, void* Adata, return NULL; } - /* Check if maxl > 2 */ - if (maxl < 3) + /* Check if maxl >= 2 */ + if (maxl < 2) { printf(MSG_ARNOLDI_NOT_ENOUGH_ITER); @@ -300,8 +300,7 @@ suncomplextype ArnoldiEstimate(ARNOLDIMem arnoldi_mem) { int n = arnoldi_mem->maxl; /* Create the vector A which holds rows of the Hessenberg matrix in the given order */ - sunrealtype* A; - A = (sunrealtype*)malloc((n*n) * sizeof(sunrealtype)); + sunrealtype* A = (sunrealtype*)malloc((n*n) * sizeof(sunrealtype)); int i, j, k = 0; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { @@ -351,6 +350,10 @@ suncomplextype ArnoldiEstimate(ARNOLDIMem arnoldi_mem) { } // Cleanup + free(A); + free(wr); + free(wi); + free(work); free(arr); } diff --git a/test/unit_tests/sundials/test_arnoldi.c b/test/unit_tests/sundials/test_arnoldi.c index a09b8a66e2..535230b4f6 100644 --- a/test/unit_tests/sundials/test_arnoldi.c +++ b/test/unit_tests/sundials/test_arnoldi.c @@ -2,7 +2,7 @@ * Programmer(s): Mustafa Aggul @ SMU * ----------------------------------------------------------------- * SUNDIALS Copyright Start - * Copyright (c) 2002-2024, Lawrence Livermore National Security + * Copyright (c) 2002-2025, Lawrence Livermore National Security * and Southern Methodist University. * All rights reserved. * From 2a271cf3ac1c9d594936de082a33159d7b99238d Mon Sep 17 00:00:00 2001 From: maggul Date: Wed, 28 May 2025 09:17:12 -0500 Subject: [PATCH 014/128] length check for unnecessary memory allocation --- src/arkode/arkode_lsrkstep.c | 5 ++--- src/sundials/sundials_arnoldi.c | 35 +++++++++++++++++++++++---------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/arkode/arkode_lsrkstep.c b/src/arkode/arkode_lsrkstep.c index 4889fc42de..1dba28e823 100644 --- a/src/arkode/arkode_lsrkstep.c +++ b/src/arkode/arkode_lsrkstep.c @@ -2300,13 +2300,12 @@ void* lsrkStep_ArnoldiCreate(void* arkode_mem) step_mem->arnoldi_rhs = step_mem->fe; - /* Allocate and fill Arnoldi_q vector TODO: use random vector instead */ + /* Allocate and fill Arnoldi_q vector with random data */ step_mem->Arnoldi_q = N_VClone(ark_mem->yn); - N_VConst(SUN_RCONST(1.0), step_mem->Arnoldi_q); + N_VRandom(step_mem->Arnoldi_q); step_mem->Arnoldi_maxl = ARNOLDI_MAXL_DEFAULT; Arnoldi_mem = ArnoldiCreate(lsrkStep_DQJtimes, arkode_mem, step_mem->Arnoldi_q, step_mem->Arnoldi_maxl, ark_mem->sunctx); - } /*--------------------------------------------------------------- diff --git a/src/sundials/sundials_arnoldi.c b/src/sundials/sundials_arnoldi.c index 749b81df13..0983805913 100644 --- a/src/sundials/sundials_arnoldi.c +++ b/src/sundials/sundials_arnoldi.c @@ -57,6 +57,7 @@ void* ArnoldiCreate(SUNATimesFn ATimes, void* Adata, return NULL; } + /* Test if sunctx is provided */ if (sunctx == NULL) { printf(MSG_ARNOLDI_NULL_SUNCTX); @@ -92,7 +93,7 @@ void* ArnoldiCreate(SUNATimesFn ATimes, void* Adata, arnoldi_mem->max_powiter = DEFAULT_MAX_POWER_ITER; /* Hessenberg matrix Hes */ - if (arnoldi_mem->Hes == NULL) + if (arnoldi_mem->Hes == NULL && arnoldi_mem->length > 2) { int k; arnoldi_mem->Hes = @@ -108,7 +109,14 @@ void* ArnoldiCreate(SUNATimesFn ATimes, void* Adata, /* Krylov subspace vectors */ if (arnoldi_mem->V == NULL) { - arnoldi_mem->V = N_VCloneVectorArray(maxl + 1, q); + if(arnoldi_mem->length > 2) + { + arnoldi_mem->V = N_VCloneVectorArray(maxl + 1, q); + } + else + { + arnoldi_mem->V = N_VCloneVectorArray(1, q); + } } /* Unitize the initial vector V[0] */ @@ -177,6 +185,13 @@ int ArnoldiComputeHess(ARNOLDIMem arnoldi_mem) return -1; } + /* Check if the dim of the matrix is less than 3 + Return immediately if dim <= 2 */ + if(arnoldi_mem->length < 3) + { + return 0; + } + int i, j; /* Initialize the Hessenberg matrix Hes with zeros */ for (i = 0; i < arnoldi_mem->maxl; i++) @@ -300,13 +315,14 @@ suncomplextype ArnoldiEstimate(ARNOLDIMem arnoldi_mem) { int n = arnoldi_mem->maxl; /* Create the vector A which holds rows of the Hessenberg matrix in the given order */ - sunrealtype* A = (sunrealtype*)malloc((n*n) * sizeof(sunrealtype)); + sunrealtype* A; + A = (sunrealtype*)malloc((n*n) * sizeof(sunrealtype)); int i, j, k = 0; for (i = 0; i < n; i++) { - for (j = 0; j < n; j++) { - A[k] = arnoldi_mem->Hes[i][j]; - k++; - } + for (j = 0; j < n; j++) { + A[k] = arnoldi_mem->Hes[i][j]; + k++; + } } sunrealtype *wr = malloc(n * sizeof(sunrealtype)); // Real and imaginary parts of eigenvalues @@ -376,9 +392,8 @@ suncomplextype ArnoldiEstimate(ARNOLDIMem arnoldi_mem) { sunbooleantype arnoldi_CheckNVector(N_Vector tmpl) { // TO DO: check required vector operations if ((tmpl->ops->nvclone == NULL) || (tmpl->ops->nvdestroy == NULL) || - (tmpl->ops->nvlinearsum == NULL) || (tmpl->ops->nvconst == NULL) || - (tmpl->ops->nvscale == NULL) || (tmpl->ops->nvwrmsnorm == NULL) || - (tmpl->ops->nvspace == NULL)) + (tmpl->ops->nvdotprod == NULL) || (tmpl->ops->nvscale == NULL) || + (tmpl->ops->nvgetlength == NULL) || (tmpl->ops->nvspace == NULL)) { return SUNFALSE; } From a8f46db9448ee07e310d1158cec7ecd34df71437 Mon Sep 17 00:00:00 2001 From: maggul Date: Wed, 28 May 2025 10:42:02 -0500 Subject: [PATCH 015/128] LAPACK_* arrays --- include/sundials/sundials_arnoldi.h | 18 ++++--- src/arkode/arkode_lsrkstep.c | 2 + src/sundials/sundials_arnoldi.c | 81 +++++++++++++++++------------ 3 files changed, 61 insertions(+), 40 deletions(-) diff --git a/include/sundials/sundials_arnoldi.h b/include/sundials/sundials_arnoldi.h index 4c3a5b7438..dbe5d3368c 100644 --- a/include/sundials/sundials_arnoldi.h +++ b/include/sundials/sundials_arnoldi.h @@ -35,6 +35,12 @@ extern "C" { ARNOLDI module data structure ===============================================================*/ +// Struct to hold the real and imaginary parts +typedef struct { + sunrealtype real; + sunrealtype imag; +} suncomplextype; + /*--------------------------------------------------------------- Types : struct ARNOLDIMemRec, ARNOLDIMem --------------------------------------------------------------- @@ -57,15 +63,15 @@ typedef struct ARNOLDIMemRec sunrealtype powiter_tol; /* Convergence criteria for the power iteration */ int max_powiter; /* Maximum number of power iterations */ + sunrealtype* LAPACK_A; /* The vector which holds rows of the Hessenberg matrix in the given order */ + sunrealtype* LAPACK_wr; /* Real parts of eigenvalues */ + sunrealtype* LAPACK_wi; /* Imaginary parts of eigenvalues */ + sunrealtype* LAPACK_work; /* Workspace array */ + suncomplextype* LAPACK_arr; /* an array to sort eigenvalues*/ + sunrealtype **Hes; /* Hessenberg matrix Hes */ }* ARNOLDIMem; -// Struct to hold the real and imaginary parts -typedef struct { - sunrealtype real; - sunrealtype imag; -} suncomplextype; - /* ------------------------------------- * Exported Functions for ARNOLDI * ------------------------------------- */ diff --git a/src/arkode/arkode_lsrkstep.c b/src/arkode/arkode_lsrkstep.c index 1dba28e823..e864452370 100644 --- a/src/arkode/arkode_lsrkstep.c +++ b/src/arkode/arkode_lsrkstep.c @@ -2306,6 +2306,8 @@ void* lsrkStep_ArnoldiCreate(void* arkode_mem) step_mem->Arnoldi_maxl = ARNOLDI_MAXL_DEFAULT; Arnoldi_mem = ArnoldiCreate(lsrkStep_DQJtimes, arkode_mem, step_mem->Arnoldi_q, step_mem->Arnoldi_maxl, ark_mem->sunctx); + + return (void*)Arnoldi_mem; } /*--------------------------------------------------------------- diff --git a/src/sundials/sundials_arnoldi.c b/src/sundials/sundials_arnoldi.c index 0983805913..cc930312c9 100644 --- a/src/sundials/sundials_arnoldi.c +++ b/src/sundials/sundials_arnoldi.c @@ -92,6 +92,15 @@ void* ArnoldiCreate(SUNATimesFn ATimes, void* Adata, /* Set the default max number of the power iteration */ arnoldi_mem->max_powiter = DEFAULT_MAX_POWER_ITER; + if (arnoldi_mem->length > 2) + { + arnoldi_mem->LAPACK_A = (sunrealtype*)malloc((maxl*maxl) * sizeof(sunrealtype)); + arnoldi_mem->LAPACK_wr = malloc(maxl * sizeof(sunrealtype)); + arnoldi_mem->LAPACK_wi = malloc(maxl * sizeof(sunrealtype)); + arnoldi_mem->LAPACK_work = malloc((4 * maxl) * sizeof(sunrealtype)); + arnoldi_mem->LAPACK_arr = (suncomplextype *)malloc(maxl * sizeof(suncomplextype)); + } + /* Hessenberg matrix Hes */ if (arnoldi_mem->Hes == NULL && arnoldi_mem->length > 2) { @@ -314,31 +323,22 @@ suncomplextype ArnoldiEstimate(ARNOLDIMem arnoldi_mem) { int n = arnoldi_mem->maxl; - /* Create the vector A which holds rows of the Hessenberg matrix in the given order */ - sunrealtype* A; - A = (sunrealtype*)malloc((n*n) * sizeof(sunrealtype)); int i, j, k = 0; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { - A[k] = arnoldi_mem->Hes[i][j]; + arnoldi_mem->LAPACK_A[k] = arnoldi_mem->Hes[i][j]; k++; } } - sunrealtype *wr = malloc(n * sizeof(sunrealtype)); // Real and imaginary parts of eigenvalues - sunrealtype *wi = malloc(n * sizeof(sunrealtype)); - int lda = n, ldvl = n, ldvr = n; int info, lwork = 4 * n; - sunrealtype *work = malloc(lwork * sizeof(sunrealtype)); // Workspace array - - char jobvl = 'N'; // Do not compute left eigenvectors char jobvr = 'N'; // Do not compute right eigenvectors // Call LAPACK's dgeev function - dgeev_(&jobvl, &jobvr, &n, A, &lda, wr, wi, NULL, &ldvl, NULL, &ldvr, work, &lwork, &info); + dgeev_(&jobvl, &jobvr, &n, arnoldi_mem->LAPACK_A, &lda, arnoldi_mem->LAPACK_wr, arnoldi_mem->LAPACK_wi, NULL, &ldvl, NULL, &ldvr, arnoldi_mem->LAPACK_work, &lwork, &info); if (info != 0) { printf(MSG_ARNOLDI_LAPACK_FAIL, info); @@ -348,33 +348,22 @@ suncomplextype ArnoldiEstimate(ARNOLDIMem arnoldi_mem) { } //Following part will order the eigenvalues by their magnitude - { - // Create an array of suncomplextype structs - suncomplextype *arr = (suncomplextype *)malloc(n * sizeof(suncomplextype)); - for (i = 0; i < n; i++) { - arr[i].real = wr[i]; - arr[i].imag = wi[i]; - } - - // Sort the array using qsort - qsort(arr, n, sizeof(suncomplextype), arnoldi_Compare); + for (i = 0; i < n; i++) { + arnoldi_mem->LAPACK_arr[i].real = arnoldi_mem->LAPACK_wr[i]; + arnoldi_mem->LAPACK_arr[i].imag = arnoldi_mem->LAPACK_wi[i]; + } - // Update the original arrays - for (i = 0; i < n; i++) { - wr[i] = arr[i].real; - wi[i] = arr[i].imag; - } + // Sort the array using qsort + qsort(arnoldi_mem->LAPACK_arr, n, sizeof(suncomplextype), arnoldi_Compare); - // Cleanup - free(A); - free(wr); - free(wi); - free(work); - free(arr); + // Update the original arrays + for (i = 0; i < n; i++) { + arnoldi_mem->LAPACK_wr[i] = arnoldi_mem->LAPACK_arr[i].real; + arnoldi_mem->LAPACK_wi[i] = arnoldi_mem->LAPACK_arr[i].imag; } - dom_eig.real = wr[0]; - dom_eig.imag = wi[0]; + dom_eig.real = arnoldi_mem->LAPACK_wr[0]; + dom_eig.imag = arnoldi_mem->LAPACK_wi[0]; return dom_eig; } @@ -437,6 +426,30 @@ void ArnoldiFree(ARNOLDIMem* arnoldi_mem) arn_mem->V = NULL; } + if (arn_mem->LAPACK_A != NULL) + { + free(arn_mem->LAPACK_A); + arn_mem->LAPACK_A = NULL; + } + + if (arn_mem->LAPACK_wr != NULL) + { + free(arn_mem->LAPACK_wr); + arn_mem->LAPACK_wr = NULL; + } + + if (arn_mem->LAPACK_wi != NULL) + { + free(arn_mem->LAPACK_wi); + arn_mem->LAPACK_wi = NULL; + } + + if (arn_mem->LAPACK_arr != NULL) + { + free(arn_mem->LAPACK_arr); + arn_mem->LAPACK_arr = NULL; + } + if (arn_mem->Hes != NULL) { free(arn_mem->Hes); From 0ad47c8acbd217e4903d6fefac23dbe37bce683c Mon Sep 17 00:00:00 2001 From: maggul Date: Wed, 28 May 2025 18:17:11 -0500 Subject: [PATCH 016/128] arnoldi to domeig name change --- include/arkode/arkode.h | 2 +- include/arkode/arkode_lsrkstep.h | 2 +- ..._arnoldi_impl.h => sundials_domeig_impl.h} | 38 +-- .../{sundials_arnoldi.h => sundials_domeig.h} | 38 +-- src/arkode/arkode_impl.h | 4 +- src/arkode/arkode_lsrkstep.c | 58 ++--- src/arkode/arkode_lsrkstep_impl.h | 16 +- src/arkode/arkode_lsrkstep_io.c | 2 +- src/sundials/CMakeLists.txt | 4 +- .../{sundials_arnoldi.c => sundials_domeig.c} | 232 +++++++++--------- test/unit_tests/sundials/CMakeLists.txt | 16 +- .../{test_arnoldi.c => test_domeig.c} | 28 +-- 12 files changed, 220 insertions(+), 220 deletions(-) rename include/sundials/priv/{sundials_arnoldi_impl.h => sundials_domeig_impl.h} (60%) rename include/sundials/{sundials_arnoldi.h => sundials_domeig.h} (76%) rename src/sundials/{sundials_arnoldi.c => sundials_domeig.c} (51%) rename test/unit_tests/sundials/{test_arnoldi.c => test_domeig.c} (92%) diff --git a/include/arkode/arkode.h b/include/arkode/arkode.h index 0a4c96daee..faa6450da1 100644 --- a/include/arkode/arkode.h +++ b/include/arkode/arkode.h @@ -152,7 +152,7 @@ extern "C" { #define ARK_ADJ_RECOMPUTE_FAIL -54 #define ARK_SUNADJSTEPPER_ERR -55 -#define ARK_ARNOLDI_FAIL -56 +#define ARK_INTERNAL_DOMEIG_FAIL -56 #define ARK_UNRECOGNIZED_ERROR -99 diff --git a/include/arkode/arkode_lsrkstep.h b/include/arkode/arkode_lsrkstep.h index ce3b4e59d4..bb879941c4 100644 --- a/include/arkode/arkode_lsrkstep.h +++ b/include/arkode/arkode_lsrkstep.h @@ -18,7 +18,7 @@ #define _LSRKSTEP_H #include -#include +#include #ifdef __cplusplus /* wrapper to enable C++ usage */ extern "C" { diff --git a/include/sundials/priv/sundials_arnoldi_impl.h b/include/sundials/priv/sundials_domeig_impl.h similarity index 60% rename from include/sundials/priv/sundials_arnoldi_impl.h rename to include/sundials/priv/sundials_domeig_impl.h index 3b1a85a932..033e0c171e 100644 --- a/include/sundials/priv/sundials_arnoldi_impl.h +++ b/include/sundials/priv/sundials_domeig_impl.h @@ -12,13 +12,13 @@ * SUNDIALS Copyright End * ----------------------------------------------------------------- * This is the implementation header file for the eigenvalue - * estimation of the SUNARNOLDI package. + * estimation of the DOMEIG module. * -----------------------------------------------------------------*/ -#ifndef _ARNOLDI_IMPL_H -#define _ARNOLDI_IMPL_H +#ifndef _DOMEIG_IMPL_H +#define _DOMEIG_IMPL_H -#include +#include #include #ifdef __cplusplus /* wrapper to enable C++ usage */ @@ -26,12 +26,12 @@ extern "C" { #endif /*=============================================================== - ARNOLDI module private function prototypes + DOMEIG module private function prototypes ===============================================================*/ - sunbooleantype arnoldi_CheckNVector(N_Vector tmpl); - sunrealtype arnoldi_Magnitude(const suncomplextype *c); - int arnoldi_Compare(const void *a, const void *b); + sunbooleantype domeig_CheckNVector(N_Vector tmpl); + sunrealtype domeig_Magnitude(const suncomplextype *c); + int domeig_Compare(const void *a, const void *b); /* * ----------------------------------------------------------------- @@ -44,20 +44,20 @@ extern "C" { int* ldvr, sunrealtype* work, int* lwork, int* info); /*=============================================================== - Reusable ARNOLDI Error Messages + Reusable DOMEIG Error Messages ===============================================================*/ /* Initialization and I/O error messages */ -#define MSG_ARNOLDI_NULL_q "q is null." -#define MSG_ARNOLDI_BAD_NVECTOR "Bad NVector." -#define MSG_ARNOLDI_NULL_ATIMES "ATimes is null." -#define MSG_ARNOLDI_ATIMES_FAIL_REC "Atimes recoverable failure" -#define MSG_ARNOLDI_ATIMES_FAIL_UNREC "Atimes unrecoverable failure" -#define MSG_ARNOLDI_NOT_ENOUGH_ITER "Number of Krylov subspace is not enough (< 2)" -#define MSG_ARNOLDI_NULL_SUNCTX "sunctx is null." -#define MSG_ARNOLDI_MEM_FAIL "ARNOLDI memory fail." -#define MSG_ARNOLDI_GS_FAIL "ARNOLDI Modified GS fail." -#define MSG_ARNOLDI_LAPACK_FAIL "Error: LAPACK dgeev failed with info = %d\n" +#define MSG_DOMEIG_NULL_q "q is null." +#define MSG_DOMEIG_BAD_NVECTOR "Bad NVector." +#define MSG_DOMEIG_NULL_ATIMES "ATimes is null." +#define MSG_DOMEIG_ATIMES_FAIL_REC "Atimes recoverable failure" +#define MSG_DOMEIG_ATIMES_FAIL_UNREC "Atimes unrecoverable failure" +#define MSG_DOMEIG_NOT_ENOUGH_ITER "Number of Krylov subspace is not enough (< 2)" +#define MSG_DOMEIG_NULL_SUNCTX "sunctx is null." +#define MSG_DOMEIG_MEM_FAIL "DOMEIG memory fail." +#define MSG_DOMEIG_GS_FAIL "DOMEIG Modified GS fail." +#define MSG_DOMEIG_LAPACK_FAIL "Error: LAPACK dgeev failed with info = %d\n" #ifdef __cplusplus } diff --git a/include/sundials/sundials_arnoldi.h b/include/sundials/sundials_domeig.h similarity index 76% rename from include/sundials/sundials_arnoldi.h rename to include/sundials/sundials_domeig.h index dbe5d3368c..6e73b9976c 100644 --- a/include/sundials/sundials_arnoldi.h +++ b/include/sundials/sundials_domeig.h @@ -12,11 +12,11 @@ * SUNDIALS Copyright End * ----------------------------------------------------------------- * This is the header file for the eigenvalue estimation of - * the SUNARNOLDI package. + * the SUNDOMEIG package. * -----------------------------------------------------------------*/ -#ifndef _ARNOLDI_H -#define _ARNOLDI_H +#ifndef _DOMEIG_H +#define _DOMEIG_H #include /* serial N_Vector types, fcts., macros */ #include @@ -26,13 +26,13 @@ extern "C" { #endif -/* Default ARNOLDI parameters */ +/* Default DOMEIG parameters */ #define DEFAULT_POWER_OF_A 0 #define DEFAULT_POWER_ITER_TOL SUN_RCONST(0.01) #define DEFAULT_MAX_POWER_ITER 100 /*=============================================================== - ARNOLDI module data structure + DOMEIG module data structure ===============================================================*/ // Struct to hold the real and imaginary parts @@ -42,15 +42,15 @@ typedef struct { } suncomplextype; /*--------------------------------------------------------------- - Types : struct ARNOLDIMemRec, ARNOLDIMem + Types : struct DOMEIGMemRec, DOMEIGMem --------------------------------------------------------------- - The type ARNOLDIMem is type pointer to struct - ARNOLDIMemRec. This structure contains fields to - perform an ARNOLDI iteration. + The type DOMEIGMem is type pointer to struct + DOMEIGMemRec. This structure contains fields to + perform an DOMEIG iteration. ---------------------------------------------------------------*/ -typedef struct ARNOLDIMemRec +typedef struct DOMEIGMemRec { - /* ARNOLDI MEMORY specification */ + /* DOMEIG MEMORY specification */ SUNATimesFn ATimes; /* User provided ATimes function */ void* Adata; /* ATimes function data*/ @@ -70,26 +70,26 @@ typedef struct ARNOLDIMemRec suncomplextype* LAPACK_arr; /* an array to sort eigenvalues*/ sunrealtype **Hes; /* Hessenberg matrix Hes */ -}* ARNOLDIMem; +}* DOMEIGMem; /* ------------------------------------- - * Exported Functions for ARNOLDI + * Exported Functions for DOMEIG * ------------------------------------- */ /* Creation and Estimation functions */ -SUNDIALS_EXPORT void* ArnoldiCreate(SUNATimesFn ATimes, void* AData, +SUNDIALS_EXPORT void* DomEigCreate(SUNATimesFn ATimes, void* AData, N_Vector q, int maxl, SUNContext sunctx); -SUNDIALS_EXPORT int ArnoldiComputeHess(ARNOLDIMem arnoldi_mem); +SUNDIALS_EXPORT int DomEigComputeHess(DOMEIGMem domeig_mem); -SUNDIALS_EXPORT int ArnoldiPreProcess(ARNOLDIMem arnoldi_mem); +SUNDIALS_EXPORT int DomEigPreProcess(DOMEIGMem domeig_mem); -SUNDIALS_EXPORT suncomplextype ArnoldiPowerIteration(ARNOLDIMem arnoldi_mem); +SUNDIALS_EXPORT suncomplextype DomEigPowerIteration(DOMEIGMem domeig_mem); -SUNDIALS_EXPORT suncomplextype ArnoldiEstimate(ARNOLDIMem arnoldi_mem); +SUNDIALS_EXPORT suncomplextype DomEigEstimate(DOMEIGMem domeig_mem); -SUNDIALS_EXPORT void ArnoldiFree(ARNOLDIMem* arnoldi_mem); +SUNDIALS_EXPORT void DomEigFree(DOMEIGMem* domeig_mem); #ifdef __cplusplus } diff --git a/src/arkode/arkode_impl.h b/src/arkode/arkode_impl.h index 36f1805bbf..33d1d3cf03 100644 --- a/src/arkode/arkode_impl.h +++ b/src/arkode/arkode_impl.h @@ -821,8 +821,8 @@ int arkGetLastKFlag(void* arkode_mem, int* last_kflag); "2. To perform ASA w.r.t. parameters, one subvector should be the state " \ "vector, and the other should be the parameter vector." -#define MSG_ARK_ARNOLDI_FAIL \ - "Arnoldi iteration for the dominant eigenvalue estimation failed. " +#define MSG_ARK_INTERNAL_DOMEIG_FAIL \ + "Internal domeig iteration for the dominant eigenvalue estimation failed. " /*=============================================================== diff --git a/src/arkode/arkode_lsrkstep.c b/src/arkode/arkode_lsrkstep.c index e864452370..af312e0372 100644 --- a/src/arkode/arkode_lsrkstep.c +++ b/src/arkode/arkode_lsrkstep.c @@ -191,16 +191,16 @@ void* lsrkStep_Create_Commons(ARKRhsFn rhs, sunrealtype t0, N_Vector y0, /* Copy the input parameters into ARKODE state */ step_mem->fe = rhs; - step_mem->arnoldi_rhs = NULL; + step_mem->domeig_rhs = NULL; /* Set NULL for dom_eig_fn */ step_mem->dom_eig_fn = NULL; - /* Set NULL for arnoldi_mem */ - step_mem->arnoldi_mem = NULL; + /* Set NULL for domeig_mem */ + step_mem->domeig_mem = NULL; - /* Set NULL for Arnoldi_q */ - step_mem->Arnoldi_q = NULL; + /* Set NULL for domeig_q */ + step_mem->domeig_q = NULL; /* Initialize all the counters */ step_mem->nfe = 0; @@ -332,7 +332,7 @@ int lsrkStep_Init(ARKodeMem ark_mem, SUNDIALS_MAYBE_UNUSED sunrealtype tout, } /* Check if user has provided dom_eig_fn */ - if (!step_mem->is_SSP && step_mem->dom_eig_fn == NULL && step_mem->arnoldi_mem == NULL) + if (!step_mem->is_SSP && step_mem->dom_eig_fn == NULL && step_mem->domeig_mem == NULL) { arkProcessError(ark_mem, ARK_DOMEIG_FAIL, __LINE__, __func__, __FILE__, "STS methods require either a user provided or an internal dominant eigenvalue estimation"); @@ -2206,11 +2206,11 @@ int lsrkStep_ComputeNewDomEig(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem) if(step_mem->dom_eig_fn == NULL) { - dom_eig = lsrkStep_ArnoldiEstimate(ark_mem, step_mem->arnoldi_mem); + dom_eig = lsrkStep_DomEigEstimate(ark_mem, step_mem->domeig_mem); if((dom_eig.real*dom_eig.real + dom_eig.imag*dom_eig.imag) < SUN_SMALL_REAL) { arkProcessError(ark_mem, ARK_DOMEIG_FAIL, __LINE__, __func__, __FILE__, - "Unable to estimate the dominant eigenvalue: Arnoldi estimation returned an error"); + "Unable to estimate the dominant eigenvalue: DomEig estimation returned an error"); return ARK_DOMEIG_FAIL; } step_mem->dom_eig_num_evals++; @@ -2272,15 +2272,15 @@ int lsrkStep_ComputeNewDomEig(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem) } /*--------------------------------------------------------------- - lsrkStep_ArnoldiCreate: + lsrkStep_DomEigCreate: - This routine creates the Arnoldi memory and attaches all the relevent + This routine creates the DomEig memory and attaches all the relevent function pointers from arkode_mem. ---------------------------------------------------------------*/ -void* lsrkStep_ArnoldiCreate(void* arkode_mem) +void* lsrkStep_DomEigCreate(void* arkode_mem) { - ARNOLDIMem Arnoldi_mem; + DOMEIGMem domeig_mem; ARKodeMem ark_mem; ARKodeLSRKStepMem step_mem; int retval; @@ -2298,24 +2298,24 @@ void* lsrkStep_ArnoldiCreate(void* arkode_mem) return NULL; } - step_mem->arnoldi_rhs = step_mem->fe; + step_mem->domeig_rhs = step_mem->fe; - /* Allocate and fill Arnoldi_q vector with random data */ - step_mem->Arnoldi_q = N_VClone(ark_mem->yn); - N_VRandom(step_mem->Arnoldi_q); - step_mem->Arnoldi_maxl = ARNOLDI_MAXL_DEFAULT; + /* Allocate and fill domeig_q vector with random data */ + step_mem->domeig_q = N_VClone(ark_mem->yn); + N_VRandom(step_mem->domeig_q); + step_mem->domeig_maxl = DOMEIG_MAXL_DEFAULT; - Arnoldi_mem = ArnoldiCreate(lsrkStep_DQJtimes, arkode_mem, step_mem->Arnoldi_q, step_mem->Arnoldi_maxl, ark_mem->sunctx); + domeig_mem = DomEigCreate(lsrkStep_DQJtimes, arkode_mem, step_mem->domeig_q, step_mem->domeig_maxl, ark_mem->sunctx); - return (void*)Arnoldi_mem; + return (void*)domeig_mem; } /*--------------------------------------------------------------- - lsrkStep_ArnoldiEstimate: + lsrkStep_DomEigEstimate: This routine estimates the dominant eigenvalue. ---------------------------------------------------------------*/ -suncomplextype lsrkStep_ArnoldiEstimate(void* arkode_mem, ARNOLDIMem Arnoldi_mem) +suncomplextype lsrkStep_DomEigEstimate(void* arkode_mem, DOMEIGMem domeig_mem) { ARKodeMem ark_mem; @@ -2333,26 +2333,26 @@ suncomplextype lsrkStep_ArnoldiEstimate(void* arkode_mem, ARNOLDIMem Arnoldi_mem ark_mem = (ARKodeMem)arkode_mem; /* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ - retval = ArnoldiPreProcess(Arnoldi_mem); + retval = DomEigPreProcess(domeig_mem); if (retval != ARK_SUCCESS) { - arkProcessError(ark_mem, ARK_ARNOLDI_FAIL, __LINE__, __func__, __FILE__, - MSG_ARK_ARNOLDI_FAIL); + arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, + MSG_ARK_INTERNAL_DOMEIG_FAIL); return dom_eig; } /* Compute the Hessenberg matrix Hes*/ - retval = ArnoldiComputeHess(Arnoldi_mem); + retval = DomEigComputeHess(domeig_mem); if (retval != ARK_SUCCESS) { - arkProcessError(ark_mem, ARK_ARNOLDI_FAIL, __LINE__, __func__, __FILE__, - MSG_ARK_ARNOLDI_FAIL); + arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, + MSG_ARK_INTERNAL_DOMEIG_FAIL); return dom_eig; } - dom_eig = ArnoldiEstimate(Arnoldi_mem); + dom_eig = DomEigEstimate(domeig_mem); return dom_eig; } @@ -2400,7 +2400,7 @@ int lsrkStep_DQJtimes(void* arkode_mem, N_Vector v, N_Vector Jv) N_VLinearSum(sig, v, ONE, y, work); /* Set Jv = f(tn, y+sig*v) */ - retval = step_mem->arnoldi_rhs(t, work, Jv, ark_mem->user_data); + retval = step_mem->domeig_rhs(t, work, Jv, ark_mem->user_data); step_mem->nfeDQ++; if (retval == 0) { break; } if (retval < 0) { return (-1); } diff --git a/src/arkode/arkode_lsrkstep_impl.h b/src/arkode/arkode_lsrkstep_impl.h index 4f7312450e..c6512956bf 100644 --- a/src/arkode/arkode_lsrkstep_impl.h +++ b/src/arkode/arkode_lsrkstep_impl.h @@ -19,7 +19,7 @@ #define _ARKODE_LSRKSTEP_IMPL_H #include -#include +#include #include "arkode_impl.h" @@ -30,7 +30,7 @@ extern "C" { #define STAGE_MAX_LIMIT_DEFAULT 200 #define DOM_EIG_SAFETY_DEFAULT SUN_RCONST(1.01) #define DOM_EIG_FREQ_DEFAULT 25 -#define ARNOLDI_MAXL_DEFAULT 3 +#define DOMEIG_MAXL_DEFAULT 3 /*=============================================================== LSRK time step module private math function macros @@ -130,7 +130,7 @@ typedef struct ARKodeLSRKStepMemRec { /* LSRK problem specification */ ARKRhsFn fe; - ARKRhsFn arnoldi_rhs; + ARKRhsFn domeig_rhs; ARKDomEigFn dom_eig_fn; int q; /* method order */ @@ -157,9 +157,9 @@ typedef struct ARKodeLSRKStepMemRec sunrealtype spectral_radius_min; /* min spectral radius*/ sunrealtype dom_eig_safety; /* some safety factor for the user provided dom_eig*/ long int dom_eig_freq; /* indicates dom_eig update after dom_eig_freq successful steps*/ - void* arnoldi_mem; /* Arnoldi memory */ - N_Vector Arnoldi_q; /* Arnoldi initial q vector*/ - int Arnoldi_maxl; /* Krylov subspace dimension */ + void* domeig_mem; /* DomEig memory */ + N_Vector domeig_q; /* DomEig initial q vector*/ + int domeig_maxl; /* Krylov subspace dimension */ /* Flags */ sunbooleantype dom_eig_update; /* flag indicating new dom_eig is needed */ @@ -210,8 +210,8 @@ int lsrkStep_AccessStepMem(ARKodeMem ark_mem, const char* fname, void lsrkStep_DomEigUpdateLogic(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem, sunrealtype dsm); int lsrkStep_ComputeNewDomEig(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem); -void* lsrkStep_ArnoldiCreate(void* arkode_mem); -suncomplextype lsrkStep_ArnoldiEstimate(void* arkode_mem, ARNOLDIMem Arnoldi_mem); +void* lsrkStep_DomEigCreate(void* arkode_mem); +suncomplextype lsrkStep_DomEigEstimate(void* arkode_mem, DOMEIGMem DomEig_mem); int lsrkStep_DQJtimes(void* arkode_mem, N_Vector v, N_Vector Jv); /*=============================================================== diff --git a/src/arkode/arkode_lsrkstep_io.c b/src/arkode/arkode_lsrkstep_io.c index 39c62093d8..5fe7476c3e 100644 --- a/src/arkode/arkode_lsrkstep_io.c +++ b/src/arkode/arkode_lsrkstep_io.c @@ -219,7 +219,7 @@ int LSRKStepSetDomEigFn(void* arkode_mem, ARKDomEigFn dom_eig) { step_mem->dom_eig_fn = NULL; - step_mem->arnoldi_mem = lsrkStep_ArnoldiCreate(arkode_mem); + step_mem->domeig_mem = lsrkStep_DomEigCreate(arkode_mem); return ARK_SUCCESS; } diff --git a/src/sundials/CMakeLists.txt b/src/sundials/CMakeLists.txt index 0bc413fbbb..8a57095fc3 100644 --- a/src/sundials/CMakeLists.txt +++ b/src/sundials/CMakeLists.txt @@ -73,7 +73,7 @@ if(ENABLE_SYCL) endif() if(ENABLE_LAPACK) - list(APPEND sundials_HEADERS sundials_arnoldi.h) + list(APPEND sundials_HEADERS sundials_domeig.h) endif() # If enabled, add the XBraid interface header @@ -115,7 +115,7 @@ if(ENABLE_MPI) endif() if(ENABLE_LAPACK) - list(APPEND sundials_SOURCES sundials_arnoldi.c) + list(APPEND sundials_SOURCES sundials_domeig.c) set(_link_lapack_if_needed PUBLIC LAPACK::LAPACK) if(CMAKE_VERSION VERSION_LESS 3.20) list(APPEND _link_lapack_if_needed BLAS::BLAS) diff --git a/src/sundials/sundials_arnoldi.c b/src/sundials/sundials_domeig.c similarity index 51% rename from src/sundials/sundials_arnoldi.c rename to src/sundials/sundials_domeig.c index cc930312c9..94c5562040 100644 --- a/src/sundials/sundials_arnoldi.c +++ b/src/sundials/sundials_domeig.c @@ -12,13 +12,13 @@ * SUNDIALS Copyright End * ----------------------------------------------------------------- * This is the implementation file for the eigenvalue estimation of - * the SUNARNOLDI package. + * the SUNDOMEIG package. * -----------------------------------------------------------------*/ #include #include -#include +#include #define ZERO SUN_RCONST(0.0) @@ -28,15 +28,15 @@ * ----------------------------------------------------------------- */ -void* ArnoldiCreate(SUNATimesFn ATimes, void* Adata, +void* DomEigCreate(SUNATimesFn ATimes, void* Adata, N_Vector q, int maxl, SUNContext sunctx) { - ARNOLDIMem arnoldi_mem; + DOMEIGMem domeig_mem; /* Test if Atimes is provided */ if (ATimes == NULL) { - printf(MSG_ARNOLDI_NULL_ATIMES); + printf(MSG_DOMEIG_NULL_ATIMES); return NULL; } @@ -44,7 +44,7 @@ void* ArnoldiCreate(SUNATimesFn ATimes, void* Adata, /* Test if q is provided */ if (q == NULL) { - printf(MSG_ARNOLDI_NULL_q); + printf(MSG_DOMEIG_NULL_q); return NULL; } @@ -52,7 +52,7 @@ void* ArnoldiCreate(SUNATimesFn ATimes, void* Adata, /* Check if maxl >= 2 */ if (maxl < 2) { - printf(MSG_ARNOLDI_NOT_ENOUGH_ITER); + printf(MSG_DOMEIG_NOT_ENOUGH_ITER); return NULL; } @@ -60,100 +60,100 @@ void* ArnoldiCreate(SUNATimesFn ATimes, void* Adata, /* Test if sunctx is provided */ if (sunctx == NULL) { - printf(MSG_ARNOLDI_NULL_SUNCTX); + printf(MSG_DOMEIG_NULL_SUNCTX); return NULL; } /* Test if all required vector operations are implemented */ - if (!arnoldi_CheckNVector(q)) + if (!domeig_CheckNVector(q)) { - printf(MSG_ARNOLDI_BAD_NVECTOR); + printf(MSG_DOMEIG_BAD_NVECTOR); return NULL; } - /* Allocate ARNOLDIMem structure, and initialize to zero */ - arnoldi_mem = (ARNOLDIMem)calloc(1, sizeof(*arnoldi_mem)); + /* Allocate DOMEIGMem structure, and initialize to zero */ + domeig_mem = (DOMEIGMem)calloc(1, sizeof(*domeig_mem)); - /* Copy the inputs into ARNOLDI memory */ - arnoldi_mem->ATimes = ATimes; - arnoldi_mem->Adata = Adata; - arnoldi_mem->q = q; - arnoldi_mem->maxl = maxl; - arnoldi_mem->length = q->ops->nvgetlength(q); + /* Copy the inputs into DOMEIG memory */ + domeig_mem->ATimes = ATimes; + domeig_mem->Adata = Adata; + domeig_mem->q = q; + domeig_mem->maxl = maxl; + domeig_mem->length = q->ops->nvgetlength(q); /* Set the default power of A to start with (# of warm-ups) */ - arnoldi_mem->power_of_A = DEFAULT_POWER_OF_A; + domeig_mem->power_of_A = DEFAULT_POWER_OF_A; /* Set the default tolerance of the power iteration */ - arnoldi_mem->powiter_tol = DEFAULT_POWER_ITER_TOL; + domeig_mem->powiter_tol = DEFAULT_POWER_ITER_TOL; /* Set the default max number of the power iteration */ - arnoldi_mem->max_powiter = DEFAULT_MAX_POWER_ITER; + domeig_mem->max_powiter = DEFAULT_MAX_POWER_ITER; - if (arnoldi_mem->length > 2) + if (domeig_mem->length > 2) { - arnoldi_mem->LAPACK_A = (sunrealtype*)malloc((maxl*maxl) * sizeof(sunrealtype)); - arnoldi_mem->LAPACK_wr = malloc(maxl * sizeof(sunrealtype)); - arnoldi_mem->LAPACK_wi = malloc(maxl * sizeof(sunrealtype)); - arnoldi_mem->LAPACK_work = malloc((4 * maxl) * sizeof(sunrealtype)); - arnoldi_mem->LAPACK_arr = (suncomplextype *)malloc(maxl * sizeof(suncomplextype)); + domeig_mem->LAPACK_A = (sunrealtype*)malloc((maxl*maxl) * sizeof(sunrealtype)); + domeig_mem->LAPACK_wr = malloc(maxl * sizeof(sunrealtype)); + domeig_mem->LAPACK_wi = malloc(maxl * sizeof(sunrealtype)); + domeig_mem->LAPACK_work = malloc((4 * maxl) * sizeof(sunrealtype)); + domeig_mem->LAPACK_arr = (suncomplextype *)malloc(maxl * sizeof(suncomplextype)); } /* Hessenberg matrix Hes */ - if (arnoldi_mem->Hes == NULL && arnoldi_mem->length > 2) + if (domeig_mem->Hes == NULL && domeig_mem->length > 2) { int k; - arnoldi_mem->Hes = + domeig_mem->Hes = (sunrealtype**)malloc((maxl + 1) * sizeof(sunrealtype*)); for (k = 0; k <= maxl; k++) { - arnoldi_mem->Hes[k] = NULL; - arnoldi_mem->Hes[k] = (sunrealtype*)malloc(maxl * sizeof(sunrealtype)); + domeig_mem->Hes[k] = NULL; + domeig_mem->Hes[k] = (sunrealtype*)malloc(maxl * sizeof(sunrealtype)); } } /* Krylov subspace vectors */ - if (arnoldi_mem->V == NULL) + if (domeig_mem->V == NULL) { - if(arnoldi_mem->length > 2) + if(domeig_mem->length > 2) { - arnoldi_mem->V = N_VCloneVectorArray(maxl + 1, q); + domeig_mem->V = N_VCloneVectorArray(maxl + 1, q); } else { - arnoldi_mem->V = N_VCloneVectorArray(1, q); + domeig_mem->V = N_VCloneVectorArray(1, q); } } /* Unitize the initial vector V[0] */ sunrealtype normq = N_VDotProd(q, q); normq = SUNRsqrt(normq); - N_VScale(SUN_RCONST(1.0)/normq, arnoldi_mem->q, arnoldi_mem->V[0]); + N_VScale(SUN_RCONST(1.0)/normq, domeig_mem->q, domeig_mem->V[0]); - return (void*)arnoldi_mem; + return (void*)domeig_mem; } /* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ -int ArnoldiPreProcess(ARNOLDIMem arnoldi_mem) +int DomEigPreProcess(DOMEIGMem domeig_mem) { int retval; - /* Check if Arnoldi memory is allocated */ - if(arnoldi_mem == NULL) + /* Check if DomEig memory is allocated */ + if(domeig_mem == NULL) { - printf(MSG_ARNOLDI_MEM_FAIL); + printf(MSG_DOMEIG_MEM_FAIL); return -1; } /* Check if ATimes is provided */ - if(arnoldi_mem->ATimes == NULL) + if(domeig_mem->ATimes == NULL) { - printf(MSG_ARNOLDI_NULL_ATIMES); - ArnoldiFree(&arnoldi_mem); + printf(MSG_DOMEIG_NULL_ATIMES); + DomEigFree(&domeig_mem); return -1; } @@ -162,82 +162,82 @@ int ArnoldiPreProcess(ARNOLDIMem arnoldi_mem) int i; /* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ - for(i = 0; i < arnoldi_mem->power_of_A; i++) { - retval = arnoldi_mem->ATimes(arnoldi_mem->Adata, arnoldi_mem->V[0], arnoldi_mem->q); + for(i = 0; i < domeig_mem->power_of_A; i++) { + retval = domeig_mem->ATimes(domeig_mem->Adata, domeig_mem->V[0], domeig_mem->q); if (retval != 0) { (retval < 0) ? - printf(MSG_ARNOLDI_ATIMES_FAIL_UNREC) : - printf(MSG_ARNOLDI_ATIMES_FAIL_REC); - ArnoldiFree(&arnoldi_mem); + printf(MSG_DOMEIG_ATIMES_FAIL_UNREC) : + printf(MSG_DOMEIG_ATIMES_FAIL_REC); + DomEigFree(&domeig_mem); return retval; } - normq = N_VDotProd(arnoldi_mem->q, arnoldi_mem->q); + normq = N_VDotProd(domeig_mem->q, domeig_mem->q); normq = SUNRsqrt(normq); - N_VScale(SUN_RCONST(1.0)/normq, arnoldi_mem->q, arnoldi_mem->V[0]); + N_VScale(SUN_RCONST(1.0)/normq, domeig_mem->q, domeig_mem->V[0]); } return 0; } -/* Compute the Hessenberg matrix Arnoldi_mem->Hes*/ -int ArnoldiComputeHess(ARNOLDIMem arnoldi_mem) +/* Compute the Hessenberg matrix DomEig_mem->Hes*/ +int DomEigComputeHess(DOMEIGMem domeig_mem) { int retval; - /* Check if Arnoldi memory is allocated */ - if(arnoldi_mem == NULL) + /* Check if DomEig memory is allocated */ + if(domeig_mem == NULL) { - printf(MSG_ARNOLDI_MEM_FAIL); + printf(MSG_DOMEIG_MEM_FAIL); return -1; } /* Check if the dim of the matrix is less than 3 Return immediately if dim <= 2 */ - if(arnoldi_mem->length < 3) + if(domeig_mem->length < 3) { return 0; } int i, j; /* Initialize the Hessenberg matrix Hes with zeros */ - for (i = 0; i < arnoldi_mem->maxl; i++) + for (i = 0; i < domeig_mem->maxl; i++) { - for (j = 0; j < arnoldi_mem->maxl; j++) { arnoldi_mem->Hes[i][j] = ZERO; } + for (j = 0; j < domeig_mem->maxl; j++) { domeig_mem->Hes[i][j] = ZERO; } } - for (i = 0; i < arnoldi_mem->maxl; i++) + for (i = 0; i < domeig_mem->maxl; i++) { /* Compute the next Krylov vector */ - retval = arnoldi_mem->ATimes(arnoldi_mem->Adata, arnoldi_mem->V[i], arnoldi_mem->V[i+1]); + retval = domeig_mem->ATimes(domeig_mem->Adata, domeig_mem->V[i], domeig_mem->V[i+1]); if (retval != 0) { (retval < 0) ? - printf(MSG_ARNOLDI_ATIMES_FAIL_UNREC) : - printf(MSG_ARNOLDI_ATIMES_FAIL_REC); - ArnoldiFree(&arnoldi_mem); + printf(MSG_DOMEIG_ATIMES_FAIL_UNREC) : + printf(MSG_DOMEIG_ATIMES_FAIL_REC); + DomEigFree(&domeig_mem); return retval; } - if(SUNModifiedGS(arnoldi_mem->V, arnoldi_mem->Hes, i + 1, arnoldi_mem->maxl, &(arnoldi_mem->Hes[i + 1][i])) != SUN_SUCCESS) + if(SUNModifiedGS(domeig_mem->V, domeig_mem->Hes, i + 1, domeig_mem->maxl, &(domeig_mem->Hes[i + 1][i])) != SUN_SUCCESS) { - printf(MSG_ARNOLDI_GS_FAIL); - ArnoldiFree(&arnoldi_mem); + printf(MSG_DOMEIG_GS_FAIL); + DomEigFree(&domeig_mem); return -1; } /* Unitize the computed orthogonal vector */ - N_VScale(SUN_RCONST(1.0)/arnoldi_mem->Hes[i + 1][i], arnoldi_mem->V[i+1], arnoldi_mem->V[i+1]); + N_VScale(SUN_RCONST(1.0)/domeig_mem->Hes[i + 1][i], domeig_mem->V[i+1], domeig_mem->V[i+1]); } return 0; } -suncomplextype ArnoldiPowerIteration(ARNOLDIMem arnoldi_mem) +suncomplextype DomEigPowerIteration(DOMEIGMem domeig_mem) { int retval; @@ -247,19 +247,19 @@ suncomplextype ArnoldiPowerIteration(ARNOLDIMem arnoldi_mem) dom_eig_old.real = ZERO; dom_eig_old.imag = ZERO; - /* Check if Arnoldi memory is allocated */ - if(arnoldi_mem == NULL) + /* Check if DomEig memory is allocated */ + if(domeig_mem == NULL) { - printf(MSG_ARNOLDI_MEM_FAIL); + printf(MSG_DOMEIG_MEM_FAIL); return dom_eig; } /* Check if ATimes is provided */ - if(arnoldi_mem->ATimes == NULL) + if(domeig_mem->ATimes == NULL) { - printf(MSG_ARNOLDI_NULL_ATIMES); - ArnoldiFree(&arnoldi_mem); + printf(MSG_DOMEIG_NULL_ATIMES); + DomEigFree(&domeig_mem); return dom_eig; } @@ -267,15 +267,15 @@ suncomplextype ArnoldiPowerIteration(ARNOLDIMem arnoldi_mem) int k; sunrealtype normq; - for (k = 0; k < arnoldi_mem->max_powiter; k++) + for (k = 0; k < domeig_mem->max_powiter; k++) { - retval = arnoldi_mem->ATimes(arnoldi_mem->Adata, arnoldi_mem->V[0], arnoldi_mem->q); + retval = domeig_mem->ATimes(domeig_mem->Adata, domeig_mem->V[0], domeig_mem->q); if (retval != 0) { (retval < 0) ? - printf(MSG_ARNOLDI_ATIMES_FAIL_UNREC) : - printf(MSG_ARNOLDI_ATIMES_FAIL_REC); - ArnoldiFree(&arnoldi_mem); + printf(MSG_DOMEIG_ATIMES_FAIL_UNREC) : + printf(MSG_DOMEIG_ATIMES_FAIL_REC); + DomEigFree(&domeig_mem); dom_eig.real = ZERO; dom_eig.imag = ZERO; @@ -283,16 +283,16 @@ suncomplextype ArnoldiPowerIteration(ARNOLDIMem arnoldi_mem) return dom_eig; } - dom_eig.real = N_VDotProd(arnoldi_mem->V[0], arnoldi_mem->q); //Rayleigh quotient + dom_eig.real = N_VDotProd(domeig_mem->V[0], domeig_mem->q); //Rayleigh quotient - if(fabs(dom_eig.real - dom_eig_old.real) < arnoldi_mem->powiter_tol) + if(fabs(dom_eig.real - dom_eig_old.real) < domeig_mem->powiter_tol) { break; } - normq = N_VDotProd(arnoldi_mem->q, arnoldi_mem->q); + normq = N_VDotProd(domeig_mem->q, domeig_mem->q); normq = SUNRsqrt(normq); - N_VScale(SUN_RCONST(1.0)/normq, arnoldi_mem->q, arnoldi_mem->V[0]); + N_VScale(SUN_RCONST(1.0)/normq, domeig_mem->q, domeig_mem->V[0]); dom_eig_old.real = dom_eig.real; } @@ -301,32 +301,32 @@ suncomplextype ArnoldiPowerIteration(ARNOLDIMem arnoldi_mem) } /* Estimate the dominant eigvalues of the Hessenberg matrix */ -suncomplextype ArnoldiEstimate(ARNOLDIMem arnoldi_mem) { +suncomplextype DomEigEstimate(DOMEIGMem domeig_mem) { suncomplextype dom_eig; dom_eig.real = ZERO; dom_eig.imag = ZERO; - /* Check if Arnoldi memory is allocated */ - if(arnoldi_mem == NULL) + /* Check if DomEig memory is allocated */ + if(domeig_mem == NULL) { - printf(MSG_ARNOLDI_MEM_FAIL); + printf(MSG_DOMEIG_MEM_FAIL); return dom_eig; } - if(arnoldi_mem->length < 3) + if(domeig_mem->length < 3) { - dom_eig = ArnoldiPowerIteration(arnoldi_mem); + dom_eig = DomEigPowerIteration(domeig_mem); return dom_eig; } - int n = arnoldi_mem->maxl; + int n = domeig_mem->maxl; int i, j, k = 0; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { - arnoldi_mem->LAPACK_A[k] = arnoldi_mem->Hes[i][j]; + domeig_mem->LAPACK_A[k] = domeig_mem->Hes[i][j]; k++; } } @@ -338,32 +338,32 @@ suncomplextype ArnoldiEstimate(ARNOLDIMem arnoldi_mem) { char jobvr = 'N'; // Do not compute right eigenvectors // Call LAPACK's dgeev function - dgeev_(&jobvl, &jobvr, &n, arnoldi_mem->LAPACK_A, &lda, arnoldi_mem->LAPACK_wr, arnoldi_mem->LAPACK_wi, NULL, &ldvl, NULL, &ldvr, arnoldi_mem->LAPACK_work, &lwork, &info); + dgeev_(&jobvl, &jobvr, &n, domeig_mem->LAPACK_A, &lda, domeig_mem->LAPACK_wr, domeig_mem->LAPACK_wi, NULL, &ldvl, NULL, &ldvr, domeig_mem->LAPACK_work, &lwork, &info); if (info != 0) { - printf(MSG_ARNOLDI_LAPACK_FAIL, info); - ArnoldiFree(&arnoldi_mem); + printf(MSG_DOMEIG_LAPACK_FAIL, info); + DomEigFree(&domeig_mem); return dom_eig; } //Following part will order the eigenvalues by their magnitude for (i = 0; i < n; i++) { - arnoldi_mem->LAPACK_arr[i].real = arnoldi_mem->LAPACK_wr[i]; - arnoldi_mem->LAPACK_arr[i].imag = arnoldi_mem->LAPACK_wi[i]; + domeig_mem->LAPACK_arr[i].real = domeig_mem->LAPACK_wr[i]; + domeig_mem->LAPACK_arr[i].imag = domeig_mem->LAPACK_wi[i]; } // Sort the array using qsort - qsort(arnoldi_mem->LAPACK_arr, n, sizeof(suncomplextype), arnoldi_Compare); + qsort(domeig_mem->LAPACK_arr, n, sizeof(suncomplextype), domeig_Compare); // Update the original arrays for (i = 0; i < n; i++) { - arnoldi_mem->LAPACK_wr[i] = arnoldi_mem->LAPACK_arr[i].real; - arnoldi_mem->LAPACK_wi[i] = arnoldi_mem->LAPACK_arr[i].imag; + domeig_mem->LAPACK_wr[i] = domeig_mem->LAPACK_arr[i].real; + domeig_mem->LAPACK_wi[i] = domeig_mem->LAPACK_arr[i].imag; } - dom_eig.real = arnoldi_mem->LAPACK_wr[0]; - dom_eig.imag = arnoldi_mem->LAPACK_wi[0]; + dom_eig.real = domeig_mem->LAPACK_wr[0]; + dom_eig.imag = domeig_mem->LAPACK_wi[0]; return dom_eig; } @@ -373,12 +373,12 @@ suncomplextype ArnoldiEstimate(ARNOLDIMem arnoldi_mem) { ===============================================================*/ /*--------------------------------------------------------------- - arnoldi_CheckNVector: + domeig_CheckNVector: This routine checks if all required vector operations are present. If any of them is missing it returns SUNFALSE. ---------------------------------------------------------------*/ -sunbooleantype arnoldi_CheckNVector(N_Vector tmpl) +sunbooleantype domeig_CheckNVector(N_Vector tmpl) { // TO DO: check required vector operations if ((tmpl->ops->nvclone == NULL) || (tmpl->ops->nvdestroy == NULL) || (tmpl->ops->nvdotprod == NULL) || (tmpl->ops->nvscale == NULL) || @@ -390,30 +390,30 @@ sunbooleantype arnoldi_CheckNVector(N_Vector tmpl) } // Function to calculate the magnitude of a suncomplextype number -sunrealtype arnoldi_Magnitude(const suncomplextype *c) { +sunrealtype domeig_Magnitude(const suncomplextype *c) { return sqrt(c->real * c->real + c->imag * c->imag); } // Comparison function for qsort -int arnoldi_Compare(const void *a, const void *b) { +int domeig_Compare(const void *a, const void *b) { const suncomplextype *c1 = (const suncomplextype *)a; const suncomplextype *c2 = (const suncomplextype *)b; - sunrealtype mag1 = arnoldi_Magnitude(c1); - sunrealtype mag2 = arnoldi_Magnitude(c2); + sunrealtype mag1 = domeig_Magnitude(c1); + sunrealtype mag2 = domeig_Magnitude(c2); return (mag2 > mag1) - (mag2 < mag1); // Descending order } /*--------------------------------------------------------------- - ArnoldiFree frees all Arnoldi memory. + DomEigFree frees all DomEig memory. ---------------------------------------------------------------*/ -void ArnoldiFree(ARNOLDIMem* arnoldi_mem) +void DomEigFree(DOMEIGMem* domeig_mem) { - ARNOLDIMem arn_mem; + DOMEIGMem arn_mem; - /* nothing to do if arnoldi_mem is already NULL */ - if (arnoldi_mem == NULL) { return; } + /* nothing to do if domeig_mem is already NULL */ + if (domeig_mem == NULL) { return; } - arn_mem = (ARNOLDIMem)(*arnoldi_mem); + arn_mem = (DOMEIGMem)(*domeig_mem); if (arn_mem->q != NULL) { @@ -456,6 +456,6 @@ void ArnoldiFree(ARNOLDIMem* arnoldi_mem) arn_mem->Hes = NULL; } - free(*arnoldi_mem); - *arnoldi_mem = NULL; + free(*domeig_mem); + *domeig_mem = NULL; } \ No newline at end of file diff --git a/test/unit_tests/sundials/CMakeLists.txt b/test/unit_tests/sundials/CMakeLists.txt index bcd5bf0c59..d4261b4bf1 100644 --- a/test/unit_tests/sundials/CMakeLists.txt +++ b/test/unit_tests/sundials/CMakeLists.txt @@ -36,12 +36,12 @@ if(TARGET GTest::gtest_main AND TARGET GTest::gmock) endif() -# Tests for the arnoldi utility routine (estimates dominant eigenvalue; depends on LAPACK) +# Tests for the domeig utility routine (estimates dominant eigenvalue; depends on LAPACK) if(ENABLE_LAPACK) set(unit_tests_lapack - "test_arnoldi\;100 10\;" - "test_arnoldi\;1000 20\;" - "test_arnoldi\;10000 50\;") + "test_domeig\;100 10\;" + "test_domeig\;1000 20\;" + "test_domeig\;10000 50\;") # Add the build and install targets for each test foreach(test_tuple ${unit_tests_lapack}) @@ -65,11 +65,11 @@ if(ENABLE_LAPACK) ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/src) # libraries to link against - set(_arnoldi_libs sundials_core sundials_nvecserial LAPACK::LAPACK) + set(_domeig_libs sundials_core sundials_nvecserial LAPACK::LAPACK) if(CMAKE_VERSION VERSION_LESS 3.20) - list(APPEND _arnoldi_libs BLAS::BLAS) + list(APPEND _domeig_libs BLAS::BLAS) endif() - target_link_libraries(${test} ${_arnoldi_libs} + target_link_libraries(${test} ${_domeig_libs} ${EXE_EXTRA_LINK_LIBS}) endif() @@ -87,5 +87,5 @@ if(ENABLE_LAPACK) endforeach() - message(STATUS "Added arnoldi units tests") + message(STATUS "Added domeig units tests") endif() diff --git a/test/unit_tests/sundials/test_arnoldi.c b/test/unit_tests/sundials/test_domeig.c similarity index 92% rename from test/unit_tests/sundials/test_arnoldi.c rename to test/unit_tests/sundials/test_domeig.c index 535230b4f6..9cbb6ed398 100644 --- a/test/unit_tests/sundials/test_arnoldi.c +++ b/test/unit_tests/sundials/test_domeig.c @@ -11,7 +11,7 @@ * SPDX-License-Identifier: BSD-3-Clause * SUNDIALS Copyright End * ----------------------------------------------------------------- - * These test functions check some components of an Arnoldi iteration + * These test functions check some components of an DomEig iteration * module implementation. * ----------------------------------------------------------------- */ @@ -20,7 +20,7 @@ #include #include /* def. of SUNRsqrt, etc. */ #include /* definition of type sunrealtype */ -#include +#include #if defined(SUNDIALS_EXTENDED_PRECISION) @@ -62,7 +62,7 @@ sunindextype problem_size; /* ---------------------------------------------------------------------- - * Arnoldi Iteration Testing Routine + * DomEig Module Testing Routine * --------------------------------------------------------------------*/ int main(int argc, char* argv[]) { @@ -103,7 +103,7 @@ int main(int argc, char* argv[]) return 1; } - printf("\nArnoldi iteration test:\n"); + printf("\nDomEig module test:\n"); printf(" Problem size = %ld\n", (long int)ProbData.N); printf(" Krylov subspace dimension = %i\n", maxl); @@ -130,29 +130,29 @@ int main(int argc, char* argv[]) ProbData.real_part = realpart; ProbData.imag_part = imagpart; - /* Create ARNOLDI memory structure */ - ARNOLDIMem Arnoldi_mem; - Arnoldi_mem = ArnoldiCreate(ATimes, &ProbData, q, maxl,sunctx); + /* Create DOMEIG memory structure */ + DOMEIGMem DomEig_mem; + DomEig_mem = DomEigCreate(ATimes, &ProbData, q, maxl,sunctx); /* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ - ArnoldiPreProcess(Arnoldi_mem); + DomEigPreProcess(DomEig_mem); /* Compute the Hessenberg matrix Hes*/ - ArnoldiComputeHess(Arnoldi_mem); + DomEigComputeHess(DomEig_mem); /* Print the Hessenberg matrix Hes if N <= 10*/ if(ProbData.N <= 10){ printf("\n"); printf("Hes:\n"); - for (i = 0; i < Arnoldi_mem->maxl + 1; i++) { - for (j = 0; j < Arnoldi_mem->maxl; j++) { - printf("%20.2lf ", Arnoldi_mem->Hes[i][j]); + for (i = 0; i < DomEig_mem->maxl + 1; i++) { + for (j = 0; j < DomEig_mem->maxl; j++) { + printf("%20.2lf ", DomEig_mem->Hes[i][j]); } printf("\n"); } } - suncomplextype dom_eig = ArnoldiEstimate(Arnoldi_mem); + suncomplextype dom_eig = DomEigEstimate(DomEig_mem); sunrealtype norm_of_dom_eig = SUNRsqrt(dom_eig.real * dom_eig.real + dom_eig.imag * dom_eig.imag); if(norm_of_dom_eig < SUN_SMALL_REAL) { printf("FAIL: Dominant Eigenvalue Test Failed"); @@ -194,7 +194,7 @@ int main(int argc, char* argv[]) N_VDestroy(q); N_VDestroy(ProbData.d); SUNContext_Free(&sunctx); - ArnoldiFree(&Arnoldi_mem); + DomEigFree(&DomEig_mem); return (passfail); } From 0bc088b80f31dc7048fe40b7eaa2c41d44fb94ce Mon Sep 17 00:00:00 2001 From: maggul Date: Tue, 3 Jun 2025 02:39:08 -0500 Subject: [PATCH 017/128] updated functions for SUNErrCode returns --- include/sundials/priv/sundials_domeig_impl.h | 11 +- include/sundials/sundials_domeig.h | 18 +- include/sundials/sundials_errors.h | 10 + src/arkode/arkode_lsrkstep.c | 26 +- src/sundials/sundials_domeig.c | 314 ++++++++++--------- test/unit_tests/sundials/test_domeig.c | 30 +- 6 files changed, 226 insertions(+), 183 deletions(-) diff --git a/include/sundials/priv/sundials_domeig_impl.h b/include/sundials/priv/sundials_domeig_impl.h index 033e0c171e..c803b888c8 100644 --- a/include/sundials/priv/sundials_domeig_impl.h +++ b/include/sundials/priv/sundials_domeig_impl.h @@ -29,7 +29,7 @@ extern "C" { DOMEIG module private function prototypes ===============================================================*/ - sunbooleantype domeig_CheckNVector(N_Vector tmpl); + SUNErrCode domeig_CheckNVector(N_Vector tmpl); sunrealtype domeig_Magnitude(const suncomplextype *c); int domeig_Compare(const void *a, const void *b); @@ -48,15 +48,6 @@ extern "C" { ===============================================================*/ /* Initialization and I/O error messages */ -#define MSG_DOMEIG_NULL_q "q is null." -#define MSG_DOMEIG_BAD_NVECTOR "Bad NVector." -#define MSG_DOMEIG_NULL_ATIMES "ATimes is null." -#define MSG_DOMEIG_ATIMES_FAIL_REC "Atimes recoverable failure" -#define MSG_DOMEIG_ATIMES_FAIL_UNREC "Atimes unrecoverable failure" -#define MSG_DOMEIG_NOT_ENOUGH_ITER "Number of Krylov subspace is not enough (< 2)" -#define MSG_DOMEIG_NULL_SUNCTX "sunctx is null." -#define MSG_DOMEIG_MEM_FAIL "DOMEIG memory fail." -#define MSG_DOMEIG_GS_FAIL "DOMEIG Modified GS fail." #define MSG_DOMEIG_LAPACK_FAIL "Error: LAPACK dgeev failed with info = %d\n" #ifdef __cplusplus diff --git a/include/sundials/sundials_domeig.h b/include/sundials/sundials_domeig.h index 6e73b9976c..dc6120942c 100644 --- a/include/sundials/sundials_domeig.h +++ b/include/sundials/sundials_domeig.h @@ -19,7 +19,9 @@ #define _DOMEIG_H #include /* serial N_Vector types, fcts., macros */ +#include #include +#include "sundials/sundials_errors.h" #include #ifdef __cplusplus /* wrapper to enable C++ usage */ @@ -50,6 +52,8 @@ typedef struct { ---------------------------------------------------------------*/ typedef struct DOMEIGMemRec { + SUNContext sunctx; + /* DOMEIG MEMORY specification */ SUNATimesFn ATimes; /* User provided ATimes function */ void* Adata; /* ATimes function data*/ @@ -78,18 +82,18 @@ typedef struct DOMEIGMemRec /* Creation and Estimation functions */ -SUNDIALS_EXPORT void* DomEigCreate(SUNATimesFn ATimes, void* AData, - N_Vector q, int maxl, SUNContext sunctx); +SUNDIALS_EXPORT SUNErrCode DomEigCreate(SUNATimesFn ATimes, void* Adata, + N_Vector q, int maxl, SUNContext sunctx, void** domeig_mem_out); -SUNDIALS_EXPORT int DomEigComputeHess(DOMEIGMem domeig_mem); +SUNDIALS_EXPORT SUNErrCode DomEigPreProcess(DOMEIGMem domeig_mem, SUNContext sunctx); -SUNDIALS_EXPORT int DomEigPreProcess(DOMEIGMem domeig_mem); +SUNDIALS_EXPORT SUNErrCode DomEigComputeHess(DOMEIGMem domeig_mem, SUNContext sunctx); -SUNDIALS_EXPORT suncomplextype DomEigPowerIteration(DOMEIGMem domeig_mem); +SUNDIALS_EXPORT SUNErrCode DomEigPowerIteration(DOMEIGMem domeig_mem, suncomplextype* dom_eig, SUNContext sunctx); -SUNDIALS_EXPORT suncomplextype DomEigEstimate(DOMEIGMem domeig_mem); +SUNDIALS_EXPORT SUNErrCode DomEigEstimate(DOMEIGMem domeig_mem, suncomplextype* dom_eig, SUNContext sunctx); -SUNDIALS_EXPORT void DomEigFree(DOMEIGMem* domeig_mem); +SUNDIALS_EXPORT void DomEigDestroy(void** domeig_mem); #ifdef __cplusplus } diff --git a/include/sundials/sundials_errors.h b/include/sundials/sundials_errors.h index 55293a288f..bed33aa8cd 100644 --- a/include/sundials/sundials_errors.h +++ b/include/sundials/sundials_errors.h @@ -70,6 +70,16 @@ ENTRY(SUN_ERR_CHECKPOINT_MISMATCH, "the expected time for the checkpoint " \ "and the stored time do not match") \ \ + ENTRY(SUN_ERR_DOMEIG_BAD_NVECTOR, "Bad NVector") \ + ENTRY(SUN_ERR_DOMEIG_NULL_ATIMES, "ATimes is null") \ + ENTRY(SUN_ERR_DOMEIG_NULL_HES, "Hessenberg matrix is null") \ + ENTRY(SUN_ERR_DOMEIG_MEM_FAIL, "DOMEIG memory fail") \ + ENTRY(SUN_ERR_DOMEIG_NOT_ENOUGH_ITER, "Number of Krylov subspace is not " \ + "enough (< 2)") \ + ENTRY(SUN_ERR_DOMEIG_ATIMES_FAIL_REC, "Atimes recoverable failure") \ + ENTRY(SUN_ERR_DOMEIG_ATIMES_FAIL_UNREC, "Atimes unrecoverable failure") \ + ENTRY(SUN_ERR_DOMEIG_LAPACK_FAIL, "LAPACK dgeev function failure") \ + \ ENTRY(SUN_ERR_SUNCTX_CORRUPT, "SUNContext is NULL or corrupt") \ \ ENTRY(SUN_ERR_MPI_FAIL, \ diff --git a/src/arkode/arkode_lsrkstep.c b/src/arkode/arkode_lsrkstep.c index af312e0372..085fb64e97 100644 --- a/src/arkode/arkode_lsrkstep.c +++ b/src/arkode/arkode_lsrkstep.c @@ -2305,7 +2305,8 @@ void* lsrkStep_DomEigCreate(void* arkode_mem) N_VRandom(step_mem->domeig_q); step_mem->domeig_maxl = DOMEIG_MAXL_DEFAULT; - domeig_mem = DomEigCreate(lsrkStep_DQJtimes, arkode_mem, step_mem->domeig_q, step_mem->domeig_maxl, ark_mem->sunctx); + retval = DomEigCreate(lsrkStep_DQJtimes, arkode_mem, step_mem->domeig_q, step_mem->domeig_maxl, ark_mem->sunctx, (void**)&domeig_mem); + if (retval != ARK_SUCCESS) { return NULL; } return (void*)domeig_mem; } @@ -2332,8 +2333,15 @@ suncomplextype lsrkStep_DomEigEstimate(void* arkode_mem, DOMEIGMem domeig_mem) } ark_mem = (ARKodeMem)arkode_mem; + if (ark_mem->sunctx == NULL) + { + arkProcessError(NULL, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + MSG_ARK_NULL_SUNCTX); + return dom_eig; + } + /* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ - retval = DomEigPreProcess(domeig_mem); + retval = DomEigPreProcess(domeig_mem, ark_mem->sunctx); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, @@ -2343,7 +2351,7 @@ suncomplextype lsrkStep_DomEigEstimate(void* arkode_mem, DOMEIGMem domeig_mem) } /* Compute the Hessenberg matrix Hes*/ - retval = DomEigComputeHess(domeig_mem); + retval = DomEigComputeHess(domeig_mem, ark_mem->sunctx); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, @@ -2352,7 +2360,17 @@ suncomplextype lsrkStep_DomEigEstimate(void* arkode_mem, DOMEIGMem domeig_mem) return dom_eig; } - dom_eig = DomEigEstimate(domeig_mem); + retval = DomEigEstimate(domeig_mem, &dom_eig, ark_mem->sunctx); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, + MSG_ARK_INTERNAL_DOMEIG_FAIL); + + dom_eig.real = ZERO; + dom_eig.imag = ZERO; + + return dom_eig; + } return dom_eig; } diff --git a/src/sundials/sundials_domeig.c b/src/sundials/sundials_domeig.c index 94c5562040..d70be8dc6d 100644 --- a/src/sundials/sundials_domeig.c +++ b/src/sundials/sundials_domeig.c @@ -19,6 +19,8 @@ #include #include +#include +#include #define ZERO SUN_RCONST(0.0) @@ -28,55 +30,39 @@ * ----------------------------------------------------------------- */ -void* DomEigCreate(SUNATimesFn ATimes, void* Adata, - N_Vector q, int maxl, SUNContext sunctx) +SUNErrCode DomEigCreate(SUNATimesFn ATimes, void* Adata, + N_Vector q, int maxl, SUNContext sunctx, void** domeig_mem_out) { + SUNFunctionBegin(sunctx); // is this correct? DOMEIGMem domeig_mem; - /* Test if Atimes is provided */ - if (ATimes == NULL) + /* Test if Atimes and q are provided */ + if (ATimes == NULL || q == NULL) { - printf(MSG_DOMEIG_NULL_ATIMES); - - return NULL; - } - - /* Test if q is provided */ - if (q == NULL) - { - printf(MSG_DOMEIG_NULL_q); - - return NULL; + return SUN_ERR_DOMEIG_NULL_ATIMES; } /* Check if maxl >= 2 */ if (maxl < 2) { - printf(MSG_DOMEIG_NOT_ENOUGH_ITER); - - return NULL; + return SUN_ERR_DOMEIG_NOT_ENOUGH_ITER; } /* Test if sunctx is provided */ if (sunctx == NULL) { - printf(MSG_DOMEIG_NULL_SUNCTX); - - return NULL; + return SUN_ERR_SUNCTX_CORRUPT; } /* Test if all required vector operations are implemented */ - if (!domeig_CheckNVector(q)) - { - printf(MSG_DOMEIG_BAD_NVECTOR); - - return NULL; - } + SUNCheckCall(domeig_CheckNVector(q)); /* Allocate DOMEIGMem structure, and initialize to zero */ domeig_mem = (DOMEIGMem)calloc(1, sizeof(*domeig_mem)); + SUNAssert(domeig_mem, SUN_ERR_MALLOC_FAIL); /* Copy the inputs into DOMEIG memory */ + domeig_mem->sunctx = q->sunctx; domeig_mem->ATimes = ATimes; domeig_mem->Adata = Adata; domeig_mem->q = q; @@ -133,29 +119,28 @@ void* DomEigCreate(SUNATimesFn ATimes, void* Adata, normq = SUNRsqrt(normq); N_VScale(SUN_RCONST(1.0)/normq, domeig_mem->q, domeig_mem->V[0]); - return (void*)domeig_mem; + *domeig_mem_out = (void*)domeig_mem; + + return SUN_SUCCESS; } /* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ -int DomEigPreProcess(DOMEIGMem domeig_mem) +SUNErrCode DomEigPreProcess(DOMEIGMem domeig_mem, SUNContext sunctx) { + SUNFunctionBegin(sunctx); // is this correct? + int retval; /* Check if DomEig memory is allocated */ if(domeig_mem == NULL) { - printf(MSG_DOMEIG_MEM_FAIL); - - return -1; + return SUN_ERR_DOMEIG_MEM_FAIL; } /* Check if ATimes is provided */ if(domeig_mem->ATimes == NULL) { - printf(MSG_DOMEIG_NULL_ATIMES); - DomEigFree(&domeig_mem); - - return -1; + return SUN_ERR_DOMEIG_NULL_ATIMES; } sunrealtype normq; @@ -166,42 +151,61 @@ int DomEigPreProcess(DOMEIGMem domeig_mem) retval = domeig_mem->ATimes(domeig_mem->Adata, domeig_mem->V[0], domeig_mem->q); if (retval != 0) { - (retval < 0) ? - printf(MSG_DOMEIG_ATIMES_FAIL_UNREC) : - printf(MSG_DOMEIG_ATIMES_FAIL_REC); - DomEigFree(&domeig_mem); - - return retval; + DomEigDestroy(&domeig_mem); + + if(retval < 0) + { + return SUN_ERR_DOMEIG_ATIMES_FAIL_UNREC; + } + else + { + return SUN_ERR_DOMEIG_ATIMES_FAIL_REC; + } } normq = N_VDotProd(domeig_mem->q, domeig_mem->q); + SUNCheckLastErr(); + normq = SUNRsqrt(normq); N_VScale(SUN_RCONST(1.0)/normq, domeig_mem->q, domeig_mem->V[0]); + SUNCheckLastErr(); } - return 0; + return SUN_SUCCESS; } /* Compute the Hessenberg matrix DomEig_mem->Hes*/ -int DomEigComputeHess(DOMEIGMem domeig_mem) +SUNErrCode DomEigComputeHess(DOMEIGMem domeig_mem, SUNContext sunctx) { - int retval; + SUNFunctionBegin(sunctx); // is this correct? /* Check if DomEig memory is allocated */ if(domeig_mem == NULL) { - printf(MSG_DOMEIG_MEM_FAIL); - - return -1; + return SUN_ERR_DOMEIG_MEM_FAIL; } - /* Check if the dim of the matrix is less than 3 - Return immediately if dim <= 2 */ + /* Check if the dim of the matrix is less than 3. + Return immediately if dim <= 2; + no need to compute Hessenberg matrix + since the default is power iteration for dim <= 2 */ if(domeig_mem->length < 3) { - return 0; + return SUN_SUCCESS; } - int i, j; + /* Check if ATimes is provided */ + if(domeig_mem->ATimes == NULL) + { + return SUN_ERR_DOMEIG_NULL_ATIMES; + } + + /* Check if Hes is allocated */ + if(domeig_mem->Hes == NULL) + { + return SUN_ERR_DOMEIG_NULL_HES; + } + + int retval, i, j; /* Initialize the Hessenberg matrix Hes with zeros */ for (i = 0; i < domeig_mem->maxl; i++) { @@ -214,57 +218,53 @@ int DomEigComputeHess(DOMEIGMem domeig_mem) retval = domeig_mem->ATimes(domeig_mem->Adata, domeig_mem->V[i], domeig_mem->V[i+1]); if (retval != 0) { - (retval < 0) ? - printf(MSG_DOMEIG_ATIMES_FAIL_UNREC) : - printf(MSG_DOMEIG_ATIMES_FAIL_REC); - DomEigFree(&domeig_mem); - - return retval; + DomEigDestroy(&domeig_mem); + + if(retval < 0) + { + return SUN_ERR_DOMEIG_ATIMES_FAIL_UNREC; + } + else + { + return SUN_ERR_DOMEIG_ATIMES_FAIL_REC; + } } - if(SUNModifiedGS(domeig_mem->V, domeig_mem->Hes, i + 1, domeig_mem->maxl, &(domeig_mem->Hes[i + 1][i])) != SUN_SUCCESS) - { - printf(MSG_DOMEIG_GS_FAIL); - DomEigFree(&domeig_mem); - - return -1; - } + SUNCheckCall(SUNModifiedGS(domeig_mem->V, domeig_mem->Hes, i + 1, domeig_mem->maxl, &(domeig_mem->Hes[i + 1][i]))); /* Unitize the computed orthogonal vector */ N_VScale(SUN_RCONST(1.0)/domeig_mem->Hes[i + 1][i], domeig_mem->V[i+1], domeig_mem->V[i+1]); + SUNCheckLastErr(); } - return 0; + return SUN_SUCCESS; } -suncomplextype DomEigPowerIteration(DOMEIGMem domeig_mem) +SUNErrCode DomEigPowerIteration(DOMEIGMem domeig_mem, suncomplextype* dom_eig, SUNContext sunctx) { - int retval; - - suncomplextype dom_eig, dom_eig_old; - dom_eig.real = ZERO; - dom_eig.imag = ZERO; - dom_eig_old.real = ZERO; - dom_eig_old.imag = ZERO; + SUNFunctionBegin(sunctx); // is this correct? /* Check if DomEig memory is allocated */ if(domeig_mem == NULL) { - printf(MSG_DOMEIG_MEM_FAIL); - - return dom_eig; + return SUN_ERR_DOMEIG_MEM_FAIL; } /* Check if ATimes is provided */ if(domeig_mem->ATimes == NULL) { - printf(MSG_DOMEIG_NULL_ATIMES); - DomEigFree(&domeig_mem); - - return dom_eig; + return SUN_ERR_DOMEIG_NULL_ATIMES; } - int k; + suncomplextype dom_eig_new = *dom_eig; + suncomplextype dom_eig_old; + + dom_eig_new.real = ZERO; + dom_eig_new.imag = ZERO; + dom_eig_old.real = ZERO; + dom_eig_old.imag = ZERO; + + int retval, k; sunrealtype normq; for (k = 0; k < domeig_mem->max_powiter; k++) @@ -272,57 +272,76 @@ suncomplextype DomEigPowerIteration(DOMEIGMem domeig_mem) retval = domeig_mem->ATimes(domeig_mem->Adata, domeig_mem->V[0], domeig_mem->q); if (retval != 0) { - (retval < 0) ? - printf(MSG_DOMEIG_ATIMES_FAIL_UNREC) : - printf(MSG_DOMEIG_ATIMES_FAIL_REC); - DomEigFree(&domeig_mem); - - dom_eig.real = ZERO; - dom_eig.imag = ZERO; - - return dom_eig; + DomEigDestroy(&domeig_mem); + + if(retval < 0) + { + return SUN_ERR_DOMEIG_ATIMES_FAIL_UNREC; + } + else + { + return SUN_ERR_DOMEIG_ATIMES_FAIL_REC; + } } - dom_eig.real = N_VDotProd(domeig_mem->V[0], domeig_mem->q); //Rayleigh quotient + dom_eig_new.real = N_VDotProd(domeig_mem->V[0], domeig_mem->q); //Rayleigh quotient + SUNCheckLastErr(); - if(fabs(dom_eig.real - dom_eig_old.real) < domeig_mem->powiter_tol) + if(fabs(dom_eig_new.real - dom_eig_old.real) < domeig_mem->powiter_tol) { break; } normq = N_VDotProd(domeig_mem->q, domeig_mem->q); + SUNCheckLastErr(); + normq = SUNRsqrt(normq); N_VScale(SUN_RCONST(1.0)/normq, domeig_mem->q, domeig_mem->V[0]); + SUNCheckLastErr(); - dom_eig_old.real = dom_eig.real; + dom_eig_old.real = dom_eig_new.real; } - return dom_eig; + *dom_eig = dom_eig_new; + + return SUN_SUCCESS; } -/* Estimate the dominant eigvalues of the Hessenberg matrix */ -suncomplextype DomEigEstimate(DOMEIGMem domeig_mem) { - suncomplextype dom_eig; - dom_eig.real = ZERO; - dom_eig.imag = ZERO; +/* Estimate the dominant eigvalues of the Hessenberg matrix or + run power iterations for problem size less than 3 */ +SUNErrCode DomEigEstimate(DOMEIGMem domeig_mem, suncomplextype* dom_eig, SUNContext sunctx) +{ + SUNFunctionBegin(sunctx); // is this correct? /* Check if DomEig memory is allocated */ if(domeig_mem == NULL) { - printf(MSG_DOMEIG_MEM_FAIL); - - return dom_eig; + return SUN_ERR_DOMEIG_MEM_FAIL; } + suncomplextype dom_eig_new; + dom_eig_new.real = ZERO; + dom_eig_new.imag = ZERO; + + /* run power iterations for problem size less than 3 */ if(domeig_mem->length < 3) { - dom_eig = DomEigPowerIteration(domeig_mem); + SUNCheckCall(DomEigPowerIteration(domeig_mem, &dom_eig_new, domeig_mem->sunctx)); - return dom_eig; + *dom_eig = dom_eig_new; + + return SUN_SUCCESS; + } + + /* Check if Hes is allocated */ + if(domeig_mem->Hes == NULL) + { + return SUN_ERR_DOMEIG_NULL_HES; } int n = domeig_mem->maxl; + /* Reshape the Hessenberg matrix as an input vector for the LAPACK dgeev_ function */ int i, j, k = 0; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { @@ -337,35 +356,41 @@ suncomplextype DomEigEstimate(DOMEIGMem domeig_mem) { char jobvl = 'N'; // Do not compute left eigenvectors char jobvr = 'N'; // Do not compute right eigenvectors - // Call LAPACK's dgeev function + /* Call LAPACK's dgeev function */ dgeev_(&jobvl, &jobvr, &n, domeig_mem->LAPACK_A, &lda, domeig_mem->LAPACK_wr, domeig_mem->LAPACK_wi, NULL, &ldvl, NULL, &ldvr, domeig_mem->LAPACK_work, &lwork, &info); if (info != 0) { printf(MSG_DOMEIG_LAPACK_FAIL, info); - DomEigFree(&domeig_mem); + DomEigDestroy(&domeig_mem); - return dom_eig; + return SUN_ERR_DOMEIG_LAPACK_FAIL; } - //Following part will order the eigenvalues by their magnitude + /* order the eigenvalues by their magnitude */ for (i = 0; i < n; i++) { domeig_mem->LAPACK_arr[i].real = domeig_mem->LAPACK_wr[i]; domeig_mem->LAPACK_arr[i].imag = domeig_mem->LAPACK_wi[i]; } - // Sort the array using qsort + /* Sort the array using qsort */ qsort(domeig_mem->LAPACK_arr, n, sizeof(suncomplextype), domeig_Compare); - // Update the original arrays + /* Update the original arrays */ for (i = 0; i < n; i++) { domeig_mem->LAPACK_wr[i] = domeig_mem->LAPACK_arr[i].real; domeig_mem->LAPACK_wi[i] = domeig_mem->LAPACK_arr[i].imag; } - dom_eig.real = domeig_mem->LAPACK_wr[0]; - dom_eig.imag = domeig_mem->LAPACK_wi[0]; + // alternatively we can return a vector of all computed dom_eigs (up to maxl) + // TODO: Get opinions + + /* Copy the dominant eigenvalue */ + dom_eig_new.real = domeig_mem->LAPACK_wr[0]; + dom_eig_new.imag = domeig_mem->LAPACK_wi[0]; + + *dom_eig = dom_eig_new; - return dom_eig; + return SUN_SUCCESS; } /*=============================================================== @@ -376,17 +401,18 @@ suncomplextype DomEigEstimate(DOMEIGMem domeig_mem) { domeig_CheckNVector: This routine checks if all required vector operations are - present. If any of them is missing it returns SUNFALSE. + present. If any of them is missing it returns the corresponding + SUNErrCode. ---------------------------------------------------------------*/ -sunbooleantype domeig_CheckNVector(N_Vector tmpl) +SUNErrCode domeig_CheckNVector(N_Vector tmpl) { // TO DO: check required vector operations if ((tmpl->ops->nvclone == NULL) || (tmpl->ops->nvdestroy == NULL) || (tmpl->ops->nvdotprod == NULL) || (tmpl->ops->nvscale == NULL) || (tmpl->ops->nvgetlength == NULL) || (tmpl->ops->nvspace == NULL)) { - return SUNFALSE; + return SUN_ERR_DOMEIG_BAD_NVECTOR; } - return SUNTRUE; + return SUN_SUCCESS; } // Function to calculate the magnitude of a suncomplextype number @@ -404,56 +430,56 @@ int domeig_Compare(const void *a, const void *b) { } /*--------------------------------------------------------------- - DomEigFree frees all DomEig memory. + DomEigDestroy frees all DomEig memory. ---------------------------------------------------------------*/ -void DomEigFree(DOMEIGMem* domeig_mem) +void DomEigDestroy(void** domeig_mem) { - DOMEIGMem arn_mem; + DOMEIGMem dom_eig_mem; /* nothing to do if domeig_mem is already NULL */ - if (domeig_mem == NULL) { return; } + if (*domeig_mem == NULL) { return; } - arn_mem = (DOMEIGMem)(*domeig_mem); + dom_eig_mem = (DOMEIGMem)(*domeig_mem); - if (arn_mem->q != NULL) + if (dom_eig_mem->q != NULL) { - N_VDestroy(arn_mem->q); - arn_mem->q = NULL; + N_VDestroy(dom_eig_mem->q); + dom_eig_mem->q = NULL; } - if (arn_mem->V != NULL) + if (dom_eig_mem->V != NULL) { - N_VDestroyVectorArray(arn_mem->V, arn_mem->maxl + 1); - arn_mem->V = NULL; + N_VDestroyVectorArray(dom_eig_mem->V, dom_eig_mem->maxl + 1); + dom_eig_mem->V = NULL; } - if (arn_mem->LAPACK_A != NULL) + if (dom_eig_mem->LAPACK_A != NULL) { - free(arn_mem->LAPACK_A); - arn_mem->LAPACK_A = NULL; + free(dom_eig_mem->LAPACK_A); + dom_eig_mem->LAPACK_A = NULL; } - if (arn_mem->LAPACK_wr != NULL) + if (dom_eig_mem->LAPACK_wr != NULL) { - free(arn_mem->LAPACK_wr); - arn_mem->LAPACK_wr = NULL; + free(dom_eig_mem->LAPACK_wr); + dom_eig_mem->LAPACK_wr = NULL; } - if (arn_mem->LAPACK_wi != NULL) + if (dom_eig_mem->LAPACK_wi != NULL) { - free(arn_mem->LAPACK_wi); - arn_mem->LAPACK_wi = NULL; + free(dom_eig_mem->LAPACK_wi); + dom_eig_mem->LAPACK_wi = NULL; } - if (arn_mem->LAPACK_arr != NULL) + if (dom_eig_mem->LAPACK_arr != NULL) { - free(arn_mem->LAPACK_arr); - arn_mem->LAPACK_arr = NULL; + free(dom_eig_mem->LAPACK_arr); + dom_eig_mem->LAPACK_arr = NULL; } - if (arn_mem->Hes != NULL) + if (dom_eig_mem->Hes != NULL) { - free(arn_mem->Hes); - arn_mem->Hes = NULL; + free(dom_eig_mem->Hes); + dom_eig_mem->Hes = NULL; } free(*domeig_mem); diff --git a/test/unit_tests/sundials/test_domeig.c b/test/unit_tests/sundials/test_domeig.c index 9cbb6ed398..11bd64264c 100644 --- a/test/unit_tests/sundials/test_domeig.c +++ b/test/unit_tests/sundials/test_domeig.c @@ -131,28 +131,22 @@ int main(int argc, char* argv[]) ProbData.imag_part = imagpart; /* Create DOMEIG memory structure */ - DOMEIGMem DomEig_mem; - DomEig_mem = DomEigCreate(ATimes, &ProbData, q, maxl,sunctx); + void* DomEig_mem = NULL; + passfail = DomEigCreate(ATimes, &ProbData, q, maxl, sunctx, &DomEig_mem); + if (check_flag(&passfail, "DomEigCreate", 1)) { return 1; } /* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ - DomEigPreProcess(DomEig_mem); + passfail = DomEigPreProcess(DomEig_mem, sunctx); + if (check_flag(&passfail, "DomEigPreProcess", 1)) { return 1; } /* Compute the Hessenberg matrix Hes*/ - DomEigComputeHess(DomEig_mem); - - /* Print the Hessenberg matrix Hes if N <= 10*/ - if(ProbData.N <= 10){ - printf("\n"); - printf("Hes:\n"); - for (i = 0; i < DomEig_mem->maxl + 1; i++) { - for (j = 0; j < DomEig_mem->maxl; j++) { - printf("%20.2lf ", DomEig_mem->Hes[i][j]); - } - printf("\n"); - } - } + passfail = DomEigComputeHess(DomEig_mem, sunctx); + if (check_flag(&passfail, "DomEigComputeHess", 1)) { return 1; } + + suncomplextype dom_eig; + passfail = DomEigEstimate(DomEig_mem, &dom_eig, sunctx); + if (check_flag(&passfail, "DomEigEstimate", 1)) { return 1; } - suncomplextype dom_eig = DomEigEstimate(DomEig_mem); sunrealtype norm_of_dom_eig = SUNRsqrt(dom_eig.real * dom_eig.real + dom_eig.imag * dom_eig.imag); if(norm_of_dom_eig < SUN_SMALL_REAL) { printf("FAIL: Dominant Eigenvalue Test Failed"); @@ -194,7 +188,7 @@ int main(int argc, char* argv[]) N_VDestroy(q); N_VDestroy(ProbData.d); SUNContext_Free(&sunctx); - DomEigFree(&DomEig_mem); + DomEigDestroy(&DomEig_mem); return (passfail); } From 587eeafc0c5894f3eeca73d5649d3aeb3e23550e Mon Sep 17 00:00:00 2001 From: maggul Date: Tue, 3 Jun 2025 11:36:25 -0500 Subject: [PATCH 018/128] Removed sunctx argument --- include/sundials/sundials_domeig.h | 8 ++--- include/sundials/sundials_errors.h | 1 - src/arkode/arkode_lsrkstep.c | 6 ++-- src/arkode/arkode_lsrkstep_io.c | 6 ++++ src/sundials/sundials_domeig.c | 44 ++++++-------------------- test/unit_tests/sundials/test_domeig.c | 6 ++-- 6 files changed, 26 insertions(+), 45 deletions(-) diff --git a/include/sundials/sundials_domeig.h b/include/sundials/sundials_domeig.h index dc6120942c..bc2bbf2ebb 100644 --- a/include/sundials/sundials_domeig.h +++ b/include/sundials/sundials_domeig.h @@ -85,13 +85,13 @@ typedef struct DOMEIGMemRec SUNDIALS_EXPORT SUNErrCode DomEigCreate(SUNATimesFn ATimes, void* Adata, N_Vector q, int maxl, SUNContext sunctx, void** domeig_mem_out); -SUNDIALS_EXPORT SUNErrCode DomEigPreProcess(DOMEIGMem domeig_mem, SUNContext sunctx); +SUNDIALS_EXPORT SUNErrCode DomEigPreProcess(DOMEIGMem domeig_mem); -SUNDIALS_EXPORT SUNErrCode DomEigComputeHess(DOMEIGMem domeig_mem, SUNContext sunctx); +SUNDIALS_EXPORT SUNErrCode DomEigComputeHess(DOMEIGMem domeig_mem); -SUNDIALS_EXPORT SUNErrCode DomEigPowerIteration(DOMEIGMem domeig_mem, suncomplextype* dom_eig, SUNContext sunctx); +SUNDIALS_EXPORT SUNErrCode DomEigPowerIteration(DOMEIGMem domeig_mem, suncomplextype* dom_eig); -SUNDIALS_EXPORT SUNErrCode DomEigEstimate(DOMEIGMem domeig_mem, suncomplextype* dom_eig, SUNContext sunctx); +SUNDIALS_EXPORT SUNErrCode DomEigEstimate(DOMEIGMem domeig_mem, suncomplextype* dom_eig); SUNDIALS_EXPORT void DomEigDestroy(void** domeig_mem); diff --git a/include/sundials/sundials_errors.h b/include/sundials/sundials_errors.h index bed33aa8cd..0709d1d843 100644 --- a/include/sundials/sundials_errors.h +++ b/include/sundials/sundials_errors.h @@ -73,7 +73,6 @@ ENTRY(SUN_ERR_DOMEIG_BAD_NVECTOR, "Bad NVector") \ ENTRY(SUN_ERR_DOMEIG_NULL_ATIMES, "ATimes is null") \ ENTRY(SUN_ERR_DOMEIG_NULL_HES, "Hessenberg matrix is null") \ - ENTRY(SUN_ERR_DOMEIG_MEM_FAIL, "DOMEIG memory fail") \ ENTRY(SUN_ERR_DOMEIG_NOT_ENOUGH_ITER, "Number of Krylov subspace is not " \ "enough (< 2)") \ ENTRY(SUN_ERR_DOMEIG_ATIMES_FAIL_REC, "Atimes recoverable failure") \ diff --git a/src/arkode/arkode_lsrkstep.c b/src/arkode/arkode_lsrkstep.c index 085fb64e97..9ad2409607 100644 --- a/src/arkode/arkode_lsrkstep.c +++ b/src/arkode/arkode_lsrkstep.c @@ -2341,7 +2341,7 @@ suncomplextype lsrkStep_DomEigEstimate(void* arkode_mem, DOMEIGMem domeig_mem) } /* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ - retval = DomEigPreProcess(domeig_mem, ark_mem->sunctx); + retval = DomEigPreProcess(domeig_mem); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, @@ -2351,7 +2351,7 @@ suncomplextype lsrkStep_DomEigEstimate(void* arkode_mem, DOMEIGMem domeig_mem) } /* Compute the Hessenberg matrix Hes*/ - retval = DomEigComputeHess(domeig_mem, ark_mem->sunctx); + retval = DomEigComputeHess(domeig_mem); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, @@ -2360,7 +2360,7 @@ suncomplextype lsrkStep_DomEigEstimate(void* arkode_mem, DOMEIGMem domeig_mem) return dom_eig; } - retval = DomEigEstimate(domeig_mem, &dom_eig, ark_mem->sunctx); + retval = DomEigEstimate(domeig_mem, &dom_eig); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, diff --git a/src/arkode/arkode_lsrkstep_io.c b/src/arkode/arkode_lsrkstep_io.c index 5fe7476c3e..ab618cfc1c 100644 --- a/src/arkode/arkode_lsrkstep_io.c +++ b/src/arkode/arkode_lsrkstep_io.c @@ -220,6 +220,12 @@ int LSRKStepSetDomEigFn(void* arkode_mem, ARKDomEigFn dom_eig) step_mem->dom_eig_fn = NULL; step_mem->domeig_mem = lsrkStep_DomEigCreate(arkode_mem); + if (step_mem->domeig_mem == NULL) + { + arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, + "Internal domeig_mem is NULL"); + return ARK_INTERNAL_DOMEIG_FAIL; + } return ARK_SUCCESS; } diff --git a/src/sundials/sundials_domeig.c b/src/sundials/sundials_domeig.c index d70be8dc6d..914ef5548d 100644 --- a/src/sundials/sundials_domeig.c +++ b/src/sundials/sundials_domeig.c @@ -33,7 +33,7 @@ SUNErrCode DomEigCreate(SUNATimesFn ATimes, void* Adata, N_Vector q, int maxl, SUNContext sunctx, void** domeig_mem_out) { - SUNFunctionBegin(sunctx); // is this correct? + SUNFunctionBegin(sunctx); DOMEIGMem domeig_mem; /* Test if Atimes and q are provided */ @@ -125,18 +125,12 @@ SUNErrCode DomEigCreate(SUNATimesFn ATimes, void* Adata, } /* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ -SUNErrCode DomEigPreProcess(DOMEIGMem domeig_mem, SUNContext sunctx) +SUNErrCode DomEigPreProcess(DOMEIGMem domeig_mem) { - SUNFunctionBegin(sunctx); // is this correct? + SUNFunctionBegin(domeig_mem->sunctx); int retval; - /* Check if DomEig memory is allocated */ - if(domeig_mem == NULL) - { - return SUN_ERR_DOMEIG_MEM_FAIL; - } - /* Check if ATimes is provided */ if(domeig_mem->ATimes == NULL) { @@ -174,15 +168,9 @@ SUNErrCode DomEigPreProcess(DOMEIGMem domeig_mem, SUNContext sunctx) } /* Compute the Hessenberg matrix DomEig_mem->Hes*/ -SUNErrCode DomEigComputeHess(DOMEIGMem domeig_mem, SUNContext sunctx) +SUNErrCode DomEigComputeHess(DOMEIGMem domeig_mem) { - SUNFunctionBegin(sunctx); // is this correct? - - /* Check if DomEig memory is allocated */ - if(domeig_mem == NULL) - { - return SUN_ERR_DOMEIG_MEM_FAIL; - } + SUNFunctionBegin(domeig_mem->sunctx); /* Check if the dim of the matrix is less than 3. Return immediately if dim <= 2; @@ -240,15 +228,9 @@ SUNErrCode DomEigComputeHess(DOMEIGMem domeig_mem, SUNContext sunctx) return SUN_SUCCESS; } -SUNErrCode DomEigPowerIteration(DOMEIGMem domeig_mem, suncomplextype* dom_eig, SUNContext sunctx) +SUNErrCode DomEigPowerIteration(DOMEIGMem domeig_mem, suncomplextype* dom_eig) { - SUNFunctionBegin(sunctx); // is this correct? - - /* Check if DomEig memory is allocated */ - if(domeig_mem == NULL) - { - return SUN_ERR_DOMEIG_MEM_FAIL; - } + SUNFunctionBegin(domeig_mem->sunctx); /* Check if ATimes is provided */ if(domeig_mem->ATimes == NULL) @@ -309,15 +291,9 @@ SUNErrCode DomEigPowerIteration(DOMEIGMem domeig_mem, suncomplextype* dom_eig, S /* Estimate the dominant eigvalues of the Hessenberg matrix or run power iterations for problem size less than 3 */ -SUNErrCode DomEigEstimate(DOMEIGMem domeig_mem, suncomplextype* dom_eig, SUNContext sunctx) +SUNErrCode DomEigEstimate(DOMEIGMem domeig_mem, suncomplextype* dom_eig) { - SUNFunctionBegin(sunctx); // is this correct? - - /* Check if DomEig memory is allocated */ - if(domeig_mem == NULL) - { - return SUN_ERR_DOMEIG_MEM_FAIL; - } + SUNFunctionBegin(domeig_mem->sunctx); suncomplextype dom_eig_new; dom_eig_new.real = ZERO; @@ -326,7 +302,7 @@ SUNErrCode DomEigEstimate(DOMEIGMem domeig_mem, suncomplextype* dom_eig, SUNCont /* run power iterations for problem size less than 3 */ if(domeig_mem->length < 3) { - SUNCheckCall(DomEigPowerIteration(domeig_mem, &dom_eig_new, domeig_mem->sunctx)); + SUNCheckCall(DomEigPowerIteration(domeig_mem, &dom_eig_new)); *dom_eig = dom_eig_new; diff --git a/test/unit_tests/sundials/test_domeig.c b/test/unit_tests/sundials/test_domeig.c index 11bd64264c..f36a50f25f 100644 --- a/test/unit_tests/sundials/test_domeig.c +++ b/test/unit_tests/sundials/test_domeig.c @@ -136,15 +136,15 @@ int main(int argc, char* argv[]) if (check_flag(&passfail, "DomEigCreate", 1)) { return 1; } /* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ - passfail = DomEigPreProcess(DomEig_mem, sunctx); + passfail = DomEigPreProcess(DomEig_mem); if (check_flag(&passfail, "DomEigPreProcess", 1)) { return 1; } /* Compute the Hessenberg matrix Hes*/ - passfail = DomEigComputeHess(DomEig_mem, sunctx); + passfail = DomEigComputeHess(DomEig_mem); if (check_flag(&passfail, "DomEigComputeHess", 1)) { return 1; } suncomplextype dom_eig; - passfail = DomEigEstimate(DomEig_mem, &dom_eig, sunctx); + passfail = DomEigEstimate(DomEig_mem, &dom_eig); if (check_flag(&passfail, "DomEigEstimate", 1)) { return 1; } sunrealtype norm_of_dom_eig = SUNRsqrt(dom_eig.real * dom_eig.real + dom_eig.imag * dom_eig.imag); From cf61411b30596f6f2f6dbcee099f72bdd8550834 Mon Sep 17 00:00:00 2001 From: maggul Date: Tue, 3 Jun 2025 12:05:08 -0500 Subject: [PATCH 019/128] DomEigDestroy argument fix --- src/sundials/sundials_domeig.c | 8 ++++---- test/unit_tests/sundials/test_domeig.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sundials/sundials_domeig.c b/src/sundials/sundials_domeig.c index 914ef5548d..d35bcc297d 100644 --- a/src/sundials/sundials_domeig.c +++ b/src/sundials/sundials_domeig.c @@ -145,7 +145,7 @@ SUNErrCode DomEigPreProcess(DOMEIGMem domeig_mem) retval = domeig_mem->ATimes(domeig_mem->Adata, domeig_mem->V[0], domeig_mem->q); if (retval != 0) { - DomEigDestroy(&domeig_mem); + DomEigDestroy((void**)&domeig_mem); if(retval < 0) { @@ -206,7 +206,7 @@ SUNErrCode DomEigComputeHess(DOMEIGMem domeig_mem) retval = domeig_mem->ATimes(domeig_mem->Adata, domeig_mem->V[i], domeig_mem->V[i+1]); if (retval != 0) { - DomEigDestroy(&domeig_mem); + DomEigDestroy((void**)&domeig_mem); if(retval < 0) { @@ -254,7 +254,7 @@ SUNErrCode DomEigPowerIteration(DOMEIGMem domeig_mem, suncomplextype* dom_eig) retval = domeig_mem->ATimes(domeig_mem->Adata, domeig_mem->V[0], domeig_mem->q); if (retval != 0) { - DomEigDestroy(&domeig_mem); + DomEigDestroy((void**)&domeig_mem); if(retval < 0) { @@ -337,7 +337,7 @@ SUNErrCode DomEigEstimate(DOMEIGMem domeig_mem, suncomplextype* dom_eig) if (info != 0) { printf(MSG_DOMEIG_LAPACK_FAIL, info); - DomEigDestroy(&domeig_mem); + DomEigDestroy((void**)&domeig_mem); return SUN_ERR_DOMEIG_LAPACK_FAIL; } diff --git a/test/unit_tests/sundials/test_domeig.c b/test/unit_tests/sundials/test_domeig.c index f36a50f25f..197dbdc2c9 100644 --- a/test/unit_tests/sundials/test_domeig.c +++ b/test/unit_tests/sundials/test_domeig.c @@ -188,7 +188,7 @@ int main(int argc, char* argv[]) N_VDestroy(q); N_VDestroy(ProbData.d); SUNContext_Free(&sunctx); - DomEigDestroy(&DomEig_mem); + DomEigDestroy((void**)&DomEig_mem); return (passfail); } From a3ed79915509f0eeed499dbc38b1900a6d5c756a Mon Sep 17 00:00:00 2001 From: maggul Date: Tue, 3 Jun 2025 22:23:03 -0500 Subject: [PATCH 020/128] removed the sunctx check --- src/sundials/sundials_domeig.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/sundials/sundials_domeig.c b/src/sundials/sundials_domeig.c index d35bcc297d..e256563ec2 100644 --- a/src/sundials/sundials_domeig.c +++ b/src/sundials/sundials_domeig.c @@ -48,12 +48,6 @@ SUNErrCode DomEigCreate(SUNATimesFn ATimes, void* Adata, return SUN_ERR_DOMEIG_NOT_ENOUGH_ITER; } - /* Test if sunctx is provided */ - if (sunctx == NULL) - { - return SUN_ERR_SUNCTX_CORRUPT; - } - /* Test if all required vector operations are implemented */ SUNCheckCall(domeig_CheckNVector(q)); From 377d54a360e61cceefc366c67ccc378fdb8e081b Mon Sep 17 00:00:00 2001 From: maggul Date: Sat, 7 Jun 2025 13:42:11 -0500 Subject: [PATCH 021/128] header and src files --- include/sundials/sundials_domeigestimator.h | 120 ++++++ include/sundomeigest/sundomeigest_arnoldi.h | 98 +++++ include/sundomeigest/sundomeigest_pi.h | 94 +++++ src/sundials/sundials_domeigestimator.c | 151 +++++++ src/sundomeigest/ArnI/sundomeigest_arni.c | 416 ++++++++++++++++++++ src/sundomeigest/PI/sundomeigest_pi.c | 305 ++++++++++++++ 6 files changed, 1184 insertions(+) create mode 100644 include/sundials/sundials_domeigestimator.h create mode 100644 include/sundomeigest/sundomeigest_arnoldi.h create mode 100644 include/sundomeigest/sundomeigest_pi.h create mode 100644 src/sundials/sundials_domeigestimator.c create mode 100644 src/sundomeigest/ArnI/sundomeigest_arni.c create mode 100644 src/sundomeigest/PI/sundomeigest_pi.c diff --git a/include/sundials/sundials_domeigestimator.h b/include/sundials/sundials_domeigestimator.h new file mode 100644 index 0000000000..446cba549f --- /dev/null +++ b/include/sundials/sundials_domeigestimator.h @@ -0,0 +1,120 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Mustafa Aggul @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2025, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------- + * This is the header file for a generic SUNDomEigEst package. + * -----------------------------------------------------------------*/ + +#ifndef _DOMEIGEST_H +#define _DOMEIGEST_H + +#include /* serial N_Vector types, fcts., macros */ +#include +#include +#include "sundials/sundials_errors.h" +#include + +#ifdef __cplusplus /* wrapper to enable C++ usage */ +extern "C" { +#endif + +// Struct to hold the real and imaginary parts +typedef struct { + sunrealtype real; + sunrealtype imag; +} suncomplextype; + +/* ----------------------------------------------------------------- + * Implemented SUNDomEigEstimator types + * ----------------------------------------------------------------- */ + +typedef enum +{ + SUNDOMEIG_POWER, + SUNDOMEIG_ARNOLDI +} SUNDomEigEstimator_Type; + +/* ----------------------------------------------------------------- + * Generic definition of SUNDomEigEstimator + * ----------------------------------------------------------------- */ + +/* Forward reference for pointer to SUNDomEigEstimator_Ops object */ +typedef _SUNDIALS_STRUCT_ _generic_SUNDomEigEstimator_Ops* SUNDomEigEstimator_Ops; + +/* Forward reference for pointer to SUNDomEigEstimator object */ +typedef _SUNDIALS_STRUCT_ _generic_SUNDomEigEstimator* SUNDomEigEstimator; + +/* Structure containing function pointers to estimator operations */ +struct _generic_SUNDomEigEstimator_Ops +{ + SUNDomEigEstimator_Type (*gettype)(SUNDomEigEstimator); + SUNErrCode (*setatimes)(SUNDomEigEstimator, void*, SUNATimesFn); + SUNErrCode (*setmaxpoweriter)(SUNDomEigEstimator, int); + SUNErrCode (*initialize)(SUNDomEigEstimator); + SUNErrCode (*preprocess)(SUNDomEigEstimator); + SUNErrCode (*computehess)(SUNDomEigEstimator); + SUNErrCode (*estimate)(SUNDomEigEstimator, suncomplextype*); + int (*getnumofiters)(SUNDomEigEstimator); + SUNErrCode (*free)(SUNDomEigEstimator); +}; + +/* A estimator is a structure with an implementation-dependent + 'content' field, and a pointer to a structure of estimator + operations corresponding to that implementation. */ +struct _generic_SUNDomEigEstimator +{ + void* content; + SUNDomEigEstimator_Ops ops; + SUNContext sunctx; +}; + +/* ----------------------------------------------------------------- + * Functions exported by SUNDomEigEstimator module + * ----------------------------------------------------------------- */ + +SUNDIALS_EXPORT +SUNDomEigEstimator SUNDomEigEstNewEmpty(SUNContext sunctx); + +SUNDIALS_EXPORT +void SUNDomEigEstFreeEmpty(SUNDomEigEstimator D); + +SUNDIALS_EXPORT +SUNDomEigEstimator_Type SUNDomEigEstGetType(SUNDomEigEstimator D); + +SUNDIALS_EXPORT +SUNErrCode SUNDomEigEstSetATimes(SUNDomEigEstimator D, void* A_data, + SUNATimesFn ATimes); + +SUNDIALS_EXPORT +SUNErrCode SUNDomEigEstInitialize(SUNDomEigEstimator D, void* A_data, + SUNATimesFn ATimes); + +SUNDIALS_EXPORT +SUNErrCode SUNDomEigEstPreProcess(SUNDomEigEstimator D); + +SUNDIALS_EXPORT +SUNErrCode SUNDomEigEstComputeHess(SUNDomEigEstimator D); + +SUNDIALS_EXPORT +SUNErrCode SUNDomEigEstimate(SUNDomEigEstimator D, suncomplextype* dom_eig); + +/* ----------------------------------------------------------------- + * SUNDomEigEstimator return values + * ----------------------------------------------------------------- */ + +#define SUNDEE_LAPACK_FAIL "Error: LAPACK dgeev failed with info = %d\n" + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/include/sundomeigest/sundomeigest_arnoldi.h b/include/sundomeigest/sundomeigest_arnoldi.h new file mode 100644 index 0000000000..e239b7ee5d --- /dev/null +++ b/include/sundomeigest/sundomeigest_arnoldi.h @@ -0,0 +1,98 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Mustafa Aggul @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2025, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------- + * This is the header file for the Arnoldi Iteration (ArnI) + * implementation of the SUNDomEigEst package. + * + * Note: + * - The definition of the generic SUNDomEigEstimator structure can + * be found in the header file sundials_domeigestimator.h. + * ----------------------------------------------------------------- + */ + +#ifndef _DOMEIGEST_ARNI_H +#define _DOMEIGEST_ARNI_H + +#include + +#ifdef __cplusplus /* wrapper to enable C++ usage */ +extern "C" { +#endif + +/* Default Arnoldi Iteration parameters */ +#define SUNDOMEIGEST_ARN_MAXL_DEFAULT 3 +#define SUNDOMEIGEST_PI_POWER_OF_A_DEFAULT 10 +#define SUNDOMEIGEST_LAPACK_FAIL "Error: LAPACK dgeev failed with info = %d\n" + +/* ----------------------------------------------------- + * Arnoldi Iteration Implementation of SUNDomEigEstimator + * ----------------------------------------------------- */ + +struct _SUNDomEigEstimatorContent_ArnI +{ + SUNATimesFn ATimes; /* User provided ATimes function */ + void* ATdata; /* ATimes function data*/ + + N_Vector *V, q; /* Krylov subspace vectors */ + + int maxl; /* Krylov subspace dimension */ + int power_of_A; /* Power of A in the preprocessing; initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ + + sunrealtype* LAPACK_A; /* The vector which holds rows of the Hessenberg matrix in the given order */ + sunrealtype* LAPACK_wr; /* Real parts of eigenvalues */ + sunrealtype* LAPACK_wi; /* Imaginary parts of eigenvalues */ + sunrealtype* LAPACK_work; /* Workspace array */ + suncomplextype* LAPACK_arr; /* an array to sort eigenvalues*/ + + sunrealtype **Hes; /* Hessenberg matrix Hes */ +}; + +typedef struct _SUNDomEigEstimatorContent_ArnI* SUNDomEigEstimatorContent_ArnI; + +/* --------------------------------------- + * Exported Functions for SUNDOMEIGEST_ArnI + * --------------------------------------- */ + +SUNDIALS_EXPORT +SUNDomEigEstimator SUNDomEigEst_ArnI(N_Vector q, int maxl, SUNContext sunctx); + +SUNDIALS_EXPORT +SUNDomEigEstimator_Type SUNDomEigEst_ArnIGetType(SUNDomEigEstimator DEE); + +SUNDIALS_EXPORT +SUNErrCode SUNDomEigEstSetATimes_ArnI(SUNDomEigEstimator DEE, void* A_data, + SUNATimesFn ATimes); + +SUNDIALS_EXPORT +SUNErrCode SUNDomEigEstInitialize_ArnI(SUNDomEigEstimator DEE); + +SUNDIALS_EXPORT +SUNErrCode SUNDomEigEstPreProcess_ArnI(SUNDomEigEstimator DEE); + +SUNDIALS_EXPORT +SUNErrCode SUNDomEigEstComputeHess_ArnI(SUNDomEigEstimator DEE); + +SUNDIALS_EXPORT +SUNErrCode SUNDomEigEstimate_ArnI(SUNDomEigEstimator DEE, suncomplextype* dom_eig); + +SUNDIALS_EXPORT +SUNErrCode SUNDomEigEstFree_ArnI(SUNDomEigEstimator DEE); + +SUNDIALS_EXPORT +int SUNDomEigEstNumIters_ArnI(SUNDomEigEstimator DEE); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/sundomeigest/sundomeigest_pi.h b/include/sundomeigest/sundomeigest_pi.h new file mode 100644 index 0000000000..9a522a80ba --- /dev/null +++ b/include/sundomeigest/sundomeigest_pi.h @@ -0,0 +1,94 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Mustafa Aggul @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2025, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------- + * This is the header file for the Power Iteration (PI) implementation + * of the SUNDomEigEst package. + * + * Note: + * - The definition of the generic SUNDomEigEstimator structure can + * be found in the header file sundials_domeigestimator.h. + * ----------------------------------------------------------------- + */ + +#ifndef _DOMEIGEST_PI_H +#define _DOMEIGEST_PI_H + +#include + +#ifdef __cplusplus /* wrapper to enable C++ usage */ +extern "C" { +#endif + +/* Default Power Iteration parameters */ +#define SUNDOMEIGEST_PI_TOL_DEFAULT SUN_RCONST(0.01) +#define SUNDOMEIGEST_MAX_PI_DEFAULT 100 +#define SUNDOMEIGEST_PI_POWER_OF_A_DEFAULT 10 + +/* ----------------------------------------------------- + * Power Iteration Implementation of SUNDomEigEstimator + * ----------------------------------------------------- */ + +struct _SUNDomEigEstimatorContent_PI +{ + SUNATimesFn ATimes; /* User provided ATimes function */ + void* ATdata; /* ATimes function data*/ + + N_Vector V, q; /* workspace vectors */ + + int power_of_A; /* Power of A in the preprocessing; initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ + + sunrealtype powiter_tol; /* Convergence criteria for the power iteration */ + sunrealtype resnorm; /* Current residual of power iterations */ + int max_powiter; /* Maximum number of power iterations */ + int numiters; /* Number of power iterations */ +}; + +typedef struct _SUNDomEigEstimatorContent_PI* SUNDomEigEstimatorContent_PI; + +/* --------------------------------------- + * Exported Functions for SUNDOMEIGEST_PI + * --------------------------------------- */ + +SUNDIALS_EXPORT +SUNDomEigEstimator SUNDomEigEst_PI(N_Vector q, int max_powiter, SUNContext sunctx); + +SUNDIALS_EXPORT +SUNDomEigEstimator_Type SUNDomEigEst_PIGetType(SUNDomEigEstimator DEE); + +SUNDIALS_EXPORT +SUNErrCode SUNDomEigEstInitialize_PI(SUNDomEigEstimator DEE); + +SUNDIALS_EXPORT +SUNErrCode SUNDomEigEstSetATimes_PI(SUNDomEigEstimator DEE, void* A_data, + SUNATimesFn ATimes); + +SUNDIALS_EXPORT +SUNErrCode SUNDomEigEst_PISetMaxPowerIter(SUNDomEigEstimator DEE, int max_powiter); + +SUNDIALS_EXPORT +SUNErrCode SUNDomEigEstPreProcess_PI(SUNDomEigEstimator DEE); + +SUNDIALS_EXPORT +SUNErrCode SUNDomEigEstimate_PI(SUNDomEigEstimator DEE, suncomplextype* dom_eig); + +SUNDIALS_EXPORT +int SUNDomEigEstNumIters_PI(SUNDomEigEstimator DEE); + +SUNDIALS_EXPORT +SUNErrCode SUNDomEigEstFree_PI(SUNDomEigEstimator DEE); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/sundials/sundials_domeigestimator.c b/src/sundials/sundials_domeigestimator.c new file mode 100644 index 0000000000..c0d52b74f7 --- /dev/null +++ b/src/sundials/sundials_domeigestimator.c @@ -0,0 +1,151 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Mustafa Aggul @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2025, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------- + * This is the implementation file for a generic SUNDomEigEst + * package. It contains the implementation of the SUNDomEigEstimator + * operations listed in sundials_domeigestimator.h + * -----------------------------------------------------------------*/ + +#include +#include + +#include +#include +#include + +#include + +#if defined(SUNDIALS_BUILD_WITH_PROFILING) +static SUNProfiler getSUNProfiler(SUNDomEigEstimator D) +{ + return (D->sunctx->profiler); +} +#endif + +/* ----------------------------------------------------------------- + * Create a new empty SUNDomEigEstimator object + * ----------------------------------------------------------------- */ + +SUNDomEigEstimator SUNDomEigEstNewEmpty(SUNContext sunctx) +{ + SUNDomEigEstimator DEE; + SUNDomEigEstimator_Ops ops; + + if (sunctx == NULL) { return NULL; } + + SUNFunctionBegin(sunctx); + + /* create dominant eigenvalue estimator object */ + DEE = NULL; + DEE = (SUNDomEigEstimator)malloc(sizeof *DEE); + SUNAssertNull(DEE, SUN_ERR_MALLOC_FAIL); + + /* create dominant eigenvalue estimator ops structure */ + ops = NULL; + ops = (SUNDomEigEstimator_Ops)malloc(sizeof *ops); + SUNAssertNull(ops, SUN_ERR_MALLOC_FAIL); + + /* initialize operations to NULL */ + ops->gettype = NULL; + ops->setatimes = NULL; + ops->initialize = NULL; + ops->preprocess = NULL; + ops->computehess = NULL; + ops->initialize = NULL; + ops->estimate = NULL; + ops->free = NULL; + + /* attach ops and initialize content and context to NULL */ + DEE->ops = ops; + DEE->content = NULL; + DEE->sunctx = sunctx; + + return (DEE); +} + +/* ----------------------------------------------------------------- + * Free a generic SUNDomEigEstimator (assumes content is already empty) + * ----------------------------------------------------------------- */ + +void SUNDomEigEstFreeEmpty(SUNDomEigEstimator DEE) +{ + if (DEE == NULL) { return; } + + /* free non-NULL ops structure */ + if (DEE->ops) { free(DEE->ops); } + DEE->ops = NULL; + + /* free overall N_Vector object and return */ + free(DEE); + return; +} + +/* ----------------------------------------------------------------- + * Functions in the 'ops' structure + * -----------------------------------------------------------------*/ + +SUNDomEigEstimator_Type SUNLinSolGetType(SUNDomEigEstimator DEE) +{ + return (DEE->ops->gettype(DEE)); +} + +SUNErrCode SUNDomEigEstSetATimes(SUNDomEigEstimator DEE, void* A_data, SUNATimesFn ATimes) +{ + SUNErrCode ier; + SUNDIALS_MARK_FUNCTION_BEGIN(getSUNProfiler(DEE)); + if (DEE->ops->setatimes) { ier = DEE->ops->setatimes(DEE, A_data, ATimes); } + else { ier = SUN_SUCCESS; } + SUNDIALS_MARK_FUNCTION_END(getSUNProfiler(DEE)); + return (ier); +} + +SUNErrCode SUNDomEigEstInitialize(SUNDomEigEstimator DEE, void* A_data, + SUNATimesFn ATimes) //maybe drop Atimes from here +{ + SUNErrCode ier; + SUNDIALS_MARK_FUNCTION_BEGIN(getSUNProfiler(DEE)); + if (DEE->ops->initialize) { ier = DEE->ops->initialize(DEE); } + else { ier = SUN_SUCCESS; } + SUNDIALS_MARK_FUNCTION_END(getSUNProfiler(DEE)); + return (ier); +} + +SUNErrCode SUNDomEigEstPreProcess(SUNDomEigEstimator DEE) +{ + SUNErrCode ier; + SUNDIALS_MARK_FUNCTION_BEGIN(getSUNProfiler(DEE)); + if (DEE->ops->preprocess) { ier = DEE->ops->preprocess(DEE); } + else { ier = SUN_SUCCESS; } + SUNDIALS_MARK_FUNCTION_END(getSUNProfiler(DEE)); + return (ier); +} + +SUNErrCode SUNDomEigEstComputeHess(SUNDomEigEstimator DEE) +{ + SUNErrCode ier; + SUNDIALS_MARK_FUNCTION_BEGIN(getSUNProfiler(DEE)); + if (DEE->ops->computehess) { ier = DEE->ops->computehess(DEE); } + else { ier = SUN_SUCCESS; } + SUNDIALS_MARK_FUNCTION_END(getSUNProfiler(DEE)); + return (ier); +} + +SUNErrCode SUNDomEigEstimate(SUNDomEigEstimator DEE, suncomplextype* dom_eig) +{ + SUNErrCode ier; + SUNDIALS_MARK_FUNCTION_BEGIN(getSUNProfiler(DEE)); + if (DEE->ops->estimate) { ier = DEE->ops->estimate(DEE, dom_eig); } + else { ier = SUN_SUCCESS; } + SUNDIALS_MARK_FUNCTION_END(getSUNProfiler(DEE)); + return (ier); +} \ No newline at end of file diff --git a/src/sundomeigest/ArnI/sundomeigest_arni.c b/src/sundomeigest/ArnI/sundomeigest_arni.c new file mode 100644 index 0000000000..a1375dcc10 --- /dev/null +++ b/src/sundomeigest/ArnI/sundomeigest_arni.c @@ -0,0 +1,416 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Mustafa Aggul @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2025, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------- + * This is the implementation file for the Arnoldi Iteration (ArnI) + * implementation of the SUNDomEigEst package. + * ----------------------------------------------------------------- + */ + + #include +#include + +#include +#include +#include + +#include "sundials_logger_impl.h" +#include "sundials_macros.h" + +#define ZERO SUN_RCONST(0.0) +#define ONE SUN_RCONST(1.0) + +/* + * ----------------------------------------------------------------- + * Arnoldi itetation structure accessibility macros: + * ----------------------------------------------------------------- + */ + +#define ArnI_CONTENT(DEE) ((SUNDomEigEstimatorContent_ArnI)(DEE->content)) + +/* + * ----------------------------------------------------------------- + * internally used functions + * ----------------------------------------------------------------- + */ + +sunrealtype domeig_Magnitude(const suncomplextype *c); +int domeig_Compare(const void *a, const void *b); + +/* + * ----------------------------------------------------------------- + * exported functions + * ----------------------------------------------------------------- + */ + +/* ---------------------------------------------------------------------------- + * Function to create a new ArnI estimator + */ + +SUNDomEigEstimator SUNDomEigEst_ArnI(N_Vector q, int maxl, SUNContext sunctx) +{ + SUNFunctionBegin(sunctx); + SUNDomEigEstimator DEE; + SUNDomEigEstimatorContent_ArnI content; + + /* check for legal q; if illegal return NULL */ + // TO DO: check required vector operations + SUNAssert(( + (q->ops->nvclone == NULL) || (q->ops->nvdestroy == NULL) || + (q->ops->nvdotprod == NULL) || (q->ops->nvscale == NULL) || + (q->ops->nvgetlength == NULL) || (q->ops->nvspace == NULL)), SUN_ERR_DOMEIG_BAD_NVECTOR); + + /* Check if maxl >= 2 */ + SUNAssert(maxl < 2, SUN_ERR_DOMEIG_NOT_ENOUGH_ITER); + + /* Create dominant eigenvalue estimator */ + DEE = NULL; + DEE = SUNDomEigEstNewEmpty (sunctx); + SUNCheckLastErrNull(); + + /* Attach operations */ + DEE->ops->gettype = SUNDomEigEst_ArnIGetType; + DEE->ops->setatimes = SUNDomEigEstSetATimes_ArnI; + DEE->ops->setmaxpoweriter = NULL; + DEE->ops->initialize = SUNDomEigEstInitialize_ArnI; + DEE->ops->preprocess = SUNDomEigEstPreProcess_ArnI; + DEE->ops->computehess = SUNDomEigEstComputeHess_ArnI; + DEE->ops->estimate = SUNDomEigEstimate_ArnI; + DEE->ops->getnumofiters = NULL; + DEE->ops->free = SUNDomEigEstFree_ArnI; + + /* Create content */ + content = NULL; + content = (SUNDomEigEstimatorContent_ArnI)malloc(sizeof *content); + SUNAssertNull(content, SUN_ERR_MALLOC_FAIL); + + /* Attach content */ + DEE->content = content; + + /* Fill content */ + content->ATimes = NULL; + content->ATdata = NULL; + content->V = NULL; + content->q = NULL; + content->maxl = maxl; + content->power_of_A = NULL; + content->LAPACK_A = NULL; + content->LAPACK_wr = NULL; + content->LAPACK_wi = NULL; + content->LAPACK_work = NULL; + content->LAPACK_arr = NULL; + content->Hes = NULL; + + /* Allocate content */ + content->q = N_VClone(q); + SUNCheckLastErrNull(); + + content->V = N_VCloneVectorArray(maxl + 1, q); + SUNCheckLastErrNull(); + + return (DEE); +} + +/* + * ----------------------------------------------------------------- + * implementation of dominant eigenvalue estimator operations + * ----------------------------------------------------------------- + */ + +SUNDomEigEstimator_Type SUNDomEigEst_ArnIGetType(SUNDIALS_MAYBE_UNUSED SUNDomEigEstimator DEE) +{ + return (SUNDOMEIG_ARNOLDI); +} + +SUNErrCode SUNDomEigEstInitialize_ArnI(SUNDomEigEstimator DEE) +{ + SUNFunctionBegin(DEE->sunctx); + + if (ArnI_CONTENT(DEE)->maxl < 2) { ArnI_CONTENT(DEE)->maxl = SUNDOMEIGEST_ARN_MAXL_DEFAULT; } + if (ArnI_CONTENT(DEE)->power_of_A < 0) { ArnI_CONTENT(DEE)->power_of_A = SUNDOMEIGEST_PI_POWER_OF_A_DEFAULT; } + + SUNAssert(ArnI_CONTENT(DEE)->ATimes, SUN_ERR_ARG_CORRUPT); + SUNAssert(ArnI_CONTENT(DEE)->V, SUN_ERR_ARG_CORRUPT); + SUNAssert(ArnI_CONTENT(DEE)->q, SUN_ERR_ARG_CORRUPT); + + ArnI_CONTENT(DEE)->LAPACK_A = (sunrealtype*)malloc((ArnI_CONTENT(DEE)->maxl*ArnI_CONTENT(DEE)->maxl) * sizeof(sunrealtype)); + ArnI_CONTENT(DEE)->LAPACK_wr = malloc(ArnI_CONTENT(DEE)->maxl * sizeof(sunrealtype)); + ArnI_CONTENT(DEE)->LAPACK_wi = malloc(ArnI_CONTENT(DEE)->maxl * sizeof(sunrealtype)); + ArnI_CONTENT(DEE)->LAPACK_work = malloc((4 * ArnI_CONTENT(DEE)->maxl) * sizeof(sunrealtype)); + ArnI_CONTENT(DEE)->LAPACK_arr = (suncomplextype *)malloc(ArnI_CONTENT(DEE)->maxl * sizeof(suncomplextype)); + + N_VRandom(ArnI_CONTENT(DEE)->q); + SUNCheckLastErrNull(); + + /* Initialize the vector V */ + sunrealtype normq = N_VDotProd(ArnI_CONTENT(DEE)->q, ArnI_CONTENT(DEE)->q); + SUNCheckLastErrNull(); + + normq = SUNRsqrt(normq); + + N_VScale(ONE/normq, ArnI_CONTENT(DEE)->q, ArnI_CONTENT(DEE)->V); + SUNCheckLastErrNull(); + + /* Hessenberg matrix Hes */ + if (ArnI_CONTENT(DEE)->Hes == NULL) + { + int k; + ArnI_CONTENT(DEE)->Hes = + (sunrealtype**)malloc((ArnI_CONTENT(DEE)->maxl + 1) * sizeof(sunrealtype*)); + + for (k = 0; k <= ArnI_CONTENT(DEE)->maxl; k++) + { + ArnI_CONTENT(DEE)->Hes[k] = NULL; + ArnI_CONTENT(DEE)->Hes[k] = (sunrealtype*)malloc(ArnI_CONTENT(DEE)->maxl * sizeof(sunrealtype)); + } + } + + /* Initialize the vector V[0] */ + sunrealtype normq = N_VDotProd(ArnI_CONTENT(DEE)->q, ArnI_CONTENT(DEE)->q); + SUNCheckLastErrNull(); + + normq = SUNRsqrt(normq); + + N_VScale(ONE/normq, ArnI_CONTENT(DEE)->q, ArnI_CONTENT(DEE)->V[0]); + SUNCheckLastErrNull(); + + return SUN_SUCCESS; +} + +SUNErrCode SUNDomEigEstSetATimes_ArnI(SUNDomEigEstimator DEE, void* A_data, SUNATimesFn ATimes) +{ + SUNFunctionBegin(DEE->sunctx); + + /* set function pointers to integrator-supplied ATimes routine + and data, and return with success */ + ArnI_CONTENT(DEE)->ATimes = ATimes; + ArnI_CONTENT(DEE)->ATdata = A_data; + return SUN_SUCCESS; +} + +SUNErrCode SUNDomEigEstPreProcess_ArnI(SUNDomEigEstimator DEE) +{ + SUNFunctionBegin(DEE->sunctx); + + SUNAssert(ArnI_CONTENT(DEE)->ATimes, SUN_ERR_ARG_CORRUPT); + SUNAssert(ArnI_CONTENT(DEE)->V, SUN_ERR_ARG_CORRUPT); + SUNAssert(ArnI_CONTENT(DEE)->q, SUN_ERR_ARG_CORRUPT); + + sunrealtype normq; + int i, retval; + + /* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ + for(i = 0; i < ArnI_CONTENT(DEE)->power_of_A; i++) + { + retval = ArnI_CONTENT(DEE)->ATimes(ArnI_CONTENT(DEE)->ATdata, ArnI_CONTENT(DEE)->V, ArnI_CONTENT(DEE)->q); + if (retval != 0) + { + if(retval < 0) + { + return SUN_ERR_DOMEIG_ATIMES_FAIL_UNREC; + } + else + { + return SUN_ERR_DOMEIG_ATIMES_FAIL_REC; + } + } + normq = N_VDotProd(ArnI_CONTENT(DEE)->q, ArnI_CONTENT(DEE)->q); + SUNCheckLastErr(); + + normq = SUNRsqrt(normq); + N_VScale(ONE/normq, ArnI_CONTENT(DEE)->q, ArnI_CONTENT(DEE)->V); + SUNCheckLastErr(); + } + + return SUN_SUCCESS; +} + +SUNErrCode SUNDomEigEstComputeHess_ArnI(SUNDomEigEstimator DEE) +{ + SUNFunctionBegin(DEE->sunctx); + + SUNAssert(ArnI_CONTENT(DEE)->ATimes, SUN_ERR_ARG_CORRUPT); + SUNAssert(ArnI_CONTENT(DEE)->V, SUN_ERR_ARG_CORRUPT); + SUNAssert(ArnI_CONTENT(DEE)->q, SUN_ERR_ARG_CORRUPT); + SUNAssert(ArnI_CONTENT(DEE)->Hes, SUN_ERR_ARG_CORRUPT); + + int retval, i, j; + /* Initialize the Hessenberg matrix Hes with zeros */ + for (i = 0; i < ArnI_CONTENT(DEE)->maxl; i++) + { + for (j = 0; j < ArnI_CONTENT(DEE)->maxl; j++) {ArnI_CONTENT(DEE)->Hes[i][j] = ZERO; } + } + + for (i = 0; i < ArnI_CONTENT(DEE)->maxl; i++) + { + /* Compute the next Krylov vector */ + retval = ArnI_CONTENT(DEE)->ATimes(ArnI_CONTENT(DEE)->ATdata, ArnI_CONTENT(DEE)->V[i], ArnI_CONTENT(DEE)->V[i+1]); + if (retval != 0) + { + if(retval < 0) + { + return SUN_ERR_DOMEIG_ATIMES_FAIL_UNREC; + } + else + { + return SUN_ERR_DOMEIG_ATIMES_FAIL_REC; + } + } + + SUNCheckCall(SUNModifiedGS(ArnI_CONTENT(DEE)->V, ArnI_CONTENT(DEE)->Hes, i + 1, ArnI_CONTENT(DEE)->maxl, &(ArnI_CONTENT(DEE)->Hes[i + 1][i]))); + + /* Unitize the computed orthogonal vector */ + N_VScale(SUN_RCONST(1.0)/ArnI_CONTENT(DEE)->Hes[i + 1][i], ArnI_CONTENT(DEE)->V[i+1], ArnI_CONTENT(DEE)->V[i+1]); + SUNCheckLastErr(); + } + + return SUN_SUCCESS; +} + +SUNErrCode SUNDomEigEstimate_ArnI(SUNDomEigEstimator DEE, suncomplextype* dom_eig) +{ + SUNFunctionBegin(DEE->sunctx); + + SUNAssert(dom_eig, SUN_ERR_ARG_CORRUPT); + SUNAssert(ArnI_CONTENT(DEE)->ATimes, SUN_ERR_ARG_CORRUPT); + SUNAssert(ArnI_CONTENT(DEE)->V, SUN_ERR_ARG_CORRUPT); + SUNAssert(ArnI_CONTENT(DEE)->q, SUN_ERR_ARG_CORRUPT); + SUNAssert(ArnI_CONTENT(DEE)->Hes, SUN_ERR_ARG_CORRUPT); + + suncomplextype dom_eig_new; + dom_eig_new.real = ZERO; + dom_eig_new.imag = ZERO; + + int n = ArnI_CONTENT(DEE)->maxl; + + /* Reshape the Hessenberg matrix as an input vector for the LAPACK dgeev_ function */ + int i, j, k = 0; + for (i = 0; i < n; i++) { + for (j = 0; j < n; j++) { + ArnI_CONTENT(DEE)->LAPACK_A[k] = ArnI_CONTENT(DEE)->Hes[i][j]; + k++; + } + } + + int lda = n, ldvl = n, ldvr = n; + int info, lwork = 4 * n; + + char jobvl = 'N'; // Do not compute left eigenvectors + char jobvr = 'N'; // Do not compute right eigenvectors + + /* Call LAPACK's dgeev function */ + dgeev_(&jobvl, &jobvr, &n, ArnI_CONTENT(DEE)->LAPACK_A, &lda, ArnI_CONTENT(DEE)->LAPACK_wr, ArnI_CONTENT(DEE)->LAPACK_wi, NULL, &ldvl, NULL, &ldvr, ArnI_CONTENT(DEE)->LAPACK_work, &lwork, &info); + + if (info != 0) { + printf(SUNDOMEIGEST_LAPACK_FAIL, info); + + return SUN_ERR_DOMEIG_LAPACK_FAIL; + } + + /* order the eigenvalues by their magnitude */ + for (i = 0; i < n; i++) { + ArnI_CONTENT(DEE)->LAPACK_arr[i].real = ArnI_CONTENT(DEE)->LAPACK_wr[i]; + ArnI_CONTENT(DEE)->LAPACK_arr[i].imag = ArnI_CONTENT(DEE)->LAPACK_wi[i]; + } + + /* Sort the array using qsort */ + qsort(ArnI_CONTENT(DEE)->LAPACK_arr, n, sizeof(suncomplextype), domeig_Compare); + + /* Update the original arrays */ + for (i = 0; i < n; i++) { + ArnI_CONTENT(DEE)->LAPACK_wr[i] = ArnI_CONTENT(DEE)->LAPACK_arr[i].real; + ArnI_CONTENT(DEE)->LAPACK_wi[i] = ArnI_CONTENT(DEE)->LAPACK_arr[i].imag; + } + + // alternatively we can return a vector of all computed dom_eigs (up to maxl) + // TODO: Get opinions + + /* Copy the dominant eigenvalue */ + dom_eig_new.real = ArnI_CONTENT(DEE)->LAPACK_wr[0]; + dom_eig_new.imag = ArnI_CONTENT(DEE)->LAPACK_wi[0]; + + *dom_eig = dom_eig_new; + + return SUN_SUCCESS; +} + +SUNErrCode SUNDomEigEstFree_ArnI(SUNDomEigEstimator DEE) +{ + SUNFunctionBegin(DEE->sunctx); + + if (DEE == NULL) { return SUN_SUCCESS; } + + if (DEE->content) + { + /* delete items from within the content structure */ + if (ArnI_CONTENT(DEE)->q) + { + N_VDestroy(ArnI_CONTENT(DEE)->q); + ArnI_CONTENT(DEE)->q = NULL; + } + if (ArnI_CONTENT(DEE)->V) + { + N_VDestroyVectorArray(ArnI_CONTENT(DEE)->V, 1); + ArnI_CONTENT(DEE)->V = NULL; + } + if (ArnI_CONTENT(DEE)->LAPACK_A != NULL) + { + free(ArnI_CONTENT(DEE)->LAPACK_A); + ArnI_CONTENT(DEE)->LAPACK_A = NULL; + } + if (ArnI_CONTENT(DEE)->LAPACK_wr != NULL) + { + free(ArnI_CONTENT(DEE)->LAPACK_wr); + ArnI_CONTENT(DEE)->LAPACK_wr = NULL; + } + if (ArnI_CONTENT(DEE)->LAPACK_wi != NULL) + { + free(ArnI_CONTENT(DEE)->LAPACK_wi); + ArnI_CONTENT(DEE)->LAPACK_wi = NULL; + } + if (ArnI_CONTENT(DEE)->LAPACK_arr != NULL) + { + free(ArnI_CONTENT(DEE)->LAPACK_arr); + ArnI_CONTENT(DEE)->LAPACK_arr = NULL; + } + if (ArnI_CONTENT(DEE)->Hes != NULL) + { + free(ArnI_CONTENT(DEE)->Hes); + ArnI_CONTENT(DEE)->Hes = NULL; + } + + free(DEE->content); + DEE->content = NULL; + } + if (DEE->ops) + { + free(DEE->ops); + DEE->ops = NULL; + } + free(DEE); + DEE = NULL; + return SUN_SUCCESS; +} + +// Function to calculate the magnitude of a suncomplextype number +sunrealtype domeig_Magnitude(const suncomplextype *c) { + return sqrt(c->real * c->real + c->imag * c->imag); +} + +// Comparison function for qsort +int domeig_Compare(const void *a, const void *b) { + const suncomplextype *c1 = (const suncomplextype *)a; + const suncomplextype *c2 = (const suncomplextype *)b; + sunrealtype mag1 = domeig_Magnitude(c1); + sunrealtype mag2 = domeig_Magnitude(c2); + return (mag2 > mag1) - (mag2 < mag1); // Descending order +} \ No newline at end of file diff --git a/src/sundomeigest/PI/sundomeigest_pi.c b/src/sundomeigest/PI/sundomeigest_pi.c new file mode 100644 index 0000000000..130cae722b --- /dev/null +++ b/src/sundomeigest/PI/sundomeigest_pi.c @@ -0,0 +1,305 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Mustafa Aggul @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2025, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------- + * This is the implementation file for the Power Iteration (PI) + * implementation of the SUNDomEigEst package. + * ----------------------------------------------------------------- + */ + + #include +#include + +#include +#include +#include + +#include "sundials_logger_impl.h" +#include "sundials_macros.h" + +#define ZERO SUN_RCONST(0.0) + +/* + * ----------------------------------------------------------------- + * Power itetation structure accessibility macros: + * ----------------------------------------------------------------- + */ + +#define PI_CONTENT(DEE) ((SUNDomEigEstimatorContent_PI)(DEE->content)) + +/* + * ----------------------------------------------------------------- + * exported functions + * ----------------------------------------------------------------- + */ + +/* ---------------------------------------------------------------------------- + * Function to create a new PI estimator + */ + +SUNDomEigEstimator SUNDomEigEst_PI(N_Vector q, int max_powiter, SUNContext sunctx) +{ + SUNFunctionBegin(sunctx); + SUNDomEigEstimator DEE; + SUNDomEigEstimatorContent_PI content; + + /* check for legal q; if illegal return NULL */ + // TO DO: check required vector operations + SUNAssert(( + (q->ops->nvclone == NULL) || (q->ops->nvdestroy == NULL) || + (q->ops->nvdotprod == NULL) || (q->ops->nvscale == NULL) || + (q->ops->nvgetlength == NULL) || (q->ops->nvspace == NULL)), SUN_ERR_DOMEIG_BAD_NVECTOR); + + /* check for max_powiter values; if illegal use defaults */ + if (max_powiter <= 0) { max_powiter = SUNDOMEIGEST_MAX_PI_DEFAULT; } + + /* Create dominant eigenvalue estimator */ + DEE = NULL; + DEE = SUNDomEigEstNewEmpty (sunctx); + SUNCheckLastErrNull(); + + /* Attach operations */ + DEE->ops->gettype = SUNDomEigEst_PIGetType; + DEE->ops->setatimes = SUNDomEigEstSetATimes_PI; + DEE->ops->setmaxpoweriter = SUNDomEigEst_PISetMaxPowerIter; + DEE->ops->initialize = SUNDomEigEstInitialize_PI; + DEE->ops->preprocess = SUNDomEigEstPreProcess_PI; + DEE->ops->computehess = NULL; + DEE->ops->estimate = SUNDomEigEstimate_PI; + DEE->ops->getnumofiters = SUNDomEigEstNumIters_PI; + DEE->ops->free = SUNDomEigEstFree_PI; + + /* Create content */ + content = NULL; + content = (SUNDomEigEstimatorContent_PI)malloc(sizeof *content); + SUNAssertNull(content, SUN_ERR_MALLOC_FAIL); + + /* Attach content */ + DEE->content = content; + + /* Fill content */ + content->ATimes = NULL; + content->ATdata = NULL; + content->V = NULL; + content->q = NULL; + content->power_of_A = NULL; + content->powiter_tol = ZERO; + content->resnorm = ZERO; + content->max_powiter = max_powiter; + content->numiters = 0; + + /* Allocate content */ + content->q = N_VClone(q); + SUNCheckLastErrNull(); + + content->V = N_VCloneVectorArray(1, q); + SUNCheckLastErrNull(); + + return (DEE); +} + +/* + * ----------------------------------------------------------------- + * implementation of dominant eigenvalue estimator operations + * ----------------------------------------------------------------- + */ + +SUNDomEigEstimator_Type SUNDomEigEst_PIGetType(SUNDIALS_MAYBE_UNUSED SUNDomEigEstimator DEE) +{ + return (SUNDOMEIG_POWER); +} + +SUNErrCode SUNDomEigEstInitialize_PI(SUNDomEigEstimator DEE) +{ + SUNFunctionBegin(DEE->sunctx); + + if (PI_CONTENT(DEE)->powiter_tol <= 0) { PI_CONTENT(DEE)->powiter_tol = SUNDOMEIGEST_PI_TOL_DEFAULT; } + if (PI_CONTENT(DEE)->power_of_A <= 0) { PI_CONTENT(DEE)->power_of_A = SUNDOMEIGEST_PI_POWER_OF_A_DEFAULT; } + if (PI_CONTENT(DEE)->max_powiter <= 0) { PI_CONTENT(DEE)->max_powiter = SUNDOMEIGEST_MAX_PI_DEFAULT; } + + SUNAssert(PI_CONTENT(DEE)->ATimes, SUN_ERR_ARG_CORRUPT); + SUNAssert(PI_CONTENT(DEE)->V, SUN_ERR_ARG_CORRUPT); + SUNAssert(PI_CONTENT(DEE)->q, SUN_ERR_ARG_CORRUPT); + + N_VRandom(PI_CONTENT(DEE)->q); + SUNCheckLastErrNull(); + + /* Initialize the vector V */ + sunrealtype normq = N_VDotProd(PI_CONTENT(DEE)->q, PI_CONTENT(DEE)->q); + SUNCheckLastErrNull(); + + normq = SUNRsqrt(normq); + + N_VScale(ONE/normq, PI_CONTENT(DEE)->q, PI_CONTENT(DEE)->V); + SUNCheckLastErrNull(); + + return SUN_SUCCESS; +} + +SUNErrCode SUNDomEigEstSetATimes_PI(SUNDomEigEstimator DEE, void* A_data, SUNATimesFn ATimes) +{ + SUNFunctionBegin(DEE->sunctx); + + /* set function pointers to integrator-supplied ATimes routine + and data, and return with success */ + PI_CONTENT(DEE)->ATimes = ATimes; + PI_CONTENT(DEE)->ATdata = A_data; + return SUN_SUCCESS; +} + +SUNErrCode SUNDomEigEst_PISetMaxPowerIter(SUNDomEigEstimator DEE, int max_powiter) +{ + SUNFunctionBegin(DEE->sunctx); + + /* Check for legal number of iters */ + if (max_powiter <= 0) { max_powiter = SUNDOMEIGEST_MAX_PI_DEFAULT; } + + /* Set max iters */ + PI_CONTENT(DEE)->max_powiter = max_powiter; + return SUN_SUCCESS; +} + +SUNErrCode SUNDomEigEstPreProcess_PI(SUNDomEigEstimator DEE) +{ + SUNFunctionBegin(DEE->sunctx); + + SUNAssert(PI_CONTENT(DEE)->ATimes, SUN_ERR_ARG_CORRUPT); + SUNAssert(PI_CONTENT(DEE)->V, SUN_ERR_ARG_CORRUPT); + SUNAssert(PI_CONTENT(DEE)->q, SUN_ERR_ARG_CORRUPT); + + sunrealtype normq; + int i, retval; + + /* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ + for(i = 0; i < PI_CONTENT(DEE)->power_of_A; i++) + { + retval = PI_CONTENT(DEE)->ATimes(PI_CONTENT(DEE)->ATdata, PI_CONTENT(DEE)->V, PI_CONTENT(DEE)->q); + if (retval != 0) + { + if(retval < 0) + { + return SUN_ERR_DOMEIG_ATIMES_FAIL_UNREC; + } + else + { + return SUN_ERR_DOMEIG_ATIMES_FAIL_REC; + } + } + normq = N_VDotProd(PI_CONTENT(DEE)->q, PI_CONTENT(DEE)->q); + SUNCheckLastErr(); + + normq = SUNRsqrt(normq); + N_VScale(ONE/normq, PI_CONTENT(DEE)->q, PI_CONTENT(DEE)->V); + SUNCheckLastErr(); + } + + return SUN_SUCCESS; +} + +SUNErrCode SUNDomEigEstimate_PI(SUNDomEigEstimator DEE, suncomplextype* dom_eig) +{ + SUNFunctionBegin(DEE->sunctx); + + SUNAssert(dom_eig, SUN_ERR_ARG_CORRUPT); + SUNAssert(PI_CONTENT(DEE)->ATimes, SUN_ERR_ARG_CORRUPT); + SUNAssert(PI_CONTENT(DEE)->V, SUN_ERR_ARG_CORRUPT); + SUNAssert(PI_CONTENT(DEE)->q, SUN_ERR_ARG_CORRUPT); + SUNAssert((PI_CONTENT(DEE)->max_powiter < 0), SUN_ERR_ARG_CORRUPT); + + suncomplextype dom_eig_new, dom_eig_old; + + dom_eig_new.real = ZERO; + dom_eig_new.imag = ZERO; + dom_eig_old.real = ZERO; + dom_eig_old.imag = ZERO; + + int retval, k; + sunrealtype normq; + + for (k = 0; k < PI_CONTENT(DEE)->max_powiter; k++) + { + retval = PI_CONTENT(DEE)->ATimes(PI_CONTENT(DEE)->ATdata, PI_CONTENT(DEE)->V, PI_CONTENT(DEE)->q); + if (retval != 0) + { + if(retval < 0) + { + return SUN_ERR_DOMEIG_ATIMES_FAIL_UNREC; + } + else + { + return SUN_ERR_DOMEIG_ATIMES_FAIL_REC; + } + } + + dom_eig_new.real = N_VDotProd(PI_CONTENT(DEE)->V, PI_CONTENT(DEE)->q); //Rayleigh quotient + SUNCheckLastErr(); + + PI_CONTENT(DEE)->resnorm = fabs(dom_eig_new.real - dom_eig_old.real); + + if(PI_CONTENT(DEE)->resnorm < PI_CONTENT(DEE)->powiter_tol) + { + break; + } + + normq = N_VDotProd(PI_CONTENT(DEE)->q, PI_CONTENT(DEE)->q); + SUNCheckLastErr(); + + normq = SUNRsqrt(normq); + N_VScale(ONE/normq, PI_CONTENT(DEE)->q, PI_CONTENT(DEE)->V); + SUNCheckLastErr(); + + dom_eig_old.real = dom_eig_new.real; + } + + *dom_eig = dom_eig_new; + PI_CONTENT(DEE)->numiters = k; + + return SUN_SUCCESS; +} + +int SUNDomEigEstNumIters_PI(SUNDomEigEstimator DEE) +{ + return PI_CONTENT(DEE)->numiters; +} + +SUNErrCode SUNDomEigEstFree_PI(SUNDomEigEstimator DEE) +{ + SUNFunctionBegin(DEE->sunctx); + + if (DEE == NULL) { return SUN_SUCCESS; } + + if (DEE->content) + { + /* delete items from within the content structure */ + if (PI_CONTENT(DEE)->q) + { + N_VDestroy(PI_CONTENT(DEE)->q); + PI_CONTENT(DEE)->q = NULL; + } + if (PI_CONTENT(DEE)->V) + { + N_VDestroyVectorArray(PI_CONTENT(DEE)->V, 1); + PI_CONTENT(DEE)->V = NULL; + } + + free(DEE->content); + DEE->content = NULL; + } + if (DEE->ops) + { + free(DEE->ops); + DEE->ops = NULL; + } + free(DEE); + DEE = NULL; + return SUN_SUCCESS; +} From 8c4505492b44d4f8a0063db1802edbe3a8c7e206 Mon Sep 17 00:00:00 2001 From: maggul Date: Sat, 7 Jun 2025 18:10:13 -0500 Subject: [PATCH 022/128] first compiled version -- needs debugging --- include/arkode/arkode_lsrkstep.h | 2 +- ...impl.h => sundials_domeigestimator_impl.h} | 2 +- include/sundials/sundials_domeig.h | 102 ---- include/sundials/sundials_domeigestimator.h | 1 + ...omeigest_arnoldi.h => sundomeigest_arni.h} | 3 + src/CMakeLists.txt | 1 + src/arkode/CMakeLists.txt | 2 + src/arkode/arkode_lsrkstep.c | 84 +++- src/arkode/arkode_lsrkstep_impl.h | 23 +- src/arkode/arkode_lsrkstep_io.c | 6 +- src/sundials/CMakeLists.txt | 4 +- src/sundials/sundials_domeig.c | 457 ------------------ src/sundials/sundials_domeigestimator.c | 25 +- src/sundomeigest/ArnI/CMakeLists.txt | 32 ++ src/sundomeigest/ArnI/sundomeigest_arni.c | 64 ++- src/sundomeigest/CMakeLists.txt | 22 + src/sundomeigest/PI/CMakeLists.txt | 31 ++ src/sundomeigest/PI/sundomeigest_pi.c | 27 +- .../arkode/CXX_parallel/CMakeLists.txt | 2 + .../arkode/CXX_serial/CMakeLists.txt | 2 + .../unit_tests/arkode/C_serial/CMakeLists.txt | 2 + test/unit_tests/sundials/CMakeLists.txt | 8 +- test/unit_tests/sundials/test_domeig.c | 55 ++- 23 files changed, 290 insertions(+), 667 deletions(-) rename include/sundials/priv/{sundials_domeig_impl.h => sundials_domeigestimator_impl.h} (97%) delete mode 100644 include/sundials/sundials_domeig.h rename include/sundomeigest/{sundomeigest_arnoldi.h => sundomeigest_arni.h} (96%) delete mode 100644 src/sundials/sundials_domeig.c create mode 100644 src/sundomeigest/ArnI/CMakeLists.txt create mode 100644 src/sundomeigest/CMakeLists.txt create mode 100644 src/sundomeigest/PI/CMakeLists.txt diff --git a/include/arkode/arkode_lsrkstep.h b/include/arkode/arkode_lsrkstep.h index bb879941c4..8fe11676df 100644 --- a/include/arkode/arkode_lsrkstep.h +++ b/include/arkode/arkode_lsrkstep.h @@ -18,7 +18,7 @@ #define _LSRKSTEP_H #include -#include +#include #ifdef __cplusplus /* wrapper to enable C++ usage */ extern "C" { diff --git a/include/sundials/priv/sundials_domeig_impl.h b/include/sundials/priv/sundials_domeigestimator_impl.h similarity index 97% rename from include/sundials/priv/sundials_domeig_impl.h rename to include/sundials/priv/sundials_domeigestimator_impl.h index c803b888c8..3962ea84f5 100644 --- a/include/sundials/priv/sundials_domeig_impl.h +++ b/include/sundials/priv/sundials_domeigestimator_impl.h @@ -18,7 +18,7 @@ #ifndef _DOMEIG_IMPL_H #define _DOMEIG_IMPL_H -#include +#include #include #ifdef __cplusplus /* wrapper to enable C++ usage */ diff --git a/include/sundials/sundials_domeig.h b/include/sundials/sundials_domeig.h deleted file mode 100644 index bc2bbf2ebb..0000000000 --- a/include/sundials/sundials_domeig.h +++ /dev/null @@ -1,102 +0,0 @@ -/* ----------------------------------------------------------------- - * Programmer(s): Mustafa Aggul @ SMU - * ----------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2025, Lawrence Livermore National Security - * and Southern Methodist University. - * All rights reserved. - * - * See the top-level LICENSE and NOTICE files for details. - * - * SPDX-License-Identifier: BSD-3-Clause - * SUNDIALS Copyright End - * ----------------------------------------------------------------- - * This is the header file for the eigenvalue estimation of - * the SUNDOMEIG package. - * -----------------------------------------------------------------*/ - -#ifndef _DOMEIG_H -#define _DOMEIG_H - -#include /* serial N_Vector types, fcts., macros */ -#include -#include -#include "sundials/sundials_errors.h" -#include - -#ifdef __cplusplus /* wrapper to enable C++ usage */ -extern "C" { -#endif - -/* Default DOMEIG parameters */ -#define DEFAULT_POWER_OF_A 0 -#define DEFAULT_POWER_ITER_TOL SUN_RCONST(0.01) -#define DEFAULT_MAX_POWER_ITER 100 - -/*=============================================================== - DOMEIG module data structure - ===============================================================*/ - -// Struct to hold the real and imaginary parts -typedef struct { - sunrealtype real; - sunrealtype imag; -} suncomplextype; - -/*--------------------------------------------------------------- - Types : struct DOMEIGMemRec, DOMEIGMem - --------------------------------------------------------------- - The type DOMEIGMem is type pointer to struct - DOMEIGMemRec. This structure contains fields to - perform an DOMEIG iteration. - ---------------------------------------------------------------*/ -typedef struct DOMEIGMemRec -{ - SUNContext sunctx; - - /* DOMEIG MEMORY specification */ - SUNATimesFn ATimes; /* User provided ATimes function */ - void* Adata; /* ATimes function data*/ - - N_Vector *V, q; /* Krylov subspace vectors */ - - int maxl; /* Krylov subspace dimension */ - int length; /* Problem dimension */ - int power_of_A; /* Power of A in the preprocessing; initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ - - sunrealtype powiter_tol; /* Convergence criteria for the power iteration */ - int max_powiter; /* Maximum number of power iterations */ - - sunrealtype* LAPACK_A; /* The vector which holds rows of the Hessenberg matrix in the given order */ - sunrealtype* LAPACK_wr; /* Real parts of eigenvalues */ - sunrealtype* LAPACK_wi; /* Imaginary parts of eigenvalues */ - sunrealtype* LAPACK_work; /* Workspace array */ - suncomplextype* LAPACK_arr; /* an array to sort eigenvalues*/ - - sunrealtype **Hes; /* Hessenberg matrix Hes */ -}* DOMEIGMem; - -/* ------------------------------------- - * Exported Functions for DOMEIG - * ------------------------------------- */ - -/* Creation and Estimation functions */ - -SUNDIALS_EXPORT SUNErrCode DomEigCreate(SUNATimesFn ATimes, void* Adata, - N_Vector q, int maxl, SUNContext sunctx, void** domeig_mem_out); - -SUNDIALS_EXPORT SUNErrCode DomEigPreProcess(DOMEIGMem domeig_mem); - -SUNDIALS_EXPORT SUNErrCode DomEigComputeHess(DOMEIGMem domeig_mem); - -SUNDIALS_EXPORT SUNErrCode DomEigPowerIteration(DOMEIGMem domeig_mem, suncomplextype* dom_eig); - -SUNDIALS_EXPORT SUNErrCode DomEigEstimate(DOMEIGMem domeig_mem, suncomplextype* dom_eig); - -SUNDIALS_EXPORT void DomEigDestroy(void** domeig_mem); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/include/sundials/sundials_domeigestimator.h b/include/sundials/sundials_domeigestimator.h index 446cba549f..8b285975ae 100644 --- a/include/sundials/sundials_domeigestimator.h +++ b/include/sundials/sundials_domeigestimator.h @@ -59,6 +59,7 @@ struct _generic_SUNDomEigEstimator_Ops SUNDomEigEstimator_Type (*gettype)(SUNDomEigEstimator); SUNErrCode (*setatimes)(SUNDomEigEstimator, void*, SUNATimesFn); SUNErrCode (*setmaxpoweriter)(SUNDomEigEstimator, int); + SUNErrCode (*setnumofperprocess)(SUNDomEigEstimator, int); SUNErrCode (*initialize)(SUNDomEigEstimator); SUNErrCode (*preprocess)(SUNDomEigEstimator); SUNErrCode (*computehess)(SUNDomEigEstimator); diff --git a/include/sundomeigest/sundomeigest_arnoldi.h b/include/sundomeigest/sundomeigest_arni.h similarity index 96% rename from include/sundomeigest/sundomeigest_arnoldi.h rename to include/sundomeigest/sundomeigest_arni.h index e239b7ee5d..a0013bdfbd 100644 --- a/include/sundomeigest/sundomeigest_arnoldi.h +++ b/include/sundomeigest/sundomeigest_arni.h @@ -76,6 +76,9 @@ SUNErrCode SUNDomEigEstSetATimes_ArnI(SUNDomEigEstimator DEE, void* A_data, SUNDIALS_EXPORT SUNErrCode SUNDomEigEstInitialize_ArnI(SUNDomEigEstimator DEE); +SUNDIALS_EXPORT +SUNErrCode SUNDomEigEstSetNumofPreProcess_ArnI(SUNDomEigEstimator DEE, int numofperprocess); + SUNDIALS_EXPORT SUNErrCode SUNDomEigEstPreProcess_ArnI(SUNDomEigEstimator DEE); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0cae493ce7..8569d83a1c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -24,6 +24,7 @@ add_subdirectory(sunnonlinsol) add_subdirectory(sunmemory) add_subdirectory(sunadaptcontroller) add_subdirectory(sunadjointcheckpointscheme) +add_subdirectory(sundomeigest) # ARKODE library if(BUILD_ARKODE) diff --git a/src/arkode/CMakeLists.txt b/src/arkode/CMakeLists.txt index ff57c62a3c..b46d5ab05c 100644 --- a/src/arkode/CMakeLists.txt +++ b/src/arkode/CMakeLists.txt @@ -99,6 +99,8 @@ sundials_add_library( sundials_sunnonlinsolnewton_obj sundials_sunnonlinsolfixedpoint_obj sundials_adjointcheckpointscheme_fixed_obj + sundials_sundomeigestpi_obj + sundials_sundomeigestarni_obj OUTPUT_NAME sundials_arkode VERSION ${arkodelib_VERSION} SOVERSION ${arkodelib_SOVERSION}) diff --git a/src/arkode/arkode_lsrkstep.c b/src/arkode/arkode_lsrkstep.c index 9ad2409607..28f23d19f4 100644 --- a/src/arkode/arkode_lsrkstep.c +++ b/src/arkode/arkode_lsrkstep.c @@ -196,8 +196,8 @@ void* lsrkStep_Create_Commons(ARKRhsFn rhs, sunrealtype t0, N_Vector y0, /* Set NULL for dom_eig_fn */ step_mem->dom_eig_fn = NULL; - /* Set NULL for domeig_mem */ - step_mem->domeig_mem = NULL; + /* Set NULL for DEE */ + step_mem->DEE = NULL; /* Set NULL for domeig_q */ step_mem->domeig_q = NULL; @@ -332,7 +332,7 @@ int lsrkStep_Init(ARKodeMem ark_mem, SUNDIALS_MAYBE_UNUSED sunrealtype tout, } /* Check if user has provided dom_eig_fn */ - if (!step_mem->is_SSP && step_mem->dom_eig_fn == NULL && step_mem->domeig_mem == NULL) + if (!step_mem->is_SSP && step_mem->dom_eig_fn == NULL && step_mem->DEE == NULL) { arkProcessError(ark_mem, ARK_DOMEIG_FAIL, __LINE__, __func__, __FILE__, "STS methods require either a user provided or an internal dominant eigenvalue estimation"); @@ -2206,7 +2206,7 @@ int lsrkStep_ComputeNewDomEig(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem) if(step_mem->dom_eig_fn == NULL) { - dom_eig = lsrkStep_DomEigEstimate(ark_mem, step_mem->domeig_mem); + dom_eig = lsrkStep_DomEigEstimate(ark_mem, step_mem->DEE); if((dom_eig.real*dom_eig.real + dom_eig.imag*dom_eig.imag) < SUN_SMALL_REAL) { arkProcessError(ark_mem, ARK_DOMEIG_FAIL, __LINE__, __func__, __FILE__, @@ -2278,9 +2278,9 @@ int lsrkStep_ComputeNewDomEig(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem) function pointers from arkode_mem. ---------------------------------------------------------------*/ -void* lsrkStep_DomEigCreate(void* arkode_mem) +SUNDomEigEstimator lsrkStep_DomEigCreate(void* arkode_mem) { - DOMEIGMem domeig_mem; + SUNDomEigEstimator DEE; ARKodeMem ark_mem; ARKodeLSRKStepMem step_mem; int retval; @@ -2301,14 +2301,70 @@ void* lsrkStep_DomEigCreate(void* arkode_mem) step_mem->domeig_rhs = step_mem->fe; /* Allocate and fill domeig_q vector with random data */ + /* TODO: check if we have to clone or just passing yn is ok! */ step_mem->domeig_q = N_VClone(ark_mem->yn); - N_VRandom(step_mem->domeig_q); step_mem->domeig_maxl = DOMEIG_MAXL_DEFAULT; + step_mem->domeig_power_of_A = DOMEIG_POWER_OF_A_DEFAULT; + step_mem->domeig_maxiters = DOMEIG_MAX_NUMBER_OF_POWER_ITERS_DEFAULT; - retval = DomEigCreate(lsrkStep_DQJtimes, arkode_mem, step_mem->domeig_q, step_mem->domeig_maxl, ark_mem->sunctx, (void**)&domeig_mem); - if (retval != ARK_SUCCESS) { return NULL; } + /* Default estimator for the problems sized < 2 is Power Iteration; + Arnoldi iterations, otherwise*/ + /* TODO: Also check if LAPACK enabled */ + if(ark_mem->yn->ops->nvgetlength(ark_mem->yn) > 2) + { + DEE = SUNDomEigEst_ArnI(step_mem->domeig_q, step_mem->domeig_maxl, ark_mem->sunctx); + if (DEE == NULL) + { + arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, + MSG_ARK_INTERNAL_DOMEIG_FAIL); + return NULL; + } + } + else + { + DEE = SUNDomEigEst_PI(step_mem->domeig_q, step_mem->domeig_maxiters, ark_mem->sunctx); + if (DEE == NULL) + { + arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, + MSG_ARK_INTERNAL_DOMEIG_FAIL); + return NULL; + } + } + + /* Set Atimes*/ + retval = DEE->ops->setatimes(DEE, arkode_mem, lsrkStep_DQJtimes); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, + MSG_ARK_INTERNAL_DOMEIG_FAIL); + return NULL; + } + + /* Set Max Power Itetations*/ + if(DEE->ops->setmaxpoweriter != NULL) + { + retval = DEE->ops->setmaxpoweriter(DEE, step_mem->domeig_maxiters); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, + MSG_ARK_INTERNAL_DOMEIG_FAIL); + return NULL; + } + } + + /* Set the number of preprocessings */ + if(DEE->ops->setnumofperprocess != NULL) + { + retval = DEE->ops->setnumofperprocess(DEE, step_mem->domeig_power_of_A); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, + MSG_ARK_INTERNAL_DOMEIG_FAIL); + return NULL; + } + } - return (void*)domeig_mem; + return DEE; } /*--------------------------------------------------------------- @@ -2316,7 +2372,7 @@ void* lsrkStep_DomEigCreate(void* arkode_mem) This routine estimates the dominant eigenvalue. ---------------------------------------------------------------*/ -suncomplextype lsrkStep_DomEigEstimate(void* arkode_mem, DOMEIGMem domeig_mem) +suncomplextype lsrkStep_DomEigEstimate(void* arkode_mem, SUNDomEigEstimator DEE) { ARKodeMem ark_mem; @@ -2341,7 +2397,7 @@ suncomplextype lsrkStep_DomEigEstimate(void* arkode_mem, DOMEIGMem domeig_mem) } /* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ - retval = DomEigPreProcess(domeig_mem); + retval = DEE->ops->preprocess(DEE); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, @@ -2351,7 +2407,7 @@ suncomplextype lsrkStep_DomEigEstimate(void* arkode_mem, DOMEIGMem domeig_mem) } /* Compute the Hessenberg matrix Hes*/ - retval = DomEigComputeHess(domeig_mem); + retval = DEE->ops->computehess(DEE); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, @@ -2360,7 +2416,7 @@ suncomplextype lsrkStep_DomEigEstimate(void* arkode_mem, DOMEIGMem domeig_mem) return dom_eig; } - retval = DomEigEstimate(domeig_mem, &dom_eig); + retval = DEE->ops->estimate(DEE, &dom_eig); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, diff --git a/src/arkode/arkode_lsrkstep_impl.h b/src/arkode/arkode_lsrkstep_impl.h index c6512956bf..c7b9b4e54b 100644 --- a/src/arkode/arkode_lsrkstep_impl.h +++ b/src/arkode/arkode_lsrkstep_impl.h @@ -19,7 +19,9 @@ #define _ARKODE_LSRKSTEP_IMPL_H #include -#include +#include +#include +#include #include "arkode_impl.h" @@ -27,10 +29,12 @@ extern "C" { #endif -#define STAGE_MAX_LIMIT_DEFAULT 200 -#define DOM_EIG_SAFETY_DEFAULT SUN_RCONST(1.01) -#define DOM_EIG_FREQ_DEFAULT 25 -#define DOMEIG_MAXL_DEFAULT 3 +#define STAGE_MAX_LIMIT_DEFAULT 200 +#define DOM_EIG_SAFETY_DEFAULT SUN_RCONST(1.01) +#define DOM_EIG_FREQ_DEFAULT 25 +#define DOMEIG_MAXL_DEFAULT 3 +#define DOMEIG_POWER_OF_A_DEFAULT 0 +#define DOMEIG_MAX_NUMBER_OF_POWER_ITERS_DEFAULT 100 /*=============================================================== LSRK time step module private math function macros @@ -157,9 +161,12 @@ typedef struct ARKodeLSRKStepMemRec sunrealtype spectral_radius_min; /* min spectral radius*/ sunrealtype dom_eig_safety; /* some safety factor for the user provided dom_eig*/ long int dom_eig_freq; /* indicates dom_eig update after dom_eig_freq successful steps*/ - void* domeig_mem; /* DomEig memory */ + + SUNDomEigEstimator DEE; /* DomEig estimator*/ N_Vector domeig_q; /* DomEig initial q vector*/ int domeig_maxl; /* Krylov subspace dimension */ + int domeig_power_of_A; /* Power of A for the warm-up */ + int domeig_maxiters; /* Max number of Power Iterations */ /* Flags */ sunbooleantype dom_eig_update; /* flag indicating new dom_eig is needed */ @@ -210,8 +217,8 @@ int lsrkStep_AccessStepMem(ARKodeMem ark_mem, const char* fname, void lsrkStep_DomEigUpdateLogic(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem, sunrealtype dsm); int lsrkStep_ComputeNewDomEig(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem); -void* lsrkStep_DomEigCreate(void* arkode_mem); -suncomplextype lsrkStep_DomEigEstimate(void* arkode_mem, DOMEIGMem DomEig_mem); +SUNDomEigEstimator lsrkStep_DomEigCreate(void* arkode_mem); +suncomplextype lsrkStep_DomEigEstimate(void* arkode_mem, SUNDomEigEstimator DEE); int lsrkStep_DQJtimes(void* arkode_mem, N_Vector v, N_Vector Jv); /*=============================================================== diff --git a/src/arkode/arkode_lsrkstep_io.c b/src/arkode/arkode_lsrkstep_io.c index ab618cfc1c..1a748b176f 100644 --- a/src/arkode/arkode_lsrkstep_io.c +++ b/src/arkode/arkode_lsrkstep_io.c @@ -219,8 +219,8 @@ int LSRKStepSetDomEigFn(void* arkode_mem, ARKDomEigFn dom_eig) { step_mem->dom_eig_fn = NULL; - step_mem->domeig_mem = lsrkStep_DomEigCreate(arkode_mem); - if (step_mem->domeig_mem == NULL) + step_mem->DEE = lsrkStep_DomEigCreate(arkode_mem); + if (step_mem->DEE == NULL) { arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, "Internal domeig_mem is NULL"); @@ -526,6 +526,8 @@ int lsrkStep_SetDefaults(ARKodeMem ark_mem) step_mem->spectral_radius_min = ZERO; step_mem->dom_eig_safety = DOM_EIG_SAFETY_DEFAULT; step_mem->dom_eig_freq = DOM_EIG_FREQ_DEFAULT; + step_mem->domeig_maxl = DOMEIG_MAXL_DEFAULT; + step_mem->domeig_power_of_A = DOMEIG_POWER_OF_A_DEFAULT; /* Flags */ step_mem->dom_eig_update = SUNTRUE; diff --git a/src/sundials/CMakeLists.txt b/src/sundials/CMakeLists.txt index 8a57095fc3..34254f15e2 100644 --- a/src/sundials/CMakeLists.txt +++ b/src/sundials/CMakeLists.txt @@ -73,7 +73,7 @@ if(ENABLE_SYCL) endif() if(ENABLE_LAPACK) - list(APPEND sundials_HEADERS sundials_domeig.h) + list(APPEND sundials_HEADERS sundials_domeigestimator.h) endif() # If enabled, add the XBraid interface header @@ -115,7 +115,7 @@ if(ENABLE_MPI) endif() if(ENABLE_LAPACK) - list(APPEND sundials_SOURCES sundials_domeig.c) + list(APPEND sundials_SOURCES sundials_domeigestimator.c) set(_link_lapack_if_needed PUBLIC LAPACK::LAPACK) if(CMAKE_VERSION VERSION_LESS 3.20) list(APPEND _link_lapack_if_needed BLAS::BLAS) diff --git a/src/sundials/sundials_domeig.c b/src/sundials/sundials_domeig.c deleted file mode 100644 index e256563ec2..0000000000 --- a/src/sundials/sundials_domeig.c +++ /dev/null @@ -1,457 +0,0 @@ -/* ----------------------------------------------------------------- - * Programmer(s): Mustafa Aggul @ SMU - * ----------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2025, Lawrence Livermore National Security - * and Southern Methodist University. - * All rights reserved. - * - * See the top-level LICENSE and NOTICE files for details. - * - * SPDX-License-Identifier: BSD-3-Clause - * SUNDIALS Copyright End - * ----------------------------------------------------------------- - * This is the implementation file for the eigenvalue estimation of - * the SUNDOMEIG package. - * -----------------------------------------------------------------*/ - -#include -#include - -#include -#include -#include - -#define ZERO SUN_RCONST(0.0) - -/* - * ----------------------------------------------------------------- - * exported functions - * ----------------------------------------------------------------- - */ - -SUNErrCode DomEigCreate(SUNATimesFn ATimes, void* Adata, - N_Vector q, int maxl, SUNContext sunctx, void** domeig_mem_out) -{ - SUNFunctionBegin(sunctx); - DOMEIGMem domeig_mem; - - /* Test if Atimes and q are provided */ - if (ATimes == NULL || q == NULL) - { - return SUN_ERR_DOMEIG_NULL_ATIMES; - } - - /* Check if maxl >= 2 */ - if (maxl < 2) - { - return SUN_ERR_DOMEIG_NOT_ENOUGH_ITER; - } - - /* Test if all required vector operations are implemented */ - SUNCheckCall(domeig_CheckNVector(q)); - - /* Allocate DOMEIGMem structure, and initialize to zero */ - domeig_mem = (DOMEIGMem)calloc(1, sizeof(*domeig_mem)); - SUNAssert(domeig_mem, SUN_ERR_MALLOC_FAIL); - - /* Copy the inputs into DOMEIG memory */ - domeig_mem->sunctx = q->sunctx; - domeig_mem->ATimes = ATimes; - domeig_mem->Adata = Adata; - domeig_mem->q = q; - domeig_mem->maxl = maxl; - domeig_mem->length = q->ops->nvgetlength(q); - - /* Set the default power of A to start with (# of warm-ups) */ - domeig_mem->power_of_A = DEFAULT_POWER_OF_A; - - /* Set the default tolerance of the power iteration */ - domeig_mem->powiter_tol = DEFAULT_POWER_ITER_TOL; - - /* Set the default max number of the power iteration */ - domeig_mem->max_powiter = DEFAULT_MAX_POWER_ITER; - - if (domeig_mem->length > 2) - { - domeig_mem->LAPACK_A = (sunrealtype*)malloc((maxl*maxl) * sizeof(sunrealtype)); - domeig_mem->LAPACK_wr = malloc(maxl * sizeof(sunrealtype)); - domeig_mem->LAPACK_wi = malloc(maxl * sizeof(sunrealtype)); - domeig_mem->LAPACK_work = malloc((4 * maxl) * sizeof(sunrealtype)); - domeig_mem->LAPACK_arr = (suncomplextype *)malloc(maxl * sizeof(suncomplextype)); - } - - /* Hessenberg matrix Hes */ - if (domeig_mem->Hes == NULL && domeig_mem->length > 2) - { - int k; - domeig_mem->Hes = - (sunrealtype**)malloc((maxl + 1) * sizeof(sunrealtype*)); - - for (k = 0; k <= maxl; k++) - { - domeig_mem->Hes[k] = NULL; - domeig_mem->Hes[k] = (sunrealtype*)malloc(maxl * sizeof(sunrealtype)); - } - } - - /* Krylov subspace vectors */ - if (domeig_mem->V == NULL) - { - if(domeig_mem->length > 2) - { - domeig_mem->V = N_VCloneVectorArray(maxl + 1, q); - } - else - { - domeig_mem->V = N_VCloneVectorArray(1, q); - } - } - - /* Unitize the initial vector V[0] */ - sunrealtype normq = N_VDotProd(q, q); - normq = SUNRsqrt(normq); - N_VScale(SUN_RCONST(1.0)/normq, domeig_mem->q, domeig_mem->V[0]); - - *domeig_mem_out = (void*)domeig_mem; - - return SUN_SUCCESS; -} - -/* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ -SUNErrCode DomEigPreProcess(DOMEIGMem domeig_mem) -{ - SUNFunctionBegin(domeig_mem->sunctx); - - int retval; - - /* Check if ATimes is provided */ - if(domeig_mem->ATimes == NULL) - { - return SUN_ERR_DOMEIG_NULL_ATIMES; - } - - sunrealtype normq; - int i; - - /* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ - for(i = 0; i < domeig_mem->power_of_A; i++) { - retval = domeig_mem->ATimes(domeig_mem->Adata, domeig_mem->V[0], domeig_mem->q); - if (retval != 0) - { - DomEigDestroy((void**)&domeig_mem); - - if(retval < 0) - { - return SUN_ERR_DOMEIG_ATIMES_FAIL_UNREC; - } - else - { - return SUN_ERR_DOMEIG_ATIMES_FAIL_REC; - } - } - normq = N_VDotProd(domeig_mem->q, domeig_mem->q); - SUNCheckLastErr(); - - normq = SUNRsqrt(normq); - N_VScale(SUN_RCONST(1.0)/normq, domeig_mem->q, domeig_mem->V[0]); - SUNCheckLastErr(); - } - - return SUN_SUCCESS; -} - -/* Compute the Hessenberg matrix DomEig_mem->Hes*/ -SUNErrCode DomEigComputeHess(DOMEIGMem domeig_mem) -{ - SUNFunctionBegin(domeig_mem->sunctx); - - /* Check if the dim of the matrix is less than 3. - Return immediately if dim <= 2; - no need to compute Hessenberg matrix - since the default is power iteration for dim <= 2 */ - if(domeig_mem->length < 3) - { - return SUN_SUCCESS; - } - - /* Check if ATimes is provided */ - if(domeig_mem->ATimes == NULL) - { - return SUN_ERR_DOMEIG_NULL_ATIMES; - } - - /* Check if Hes is allocated */ - if(domeig_mem->Hes == NULL) - { - return SUN_ERR_DOMEIG_NULL_HES; - } - - int retval, i, j; - /* Initialize the Hessenberg matrix Hes with zeros */ - for (i = 0; i < domeig_mem->maxl; i++) - { - for (j = 0; j < domeig_mem->maxl; j++) { domeig_mem->Hes[i][j] = ZERO; } - } - - for (i = 0; i < domeig_mem->maxl; i++) - { - /* Compute the next Krylov vector */ - retval = domeig_mem->ATimes(domeig_mem->Adata, domeig_mem->V[i], domeig_mem->V[i+1]); - if (retval != 0) - { - DomEigDestroy((void**)&domeig_mem); - - if(retval < 0) - { - return SUN_ERR_DOMEIG_ATIMES_FAIL_UNREC; - } - else - { - return SUN_ERR_DOMEIG_ATIMES_FAIL_REC; - } - } - - SUNCheckCall(SUNModifiedGS(domeig_mem->V, domeig_mem->Hes, i + 1, domeig_mem->maxl, &(domeig_mem->Hes[i + 1][i]))); - - /* Unitize the computed orthogonal vector */ - N_VScale(SUN_RCONST(1.0)/domeig_mem->Hes[i + 1][i], domeig_mem->V[i+1], domeig_mem->V[i+1]); - SUNCheckLastErr(); - } - - return SUN_SUCCESS; -} - -SUNErrCode DomEigPowerIteration(DOMEIGMem domeig_mem, suncomplextype* dom_eig) -{ - SUNFunctionBegin(domeig_mem->sunctx); - - /* Check if ATimes is provided */ - if(domeig_mem->ATimes == NULL) - { - return SUN_ERR_DOMEIG_NULL_ATIMES; - } - - suncomplextype dom_eig_new = *dom_eig; - suncomplextype dom_eig_old; - - dom_eig_new.real = ZERO; - dom_eig_new.imag = ZERO; - dom_eig_old.real = ZERO; - dom_eig_old.imag = ZERO; - - int retval, k; - sunrealtype normq; - - for (k = 0; k < domeig_mem->max_powiter; k++) - { - retval = domeig_mem->ATimes(domeig_mem->Adata, domeig_mem->V[0], domeig_mem->q); - if (retval != 0) - { - DomEigDestroy((void**)&domeig_mem); - - if(retval < 0) - { - return SUN_ERR_DOMEIG_ATIMES_FAIL_UNREC; - } - else - { - return SUN_ERR_DOMEIG_ATIMES_FAIL_REC; - } - } - - dom_eig_new.real = N_VDotProd(domeig_mem->V[0], domeig_mem->q); //Rayleigh quotient - SUNCheckLastErr(); - - if(fabs(dom_eig_new.real - dom_eig_old.real) < domeig_mem->powiter_tol) - { - break; - } - - normq = N_VDotProd(domeig_mem->q, domeig_mem->q); - SUNCheckLastErr(); - - normq = SUNRsqrt(normq); - N_VScale(SUN_RCONST(1.0)/normq, domeig_mem->q, domeig_mem->V[0]); - SUNCheckLastErr(); - - dom_eig_old.real = dom_eig_new.real; - } - - *dom_eig = dom_eig_new; - - return SUN_SUCCESS; -} - -/* Estimate the dominant eigvalues of the Hessenberg matrix or - run power iterations for problem size less than 3 */ -SUNErrCode DomEigEstimate(DOMEIGMem domeig_mem, suncomplextype* dom_eig) -{ - SUNFunctionBegin(domeig_mem->sunctx); - - suncomplextype dom_eig_new; - dom_eig_new.real = ZERO; - dom_eig_new.imag = ZERO; - - /* run power iterations for problem size less than 3 */ - if(domeig_mem->length < 3) - { - SUNCheckCall(DomEigPowerIteration(domeig_mem, &dom_eig_new)); - - *dom_eig = dom_eig_new; - - return SUN_SUCCESS; - } - - /* Check if Hes is allocated */ - if(domeig_mem->Hes == NULL) - { - return SUN_ERR_DOMEIG_NULL_HES; - } - - int n = domeig_mem->maxl; - - /* Reshape the Hessenberg matrix as an input vector for the LAPACK dgeev_ function */ - int i, j, k = 0; - for (i = 0; i < n; i++) { - for (j = 0; j < n; j++) { - domeig_mem->LAPACK_A[k] = domeig_mem->Hes[i][j]; - k++; - } - } - - int lda = n, ldvl = n, ldvr = n; - int info, lwork = 4 * n; - - char jobvl = 'N'; // Do not compute left eigenvectors - char jobvr = 'N'; // Do not compute right eigenvectors - - /* Call LAPACK's dgeev function */ - dgeev_(&jobvl, &jobvr, &n, domeig_mem->LAPACK_A, &lda, domeig_mem->LAPACK_wr, domeig_mem->LAPACK_wi, NULL, &ldvl, NULL, &ldvr, domeig_mem->LAPACK_work, &lwork, &info); - - if (info != 0) { - printf(MSG_DOMEIG_LAPACK_FAIL, info); - DomEigDestroy((void**)&domeig_mem); - - return SUN_ERR_DOMEIG_LAPACK_FAIL; - } - - /* order the eigenvalues by their magnitude */ - for (i = 0; i < n; i++) { - domeig_mem->LAPACK_arr[i].real = domeig_mem->LAPACK_wr[i]; - domeig_mem->LAPACK_arr[i].imag = domeig_mem->LAPACK_wi[i]; - } - - /* Sort the array using qsort */ - qsort(domeig_mem->LAPACK_arr, n, sizeof(suncomplextype), domeig_Compare); - - /* Update the original arrays */ - for (i = 0; i < n; i++) { - domeig_mem->LAPACK_wr[i] = domeig_mem->LAPACK_arr[i].real; - domeig_mem->LAPACK_wi[i] = domeig_mem->LAPACK_arr[i].imag; - } - - // alternatively we can return a vector of all computed dom_eigs (up to maxl) - // TODO: Get opinions - - /* Copy the dominant eigenvalue */ - dom_eig_new.real = domeig_mem->LAPACK_wr[0]; - dom_eig_new.imag = domeig_mem->LAPACK_wi[0]; - - *dom_eig = dom_eig_new; - - return SUN_SUCCESS; -} - -/*=============================================================== - Internal utility routines - ===============================================================*/ - -/*--------------------------------------------------------------- - domeig_CheckNVector: - - This routine checks if all required vector operations are - present. If any of them is missing it returns the corresponding - SUNErrCode. - ---------------------------------------------------------------*/ -SUNErrCode domeig_CheckNVector(N_Vector tmpl) -{ // TO DO: check required vector operations - if ((tmpl->ops->nvclone == NULL) || (tmpl->ops->nvdestroy == NULL) || - (tmpl->ops->nvdotprod == NULL) || (tmpl->ops->nvscale == NULL) || - (tmpl->ops->nvgetlength == NULL) || (tmpl->ops->nvspace == NULL)) - { - return SUN_ERR_DOMEIG_BAD_NVECTOR; - } - return SUN_SUCCESS; -} - -// Function to calculate the magnitude of a suncomplextype number -sunrealtype domeig_Magnitude(const suncomplextype *c) { - return sqrt(c->real * c->real + c->imag * c->imag); -} - -// Comparison function for qsort -int domeig_Compare(const void *a, const void *b) { - const suncomplextype *c1 = (const suncomplextype *)a; - const suncomplextype *c2 = (const suncomplextype *)b; - sunrealtype mag1 = domeig_Magnitude(c1); - sunrealtype mag2 = domeig_Magnitude(c2); - return (mag2 > mag1) - (mag2 < mag1); // Descending order -} - -/*--------------------------------------------------------------- - DomEigDestroy frees all DomEig memory. - ---------------------------------------------------------------*/ -void DomEigDestroy(void** domeig_mem) -{ - DOMEIGMem dom_eig_mem; - - /* nothing to do if domeig_mem is already NULL */ - if (*domeig_mem == NULL) { return; } - - dom_eig_mem = (DOMEIGMem)(*domeig_mem); - - if (dom_eig_mem->q != NULL) - { - N_VDestroy(dom_eig_mem->q); - dom_eig_mem->q = NULL; - } - if (dom_eig_mem->V != NULL) - { - N_VDestroyVectorArray(dom_eig_mem->V, dom_eig_mem->maxl + 1); - dom_eig_mem->V = NULL; - } - - if (dom_eig_mem->LAPACK_A != NULL) - { - free(dom_eig_mem->LAPACK_A); - dom_eig_mem->LAPACK_A = NULL; - } - - if (dom_eig_mem->LAPACK_wr != NULL) - { - free(dom_eig_mem->LAPACK_wr); - dom_eig_mem->LAPACK_wr = NULL; - } - - if (dom_eig_mem->LAPACK_wi != NULL) - { - free(dom_eig_mem->LAPACK_wi); - dom_eig_mem->LAPACK_wi = NULL; - } - - if (dom_eig_mem->LAPACK_arr != NULL) - { - free(dom_eig_mem->LAPACK_arr); - dom_eig_mem->LAPACK_arr = NULL; - } - - if (dom_eig_mem->Hes != NULL) - { - free(dom_eig_mem->Hes); - dom_eig_mem->Hes = NULL; - } - - free(*domeig_mem); - *domeig_mem = NULL; -} \ No newline at end of file diff --git a/src/sundials/sundials_domeigestimator.c b/src/sundials/sundials_domeigestimator.c index c0d52b74f7..733c327f5f 100644 --- a/src/sundials/sundials_domeigestimator.c +++ b/src/sundials/sundials_domeigestimator.c @@ -16,14 +16,12 @@ * operations listed in sundials_domeigestimator.h * -----------------------------------------------------------------*/ -#include #include - -#include #include +#include #include -#include +#include #if defined(SUNDIALS_BUILD_WITH_PROFILING) static SUNProfiler getSUNProfiler(SUNDomEigEstimator D) @@ -56,14 +54,15 @@ SUNDomEigEstimator SUNDomEigEstNewEmpty(SUNContext sunctx) SUNAssertNull(ops, SUN_ERR_MALLOC_FAIL); /* initialize operations to NULL */ - ops->gettype = NULL; - ops->setatimes = NULL; - ops->initialize = NULL; - ops->preprocess = NULL; - ops->computehess = NULL; - ops->initialize = NULL; - ops->estimate = NULL; - ops->free = NULL; + ops->gettype = NULL; + ops->setatimes = NULL; + ops->setnumofperprocess = NULL; + ops->initialize = NULL; + ops->preprocess = NULL; + ops->computehess = NULL; + ops->initialize = NULL; + ops->estimate = NULL; + ops->free = NULL; /* attach ops and initialize content and context to NULL */ DEE->ops = ops; @@ -94,7 +93,7 @@ void SUNDomEigEstFreeEmpty(SUNDomEigEstimator DEE) * Functions in the 'ops' structure * -----------------------------------------------------------------*/ -SUNDomEigEstimator_Type SUNLinSolGetType(SUNDomEigEstimator DEE) +SUNDomEigEstimator_Type SUNDomEigEstGetType(SUNDomEigEstimator DEE) { return (DEE->ops->gettype(DEE)); } diff --git a/src/sundomeigest/ArnI/CMakeLists.txt b/src/sundomeigest/ArnI/CMakeLists.txt new file mode 100644 index 0000000000..c1a24990a8 --- /dev/null +++ b/src/sundomeigest/ArnI/CMakeLists.txt @@ -0,0 +1,32 @@ +# --------------------------------------------------------------- +# Programmer(s): Mustafa Aggul @ SMU +# --------------------------------------------------------------- +# SUNDIALS Copyright Start +# Copyright (c) 2002-2025, Lawrence Livermore National Security +# and Southern Methodist University. +# All rights reserved. +# +# See the top-level LICENSE and NOTICE files for details. +# +# SPDX-License-Identifier: BSD-3-Clause +# SUNDIALS Copyright End +# --------------------------------------------------------------- +# CMakeLists.txt file for the Arnoldi Iteration +# SUNDomEigEstimator library +# --------------------------------------------------------------- + +install(CODE "MESSAGE(\"\nInstall SUNDOMEIGEST_ARNI\n\")") + +# Add the sundomeigest_arni library +sundials_add_library( + sundials_sundomeigestarni + SOURCES sundomeigest_arni.c + HEADERS ${SUNDIALS_SOURCE_DIR}/include/sundomeigest/sundomeigest_arni.h + INCLUDE_SUBDIR sundomeigest + LINK_LIBRARIES PUBLIC sundials_core + OBJECT_LIBRARIES + OUTPUT_NAME sundials_sundomeigestarni + VERSION ${sundomeigestlib_VERSION} + SOVERSION ${sundomeigestlib_SOVERSION}) + +message(STATUS "Added SUNDOMEIGEST_ARNI module") diff --git a/src/sundomeigest/ArnI/sundomeigest_arni.c b/src/sundomeigest/ArnI/sundomeigest_arni.c index a1375dcc10..9468d9a4ee 100644 --- a/src/sundomeigest/ArnI/sundomeigest_arni.c +++ b/src/sundomeigest/ArnI/sundomeigest_arni.c @@ -21,7 +21,8 @@ #include #include -#include +#include +#include #include "sundials_logger_impl.h" #include "sundials_macros.h" @@ -37,15 +38,6 @@ #define ArnI_CONTENT(DEE) ((SUNDomEigEstimatorContent_ArnI)(DEE->content)) -/* - * ----------------------------------------------------------------- - * internally used functions - * ----------------------------------------------------------------- - */ - -sunrealtype domeig_Magnitude(const suncomplextype *c); -int domeig_Compare(const void *a, const void *b); - /* * ----------------------------------------------------------------- * exported functions @@ -62,31 +54,32 @@ SUNDomEigEstimator SUNDomEigEst_ArnI(N_Vector q, int maxl, SUNContext sunctx) SUNDomEigEstimator DEE; SUNDomEigEstimatorContent_ArnI content; + /* Check if maxl >= 2 */ + SUNAssert(maxl >= 2, SUN_ERR_DOMEIG_NOT_ENOUGH_ITER); + /* check for legal q; if illegal return NULL */ // TO DO: check required vector operations - SUNAssert(( + SUNAssert(!( (q->ops->nvclone == NULL) || (q->ops->nvdestroy == NULL) || (q->ops->nvdotprod == NULL) || (q->ops->nvscale == NULL) || (q->ops->nvgetlength == NULL) || (q->ops->nvspace == NULL)), SUN_ERR_DOMEIG_BAD_NVECTOR); - /* Check if maxl >= 2 */ - SUNAssert(maxl < 2, SUN_ERR_DOMEIG_NOT_ENOUGH_ITER); - /* Create dominant eigenvalue estimator */ DEE = NULL; DEE = SUNDomEigEstNewEmpty (sunctx); SUNCheckLastErrNull(); /* Attach operations */ - DEE->ops->gettype = SUNDomEigEst_ArnIGetType; - DEE->ops->setatimes = SUNDomEigEstSetATimes_ArnI; - DEE->ops->setmaxpoweriter = NULL; - DEE->ops->initialize = SUNDomEigEstInitialize_ArnI; - DEE->ops->preprocess = SUNDomEigEstPreProcess_ArnI; - DEE->ops->computehess = SUNDomEigEstComputeHess_ArnI; - DEE->ops->estimate = SUNDomEigEstimate_ArnI; - DEE->ops->getnumofiters = NULL; - DEE->ops->free = SUNDomEigEstFree_ArnI; + DEE->ops->gettype = SUNDomEigEst_ArnIGetType; + DEE->ops->setatimes = SUNDomEigEstSetATimes_ArnI; + DEE->ops->setmaxpoweriter = NULL; + DEE->ops->setnumofperprocess = SUNDomEigEstSetNumofPreProcess_ArnI; + DEE->ops->initialize = SUNDomEigEstInitialize_ArnI; + DEE->ops->preprocess = SUNDomEigEstPreProcess_ArnI; + DEE->ops->computehess = SUNDomEigEstComputeHess_ArnI; + DEE->ops->estimate = SUNDomEigEstimate_ArnI; + DEE->ops->getnumofiters = NULL; + DEE->ops->free = SUNDomEigEstFree_ArnI; /* Create content */ content = NULL; @@ -102,7 +95,7 @@ SUNDomEigEstimator SUNDomEigEst_ArnI(N_Vector q, int maxl, SUNContext sunctx) content->V = NULL; content->q = NULL; content->maxl = maxl; - content->power_of_A = NULL; + content->power_of_A = 0; content->LAPACK_A = NULL; content->LAPACK_wr = NULL; content->LAPACK_wi = NULL; @@ -151,15 +144,6 @@ SUNErrCode SUNDomEigEstInitialize_ArnI(SUNDomEigEstimator DEE) N_VRandom(ArnI_CONTENT(DEE)->q); SUNCheckLastErrNull(); - /* Initialize the vector V */ - sunrealtype normq = N_VDotProd(ArnI_CONTENT(DEE)->q, ArnI_CONTENT(DEE)->q); - SUNCheckLastErrNull(); - - normq = SUNRsqrt(normq); - - N_VScale(ONE/normq, ArnI_CONTENT(DEE)->q, ArnI_CONTENT(DEE)->V); - SUNCheckLastErrNull(); - /* Hessenberg matrix Hes */ if (ArnI_CONTENT(DEE)->Hes == NULL) { @@ -197,6 +181,16 @@ SUNErrCode SUNDomEigEstSetATimes_ArnI(SUNDomEigEstimator DEE, void* A_data, SUNA return SUN_SUCCESS; } +SUNErrCode SUNDomEigEstSetNumofPreProcess_ArnI(SUNDomEigEstimator DEE, int numofperprocess) +{ + SUNFunctionBegin(DEE->sunctx); + + /* set function pointers to integrator-supplied ATimes routine + and data, and return with success */ + ArnI_CONTENT(DEE)->power_of_A = numofperprocess; + return SUN_SUCCESS; +} + SUNErrCode SUNDomEigEstPreProcess_ArnI(SUNDomEigEstimator DEE) { SUNFunctionBegin(DEE->sunctx); @@ -211,7 +205,7 @@ SUNErrCode SUNDomEigEstPreProcess_ArnI(SUNDomEigEstimator DEE) /* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ for(i = 0; i < ArnI_CONTENT(DEE)->power_of_A; i++) { - retval = ArnI_CONTENT(DEE)->ATimes(ArnI_CONTENT(DEE)->ATdata, ArnI_CONTENT(DEE)->V, ArnI_CONTENT(DEE)->q); + retval = ArnI_CONTENT(DEE)->ATimes(ArnI_CONTENT(DEE)->ATdata, ArnI_CONTENT(DEE)->V[0], ArnI_CONTENT(DEE)->q); if (retval != 0) { if(retval < 0) @@ -227,7 +221,7 @@ SUNErrCode SUNDomEigEstPreProcess_ArnI(SUNDomEigEstimator DEE) SUNCheckLastErr(); normq = SUNRsqrt(normq); - N_VScale(ONE/normq, ArnI_CONTENT(DEE)->q, ArnI_CONTENT(DEE)->V); + N_VScale(ONE/normq, ArnI_CONTENT(DEE)->q, ArnI_CONTENT(DEE)->V[0]); SUNCheckLastErr(); } diff --git a/src/sundomeigest/CMakeLists.txt b/src/sundomeigest/CMakeLists.txt new file mode 100644 index 0000000000..1d3df2489e --- /dev/null +++ b/src/sundomeigest/CMakeLists.txt @@ -0,0 +1,22 @@ +# ------------------------------------------------------------------------------ +# Programmer(s): Mustafa Aggul @ SMU +# ------------------------------------------------------------------------------ +# SUNDIALS Copyright Start +# Copyright (c) 2002-2025, Lawrence Livermore National Security +# and Southern Methodist University. +# All rights reserved. +# +# See the top-level LICENSE and NOTICE files for details. +# +# SPDX-License-Identifier: BSD-3-Clause +# SUNDIALS Copyright End +# ------------------------------------------------------------------------------ +# dominant eigenvalue estimator level CMakeLists.txt for SUNDIALS +# ------------------------------------------------------------------------------ + +# required native dominant eigenvalue estimators +add_subdirectory(PI) + +if(ENABLE_LAPACK) + add_subdirectory(ArnI) +endif() \ No newline at end of file diff --git a/src/sundomeigest/PI/CMakeLists.txt b/src/sundomeigest/PI/CMakeLists.txt new file mode 100644 index 0000000000..d9f25e8d51 --- /dev/null +++ b/src/sundomeigest/PI/CMakeLists.txt @@ -0,0 +1,31 @@ +# --------------------------------------------------------------- +# Programmer(s): Mustafa Aggul @ SMU +# --------------------------------------------------------------- +# SUNDIALS Copyright Start +# Copyright (c) 2002-2025, Lawrence Livermore National Security +# and Southern Methodist University. +# All rights reserved. +# +# See the top-level LICENSE and NOTICE files for details. +# +# SPDX-License-Identifier: BSD-3-Clause +# SUNDIALS Copyright End +# --------------------------------------------------------------- +# CMakeLists.txt file for the PI SUNDomEigEstimator library +# --------------------------------------------------------------- + +install(CODE "MESSAGE(\"\nInstall SUNDOMEIGEST_PI\n\")") + +# Add the sundomeigest_pi library +sundials_add_library( + sundials_sundomeigestpi + SOURCES sundomeigest_pi.c + HEADERS ${SUNDIALS_SOURCE_DIR}/include/sundomeigest/sundomeigest_pi.h + INCLUDE_SUBDIR sundomeigest + LINK_LIBRARIES PUBLIC sundials_core + OBJECT_LIBRARIES + OUTPUT_NAME sundials_sundomeigestpi + VERSION ${sundomeigestlib_VERSION} + SOVERSION ${sundomeigestlib_SOVERSION}) + +message(STATUS "Added SUNDOMEIGEST_PI module") diff --git a/src/sundomeigest/PI/sundomeigest_pi.c b/src/sundomeigest/PI/sundomeigest_pi.c index 130cae722b..598abeb1c6 100644 --- a/src/sundomeigest/PI/sundomeigest_pi.c +++ b/src/sundomeigest/PI/sundomeigest_pi.c @@ -21,12 +21,14 @@ #include #include -#include +#include +#include #include "sundials_logger_impl.h" #include "sundials_macros.h" #define ZERO SUN_RCONST(0.0) +#define ONE SUN_RCONST(1.0) /* * ----------------------------------------------------------------- @@ -68,15 +70,16 @@ SUNDomEigEstimator SUNDomEigEst_PI(N_Vector q, int max_powiter, SUNContext sunct SUNCheckLastErrNull(); /* Attach operations */ - DEE->ops->gettype = SUNDomEigEst_PIGetType; - DEE->ops->setatimes = SUNDomEigEstSetATimes_PI; - DEE->ops->setmaxpoweriter = SUNDomEigEst_PISetMaxPowerIter; - DEE->ops->initialize = SUNDomEigEstInitialize_PI; - DEE->ops->preprocess = SUNDomEigEstPreProcess_PI; - DEE->ops->computehess = NULL; - DEE->ops->estimate = SUNDomEigEstimate_PI; - DEE->ops->getnumofiters = SUNDomEigEstNumIters_PI; - DEE->ops->free = SUNDomEigEstFree_PI; + DEE->ops->gettype = SUNDomEigEst_PIGetType; + DEE->ops->setatimes = SUNDomEigEstSetATimes_PI; + DEE->ops->setmaxpoweriter = SUNDomEigEst_PISetMaxPowerIter; + DEE->ops->setnumofperprocess = NULL; + DEE->ops->initialize = SUNDomEigEstInitialize_PI; + DEE->ops->preprocess = SUNDomEigEstPreProcess_PI; + DEE->ops->computehess = NULL; + DEE->ops->estimate = SUNDomEigEstimate_PI; + DEE->ops->getnumofiters = SUNDomEigEstNumIters_PI; + DEE->ops->free = SUNDomEigEstFree_PI; /* Create content */ content = NULL; @@ -91,7 +94,7 @@ SUNDomEigEstimator SUNDomEigEst_PI(N_Vector q, int max_powiter, SUNContext sunct content->ATdata = NULL; content->V = NULL; content->q = NULL; - content->power_of_A = NULL; + content->power_of_A = 0; content->powiter_tol = ZERO; content->resnorm = ZERO; content->max_powiter = max_powiter; @@ -101,7 +104,7 @@ SUNDomEigEstimator SUNDomEigEst_PI(N_Vector q, int max_powiter, SUNContext sunct content->q = N_VClone(q); SUNCheckLastErrNull(); - content->V = N_VCloneVectorArray(1, q); + content->V = N_VClone(q); SUNCheckLastErrNull(); return (DEE); diff --git a/test/unit_tests/arkode/CXX_parallel/CMakeLists.txt b/test/unit_tests/arkode/CXX_parallel/CMakeLists.txt index 545ce2f7e1..b813d4b48c 100644 --- a/test/unit_tests/arkode/CXX_parallel/CMakeLists.txt +++ b/test/unit_tests/arkode/CXX_parallel/CMakeLists.txt @@ -48,6 +48,8 @@ foreach(test_tuple ${unit_tests}) # libraries to link against target_link_libraries(${test_target} MPI::MPI_CXX sundials_arkode + sundials_sundomeigestpi_obj + sundials_sundomeigestarni_obj sundials_nvecparallel ${EXE_EXTRA_LINK_LIBS}) endif() diff --git a/test/unit_tests/arkode/CXX_serial/CMakeLists.txt b/test/unit_tests/arkode/CXX_serial/CMakeLists.txt index 9449f8f9eb..fe9ded5288 100644 --- a/test/unit_tests/arkode/CXX_serial/CMakeLists.txt +++ b/test/unit_tests/arkode/CXX_serial/CMakeLists.txt @@ -113,6 +113,8 @@ foreach(test_tuple ${unit_tests}) sundials_sunadaptcontrollersoderlind_obj sundials_sunadaptcontrollermrihtol_obj sundials_adjointcheckpointscheme_fixed_obj + sundials_sundomeigestpi_obj + sundials_sundomeigestarni_obj ${EXE_EXTRA_LINK_LIBS}) # Tell CMake that we depend on the ARKODE library since it does not pick diff --git a/test/unit_tests/arkode/C_serial/CMakeLists.txt b/test/unit_tests/arkode/C_serial/CMakeLists.txt index 0471d7db68..148cd8d5d9 100644 --- a/test/unit_tests/arkode/C_serial/CMakeLists.txt +++ b/test/unit_tests/arkode/C_serial/CMakeLists.txt @@ -73,6 +73,8 @@ foreach(test_tuple ${ARKODE_unit_tests}) sundials_sunadaptcontrollerimexgus_obj sundials_sunadaptcontrollersoderlind_obj sundials_adjointcheckpointscheme_fixed_obj + sundials_sundomeigestpi_obj + sundials_sundomeigestarni_obj ${EXE_EXTRA_LINK_LIBS}) # Tell CMake that we depend on the ARKODE library since it does not pick diff --git a/test/unit_tests/sundials/CMakeLists.txt b/test/unit_tests/sundials/CMakeLists.txt index d4261b4bf1..ad11528ada 100644 --- a/test/unit_tests/sundials/CMakeLists.txt +++ b/test/unit_tests/sundials/CMakeLists.txt @@ -39,9 +39,9 @@ endif() # Tests for the domeig utility routine (estimates dominant eigenvalue; depends on LAPACK) if(ENABLE_LAPACK) set(unit_tests_lapack - "test_domeig\;100 10\;" - "test_domeig\;1000 20\;" - "test_domeig\;10000 50\;") + "test_domeig\;100 10 10\;" + "test_domeig\;1000 20 10\;" + "test_domeig\;10000 50 10\;") # Add the build and install targets for each test foreach(test_tuple ${unit_tests_lapack}) @@ -65,7 +65,7 @@ if(ENABLE_LAPACK) ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/src) # libraries to link against - set(_domeig_libs sundials_core sundials_nvecserial LAPACK::LAPACK) + set(_domeig_libs sundials_core sundials_nvecserial sundials_sundomeigestpi_obj sundials_sundomeigestarni_obj LAPACK::LAPACK) if(CMAKE_VERSION VERSION_LESS 3.20) list(APPEND _domeig_libs BLAS::BLAS) endif() diff --git a/test/unit_tests/sundials/test_domeig.c b/test/unit_tests/sundials/test_domeig.c index 197dbdc2c9..deee4cad4b 100644 --- a/test/unit_tests/sundials/test_domeig.c +++ b/test/unit_tests/sundials/test_domeig.c @@ -20,7 +20,9 @@ #include #include /* def. of SUNRsqrt, etc. */ #include /* definition of type sunrealtype */ -#include +#include +#include +#include #if defined(SUNDIALS_EXTENDED_PRECISION) @@ -70,7 +72,7 @@ int main(int argc, char* argv[]) int passfail = 0; /* overall pass/fail flag */ N_Vector q; /* test vectors */ UserData ProbData; /* problem data structure */ - int maxl, failure; + int maxl, failure, power_of_A; SUNContext sunctx; sunrealtype tolerans = 1.0e-2; @@ -81,11 +83,12 @@ int main(int argc, char* argv[]) } /* check inputs: local problem size */ - if (argc < 3) + if (argc < 4) { printf("ERROR: TWO (2) Inputs required:\n"); printf(" Problem size should be >0\n"); printf(" Krylov subspace dimension should be >0\n"); + printf(" Number of preprocessing should be >= 0\n"); return 1; } ProbData.N = (sunindextype)atol(argv[1]); @@ -102,10 +105,17 @@ int main(int argc, char* argv[]) "ERROR: Krylov subspace dimension must be a positive integer\n"); return 1; } - + power_of_A = atoi(argv[3]); + if (power_of_A < 0) + { + printf( + "ERROR: Number of preprocessing must be a nonnegative integer\n"); + return 1; + } printf("\nDomEig module test:\n"); printf(" Problem size = %ld\n", (long int)ProbData.N); printf(" Krylov subspace dimension = %i\n", maxl); + printf(" Number of preprocessing = %i\n", power_of_A); /* Create vectors */ q = N_VNew_Serial(ProbData.N, sunctx); @@ -130,22 +140,35 @@ int main(int argc, char* argv[]) ProbData.real_part = realpart; ProbData.imag_part = imagpart; - /* Create DOMEIG memory structure */ - void* DomEig_mem = NULL; - passfail = DomEigCreate(ATimes, &ProbData, q, maxl, sunctx, &DomEig_mem); - if (check_flag(&passfail, "DomEigCreate", 1)) { return 1; } + /* Create DomEig estimator*/ + SUNDomEigEstimator DEE = NULL; + + DEE = SUNDomEigEst_ArnI(q, maxl, sunctx); + if (check_flag(DEE, "SUNDomEigEst_ArnI", 0)) { return 1; } + + /* Set Atimes*/ + passfail = DEE->ops->setatimes(DEE, &ProbData, ATimes); + if (check_flag(&passfail, "setatimes", 1)) { return 1; } + + /* Set the number of preprocessings */ + if(DEE->ops->setnumofperprocess != NULL) + { + passfail = DEE->ops->setnumofperprocess(DEE, power_of_A); + if (check_flag(&passfail, "setnumofperprocess", 1)) { return 1; } + } /* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ - passfail = DomEigPreProcess(DomEig_mem); - if (check_flag(&passfail, "DomEigPreProcess", 1)) { return 1; } + passfail = DEE->ops->preprocess(DEE); + if (check_flag(&passfail, "preprocess", 1)) { return 1; } - /* Compute the Hessenberg matrix Hes*/ - passfail = DomEigComputeHess(DomEig_mem); - if (check_flag(&passfail, "DomEigComputeHess", 1)) { return 1; } + /* Compute the Hessenberg matrix Hes */ + passfail = DEE->ops->computehess(DEE); + if (check_flag(&passfail, "computehess", 1)) { return 1; } + /* Estimate the dominant eigenvalue */ suncomplextype dom_eig; - passfail = DomEigEstimate(DomEig_mem, &dom_eig); - if (check_flag(&passfail, "DomEigEstimate", 1)) { return 1; } + passfail = DEE->ops->estimate(DEE, &dom_eig); + if (check_flag(&passfail, "estimate", 1)) { return 1; } sunrealtype norm_of_dom_eig = SUNRsqrt(dom_eig.real * dom_eig.real + dom_eig.imag * dom_eig.imag); if(norm_of_dom_eig < SUN_SMALL_REAL) { @@ -188,7 +211,7 @@ int main(int argc, char* argv[]) N_VDestroy(q); N_VDestroy(ProbData.d); SUNContext_Free(&sunctx); - DomEigDestroy((void**)&DomEig_mem); + DEE->ops->free(DEE); return (passfail); } From 441d82f35594b3604e73a4f83847f28b64f7ebc9 Mon Sep 17 00:00:00 2001 From: maggul Date: Sat, 7 Jun 2025 18:35:31 -0500 Subject: [PATCH 023/128] unit test and lsrk example works fine -- needs polishing --- src/arkode/arkode_lsrkstep.c | 24 ++++++++++++++++++------ src/sundomeigest/PI/sundomeigest_pi.c | 4 ++-- test/unit_tests/sundials/test_domeig.c | 4 ++++ 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/arkode/arkode_lsrkstep.c b/src/arkode/arkode_lsrkstep.c index 28f23d19f4..73089a1326 100644 --- a/src/arkode/arkode_lsrkstep.c +++ b/src/arkode/arkode_lsrkstep.c @@ -2352,6 +2352,15 @@ SUNDomEigEstimator lsrkStep_DomEigCreate(void* arkode_mem) } } + /* Initialize the estimator */ + retval = DEE->ops->initialize(DEE); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, + MSG_ARK_INTERNAL_DOMEIG_FAIL); + return NULL; + } + /* Set the number of preprocessings */ if(DEE->ops->setnumofperprocess != NULL) { @@ -2406,14 +2415,17 @@ suncomplextype lsrkStep_DomEigEstimate(void* arkode_mem, SUNDomEigEstimator DEE) return dom_eig; } - /* Compute the Hessenberg matrix Hes*/ - retval = DEE->ops->computehess(DEE); - if (retval != ARK_SUCCESS) + /* Compute the Hessenberg matrix Hes if Arnoldi */ + if(DEE->ops->computehess != NULL) { - arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, - MSG_ARK_INTERNAL_DOMEIG_FAIL); + retval = DEE->ops->computehess(DEE); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, + MSG_ARK_INTERNAL_DOMEIG_FAIL); - return dom_eig; + return dom_eig; + } } retval = DEE->ops->estimate(DEE, &dom_eig); diff --git a/src/sundomeigest/PI/sundomeigest_pi.c b/src/sundomeigest/PI/sundomeigest_pi.c index 598abeb1c6..5b6af950c5 100644 --- a/src/sundomeigest/PI/sundomeigest_pi.c +++ b/src/sundomeigest/PI/sundomeigest_pi.c @@ -56,7 +56,7 @@ SUNDomEigEstimator SUNDomEigEst_PI(N_Vector q, int max_powiter, SUNContext sunct /* check for legal q; if illegal return NULL */ // TO DO: check required vector operations - SUNAssert(( + SUNAssert(!( (q->ops->nvclone == NULL) || (q->ops->nvdestroy == NULL) || (q->ops->nvdotprod == NULL) || (q->ops->nvscale == NULL) || (q->ops->nvgetlength == NULL) || (q->ops->nvspace == NULL)), SUN_ERR_DOMEIG_BAD_NVECTOR); @@ -216,7 +216,7 @@ SUNErrCode SUNDomEigEstimate_PI(SUNDomEigEstimator DEE, suncomplextype* dom_eig) SUNAssert(PI_CONTENT(DEE)->ATimes, SUN_ERR_ARG_CORRUPT); SUNAssert(PI_CONTENT(DEE)->V, SUN_ERR_ARG_CORRUPT); SUNAssert(PI_CONTENT(DEE)->q, SUN_ERR_ARG_CORRUPT); - SUNAssert((PI_CONTENT(DEE)->max_powiter < 0), SUN_ERR_ARG_CORRUPT); + SUNAssert((PI_CONTENT(DEE)->max_powiter >= 0), SUN_ERR_ARG_CORRUPT); suncomplextype dom_eig_new, dom_eig_old; diff --git a/test/unit_tests/sundials/test_domeig.c b/test/unit_tests/sundials/test_domeig.c index deee4cad4b..091e0082c5 100644 --- a/test/unit_tests/sundials/test_domeig.c +++ b/test/unit_tests/sundials/test_domeig.c @@ -157,6 +157,10 @@ int main(int argc, char* argv[]) if (check_flag(&passfail, "setnumofperprocess", 1)) { return 1; } } + /* Initialize the estimator */ + passfail = DEE->ops->initialize(DEE); + if (check_flag(&passfail, "initialize", 1)) { return 1; } + /* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ passfail = DEE->ops->preprocess(DEE); if (check_flag(&passfail, "preprocess", 1)) { return 1; } From 09b1c29635ef9d260e07f584b49ea9c55849d438 Mon Sep 17 00:00:00 2001 From: maggul Date: Sat, 7 Jun 2025 22:43:54 -0500 Subject: [PATCH 024/128] CI test debug --- include/sundials/sundials_domeigestimator.h | 15 +++++++-------- src/sundials/sundials_domeigestimator.c | 7 +++---- .../unit_tests/arkode/CXX_parallel/CMakeLists.txt | 4 ++-- test/unit_tests/sundials/CMakeLists.txt | 2 +- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/include/sundials/sundials_domeigestimator.h b/include/sundials/sundials_domeigestimator.h index 8b285975ae..03eb397165 100644 --- a/include/sundials/sundials_domeigestimator.h +++ b/include/sundials/sundials_domeigestimator.h @@ -86,27 +86,26 @@ SUNDIALS_EXPORT SUNDomEigEstimator SUNDomEigEstNewEmpty(SUNContext sunctx); SUNDIALS_EXPORT -void SUNDomEigEstFreeEmpty(SUNDomEigEstimator D); +void SUNDomEigEstFreeEmpty(SUNDomEigEstimator DEE); SUNDIALS_EXPORT -SUNDomEigEstimator_Type SUNDomEigEstGetType(SUNDomEigEstimator D); +SUNDomEigEstimator_Type SUNDomEigEstGetType(SUNDomEigEstimator DEE); SUNDIALS_EXPORT -SUNErrCode SUNDomEigEstSetATimes(SUNDomEigEstimator D, void* A_data, +SUNErrCode SUNDomEigEstSetATimes(SUNDomEigEstimator DEE, void* A_data, SUNATimesFn ATimes); SUNDIALS_EXPORT -SUNErrCode SUNDomEigEstInitialize(SUNDomEigEstimator D, void* A_data, - SUNATimesFn ATimes); +SUNErrCode SUNDomEigEstInitialize(SUNDomEigEstimator DEE); SUNDIALS_EXPORT -SUNErrCode SUNDomEigEstPreProcess(SUNDomEigEstimator D); +SUNErrCode SUNDomEigEstPreProcess(SUNDomEigEstimator DEE); SUNDIALS_EXPORT -SUNErrCode SUNDomEigEstComputeHess(SUNDomEigEstimator D); +SUNErrCode SUNDomEigEstComputeHess(SUNDomEigEstimator DEE); SUNDIALS_EXPORT -SUNErrCode SUNDomEigEstimate(SUNDomEigEstimator D, suncomplextype* dom_eig); +SUNErrCode SUNDomEigEstimate(SUNDomEigEstimator DEE, suncomplextype* dom_eig); /* ----------------------------------------------------------------- * SUNDomEigEstimator return values diff --git a/src/sundials/sundials_domeigestimator.c b/src/sundials/sundials_domeigestimator.c index 733c327f5f..66aff7efc7 100644 --- a/src/sundials/sundials_domeigestimator.c +++ b/src/sundials/sundials_domeigestimator.c @@ -24,9 +24,9 @@ #include #if defined(SUNDIALS_BUILD_WITH_PROFILING) -static SUNProfiler getSUNProfiler(SUNDomEigEstimator D) +static SUNProfiler getSUNProfiler(SUNDomEigEstimator DEE) { - return (D->sunctx->profiler); + return (DEE->sunctx->profiler); } #endif @@ -108,8 +108,7 @@ SUNErrCode SUNDomEigEstSetATimes(SUNDomEigEstimator DEE, void* A_data, SUNATimes return (ier); } -SUNErrCode SUNDomEigEstInitialize(SUNDomEigEstimator DEE, void* A_data, - SUNATimesFn ATimes) //maybe drop Atimes from here +SUNErrCode SUNDomEigEstInitialize(SUNDomEigEstimator DEE) { SUNErrCode ier; SUNDIALS_MARK_FUNCTION_BEGIN(getSUNProfiler(DEE)); diff --git a/test/unit_tests/arkode/CXX_parallel/CMakeLists.txt b/test/unit_tests/arkode/CXX_parallel/CMakeLists.txt index b813d4b48c..84e7169ac9 100644 --- a/test/unit_tests/arkode/CXX_parallel/CMakeLists.txt +++ b/test/unit_tests/arkode/CXX_parallel/CMakeLists.txt @@ -48,8 +48,8 @@ foreach(test_tuple ${unit_tests}) # libraries to link against target_link_libraries(${test_target} MPI::MPI_CXX sundials_arkode - sundials_sundomeigestpi_obj - sundials_sundomeigestarni_obj + sundials_sundomeigestpi + sundials_sundomeigestarni sundials_nvecparallel ${EXE_EXTRA_LINK_LIBS}) endif() diff --git a/test/unit_tests/sundials/CMakeLists.txt b/test/unit_tests/sundials/CMakeLists.txt index ad11528ada..b000441e60 100644 --- a/test/unit_tests/sundials/CMakeLists.txt +++ b/test/unit_tests/sundials/CMakeLists.txt @@ -65,7 +65,7 @@ if(ENABLE_LAPACK) ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/src) # libraries to link against - set(_domeig_libs sundials_core sundials_nvecserial sundials_sundomeigestpi_obj sundials_sundomeigestarni_obj LAPACK::LAPACK) + set(_domeig_libs sundials_core sundials_nvecserial sundials_sundomeigestpi sundials_sundomeigestarni LAPACK::LAPACK) if(CMAKE_VERSION VERSION_LESS 3.20) list(APPEND _domeig_libs BLAS::BLAS) endif() From ada6e6e7a89dc3467e1dc97d7f18e072e7afae83 Mon Sep 17 00:00:00 2001 From: maggul Date: Sat, 7 Jun 2025 23:49:45 -0500 Subject: [PATCH 025/128] CI testing fixes --- CMakeLists.txt | 3 +++ .../sundials/priv/sundials_domeigestimator_impl.h | 9 +-------- include/sundials/sundials_domeigestimator.h | 6 ------ include/sundomeigest/sundomeigest_arni.h | 10 +++++----- include/sundomeigest/sundomeigest_pi.h | 12 ++++++------ src/nvector/parhyp/nvector_parhyp.c | 1 + src/sundomeigest/ArnI/CMakeLists.txt | 2 +- src/sundomeigest/ArnI/sundomeigest_arni.c | 14 +++++++------- src/sundomeigest/PI/sundomeigest_pi.c | 12 ++++++------ 9 files changed, 30 insertions(+), 39 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b76779edd..98e721f923 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,6 +102,9 @@ set(sunlinsollib_SOVERSION "5") set(sunnonlinsollib_VERSION "4.3.0") set(sunnonlinsollib_SOVERSION "4") +set(sundomeigestlib_VERSION "1.0.0") +set(sundomeigestlib_SOVERSION "1") + set(sundialslib_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}" ) diff --git a/include/sundials/priv/sundials_domeigestimator_impl.h b/include/sundials/priv/sundials_domeigestimator_impl.h index 3962ea84f5..0c5cbd6721 100644 --- a/include/sundials/priv/sundials_domeigestimator_impl.h +++ b/include/sundials/priv/sundials_domeigestimator_impl.h @@ -31,7 +31,7 @@ extern "C" { SUNErrCode domeig_CheckNVector(N_Vector tmpl); sunrealtype domeig_Magnitude(const suncomplextype *c); - int domeig_Compare(const void *a, const void *b); + sunindextype domeig_Compare(const void *a, const void *b); /* * ----------------------------------------------------------------- @@ -43,13 +43,6 @@ extern "C" { sunrealtype* wr, sunrealtype* wi, sunrealtype* vl, int* ldvl, sunrealtype* vr, int* ldvr, sunrealtype* work, int* lwork, int* info); -/*=============================================================== - Reusable DOMEIG Error Messages - ===============================================================*/ - -/* Initialization and I/O error messages */ -#define MSG_DOMEIG_LAPACK_FAIL "Error: LAPACK dgeev failed with info = %d\n" - #ifdef __cplusplus } #endif diff --git a/include/sundials/sundials_domeigestimator.h b/include/sundials/sundials_domeigestimator.h index 03eb397165..e0f982692f 100644 --- a/include/sundials/sundials_domeigestimator.h +++ b/include/sundials/sundials_domeigestimator.h @@ -107,12 +107,6 @@ SUNErrCode SUNDomEigEstComputeHess(SUNDomEigEstimator DEE); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstimate(SUNDomEigEstimator DEE, suncomplextype* dom_eig); -/* ----------------------------------------------------------------- - * SUNDomEigEstimator return values - * ----------------------------------------------------------------- */ - -#define SUNDEE_LAPACK_FAIL "Error: LAPACK dgeev failed with info = %d\n" - #ifdef __cplusplus } #endif diff --git a/include/sundomeigest/sundomeigest_arni.h b/include/sundomeigest/sundomeigest_arni.h index a0013bdfbd..8a254d7219 100644 --- a/include/sundomeigest/sundomeigest_arni.h +++ b/include/sundomeigest/sundomeigest_arni.h @@ -45,8 +45,8 @@ struct _SUNDomEigEstimatorContent_ArnI N_Vector *V, q; /* Krylov subspace vectors */ - int maxl; /* Krylov subspace dimension */ - int power_of_A; /* Power of A in the preprocessing; initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ + sunindextype maxl; /* Krylov subspace dimension */ + sunindextype power_of_A; /* Power of A in the preprocessing; initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ sunrealtype* LAPACK_A; /* The vector which holds rows of the Hessenberg matrix in the given order */ sunrealtype* LAPACK_wr; /* Real parts of eigenvalues */ @@ -64,7 +64,7 @@ typedef struct _SUNDomEigEstimatorContent_ArnI* SUNDomEigEstimatorContent_ArnI; * --------------------------------------- */ SUNDIALS_EXPORT -SUNDomEigEstimator SUNDomEigEst_ArnI(N_Vector q, int maxl, SUNContext sunctx); +SUNDomEigEstimator SUNDomEigEst_ArnI(N_Vector q, sunindextype maxl, SUNContext sunctx); SUNDIALS_EXPORT SUNDomEigEstimator_Type SUNDomEigEst_ArnIGetType(SUNDomEigEstimator DEE); @@ -77,7 +77,7 @@ SUNDIALS_EXPORT SUNErrCode SUNDomEigEstInitialize_ArnI(SUNDomEigEstimator DEE); SUNDIALS_EXPORT -SUNErrCode SUNDomEigEstSetNumofPreProcess_ArnI(SUNDomEigEstimator DEE, int numofperprocess); +SUNErrCode SUNDomEigEstSetNumofPreProcess_ArnI(SUNDomEigEstimator DEE, sunindextype numofperprocess); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstPreProcess_ArnI(SUNDomEigEstimator DEE); @@ -92,7 +92,7 @@ SUNDIALS_EXPORT SUNErrCode SUNDomEigEstFree_ArnI(SUNDomEigEstimator DEE); SUNDIALS_EXPORT -int SUNDomEigEstNumIters_ArnI(SUNDomEigEstimator DEE); +sunindextype SUNDomEigEstNumIters_ArnI(SUNDomEigEstimator DEE); #ifdef __cplusplus } diff --git a/include/sundomeigest/sundomeigest_pi.h b/include/sundomeigest/sundomeigest_pi.h index 9a522a80ba..2ec77606eb 100644 --- a/include/sundomeigest/sundomeigest_pi.h +++ b/include/sundomeigest/sundomeigest_pi.h @@ -45,12 +45,12 @@ struct _SUNDomEigEstimatorContent_PI N_Vector V, q; /* workspace vectors */ - int power_of_A; /* Power of A in the preprocessing; initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ + sunindextype power_of_A; /* Power of A in the preprocessing; initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ sunrealtype powiter_tol; /* Convergence criteria for the power iteration */ sunrealtype resnorm; /* Current residual of power iterations */ - int max_powiter; /* Maximum number of power iterations */ - int numiters; /* Number of power iterations */ + sunindextype max_powiter; /* Maximum number of power iterations */ + sunindextype numiters; /* Number of power iterations */ }; typedef struct _SUNDomEigEstimatorContent_PI* SUNDomEigEstimatorContent_PI; @@ -60,7 +60,7 @@ typedef struct _SUNDomEigEstimatorContent_PI* SUNDomEigEstimatorContent_PI; * --------------------------------------- */ SUNDIALS_EXPORT -SUNDomEigEstimator SUNDomEigEst_PI(N_Vector q, int max_powiter, SUNContext sunctx); +SUNDomEigEstimator SUNDomEigEst_PI(N_Vector q, sunindextype max_powiter, SUNContext sunctx); SUNDIALS_EXPORT SUNDomEigEstimator_Type SUNDomEigEst_PIGetType(SUNDomEigEstimator DEE); @@ -73,7 +73,7 @@ SUNErrCode SUNDomEigEstSetATimes_PI(SUNDomEigEstimator DEE, void* A_data, SUNATimesFn ATimes); SUNDIALS_EXPORT -SUNErrCode SUNDomEigEst_PISetMaxPowerIter(SUNDomEigEstimator DEE, int max_powiter); +SUNErrCode SUNDomEigEst_PISetMaxPowerIter(SUNDomEigEstimator DEE, sunindextype max_powiter); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstPreProcess_PI(SUNDomEigEstimator DEE); @@ -82,7 +82,7 @@ SUNDIALS_EXPORT SUNErrCode SUNDomEigEstimate_PI(SUNDomEigEstimator DEE, suncomplextype* dom_eig); SUNDIALS_EXPORT -int SUNDomEigEstNumIters_PI(SUNDomEigEstimator DEE); +sunindextype SUNDomEigEstNumIters_PI(SUNDomEigEstimator DEE); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstFree_PI(SUNDomEigEstimator DEE); diff --git a/src/nvector/parhyp/nvector_parhyp.c b/src/nvector/parhyp/nvector_parhyp.c index f6c0079d5a..44ba94a113 100644 --- a/src/nvector/parhyp/nvector_parhyp.c +++ b/src/nvector/parhyp/nvector_parhyp.c @@ -22,6 +22,7 @@ #include #include +#include #include #include #include diff --git a/src/sundomeigest/ArnI/CMakeLists.txt b/src/sundomeigest/ArnI/CMakeLists.txt index c1a24990a8..719465d7bf 100644 --- a/src/sundomeigest/ArnI/CMakeLists.txt +++ b/src/sundomeigest/ArnI/CMakeLists.txt @@ -29,4 +29,4 @@ sundials_add_library( VERSION ${sundomeigestlib_VERSION} SOVERSION ${sundomeigestlib_SOVERSION}) -message(STATUS "Added SUNDOMEIGEST_ARNI module") +message(STATUS "Added SUNDOMEIGEST_ARNI module") \ No newline at end of file diff --git a/src/sundomeigest/ArnI/sundomeigest_arni.c b/src/sundomeigest/ArnI/sundomeigest_arni.c index 9468d9a4ee..ef5ea499c6 100644 --- a/src/sundomeigest/ArnI/sundomeigest_arni.c +++ b/src/sundomeigest/ArnI/sundomeigest_arni.c @@ -48,7 +48,7 @@ * Function to create a new ArnI estimator */ -SUNDomEigEstimator SUNDomEigEst_ArnI(N_Vector q, int maxl, SUNContext sunctx) +SUNDomEigEstimator SUNDomEigEst_ArnI(N_Vector q, sunindextype maxl, SUNContext sunctx) { SUNFunctionBegin(sunctx); SUNDomEigEstimator DEE; @@ -147,7 +147,7 @@ SUNErrCode SUNDomEigEstInitialize_ArnI(SUNDomEigEstimator DEE) /* Hessenberg matrix Hes */ if (ArnI_CONTENT(DEE)->Hes == NULL) { - int k; + sunindextype k; ArnI_CONTENT(DEE)->Hes = (sunrealtype**)malloc((ArnI_CONTENT(DEE)->maxl + 1) * sizeof(sunrealtype*)); @@ -181,7 +181,7 @@ SUNErrCode SUNDomEigEstSetATimes_ArnI(SUNDomEigEstimator DEE, void* A_data, SUNA return SUN_SUCCESS; } -SUNErrCode SUNDomEigEstSetNumofPreProcess_ArnI(SUNDomEigEstimator DEE, int numofperprocess) +SUNErrCode SUNDomEigEstSetNumofPreProcess_ArnI(SUNDomEigEstimator DEE, sunindextype numofperprocess) { SUNFunctionBegin(DEE->sunctx); @@ -200,7 +200,7 @@ SUNErrCode SUNDomEigEstPreProcess_ArnI(SUNDomEigEstimator DEE) SUNAssert(ArnI_CONTENT(DEE)->q, SUN_ERR_ARG_CORRUPT); sunrealtype normq; - int i, retval; + sunindextype i, retval; /* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ for(i = 0; i < ArnI_CONTENT(DEE)->power_of_A; i++) @@ -237,7 +237,7 @@ SUNErrCode SUNDomEigEstComputeHess_ArnI(SUNDomEigEstimator DEE) SUNAssert(ArnI_CONTENT(DEE)->q, SUN_ERR_ARG_CORRUPT); SUNAssert(ArnI_CONTENT(DEE)->Hes, SUN_ERR_ARG_CORRUPT); - int retval, i, j; + sunindextype retval, i, j; /* Initialize the Hessenberg matrix Hes with zeros */ for (i = 0; i < ArnI_CONTENT(DEE)->maxl; i++) { @@ -287,7 +287,7 @@ SUNErrCode SUNDomEigEstimate_ArnI(SUNDomEigEstimator DEE, suncomplextype* dom_ei int n = ArnI_CONTENT(DEE)->maxl; /* Reshape the Hessenberg matrix as an input vector for the LAPACK dgeev_ function */ - int i, j, k = 0; + sunindextype i, j, k = 0; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { ArnI_CONTENT(DEE)->LAPACK_A[k] = ArnI_CONTENT(DEE)->Hes[i][j]; @@ -401,7 +401,7 @@ sunrealtype domeig_Magnitude(const suncomplextype *c) { } // Comparison function for qsort -int domeig_Compare(const void *a, const void *b) { +sunindextype domeig_Compare(const void *a, const void *b) { const suncomplextype *c1 = (const suncomplextype *)a; const suncomplextype *c2 = (const suncomplextype *)b; sunrealtype mag1 = domeig_Magnitude(c1); diff --git a/src/sundomeigest/PI/sundomeigest_pi.c b/src/sundomeigest/PI/sundomeigest_pi.c index 5b6af950c5..5c8e92387f 100644 --- a/src/sundomeigest/PI/sundomeigest_pi.c +++ b/src/sundomeigest/PI/sundomeigest_pi.c @@ -48,7 +48,7 @@ * Function to create a new PI estimator */ -SUNDomEigEstimator SUNDomEigEst_PI(N_Vector q, int max_powiter, SUNContext sunctx) +SUNDomEigEstimator SUNDomEigEst_PI(N_Vector q, sunindextype max_powiter, SUNContext sunctx) { SUNFunctionBegin(sunctx); SUNDomEigEstimator DEE; @@ -159,7 +159,7 @@ SUNErrCode SUNDomEigEstSetATimes_PI(SUNDomEigEstimator DEE, void* A_data, SUNATi return SUN_SUCCESS; } -SUNErrCode SUNDomEigEst_PISetMaxPowerIter(SUNDomEigEstimator DEE, int max_powiter) +SUNErrCode SUNDomEigEst_PISetMaxPowerIter(SUNDomEigEstimator DEE, sunindextype max_powiter) { SUNFunctionBegin(DEE->sunctx); @@ -180,7 +180,7 @@ SUNErrCode SUNDomEigEstPreProcess_PI(SUNDomEigEstimator DEE) SUNAssert(PI_CONTENT(DEE)->q, SUN_ERR_ARG_CORRUPT); sunrealtype normq; - int i, retval; + sunindextype i, retval; /* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ for(i = 0; i < PI_CONTENT(DEE)->power_of_A; i++) @@ -225,7 +225,7 @@ SUNErrCode SUNDomEigEstimate_PI(SUNDomEigEstimator DEE, suncomplextype* dom_eig) dom_eig_old.real = ZERO; dom_eig_old.imag = ZERO; - int retval, k; + sunindextype retval, k; sunrealtype normq; for (k = 0; k < PI_CONTENT(DEE)->max_powiter; k++) @@ -269,7 +269,7 @@ SUNErrCode SUNDomEigEstimate_PI(SUNDomEigEstimator DEE, suncomplextype* dom_eig) return SUN_SUCCESS; } -int SUNDomEigEstNumIters_PI(SUNDomEigEstimator DEE) +sunindextype SUNDomEigEstNumIters_PI(SUNDomEigEstimator DEE) { return PI_CONTENT(DEE)->numiters; } @@ -290,7 +290,7 @@ SUNErrCode SUNDomEigEstFree_PI(SUNDomEigEstimator DEE) } if (PI_CONTENT(DEE)->V) { - N_VDestroyVectorArray(PI_CONTENT(DEE)->V, 1); + N_VDestroy(PI_CONTENT(DEE)->V); PI_CONTENT(DEE)->V = NULL; } From b8581ebef2f4a30ba8187c4880ca794978ae77c5 Mon Sep 17 00:00:00 2001 From: maggul Date: Sun, 8 Jun 2025 17:05:56 -0500 Subject: [PATCH 026/128] unit tests --- include/sundials/sundials_core.h | 1 + include/sundials/sundials_domeigestimator.h | 2 +- include/sundomeigest/sundomeigest_pi.h | 3 + src/sundomeigest/ArnI/sundomeigest_arni.c | 3 +- src/sundomeigest/PI/sundomeigest_pi.c | 11 +- test/unit_tests/CMakeLists.txt | 2 + test/unit_tests/sundials/CMakeLists.txt | 57 +--- test/unit_tests/sundomeigest/CMakeLists.txt | 39 +++ .../sundomeigest/arni/CMakeLists.txt | 121 ++++++++ .../arni/test_sundomeigest_arni.c} | 1 - .../unit_tests/sundomeigest/pi/CMakeLists.txt | 121 ++++++++ .../sundomeigest/pi/test_sundomeigest_pi.c | 282 ++++++++++++++++++ .../sundomeigest/test_sundomeigest.c | 196 ++++++++++++ .../sundomeigest/test_sundomeigest.h | 49 +++ 14 files changed, 827 insertions(+), 61 deletions(-) create mode 100644 test/unit_tests/sundomeigest/CMakeLists.txt create mode 100644 test/unit_tests/sundomeigest/arni/CMakeLists.txt rename test/unit_tests/{sundials/test_domeig.c => sundomeigest/arni/test_sundomeigest_arni.c} (99%) create mode 100644 test/unit_tests/sundomeigest/pi/CMakeLists.txt create mode 100644 test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c create mode 100644 test/unit_tests/sundomeigest/test_sundomeigest.c create mode 100644 test/unit_tests/sundomeigest/test_sundomeigest.h diff --git a/include/sundials/sundials_core.h b/include/sundials/sundials_core.h index a22eeca389..70785afcbb 100644 --- a/include/sundials/sundials_core.h +++ b/include/sundials/sundials_core.h @@ -33,6 +33,7 @@ #include #include #include +#include #if SUNDIALS_MPI_ENABLED #include diff --git a/include/sundials/sundials_domeigestimator.h b/include/sundials/sundials_domeigestimator.h index e0f982692f..c8f70daff6 100644 --- a/include/sundials/sundials_domeigestimator.h +++ b/include/sundials/sundials_domeigestimator.h @@ -20,7 +20,7 @@ #include /* serial N_Vector types, fcts., macros */ #include #include -#include "sundials/sundials_errors.h" +#include #include #ifdef __cplusplus /* wrapper to enable C++ usage */ diff --git a/include/sundomeigest/sundomeigest_pi.h b/include/sundomeigest/sundomeigest_pi.h index 2ec77606eb..c25217858f 100644 --- a/include/sundomeigest/sundomeigest_pi.h +++ b/include/sundomeigest/sundomeigest_pi.h @@ -68,6 +68,9 @@ SUNDomEigEstimator_Type SUNDomEigEst_PIGetType(SUNDomEigEstimator DEE); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstInitialize_PI(SUNDomEigEstimator DEE); +SUNDIALS_EXPORT +SUNErrCode SUNDomEigEstSetNumofPreProcess_PI(SUNDomEigEstimator DEE, sunindextype numofperprocess); + SUNDIALS_EXPORT SUNErrCode SUNDomEigEstSetATimes_PI(SUNDomEigEstimator DEE, void* A_data, SUNATimesFn ATimes); diff --git a/src/sundomeigest/ArnI/sundomeigest_arni.c b/src/sundomeigest/ArnI/sundomeigest_arni.c index ef5ea499c6..d69413f68d 100644 --- a/src/sundomeigest/ArnI/sundomeigest_arni.c +++ b/src/sundomeigest/ArnI/sundomeigest_arni.c @@ -185,8 +185,7 @@ SUNErrCode SUNDomEigEstSetNumofPreProcess_ArnI(SUNDomEigEstimator DEE, sunindext { SUNFunctionBegin(DEE->sunctx); - /* set function pointers to integrator-supplied ATimes routine - and data, and return with success */ + /* set the number of warmups */ ArnI_CONTENT(DEE)->power_of_A = numofperprocess; return SUN_SUCCESS; } diff --git a/src/sundomeigest/PI/sundomeigest_pi.c b/src/sundomeigest/PI/sundomeigest_pi.c index 5c8e92387f..dde75f4b5f 100644 --- a/src/sundomeigest/PI/sundomeigest_pi.c +++ b/src/sundomeigest/PI/sundomeigest_pi.c @@ -73,7 +73,7 @@ SUNDomEigEstimator SUNDomEigEst_PI(N_Vector q, sunindextype max_powiter, SUNCont DEE->ops->gettype = SUNDomEigEst_PIGetType; DEE->ops->setatimes = SUNDomEigEstSetATimes_PI; DEE->ops->setmaxpoweriter = SUNDomEigEst_PISetMaxPowerIter; - DEE->ops->setnumofperprocess = NULL; + DEE->ops->setnumofperprocess = SUNDomEigEstSetNumofPreProcess_PI; DEE->ops->initialize = SUNDomEigEstInitialize_PI; DEE->ops->preprocess = SUNDomEigEstPreProcess_PI; DEE->ops->computehess = NULL; @@ -148,6 +148,15 @@ SUNErrCode SUNDomEigEstInitialize_PI(SUNDomEigEstimator DEE) return SUN_SUCCESS; } +SUNErrCode SUNDomEigEstSetNumofPreProcess_PI(SUNDomEigEstimator DEE, sunindextype numofperprocess) +{ + SUNFunctionBegin(DEE->sunctx); + + /* set the number of warmups */ + PI_CONTENT(DEE)->power_of_A = numofperprocess; + return SUN_SUCCESS; +} + SUNErrCode SUNDomEigEstSetATimes_PI(SUNDomEigEstimator DEE, void* A_data, SUNATimesFn ATimes) { SUNFunctionBegin(DEE->sunctx); diff --git a/test/unit_tests/CMakeLists.txt b/test/unit_tests/CMakeLists.txt index 4ce4c9f202..d6a697723f 100644 --- a/test/unit_tests/CMakeLists.txt +++ b/test/unit_tests/CMakeLists.txt @@ -58,6 +58,8 @@ add_subdirectory(sunnonlinsol) add_subdirectory(sunadjointcheckpointscheme) +add_subdirectory(sundomeigest) + if(CXX_FOUND) add_subdirectory(logging) add_subdirectory(sunmemory) diff --git a/test/unit_tests/sundials/CMakeLists.txt b/test/unit_tests/sundials/CMakeLists.txt index b000441e60..6a6248ab0f 100644 --- a/test/unit_tests/sundials/CMakeLists.txt +++ b/test/unit_tests/sundials/CMakeLists.txt @@ -33,59 +33,4 @@ if(TARGET GTest::gtest_main AND TARGET GTest::gmock) gtest_discover_tests(${test}) endforeach() -endif() - - -# Tests for the domeig utility routine (estimates dominant eigenvalue; depends on LAPACK) -if(ENABLE_LAPACK) - set(unit_tests_lapack - "test_domeig\;100 10 10\;" - "test_domeig\;1000 20 10\;" - "test_domeig\;10000 50 10\;") - - # Add the build and install targets for each test - foreach(test_tuple ${unit_tests_lapack}) - - # parse the test tuple - list(GET test_tuple 0 test) - list(GET test_tuple 1 test_args) - - # check if this test has already been added, only need to add test source - # files once for testing with different inputs - if(NOT TARGET ${test}) - - # test source files - add_executable(${test} ${test}.c) - - set_target_properties(${test} PROPERTIES FOLDER "unit_tests") - - # include location of public and private header files - target_include_directories( - ${test} PRIVATE $ - ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/src) - - # libraries to link against - set(_domeig_libs sundials_core sundials_nvecserial sundials_sundomeigestpi sundials_sundomeigestarni LAPACK::LAPACK) - if(CMAKE_VERSION VERSION_LESS 3.20) - list(APPEND _domeig_libs BLAS::BLAS) - endif() - target_link_libraries(${test} ${_domeig_libs} - ${EXE_EXTRA_LINK_LIBS}) - - endif() - - # check if test args are provided and set the test name - if("${test_args}" STREQUAL "") - set(test_name ${test}) - else() - string(REPLACE " " "_" test_name "${test}_${test_args}") - string(REPLACE " " ";" test_args "${test_args}") - endif() - - # add test to regression tests - add_test(NAME ${test_name} COMMAND ${test} ${test_args}) - - endforeach() - - message(STATUS "Added domeig units tests") -endif() +endif() \ No newline at end of file diff --git a/test/unit_tests/sundomeigest/CMakeLists.txt b/test/unit_tests/sundomeigest/CMakeLists.txt new file mode 100644 index 0000000000..f4a833db3f --- /dev/null +++ b/test/unit_tests/sundomeigest/CMakeLists.txt @@ -0,0 +1,39 @@ +# --------------------------------------------------------------- +# Programmer(s): Mustafa Aggul @ SMU +# --------------------------------------------------------------- +# SUNDIALS Copyright Start +# Copyright (c) 2002-2025, Lawrence Livermore National Security +# and Southern Methodist University. +# All rights reserved. +# +# See the top-level LICENSE and NOTICE files for details. +# +# SPDX-License-Identifier: BSD-3-Clause +# SUNDIALS Copyright End +# --------------------------------------------------------------- +# test/unit_tests/sundomeigest level CMakeLists.txt for SUNDIALS +# --------------------------------------------------------------- + +if(ENABLE_CALIPER AND SUNDIALS_BUILD_WITH_PROFILING) + include_directories(${caliper_INCLUDE_DIR}) + set(EXE_EXTRA_LINK_LIBS ${EXE_EXTRA_LINK_LIBS} caliper) +endif() + + +# Always add the power iteration examples +add_subdirectory(pi) + +# Add the Arnoldi iteration examples if LAPACK is enabled +if(ENABLE_LAPACK) + add_subdirectory(arni) +endif() + +# Build the sundials_sundomeigest test utilities +add_library(sundials_sundomeigest_obj OBJECT test_sundomeigest.c test_sundomeigest.h) +if(BUILD_SHARED_LIBS) + # need PIC when shared libs are used since the example executables will link + # to the shared lib + set_property(TARGET sundials_sundomeigest_obj PROPERTY POSITION_INDEPENDENT_CODE + TRUE) +endif() +target_link_libraries(sundials_sundomeigest_obj sundials_sundomeigestarni sundials_sundomeigestpi) diff --git a/test/unit_tests/sundomeigest/arni/CMakeLists.txt b/test/unit_tests/sundomeigest/arni/CMakeLists.txt new file mode 100644 index 0000000000..85892491d1 --- /dev/null +++ b/test/unit_tests/sundomeigest/arni/CMakeLists.txt @@ -0,0 +1,121 @@ +# --------------------------------------------------------------- +# Programmer(s): Mustafa Aggul @ SMU +# --------------------------------------------------------------- +# SUNDIALS Copyright Start +# Copyright (c) 2002-2025, Lawrence Livermore National Security +# and Southern Methodist University. +# All rights reserved. +# +# See the top-level LICENSE and NOTICE files for details. +# +# SPDX-License-Identifier: BSD-3-Clause +# SUNDIALS Copyright End +# --------------------------------------------------------------- +# CMakeLists.txt file for sundomeigest ArnI examples +# --------------------------------------------------------------- + +# Example lists are tuples "name\;args\;type" where the type is 'develop' for +# examples excluded from 'make test' in releases + +# Examples using SUNDIALS ArnI dominant eigenvalue estimator +set(sundomeigest_arni_examples + "test_sundomeigest_arni\;100 10 10\;" + "test_sundomeigest_arni\;1000 10 10\;" + "test_sundomeigest_arni\;10000 10 10\;") + +# Dependencies for dominant eigenvalue examples +set(sundomeigest_arni_dependencies test_sundomeigest) + +# Add source directory to include directories +include_directories(. ../..) + +# Add the build and install targets for each example +foreach(example_tuple ${sundomeigest_arni_examples}) + + # parse the example tuple + list(GET example_tuple 0 example) + list(GET example_tuple 1 example_args) + list(GET example_tuple 2 example_type) + + # check if this example has already been added, only need to add example + # source files once for testing with different inputs + if(NOT TARGET ${example}) + # example source files + sundials_add_executable(${example} ${example}.c ../test_sundomeigest.c) + + # folder to organize targets in an IDE + set_target_properties(${example} PROPERTIES FOLDER "Examples") + + # libraries to link against + target_link_libraries(${example} sundials_nvecserial sundials_sundomeigestarni + ${EXE_EXTRA_LINK_LIBS}) + endif() + + # check if example args are provided and set the test name + if("${example_args}" STREQUAL "") + set(test_name ${example}) + else() + string(REGEX REPLACE " " "_" test_name ${example}_${example_args}) + endif() + + # add example to regression tests + sundials_add_test( + ${test_name} ${example} + TEST_ARGS ${example_args} + EXAMPLE_TYPE ${example_type} + NODIFF) + + # install example source files + if(EXAMPLES_INSTALL) + install(FILES ${example}.c ../test_sundomeigest.h ../test_sundomeigest.c + DESTINATION ${EXAMPLES_INSTALL_PATH}/sundomeigest/arni) + endif() + +endforeach(example_tuple ${sundomeigest_arni_examples}) + +if(EXAMPLES_INSTALL) + + # Install the README file + install(FILES DESTINATION ${EXAMPLES_INSTALL_PATH}/sundomeigest/arni) + + # Prepare substitution variables for Makefile and/or CMakeLists templates + set(SOLVER_LIB "sundials_sundomeigestarni") + + examples2string(sundomeigest_arni_examples EXAMPLES) + examples2string(sundomeigest_arni_dependencies EXAMPLES_DEPENDENCIES) + + # Regardless of the platform we're on, we will generate and install + # CMakeLists.txt file for building the examples. This file can then be used + # as a template for the user's own programs. + + # generate CMakelists.txt in the binary directory + configure_file( + ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_serial_C_ex.in + ${PROJECT_BINARY_DIR}/test/unit_tests/sundomeigest/arni/CMakeLists.txt + @ONLY) + + # install CMakelists.txt + install( + FILES + ${PROJECT_BINARY_DIR}/test/unit_tests/sundomeigest/arni/CMakeLists.txt + DESTINATION ${EXAMPLES_INSTALL_PATH}/sundomeigest/arni) + + # On UNIX-type platforms, we also generate and install a makefile for + # building the examples. This makefile can then be used as a template for the + # user's own programs. + + if(UNIX) + # generate Makefile and place it in the binary dir + configure_file( + ${PROJECT_SOURCE_DIR}/examples/templates/makefile_serial_C_ex.in + ${PROJECT_BINARY_DIR}/test/unit_tests/sundomeigest/arni/Makefile_ex + @ONLY) + # install the configured Makefile_ex as Makefile + install( + FILES + ${PROJECT_BINARY_DIR}/test/unit_tests/sundomeigest/arni/Makefile_ex + DESTINATION ${EXAMPLES_INSTALL_PATH}/sundomeigest/arni + RENAME Makefile) + endif() + +endif() diff --git a/test/unit_tests/sundials/test_domeig.c b/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c similarity index 99% rename from test/unit_tests/sundials/test_domeig.c rename to test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c index 091e0082c5..21f3fed6dc 100644 --- a/test/unit_tests/sundials/test_domeig.c +++ b/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c @@ -21,7 +21,6 @@ #include /* def. of SUNRsqrt, etc. */ #include /* definition of type sunrealtype */ #include -#include #include diff --git a/test/unit_tests/sundomeigest/pi/CMakeLists.txt b/test/unit_tests/sundomeigest/pi/CMakeLists.txt new file mode 100644 index 0000000000..1e34a06ce7 --- /dev/null +++ b/test/unit_tests/sundomeigest/pi/CMakeLists.txt @@ -0,0 +1,121 @@ +# --------------------------------------------------------------- +# Programmer(s): Mustafa Aggul @ SMU +# --------------------------------------------------------------- +# SUNDIALS Copyright Start +# Copyright (c) 2002-2025, Lawrence Livermore National Security +# and Southern Methodist University. +# All rights reserved. +# +# See the top-level LICENSE and NOTICE files for details. +# +# SPDX-License-Identifier: BSD-3-Clause +# SUNDIALS Copyright End +# --------------------------------------------------------------- +# CMakeLists.txt file for sundomeigest PI examples +# --------------------------------------------------------------- + +# Example lists are tuples "name\;args\;type" where the type is 'develop' for +# examples excluded from 'make test' in releases + +# Examples using SUNDIALS PI dominant eigenvalue estimator +set(sundomeigest_pi_examples + "test_sundomeigest_pi\;100 10 10\;" + "test_sundomeigest_pi\;1000 10 10\;" + "test_sundomeigest_pi\;10000 10 10\;") + +# Dependencies for dominant eigenvalue examples +set(sundomeigest_pi_dependencies test_sundomeigest) + +# Add source directory to include directories +include_directories(. ../..) + +# Add the build and install targets for each example +foreach(example_tuple ${sundomeigest_pi_examples}) + + # parse the example tuple + list(GET example_tuple 0 example) + list(GET example_tuple 1 example_args) + list(GET example_tuple 2 example_type) + + # check if this example has already been added, only need to add example + # source files once for testing with different inputs + if(NOT TARGET ${example}) + # example source files + sundials_add_executable(${example} ${example}.c ../test_sundomeigest.c) + + # folder to organize targets in an IDE + set_target_properties(${example} PROPERTIES FOLDER "Examples") + + # libraries to link against + target_link_libraries(${example} sundials_nvecserial sundials_sundomeigestpi + ${EXE_EXTRA_LINK_LIBS}) + endif() + + # check if example args are provided and set the test name + if("${example_args}" STREQUAL "") + set(test_name ${example}) + else() + string(REGEX REPLACE " " "_" test_name ${example}_${example_args}) + endif() + + # add example to regression tests + sundials_add_test( + ${test_name} ${example} + TEST_ARGS ${example_args} + EXAMPLE_TYPE ${example_type} + NODIFF) + + # install example source files + if(EXAMPLES_INSTALL) + install(FILES ${example}.c ../test_sundomeigest.h ../test_sundomeigest.c + DESTINATION ${EXAMPLES_INSTALL_PATH}/sundomeigest/pi) + endif() + +endforeach(example_tuple ${sundomeigest_pi_examples}) + +if(EXAMPLES_INSTALL) + + # Install the README file + install(FILES DESTINATION ${EXAMPLES_INSTALL_PATH}/sundomeigest/pi) + + # Prepare substitution variables for Makefile and/or CMakeLists templates + set(SOLVER_LIB "sundials_sundomeigestpi") + + examples2string(sundomeigest_pi_examples EXAMPLES) + examples2string(sundomeigest_pi_dependencies EXAMPLES_DEPENDENCIES) + + # Regardless of the platform we're on, we will generate and install + # CMakeLists.txt file for building the examples. This file can then be used + # as a template for the user's own programs. + + # generate CMakelists.txt in the binary directory + configure_file( + ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_serial_C_ex.in + ${PROJECT_BINARY_DIR}/test/unit_tests/sundomeigest/pi/CMakeLists.txt + @ONLY) + + # install CMakelists.txt + install( + FILES + ${PROJECT_BINARY_DIR}/test/unit_tests/sundomeigest/pi/CMakeLists.txt + DESTINATION ${EXAMPLES_INSTALL_PATH}/sundomeigest/pi) + + # On UNIX-type platforms, we also generate and install a makefile for + # building the examples. This makefile can then be used as a template for the + # user's own programs. + + if(UNIX) + # generate Makefile and place it in the binary dir + configure_file( + ${PROJECT_SOURCE_DIR}/examples/templates/makefile_serial_C_ex.in + ${PROJECT_BINARY_DIR}/test/unit_tests/sundomeigest/pi/Makefile_ex + @ONLY) + # install the configured Makefile_ex as Makefile + install( + FILES + ${PROJECT_BINARY_DIR}/test/unit_tests/sundomeigest/pi/Makefile_ex + DESTINATION ${EXAMPLES_INSTALL_PATH}/sundomeigest/pi + RENAME Makefile) + endif() + +endif() diff --git a/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c b/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c new file mode 100644 index 0000000000..13a11a4ae0 --- /dev/null +++ b/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c @@ -0,0 +1,282 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Mustafa Aggul @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2025, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------- + * These test functions check some components of an DomEig iteration + * module implementation. + * ----------------------------------------------------------------- + */ + +#include +#include +#include /* def. of SUNRsqrt, etc. */ +#include /* definition of type sunrealtype */ +#include +#include + + +#if defined(SUNDIALS_EXTENDED_PRECISION) +#define GSYM "Lg" +#define ESYM "Le" +#define FSYM "Lf" +#else +#define GSYM "g" +#define ESYM "e" +#define FSYM "f" +#endif + +/* constants */ +#define ZERO SUN_RCONST(0.0) + +#define factor (-100.0) +#define realpart (-30000.0) +#define imagpart (0.0) + +/* user data structure */ +typedef struct +{ + sunindextype N; /* problem size */ + N_Vector d; /* matrix diagonal */ + sunrealtype real_part; /* nondiagonal entries of the matrix */ + sunrealtype imag_part; /* nondiagonal entries of the matrix */ +} UserData; + +/* private functions */ +/* matrix-vector product */ +int ATimes(void* ProbData, N_Vector v, N_Vector z); +/* checks function return values */ +static int check_flag(void* flagvalue, const char* funcname, int opt); +/* uniform random number generator in [0,1] */ +static int check_vector(N_Vector X, N_Vector Y, sunrealtype tol); + +/* global copy of the problem size (for check_vector routine) */ +sunindextype problem_size; + + +/* ---------------------------------------------------------------------- + * DomEig Module Testing Routine + * --------------------------------------------------------------------*/ +int main(int argc, char* argv[]) +{ + int fails = 0; /* counter for test failures */ + int passfail = 0; /* overall pass/fail flag */ + N_Vector q; /* test vectors */ + UserData ProbData; /* problem data structure */ + int maxl, failure, power_of_A; + SUNContext sunctx; + sunrealtype tolerans = 1.0e-2; + + if (SUNContext_Create(SUN_COMM_NULL, &sunctx)) + { + printf("ERROR: SUNContext_Create failed\n"); + return (-1); + } + + /* check inputs: local problem size */ + if (argc < 4) + { + printf("ERROR: TWO (2) Inputs required:\n"); + printf(" Problem size should be >0\n"); + printf(" Krylov subspace dimension should be >0\n"); + printf(" Number of preprocessing should be >= 0\n"); + return 1; + } + ProbData.N = (sunindextype)atol(argv[1]); + problem_size = ProbData.N; + if (ProbData.N <= 0) + { + printf("ERROR: Problem size must be a positive integer\n"); + return 1; + } + maxl = atoi(argv[2]); + if (maxl <= 0) + { + printf( + "ERROR: Krylov subspace dimension must be a positive integer\n"); + return 1; + } + power_of_A = atoi(argv[3]); + if (power_of_A < 0) + { + printf( + "ERROR: Number of preprocessing must be a nonnegative integer\n"); + return 1; + } + printf("\nDomEig module test:\n"); + printf(" Problem size = %ld\n", (long int)ProbData.N); + printf(" Krylov subspace dimension = %i\n", maxl); + printf(" Number of preprocessing = %i\n", power_of_A); + + /* Create vectors */ + q = N_VNew_Serial(ProbData.N, sunctx); + if (check_flag(q, "N_VNew_Serial", 0)) { return 1; } + ProbData.d = N_VClone(q); + if (check_flag(ProbData.d, "N_VClone", 0)) { return 1; } + + /* Fill q vector with 1s */ + N_VConst(SUN_RCONST(1.0), q); + + /* Fill matrix diagonal and problem data */ + // real diag is factor*[3 4 5 ... N 0 0] + // suncomplextype diag is [ realpart imagpart; + // -imagpart realpart] + sunrealtype *v = N_VGetArrayPointer(ProbData.d); + int i, j; + for(i = 0; i < ProbData.N-2; i++) + { + v[i] = factor*(i + 3); + } + + ProbData.real_part = realpart; + ProbData.imag_part = imagpart; + + /* Create DomEig estimator*/ + SUNDomEigEstimator DEE = NULL; + + DEE = SUNDomEigEst_PI(q, maxl, sunctx); + if (check_flag(DEE, "SUNDomEigEst_PI", 0)) { return 1; } + + /* Set Atimes*/ + passfail = DEE->ops->setatimes(DEE, &ProbData, ATimes); + if (check_flag(&passfail, "setatimes", 1)) { return 1; } + + /* Set the number of preprocessings */ + if(DEE->ops->setnumofperprocess != NULL) + { + passfail = DEE->ops->setnumofperprocess(DEE, power_of_A); + if (check_flag(&passfail, "setnumofperprocess", 1)) { return 1; } + } + + /* Initialize the estimator */ + passfail = DEE->ops->initialize(DEE); + if (check_flag(&passfail, "initialize", 1)) { return 1; } + + /* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ + passfail = DEE->ops->preprocess(DEE); + if (check_flag(&passfail, "preprocess", 1)) { return 1; } + + /* Estimate the dominant eigenvalue */ + suncomplextype dom_eig; + passfail = DEE->ops->estimate(DEE, &dom_eig); + if (check_flag(&passfail, "estimate", 1)) { return 1; } + + sunrealtype norm_of_dom_eig = SUNRsqrt(dom_eig.real * dom_eig.real + dom_eig.imag * dom_eig.imag); + if(norm_of_dom_eig < SUN_SMALL_REAL) { + printf("FAIL: Dominant Eigenvalue Test Failed"); + return 1; + } + + suncomplextype true_dom_eig; + /* Identify true_dom_eig based on given parameters*/ + if(SUNRsqrt(realpart * realpart + imagpart * imagpart) > -1.0 * factor * ProbData.N) + { + true_dom_eig.real = realpart; + true_dom_eig.imag = imagpart; + } + else + { + true_dom_eig.real = factor*ProbData.N; + true_dom_eig.imag = ZERO; + } + + printf("\ncomputed dominant eigenvalue = %20.4lf + %20.4lfi\n", dom_eig.real, dom_eig.imag); + printf(" true dominant eigenvalue = %20.4lf + %20.4lfi\n", true_dom_eig.real, true_dom_eig.imag); + + /* Compare the estimated dom_eig with true_dom_eig*/ + sunrealtype error = SUNRsqrt((dom_eig.real - true_dom_eig.real) * (dom_eig.real - true_dom_eig.real) + + (dom_eig.imag - true_dom_eig.imag) * (dom_eig.imag - true_dom_eig.imag)); + + error /= norm_of_dom_eig; + + if(error < tolerans) { + printf("\n\nPASS: relative error = %lf\n", error); + return 0; + } + else { + printf("\n\nFAIL: relative error = %lf\n", error); + return 0; + } + + /* Free solver and vectors */ + N_VDestroy(q); + N_VDestroy(ProbData.d); + SUNContext_Free(&sunctx); + DEE->ops->free(DEE); + + return (passfail); +} + +/* ---------------------------------------------------------------------- + * Private helper functions + * --------------------------------------------------------------------*/ + +/* matrix-vector product */ +int ATimes(void* Data, N_Vector v_vec, N_Vector z_vec) +{ + /* local variables */ + sunrealtype *v, *z, *diag, real_part, imag_part; + sunindextype i, N; + UserData* ProbData; + + /* access user data structure and vector data */ + ProbData = (UserData*)Data; + v = N_VGetArrayPointer(v_vec); + if (check_flag(v, "N_VGetArrayPointer", 0)) { return 1; } + z = N_VGetArrayPointer(z_vec); + if (check_flag(z, "N_VGetArrayPointer", 0)) { return 1; } + N = ProbData->N; + real_part = ProbData->real_part; + imag_part = ProbData->imag_part; + diag = N_VGetArrayPointer(ProbData->d); + if (check_flag(diag, "N_VGetArrayPointer", 0)) { return 1; } + + /* perform product on the diagonal part of the matrix */ + for (i = 0; i < N - 2; i++) + { + z[i] = diag[i] * v[i]; + } + + /* perform product at the non-diagonal last two rows */ + z[N - 2] = v[N - 2] * real_part + v[N - 1] * imag_part; + z[N - 1] = v[N - 1] * real_part - v[N - 2] * imag_part; + /* return with success */ + return 0; +} + +/* Check function return value based on "opt" input: + 0: function allocates memory so check for NULL pointer + 1: function returns a flag so check for flag != 0 */ +static int check_flag(void* flagvalue, const char* funcname, int opt) +{ + int* errflag; + + /* Check if function returned NULL pointer - no memory allocated */ + if (opt == 0 && flagvalue == NULL) + { + fprintf(stderr, "\nERROR: %s() failed - returned NULL pointer\n\n", funcname); + return 1; + } + + /* Check if flag != 0 */ + if (opt == 1) + { + errflag = (int*)flagvalue; + if (*errflag != 0) + { + fprintf(stderr, "\nERROR: %s() failed with flag = %d\n\n", funcname, + *errflag); + return 1; + } + } + + return 0; +} diff --git a/test/unit_tests/sundomeigest/test_sundomeigest.c b/test/unit_tests/sundomeigest/test_sundomeigest.c new file mode 100644 index 0000000000..c31f756849 --- /dev/null +++ b/test/unit_tests/sundomeigest/test_sundomeigest.c @@ -0,0 +1,196 @@ +/* + * ----------------------------------------------------------------- + * Programmer(s): Mustafa Aggul @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2025, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------- + * These test functions are designed to check a SUNDomEigEstimator + * module implementation. + * ----------------------------------------------------------------- + */ + +#include "test_sundomeigest.h" + +#include +#include +#include +#include +#include +#include + +#if defined(SUNDIALS_HAVE_POSIX_TIMERS) +#include +#include +#endif + +/* private functions */ +static double get_time(void); + +int print_time = 0; + +#define PRINT_TIME(format, time) \ + if (print_time) printf(format, time) + +/* ---------------------------------------------------------------------- + * SUNDomEigEstGetType Test + * --------------------------------------------------------------------*/ +int Test_SUNDomEigEstGetType(SUNDomEigEstimator DEE, SUNLinearSolver_Type suntype, + int myid) +{ + double start_time, stop_time; + SUNLinearSolver_Type mysuntype; + + start_time = get_time(); + mysuntype = SUNDomEigEstGetType(DEE); + // sync_device(); + stop_time = get_time(); + + if (suntype != mysuntype) + { + printf(">>> FAILED test -- SUNDomEigEstGetType, Proc %d \n", myid); + PRINT_TIME(" SUNDomEigEstGetType Time: %22.15e \n \n", + stop_time - start_time); + return (1); + } + else if (myid == 0) + { + printf(" PASSED test -- SUNDomEigEstGetType \n"); + PRINT_TIME(" SUNDomEigEstGetType Time: %22.15e \n \n", + stop_time - start_time); + } + + return (0); +} + +/* ---------------------------------------------------------------------- + * SUNDomEigEstSetATimes Test + * --------------------------------------------------------------------*/ +int Test_SUNDomEigEstSetATimes(SUNDomEigEstimator DEE, void* ATdata, SUNATimesFn ATimes, + int myid) +{ + int failure; + double start_time, stop_time; + + /* try calling SetATimes routine: should pass/fail based on expected input */ + start_time = get_time(); + failure = SUNDomEigEstSetATimes(DEE, ATdata, ATimes); + // sync_device(); + stop_time = get_time(); + + if (failure) + { + printf(">>> FAILED test -- SUNDomEigEstSetATimes returned %d on Proc %d \n", + failure, myid); + return (1); + } + else if (myid == 0) + { + printf(" PASSED test -- SUNDomEigEstSetATimes \n"); + PRINT_TIME(" SUNDomEigEstSetATimes Time: %22.15e \n \n", + stop_time - start_time); + } + + return (0); +} + +/* ---------------------------------------------------------------------- + * SUNDomEigEstInitialize Test + * --------------------------------------------------------------------*/ +int Test_SUNDomEigEstInitialize(SUNDomEigEstimator DEE, int myid) +{ + int failure; + double start_time, stop_time; + + start_time = get_time(); + failure = SUNDomEigEstInitialize(DEE); + // sync_device(); + stop_time = get_time(); + + if (failure) + { + printf(">>> FAILED test -- SUNDomEigEstInitialize check, Proc %d \n", myid); + PRINT_TIME(" SUNDomEigEstInitialize Time: %22.15e \n \n", + stop_time - start_time); + return (1); + } + else if (myid == 0) + { + printf(" PASSED test -- SUNDomEigEstInitialize \n"); + PRINT_TIME(" SUNDomEigEstInitialize Time: %22.15e \n \n", + stop_time - start_time); + } + + return (0); +} + +/* ---------------------------------------------------------------------- + * SUNDomEigEstPreProcess Test + * --------------------------------------------------------------------*/ +int Test_SUNDomEigEstPreProcess(SUNDomEigEstimator DEE, int myid) +{ + return (0); +} + +/* ---------------------------------------------------------------------- + * SUNDomEigEstComputeHess Test + * --------------------------------------------------------------------*/ +int Test_SUNDomEigEstComputeHess(SUNDomEigEstimator DEE, int myid) +{ + return (0); +} + +/* ---------------------------------------------------------------------- + * SUNDomEigEstimate Test + * --------------------------------------------------------------------*/ +int Test_SUNDomEigEstimate(SUNDomEigEstimator DEE, int myid) +{ + return (0); +} + + +/* ====================================================================== + * Private functions + * ====================================================================*/ + +#if defined(SUNDIALS_HAVE_POSIX_TIMERS) +time_t base_time_tv_sec = 0; /* Base time; makes time values returned + by get_time easier to read when + printed since they will be zero + based. + */ +#endif + +void SetTiming(int onoff) +{ + print_time = onoff; + +#if defined(SUNDIALS_HAVE_POSIX_TIMERS) + struct timespec spec; + clock_gettime(CLOCK_MONOTONIC, &spec); + base_time_tv_sec = spec.tv_sec; +#endif +} + +/* ---------------------------------------------------------------------- + * Timer + * --------------------------------------------------------------------*/ +static double get_time(void) +{ +#if defined(SUNDIALS_HAVE_POSIX_TIMERS) + struct timespec spec; + clock_gettime(CLOCK_MONOTONIC, &spec); + double time = (double)(spec.tv_sec - base_time_tv_sec) + + ((double)(spec.tv_nsec) / 1E9); +#else + double time = 0; +#endif + return time; +} diff --git a/test/unit_tests/sundomeigest/test_sundomeigest.h b/test/unit_tests/sundomeigest/test_sundomeigest.h new file mode 100644 index 0000000000..9c57e063ce --- /dev/null +++ b/test/unit_tests/sundomeigest/test_sundomeigest.h @@ -0,0 +1,49 @@ +/* + * ----------------------------------------------------------------- + * Programmer(s): Mustafa Aggul @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2025, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------- + * This is the header file contains the prototypes for functions to + * test SUNDomEigEstimator module implementations. + * ----------------------------------------------------------------- + */ + +#include +#include + +/* define constants */ +#define ZERO SUN_RCONST(0.0) +#define ONE SUN_RCONST(1.0) + +#ifdef __cplusplus /* wrapper to enable C++ usage */ +extern "C" { +#endif +/* Forward declarations for implementation specific utility functions */ +int check_vector(N_Vector expected, N_Vector computed, sunrealtype tol); +// void sync_device(void); + +/* Test function declarations */ +int Test_SUNDomEigEstGetType(SUNDomEigEstimator DEE, SUNLinearSolver_Type suntype, + int myid); +int Test_SUNDomEigEstSetATimes(SUNDomEigEstimator DEE, void* ATdata, SUNATimesFn ATimes, + int myid); +int Test_SUNDomEigEstInitialize(SUNDomEigEstimator DEE, int myid); +int Test_SUNDomEigEstPreProcess(SUNDomEigEstimator DEE, int myid); +int Test_SUNDomEigEstComputeHess(SUNDomEigEstimator DEE, int myid); +int Test_SUNDomEigEstimate(SUNDomEigEstimator DEE, int myid); + +/* Timing function */ +void SetTiming(int onoff); + +#ifdef __cplusplus +} +#endif From 2dd60c4a01208638dd43d32c053af2dc0cef881a Mon Sep 17 00:00:00 2001 From: maggul Date: Sun, 8 Jun 2025 19:13:42 -0500 Subject: [PATCH 027/128] ARKODE_LSRKInternal_DomEigEst_Type --- include/arkode/arkode_lsrkstep.h | 8 ++++ src/arkode/CMakeLists.txt | 32 +++++++------ src/arkode/arkode_lsrkstep.c | 76 +++++++++++++++++++++---------- src/arkode/arkode_lsrkstep_impl.h | 6 ++- src/arkode/arkode_lsrkstep_io.c | 57 ++++++++++++++++++++++- 5 files changed, 139 insertions(+), 40 deletions(-) diff --git a/include/arkode/arkode_lsrkstep.h b/include/arkode/arkode_lsrkstep.h index 8fe11676df..09e59771ea 100644 --- a/include/arkode/arkode_lsrkstep.h +++ b/include/arkode/arkode_lsrkstep.h @@ -42,6 +42,12 @@ typedef enum ARKODE_LSRK_SSP_10_4 } ARKODE_LSRKMethodType; +typedef enum +{ + ARKODE_LSRK_POWER_ITERATION, + ARKODE_LSRK_ARNOLDI_ITERATION +} ARKODE_LSRKInternal_DomEigEst_Type; + /* ------------------- * Exported Functions * ------------------- */ @@ -76,6 +82,8 @@ SUNDIALS_EXPORT int LSRKStepSetSSPMethodByName(void* arkode_mem, SUNDIALS_EXPORT int LSRKStepSetDomEigFn(void* arkode_mem, ARKDomEigFn dom_eig); +SUNDIALS_EXPORT int LSRKStepSetInternalDomEigEstType(void* arkode_mem, ARKODE_LSRKInternal_DomEigEst_Type dom_eig_type); + SUNDIALS_EXPORT int LSRKStepSetDomEigFrequency(void* arkode_mem, long int nsteps); SUNDIALS_EXPORT int LSRKStepSetMaxNumStages(void* arkode_mem, diff --git a/src/arkode/CMakeLists.txt b/src/arkode/CMakeLists.txt index b46d5ab05c..68f19111bc 100644 --- a/src/arkode/CMakeLists.txt +++ b/src/arkode/CMakeLists.txt @@ -69,17 +69,8 @@ set(arkode_HEADERS arkode_sprk.h arkode_sprkstep.h) -# Add prefix with complete path to the ARKODE header files -add_prefix(${SUNDIALS_SOURCE_DIR}/include/arkode/ arkode_HEADERS) - -# Create the sundials_arkode library -sundials_add_library( - sundials_arkode - SOURCES ${arkode_SOURCES} - HEADERS ${arkode_HEADERS} - INCLUDE_SUBDIR arkode - LINK_LIBRARIES PUBLIC sundials_core - OBJECT_LIBRARIES +# Add variable arkode_OBJECT_LIBRARIES +set(arkode_OBJECT_LIBRARIES sundials_sunmemsys_obj sundials_nvecserial_obj sundials_nvecmanyvector_obj @@ -99,8 +90,23 @@ sundials_add_library( sundials_sunnonlinsolnewton_obj sundials_sunnonlinsolfixedpoint_obj sundials_adjointcheckpointscheme_fixed_obj - sundials_sundomeigestpi_obj - sundials_sundomeigestarni_obj + sundials_sundomeigestpi_obj) + +if(ENABLE_LAPACK) + list(APPEND arkode_OBJECT_LIBRARIES sundials_sundomeigestarni_obj) +endif() + +# Add prefix with complete path to the ARKODE header files +add_prefix(${SUNDIALS_SOURCE_DIR}/include/arkode/ arkode_HEADERS) + +# Create the sundials_arkode library +sundials_add_library( + sundials_arkode + SOURCES ${arkode_SOURCES} + HEADERS ${arkode_HEADERS} + INCLUDE_SUBDIR arkode + LINK_LIBRARIES PUBLIC sundials_core + OBJECT_LIBRARIES ${arkode_OBJECT_LIBRARIES} OUTPUT_NAME sundials_arkode VERSION ${arkodelib_VERSION} SOVERSION ${arkodelib_SOVERSION}) diff --git a/src/arkode/arkode_lsrkstep.c b/src/arkode/arkode_lsrkstep.c index 73089a1326..2bf970ec67 100644 --- a/src/arkode/arkode_lsrkstep.c +++ b/src/arkode/arkode_lsrkstep.c @@ -193,6 +193,9 @@ void* lsrkStep_Create_Commons(ARKRhsFn rhs, sunrealtype t0, N_Vector y0, step_mem->fe = rhs; step_mem->domeig_rhs = NULL; + /* Set internal DomEigEst type */ + step_mem->internal_domeigest_type = ARKODE_LSRK_POWER_ITERATION; + /* Set NULL for dom_eig_fn */ step_mem->dom_eig_fn = NULL; @@ -2204,7 +2207,21 @@ int lsrkStep_ComputeNewDomEig(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem) suncomplextype dom_eig; - if(step_mem->dom_eig_fn == NULL) + if (step_mem->dom_eig_fn != NULL) + { + retval = step_mem->dom_eig_fn(ark_mem->tn, ark_mem->ycur, ark_mem->fn, + &step_mem->lambdaR, &step_mem->lambdaI, + ark_mem->user_data, ark_mem->tempv1, + ark_mem->tempv2, ark_mem->tempv3); + step_mem->dom_eig_num_evals++; + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_DOMEIG_FAIL, __LINE__, __func__, __FILE__, + "Unable to estimate the dominant eigenvalue"); + return ARK_DOMEIG_FAIL; + } + } + else if (step_mem->DEE != NULL) { dom_eig = lsrkStep_DomEigEstimate(ark_mem, step_mem->DEE); if((dom_eig.real*dom_eig.real + dom_eig.imag*dom_eig.imag) < SUN_SMALL_REAL) @@ -2220,17 +2237,9 @@ int lsrkStep_ComputeNewDomEig(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem) } else { - retval = step_mem->dom_eig_fn(ark_mem->tn, ark_mem->ycur, ark_mem->fn, - &step_mem->lambdaR, &step_mem->lambdaI, - ark_mem->user_data, ark_mem->tempv1, - ark_mem->tempv2, ark_mem->tempv3); - step_mem->dom_eig_num_evals++; - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, ARK_DOMEIG_FAIL, __LINE__, __func__, __FILE__, - "Unable to estimate the dominant eigenvalue"); - return ARK_DOMEIG_FAIL; - } + arkProcessError(ark_mem, ARK_DOMEIG_FAIL, __LINE__, __func__, __FILE__, + "Unable to estimate the dominant eigenvalue: Either a user provided or an internal dominant eigenvalue estimation is required"); + return ARK_DOMEIG_FAIL; } if (step_mem->lambdaR * ark_mem->h > ZERO) @@ -2307,12 +2316,16 @@ SUNDomEigEstimator lsrkStep_DomEigCreate(void* arkode_mem) step_mem->domeig_power_of_A = DOMEIG_POWER_OF_A_DEFAULT; step_mem->domeig_maxiters = DOMEIG_MAX_NUMBER_OF_POWER_ITERS_DEFAULT; - /* Default estimator for the problems sized < 2 is Power Iteration; - Arnoldi iterations, otherwise*/ - /* TODO: Also check if LAPACK enabled */ - if(ark_mem->yn->ops->nvgetlength(ark_mem->yn) > 2) + /* Enforce the power iteration if the problem size < 3 */ + if(step_mem->internal_domeigest_type == ARKODE_LSRK_ARNOLDI_ITERATION && ark_mem->yn->ops->nvgetlength(ark_mem->yn) < 3) { - DEE = SUNDomEigEst_ArnI(step_mem->domeig_q, step_mem->domeig_maxl, ark_mem->sunctx); + step_mem->internal_domeigest_type == ARKODE_LSRK_POWER_ITERATION; + } + + /* Create the internal DomEigEst */ + if(step_mem->internal_domeigest_type == ARKODE_LSRK_POWER_ITERATION) + { + DEE = SUNDomEigEst_PI(step_mem->domeig_q, step_mem->domeig_maxiters, ark_mem->sunctx); if (DEE == NULL) { arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, @@ -2320,15 +2333,27 @@ SUNDomEigEstimator lsrkStep_DomEigCreate(void* arkode_mem) return NULL; } } - else + else if (step_mem->internal_domeigest_type == ARKODE_LSRK_ARNOLDI_ITERATION) { - DEE = SUNDomEigEst_PI(step_mem->domeig_q, step_mem->domeig_maxiters, ark_mem->sunctx); +#ifdef SUNDIALS_BLAS_LAPACK_ENABLED + DEE = SUNDomEigEst_ArnI(step_mem->domeig_q, step_mem->domeig_maxl, ark_mem->sunctx); if (DEE == NULL) { arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, MSG_ARK_INTERNAL_DOMEIG_FAIL); return NULL; } +#else + arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, + "Internal Arnoldi iteration requires LAPACK package"); + return NULL; +#endif + } + else + { + arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, + "Attempted to create an internal domeig estimator with an unknown type"); + return NULL; } /* Set Atimes*/ @@ -2406,13 +2431,16 @@ suncomplextype lsrkStep_DomEigEstimate(void* arkode_mem, SUNDomEigEstimator DEE) } /* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ - retval = DEE->ops->preprocess(DEE); - if (retval != ARK_SUCCESS) + if(DEE->ops->preprocess != NULL) { - arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, - MSG_ARK_INTERNAL_DOMEIG_FAIL); + retval = DEE->ops->preprocess(DEE); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, + MSG_ARK_INTERNAL_DOMEIG_FAIL); - return dom_eig; + return dom_eig; + } } /* Compute the Hessenberg matrix Hes if Arnoldi */ diff --git a/src/arkode/arkode_lsrkstep_impl.h b/src/arkode/arkode_lsrkstep_impl.h index c7b9b4e54b..ab3a933d97 100644 --- a/src/arkode/arkode_lsrkstep_impl.h +++ b/src/arkode/arkode_lsrkstep_impl.h @@ -21,7 +21,10 @@ #include #include #include -#include + +#ifdef SUNDIALS_BLAS_LAPACK_ENABLED + #include +#endif #include "arkode_impl.h" @@ -162,6 +165,7 @@ typedef struct ARKodeLSRKStepMemRec sunrealtype dom_eig_safety; /* some safety factor for the user provided dom_eig*/ long int dom_eig_freq; /* indicates dom_eig update after dom_eig_freq successful steps*/ + ARKODE_LSRKInternal_DomEigEst_Type internal_domeigest_type; /* Internal DomEig estimator type*/ SUNDomEigEstimator DEE; /* DomEig estimator*/ N_Vector domeig_q; /* DomEig initial q vector*/ int domeig_maxl; /* Krylov subspace dimension */ diff --git a/src/arkode/arkode_lsrkstep_io.c b/src/arkode/arkode_lsrkstep_io.c index 1a748b176f..60c61f6ac1 100644 --- a/src/arkode/arkode_lsrkstep_io.c +++ b/src/arkode/arkode_lsrkstep_io.c @@ -217,13 +217,18 @@ int LSRKStepSetDomEigFn(void* arkode_mem, ARKDomEigFn dom_eig) } else { - step_mem->dom_eig_fn = NULL; + /* Set the default internal dominant eigenvalue estimator type */ + if(step_mem->internal_domeigest_type != ARKODE_LSRK_ARNOLDI_ITERATION) + { + step_mem->internal_domeigest_type == ARKODE_LSRK_POWER_ITERATION; + } + /* Create an internal dominant eigenvalue estimator */ step_mem->DEE = lsrkStep_DomEigCreate(arkode_mem); if (step_mem->DEE == NULL) { arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, - "Internal domeig_mem is NULL"); + "Internal DomEigEstimator is NULL"); return ARK_INTERNAL_DOMEIG_FAIL; } @@ -231,6 +236,54 @@ int LSRKStepSetDomEigFn(void* arkode_mem, ARKDomEigFn dom_eig) } } +/*--------------------------------------------------------------- + LSRKStepSetInternalDomEigEstType sets internal DomEigEst type. + ---------------------------------------------------------------*/ +SUNDIALS_EXPORT int LSRKStepSetInternalDomEigEstType(void* arkode_mem, + ARKODE_LSRKInternal_DomEigEst_Type dom_eig_type) +{ + ARKodeMem ark_mem; + ARKodeLSRKStepMem step_mem; + int retval; + + /* access ARKodeMem and ARKodeLSRKStepMem structures */ + retval = lsrkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, + &step_mem); + if (retval != ARK_SUCCESS) { return retval; } + + if (dom_eig_type == ARKODE_LSRK_POWER_ITERATION) + { + step_mem->internal_domeigest_type = ARKODE_LSRK_POWER_ITERATION; + /* Create internal dominant eigenvalue estimator -- PI */ + if(step_mem->DEE == NULL) + { + step_mem->DEE = lsrkStep_DomEigCreate(arkode_mem); + } + } + else if (dom_eig_type == ARKODE_LSRK_ARNOLDI_ITERATION) + { +#ifdef SUNDIALS_BLAS_LAPACK_ENABLED + step_mem->internal_domeigest_type = ARKODE_LSRK_ARNOLDI_ITERATION; + /* Create an internal dominant eigenvalue estimator -- ArnI*/ + if(step_mem->DEE == NULL) + { + step_mem->DEE = lsrkStep_DomEigCreate(arkode_mem); + } +#else + arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, + "Internal Arnoldi iteration requires LAPACK package"); + return ARK_INTERNAL_DOMEIG_FAIL; +#endif + } + else + { + arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, + "Attempted to set an internal domeig estimator with an unknown type"); + return ARK_INTERNAL_DOMEIG_FAIL; + } + return ARK_SUCCESS; +} + /*--------------------------------------------------------------- LSRKStepSetDomEigFrequency sets dom_eig computation frequency - Dominated Eigenvalue is recomputed after "nsteps" successful steps. From a30128deb7210e5416f80507a1b18affefedb1d2 Mon Sep 17 00:00:00 2001 From: maggul Date: Sun, 8 Jun 2025 21:04:29 -0500 Subject: [PATCH 028/128] header updates --- include/sundials/sundials_domeigestimator.h | 9 ++++++--- src/sundials/sundials_domeigestimator.c | 2 +- .../sundomeigest/arni/test_sundomeigest_arni.c | 16 ++++++++++------ .../sundomeigest/pi/test_sundomeigest_pi.c | 16 ++++++++++------ 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/include/sundials/sundials_domeigestimator.h b/include/sundials/sundials_domeigestimator.h index c8f70daff6..7234388144 100644 --- a/include/sundials/sundials_domeigestimator.h +++ b/include/sundials/sundials_domeigestimator.h @@ -17,11 +17,14 @@ #ifndef _DOMEIGEST_H #define _DOMEIGEST_H -#include /* serial N_Vector types, fcts., macros */ +/* TODO: Check to see if they are all required */ +#include +#include #include -#include -#include #include +#include +#include +#include #ifdef __cplusplus /* wrapper to enable C++ usage */ extern "C" { diff --git a/src/sundials/sundials_domeigestimator.c b/src/sundials/sundials_domeigestimator.c index 66aff7efc7..7149063ba3 100644 --- a/src/sundials/sundials_domeigestimator.c +++ b/src/sundials/sundials_domeigestimator.c @@ -19,8 +19,8 @@ #include #include #include -#include +#include #include #if defined(SUNDIALS_BUILD_WITH_PROFILING) diff --git a/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c b/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c index 21f3fed6dc..dbfd0eacb0 100644 --- a/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c +++ b/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c @@ -16,13 +16,17 @@ * ----------------------------------------------------------------- */ -#include +#include #include -#include /* def. of SUNRsqrt, etc. */ -#include /* definition of type sunrealtype */ +#include +#include +#include +#include + #include #include +#include "../test_sundomeigest.h" #if defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" @@ -54,9 +58,9 @@ typedef struct /* matrix-vector product */ int ATimes(void* ProbData, N_Vector v, N_Vector z); /* checks function return values */ -static int check_flag(void* flagvalue, const char* funcname, int opt); +int check_flag(void* flagvalue, const char* funcname, int opt); /* uniform random number generator in [0,1] */ -static int check_vector(N_Vector X, N_Vector Y, sunrealtype tol); +int check_vector(N_Vector X, N_Vector Y, sunrealtype tol); /* global copy of the problem size (for check_vector routine) */ sunindextype problem_size; @@ -259,7 +263,7 @@ int ATimes(void* Data, N_Vector v_vec, N_Vector z_vec) /* Check function return value based on "opt" input: 0: function allocates memory so check for NULL pointer 1: function returns a flag so check for flag != 0 */ -static int check_flag(void* flagvalue, const char* funcname, int opt) +int check_flag(void* flagvalue, const char* funcname, int opt) { int* errflag; diff --git a/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c b/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c index 13a11a4ae0..790db245f3 100644 --- a/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c +++ b/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c @@ -16,13 +16,17 @@ * ----------------------------------------------------------------- */ -#include +#include #include -#include /* def. of SUNRsqrt, etc. */ -#include /* definition of type sunrealtype */ +#include +#include +#include +#include + #include #include +#include "../test_sundomeigest.h" #if defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" @@ -54,9 +58,9 @@ typedef struct /* matrix-vector product */ int ATimes(void* ProbData, N_Vector v, N_Vector z); /* checks function return values */ -static int check_flag(void* flagvalue, const char* funcname, int opt); +int check_flag(void* flagvalue, const char* funcname, int opt); /* uniform random number generator in [0,1] */ -static int check_vector(N_Vector X, N_Vector Y, sunrealtype tol); +int check_vector(N_Vector X, N_Vector Y, sunrealtype tol); /* global copy of the problem size (for check_vector routine) */ sunindextype problem_size; @@ -255,7 +259,7 @@ int ATimes(void* Data, N_Vector v_vec, N_Vector z_vec) /* Check function return value based on "opt" input: 0: function allocates memory so check for NULL pointer 1: function returns a flag so check for flag != 0 */ -static int check_flag(void* flagvalue, const char* funcname, int opt) +int check_flag(void* flagvalue, const char* funcname, int opt) { int* errflag; From dfc1a4133924d42fd39401338037d928a4c8120a Mon Sep 17 00:00:00 2001 From: maggul Date: Mon, 9 Jun 2025 05:50:50 -0500 Subject: [PATCH 029/128] CMakeLists updates --- CMakeLists.txt | 2 +- include/sundomeigest/sundomeigest_arni.h | 1 + scripts/updateVersion.sh | 16 +++++++ src/arkode/CMakeLists.txt | 42 ++++++++++--------- src/sundials/CMakeLists.txt | 15 +------ .../arkode/CXX_parallel/CMakeLists.txt | 19 +++++++-- .../arkode/CXX_serial/CMakeLists.txt | 15 ++++++- .../unit_tests/arkode/C_serial/CMakeLists.txt | 15 ++++++- test/unit_tests/arkode/gtest/CMakeLists.txt | 16 ++++++- test/unit_tests/sundomeigest/CMakeLists.txt | 27 ++++++++---- .../sundomeigest/arni/CMakeLists.txt | 38 ++++++++++------- .../unit_tests/sundomeigest/pi/CMakeLists.txt | 36 +++++++++------- 12 files changed, 165 insertions(+), 77 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 98e721f923..433659b69f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,7 +102,7 @@ set(sunlinsollib_SOVERSION "5") set(sunnonlinsollib_VERSION "4.3.0") set(sunnonlinsollib_SOVERSION "4") -set(sundomeigestlib_VERSION "1.0.0") +set(sundomeigestlib_VERSION "1.3.0") set(sundomeigestlib_SOVERSION "1") set(sundialslib_VERSION diff --git a/include/sundomeigest/sundomeigest_arni.h b/include/sundomeigest/sundomeigest_arni.h index 8a254d7219..1a931828fd 100644 --- a/include/sundomeigest/sundomeigest_arni.h +++ b/include/sundomeigest/sundomeigest_arni.h @@ -24,6 +24,7 @@ #define _DOMEIGEST_ARNI_H #include +#include #ifdef __cplusplus /* wrapper to enable C++ usage */ extern "C" { diff --git a/scripts/updateVersion.sh b/scripts/updateVersion.sh index 7015d84214..4966358736 100755 --- a/scripts/updateVersion.sh +++ b/scripts/updateVersion.sh @@ -164,6 +164,19 @@ else nls_ver="${nls_major}.${nls_minor}.${nls_patch}-${nls_label}" fi +# Set the SUNDomEigEstimator version values. Assume the major version is six +# less than the SUNDIALS major version. +dee_major=$(( sun_major - 6 )) +dee_minor=$sun_minor +dee_patch=$sun_patch +dee_label=$sun_label + +if [ "${dee_label}" == "" ]; then + dee_ver="${dee_major}.${dee_minor}.${dee_patch}" +else + dee_ver="${dee_major}.${dee_minor}.${dee_patch}-${dee_label}" +fi + # ------------------------------------------------------------------------------ # Wrapper for editing inplace with different sed implementations # ------------------------------------------------------------------------------ @@ -217,6 +230,9 @@ sedi "/sunlinsollib_SOVERSION.*/ s/SOVERSION.*/SOVERSION \"${ls_major}\")/" $fn sedi "/sunnonlinsollib_VERSION.*/ s/VERSION.*/VERSION \"${nls_ver}\")/" $fn sedi "/sunnonlinsollib_SOVERSION.*/ s/SOVERSION.*/SOVERSION \"${nls_major}\")/" $fn +sedi "/sundomeigestlib_VERSION.*/ s/VERSION.*/VERSION \"${dee_ver}\")/" $fn +sedi "/sundomeigestlib_SOVERSION.*/ s/SOVERSION.*/SOVERSION \"${dee_major}\")/" $fn + # ------------------------------------------------------------------------------ # Update README files # ------------------------------------------------------------------------------ diff --git a/src/arkode/CMakeLists.txt b/src/arkode/CMakeLists.txt index 68f19111bc..52d756982e 100644 --- a/src/arkode/CMakeLists.txt +++ b/src/arkode/CMakeLists.txt @@ -69,8 +69,28 @@ set(arkode_HEADERS arkode_sprk.h arkode_sprkstep.h) -# Add variable arkode_OBJECT_LIBRARIES -set(arkode_OBJECT_LIBRARIES +# Add variable DOMEIG_OBJECT_LIBRARIES +set(DOMEIG_OBJECT_LIBRARIES sundials_sundomeigestpi_obj) + +if(ENABLE_LAPACK) + list(APPEND DOMEIG_OBJECT_LIBRARIES sundials_sundomeigestarni_obj) + set(LAPACK_LIBRARY LAPACK::LAPACK) + if(CMAKE_VERSION VERSION_LESS 3.20) + list(APPEND LAPACK_LIBRARY BLAS::BLAS) + endif() +endif() + +# Add prefix with complete path to the ARKODE header files +add_prefix(${SUNDIALS_SOURCE_DIR}/include/arkode/ arkode_HEADERS) + +# Create the sundials_arkode library +sundials_add_library( + sundials_arkode + SOURCES ${arkode_SOURCES} + HEADERS ${arkode_HEADERS} + INCLUDE_SUBDIR arkode + LINK_LIBRARIES PUBLIC sundials_core PRIVATE ${LAPACK_LIBRARY} + OBJECT_LIBRARIES sundials_sunmemsys_obj sundials_nvecserial_obj sundials_nvecmanyvector_obj @@ -90,23 +110,7 @@ set(arkode_OBJECT_LIBRARIES sundials_sunnonlinsolnewton_obj sundials_sunnonlinsolfixedpoint_obj sundials_adjointcheckpointscheme_fixed_obj - sundials_sundomeigestpi_obj) - -if(ENABLE_LAPACK) - list(APPEND arkode_OBJECT_LIBRARIES sundials_sundomeigestarni_obj) -endif() - -# Add prefix with complete path to the ARKODE header files -add_prefix(${SUNDIALS_SOURCE_DIR}/include/arkode/ arkode_HEADERS) - -# Create the sundials_arkode library -sundials_add_library( - sundials_arkode - SOURCES ${arkode_SOURCES} - HEADERS ${arkode_HEADERS} - INCLUDE_SUBDIR arkode - LINK_LIBRARIES PUBLIC sundials_core - OBJECT_LIBRARIES ${arkode_OBJECT_LIBRARIES} + ${DOMEIG_OBJECT_LIBRARIES} OUTPUT_NAME sundials_arkode VERSION ${arkodelib_VERSION} SOVERSION ${arkodelib_SOVERSION}) diff --git a/src/sundials/CMakeLists.txt b/src/sundials/CMakeLists.txt index 34254f15e2..980a840cbf 100644 --- a/src/sundials/CMakeLists.txt +++ b/src/sundials/CMakeLists.txt @@ -33,6 +33,7 @@ set(sundials_HEADERS sundials_core.hpp sundials_dense.h sundials_direct.h + sundials_domeigestimator.h sundials_errors.h sundials_futils.h sundials_iterative.h @@ -72,10 +73,6 @@ if(ENABLE_SYCL) list(APPEND sundials_HEADERS sundials_sycl_policies.hpp) endif() -if(ENABLE_LAPACK) - list(APPEND sundials_HEADERS sundials_domeigestimator.h) -endif() - # If enabled, add the XBraid interface header if(ENABLE_XBRAID) list(APPEND sundials_HEADERS sundials_xbraid.h) @@ -95,6 +92,7 @@ set(sundials_SOURCES sundials_datanode.c sundials_direct.c sundials_errors.c + sundials_domeigestimator.c sundials_futils.c sundials_hashmap.c sundials_iterative.c @@ -114,15 +112,6 @@ if(ENABLE_MPI) list(APPEND sundials_SOURCES sundials_mpi_errors.c) endif() -if(ENABLE_LAPACK) - list(APPEND sundials_SOURCES sundials_domeigestimator.c) - set(_link_lapack_if_needed PUBLIC LAPACK::LAPACK) - if(CMAKE_VERSION VERSION_LESS 3.20) - list(APPEND _link_lapack_if_needed BLAS::BLAS) - endif() -endif() - - # Add prefix with complete path to the source files add_prefix(${SUNDIALS_SOURCE_DIR}/src/sundials/ sundials_SOURCES) diff --git a/test/unit_tests/arkode/CXX_parallel/CMakeLists.txt b/test/unit_tests/arkode/CXX_parallel/CMakeLists.txt index 84e7169ac9..a35b35ce70 100644 --- a/test/unit_tests/arkode/CXX_parallel/CMakeLists.txt +++ b/test/unit_tests/arkode/CXX_parallel/CMakeLists.txt @@ -20,6 +20,18 @@ if(NOT SUNDIALS_PRECISION MATCHES "SINGLE") "ark_test_heat2D_mri.cpp\;4\;1") endif() +# Add variable DOMEIG_OBJECT_LIBRARIES +set(DOMEIG_OBJECT_LIBRARIES + sundials_sundomeigestpi_obj) + +if(ENABLE_LAPACK) + list(APPEND DOMEIG_OBJECT_LIBRARIES sundials_sundomeigestarni_obj) + set(LAPACK_LIBRARY LAPACK::LAPACK) + if(CMAKE_VERSION VERSION_LESS 3.20) + list(APPEND LAPACK_LIBRARY BLAS::BLAS) + endif() +endif() + # Add the build and install targets for each test foreach(test_tuple ${unit_tests}) @@ -48,9 +60,10 @@ foreach(test_tuple ${unit_tests}) # libraries to link against target_link_libraries(${test_target} MPI::MPI_CXX sundials_arkode - sundials_sundomeigestpi - sundials_sundomeigestarni - sundials_nvecparallel ${EXE_EXTRA_LINK_LIBS}) + sundials_nvecparallel + ${DOMEIG_OBJECT_LIBRARIES} + ${EXE_EXTRA_LINK_LIBS} + PRIVATE ${LAPACK_LIBRARY}) endif() diff --git a/test/unit_tests/arkode/CXX_serial/CMakeLists.txt b/test/unit_tests/arkode/CXX_serial/CMakeLists.txt index fe9ded5288..b3880cc9e1 100644 --- a/test/unit_tests/arkode/CXX_serial/CMakeLists.txt +++ b/test/unit_tests/arkode/CXX_serial/CMakeLists.txt @@ -68,6 +68,17 @@ set(unit_tests "ark_test_adjoint_ark.cpp\;--check-freq 2 --dont-keep\;" "ark_test_adjoint_ark.cpp\;--check-freq 5 --dont-keep\;") +# Add variable DOMEIG_OBJECT_LIBRARIES +set(DOMEIG_OBJECT_LIBRARIES sundials_sundomeigestpi_obj) + +if(ENABLE_LAPACK) + list(APPEND DOMEIG_OBJECT_LIBRARIES sundials_sundomeigestarni_obj) + set(LAPACK_LIBRARY LAPACK::LAPACK) + if(CMAKE_VERSION VERSION_LESS 3.20) + list(APPEND LAPACK_LIBRARY BLAS::BLAS) + endif() +endif() + # Add the build and install targets for each test foreach(test_tuple ${unit_tests}) @@ -101,6 +112,7 @@ foreach(test_tuple ${unit_tests}) # their visibility in the installed libraries. target_link_libraries( ${test_target} + PRIVATE ${LAPACK_LIBRARY} $ sundials_sunmemsys_obj sundials_nvecserial_obj @@ -113,8 +125,7 @@ foreach(test_tuple ${unit_tests}) sundials_sunadaptcontrollersoderlind_obj sundials_sunadaptcontrollermrihtol_obj sundials_adjointcheckpointscheme_fixed_obj - sundials_sundomeigestpi_obj - sundials_sundomeigestarni_obj + ${DOMEIG_OBJECT_LIBRARIES} ${EXE_EXTRA_LINK_LIBS}) # Tell CMake that we depend on the ARKODE library since it does not pick diff --git a/test/unit_tests/arkode/C_serial/CMakeLists.txt b/test/unit_tests/arkode/C_serial/CMakeLists.txt index 148cd8d5d9..30979f1859 100644 --- a/test/unit_tests/arkode/C_serial/CMakeLists.txt +++ b/test/unit_tests/arkode/C_serial/CMakeLists.txt @@ -37,6 +37,17 @@ set(ARKODE_unit_tests "ark_test_splittingstep_coefficients\;" "ark_test_tstop\;") +# Add variable DOMEIG_OBJECT_LIBRARIES +set(DOMEIG_OBJECT_LIBRARIES sundials_sundomeigestpi_obj) + +if(ENABLE_LAPACK) + list(APPEND DOMEIG_OBJECT_LIBRARIES sundials_sundomeigestarni_obj) + set(LAPACK_LIBRARY LAPACK::LAPACK) + if(CMAKE_VERSION VERSION_LESS 3.20) + list(APPEND LAPACK_LIBRARY BLAS::BLAS) + endif() +endif() + # Add the build and install targets for each test foreach(test_tuple ${ARKODE_unit_tests}) @@ -63,6 +74,7 @@ foreach(test_tuple ${ARKODE_unit_tests}) # their visibility in the installed libraries. target_link_libraries( ${test} + PRIVATE ${LAPACK_LIBRARY} $ sundials_sunmemsys_obj sundials_nvecserial_obj @@ -73,8 +85,7 @@ foreach(test_tuple ${ARKODE_unit_tests}) sundials_sunadaptcontrollerimexgus_obj sundials_sunadaptcontrollersoderlind_obj sundials_adjointcheckpointscheme_fixed_obj - sundials_sundomeigestpi_obj - sundials_sundomeigestarni_obj + ${DOMEIG_OBJECT_LIBRARIES} ${EXE_EXTRA_LINK_LIBS}) # Tell CMake that we depend on the ARKODE library since it does not pick diff --git a/test/unit_tests/arkode/gtest/CMakeLists.txt b/test/unit_tests/arkode/gtest/CMakeLists.txt index 6adc1c3bd4..66423b368f 100644 --- a/test/unit_tests/arkode/gtest/CMakeLists.txt +++ b/test/unit_tests/arkode/gtest/CMakeLists.txt @@ -19,12 +19,25 @@ target_include_directories( PRIVATE $ ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/src) +# Add variable DOMEIG_OBJECT_LIBRARIES +set(DOMEIG_OBJECT_LIBRARIES sundials_sundomeigestpi_obj) + +if(ENABLE_LAPACK) + list(APPEND DOMEIG_OBJECT_LIBRARIES sundials_sundomeigestarni_obj) + set(LAPACK_LIBRARY LAPACK::LAPACK) + if(CMAKE_VERSION VERSION_LESS 3.20) + list(APPEND LAPACK_LIBRARY BLAS::BLAS) + endif() +endif() + + # We explicitly choose which object libraries to link to and link in the ARKODE # objects so that we have access to private functions w/o changing their # visibility in the installed libraries. target_link_libraries( test_arkode_error_handling - PRIVATE $ + PRIVATE ${LAPACK_LIBRARY} + $ sundials_sunmemsys_obj sundials_nvecserial_obj sundials_nvecmanyvector_obj @@ -33,6 +46,7 @@ target_link_libraries( sundials_sunnonlinsolnewton_obj sundials_sunadaptcontrollerimexgus_obj sundials_sunadaptcontrollersoderlind_obj + ${DOMEIG_OBJECT_LIBRARIES} ${EXE_EXTRA_LINK_LIBS}) # Tell CMake that we depend on the ARKODE library since it does not pick that up diff --git a/test/unit_tests/sundomeigest/CMakeLists.txt b/test/unit_tests/sundomeigest/CMakeLists.txt index f4a833db3f..b26da75905 100644 --- a/test/unit_tests/sundomeigest/CMakeLists.txt +++ b/test/unit_tests/sundomeigest/CMakeLists.txt @@ -19,21 +19,32 @@ if(ENABLE_CALIPER AND SUNDIALS_BUILD_WITH_PROFILING) set(EXE_EXTRA_LINK_LIBS ${EXE_EXTRA_LINK_LIBS} caliper) endif() +set(EXE_EXTRA_LINK_LIBS ${EXE_EXTRA_LINK_LIBS} sundials_sundomeigestpi) -# Always add the power iteration examples -add_subdirectory(pi) - -# Add the Arnoldi iteration examples if LAPACK is enabled if(ENABLE_LAPACK) - add_subdirectory(arni) + set(EXE_EXTRA_LINK_LIBS ${EXE_EXTRA_LINK_LIBS} sundials_sundomeigestarni) endif() +# Always add the power iteration examples +add_subdirectory(pi) + # Build the sundials_sundomeigest test utilities -add_library(sundials_sundomeigest_obj OBJECT test_sundomeigest.c test_sundomeigest.h) +add_library(test_sundomeigest_obj OBJECT test_sundomeigest.c) if(BUILD_SHARED_LIBS) # need PIC when shared libs are used since the example executables will link # to the shared lib - set_property(TARGET sundials_sundomeigest_obj PROPERTY POSITION_INDEPENDENT_CODE + set_property(TARGET test_sundomeigest_obj PROPERTY POSITION_INDEPENDENT_CODE TRUE) endif() -target_link_libraries(sundials_sundomeigest_obj sundials_sundomeigestarni sundials_sundomeigestpi) +target_link_libraries(test_sundomeigest_obj PRIVATE sundials_sundomeigestpi) + +# Add the Arnoldi iteration examples if LAPACK is enabled +if(ENABLE_LAPACK) + add_subdirectory(arni) + + if(BUILD_SHARED_LIBS) + set_property(TARGET test_sundomeigest_obj PROPERTY POSITION_INDEPENDENT_CODE + TRUE) + endif() + target_link_libraries(test_sundomeigest_obj PRIVATE sundials_sundomeigestpi sundials_sundomeigestarni) +endif() \ No newline at end of file diff --git a/test/unit_tests/sundomeigest/arni/CMakeLists.txt b/test/unit_tests/sundomeigest/arni/CMakeLists.txt index 85892491d1..7ff7bc1237 100644 --- a/test/unit_tests/sundomeigest/arni/CMakeLists.txt +++ b/test/unit_tests/sundomeigest/arni/CMakeLists.txt @@ -27,7 +27,15 @@ set(sundomeigest_arni_examples set(sundomeigest_arni_dependencies test_sundomeigest) # Add source directory to include directories -include_directories(. ../..) +include_directories(. ..) + +# Specify libraries to link against +set(DOMEIG_LIB sundials_sundomeigestarni LAPACK::LAPACK) +if(CMAKE_VERSION VERSION_LESS 3.20) + list(APPEND DOMEIG_LIB BLAS::BLAS) +endif() +# Set-up linker flags and link libraries +set(SUNDIALS_LIBS sundials_nvecserial ${DOMEIG_LIB} ${EXE_EXTRA_LINK_LIBS}) # Add the build and install targets for each example foreach(example_tuple ${sundomeigest_arni_examples}) @@ -41,14 +49,16 @@ foreach(example_tuple ${sundomeigest_arni_examples}) # source files once for testing with different inputs if(NOT TARGET ${example}) # example source files - sundials_add_executable(${example} ${example}.c ../test_sundomeigest.c) + sundials_add_executable(${example} ${example}.c) - # folder to organize targets in an IDE - set_target_properties(${example} PROPERTIES FOLDER "Examples") + # link domeigest test utilities + target_link_libraries(${example} PRIVATE test_sundomeigest_obj) # libraries to link against - target_link_libraries(${example} sundials_nvecserial sundials_sundomeigestarni - ${EXE_EXTRA_LINK_LIBS}) + target_link_libraries(${example} PRIVATE ${SUNDIALS_LIBS}) + + # folder to organize targets in an IDE + set_target_properties(${example} PROPERTIES FOLDER "Examples") endif() # check if example args are provided and set the test name @@ -82,6 +92,7 @@ if(EXAMPLES_INSTALL) set(SOLVER_LIB "sundials_sundomeigestarni") examples2string(sundomeigest_arni_examples EXAMPLES) + set(sundomeigest_arni_dependencies test_sundomeigest.c) examples2string(sundomeigest_arni_dependencies EXAMPLES_DEPENDENCIES) # Regardless of the platform we're on, we will generate and install @@ -91,29 +102,28 @@ if(EXAMPLES_INSTALL) # generate CMakelists.txt in the binary directory configure_file( ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_serial_C_ex.in - ${PROJECT_BINARY_DIR}/test/unit_tests/sundomeigest/arni/CMakeLists.txt - @ONLY) + ${PROJECT_BINARY_DIR}/test/unit_tests/sundomeigest/arni/CMakeLists.txt @ONLY) # install CMakelists.txt install( - FILES - ${PROJECT_BINARY_DIR}/test/unit_tests/sundomeigest/arni/CMakeLists.txt + FILES ${PROJECT_BINARY_DIR}/test/unit_tests/sundomeigest/arni/CMakeLists.txt DESTINATION ${EXAMPLES_INSTALL_PATH}/sundomeigest/arni) # On UNIX-type platforms, we also generate and install a makefile for # building the examples. This makefile can then be used as a template for the # user's own programs. + set(EXAMPLES_DEPENDENCIES) + set(sundomeigest_arni_dependencies test_sundomeigest) + examples2string(sundomeigest_arni_dependencies EXAMPLES_DEPENDENCIES) if(UNIX) # generate Makefile and place it in the binary dir configure_file( ${PROJECT_SOURCE_DIR}/examples/templates/makefile_serial_C_ex.in - ${PROJECT_BINARY_DIR}/test/unit_tests/sundomeigest/arni/Makefile_ex - @ONLY) + ${PROJECT_BINARY_DIR}/test/unit_tests/sundomeigest/arni/Makefile_ex @ONLY) # install the configured Makefile_ex as Makefile install( - FILES - ${PROJECT_BINARY_DIR}/test/unit_tests/sundomeigest/arni/Makefile_ex + FILES ${PROJECT_BINARY_DIR}/test/unit_tests/sundomeigest/arni/Makefile_ex DESTINATION ${EXAMPLES_INSTALL_PATH}/sundomeigest/arni RENAME Makefile) endif() diff --git a/test/unit_tests/sundomeigest/pi/CMakeLists.txt b/test/unit_tests/sundomeigest/pi/CMakeLists.txt index 1e34a06ce7..dbb0283abc 100644 --- a/test/unit_tests/sundomeigest/pi/CMakeLists.txt +++ b/test/unit_tests/sundomeigest/pi/CMakeLists.txt @@ -27,7 +27,13 @@ set(sundomeigest_pi_examples set(sundomeigest_pi_dependencies test_sundomeigest) # Add source directory to include directories -include_directories(. ../..) +include_directories(. ..) + +# Specify libraries to link against +set(DOMEIG_LIB sundials_sundomeigestpi) + +# Set-up linker flags and link libraries +set(SUNDIALS_LIBS sundials_nvecserial ${DOMEIG_LIB} ${EXE_EXTRA_LINK_LIBS}) # Add the build and install targets for each example foreach(example_tuple ${sundomeigest_pi_examples}) @@ -41,14 +47,16 @@ foreach(example_tuple ${sundomeigest_pi_examples}) # source files once for testing with different inputs if(NOT TARGET ${example}) # example source files - sundials_add_executable(${example} ${example}.c ../test_sundomeigest.c) + sundials_add_executable(${example} ${example}.c) - # folder to organize targets in an IDE - set_target_properties(${example} PROPERTIES FOLDER "Examples") + # link domeigest test utilities + target_link_libraries(${example} PRIVATE test_sundomeigest_obj) # libraries to link against - target_link_libraries(${example} sundials_nvecserial sundials_sundomeigestpi - ${EXE_EXTRA_LINK_LIBS}) + target_link_libraries(${example} PRIVATE ${SUNDIALS_LIBS}) + + # folder to organize targets in an IDE + set_target_properties(${example} PROPERTIES FOLDER "Examples") endif() # check if example args are provided and set the test name @@ -82,6 +90,7 @@ if(EXAMPLES_INSTALL) set(SOLVER_LIB "sundials_sundomeigestpi") examples2string(sundomeigest_pi_examples EXAMPLES) + set(sundomeigest_pi_dependencies test_sundomeigest.c) examples2string(sundomeigest_pi_dependencies EXAMPLES_DEPENDENCIES) # Regardless of the platform we're on, we will generate and install @@ -91,29 +100,28 @@ if(EXAMPLES_INSTALL) # generate CMakelists.txt in the binary directory configure_file( ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_serial_C_ex.in - ${PROJECT_BINARY_DIR}/test/unit_tests/sundomeigest/pi/CMakeLists.txt - @ONLY) + ${PROJECT_BINARY_DIR}/test/unit_tests/sundomeigest/pi/CMakeLists.txt @ONLY) # install CMakelists.txt install( - FILES - ${PROJECT_BINARY_DIR}/test/unit_tests/sundomeigest/pi/CMakeLists.txt + FILES ${PROJECT_BINARY_DIR}/test/unit_tests/sundomeigest/pi/CMakeLists.txt DESTINATION ${EXAMPLES_INSTALL_PATH}/sundomeigest/pi) # On UNIX-type platforms, we also generate and install a makefile for # building the examples. This makefile can then be used as a template for the # user's own programs. + set(EXAMPLES_DEPENDENCIES) + set(sundomeigest_pi_dependencies test_sundomeigest) + examples2string(sundomeigest_pi_dependencies EXAMPLES_DEPENDENCIES) if(UNIX) # generate Makefile and place it in the binary dir configure_file( ${PROJECT_SOURCE_DIR}/examples/templates/makefile_serial_C_ex.in - ${PROJECT_BINARY_DIR}/test/unit_tests/sundomeigest/pi/Makefile_ex - @ONLY) + ${PROJECT_BINARY_DIR}/test/unit_tests/sundomeigest/pi/Makefile_ex @ONLY) # install the configured Makefile_ex as Makefile install( - FILES - ${PROJECT_BINARY_DIR}/test/unit_tests/sundomeigest/pi/Makefile_ex + FILES ${PROJECT_BINARY_DIR}/test/unit_tests/sundomeigest/pi/Makefile_ex DESTINATION ${EXAMPLES_INSTALL_PATH}/sundomeigest/pi RENAME Makefile) endif() From 582519decbcf3bc3ba34af666d8fc1fbecff3797 Mon Sep 17 00:00:00 2001 From: maggul Date: Mon, 9 Jun 2025 05:57:56 -0500 Subject: [PATCH 030/128] formatting --- include/arkode/arkode_lsrkstep.h | 3 +- include/nvector/nvector_kokkos.hpp | 2 +- .../priv/sundials_domeigestimator_impl.h | 15 +- include/sundials/sundials_core.h | 2 +- include/sundials/sundials_domeigestimator.h | 13 +- include/sundomeigest/sundomeigest_arni.h | 33 ++-- include/sundomeigest/sundomeigest_pi.h | 31 +-- src/arkode/arkode_lsrkstep.c | 91 +++++---- src/arkode/arkode_lsrkstep_impl.h | 12 +- src/arkode/arkode_lsrkstep_io.c | 23 +-- src/arkode/fmod_int32/farkode_lsrkstep_mod.c | 14 ++ .../fmod_int32/farkode_lsrkstep_mod.f90 | 33 ++++ src/arkode/fmod_int32/farkode_mod.f90 | 1 + src/arkode/fmod_int64/farkode_lsrkstep_mod.c | 14 ++ .../fmod_int64/farkode_lsrkstep_mod.f90 | 33 ++++ src/arkode/fmod_int64/farkode_mod.f90 | 1 + src/nvector/cuda/VectorKernels.cuh | 15 +- src/nvector/cuda/nvector_cuda.cu | 2 +- src/nvector/manyvector/nvector_manyvector.c | 9 +- src/nvector/openmp/nvector_openmp.c | 4 +- src/nvector/parallel/nvector_parallel.c | 8 +- src/nvector/parhyp/nvector_parhyp.c | 6 +- src/nvector/petsc/nvector_petsc.c | 4 +- src/nvector/serial/nvector_serial.c | 4 +- src/sundials/fmod_int32/fsundials_core_mod.c | 12 ++ .../fmod_int32/fsundials_core_mod.f90 | 36 +++- src/sundials/fmod_int64/fsundials_core_mod.c | 12 ++ .../fmod_int64/fsundials_core_mod.f90 | 36 +++- src/sundials/sundials_domeigestimator.c | 5 +- src/sundials/sundials_nvector.c | 7 +- src/sundomeigest/ArnI/CMakeLists.txt | 2 +- src/sundomeigest/ArnI/sundomeigest_arni.c | 183 ++++++++++-------- src/sundomeigest/CMakeLists.txt | 2 +- src/sundomeigest/PI/sundomeigest_pi.c | 108 ++++++----- .../arkode/CXX_parallel/CMakeLists.txt | 12 +- .../arkode/CXX_serial/CMakeLists.txt | 28 +-- .../unit_tests/arkode/C_serial/CMakeLists.txt | 24 +-- test/unit_tests/arkode/gtest/CMakeLists.txt | 1 - test/unit_tests/nvector/test_nvector.c | 23 ++- test/unit_tests/sundials/CMakeLists.txt | 2 +- test/unit_tests/sundomeigest/CMakeLists.txt | 9 +- .../sundomeigest/arni/CMakeLists.txt | 9 +- .../arni/test_sundomeigest_arni.c | 77 ++++---- .../unit_tests/sundomeigest/pi/CMakeLists.txt | 5 +- .../sundomeigest/pi/test_sundomeigest_pi.c | 77 ++++---- .../sundomeigest/test_sundomeigest.c | 14 +- .../sundomeigest/test_sundomeigest.h | 8 +- 47 files changed, 641 insertions(+), 424 deletions(-) diff --git a/include/arkode/arkode_lsrkstep.h b/include/arkode/arkode_lsrkstep.h index 09e59771ea..fce3c4adac 100644 --- a/include/arkode/arkode_lsrkstep.h +++ b/include/arkode/arkode_lsrkstep.h @@ -82,7 +82,8 @@ SUNDIALS_EXPORT int LSRKStepSetSSPMethodByName(void* arkode_mem, SUNDIALS_EXPORT int LSRKStepSetDomEigFn(void* arkode_mem, ARKDomEigFn dom_eig); -SUNDIALS_EXPORT int LSRKStepSetInternalDomEigEstType(void* arkode_mem, ARKODE_LSRKInternal_DomEigEst_Type dom_eig_type); +SUNDIALS_EXPORT int LSRKStepSetInternalDomEigEstType( + void* arkode_mem, ARKODE_LSRKInternal_DomEigEst_Type dom_eig_type); SUNDIALS_EXPORT int LSRKStepSetDomEigFrequency(void* arkode_mem, long int nsteps); diff --git a/include/nvector/nvector_kokkos.hpp b/include/nvector/nvector_kokkos.hpp index d2efedef91..18a80c4a8e 100644 --- a/include/nvector/nvector_kokkos.hpp +++ b/include/nvector/nvector_kokkos.hpp @@ -622,7 +622,7 @@ class Vector : public sundials::impl::BaseNVector, this->object_->ops->nvwl2norm = impl::N_VWL2Norm_Kokkos; this->object_->ops->nvwrmsnorm = impl::N_VWrmsNorm_Kokkos; this->object_->ops->nvwrmsnormmask = impl::N_VWrmsNormMask_Kokkos; - this->object_->ops->nvrandom = impl::N_VRandom_Kokkos; + this->object_->ops->nvrandom = impl::N_VRandom_Kokkos; /* local reduction operations */ this->object_->ops->nvconstrmasklocal = impl::N_VConstrMask_Kokkos; diff --git a/include/sundials/priv/sundials_domeigestimator_impl.h b/include/sundials/priv/sundials_domeigestimator_impl.h index 0c5cbd6721..93c87a4d64 100644 --- a/include/sundials/priv/sundials_domeigestimator_impl.h +++ b/include/sundials/priv/sundials_domeigestimator_impl.h @@ -29,19 +29,20 @@ extern "C" { DOMEIG module private function prototypes ===============================================================*/ - SUNErrCode domeig_CheckNVector(N_Vector tmpl); - sunrealtype domeig_Magnitude(const suncomplextype *c); - sunindextype domeig_Compare(const void *a, const void *b); +SUNErrCode domeig_CheckNVector(N_Vector tmpl); +sunrealtype domeig_Magnitude(const suncomplextype* c); +sunindextype domeig_Compare(const void* a, const void* b); - /* +/* * ----------------------------------------------------------------- * LAPACK function * ----------------------------------------------------------------- */ - extern void dgeev_(char* jobvl, char* jobvr, int* n, sunrealtype* a, int* lda, - sunrealtype* wr, sunrealtype* wi, sunrealtype* vl, int* ldvl, sunrealtype* vr, - int* ldvr, sunrealtype* work, int* lwork, int* info); +extern void dgeev_(char* jobvl, char* jobvr, int* n, sunrealtype* a, int* lda, + sunrealtype* wr, sunrealtype* wi, sunrealtype* vl, int* ldvl, + sunrealtype* vr, int* ldvr, sunrealtype* work, int* lwork, + int* info); #ifdef __cplusplus } diff --git a/include/sundials/sundials_core.h b/include/sundials/sundials_core.h index 70785afcbb..38cecd9576 100644 --- a/include/sundials/sundials_core.h +++ b/include/sundials/sundials_core.h @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -33,7 +34,6 @@ #include #include #include -#include #if SUNDIALS_MPI_ENABLED #include diff --git a/include/sundials/sundials_domeigestimator.h b/include/sundials/sundials_domeigestimator.h index 7234388144..fc268ea545 100644 --- a/include/sundials/sundials_domeigestimator.h +++ b/include/sundials/sundials_domeigestimator.h @@ -18,22 +18,23 @@ #define _DOMEIGEST_H /* TODO: Check to see if they are all required */ +#include #include #include -#include #include +#include #include #include -#include #ifdef __cplusplus /* wrapper to enable C++ usage */ extern "C" { #endif // Struct to hold the real and imaginary parts -typedef struct { - sunrealtype real; - sunrealtype imag; +typedef struct +{ + sunrealtype real; + sunrealtype imag; } suncomplextype; /* ----------------------------------------------------------------- @@ -96,7 +97,7 @@ SUNDomEigEstimator_Type SUNDomEigEstGetType(SUNDomEigEstimator DEE); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstSetATimes(SUNDomEigEstimator DEE, void* A_data, - SUNATimesFn ATimes); + SUNATimesFn ATimes); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstInitialize(SUNDomEigEstimator DEE); diff --git a/include/sundomeigest/sundomeigest_arni.h b/include/sundomeigest/sundomeigest_arni.h index 1a931828fd..a665d76220 100644 --- a/include/sundomeigest/sundomeigest_arni.h +++ b/include/sundomeigest/sundomeigest_arni.h @@ -23,17 +23,17 @@ #ifndef _DOMEIGEST_ARNI_H #define _DOMEIGEST_ARNI_H -#include #include +#include #ifdef __cplusplus /* wrapper to enable C++ usage */ extern "C" { #endif /* Default Arnoldi Iteration parameters */ -#define SUNDOMEIGEST_ARN_MAXL_DEFAULT 3 -#define SUNDOMEIGEST_PI_POWER_OF_A_DEFAULT 10 -#define SUNDOMEIGEST_LAPACK_FAIL "Error: LAPACK dgeev failed with info = %d\n" +#define SUNDOMEIGEST_ARN_MAXL_DEFAULT 3 +#define SUNDOMEIGEST_PI_POWER_OF_A_DEFAULT 10 +#define SUNDOMEIGEST_LAPACK_FAIL "Error: LAPACK dgeev failed with info = %d\n" /* ----------------------------------------------------- * Arnoldi Iteration Implementation of SUNDomEigEstimator @@ -41,21 +41,21 @@ extern "C" { struct _SUNDomEigEstimatorContent_ArnI { - SUNATimesFn ATimes; /* User provided ATimes function */ - void* ATdata; /* ATimes function data*/ + SUNATimesFn ATimes; /* User provided ATimes function */ + void* ATdata; /* ATimes function data*/ - N_Vector *V, q; /* Krylov subspace vectors */ + N_Vector *V, q; /* Krylov subspace vectors */ - sunindextype maxl; /* Krylov subspace dimension */ - sunindextype power_of_A; /* Power of A in the preprocessing; initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ + sunindextype maxl; /* Krylov subspace dimension */ + sunindextype power_of_A; /* Power of A in the preprocessing; initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ - sunrealtype* LAPACK_A; /* The vector which holds rows of the Hessenberg matrix in the given order */ + sunrealtype* LAPACK_A; /* The vector which holds rows of the Hessenberg matrix in the given order */ sunrealtype* LAPACK_wr; /* Real parts of eigenvalues */ sunrealtype* LAPACK_wi; /* Imaginary parts of eigenvalues */ sunrealtype* LAPACK_work; /* Workspace array */ suncomplextype* LAPACK_arr; /* an array to sort eigenvalues*/ - sunrealtype **Hes; /* Hessenberg matrix Hes */ + sunrealtype** Hes; /* Hessenberg matrix Hes */ }; typedef struct _SUNDomEigEstimatorContent_ArnI* SUNDomEigEstimatorContent_ArnI; @@ -65,20 +65,22 @@ typedef struct _SUNDomEigEstimatorContent_ArnI* SUNDomEigEstimatorContent_ArnI; * --------------------------------------- */ SUNDIALS_EXPORT -SUNDomEigEstimator SUNDomEigEst_ArnI(N_Vector q, sunindextype maxl, SUNContext sunctx); +SUNDomEigEstimator SUNDomEigEst_ArnI(N_Vector q, sunindextype maxl, + SUNContext sunctx); SUNDIALS_EXPORT SUNDomEigEstimator_Type SUNDomEigEst_ArnIGetType(SUNDomEigEstimator DEE); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstSetATimes_ArnI(SUNDomEigEstimator DEE, void* A_data, - SUNATimesFn ATimes); + SUNATimesFn ATimes); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstInitialize_ArnI(SUNDomEigEstimator DEE); SUNDIALS_EXPORT -SUNErrCode SUNDomEigEstSetNumofPreProcess_ArnI(SUNDomEigEstimator DEE, sunindextype numofperprocess); +SUNErrCode SUNDomEigEstSetNumofPreProcess_ArnI(SUNDomEigEstimator DEE, + sunindextype numofperprocess); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstPreProcess_ArnI(SUNDomEigEstimator DEE); @@ -87,7 +89,8 @@ SUNDIALS_EXPORT SUNErrCode SUNDomEigEstComputeHess_ArnI(SUNDomEigEstimator DEE); SUNDIALS_EXPORT -SUNErrCode SUNDomEigEstimate_ArnI(SUNDomEigEstimator DEE, suncomplextype* dom_eig); +SUNErrCode SUNDomEigEstimate_ArnI(SUNDomEigEstimator DEE, + suncomplextype* dom_eig); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstFree_ArnI(SUNDomEigEstimator DEE); diff --git a/include/sundomeigest/sundomeigest_pi.h b/include/sundomeigest/sundomeigest_pi.h index c25217858f..1c655d77a0 100644 --- a/include/sundomeigest/sundomeigest_pi.h +++ b/include/sundomeigest/sundomeigest_pi.h @@ -30,9 +30,9 @@ extern "C" { #endif /* Default Power Iteration parameters */ -#define SUNDOMEIGEST_PI_TOL_DEFAULT SUN_RCONST(0.01) -#define SUNDOMEIGEST_MAX_PI_DEFAULT 100 -#define SUNDOMEIGEST_PI_POWER_OF_A_DEFAULT 10 +#define SUNDOMEIGEST_PI_TOL_DEFAULT SUN_RCONST(0.01) +#define SUNDOMEIGEST_MAX_PI_DEFAULT 100 +#define SUNDOMEIGEST_PI_POWER_OF_A_DEFAULT 10 /* ----------------------------------------------------- * Power Iteration Implementation of SUNDomEigEstimator @@ -40,17 +40,17 @@ extern "C" { struct _SUNDomEigEstimatorContent_PI { - SUNATimesFn ATimes; /* User provided ATimes function */ - void* ATdata; /* ATimes function data*/ + SUNATimesFn ATimes; /* User provided ATimes function */ + void* ATdata; /* ATimes function data*/ - N_Vector V, q; /* workspace vectors */ + N_Vector V, q; /* workspace vectors */ - sunindextype power_of_A; /* Power of A in the preprocessing; initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ + sunindextype power_of_A; /* Power of A in the preprocessing; initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ - sunrealtype powiter_tol; /* Convergence criteria for the power iteration */ - sunrealtype resnorm; /* Current residual of power iterations */ - sunindextype max_powiter; /* Maximum number of power iterations */ - sunindextype numiters; /* Number of power iterations */ + sunrealtype powiter_tol; /* Convergence criteria for the power iteration */ + sunrealtype resnorm; /* Current residual of power iterations */ + sunindextype max_powiter; /* Maximum number of power iterations */ + sunindextype numiters; /* Number of power iterations */ }; typedef struct _SUNDomEigEstimatorContent_PI* SUNDomEigEstimatorContent_PI; @@ -60,7 +60,8 @@ typedef struct _SUNDomEigEstimatorContent_PI* SUNDomEigEstimatorContent_PI; * --------------------------------------- */ SUNDIALS_EXPORT -SUNDomEigEstimator SUNDomEigEst_PI(N_Vector q, sunindextype max_powiter, SUNContext sunctx); +SUNDomEigEstimator SUNDomEigEst_PI(N_Vector q, sunindextype max_powiter, + SUNContext sunctx); SUNDIALS_EXPORT SUNDomEigEstimator_Type SUNDomEigEst_PIGetType(SUNDomEigEstimator DEE); @@ -69,14 +70,16 @@ SUNDIALS_EXPORT SUNErrCode SUNDomEigEstInitialize_PI(SUNDomEigEstimator DEE); SUNDIALS_EXPORT -SUNErrCode SUNDomEigEstSetNumofPreProcess_PI(SUNDomEigEstimator DEE, sunindextype numofperprocess); +SUNErrCode SUNDomEigEstSetNumofPreProcess_PI(SUNDomEigEstimator DEE, + sunindextype numofperprocess); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstSetATimes_PI(SUNDomEigEstimator DEE, void* A_data, SUNATimesFn ATimes); SUNDIALS_EXPORT -SUNErrCode SUNDomEigEst_PISetMaxPowerIter(SUNDomEigEstimator DEE, sunindextype max_powiter); +SUNErrCode SUNDomEigEst_PISetMaxPowerIter(SUNDomEigEstimator DEE, + sunindextype max_powiter); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstPreProcess_PI(SUNDomEigEstimator DEE); diff --git a/src/arkode/arkode_lsrkstep.c b/src/arkode/arkode_lsrkstep.c index 2bf970ec67..600387f5a8 100644 --- a/src/arkode/arkode_lsrkstep.c +++ b/src/arkode/arkode_lsrkstep.c @@ -190,7 +190,7 @@ void* lsrkStep_Create_Commons(ARKRhsFn rhs, sunrealtype t0, N_Vector y0, } /* Copy the input parameters into ARKODE state */ - step_mem->fe = rhs; + step_mem->fe = rhs; step_mem->domeig_rhs = NULL; /* Set internal DomEigEst type */ @@ -337,8 +337,9 @@ int lsrkStep_Init(ARKodeMem ark_mem, SUNDIALS_MAYBE_UNUSED sunrealtype tout, /* Check if user has provided dom_eig_fn */ if (!step_mem->is_SSP && step_mem->dom_eig_fn == NULL && step_mem->DEE == NULL) { - arkProcessError(ark_mem, ARK_DOMEIG_FAIL, __LINE__, __func__, - __FILE__, "STS methods require either a user provided or an internal dominant eigenvalue estimation"); + arkProcessError(ark_mem, ARK_DOMEIG_FAIL, __LINE__, __func__, __FILE__, + "STS methods require either a user provided or an internal " + "dominant eigenvalue estimation"); return ARK_DOMEIG_FAIL; } @@ -2224,10 +2225,12 @@ int lsrkStep_ComputeNewDomEig(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem) else if (step_mem->DEE != NULL) { dom_eig = lsrkStep_DomEigEstimate(ark_mem, step_mem->DEE); - if((dom_eig.real*dom_eig.real + dom_eig.imag*dom_eig.imag) < SUN_SMALL_REAL) + if ((dom_eig.real * dom_eig.real + dom_eig.imag * dom_eig.imag) < + SUN_SMALL_REAL) { arkProcessError(ark_mem, ARK_DOMEIG_FAIL, __LINE__, __func__, __FILE__, - "Unable to estimate the dominant eigenvalue: DomEig estimation returned an error"); + "Unable to estimate the dominant eigenvalue: DomEig " + "estimation returned an error"); return ARK_DOMEIG_FAIL; } step_mem->dom_eig_num_evals++; @@ -2238,7 +2241,9 @@ int lsrkStep_ComputeNewDomEig(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem) else { arkProcessError(ark_mem, ARK_DOMEIG_FAIL, __LINE__, __func__, __FILE__, - "Unable to estimate the dominant eigenvalue: Either a user provided or an internal dominant eigenvalue estimation is required"); + "Unable to estimate the dominant eigenvalue: Either a user " + "provided or an internal dominant eigenvalue estimation is " + "required"); return ARK_DOMEIG_FAIL; } @@ -2283,7 +2288,7 @@ int lsrkStep_ComputeNewDomEig(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem) /*--------------------------------------------------------------- lsrkStep_DomEigCreate: - This routine creates the DomEig memory and attaches all the relevent + This routine creates the DomEig memory and attaches all the relevant function pointers from arkode_mem. ---------------------------------------------------------------*/ @@ -2311,48 +2316,52 @@ SUNDomEigEstimator lsrkStep_DomEigCreate(void* arkode_mem) /* Allocate and fill domeig_q vector with random data */ /* TODO: check if we have to clone or just passing yn is ok! */ - step_mem->domeig_q = N_VClone(ark_mem->yn); - step_mem->domeig_maxl = DOMEIG_MAXL_DEFAULT; + step_mem->domeig_q = N_VClone(ark_mem->yn); + step_mem->domeig_maxl = DOMEIG_MAXL_DEFAULT; step_mem->domeig_power_of_A = DOMEIG_POWER_OF_A_DEFAULT; - step_mem->domeig_maxiters = DOMEIG_MAX_NUMBER_OF_POWER_ITERS_DEFAULT; + step_mem->domeig_maxiters = DOMEIG_MAX_NUMBER_OF_POWER_ITERS_DEFAULT; /* Enforce the power iteration if the problem size < 3 */ - if(step_mem->internal_domeigest_type == ARKODE_LSRK_ARNOLDI_ITERATION && ark_mem->yn->ops->nvgetlength(ark_mem->yn) < 3) + if (step_mem->internal_domeigest_type == ARKODE_LSRK_ARNOLDI_ITERATION && + ark_mem->yn->ops->nvgetlength(ark_mem->yn) < 3) { step_mem->internal_domeigest_type == ARKODE_LSRK_POWER_ITERATION; } /* Create the internal DomEigEst */ - if(step_mem->internal_domeigest_type == ARKODE_LSRK_POWER_ITERATION) + if (step_mem->internal_domeigest_type == ARKODE_LSRK_POWER_ITERATION) { - DEE = SUNDomEigEst_PI(step_mem->domeig_q, step_mem->domeig_maxiters, ark_mem->sunctx); + DEE = SUNDomEigEst_PI(step_mem->domeig_q, step_mem->domeig_maxiters, + ark_mem->sunctx); if (DEE == NULL) { - arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, - MSG_ARK_INTERNAL_DOMEIG_FAIL); + arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, + __FILE__, MSG_ARK_INTERNAL_DOMEIG_FAIL); return NULL; } } else if (step_mem->internal_domeigest_type == ARKODE_LSRK_ARNOLDI_ITERATION) { #ifdef SUNDIALS_BLAS_LAPACK_ENABLED - DEE = SUNDomEigEst_ArnI(step_mem->domeig_q, step_mem->domeig_maxl, ark_mem->sunctx); + DEE = SUNDomEigEst_ArnI(step_mem->domeig_q, step_mem->domeig_maxl, + ark_mem->sunctx); if (DEE == NULL) { - arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, - MSG_ARK_INTERNAL_DOMEIG_FAIL); + arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, + __FILE__, MSG_ARK_INTERNAL_DOMEIG_FAIL); return NULL; } #else - arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, + arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, + __FILE__, "Internal Arnoldi iteration requires LAPACK package"); return NULL; #endif } else { - arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, - "Attempted to create an internal domeig estimator with an unknown type"); + arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, + __FILE__, "Attempted to create an internal domeig estimator with an unknown type"); return NULL; } @@ -2360,19 +2369,19 @@ SUNDomEigEstimator lsrkStep_DomEigCreate(void* arkode_mem) retval = DEE->ops->setatimes(DEE, arkode_mem, lsrkStep_DQJtimes); if (retval != ARK_SUCCESS) { - arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, - MSG_ARK_INTERNAL_DOMEIG_FAIL); + arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, + __FILE__, MSG_ARK_INTERNAL_DOMEIG_FAIL); return NULL; } /* Set Max Power Itetations*/ - if(DEE->ops->setmaxpoweriter != NULL) + if (DEE->ops->setmaxpoweriter != NULL) { retval = DEE->ops->setmaxpoweriter(DEE, step_mem->domeig_maxiters); if (retval != ARK_SUCCESS) { - arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, - MSG_ARK_INTERNAL_DOMEIG_FAIL); + arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, + __FILE__, MSG_ARK_INTERNAL_DOMEIG_FAIL); return NULL; } } @@ -2381,19 +2390,19 @@ SUNDomEigEstimator lsrkStep_DomEigCreate(void* arkode_mem) retval = DEE->ops->initialize(DEE); if (retval != ARK_SUCCESS) { - arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, - MSG_ARK_INTERNAL_DOMEIG_FAIL); + arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, + __FILE__, MSG_ARK_INTERNAL_DOMEIG_FAIL); return NULL; } /* Set the number of preprocessings */ - if(DEE->ops->setnumofperprocess != NULL) + if (DEE->ops->setnumofperprocess != NULL) { retval = DEE->ops->setnumofperprocess(DEE, step_mem->domeig_power_of_A); if (retval != ARK_SUCCESS) { - arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, - MSG_ARK_INTERNAL_DOMEIG_FAIL); + arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, + __FILE__, MSG_ARK_INTERNAL_DOMEIG_FAIL); return NULL; } } @@ -2431,26 +2440,26 @@ suncomplextype lsrkStep_DomEigEstimate(void* arkode_mem, SUNDomEigEstimator DEE) } /* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ - if(DEE->ops->preprocess != NULL) + if (DEE->ops->preprocess != NULL) { retval = DEE->ops->preprocess(DEE); if (retval != ARK_SUCCESS) { - arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, - MSG_ARK_INTERNAL_DOMEIG_FAIL); + arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, + __FILE__, MSG_ARK_INTERNAL_DOMEIG_FAIL); return dom_eig; } } /* Compute the Hessenberg matrix Hes if Arnoldi */ - if(DEE->ops->computehess != NULL) + if (DEE->ops->computehess != NULL) { retval = DEE->ops->computehess(DEE); if (retval != ARK_SUCCESS) { - arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, - MSG_ARK_INTERNAL_DOMEIG_FAIL); + arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, + __FILE__, MSG_ARK_INTERNAL_DOMEIG_FAIL); return dom_eig; } @@ -2459,8 +2468,8 @@ suncomplextype lsrkStep_DomEigEstimate(void* arkode_mem, SUNDomEigEstimator DEE) retval = DEE->ops->estimate(DEE, &dom_eig); if (retval != ARK_SUCCESS) { - arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, - MSG_ARK_INTERNAL_DOMEIG_FAIL); + arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, + __FILE__, MSG_ARK_INTERNAL_DOMEIG_FAIL); dom_eig.real = ZERO; dom_eig.imag = ZERO; @@ -2501,8 +2510,8 @@ int lsrkStep_DQJtimes(void* arkode_mem, N_Vector v, N_Vector Jv) } sunrealtype t = ark_mem->tn; - N_Vector y = ark_mem->yn; - N_Vector fy = ark_mem->fn; //make sure it is current! + N_Vector y = ark_mem->yn; + N_Vector fy = ark_mem->fn; //make sure it is current! N_Vector work = ark_mem->tempv3; /* Initialize perturbation to 1/||v|| */ diff --git a/src/arkode/arkode_lsrkstep_impl.h b/src/arkode/arkode_lsrkstep_impl.h index ab3a933d97..506eb7177d 100644 --- a/src/arkode/arkode_lsrkstep_impl.h +++ b/src/arkode/arkode_lsrkstep_impl.h @@ -23,7 +23,7 @@ #include #ifdef SUNDIALS_BLAS_LAPACK_ENABLED - #include +#include #endif #include "arkode_impl.h" @@ -148,8 +148,8 @@ typedef struct ARKodeLSRKStepMemRec ARKODE_LSRKMethodType LSRKmethod; /* Counters and stats*/ - long int nfe; /* num fe calls */ - long int nfeDQ; /* num fe calls for difference quotient approximation */ + long int nfe; /* num fe calls */ + long int nfeDQ; /* num fe calls for difference quotient approximation */ long int dom_eig_num_evals; /* num of dom_eig computations */ int stage_max; /* num of max stages used */ int stage_max_limit; /* max allowed num of stages */ @@ -167,10 +167,10 @@ typedef struct ARKodeLSRKStepMemRec ARKODE_LSRKInternal_DomEigEst_Type internal_domeigest_type; /* Internal DomEig estimator type*/ SUNDomEigEstimator DEE; /* DomEig estimator*/ - N_Vector domeig_q; /* DomEig initial q vector*/ - int domeig_maxl; /* Krylov subspace dimension */ + N_Vector domeig_q; /* DomEig initial q vector*/ + int domeig_maxl; /* Krylov subspace dimension */ int domeig_power_of_A; /* Power of A for the warm-up */ - int domeig_maxiters; /* Max number of Power Iterations */ + int domeig_maxiters; /* Max number of Power Iterations */ /* Flags */ sunbooleantype dom_eig_update; /* flag indicating new dom_eig is needed */ diff --git a/src/arkode/arkode_lsrkstep_io.c b/src/arkode/arkode_lsrkstep_io.c index 60c61f6ac1..e9c87e5b3a 100644 --- a/src/arkode/arkode_lsrkstep_io.c +++ b/src/arkode/arkode_lsrkstep_io.c @@ -218,7 +218,7 @@ int LSRKStepSetDomEigFn(void* arkode_mem, ARKDomEigFn dom_eig) else { /* Set the default internal dominant eigenvalue estimator type */ - if(step_mem->internal_domeigest_type != ARKODE_LSRK_ARNOLDI_ITERATION) + if (step_mem->internal_domeigest_type != ARKODE_LSRK_ARNOLDI_ITERATION) { step_mem->internal_domeigest_type == ARKODE_LSRK_POWER_ITERATION; } @@ -227,8 +227,8 @@ int LSRKStepSetDomEigFn(void* arkode_mem, ARKDomEigFn dom_eig) step_mem->DEE = lsrkStep_DomEigCreate(arkode_mem); if (step_mem->DEE == NULL) { - arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, - "Internal DomEigEstimator is NULL"); + arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, + __FILE__, "Internal DomEigEstimator is NULL"); return ARK_INTERNAL_DOMEIG_FAIL; } @@ -239,8 +239,8 @@ int LSRKStepSetDomEigFn(void* arkode_mem, ARKDomEigFn dom_eig) /*--------------------------------------------------------------- LSRKStepSetInternalDomEigEstType sets internal DomEigEst type. ---------------------------------------------------------------*/ -SUNDIALS_EXPORT int LSRKStepSetInternalDomEigEstType(void* arkode_mem, - ARKODE_LSRKInternal_DomEigEst_Type dom_eig_type) +SUNDIALS_EXPORT int LSRKStepSetInternalDomEigEstType( + void* arkode_mem, ARKODE_LSRKInternal_DomEigEst_Type dom_eig_type) { ARKodeMem ark_mem; ARKodeLSRKStepMem step_mem; @@ -255,7 +255,7 @@ SUNDIALS_EXPORT int LSRKStepSetInternalDomEigEstType(void* arkode_mem, { step_mem->internal_domeigest_type = ARKODE_LSRK_POWER_ITERATION; /* Create internal dominant eigenvalue estimator -- PI */ - if(step_mem->DEE == NULL) + if (step_mem->DEE == NULL) { step_mem->DEE = lsrkStep_DomEigCreate(arkode_mem); } @@ -265,20 +265,21 @@ SUNDIALS_EXPORT int LSRKStepSetInternalDomEigEstType(void* arkode_mem, #ifdef SUNDIALS_BLAS_LAPACK_ENABLED step_mem->internal_domeigest_type = ARKODE_LSRK_ARNOLDI_ITERATION; /* Create an internal dominant eigenvalue estimator -- ArnI*/ - if(step_mem->DEE == NULL) + if (step_mem->DEE == NULL) { step_mem->DEE = lsrkStep_DomEigCreate(arkode_mem); } #else - arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, + arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, + __FILE__, "Internal Arnoldi iteration requires LAPACK package"); return ARK_INTERNAL_DOMEIG_FAIL; #endif } else { - arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, - "Attempted to set an internal domeig estimator with an unknown type"); + arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, + __FILE__, "Attempted to set an internal domeig estimator with an unknown type"); return ARK_INTERNAL_DOMEIG_FAIL; } return ARK_SUCCESS; @@ -580,7 +581,7 @@ int lsrkStep_SetDefaults(ARKodeMem ark_mem) step_mem->dom_eig_safety = DOM_EIG_SAFETY_DEFAULT; step_mem->dom_eig_freq = DOM_EIG_FREQ_DEFAULT; step_mem->domeig_maxl = DOMEIG_MAXL_DEFAULT; - step_mem->domeig_power_of_A = DOMEIG_POWER_OF_A_DEFAULT; + step_mem->domeig_power_of_A = DOMEIG_POWER_OF_A_DEFAULT; /* Flags */ step_mem->dom_eig_update = SUNTRUE; diff --git a/src/arkode/fmod_int32/farkode_lsrkstep_mod.c b/src/arkode/fmod_int32/farkode_lsrkstep_mod.c index c1f88ede14..f9c7cdf3eb 100644 --- a/src/arkode/fmod_int32/farkode_lsrkstep_mod.c +++ b/src/arkode/fmod_int32/farkode_lsrkstep_mod.c @@ -372,6 +372,20 @@ SWIGEXPORT int _wrap_FLSRKStepSetDomEigFn(void *farg1, ARKDomEigFn farg2) { } +SWIGEXPORT int _wrap_FLSRKStepSetInternalDomEigEstType(void *farg1, int const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + ARKODE_LSRKInternal_DomEigEst_Type arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (ARKODE_LSRKInternal_DomEigEst_Type)(*farg2); + result = (int)LSRKStepSetInternalDomEigEstType(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FLSRKStepSetDomEigFrequency(void *farg1, long const *farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/arkode/fmod_int32/farkode_lsrkstep_mod.f90 b/src/arkode/fmod_int32/farkode_lsrkstep_mod.f90 index a84f45c587..6781a3e5bd 100644 --- a/src/arkode/fmod_int32/farkode_lsrkstep_mod.f90 +++ b/src/arkode/fmod_int32/farkode_lsrkstep_mod.f90 @@ -36,6 +36,13 @@ module farkode_lsrkstep_mod end enum integer, parameter, public :: ARKODE_LSRKMethodType = kind(ARKODE_LSRK_RKC_2) public :: ARKODE_LSRK_RKC_2, ARKODE_LSRK_RKL_2, ARKODE_LSRK_SSP_S_2, ARKODE_LSRK_SSP_S_3, ARKODE_LSRK_SSP_10_4 + ! typedef enum ARKODE_LSRKInternal_DomEigEst_Type + enum, bind(c) + enumerator :: ARKODE_LSRK_POWER_ITERATION + enumerator :: ARKODE_LSRK_ARNOLDI_ITERATION + end enum + integer, parameter, public :: ARKODE_LSRKInternal_DomEigEst_Type = kind(ARKODE_LSRK_POWER_ITERATION) + public :: ARKODE_LSRK_POWER_ITERATION, ARKODE_LSRK_ARNOLDI_ITERATION public :: FLSRKStepCreateSTS public :: FLSRKStepCreateSSP public :: FLSRKStepReInitSTS @@ -49,6 +56,7 @@ module farkode_lsrkstep_mod public :: FLSRKStepSetSTSMethodByName public :: FLSRKStepSetSSPMethodByName public :: FLSRKStepSetDomEigFn + public :: FLSRKStepSetInternalDomEigEstType public :: FLSRKStepSetDomEigFrequency public :: FLSRKStepSetMaxNumStages public :: FLSRKStepSetDomEigSafetyFactor @@ -149,6 +157,15 @@ function swigc_FLSRKStepSetDomEigFn(farg1, farg2) & integer(C_INT) :: fresult end function +function swigc_FLSRKStepSetInternalDomEigEstType(farg1, farg2) & +bind(C, name="_wrap_FLSRKStepSetInternalDomEigEstType") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT), intent(in) :: farg2 +integer(C_INT) :: fresult +end function + function swigc_FLSRKStepSetDomEigFrequency(farg1, farg2) & bind(C, name="_wrap_FLSRKStepSetDomEigFrequency") & result(fresult) @@ -396,6 +413,22 @@ function FLSRKStepSetDomEigFn(arkode_mem, dom_eig) & swig_result = fresult end function +function FLSRKStepSetInternalDomEigEstType(arkode_mem, dom_eig_type) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(ARKODE_LSRKInternal_DomEigEst_Type), intent(in) :: dom_eig_type +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = arkode_mem +farg2 = dom_eig_type +fresult = swigc_FLSRKStepSetInternalDomEigEstType(farg1, farg2) +swig_result = fresult +end function + function FLSRKStepSetDomEigFrequency(arkode_mem, nsteps) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/arkode/fmod_int32/farkode_mod.f90 b/src/arkode/fmod_int32/farkode_mod.f90 index 30db523cfc..d0a33ee659 100644 --- a/src/arkode/fmod_int32/farkode_mod.f90 +++ b/src/arkode/fmod_int32/farkode_mod.f90 @@ -101,6 +101,7 @@ module farkode_mod integer(C_INT), parameter, public :: ARK_ADJ_CHECKPOINT_FAIL = -53_C_INT integer(C_INT), parameter, public :: ARK_ADJ_RECOMPUTE_FAIL = -54_C_INT integer(C_INT), parameter, public :: ARK_SUNADJSTEPPER_ERR = -55_C_INT + integer(C_INT), parameter, public :: ARK_INTERNAL_DOMEIG_FAIL = -56_C_INT integer(C_INT), parameter, public :: ARK_UNRECOGNIZED_ERROR = -99_C_INT ! typedef enum ARKRelaxSolver enum, bind(c) diff --git a/src/arkode/fmod_int64/farkode_lsrkstep_mod.c b/src/arkode/fmod_int64/farkode_lsrkstep_mod.c index c1f88ede14..f9c7cdf3eb 100644 --- a/src/arkode/fmod_int64/farkode_lsrkstep_mod.c +++ b/src/arkode/fmod_int64/farkode_lsrkstep_mod.c @@ -372,6 +372,20 @@ SWIGEXPORT int _wrap_FLSRKStepSetDomEigFn(void *farg1, ARKDomEigFn farg2) { } +SWIGEXPORT int _wrap_FLSRKStepSetInternalDomEigEstType(void *farg1, int const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + ARKODE_LSRKInternal_DomEigEst_Type arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (ARKODE_LSRKInternal_DomEigEst_Type)(*farg2); + result = (int)LSRKStepSetInternalDomEigEstType(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FLSRKStepSetDomEigFrequency(void *farg1, long const *farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/arkode/fmod_int64/farkode_lsrkstep_mod.f90 b/src/arkode/fmod_int64/farkode_lsrkstep_mod.f90 index a84f45c587..6781a3e5bd 100644 --- a/src/arkode/fmod_int64/farkode_lsrkstep_mod.f90 +++ b/src/arkode/fmod_int64/farkode_lsrkstep_mod.f90 @@ -36,6 +36,13 @@ module farkode_lsrkstep_mod end enum integer, parameter, public :: ARKODE_LSRKMethodType = kind(ARKODE_LSRK_RKC_2) public :: ARKODE_LSRK_RKC_2, ARKODE_LSRK_RKL_2, ARKODE_LSRK_SSP_S_2, ARKODE_LSRK_SSP_S_3, ARKODE_LSRK_SSP_10_4 + ! typedef enum ARKODE_LSRKInternal_DomEigEst_Type + enum, bind(c) + enumerator :: ARKODE_LSRK_POWER_ITERATION + enumerator :: ARKODE_LSRK_ARNOLDI_ITERATION + end enum + integer, parameter, public :: ARKODE_LSRKInternal_DomEigEst_Type = kind(ARKODE_LSRK_POWER_ITERATION) + public :: ARKODE_LSRK_POWER_ITERATION, ARKODE_LSRK_ARNOLDI_ITERATION public :: FLSRKStepCreateSTS public :: FLSRKStepCreateSSP public :: FLSRKStepReInitSTS @@ -49,6 +56,7 @@ module farkode_lsrkstep_mod public :: FLSRKStepSetSTSMethodByName public :: FLSRKStepSetSSPMethodByName public :: FLSRKStepSetDomEigFn + public :: FLSRKStepSetInternalDomEigEstType public :: FLSRKStepSetDomEigFrequency public :: FLSRKStepSetMaxNumStages public :: FLSRKStepSetDomEigSafetyFactor @@ -149,6 +157,15 @@ function swigc_FLSRKStepSetDomEigFn(farg1, farg2) & integer(C_INT) :: fresult end function +function swigc_FLSRKStepSetInternalDomEigEstType(farg1, farg2) & +bind(C, name="_wrap_FLSRKStepSetInternalDomEigEstType") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT), intent(in) :: farg2 +integer(C_INT) :: fresult +end function + function swigc_FLSRKStepSetDomEigFrequency(farg1, farg2) & bind(C, name="_wrap_FLSRKStepSetDomEigFrequency") & result(fresult) @@ -396,6 +413,22 @@ function FLSRKStepSetDomEigFn(arkode_mem, dom_eig) & swig_result = fresult end function +function FLSRKStepSetInternalDomEigEstType(arkode_mem, dom_eig_type) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(ARKODE_LSRKInternal_DomEigEst_Type), intent(in) :: dom_eig_type +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = arkode_mem +farg2 = dom_eig_type +fresult = swigc_FLSRKStepSetInternalDomEigEstType(farg1, farg2) +swig_result = fresult +end function + function FLSRKStepSetDomEigFrequency(arkode_mem, nsteps) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/arkode/fmod_int64/farkode_mod.f90 b/src/arkode/fmod_int64/farkode_mod.f90 index ddce412866..cb314ee229 100644 --- a/src/arkode/fmod_int64/farkode_mod.f90 +++ b/src/arkode/fmod_int64/farkode_mod.f90 @@ -101,6 +101,7 @@ module farkode_mod integer(C_INT), parameter, public :: ARK_ADJ_CHECKPOINT_FAIL = -53_C_INT integer(C_INT), parameter, public :: ARK_ADJ_RECOMPUTE_FAIL = -54_C_INT integer(C_INT), parameter, public :: ARK_SUNADJSTEPPER_ERR = -55_C_INT + integer(C_INT), parameter, public :: ARK_INTERNAL_DOMEIG_FAIL = -56_C_INT integer(C_INT), parameter, public :: ARK_UNRECOGNIZED_ERROR = -99_C_INT ! typedef enum ARKRelaxSolver enum, bind(c) diff --git a/src/nvector/cuda/VectorKernels.cuh b/src/nvector/cuda/VectorKernels.cuh index 995481e7de..e3e3eb6eed 100644 --- a/src/nvector/cuda/VectorKernels.cuh +++ b/src/nvector/cuda/VectorKernels.cuh @@ -299,13 +299,14 @@ __global__ void minQuotientKernel(const T MAX_VAL, const T* num, const T* den, template __global__ void randomKernel(T* X, I n) { - GRID_STRIDE_XLOOP(I, i, n) { - // Initialize random state - curandState state; - curand_init(clock64(), i, 0, &state); - // Generate random number between 0 and 1 - X[i] = (sunrealtype) curand_uniform(&state) / (sunrealtype) UINT_MAX; - } + GRID_STRIDE_XLOOP(I, i, n) + { + // Initialize random state + curandState state; + curand_init(clock64(), i, 0, &state); + // Generate random number between 0 and 1 + X[i] = (sunrealtype)curand_uniform(&state) / (sunrealtype)UINT_MAX; + } } } // namespace impl diff --git a/src/nvector/cuda/nvector_cuda.cu b/src/nvector/cuda/nvector_cuda.cu index f0b05e58fb..76331c7c00 100644 --- a/src/nvector/cuda/nvector_cuda.cu +++ b/src/nvector/cuda/nvector_cuda.cu @@ -1372,7 +1372,7 @@ SUNErrCode N_VRandom_Cuda(N_Vector X) } randomKernel<<>>(NVEC_CUDA_DDATAp(X), - NVEC_CUDA_CONTENT(X)->length); + NVEC_CUDA_CONTENT(X)->length); PostKernelLaunch(); return SUN_SUCCESS; } diff --git a/src/nvector/manyvector/nvector_manyvector.c b/src/nvector/manyvector/nvector_manyvector.c index 8a1b8e77bd..355bce0dd5 100644 --- a/src/nvector/manyvector/nvector_manyvector.c +++ b/src/nvector/manyvector/nvector_manyvector.c @@ -247,7 +247,7 @@ N_Vector N_VMake_MPIManyVector(MPI_Comm comm, sunindextype num_subvectors, if (v->ops->nvrandom) { rank = SubvectorMPIRank(vec_array[0]); - srand(rank+1); + srand(rank + 1); } return (v); @@ -447,10 +447,7 @@ N_Vector N_VNew_ManyVector(sunindextype num_subvectors, N_Vector* vec_array, } /* Seed random number generator to ensure reproducibility between runs */ - if (v->ops->nvrandom) - { - srand(1); - } + if (v->ops->nvrandom) { srand(1); } return (v); } @@ -1499,7 +1496,6 @@ SUNErrCode N_VDotProdMultiAllReduce_MPIManyVector(int nvec_total, N_Vector x, } #endif - SUNErrCode MVAPPEND(N_VRandom)(N_Vector x) { SUNFunctionBegin(x->sunctx); @@ -1511,7 +1507,6 @@ SUNErrCode MVAPPEND(N_VRandom)(N_Vector x) return SUN_SUCCESS; } - /* ----------------------------------------------------------------- Fused vector operations ----------------------------------------------------------------- */ diff --git a/src/nvector/openmp/nvector_openmp.c b/src/nvector/openmp/nvector_openmp.c index 97a8c12cdf..adf492055c 100644 --- a/src/nvector/openmp/nvector_openmp.c +++ b/src/nvector/openmp/nvector_openmp.c @@ -1003,8 +1003,8 @@ sunrealtype N_VMinQuotient_OpenMP(N_Vector num, N_Vector denom) SUNErrCode N_VRandom_OpenMP(N_Vector x) { SUNFunctionBegin(x->sunctx); - sunrealtype *xd = NULL; - xd = NV_DATA_OMP(x); + sunrealtype* xd = NULL; + xd = NV_DATA_OMP(x); for (int i = 0; i < NV_LENGTH_OMP(x); i++) { xd[i] = (sunrealtype)rand() / (sunrealtype)RAND_MAX; diff --git a/src/nvector/parallel/nvector_parallel.c b/src/nvector/parallel/nvector_parallel.c index 9f61518000..97e8170811 100644 --- a/src/nvector/parallel/nvector_parallel.c +++ b/src/nvector/parallel/nvector_parallel.c @@ -184,7 +184,7 @@ N_Vector N_VNewEmpty_Parallel(MPI_Comm comm, sunindextype local_length, /* Seed random number generator with MPI rank ID to ensure distinct streams */ SUNCheckMPICallNull(MPI_Comm_rank(comm, &myid)); - srand(myid+1); + srand(myid + 1); return (v); } @@ -668,7 +668,7 @@ sunrealtype N_VDotProd_Parallel(N_Vector x, N_Vector y) sunrealtype lsum, gsum; lsum = N_VDotProdLocal_Parallel(x, y); SUNCheckLastErrNoRet(); - SUNCheckMPICallNoRet( + SUNCheckMPICallNoRet( MPI_Allreduce(&lsum, &gsum, 1, MPI_SUNREALTYPE, MPI_SUM, NV_COMM_P(x))); return (gsum); } @@ -980,8 +980,8 @@ sunrealtype N_VMinQuotient_Parallel(N_Vector num, N_Vector denom) SUNErrCode N_VRandom_Parallel(N_Vector x) { SUNFunctionBegin(x->sunctx); - sunrealtype *xd = NULL; - xd = NV_DATA_P(x); + sunrealtype* xd = NULL; + xd = NV_DATA_P(x); for (int i = 0; i < NV_LOCLENGTH_P(x); i++) { xd[i] = (sunrealtype)rand() / (sunrealtype)RAND_MAX; diff --git a/src/nvector/parhyp/nvector_parhyp.c b/src/nvector/parhyp/nvector_parhyp.c index 44ba94a113..9affbe6482 100644 --- a/src/nvector/parhyp/nvector_parhyp.c +++ b/src/nvector/parhyp/nvector_parhyp.c @@ -237,7 +237,7 @@ N_Vector N_VNewEmpty_ParHyp(MPI_Comm comm, sunindextype local_length, /* Seed random number generator with MPI rank ID to ensure distinct streams */ SUNCheckMPICallNull(MPI_Comm_rank(comm, &myid)); - srand(myid+1); + srand(myid + 1); return (v); } @@ -945,8 +945,8 @@ sunrealtype N_VMinQuotient_ParHyp(N_Vector num, N_Vector denom) SUNErrCode N_VRandom_ParHyp(N_Vector x) { SUNFunctionBegin(x->sunctx); - sunrealtype *xd = NULL; - xd = NV_DATA_PH(x); + sunrealtype* xd = NULL; + xd = NV_DATA_PH(x); for (int i = 0; i < NV_LOCLENGTH_PH(x); i++) { xd[i] = (sunrealtype)rand() / (sunrealtype)RAND_MAX; diff --git a/src/nvector/petsc/nvector_petsc.c b/src/nvector/petsc/nvector_petsc.c index 084f4a7fec..11f63bdfe9 100644 --- a/src/nvector/petsc/nvector_petsc.c +++ b/src/nvector/petsc/nvector_petsc.c @@ -873,8 +873,8 @@ sunrealtype N_VMinQuotient_Petsc(N_Vector num, N_Vector denom) SUNErrCode N_VRandom_Petsc(N_Vector x) { SUNFunctionBegin(x->sunctx); - Vec xv = NV_PVEC_PTC(x); - PetscErrorCode ierr = VecSetRandom(xv,NULL); + Vec xv = NV_PVEC_PTC(x); + PetscErrorCode ierr = VecSetRandom(xv, NULL); CHKERRABORT(NV_COMM_PTC(x), ierr); return SUN_SUCCESS; } diff --git a/src/nvector/serial/nvector_serial.c b/src/nvector/serial/nvector_serial.c index 838af2bb67..3a71aa00ec 100644 --- a/src/nvector/serial/nvector_serial.c +++ b/src/nvector/serial/nvector_serial.c @@ -867,8 +867,8 @@ sunrealtype N_VMinQuotient_Serial(N_Vector num, N_Vector denom) SUNErrCode N_VRandom_Serial(N_Vector x) { SUNFunctionBegin(x->sunctx); - sunrealtype *xd = NULL; - xd = NV_DATA_S(x); + sunrealtype* xd = NULL; + xd = NV_DATA_S(x); for (int i = 0; i < NV_LENGTH_S(x); i++) { xd[i] = (sunrealtype)rand() / (sunrealtype)RAND_MAX; diff --git a/src/sundials/fmod_int32/fsundials_core_mod.c b/src/sundials/fmod_int32/fsundials_core_mod.c index 9b579ade0f..1218556674 100644 --- a/src/sundials/fmod_int32/fsundials_core_mod.c +++ b/src/sundials/fmod_int32/fsundials_core_mod.c @@ -1367,6 +1367,18 @@ SWIGEXPORT int _wrap_FN_VWrmsNormMaskVectorArray(int const *farg1, void *farg2, } +SWIGEXPORT int _wrap_FN_VRandom(N_Vector farg1) { + int fresult ; + N_Vector arg1 = (N_Vector) 0 ; + SUNErrCode result; + + arg1 = (N_Vector)(farg1); + result = (SUNErrCode)N_VRandom(arg1); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT double _wrap_FN_VDotProdLocal(N_Vector farg1, N_Vector farg2) { double fresult ; N_Vector arg1 = (N_Vector) 0 ; diff --git a/src/sundials/fmod_int32/fsundials_core_mod.f90 b/src/sundials/fmod_int32/fsundials_core_mod.f90 index f1b63ec9ea..51b6a0ec2e 100644 --- a/src/sundials/fmod_int32/fsundials_core_mod.f90 +++ b/src/sundials/fmod_int32/fsundials_core_mod.f90 @@ -90,6 +90,13 @@ module fsundials_core_mod enumerator :: SUN_ERR_ADJOINT_STEPPERINVALIDSTOP enumerator :: SUN_ERR_CHECKPOINT_NOT_FOUND enumerator :: SUN_ERR_CHECKPOINT_MISMATCH + enumerator :: SUN_ERR_DOMEIG_BAD_NVECTOR + enumerator :: SUN_ERR_DOMEIG_NULL_ATIMES + enumerator :: SUN_ERR_DOMEIG_NULL_HES + enumerator :: SUN_ERR_DOMEIG_NOT_ENOUGH_ITER + enumerator :: SUN_ERR_DOMEIG_ATIMES_FAIL_REC + enumerator :: SUN_ERR_DOMEIG_ATIMES_FAIL_UNREC + enumerator :: SUN_ERR_DOMEIG_LAPACK_FAIL enumerator :: SUN_ERR_SUNCTX_CORRUPT enumerator :: SUN_ERR_MPI_FAIL enumerator :: SUN_ERR_UNREACHABLE @@ -102,8 +109,10 @@ module fsundials_core_mod SUN_ERR_MEM_FAIL, SUN_ERR_MALLOC_FAIL, SUN_ERR_EXT_FAIL, SUN_ERR_DESTROY_FAIL, SUN_ERR_NOT_IMPLEMENTED, & SUN_ERR_USER_FCN_FAIL, SUN_ERR_DATANODE_NODENOTFOUND, SUN_ERR_PROFILER_MAPFULL, SUN_ERR_PROFILER_MAPGET, & SUN_ERR_PROFILER_MAPINSERT, SUN_ERR_PROFILER_MAPKEYNOTFOUND, SUN_ERR_PROFILER_MAPSORT, SUN_ERR_ADJOINT_STEPPERFAILED, & - SUN_ERR_ADJOINT_STEPPERINVALIDSTOP, SUN_ERR_CHECKPOINT_NOT_FOUND, SUN_ERR_CHECKPOINT_MISMATCH, SUN_ERR_SUNCTX_CORRUPT, & - SUN_ERR_MPI_FAIL, SUN_ERR_UNREACHABLE, SUN_ERR_UNKNOWN, SUN_ERR_MAXIMUM, SUN_SUCCESS + SUN_ERR_ADJOINT_STEPPERINVALIDSTOP, SUN_ERR_CHECKPOINT_NOT_FOUND, SUN_ERR_CHECKPOINT_MISMATCH, SUN_ERR_DOMEIG_BAD_NVECTOR, & + SUN_ERR_DOMEIG_NULL_ATIMES, SUN_ERR_DOMEIG_NULL_HES, SUN_ERR_DOMEIG_NOT_ENOUGH_ITER, SUN_ERR_DOMEIG_ATIMES_FAIL_REC, & + SUN_ERR_DOMEIG_ATIMES_FAIL_UNREC, SUN_ERR_DOMEIG_LAPACK_FAIL, SUN_ERR_SUNCTX_CORRUPT, SUN_ERR_MPI_FAIL, SUN_ERR_UNREACHABLE, & + SUN_ERR_UNKNOWN, SUN_ERR_MAXIMUM, SUN_SUCCESS type, bind(C) :: SwigArrayWrapper type(C_PTR), public :: data = C_NULL_PTR integer(C_SIZE_T), public :: size = 0 @@ -221,6 +230,7 @@ module fsundials_core_mod type(C_FUNPTR), public :: nvwrmsnormmaskvectorarray type(C_FUNPTR), public :: nvscaleaddmultivectorarray type(C_FUNPTR), public :: nvlinearcombinationvectorarray + type(C_FUNPTR), public :: nvrandom type(C_FUNPTR), public :: nvdotprodlocal type(C_FUNPTR), public :: nvmaxnormlocal type(C_FUNPTR), public :: nvminlocal @@ -283,6 +293,7 @@ module fsundials_core_mod public :: FN_VConstVectorArray public :: FN_VWrmsNormVectorArray public :: FN_VWrmsNormMaskVectorArray + public :: FN_VRandom public :: FN_VDotProdLocal public :: FN_VMaxNormLocal public :: FN_VMinLocal @@ -1336,6 +1347,14 @@ function swigc_FN_VWrmsNormMaskVectorArray(farg1, farg2, farg3, farg4, farg5) & integer(C_INT) :: fresult end function +function swigc_FN_VRandom(farg1) & +bind(C, name="_wrap_FN_VRandom") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + function swigc_FN_VDotProdLocal(farg1, farg2) & bind(C, name="_wrap_FN_VDotProdLocal") & result(fresult) @@ -4077,6 +4096,19 @@ function FN_VWrmsNormMaskVectorArray(nvec, x, w, id, nrm) & swig_result = fresult end function +function FN_VRandom(x) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(N_Vector), target, intent(inout) :: x +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(x) +fresult = swigc_FN_VRandom(farg1) +swig_result = fresult +end function + function FN_VDotProdLocal(x, y) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sundials/fmod_int64/fsundials_core_mod.c b/src/sundials/fmod_int64/fsundials_core_mod.c index f1558f4027..949620b822 100644 --- a/src/sundials/fmod_int64/fsundials_core_mod.c +++ b/src/sundials/fmod_int64/fsundials_core_mod.c @@ -1367,6 +1367,18 @@ SWIGEXPORT int _wrap_FN_VWrmsNormMaskVectorArray(int const *farg1, void *farg2, } +SWIGEXPORT int _wrap_FN_VRandom(N_Vector farg1) { + int fresult ; + N_Vector arg1 = (N_Vector) 0 ; + SUNErrCode result; + + arg1 = (N_Vector)(farg1); + result = (SUNErrCode)N_VRandom(arg1); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT double _wrap_FN_VDotProdLocal(N_Vector farg1, N_Vector farg2) { double fresult ; N_Vector arg1 = (N_Vector) 0 ; diff --git a/src/sundials/fmod_int64/fsundials_core_mod.f90 b/src/sundials/fmod_int64/fsundials_core_mod.f90 index 9858ab966d..03902629e0 100644 --- a/src/sundials/fmod_int64/fsundials_core_mod.f90 +++ b/src/sundials/fmod_int64/fsundials_core_mod.f90 @@ -90,6 +90,13 @@ module fsundials_core_mod enumerator :: SUN_ERR_ADJOINT_STEPPERINVALIDSTOP enumerator :: SUN_ERR_CHECKPOINT_NOT_FOUND enumerator :: SUN_ERR_CHECKPOINT_MISMATCH + enumerator :: SUN_ERR_DOMEIG_BAD_NVECTOR + enumerator :: SUN_ERR_DOMEIG_NULL_ATIMES + enumerator :: SUN_ERR_DOMEIG_NULL_HES + enumerator :: SUN_ERR_DOMEIG_NOT_ENOUGH_ITER + enumerator :: SUN_ERR_DOMEIG_ATIMES_FAIL_REC + enumerator :: SUN_ERR_DOMEIG_ATIMES_FAIL_UNREC + enumerator :: SUN_ERR_DOMEIG_LAPACK_FAIL enumerator :: SUN_ERR_SUNCTX_CORRUPT enumerator :: SUN_ERR_MPI_FAIL enumerator :: SUN_ERR_UNREACHABLE @@ -102,8 +109,10 @@ module fsundials_core_mod SUN_ERR_MEM_FAIL, SUN_ERR_MALLOC_FAIL, SUN_ERR_EXT_FAIL, SUN_ERR_DESTROY_FAIL, SUN_ERR_NOT_IMPLEMENTED, & SUN_ERR_USER_FCN_FAIL, SUN_ERR_DATANODE_NODENOTFOUND, SUN_ERR_PROFILER_MAPFULL, SUN_ERR_PROFILER_MAPGET, & SUN_ERR_PROFILER_MAPINSERT, SUN_ERR_PROFILER_MAPKEYNOTFOUND, SUN_ERR_PROFILER_MAPSORT, SUN_ERR_ADJOINT_STEPPERFAILED, & - SUN_ERR_ADJOINT_STEPPERINVALIDSTOP, SUN_ERR_CHECKPOINT_NOT_FOUND, SUN_ERR_CHECKPOINT_MISMATCH, SUN_ERR_SUNCTX_CORRUPT, & - SUN_ERR_MPI_FAIL, SUN_ERR_UNREACHABLE, SUN_ERR_UNKNOWN, SUN_ERR_MAXIMUM, SUN_SUCCESS + SUN_ERR_ADJOINT_STEPPERINVALIDSTOP, SUN_ERR_CHECKPOINT_NOT_FOUND, SUN_ERR_CHECKPOINT_MISMATCH, SUN_ERR_DOMEIG_BAD_NVECTOR, & + SUN_ERR_DOMEIG_NULL_ATIMES, SUN_ERR_DOMEIG_NULL_HES, SUN_ERR_DOMEIG_NOT_ENOUGH_ITER, SUN_ERR_DOMEIG_ATIMES_FAIL_REC, & + SUN_ERR_DOMEIG_ATIMES_FAIL_UNREC, SUN_ERR_DOMEIG_LAPACK_FAIL, SUN_ERR_SUNCTX_CORRUPT, SUN_ERR_MPI_FAIL, SUN_ERR_UNREACHABLE, & + SUN_ERR_UNKNOWN, SUN_ERR_MAXIMUM, SUN_SUCCESS type, bind(C) :: SwigArrayWrapper type(C_PTR), public :: data = C_NULL_PTR integer(C_SIZE_T), public :: size = 0 @@ -221,6 +230,7 @@ module fsundials_core_mod type(C_FUNPTR), public :: nvwrmsnormmaskvectorarray type(C_FUNPTR), public :: nvscaleaddmultivectorarray type(C_FUNPTR), public :: nvlinearcombinationvectorarray + type(C_FUNPTR), public :: nvrandom type(C_FUNPTR), public :: nvdotprodlocal type(C_FUNPTR), public :: nvmaxnormlocal type(C_FUNPTR), public :: nvminlocal @@ -283,6 +293,7 @@ module fsundials_core_mod public :: FN_VConstVectorArray public :: FN_VWrmsNormVectorArray public :: FN_VWrmsNormMaskVectorArray + public :: FN_VRandom public :: FN_VDotProdLocal public :: FN_VMaxNormLocal public :: FN_VMinLocal @@ -1336,6 +1347,14 @@ function swigc_FN_VWrmsNormMaskVectorArray(farg1, farg2, farg3, farg4, farg5) & integer(C_INT) :: fresult end function +function swigc_FN_VRandom(farg1) & +bind(C, name="_wrap_FN_VRandom") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + function swigc_FN_VDotProdLocal(farg1, farg2) & bind(C, name="_wrap_FN_VDotProdLocal") & result(fresult) @@ -4077,6 +4096,19 @@ function FN_VWrmsNormMaskVectorArray(nvec, x, w, id, nrm) & swig_result = fresult end function +function FN_VRandom(x) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(N_Vector), target, intent(inout) :: x +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(x) +fresult = swigc_FN_VRandom(farg1) +swig_result = fresult +end function + function FN_VDotProdLocal(x, y) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sundials/sundials_domeigestimator.c b/src/sundials/sundials_domeigestimator.c index 7149063ba3..e557d01042 100644 --- a/src/sundials/sundials_domeigestimator.c +++ b/src/sundials/sundials_domeigestimator.c @@ -20,8 +20,8 @@ #include #include -#include #include +#include #if defined(SUNDIALS_BUILD_WITH_PROFILING) static SUNProfiler getSUNProfiler(SUNDomEigEstimator DEE) @@ -98,7 +98,8 @@ SUNDomEigEstimator_Type SUNDomEigEstGetType(SUNDomEigEstimator DEE) return (DEE->ops->gettype(DEE)); } -SUNErrCode SUNDomEigEstSetATimes(SUNDomEigEstimator DEE, void* A_data, SUNATimesFn ATimes) +SUNErrCode SUNDomEigEstSetATimes(SUNDomEigEstimator DEE, void* A_data, + SUNATimesFn ATimes) { SUNErrCode ier; SUNDIALS_MARK_FUNCTION_BEGIN(getSUNProfiler(DEE)); diff --git a/src/sundials/sundials_nvector.c b/src/sundials/sundials_nvector.c index 8c4d858806..c2ed9c0703 100644 --- a/src/sundials/sundials_nvector.c +++ b/src/sundials/sundials_nvector.c @@ -124,7 +124,7 @@ N_Vector N_VNewEmpty(SUNContext sunctx) */ ops->nvgetlocallength = NULL; - ops->nvrandom = NULL; + ops->nvrandom = NULL; /* local reduction operations (optional) */ ops->nvdotprodlocal = NULL; @@ -839,10 +839,7 @@ SUNErrCode N_VRandom(N_Vector x) { SUNErrCode ier = SUN_SUCCESS; SUNDIALS_MARK_FUNCTION_BEGIN(getSUNProfiler(x)); - if (x->ops->nvrandom != NULL) - { - ier = (x->ops->nvrandom(x)); - } + if (x->ops->nvrandom != NULL) { ier = (x->ops->nvrandom(x)); } SUNDIALS_MARK_FUNCTION_END(getSUNProfiler(x)); return (ier); } diff --git a/src/sundomeigest/ArnI/CMakeLists.txt b/src/sundomeigest/ArnI/CMakeLists.txt index 719465d7bf..c1a24990a8 100644 --- a/src/sundomeigest/ArnI/CMakeLists.txt +++ b/src/sundomeigest/ArnI/CMakeLists.txt @@ -29,4 +29,4 @@ sundials_add_library( VERSION ${sundomeigestlib_VERSION} SOVERSION ${sundomeigestlib_SOVERSION}) -message(STATUS "Added SUNDOMEIGEST_ARNI module") \ No newline at end of file +message(STATUS "Added SUNDOMEIGEST_ARNI module") diff --git a/src/sundomeigest/ArnI/sundomeigest_arni.c b/src/sundomeigest/ArnI/sundomeigest_arni.c index d69413f68d..4dcd709569 100644 --- a/src/sundomeigest/ArnI/sundomeigest_arni.c +++ b/src/sundomeigest/ArnI/sundomeigest_arni.c @@ -16,13 +16,13 @@ * ----------------------------------------------------------------- */ - #include +#include #include +#include #include #include #include -#include #include "sundials_logger_impl.h" #include "sundials_macros.h" @@ -36,7 +36,7 @@ * ----------------------------------------------------------------- */ -#define ArnI_CONTENT(DEE) ((SUNDomEigEstimatorContent_ArnI)(DEE->content)) +#define ArnI_CONTENT(DEE) ((SUNDomEigEstimatorContent_ArnI)(DEE->content)) /* * ----------------------------------------------------------------- @@ -48,7 +48,8 @@ * Function to create a new ArnI estimator */ -SUNDomEigEstimator SUNDomEigEst_ArnI(N_Vector q, sunindextype maxl, SUNContext sunctx) +SUNDomEigEstimator SUNDomEigEst_ArnI(N_Vector q, sunindextype maxl, + SUNContext sunctx) { SUNFunctionBegin(sunctx); SUNDomEigEstimator DEE; @@ -59,14 +60,14 @@ SUNDomEigEstimator SUNDomEigEst_ArnI(N_Vector q, sunindextype maxl, SUNContext s /* check for legal q; if illegal return NULL */ // TO DO: check required vector operations - SUNAssert(!( - (q->ops->nvclone == NULL) || (q->ops->nvdestroy == NULL) || - (q->ops->nvdotprod == NULL) || (q->ops->nvscale == NULL) || - (q->ops->nvgetlength == NULL) || (q->ops->nvspace == NULL)), SUN_ERR_DOMEIG_BAD_NVECTOR); + SUNAssert(!((q->ops->nvclone == NULL) || (q->ops->nvdestroy == NULL) || + (q->ops->nvdotprod == NULL) || (q->ops->nvscale == NULL) || + (q->ops->nvgetlength == NULL) || (q->ops->nvspace == NULL)), + SUN_ERR_DOMEIG_BAD_NVECTOR); /* Create dominant eigenvalue estimator */ DEE = NULL; - DEE = SUNDomEigEstNewEmpty (sunctx); + DEE = SUNDomEigEstNewEmpty(sunctx); SUNCheckLastErrNull(); /* Attach operations */ @@ -90,18 +91,18 @@ SUNDomEigEstimator SUNDomEigEst_ArnI(N_Vector q, sunindextype maxl, SUNContext s DEE->content = content; /* Fill content */ - content->ATimes = NULL; - content->ATdata = NULL; - content->V = NULL; - content->q = NULL; - content->maxl = maxl; - content->power_of_A = 0; - content->LAPACK_A = NULL; - content->LAPACK_wr = NULL; - content->LAPACK_wi = NULL; - content->LAPACK_work = NULL; - content->LAPACK_arr = NULL; - content->Hes = NULL; + content->ATimes = NULL; + content->ATdata = NULL; + content->V = NULL; + content->q = NULL; + content->maxl = maxl; + content->power_of_A = 0; + content->LAPACK_A = NULL; + content->LAPACK_wr = NULL; + content->LAPACK_wi = NULL; + content->LAPACK_work = NULL; + content->LAPACK_arr = NULL; + content->Hes = NULL; /* Allocate content */ content->q = N_VClone(q); @@ -119,7 +120,8 @@ SUNDomEigEstimator SUNDomEigEst_ArnI(N_Vector q, sunindextype maxl, SUNContext s * ----------------------------------------------------------------- */ -SUNDomEigEstimator_Type SUNDomEigEst_ArnIGetType(SUNDIALS_MAYBE_UNUSED SUNDomEigEstimator DEE) +SUNDomEigEstimator_Type SUNDomEigEst_ArnIGetType( + SUNDIALS_MAYBE_UNUSED SUNDomEigEstimator DEE) { return (SUNDOMEIG_ARNOLDI); } @@ -128,18 +130,29 @@ SUNErrCode SUNDomEigEstInitialize_ArnI(SUNDomEigEstimator DEE) { SUNFunctionBegin(DEE->sunctx); - if (ArnI_CONTENT(DEE)->maxl < 2) { ArnI_CONTENT(DEE)->maxl = SUNDOMEIGEST_ARN_MAXL_DEFAULT; } - if (ArnI_CONTENT(DEE)->power_of_A < 0) { ArnI_CONTENT(DEE)->power_of_A = SUNDOMEIGEST_PI_POWER_OF_A_DEFAULT; } + if (ArnI_CONTENT(DEE)->maxl < 2) + { + ArnI_CONTENT(DEE)->maxl = SUNDOMEIGEST_ARN_MAXL_DEFAULT; + } + if (ArnI_CONTENT(DEE)->power_of_A < 0) + { + ArnI_CONTENT(DEE)->power_of_A = SUNDOMEIGEST_PI_POWER_OF_A_DEFAULT; + } SUNAssert(ArnI_CONTENT(DEE)->ATimes, SUN_ERR_ARG_CORRUPT); SUNAssert(ArnI_CONTENT(DEE)->V, SUN_ERR_ARG_CORRUPT); SUNAssert(ArnI_CONTENT(DEE)->q, SUN_ERR_ARG_CORRUPT); - ArnI_CONTENT(DEE)->LAPACK_A = (sunrealtype*)malloc((ArnI_CONTENT(DEE)->maxl*ArnI_CONTENT(DEE)->maxl) * sizeof(sunrealtype)); - ArnI_CONTENT(DEE)->LAPACK_wr = malloc(ArnI_CONTENT(DEE)->maxl * sizeof(sunrealtype)); - ArnI_CONTENT(DEE)->LAPACK_wi = malloc(ArnI_CONTENT(DEE)->maxl * sizeof(sunrealtype)); - ArnI_CONTENT(DEE)->LAPACK_work = malloc((4 * ArnI_CONTENT(DEE)->maxl) * sizeof(sunrealtype)); - ArnI_CONTENT(DEE)->LAPACK_arr = (suncomplextype *)malloc(ArnI_CONTENT(DEE)->maxl * sizeof(suncomplextype)); + ArnI_CONTENT(DEE)->LAPACK_A = (sunrealtype*)malloc( + (ArnI_CONTENT(DEE)->maxl * ArnI_CONTENT(DEE)->maxl) * sizeof(sunrealtype)); + ArnI_CONTENT(DEE)->LAPACK_wr = + malloc(ArnI_CONTENT(DEE)->maxl * sizeof(sunrealtype)); + ArnI_CONTENT(DEE)->LAPACK_wi = + malloc(ArnI_CONTENT(DEE)->maxl * sizeof(sunrealtype)); + ArnI_CONTENT(DEE)->LAPACK_work = + malloc((4 * ArnI_CONTENT(DEE)->maxl) * sizeof(sunrealtype)); + ArnI_CONTENT(DEE)->LAPACK_arr = + (suncomplextype*)malloc(ArnI_CONTENT(DEE)->maxl * sizeof(suncomplextype)); N_VRandom(ArnI_CONTENT(DEE)->q); SUNCheckLastErrNull(); @@ -148,13 +161,14 @@ SUNErrCode SUNDomEigEstInitialize_ArnI(SUNDomEigEstimator DEE) if (ArnI_CONTENT(DEE)->Hes == NULL) { sunindextype k; - ArnI_CONTENT(DEE)->Hes = - (sunrealtype**)malloc((ArnI_CONTENT(DEE)->maxl + 1) * sizeof(sunrealtype*)); + ArnI_CONTENT(DEE)->Hes = (sunrealtype**)malloc( + (ArnI_CONTENT(DEE)->maxl + 1) * sizeof(sunrealtype*)); for (k = 0; k <= ArnI_CONTENT(DEE)->maxl; k++) { ArnI_CONTENT(DEE)->Hes[k] = NULL; - ArnI_CONTENT(DEE)->Hes[k] = (sunrealtype*)malloc(ArnI_CONTENT(DEE)->maxl * sizeof(sunrealtype)); + ArnI_CONTENT(DEE)->Hes[k] = + (sunrealtype*)malloc(ArnI_CONTENT(DEE)->maxl * sizeof(sunrealtype)); } } @@ -164,13 +178,14 @@ SUNErrCode SUNDomEigEstInitialize_ArnI(SUNDomEigEstimator DEE) normq = SUNRsqrt(normq); - N_VScale(ONE/normq, ArnI_CONTENT(DEE)->q, ArnI_CONTENT(DEE)->V[0]); + N_VScale(ONE / normq, ArnI_CONTENT(DEE)->q, ArnI_CONTENT(DEE)->V[0]); SUNCheckLastErrNull(); return SUN_SUCCESS; } -SUNErrCode SUNDomEigEstSetATimes_ArnI(SUNDomEigEstimator DEE, void* A_data, SUNATimesFn ATimes) +SUNErrCode SUNDomEigEstSetATimes_ArnI(SUNDomEigEstimator DEE, void* A_data, + SUNATimesFn ATimes) { SUNFunctionBegin(DEE->sunctx); @@ -181,7 +196,8 @@ SUNErrCode SUNDomEigEstSetATimes_ArnI(SUNDomEigEstimator DEE, void* A_data, SUNA return SUN_SUCCESS; } -SUNErrCode SUNDomEigEstSetNumofPreProcess_ArnI(SUNDomEigEstimator DEE, sunindextype numofperprocess) +SUNErrCode SUNDomEigEstSetNumofPreProcess_ArnI(SUNDomEigEstimator DEE, + sunindextype numofperprocess) { SUNFunctionBegin(DEE->sunctx); @@ -202,25 +218,21 @@ SUNErrCode SUNDomEigEstPreProcess_ArnI(SUNDomEigEstimator DEE) sunindextype i, retval; /* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ - for(i = 0; i < ArnI_CONTENT(DEE)->power_of_A; i++) + for (i = 0; i < ArnI_CONTENT(DEE)->power_of_A; i++) { - retval = ArnI_CONTENT(DEE)->ATimes(ArnI_CONTENT(DEE)->ATdata, ArnI_CONTENT(DEE)->V[0], ArnI_CONTENT(DEE)->q); + retval = ArnI_CONTENT(DEE)->ATimes(ArnI_CONTENT(DEE)->ATdata, + ArnI_CONTENT(DEE)->V[0], + ArnI_CONTENT(DEE)->q); if (retval != 0) { - if(retval < 0) - { - return SUN_ERR_DOMEIG_ATIMES_FAIL_UNREC; - } - else - { - return SUN_ERR_DOMEIG_ATIMES_FAIL_REC; - } + if (retval < 0) { return SUN_ERR_DOMEIG_ATIMES_FAIL_UNREC; } + else { return SUN_ERR_DOMEIG_ATIMES_FAIL_REC; } } normq = N_VDotProd(ArnI_CONTENT(DEE)->q, ArnI_CONTENT(DEE)->q); SUNCheckLastErr(); normq = SUNRsqrt(normq); - N_VScale(ONE/normq, ArnI_CONTENT(DEE)->q, ArnI_CONTENT(DEE)->V[0]); + N_VScale(ONE / normq, ArnI_CONTENT(DEE)->q, ArnI_CONTENT(DEE)->V[0]); SUNCheckLastErr(); } @@ -240,29 +252,31 @@ SUNErrCode SUNDomEigEstComputeHess_ArnI(SUNDomEigEstimator DEE) /* Initialize the Hessenberg matrix Hes with zeros */ for (i = 0; i < ArnI_CONTENT(DEE)->maxl; i++) { - for (j = 0; j < ArnI_CONTENT(DEE)->maxl; j++) {ArnI_CONTENT(DEE)->Hes[i][j] = ZERO; } + for (j = 0; j < ArnI_CONTENT(DEE)->maxl; j++) + { + ArnI_CONTENT(DEE)->Hes[i][j] = ZERO; + } } for (i = 0; i < ArnI_CONTENT(DEE)->maxl; i++) { /* Compute the next Krylov vector */ - retval = ArnI_CONTENT(DEE)->ATimes(ArnI_CONTENT(DEE)->ATdata, ArnI_CONTENT(DEE)->V[i], ArnI_CONTENT(DEE)->V[i+1]); + retval = ArnI_CONTENT(DEE)->ATimes(ArnI_CONTENT(DEE)->ATdata, + ArnI_CONTENT(DEE)->V[i], + ArnI_CONTENT(DEE)->V[i + 1]); if (retval != 0) { - if(retval < 0) - { - return SUN_ERR_DOMEIG_ATIMES_FAIL_UNREC; - } - else - { - return SUN_ERR_DOMEIG_ATIMES_FAIL_REC; - } + if (retval < 0) { return SUN_ERR_DOMEIG_ATIMES_FAIL_UNREC; } + else { return SUN_ERR_DOMEIG_ATIMES_FAIL_REC; } } - SUNCheckCall(SUNModifiedGS(ArnI_CONTENT(DEE)->V, ArnI_CONTENT(DEE)->Hes, i + 1, ArnI_CONTENT(DEE)->maxl, &(ArnI_CONTENT(DEE)->Hes[i + 1][i]))); + SUNCheckCall(SUNModifiedGS(ArnI_CONTENT(DEE)->V, ArnI_CONTENT(DEE)->Hes, + i + 1, ArnI_CONTENT(DEE)->maxl, + &(ArnI_CONTENT(DEE)->Hes[i + 1][i]))); /* Unitize the computed orthogonal vector */ - N_VScale(SUN_RCONST(1.0)/ArnI_CONTENT(DEE)->Hes[i + 1][i], ArnI_CONTENT(DEE)->V[i+1], ArnI_CONTENT(DEE)->V[i+1]); + N_VScale(SUN_RCONST(1.0) / ArnI_CONTENT(DEE)->Hes[i + 1][i], + ArnI_CONTENT(DEE)->V[i + 1], ArnI_CONTENT(DEE)->V[i + 1]); SUNCheckLastErr(); } @@ -287,10 +301,12 @@ SUNErrCode SUNDomEigEstimate_ArnI(SUNDomEigEstimator DEE, suncomplextype* dom_ei /* Reshape the Hessenberg matrix as an input vector for the LAPACK dgeev_ function */ sunindextype i, j, k = 0; - for (i = 0; i < n; i++) { - for (j = 0; j < n; j++) { - ArnI_CONTENT(DEE)->LAPACK_A[k] = ArnI_CONTENT(DEE)->Hes[i][j]; - k++; + for (i = 0; i < n; i++) + { + for (j = 0; j < n; j++) + { + ArnI_CONTENT(DEE)->LAPACK_A[k] = ArnI_CONTENT(DEE)->Hes[i][j]; + k++; } } @@ -301,27 +317,32 @@ SUNErrCode SUNDomEigEstimate_ArnI(SUNDomEigEstimator DEE, suncomplextype* dom_ei char jobvr = 'N'; // Do not compute right eigenvectors /* Call LAPACK's dgeev function */ - dgeev_(&jobvl, &jobvr, &n, ArnI_CONTENT(DEE)->LAPACK_A, &lda, ArnI_CONTENT(DEE)->LAPACK_wr, ArnI_CONTENT(DEE)->LAPACK_wi, NULL, &ldvl, NULL, &ldvr, ArnI_CONTENT(DEE)->LAPACK_work, &lwork, &info); + dgeev_(&jobvl, &jobvr, &n, ArnI_CONTENT(DEE)->LAPACK_A, &lda, + ArnI_CONTENT(DEE)->LAPACK_wr, ArnI_CONTENT(DEE)->LAPACK_wi, NULL, + &ldvl, NULL, &ldvr, ArnI_CONTENT(DEE)->LAPACK_work, &lwork, &info); - if (info != 0) { - printf(SUNDOMEIGEST_LAPACK_FAIL, info); + if (info != 0) + { + printf(SUNDOMEIGEST_LAPACK_FAIL, info); - return SUN_ERR_DOMEIG_LAPACK_FAIL; + return SUN_ERR_DOMEIG_LAPACK_FAIL; } /* order the eigenvalues by their magnitude */ - for (i = 0; i < n; i++) { - ArnI_CONTENT(DEE)->LAPACK_arr[i].real = ArnI_CONTENT(DEE)->LAPACK_wr[i]; - ArnI_CONTENT(DEE)->LAPACK_arr[i].imag = ArnI_CONTENT(DEE)->LAPACK_wi[i]; + for (i = 0; i < n; i++) + { + ArnI_CONTENT(DEE)->LAPACK_arr[i].real = ArnI_CONTENT(DEE)->LAPACK_wr[i]; + ArnI_CONTENT(DEE)->LAPACK_arr[i].imag = ArnI_CONTENT(DEE)->LAPACK_wi[i]; } /* Sort the array using qsort */ qsort(ArnI_CONTENT(DEE)->LAPACK_arr, n, sizeof(suncomplextype), domeig_Compare); /* Update the original arrays */ - for (i = 0; i < n; i++) { - ArnI_CONTENT(DEE)->LAPACK_wr[i] = ArnI_CONTENT(DEE)->LAPACK_arr[i].real; - ArnI_CONTENT(DEE)->LAPACK_wi[i] = ArnI_CONTENT(DEE)->LAPACK_arr[i].imag; + for (i = 0; i < n; i++) + { + ArnI_CONTENT(DEE)->LAPACK_wr[i] = ArnI_CONTENT(DEE)->LAPACK_arr[i].real; + ArnI_CONTENT(DEE)->LAPACK_wi[i] = ArnI_CONTENT(DEE)->LAPACK_arr[i].imag; } // alternatively we can return a vector of all computed dom_eigs (up to maxl) @@ -395,15 +416,17 @@ SUNErrCode SUNDomEigEstFree_ArnI(SUNDomEigEstimator DEE) } // Function to calculate the magnitude of a suncomplextype number -sunrealtype domeig_Magnitude(const suncomplextype *c) { - return sqrt(c->real * c->real + c->imag * c->imag); +sunrealtype domeig_Magnitude(const suncomplextype* c) +{ + return sqrt(c->real * c->real + c->imag * c->imag); } // Comparison function for qsort -sunindextype domeig_Compare(const void *a, const void *b) { - const suncomplextype *c1 = (const suncomplextype *)a; - const suncomplextype *c2 = (const suncomplextype *)b; - sunrealtype mag1 = domeig_Magnitude(c1); - sunrealtype mag2 = domeig_Magnitude(c2); - return (mag2 > mag1) - (mag2 < mag1); // Descending order +sunindextype domeig_Compare(const void* a, const void* b) +{ + const suncomplextype* c1 = (const suncomplextype*)a; + const suncomplextype* c2 = (const suncomplextype*)b; + sunrealtype mag1 = domeig_Magnitude(c1); + sunrealtype mag2 = domeig_Magnitude(c2); + return (mag2 > mag1) - (mag2 < mag1); // Descending order } \ No newline at end of file diff --git a/src/sundomeigest/CMakeLists.txt b/src/sundomeigest/CMakeLists.txt index 1d3df2489e..70b79b6399 100644 --- a/src/sundomeigest/CMakeLists.txt +++ b/src/sundomeigest/CMakeLists.txt @@ -19,4 +19,4 @@ add_subdirectory(PI) if(ENABLE_LAPACK) add_subdirectory(ArnI) -endif() \ No newline at end of file +endif() diff --git a/src/sundomeigest/PI/sundomeigest_pi.c b/src/sundomeigest/PI/sundomeigest_pi.c index dde75f4b5f..5699f427d8 100644 --- a/src/sundomeigest/PI/sundomeigest_pi.c +++ b/src/sundomeigest/PI/sundomeigest_pi.c @@ -16,13 +16,13 @@ * ----------------------------------------------------------------- */ - #include +#include #include +#include #include #include #include -#include #include "sundials_logger_impl.h" #include "sundials_macros.h" @@ -36,7 +36,7 @@ * ----------------------------------------------------------------- */ -#define PI_CONTENT(DEE) ((SUNDomEigEstimatorContent_PI)(DEE->content)) +#define PI_CONTENT(DEE) ((SUNDomEigEstimatorContent_PI)(DEE->content)) /* * ----------------------------------------------------------------- @@ -48,7 +48,8 @@ * Function to create a new PI estimator */ -SUNDomEigEstimator SUNDomEigEst_PI(N_Vector q, sunindextype max_powiter, SUNContext sunctx) +SUNDomEigEstimator SUNDomEigEst_PI(N_Vector q, sunindextype max_powiter, + SUNContext sunctx) { SUNFunctionBegin(sunctx); SUNDomEigEstimator DEE; @@ -56,17 +57,17 @@ SUNDomEigEstimator SUNDomEigEst_PI(N_Vector q, sunindextype max_powiter, SUNCont /* check for legal q; if illegal return NULL */ // TO DO: check required vector operations - SUNAssert(!( - (q->ops->nvclone == NULL) || (q->ops->nvdestroy == NULL) || - (q->ops->nvdotprod == NULL) || (q->ops->nvscale == NULL) || - (q->ops->nvgetlength == NULL) || (q->ops->nvspace == NULL)), SUN_ERR_DOMEIG_BAD_NVECTOR); + SUNAssert(!((q->ops->nvclone == NULL) || (q->ops->nvdestroy == NULL) || + (q->ops->nvdotprod == NULL) || (q->ops->nvscale == NULL) || + (q->ops->nvgetlength == NULL) || (q->ops->nvspace == NULL)), + SUN_ERR_DOMEIG_BAD_NVECTOR); /* check for max_powiter values; if illegal use defaults */ if (max_powiter <= 0) { max_powiter = SUNDOMEIGEST_MAX_PI_DEFAULT; } /* Create dominant eigenvalue estimator */ DEE = NULL; - DEE = SUNDomEigEstNewEmpty (sunctx); + DEE = SUNDomEigEstNewEmpty(sunctx); SUNCheckLastErrNull(); /* Attach operations */ @@ -90,15 +91,15 @@ SUNDomEigEstimator SUNDomEigEst_PI(N_Vector q, sunindextype max_powiter, SUNCont DEE->content = content; /* Fill content */ - content->ATimes = NULL; - content->ATdata = NULL; - content->V = NULL; - content->q = NULL; - content->power_of_A = 0; - content->powiter_tol = ZERO; - content->resnorm = ZERO; - content->max_powiter = max_powiter; - content->numiters = 0; + content->ATimes = NULL; + content->ATdata = NULL; + content->V = NULL; + content->q = NULL; + content->power_of_A = 0; + content->powiter_tol = ZERO; + content->resnorm = ZERO; + content->max_powiter = max_powiter; + content->numiters = 0; /* Allocate content */ content->q = N_VClone(q); @@ -116,7 +117,8 @@ SUNDomEigEstimator SUNDomEigEst_PI(N_Vector q, sunindextype max_powiter, SUNCont * ----------------------------------------------------------------- */ -SUNDomEigEstimator_Type SUNDomEigEst_PIGetType(SUNDIALS_MAYBE_UNUSED SUNDomEigEstimator DEE) +SUNDomEigEstimator_Type SUNDomEigEst_PIGetType( + SUNDIALS_MAYBE_UNUSED SUNDomEigEstimator DEE) { return (SUNDOMEIG_POWER); } @@ -125,9 +127,18 @@ SUNErrCode SUNDomEigEstInitialize_PI(SUNDomEigEstimator DEE) { SUNFunctionBegin(DEE->sunctx); - if (PI_CONTENT(DEE)->powiter_tol <= 0) { PI_CONTENT(DEE)->powiter_tol = SUNDOMEIGEST_PI_TOL_DEFAULT; } - if (PI_CONTENT(DEE)->power_of_A <= 0) { PI_CONTENT(DEE)->power_of_A = SUNDOMEIGEST_PI_POWER_OF_A_DEFAULT; } - if (PI_CONTENT(DEE)->max_powiter <= 0) { PI_CONTENT(DEE)->max_powiter = SUNDOMEIGEST_MAX_PI_DEFAULT; } + if (PI_CONTENT(DEE)->powiter_tol <= 0) + { + PI_CONTENT(DEE)->powiter_tol = SUNDOMEIGEST_PI_TOL_DEFAULT; + } + if (PI_CONTENT(DEE)->power_of_A <= 0) + { + PI_CONTENT(DEE)->power_of_A = SUNDOMEIGEST_PI_POWER_OF_A_DEFAULT; + } + if (PI_CONTENT(DEE)->max_powiter <= 0) + { + PI_CONTENT(DEE)->max_powiter = SUNDOMEIGEST_MAX_PI_DEFAULT; + } SUNAssert(PI_CONTENT(DEE)->ATimes, SUN_ERR_ARG_CORRUPT); SUNAssert(PI_CONTENT(DEE)->V, SUN_ERR_ARG_CORRUPT); @@ -142,13 +153,14 @@ SUNErrCode SUNDomEigEstInitialize_PI(SUNDomEigEstimator DEE) normq = SUNRsqrt(normq); - N_VScale(ONE/normq, PI_CONTENT(DEE)->q, PI_CONTENT(DEE)->V); + N_VScale(ONE / normq, PI_CONTENT(DEE)->q, PI_CONTENT(DEE)->V); SUNCheckLastErrNull(); return SUN_SUCCESS; } -SUNErrCode SUNDomEigEstSetNumofPreProcess_PI(SUNDomEigEstimator DEE, sunindextype numofperprocess) +SUNErrCode SUNDomEigEstSetNumofPreProcess_PI(SUNDomEigEstimator DEE, + sunindextype numofperprocess) { SUNFunctionBegin(DEE->sunctx); @@ -157,7 +169,8 @@ SUNErrCode SUNDomEigEstSetNumofPreProcess_PI(SUNDomEigEstimator DEE, sunindextyp return SUN_SUCCESS; } -SUNErrCode SUNDomEigEstSetATimes_PI(SUNDomEigEstimator DEE, void* A_data, SUNATimesFn ATimes) +SUNErrCode SUNDomEigEstSetATimes_PI(SUNDomEigEstimator DEE, void* A_data, + SUNATimesFn ATimes) { SUNFunctionBegin(DEE->sunctx); @@ -168,7 +181,8 @@ SUNErrCode SUNDomEigEstSetATimes_PI(SUNDomEigEstimator DEE, void* A_data, SUNATi return SUN_SUCCESS; } -SUNErrCode SUNDomEigEst_PISetMaxPowerIter(SUNDomEigEstimator DEE, sunindextype max_powiter) +SUNErrCode SUNDomEigEst_PISetMaxPowerIter(SUNDomEigEstimator DEE, + sunindextype max_powiter) { SUNFunctionBegin(DEE->sunctx); @@ -192,25 +206,20 @@ SUNErrCode SUNDomEigEstPreProcess_PI(SUNDomEigEstimator DEE) sunindextype i, retval; /* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ - for(i = 0; i < PI_CONTENT(DEE)->power_of_A; i++) + for (i = 0; i < PI_CONTENT(DEE)->power_of_A; i++) { - retval = PI_CONTENT(DEE)->ATimes(PI_CONTENT(DEE)->ATdata, PI_CONTENT(DEE)->V, PI_CONTENT(DEE)->q); + retval = PI_CONTENT(DEE)->ATimes(PI_CONTENT(DEE)->ATdata, + PI_CONTENT(DEE)->V, PI_CONTENT(DEE)->q); if (retval != 0) { - if(retval < 0) - { - return SUN_ERR_DOMEIG_ATIMES_FAIL_UNREC; - } - else - { - return SUN_ERR_DOMEIG_ATIMES_FAIL_REC; - } + if (retval < 0) { return SUN_ERR_DOMEIG_ATIMES_FAIL_UNREC; } + else { return SUN_ERR_DOMEIG_ATIMES_FAIL_REC; } } normq = N_VDotProd(PI_CONTENT(DEE)->q, PI_CONTENT(DEE)->q); SUNCheckLastErr(); normq = SUNRsqrt(normq); - N_VScale(ONE/normq, PI_CONTENT(DEE)->q, PI_CONTENT(DEE)->V); + N_VScale(ONE / normq, PI_CONTENT(DEE)->q, PI_CONTENT(DEE)->V); SUNCheckLastErr(); } @@ -239,40 +248,33 @@ SUNErrCode SUNDomEigEstimate_PI(SUNDomEigEstimator DEE, suncomplextype* dom_eig) for (k = 0; k < PI_CONTENT(DEE)->max_powiter; k++) { - retval = PI_CONTENT(DEE)->ATimes(PI_CONTENT(DEE)->ATdata, PI_CONTENT(DEE)->V, PI_CONTENT(DEE)->q); + retval = PI_CONTENT(DEE)->ATimes(PI_CONTENT(DEE)->ATdata, + PI_CONTENT(DEE)->V, PI_CONTENT(DEE)->q); if (retval != 0) { - if(retval < 0) - { - return SUN_ERR_DOMEIG_ATIMES_FAIL_UNREC; - } - else - { - return SUN_ERR_DOMEIG_ATIMES_FAIL_REC; - } + if (retval < 0) { return SUN_ERR_DOMEIG_ATIMES_FAIL_UNREC; } + else { return SUN_ERR_DOMEIG_ATIMES_FAIL_REC; } } - dom_eig_new.real = N_VDotProd(PI_CONTENT(DEE)->V, PI_CONTENT(DEE)->q); //Rayleigh quotient + dom_eig_new.real = N_VDotProd(PI_CONTENT(DEE)->V, + PI_CONTENT(DEE)->q); //Rayleigh quotient SUNCheckLastErr(); PI_CONTENT(DEE)->resnorm = fabs(dom_eig_new.real - dom_eig_old.real); - if(PI_CONTENT(DEE)->resnorm < PI_CONTENT(DEE)->powiter_tol) - { - break; - } + if (PI_CONTENT(DEE)->resnorm < PI_CONTENT(DEE)->powiter_tol) { break; } normq = N_VDotProd(PI_CONTENT(DEE)->q, PI_CONTENT(DEE)->q); SUNCheckLastErr(); normq = SUNRsqrt(normq); - N_VScale(ONE/normq, PI_CONTENT(DEE)->q, PI_CONTENT(DEE)->V); + N_VScale(ONE / normq, PI_CONTENT(DEE)->q, PI_CONTENT(DEE)->V); SUNCheckLastErr(); dom_eig_old.real = dom_eig_new.real; } - *dom_eig = dom_eig_new; + *dom_eig = dom_eig_new; PI_CONTENT(DEE)->numiters = k; return SUN_SUCCESS; diff --git a/test/unit_tests/arkode/CXX_parallel/CMakeLists.txt b/test/unit_tests/arkode/CXX_parallel/CMakeLists.txt index a35b35ce70..ed8f8734ce 100644 --- a/test/unit_tests/arkode/CXX_parallel/CMakeLists.txt +++ b/test/unit_tests/arkode/CXX_parallel/CMakeLists.txt @@ -21,8 +21,7 @@ if(NOT SUNDIALS_PRECISION MATCHES "SINGLE") endif() # Add variable DOMEIG_OBJECT_LIBRARIES -set(DOMEIG_OBJECT_LIBRARIES - sundials_sundomeigestpi_obj) +set(DOMEIG_OBJECT_LIBRARIES sundials_sundomeigestpi_obj) if(ENABLE_LAPACK) list(APPEND DOMEIG_OBJECT_LIBRARIES sundials_sundomeigestarni_obj) @@ -59,11 +58,10 @@ foreach(test_tuple ${unit_tests}) ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/src) # libraries to link against - target_link_libraries(${test_target} MPI::MPI_CXX sundials_arkode - sundials_nvecparallel - ${DOMEIG_OBJECT_LIBRARIES} - ${EXE_EXTRA_LINK_LIBS} - PRIVATE ${LAPACK_LIBRARY}) + target_link_libraries( + ${test_target} MPI::MPI_CXX sundials_arkode sundials_nvecparallel + ${DOMEIG_OBJECT_LIBRARIES} ${EXE_EXTRA_LINK_LIBS} + PRIVATE ${LAPACK_LIBRARY}) endif() diff --git a/test/unit_tests/arkode/CXX_serial/CMakeLists.txt b/test/unit_tests/arkode/CXX_serial/CMakeLists.txt index b3880cc9e1..6aa903b69c 100644 --- a/test/unit_tests/arkode/CXX_serial/CMakeLists.txt +++ b/test/unit_tests/arkode/CXX_serial/CMakeLists.txt @@ -113,20 +113,20 @@ foreach(test_tuple ${unit_tests}) target_link_libraries( ${test_target} PRIVATE ${LAPACK_LIBRARY} - $ - sundials_sunmemsys_obj - sundials_nvecserial_obj - sundials_nvecmanyvector_obj - sundials_sunlinsolband_obj - sundials_sunlinsoldense_obj - sundials_sunnonlinsolnewton_obj - sundials_sunnonlinsolfixedpoint_obj - sundials_sunadaptcontrollerimexgus_obj - sundials_sunadaptcontrollersoderlind_obj - sundials_sunadaptcontrollermrihtol_obj - sundials_adjointcheckpointscheme_fixed_obj - ${DOMEIG_OBJECT_LIBRARIES} - ${EXE_EXTRA_LINK_LIBS}) + $ + sundials_sunmemsys_obj + sundials_nvecserial_obj + sundials_nvecmanyvector_obj + sundials_sunlinsolband_obj + sundials_sunlinsoldense_obj + sundials_sunnonlinsolnewton_obj + sundials_sunnonlinsolfixedpoint_obj + sundials_sunadaptcontrollerimexgus_obj + sundials_sunadaptcontrollersoderlind_obj + sundials_sunadaptcontrollermrihtol_obj + sundials_adjointcheckpointscheme_fixed_obj + ${DOMEIG_OBJECT_LIBRARIES} + ${EXE_EXTRA_LINK_LIBS}) # Tell CMake that we depend on the ARKODE library since it does not pick # that up from $. diff --git a/test/unit_tests/arkode/C_serial/CMakeLists.txt b/test/unit_tests/arkode/C_serial/CMakeLists.txt index 30979f1859..fc4fc05210 100644 --- a/test/unit_tests/arkode/C_serial/CMakeLists.txt +++ b/test/unit_tests/arkode/C_serial/CMakeLists.txt @@ -75,18 +75,18 @@ foreach(test_tuple ${ARKODE_unit_tests}) target_link_libraries( ${test} PRIVATE ${LAPACK_LIBRARY} - $ - sundials_sunmemsys_obj - sundials_nvecserial_obj - sundials_nvecmanyvector_obj - sundials_sunlinsolband_obj - sundials_sunlinsoldense_obj - sundials_sunnonlinsolnewton_obj - sundials_sunadaptcontrollerimexgus_obj - sundials_sunadaptcontrollersoderlind_obj - sundials_adjointcheckpointscheme_fixed_obj - ${DOMEIG_OBJECT_LIBRARIES} - ${EXE_EXTRA_LINK_LIBS}) + $ + sundials_sunmemsys_obj + sundials_nvecserial_obj + sundials_nvecmanyvector_obj + sundials_sunlinsolband_obj + sundials_sunlinsoldense_obj + sundials_sunnonlinsolnewton_obj + sundials_sunadaptcontrollerimexgus_obj + sundials_sunadaptcontrollersoderlind_obj + sundials_adjointcheckpointscheme_fixed_obj + ${DOMEIG_OBJECT_LIBRARIES} + ${EXE_EXTRA_LINK_LIBS}) # Tell CMake that we depend on the ARKODE library since it does not pick # that up from $. diff --git a/test/unit_tests/arkode/gtest/CMakeLists.txt b/test/unit_tests/arkode/gtest/CMakeLists.txt index 66423b368f..beeb5e98d5 100644 --- a/test/unit_tests/arkode/gtest/CMakeLists.txt +++ b/test/unit_tests/arkode/gtest/CMakeLists.txt @@ -30,7 +30,6 @@ if(ENABLE_LAPACK) endif() endif() - # We explicitly choose which object libraries to link to and link in the ARKODE # objects so that we have access to private functions w/o changing their # visibility in the installed libraries. diff --git a/test/unit_tests/nvector/test_nvector.c b/test/unit_tests/nvector/test_nvector.c index d60b16408c..62de41075e 100644 --- a/test/unit_tests/nvector/test_nvector.c +++ b/test/unit_tests/nvector/test_nvector.c @@ -5568,7 +5568,7 @@ int Test_N_VMinQuotientLocal(N_Vector NUM, N_Vector DENOM, int Test_N_VRandom(N_Vector X, int myid) { SUNErrCode ierr = SUN_SUCCESS; - int failure = 0; + int failure = 0; sunrealtype ymin, ymax; /* create vector for testing */ @@ -5589,35 +5589,38 @@ int Test_N_VRandom(N_Vector X, int myid) ymax = N_VMaxNorm(Y); if (ymin == ymax) { - printf(">>> FAILED test -- N_VRandom, Proc %d (ymin == ymax = %" FSYM ") \n", myid, ymin); + printf(">>> FAILED test -- N_VRandom, Proc %d (ymin == ymax = %" FSYM + ") \n", + myid, ymin); failure = 1; } if (ymin < ZERO) { - printf(">>> FAILED test -- N_VRandom, Proc %d (ymin = %" FSYM " < 0) \n", myid, ymin); + printf(">>> FAILED test -- N_VRandom, Proc %d (ymin = %" FSYM " < 0) \n", + myid, ymin); failure = 1; } if (ymin > ONE) { - printf(">>> FAILED test -- N_VRandom, Proc %d (ymin = %" FSYM " > 1) \n", myid, ymin); + printf(">>> FAILED test -- N_VRandom, Proc %d (ymin = %" FSYM " > 1) \n", + myid, ymin); failure = 1; } if (ymax < ZERO) { - printf(">>> FAILED test -- N_VRandom, Proc %d (ymax = %" FSYM " < 0) \n", myid, ymax); + printf(">>> FAILED test -- N_VRandom, Proc %d (ymax = %" FSYM " < 0) \n", + myid, ymax); failure = 1; } if (ymax > ONE) { - printf(">>> FAILED test -- N_VRandom, Proc %d (ymax = %" FSYM " > 1) \n", myid, ymax); + printf(">>> FAILED test -- N_VRandom, Proc %d (ymax = %" FSYM " > 1) \n", + myid, ymax); failure = 1; } } - if ((failure == 0) && (myid == 0)) - { - printf("PASSED test -- N_VRandom \n"); - } + if ((failure == 0) && (myid == 0)) { printf("PASSED test -- N_VRandom \n"); } N_VDestroy(Y); return (failure); diff --git a/test/unit_tests/sundials/CMakeLists.txt b/test/unit_tests/sundials/CMakeLists.txt index 6a6248ab0f..72d22f87db 100644 --- a/test/unit_tests/sundials/CMakeLists.txt +++ b/test/unit_tests/sundials/CMakeLists.txt @@ -33,4 +33,4 @@ if(TARGET GTest::gtest_main AND TARGET GTest::gmock) gtest_discover_tests(${test}) endforeach() -endif() \ No newline at end of file +endif() diff --git a/test/unit_tests/sundomeigest/CMakeLists.txt b/test/unit_tests/sundomeigest/CMakeLists.txt index b26da75905..a4dba1f6bd 100644 --- a/test/unit_tests/sundomeigest/CMakeLists.txt +++ b/test/unit_tests/sundomeigest/CMakeLists.txt @@ -34,7 +34,7 @@ if(BUILD_SHARED_LIBS) # need PIC when shared libs are used since the example executables will link # to the shared lib set_property(TARGET test_sundomeigest_obj PROPERTY POSITION_INDEPENDENT_CODE - TRUE) + TRUE) endif() target_link_libraries(test_sundomeigest_obj PRIVATE sundials_sundomeigestpi) @@ -44,7 +44,8 @@ if(ENABLE_LAPACK) if(BUILD_SHARED_LIBS) set_property(TARGET test_sundomeigest_obj PROPERTY POSITION_INDEPENDENT_CODE - TRUE) + TRUE) endif() - target_link_libraries(test_sundomeigest_obj PRIVATE sundials_sundomeigestpi sundials_sundomeigestarni) -endif() \ No newline at end of file + target_link_libraries(test_sundomeigest_obj PRIVATE sundials_sundomeigestpi + sundials_sundomeigestarni) +endif() diff --git a/test/unit_tests/sundomeigest/arni/CMakeLists.txt b/test/unit_tests/sundomeigest/arni/CMakeLists.txt index 7ff7bc1237..ed5ec0fda4 100644 --- a/test/unit_tests/sundomeigest/arni/CMakeLists.txt +++ b/test/unit_tests/sundomeigest/arni/CMakeLists.txt @@ -19,9 +19,9 @@ # Examples using SUNDIALS ArnI dominant eigenvalue estimator set(sundomeigest_arni_examples - "test_sundomeigest_arni\;100 10 10\;" - "test_sundomeigest_arni\;1000 10 10\;" - "test_sundomeigest_arni\;10000 10 10\;") + "test_sundomeigest_arni\;100 10 10\;" + "test_sundomeigest_arni\;1000 10 10\;" + "test_sundomeigest_arni\;10000 10 10\;") # Dependencies for dominant eigenvalue examples set(sundomeigest_arni_dependencies test_sundomeigest) @@ -102,7 +102,8 @@ if(EXAMPLES_INSTALL) # generate CMakelists.txt in the binary directory configure_file( ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_serial_C_ex.in - ${PROJECT_BINARY_DIR}/test/unit_tests/sundomeigest/arni/CMakeLists.txt @ONLY) + ${PROJECT_BINARY_DIR}/test/unit_tests/sundomeigest/arni/CMakeLists.txt + @ONLY) # install CMakelists.txt install( diff --git a/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c b/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c index dbfd0eacb0..76191f4d7e 100644 --- a/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c +++ b/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c @@ -39,19 +39,19 @@ #endif /* constants */ -#define ZERO SUN_RCONST(0.0) +#define ZERO SUN_RCONST(0.0) -#define factor (-100.0) -#define realpart (-30000.0) -#define imagpart (+40000.0) +#define factor (-100.0) +#define realpart (-30000.0) +#define imagpart (+40000.0) /* user data structure */ typedef struct { - sunindextype N; /* problem size */ - N_Vector d; /* matrix diagonal */ - sunrealtype real_part; /* nondiagonal entries of the matrix */ - sunrealtype imag_part; /* nondiagonal entries of the matrix */ + sunindextype N; /* problem size */ + N_Vector d; /* matrix diagonal */ + sunrealtype real_part; /* nondiagonal entries of the matrix */ + sunrealtype imag_part; /* nondiagonal entries of the matrix */ } UserData; /* private functions */ @@ -65,16 +65,15 @@ int check_vector(N_Vector X, N_Vector Y, sunrealtype tol); /* global copy of the problem size (for check_vector routine) */ sunindextype problem_size; - /* ---------------------------------------------------------------------- * DomEig Module Testing Routine * --------------------------------------------------------------------*/ int main(int argc, char* argv[]) { - int fails = 0; /* counter for test failures */ - int passfail = 0; /* overall pass/fail flag */ - N_Vector q; /* test vectors */ - UserData ProbData; /* problem data structure */ + int fails = 0; /* counter for test failures */ + int passfail = 0; /* overall pass/fail flag */ + N_Vector q; /* test vectors */ + UserData ProbData; /* problem data structure */ int maxl, failure, power_of_A; SUNContext sunctx; sunrealtype tolerans = 1.0e-2; @@ -104,15 +103,13 @@ int main(int argc, char* argv[]) maxl = atoi(argv[2]); if (maxl <= 0) { - printf( - "ERROR: Krylov subspace dimension must be a positive integer\n"); + printf("ERROR: Krylov subspace dimension must be a positive integer\n"); return 1; } power_of_A = atoi(argv[3]); if (power_of_A < 0) { - printf( - "ERROR: Number of preprocessing must be a nonnegative integer\n"); + printf("ERROR: Number of preprocessing must be a nonnegative integer\n"); return 1; } printf("\nDomEig module test:\n"); @@ -133,12 +130,9 @@ int main(int argc, char* argv[]) // real diag is factor*[3 4 5 ... N 0 0] // suncomplextype diag is [ realpart imagpart; // -imagpart realpart] - sunrealtype *v = N_VGetArrayPointer(ProbData.d); + sunrealtype* v = N_VGetArrayPointer(ProbData.d); int i, j; - for(i = 0; i < ProbData.N-2; i++) - { - v[i] = factor*(i + 3); - } + for (i = 0; i < ProbData.N - 2; i++) { v[i] = factor * (i + 3); } ProbData.real_part = realpart; ProbData.imag_part = imagpart; @@ -154,7 +148,7 @@ int main(int argc, char* argv[]) if (check_flag(&passfail, "setatimes", 1)) { return 1; } /* Set the number of preprocessings */ - if(DEE->ops->setnumofperprocess != NULL) + if (DEE->ops->setnumofperprocess != NULL) { passfail = DEE->ops->setnumofperprocess(DEE, power_of_A); if (check_flag(&passfail, "setnumofperprocess", 1)) { return 1; } @@ -177,39 +171,47 @@ int main(int argc, char* argv[]) passfail = DEE->ops->estimate(DEE, &dom_eig); if (check_flag(&passfail, "estimate", 1)) { return 1; } - sunrealtype norm_of_dom_eig = SUNRsqrt(dom_eig.real * dom_eig.real + dom_eig.imag * dom_eig.imag); - if(norm_of_dom_eig < SUN_SMALL_REAL) { + sunrealtype norm_of_dom_eig = + SUNRsqrt(dom_eig.real * dom_eig.real + dom_eig.imag * dom_eig.imag); + if (norm_of_dom_eig < SUN_SMALL_REAL) + { printf("FAIL: Dominant Eigenvalue Test Failed"); return 1; } suncomplextype true_dom_eig; /* Identify true_dom_eig based on given parameters*/ - if(SUNRsqrt(realpart * realpart + imagpart * imagpart) > -1.0 * factor * ProbData.N) + if (SUNRsqrt(realpart * realpart + imagpart * imagpart) > + -1.0 * factor * ProbData.N) { true_dom_eig.real = realpart; true_dom_eig.imag = imagpart; } else { - true_dom_eig.real = factor*ProbData.N; + true_dom_eig.real = factor * ProbData.N; true_dom_eig.imag = ZERO; } - printf("\ncomputed dominant eigenvalue = %20.4lf + %20.4lfi\n", dom_eig.real, dom_eig.imag); - printf(" true dominant eigenvalue = %20.4lf + %20.4lfi\n", true_dom_eig.real, true_dom_eig.imag); + printf("\ncomputed dominant eigenvalue = %20.4lf + %20.4lfi\n", dom_eig.real, + dom_eig.imag); + printf(" true dominant eigenvalue = %20.4lf + %20.4lfi\n", + true_dom_eig.real, true_dom_eig.imag); /* Compare the estimated dom_eig with true_dom_eig*/ - sunrealtype error = SUNRsqrt((dom_eig.real - true_dom_eig.real) * (dom_eig.real - true_dom_eig.real) - + (dom_eig.imag - true_dom_eig.imag) * (dom_eig.imag - true_dom_eig.imag)); + sunrealtype error = SUNRsqrt( + (dom_eig.real - true_dom_eig.real) * (dom_eig.real - true_dom_eig.real) + + (dom_eig.imag - true_dom_eig.imag) * (dom_eig.imag - true_dom_eig.imag)); error /= norm_of_dom_eig; - if(error < tolerans) { + if (error < tolerans) + { printf("\n\nPASS: relative error = %lf\n", error); return 0; } - else { + else + { printf("\n\nFAIL: relative error = %lf\n", error); return 0; } @@ -241,17 +243,14 @@ int ATimes(void* Data, N_Vector v_vec, N_Vector z_vec) if (check_flag(v, "N_VGetArrayPointer", 0)) { return 1; } z = N_VGetArrayPointer(z_vec); if (check_flag(z, "N_VGetArrayPointer", 0)) { return 1; } - N = ProbData->N; + N = ProbData->N; real_part = ProbData->real_part; imag_part = ProbData->imag_part; - diag = N_VGetArrayPointer(ProbData->d); + diag = N_VGetArrayPointer(ProbData->d); if (check_flag(diag, "N_VGetArrayPointer", 0)) { return 1; } /* perform product on the diagonal part of the matrix */ - for (i = 0; i < N - 2; i++) - { - z[i] = diag[i] * v[i]; - } + for (i = 0; i < N - 2; i++) { z[i] = diag[i] * v[i]; } /* perform product at the non-diagonal last two rows */ z[N - 2] = v[N - 2] * real_part + v[N - 1] * imag_part; diff --git a/test/unit_tests/sundomeigest/pi/CMakeLists.txt b/test/unit_tests/sundomeigest/pi/CMakeLists.txt index dbb0283abc..fb5e09b360 100644 --- a/test/unit_tests/sundomeigest/pi/CMakeLists.txt +++ b/test/unit_tests/sundomeigest/pi/CMakeLists.txt @@ -19,9 +19,8 @@ # Examples using SUNDIALS PI dominant eigenvalue estimator set(sundomeigest_pi_examples - "test_sundomeigest_pi\;100 10 10\;" - "test_sundomeigest_pi\;1000 10 10\;" - "test_sundomeigest_pi\;10000 10 10\;") + "test_sundomeigest_pi\;100 10 10\;" "test_sundomeigest_pi\;1000 10 10\;" + "test_sundomeigest_pi\;10000 10 10\;") # Dependencies for dominant eigenvalue examples set(sundomeigest_pi_dependencies test_sundomeigest) diff --git a/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c b/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c index 790db245f3..150af3091c 100644 --- a/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c +++ b/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c @@ -39,19 +39,19 @@ #endif /* constants */ -#define ZERO SUN_RCONST(0.0) +#define ZERO SUN_RCONST(0.0) -#define factor (-100.0) -#define realpart (-30000.0) -#define imagpart (0.0) +#define factor (-100.0) +#define realpart (-30000.0) +#define imagpart (0.0) /* user data structure */ typedef struct { - sunindextype N; /* problem size */ - N_Vector d; /* matrix diagonal */ - sunrealtype real_part; /* nondiagonal entries of the matrix */ - sunrealtype imag_part; /* nondiagonal entries of the matrix */ + sunindextype N; /* problem size */ + N_Vector d; /* matrix diagonal */ + sunrealtype real_part; /* nondiagonal entries of the matrix */ + sunrealtype imag_part; /* nondiagonal entries of the matrix */ } UserData; /* private functions */ @@ -65,16 +65,15 @@ int check_vector(N_Vector X, N_Vector Y, sunrealtype tol); /* global copy of the problem size (for check_vector routine) */ sunindextype problem_size; - /* ---------------------------------------------------------------------- * DomEig Module Testing Routine * --------------------------------------------------------------------*/ int main(int argc, char* argv[]) { - int fails = 0; /* counter for test failures */ - int passfail = 0; /* overall pass/fail flag */ - N_Vector q; /* test vectors */ - UserData ProbData; /* problem data structure */ + int fails = 0; /* counter for test failures */ + int passfail = 0; /* overall pass/fail flag */ + N_Vector q; /* test vectors */ + UserData ProbData; /* problem data structure */ int maxl, failure, power_of_A; SUNContext sunctx; sunrealtype tolerans = 1.0e-2; @@ -104,15 +103,13 @@ int main(int argc, char* argv[]) maxl = atoi(argv[2]); if (maxl <= 0) { - printf( - "ERROR: Krylov subspace dimension must be a positive integer\n"); + printf("ERROR: Krylov subspace dimension must be a positive integer\n"); return 1; } power_of_A = atoi(argv[3]); if (power_of_A < 0) { - printf( - "ERROR: Number of preprocessing must be a nonnegative integer\n"); + printf("ERROR: Number of preprocessing must be a nonnegative integer\n"); return 1; } printf("\nDomEig module test:\n"); @@ -133,12 +130,9 @@ int main(int argc, char* argv[]) // real diag is factor*[3 4 5 ... N 0 0] // suncomplextype diag is [ realpart imagpart; // -imagpart realpart] - sunrealtype *v = N_VGetArrayPointer(ProbData.d); + sunrealtype* v = N_VGetArrayPointer(ProbData.d); int i, j; - for(i = 0; i < ProbData.N-2; i++) - { - v[i] = factor*(i + 3); - } + for (i = 0; i < ProbData.N - 2; i++) { v[i] = factor * (i + 3); } ProbData.real_part = realpart; ProbData.imag_part = imagpart; @@ -154,7 +148,7 @@ int main(int argc, char* argv[]) if (check_flag(&passfail, "setatimes", 1)) { return 1; } /* Set the number of preprocessings */ - if(DEE->ops->setnumofperprocess != NULL) + if (DEE->ops->setnumofperprocess != NULL) { passfail = DEE->ops->setnumofperprocess(DEE, power_of_A); if (check_flag(&passfail, "setnumofperprocess", 1)) { return 1; } @@ -173,39 +167,47 @@ int main(int argc, char* argv[]) passfail = DEE->ops->estimate(DEE, &dom_eig); if (check_flag(&passfail, "estimate", 1)) { return 1; } - sunrealtype norm_of_dom_eig = SUNRsqrt(dom_eig.real * dom_eig.real + dom_eig.imag * dom_eig.imag); - if(norm_of_dom_eig < SUN_SMALL_REAL) { + sunrealtype norm_of_dom_eig = + SUNRsqrt(dom_eig.real * dom_eig.real + dom_eig.imag * dom_eig.imag); + if (norm_of_dom_eig < SUN_SMALL_REAL) + { printf("FAIL: Dominant Eigenvalue Test Failed"); return 1; } suncomplextype true_dom_eig; /* Identify true_dom_eig based on given parameters*/ - if(SUNRsqrt(realpart * realpart + imagpart * imagpart) > -1.0 * factor * ProbData.N) + if (SUNRsqrt(realpart * realpart + imagpart * imagpart) > + -1.0 * factor * ProbData.N) { true_dom_eig.real = realpart; true_dom_eig.imag = imagpart; } else { - true_dom_eig.real = factor*ProbData.N; + true_dom_eig.real = factor * ProbData.N; true_dom_eig.imag = ZERO; } - printf("\ncomputed dominant eigenvalue = %20.4lf + %20.4lfi\n", dom_eig.real, dom_eig.imag); - printf(" true dominant eigenvalue = %20.4lf + %20.4lfi\n", true_dom_eig.real, true_dom_eig.imag); + printf("\ncomputed dominant eigenvalue = %20.4lf + %20.4lfi\n", dom_eig.real, + dom_eig.imag); + printf(" true dominant eigenvalue = %20.4lf + %20.4lfi\n", + true_dom_eig.real, true_dom_eig.imag); /* Compare the estimated dom_eig with true_dom_eig*/ - sunrealtype error = SUNRsqrt((dom_eig.real - true_dom_eig.real) * (dom_eig.real - true_dom_eig.real) - + (dom_eig.imag - true_dom_eig.imag) * (dom_eig.imag - true_dom_eig.imag)); + sunrealtype error = SUNRsqrt( + (dom_eig.real - true_dom_eig.real) * (dom_eig.real - true_dom_eig.real) + + (dom_eig.imag - true_dom_eig.imag) * (dom_eig.imag - true_dom_eig.imag)); error /= norm_of_dom_eig; - if(error < tolerans) { + if (error < tolerans) + { printf("\n\nPASS: relative error = %lf\n", error); return 0; } - else { + else + { printf("\n\nFAIL: relative error = %lf\n", error); return 0; } @@ -237,17 +239,14 @@ int ATimes(void* Data, N_Vector v_vec, N_Vector z_vec) if (check_flag(v, "N_VGetArrayPointer", 0)) { return 1; } z = N_VGetArrayPointer(z_vec); if (check_flag(z, "N_VGetArrayPointer", 0)) { return 1; } - N = ProbData->N; + N = ProbData->N; real_part = ProbData->real_part; imag_part = ProbData->imag_part; - diag = N_VGetArrayPointer(ProbData->d); + diag = N_VGetArrayPointer(ProbData->d); if (check_flag(diag, "N_VGetArrayPointer", 0)) { return 1; } /* perform product on the diagonal part of the matrix */ - for (i = 0; i < N - 2; i++) - { - z[i] = diag[i] * v[i]; - } + for (i = 0; i < N - 2; i++) { z[i] = diag[i] * v[i]; } /* perform product at the non-diagonal last two rows */ z[N - 2] = v[N - 2] * real_part + v[N - 1] * imag_part; diff --git a/test/unit_tests/sundomeigest/test_sundomeigest.c b/test/unit_tests/sundomeigest/test_sundomeigest.c index c31f756849..a50ae918ee 100644 --- a/test/unit_tests/sundomeigest/test_sundomeigest.c +++ b/test/unit_tests/sundomeigest/test_sundomeigest.c @@ -42,8 +42,8 @@ int print_time = 0; /* ---------------------------------------------------------------------- * SUNDomEigEstGetType Test * --------------------------------------------------------------------*/ -int Test_SUNDomEigEstGetType(SUNDomEigEstimator DEE, SUNLinearSolver_Type suntype, - int myid) +int Test_SUNDomEigEstGetType(SUNDomEigEstimator DEE, + SUNLinearSolver_Type suntype, int myid) { double start_time, stop_time; SUNLinearSolver_Type mysuntype; @@ -73,8 +73,8 @@ int Test_SUNDomEigEstGetType(SUNDomEigEstimator DEE, SUNLinearSolver_Type suntyp /* ---------------------------------------------------------------------- * SUNDomEigEstSetATimes Test * --------------------------------------------------------------------*/ -int Test_SUNDomEigEstSetATimes(SUNDomEigEstimator DEE, void* ATdata, SUNATimesFn ATimes, - int myid) +int Test_SUNDomEigEstSetATimes(SUNDomEigEstimator DEE, void* ATdata, + SUNATimesFn ATimes, int myid) { int failure; double start_time, stop_time; @@ -150,11 +150,7 @@ int Test_SUNDomEigEstComputeHess(SUNDomEigEstimator DEE, int myid) /* ---------------------------------------------------------------------- * SUNDomEigEstimate Test * --------------------------------------------------------------------*/ -int Test_SUNDomEigEstimate(SUNDomEigEstimator DEE, int myid) -{ - return (0); -} - +int Test_SUNDomEigEstimate(SUNDomEigEstimator DEE, int myid) { return (0); } /* ====================================================================== * Private functions diff --git a/test/unit_tests/sundomeigest/test_sundomeigest.h b/test/unit_tests/sundomeigest/test_sundomeigest.h index 9c57e063ce..583b49f3b0 100644 --- a/test/unit_tests/sundomeigest/test_sundomeigest.h +++ b/test/unit_tests/sundomeigest/test_sundomeigest.h @@ -32,10 +32,10 @@ int check_vector(N_Vector expected, N_Vector computed, sunrealtype tol); // void sync_device(void); /* Test function declarations */ -int Test_SUNDomEigEstGetType(SUNDomEigEstimator DEE, SUNLinearSolver_Type suntype, - int myid); -int Test_SUNDomEigEstSetATimes(SUNDomEigEstimator DEE, void* ATdata, SUNATimesFn ATimes, - int myid); +int Test_SUNDomEigEstGetType(SUNDomEigEstimator DEE, + SUNLinearSolver_Type suntype, int myid); +int Test_SUNDomEigEstSetATimes(SUNDomEigEstimator DEE, void* ATdata, + SUNATimesFn ATimes, int myid); int Test_SUNDomEigEstInitialize(SUNDomEigEstimator DEE, int myid); int Test_SUNDomEigEstPreProcess(SUNDomEigEstimator DEE, int myid); int Test_SUNDomEigEstComputeHess(SUNDomEigEstimator DEE, int myid); From 6015f059093fc26aa21de1361df39bf2f8680629 Mon Sep 17 00:00:00 2001 From: maggul Date: Mon, 9 Jun 2025 15:34:43 -0500 Subject: [PATCH 031/128] CI debugs --- include/sundials/sundials_domeigestimator.h | 8 ++++---- src/sundomeigest/ArnI/sundomeigest_arni.c | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/sundials/sundials_domeigestimator.h b/include/sundials/sundials_domeigestimator.h index fc268ea545..96d49d07fe 100644 --- a/include/sundials/sundials_domeigestimator.h +++ b/include/sundials/sundials_domeigestimator.h @@ -62,13 +62,13 @@ struct _generic_SUNDomEigEstimator_Ops { SUNDomEigEstimator_Type (*gettype)(SUNDomEigEstimator); SUNErrCode (*setatimes)(SUNDomEigEstimator, void*, SUNATimesFn); - SUNErrCode (*setmaxpoweriter)(SUNDomEigEstimator, int); - SUNErrCode (*setnumofperprocess)(SUNDomEigEstimator, int); + SUNErrCode (*setmaxpoweriter)(SUNDomEigEstimator, sunindextype); + SUNErrCode (*setnumofperprocess)(SUNDomEigEstimator, sunindextype); SUNErrCode (*initialize)(SUNDomEigEstimator); SUNErrCode (*preprocess)(SUNDomEigEstimator); SUNErrCode (*computehess)(SUNDomEigEstimator); SUNErrCode (*estimate)(SUNDomEigEstimator, suncomplextype*); - int (*getnumofiters)(SUNDomEigEstimator); + sunindextype (*getnumofiters)(SUNDomEigEstimator); SUNErrCode (*free)(SUNDomEigEstimator); }; @@ -115,4 +115,4 @@ SUNErrCode SUNDomEigEstimate(SUNDomEigEstimator DEE, suncomplextype* dom_eig); } #endif -#endif \ No newline at end of file +#endif diff --git a/src/sundomeigest/ArnI/sundomeigest_arni.c b/src/sundomeigest/ArnI/sundomeigest_arni.c index 4dcd709569..6f300e13eb 100644 --- a/src/sundomeigest/ArnI/sundomeigest_arni.c +++ b/src/sundomeigest/ArnI/sundomeigest_arni.c @@ -155,7 +155,7 @@ SUNErrCode SUNDomEigEstInitialize_ArnI(SUNDomEigEstimator DEE) (suncomplextype*)malloc(ArnI_CONTENT(DEE)->maxl * sizeof(suncomplextype)); N_VRandom(ArnI_CONTENT(DEE)->q); - SUNCheckLastErrNull(); + SUNCheckLastErr(); /* Hessenberg matrix Hes */ if (ArnI_CONTENT(DEE)->Hes == NULL) @@ -174,12 +174,12 @@ SUNErrCode SUNDomEigEstInitialize_ArnI(SUNDomEigEstimator DEE) /* Initialize the vector V[0] */ sunrealtype normq = N_VDotProd(ArnI_CONTENT(DEE)->q, ArnI_CONTENT(DEE)->q); - SUNCheckLastErrNull(); + SUNCheckLastErr(); normq = SUNRsqrt(normq); N_VScale(ONE / normq, ArnI_CONTENT(DEE)->q, ArnI_CONTENT(DEE)->V[0]); - SUNCheckLastErrNull(); + SUNCheckLastErr(); return SUN_SUCCESS; } From 97ce4894d889a808465408f3a541296ac1d148a9 Mon Sep 17 00:00:00 2001 From: maggul Date: Mon, 9 Jun 2025 15:43:24 -0500 Subject: [PATCH 032/128] added newline at end of file --- src/sundials/sundials_domeigestimator.c | 2 +- src/sundomeigest/ArnI/sundomeigest_arni.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sundials/sundials_domeigestimator.c b/src/sundials/sundials_domeigestimator.c index e557d01042..8385518e9a 100644 --- a/src/sundials/sundials_domeigestimator.c +++ b/src/sundials/sundials_domeigestimator.c @@ -147,4 +147,4 @@ SUNErrCode SUNDomEigEstimate(SUNDomEigEstimator DEE, suncomplextype* dom_eig) else { ier = SUN_SUCCESS; } SUNDIALS_MARK_FUNCTION_END(getSUNProfiler(DEE)); return (ier); -} \ No newline at end of file +} diff --git a/src/sundomeigest/ArnI/sundomeigest_arni.c b/src/sundomeigest/ArnI/sundomeigest_arni.c index 6f300e13eb..3017a19833 100644 --- a/src/sundomeigest/ArnI/sundomeigest_arni.c +++ b/src/sundomeigest/ArnI/sundomeigest_arni.c @@ -429,4 +429,4 @@ sunindextype domeig_Compare(const void* a, const void* b) sunrealtype mag1 = domeig_Magnitude(c1); sunrealtype mag2 = domeig_Magnitude(c2); return (mag2 > mag1) - (mag2 < mag1); // Descending order -} \ No newline at end of file +} From 3ff8e8951582ca6db4bc5c537d9a474ce0b2ad75 Mon Sep 17 00:00:00 2001 From: maggul Date: Mon, 9 Jun 2025 16:13:18 -0500 Subject: [PATCH 033/128] CI debugs --- src/sundomeigest/ArnI/sundomeigest_arni.c | 4 ++-- src/sundomeigest/PI/sundomeigest_pi.c | 8 ++++---- test/unit_tests/arkode/CXX_parallel/CMakeLists.txt | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/sundomeigest/ArnI/sundomeigest_arni.c b/src/sundomeigest/ArnI/sundomeigest_arni.c index 3017a19833..74f0eda794 100644 --- a/src/sundomeigest/ArnI/sundomeigest_arni.c +++ b/src/sundomeigest/ArnI/sundomeigest_arni.c @@ -56,11 +56,11 @@ SUNDomEigEstimator SUNDomEigEst_ArnI(N_Vector q, sunindextype maxl, SUNDomEigEstimatorContent_ArnI content; /* Check if maxl >= 2 */ - SUNAssert(maxl >= 2, SUN_ERR_DOMEIG_NOT_ENOUGH_ITER); + SUNAssertNull(maxl >= 2, SUN_ERR_DOMEIG_NOT_ENOUGH_ITER); /* check for legal q; if illegal return NULL */ // TO DO: check required vector operations - SUNAssert(!((q->ops->nvclone == NULL) || (q->ops->nvdestroy == NULL) || + SUNAssertNull(!((q->ops->nvclone == NULL) || (q->ops->nvdestroy == NULL) || (q->ops->nvdotprod == NULL) || (q->ops->nvscale == NULL) || (q->ops->nvgetlength == NULL) || (q->ops->nvspace == NULL)), SUN_ERR_DOMEIG_BAD_NVECTOR); diff --git a/src/sundomeigest/PI/sundomeigest_pi.c b/src/sundomeigest/PI/sundomeigest_pi.c index 5699f427d8..9b352b73b9 100644 --- a/src/sundomeigest/PI/sundomeigest_pi.c +++ b/src/sundomeigest/PI/sundomeigest_pi.c @@ -57,7 +57,7 @@ SUNDomEigEstimator SUNDomEigEst_PI(N_Vector q, sunindextype max_powiter, /* check for legal q; if illegal return NULL */ // TO DO: check required vector operations - SUNAssert(!((q->ops->nvclone == NULL) || (q->ops->nvdestroy == NULL) || + SUNAssertNull(!((q->ops->nvclone == NULL) || (q->ops->nvdestroy == NULL) || (q->ops->nvdotprod == NULL) || (q->ops->nvscale == NULL) || (q->ops->nvgetlength == NULL) || (q->ops->nvspace == NULL)), SUN_ERR_DOMEIG_BAD_NVECTOR); @@ -145,16 +145,16 @@ SUNErrCode SUNDomEigEstInitialize_PI(SUNDomEigEstimator DEE) SUNAssert(PI_CONTENT(DEE)->q, SUN_ERR_ARG_CORRUPT); N_VRandom(PI_CONTENT(DEE)->q); - SUNCheckLastErrNull(); + SUNCheckLastErr(); /* Initialize the vector V */ sunrealtype normq = N_VDotProd(PI_CONTENT(DEE)->q, PI_CONTENT(DEE)->q); - SUNCheckLastErrNull(); + SUNCheckLastErr(); normq = SUNRsqrt(normq); N_VScale(ONE / normq, PI_CONTENT(DEE)->q, PI_CONTENT(DEE)->V); - SUNCheckLastErrNull(); + SUNCheckLastErr(); return SUN_SUCCESS; } diff --git a/test/unit_tests/arkode/CXX_parallel/CMakeLists.txt b/test/unit_tests/arkode/CXX_parallel/CMakeLists.txt index ed8f8734ce..af3fc5631c 100644 --- a/test/unit_tests/arkode/CXX_parallel/CMakeLists.txt +++ b/test/unit_tests/arkode/CXX_parallel/CMakeLists.txt @@ -61,7 +61,7 @@ foreach(test_tuple ${unit_tests}) target_link_libraries( ${test_target} MPI::MPI_CXX sundials_arkode sundials_nvecparallel ${DOMEIG_OBJECT_LIBRARIES} ${EXE_EXTRA_LINK_LIBS} - PRIVATE ${LAPACK_LIBRARY}) + ${LAPACK_LIBRARY}) endif() From 092114caf703863d90bf5385d829989707428496 Mon Sep 17 00:00:00 2001 From: maggul Date: Mon, 9 Jun 2025 17:31:48 -0500 Subject: [PATCH 034/128] CI debugs --- src/arkode/arkode_lsrkstep_io.c | 2 +- src/nvector/parhyp/nvector_parhyp.c | 2 +- src/sundomeigest/ArnI/sundomeigest_arni.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/arkode/arkode_lsrkstep_io.c b/src/arkode/arkode_lsrkstep_io.c index e9c87e5b3a..eff5c896b4 100644 --- a/src/arkode/arkode_lsrkstep_io.c +++ b/src/arkode/arkode_lsrkstep_io.c @@ -220,7 +220,7 @@ int LSRKStepSetDomEigFn(void* arkode_mem, ARKDomEigFn dom_eig) /* Set the default internal dominant eigenvalue estimator type */ if (step_mem->internal_domeigest_type != ARKODE_LSRK_ARNOLDI_ITERATION) { - step_mem->internal_domeigest_type == ARKODE_LSRK_POWER_ITERATION; + step_mem->internal_domeigest_type = ARKODE_LSRK_POWER_ITERATION; } /* Create an internal dominant eigenvalue estimator */ diff --git a/src/nvector/parhyp/nvector_parhyp.c b/src/nvector/parhyp/nvector_parhyp.c index 9affbe6482..4d2f3a786c 100644 --- a/src/nvector/parhyp/nvector_parhyp.c +++ b/src/nvector/parhyp/nvector_parhyp.c @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include diff --git a/src/sundomeigest/ArnI/sundomeigest_arni.c b/src/sundomeigest/ArnI/sundomeigest_arni.c index 74f0eda794..a55e4eff17 100644 --- a/src/sundomeigest/ArnI/sundomeigest_arni.c +++ b/src/sundomeigest/ArnI/sundomeigest_arni.c @@ -336,7 +336,7 @@ SUNErrCode SUNDomEigEstimate_ArnI(SUNDomEigEstimator DEE, suncomplextype* dom_ei } /* Sort the array using qsort */ - qsort(ArnI_CONTENT(DEE)->LAPACK_arr, n, sizeof(suncomplextype), domeig_Compare); + qsort(ArnI_CONTENT(DEE)->LAPACK_arr, n, sizeof(suncomplextype), (int)domeig_Compare); /* Update the original arrays */ for (i = 0; i < n; i++) From 77fca3897903ddc962e89385d615cd991e57d0d6 Mon Sep 17 00:00:00 2001 From: maggul Date: Mon, 9 Jun 2025 17:35:25 -0500 Subject: [PATCH 035/128] CI debugs --- src/arkode/arkode_lsrkstep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arkode/arkode_lsrkstep.c b/src/arkode/arkode_lsrkstep.c index 600387f5a8..2b22d5359f 100644 --- a/src/arkode/arkode_lsrkstep.c +++ b/src/arkode/arkode_lsrkstep.c @@ -2325,7 +2325,7 @@ SUNDomEigEstimator lsrkStep_DomEigCreate(void* arkode_mem) if (step_mem->internal_domeigest_type == ARKODE_LSRK_ARNOLDI_ITERATION && ark_mem->yn->ops->nvgetlength(ark_mem->yn) < 3) { - step_mem->internal_domeigest_type == ARKODE_LSRK_POWER_ITERATION; + step_mem->internal_domeigest_type = ARKODE_LSRK_POWER_ITERATION; } /* Create the internal DomEigEst */ From 8fdb8b0b55c1cbe6b3f1cdf2201ecf834550ea64 Mon Sep 17 00:00:00 2001 From: maggul Date: Mon, 9 Jun 2025 17:49:33 -0500 Subject: [PATCH 036/128] CI debugs --- .../sundials/priv/sundials_domeigestimator_impl.h | 2 +- src/sundomeigest/ArnI/sundomeigest_arni.c | 4 ++-- .../sundomeigest/arni/test_sundomeigest_arni.c | 13 +------------ .../sundomeigest/pi/test_sundomeigest_pi.c | 15 ++------------- 4 files changed, 6 insertions(+), 28 deletions(-) diff --git a/include/sundials/priv/sundials_domeigestimator_impl.h b/include/sundials/priv/sundials_domeigestimator_impl.h index 93c87a4d64..6cbce49ba6 100644 --- a/include/sundials/priv/sundials_domeigestimator_impl.h +++ b/include/sundials/priv/sundials_domeigestimator_impl.h @@ -31,7 +31,7 @@ extern "C" { SUNErrCode domeig_CheckNVector(N_Vector tmpl); sunrealtype domeig_Magnitude(const suncomplextype* c); -sunindextype domeig_Compare(const void* a, const void* b); +int domeig_Compare(const void* a, const void* b); /* * ----------------------------------------------------------------- diff --git a/src/sundomeigest/ArnI/sundomeigest_arni.c b/src/sundomeigest/ArnI/sundomeigest_arni.c index a55e4eff17..7cdebb1be4 100644 --- a/src/sundomeigest/ArnI/sundomeigest_arni.c +++ b/src/sundomeigest/ArnI/sundomeigest_arni.c @@ -336,7 +336,7 @@ SUNErrCode SUNDomEigEstimate_ArnI(SUNDomEigEstimator DEE, suncomplextype* dom_ei } /* Sort the array using qsort */ - qsort(ArnI_CONTENT(DEE)->LAPACK_arr, n, sizeof(suncomplextype), (int)domeig_Compare); + qsort(ArnI_CONTENT(DEE)->LAPACK_arr, n, sizeof(suncomplextype), domeig_Compare); /* Update the original arrays */ for (i = 0; i < n; i++) @@ -422,7 +422,7 @@ sunrealtype domeig_Magnitude(const suncomplextype* c) } // Comparison function for qsort -sunindextype domeig_Compare(const void* a, const void* b) +int domeig_Compare(const void* a, const void* b) { const suncomplextype* c1 = (const suncomplextype*)a; const suncomplextype* c2 = (const suncomplextype*)b; diff --git a/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c b/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c index 76191f4d7e..7a7a5dd7c4 100644 --- a/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c +++ b/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c @@ -28,16 +28,6 @@ #include "../test_sundomeigest.h" -#if defined(SUNDIALS_EXTENDED_PRECISION) -#define GSYM "Lg" -#define ESYM "Le" -#define FSYM "Lf" -#else -#define GSYM "g" -#define ESYM "e" -#define FSYM "f" -#endif - /* constants */ #define ZERO SUN_RCONST(0.0) @@ -70,11 +60,10 @@ sunindextype problem_size; * --------------------------------------------------------------------*/ int main(int argc, char* argv[]) { - int fails = 0; /* counter for test failures */ int passfail = 0; /* overall pass/fail flag */ N_Vector q; /* test vectors */ UserData ProbData; /* problem data structure */ - int maxl, failure, power_of_A; + int maxl, power_of_A; SUNContext sunctx; sunrealtype tolerans = 1.0e-2; diff --git a/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c b/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c index 150af3091c..341be8cfcc 100644 --- a/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c +++ b/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c @@ -28,16 +28,6 @@ #include "../test_sundomeigest.h" -#if defined(SUNDIALS_EXTENDED_PRECISION) -#define GSYM "Lg" -#define ESYM "Le" -#define FSYM "Lf" -#else -#define GSYM "g" -#define ESYM "e" -#define FSYM "f" -#endif - /* constants */ #define ZERO SUN_RCONST(0.0) @@ -70,11 +60,10 @@ sunindextype problem_size; * --------------------------------------------------------------------*/ int main(int argc, char* argv[]) { - int fails = 0; /* counter for test failures */ int passfail = 0; /* overall pass/fail flag */ N_Vector q; /* test vectors */ UserData ProbData; /* problem data structure */ - int maxl, failure, power_of_A; + int maxl, power_of_A; SUNContext sunctx; sunrealtype tolerans = 1.0e-2; @@ -131,7 +120,7 @@ int main(int argc, char* argv[]) // suncomplextype diag is [ realpart imagpart; // -imagpart realpart] sunrealtype* v = N_VGetArrayPointer(ProbData.d); - int i, j; + int i; for (i = 0; i < ProbData.N - 2; i++) { v[i] = factor * (i + 3); } ProbData.real_part = realpart; From 00320b8b700e2ab6a0f7efc443a96cb35a0bb2ae Mon Sep 17 00:00:00 2001 From: maggul Date: Mon, 9 Jun 2025 18:19:16 -0500 Subject: [PATCH 037/128] CI debugs --- src/nvector/parallel/nvector_parallel.c | 1 - src/nvector/parhyp/nvector_parhyp.c | 1 + .../unit_tests/sundomeigest/arni/test_sundomeigest_arni.c | 2 +- test/unit_tests/sundomeigest/test_sundomeigest.c | 8 ++++---- test/unit_tests/sundomeigest/test_sundomeigest.h | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/nvector/parallel/nvector_parallel.c b/src/nvector/parallel/nvector_parallel.c index 97e8170811..2659d58f2e 100644 --- a/src/nvector/parallel/nvector_parallel.c +++ b/src/nvector/parallel/nvector_parallel.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include "sundials_macros.h" diff --git a/src/nvector/parhyp/nvector_parhyp.c b/src/nvector/parhyp/nvector_parhyp.c index 4d2f3a786c..18045dcb3c 100644 --- a/src/nvector/parhyp/nvector_parhyp.c +++ b/src/nvector/parhyp/nvector_parhyp.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include diff --git a/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c b/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c index 7a7a5dd7c4..d8a0720bfd 100644 --- a/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c +++ b/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c @@ -120,7 +120,7 @@ int main(int argc, char* argv[]) // suncomplextype diag is [ realpart imagpart; // -imagpart realpart] sunrealtype* v = N_VGetArrayPointer(ProbData.d); - int i, j; + int i; for (i = 0; i < ProbData.N - 2; i++) { v[i] = factor * (i + 3); } ProbData.real_part = realpart; diff --git a/test/unit_tests/sundomeigest/test_sundomeigest.c b/test/unit_tests/sundomeigest/test_sundomeigest.c index a50ae918ee..3a24c963fa 100644 --- a/test/unit_tests/sundomeigest/test_sundomeigest.c +++ b/test/unit_tests/sundomeigest/test_sundomeigest.c @@ -43,17 +43,17 @@ int print_time = 0; * SUNDomEigEstGetType Test * --------------------------------------------------------------------*/ int Test_SUNDomEigEstGetType(SUNDomEigEstimator DEE, - SUNLinearSolver_Type suntype, int myid) + SUNDomEigEstimator_Type suntype, int myid) { double start_time, stop_time; - SUNLinearSolver_Type mysuntype; + SUNDomEigEstimator_Type myesttype; start_time = get_time(); - mysuntype = SUNDomEigEstGetType(DEE); + myesttype = SUNDomEigEstGetType(DEE); // sync_device(); stop_time = get_time(); - if (suntype != mysuntype) + if (suntype != myesttype) { printf(">>> FAILED test -- SUNDomEigEstGetType, Proc %d \n", myid); PRINT_TIME(" SUNDomEigEstGetType Time: %22.15e \n \n", diff --git a/test/unit_tests/sundomeigest/test_sundomeigest.h b/test/unit_tests/sundomeigest/test_sundomeigest.h index 583b49f3b0..cd4ca26916 100644 --- a/test/unit_tests/sundomeigest/test_sundomeigest.h +++ b/test/unit_tests/sundomeigest/test_sundomeigest.h @@ -33,7 +33,7 @@ int check_vector(N_Vector expected, N_Vector computed, sunrealtype tol); /* Test function declarations */ int Test_SUNDomEigEstGetType(SUNDomEigEstimator DEE, - SUNLinearSolver_Type suntype, int myid); + SUNDomEigEstimator_Type suntype, int myid); int Test_SUNDomEigEstSetATimes(SUNDomEigEstimator DEE, void* ATdata, SUNATimesFn ATimes, int myid); int Test_SUNDomEigEstInitialize(SUNDomEigEstimator DEE, int myid); From 6a420068c0791423468f0bfb86742904d3884d61 Mon Sep 17 00:00:00 2001 From: maggul Date: Mon, 9 Jun 2025 18:36:46 -0500 Subject: [PATCH 038/128] commenting out SUNCheckMPICallNull(MPI_Comm_rank(comm, &myid)) --- src/nvector/parhyp/nvector_parhyp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/nvector/parhyp/nvector_parhyp.c b/src/nvector/parhyp/nvector_parhyp.c index 18045dcb3c..99ecda3e57 100644 --- a/src/nvector/parhyp/nvector_parhyp.c +++ b/src/nvector/parhyp/nvector_parhyp.c @@ -237,7 +237,9 @@ N_Vector N_VNewEmpty_ParHyp(MPI_Comm comm, sunindextype local_length, content->x = NULL; /* Seed random number generator with MPI rank ID to ensure distinct streams */ - SUNCheckMPICallNull(MPI_Comm_rank(comm, &myid)); + // SUNCheckMPICallNull(MPI_Comm_rank(comm, &myid)); + // For some reason CI testing fails: complaining "sunctx_local_scope_" is not found + // TODO: Resolve this issue in the revision srand(myid + 1); return (v); From 7226d93fcff74d068bc33ef6a1f645fd24120c4f Mon Sep 17 00:00:00 2001 From: maggul Date: Mon, 9 Jun 2025 18:57:47 -0500 Subject: [PATCH 039/128] formatting and uncommenting MPI_Comm_rank(comm, &myid); without an error check --- src/nvector/parhyp/nvector_parhyp.c | 3 ++- src/sundomeigest/ArnI/sundomeigest_arni.c | 6 +++--- src/sundomeigest/PI/sundomeigest_pi.c | 6 +++--- test/unit_tests/arkode/CXX_parallel/CMakeLists.txt | 8 ++++++-- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/nvector/parhyp/nvector_parhyp.c b/src/nvector/parhyp/nvector_parhyp.c index 99ecda3e57..134b704955 100644 --- a/src/nvector/parhyp/nvector_parhyp.c +++ b/src/nvector/parhyp/nvector_parhyp.c @@ -24,9 +24,9 @@ #include #include #include -#include #include #include +#include #include "sundials_macros.h" @@ -238,6 +238,7 @@ N_Vector N_VNewEmpty_ParHyp(MPI_Comm comm, sunindextype local_length, /* Seed random number generator with MPI rank ID to ensure distinct streams */ // SUNCheckMPICallNull(MPI_Comm_rank(comm, &myid)); + MPI_Comm_rank(comm, &myid); // For some reason CI testing fails: complaining "sunctx_local_scope_" is not found // TODO: Resolve this issue in the revision srand(myid + 1); diff --git a/src/sundomeigest/ArnI/sundomeigest_arni.c b/src/sundomeigest/ArnI/sundomeigest_arni.c index 7cdebb1be4..c87b6ef0bc 100644 --- a/src/sundomeigest/ArnI/sundomeigest_arni.c +++ b/src/sundomeigest/ArnI/sundomeigest_arni.c @@ -61,9 +61,9 @@ SUNDomEigEstimator SUNDomEigEst_ArnI(N_Vector q, sunindextype maxl, /* check for legal q; if illegal return NULL */ // TO DO: check required vector operations SUNAssertNull(!((q->ops->nvclone == NULL) || (q->ops->nvdestroy == NULL) || - (q->ops->nvdotprod == NULL) || (q->ops->nvscale == NULL) || - (q->ops->nvgetlength == NULL) || (q->ops->nvspace == NULL)), - SUN_ERR_DOMEIG_BAD_NVECTOR); + (q->ops->nvdotprod == NULL) || (q->ops->nvscale == NULL) || + (q->ops->nvgetlength == NULL) || (q->ops->nvspace == NULL)), + SUN_ERR_DOMEIG_BAD_NVECTOR); /* Create dominant eigenvalue estimator */ DEE = NULL; diff --git a/src/sundomeigest/PI/sundomeigest_pi.c b/src/sundomeigest/PI/sundomeigest_pi.c index 9b352b73b9..bb5993d2a4 100644 --- a/src/sundomeigest/PI/sundomeigest_pi.c +++ b/src/sundomeigest/PI/sundomeigest_pi.c @@ -58,9 +58,9 @@ SUNDomEigEstimator SUNDomEigEst_PI(N_Vector q, sunindextype max_powiter, /* check for legal q; if illegal return NULL */ // TO DO: check required vector operations SUNAssertNull(!((q->ops->nvclone == NULL) || (q->ops->nvdestroy == NULL) || - (q->ops->nvdotprod == NULL) || (q->ops->nvscale == NULL) || - (q->ops->nvgetlength == NULL) || (q->ops->nvspace == NULL)), - SUN_ERR_DOMEIG_BAD_NVECTOR); + (q->ops->nvdotprod == NULL) || (q->ops->nvscale == NULL) || + (q->ops->nvgetlength == NULL) || (q->ops->nvspace == NULL)), + SUN_ERR_DOMEIG_BAD_NVECTOR); /* check for max_powiter values; if illegal use defaults */ if (max_powiter <= 0) { max_powiter = SUNDOMEIGEST_MAX_PI_DEFAULT; } diff --git a/test/unit_tests/arkode/CXX_parallel/CMakeLists.txt b/test/unit_tests/arkode/CXX_parallel/CMakeLists.txt index af3fc5631c..91ea4b6832 100644 --- a/test/unit_tests/arkode/CXX_parallel/CMakeLists.txt +++ b/test/unit_tests/arkode/CXX_parallel/CMakeLists.txt @@ -59,8 +59,12 @@ foreach(test_tuple ${unit_tests}) # libraries to link against target_link_libraries( - ${test_target} MPI::MPI_CXX sundials_arkode sundials_nvecparallel - ${DOMEIG_OBJECT_LIBRARIES} ${EXE_EXTRA_LINK_LIBS} + ${test_target} + MPI::MPI_CXX + sundials_arkode + sundials_nvecparallel + ${DOMEIG_OBJECT_LIBRARIES} + ${EXE_EXTRA_LINK_LIBS} ${LAPACK_LIBRARY}) endif() From d42471b3f5816c426e376b52b114180ad9fb354b Mon Sep 17 00:00:00 2001 From: maggul Date: Tue, 10 Jun 2025 13:38:01 -0500 Subject: [PATCH 040/128] resolved the issue with SUNCheckMPICallNull --- src/nvector/parhyp/nvector_parhyp.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/nvector/parhyp/nvector_parhyp.c b/src/nvector/parhyp/nvector_parhyp.c index 134b704955..e7d6bb15b4 100644 --- a/src/nvector/parhyp/nvector_parhyp.c +++ b/src/nvector/parhyp/nvector_parhyp.c @@ -22,11 +22,9 @@ #include #include -#include #include #include #include -#include #include "sundials_macros.h" @@ -153,6 +151,7 @@ N_Vector_ID N_VGetVectorID_ParHyp(SUNDIALS_MAYBE_UNUSED N_Vector v) N_Vector N_VNewEmpty_ParHyp(MPI_Comm comm, sunindextype local_length, sunindextype global_length, SUNContext sunctx) { + SUNFunctionBegin(sunctx); N_Vector v; N_VectorContent_ParHyp content; int myid; @@ -237,11 +236,8 @@ N_Vector N_VNewEmpty_ParHyp(MPI_Comm comm, sunindextype local_length, content->x = NULL; /* Seed random number generator with MPI rank ID to ensure distinct streams */ - // SUNCheckMPICallNull(MPI_Comm_rank(comm, &myid)); - MPI_Comm_rank(comm, &myid); - // For some reason CI testing fails: complaining "sunctx_local_scope_" is not found - // TODO: Resolve this issue in the revision - srand(myid + 1); + SUNCheckMPICallNull(MPI_Comm_rank(comm, &myid)); + srand(myid+1); return (v); } From 10369e784ed4c7f18782e9bbd162e9f9c0b4360f Mon Sep 17 00:00:00 2001 From: maggul Date: Tue, 10 Jun 2025 20:06:21 -0500 Subject: [PATCH 041/128] Arnoldi iteration unit test --- include/sundials/sundials_domeigestimator.h | 4 + include/sundomeigest/sundomeigest_arni.h | 2 +- include/sundomeigest/sundomeigest_pi.h | 2 +- src/arkode/arkode_lsrkstep.c | 4 +- src/arkode/arkode_lsrkstep_impl.h | 4 +- src/arkode/arkode_lsrkstep_io.c | 2 +- src/sundials/sundials_domeigestimator.c | 10 ++ src/sundomeigest/ArnI/sundomeigest_arni.c | 4 +- src/sundomeigest/PI/sundomeigest_pi.c | 4 +- .../arni/test_sundomeigest_arni.c | 154 +++++++++--------- .../sundomeigest/pi/test_sundomeigest_pi.c | 6 +- .../sundomeigest/test_sundomeigest.c | 103 +++++++++++- .../sundomeigest/test_sundomeigest.h | 4 +- 13 files changed, 205 insertions(+), 98 deletions(-) diff --git a/include/sundials/sundials_domeigestimator.h b/include/sundials/sundials_domeigestimator.h index 96d49d07fe..63eb21b807 100644 --- a/include/sundials/sundials_domeigestimator.h +++ b/include/sundials/sundials_domeigestimator.h @@ -99,6 +99,10 @@ SUNDIALS_EXPORT SUNErrCode SUNDomEigEstSetATimes(SUNDomEigEstimator DEE, void* A_data, SUNATimesFn ATimes); +SUNDIALS_EXPORT +SUNErrCode SUNDomEigEstSetNumPreProcess(SUNDomEigEstimator DEE, + sunindextype numofperprocess); + SUNDIALS_EXPORT SUNErrCode SUNDomEigEstInitialize(SUNDomEigEstimator DEE); diff --git a/include/sundomeigest/sundomeigest_arni.h b/include/sundomeigest/sundomeigest_arni.h index a665d76220..c73c63b4d7 100644 --- a/include/sundomeigest/sundomeigest_arni.h +++ b/include/sundomeigest/sundomeigest_arni.h @@ -79,7 +79,7 @@ SUNDIALS_EXPORT SUNErrCode SUNDomEigEstInitialize_ArnI(SUNDomEigEstimator DEE); SUNDIALS_EXPORT -SUNErrCode SUNDomEigEstSetNumofPreProcess_ArnI(SUNDomEigEstimator DEE, +SUNErrCode SUNDomEigEstSetNumPreProcess_ArnI(SUNDomEigEstimator DEE, sunindextype numofperprocess); SUNDIALS_EXPORT diff --git a/include/sundomeigest/sundomeigest_pi.h b/include/sundomeigest/sundomeigest_pi.h index 1c655d77a0..bf0120c58a 100644 --- a/include/sundomeigest/sundomeigest_pi.h +++ b/include/sundomeigest/sundomeigest_pi.h @@ -70,7 +70,7 @@ SUNDIALS_EXPORT SUNErrCode SUNDomEigEstInitialize_PI(SUNDomEigEstimator DEE); SUNDIALS_EXPORT -SUNErrCode SUNDomEigEstSetNumofPreProcess_PI(SUNDomEigEstimator DEE, +SUNErrCode SUNDomEigEstSetNumPreProcess_PI(SUNDomEigEstimator DEE, sunindextype numofperprocess); SUNDIALS_EXPORT diff --git a/src/arkode/arkode_lsrkstep.c b/src/arkode/arkode_lsrkstep.c index 2b22d5359f..f1da108b07 100644 --- a/src/arkode/arkode_lsrkstep.c +++ b/src/arkode/arkode_lsrkstep.c @@ -2317,7 +2317,7 @@ SUNDomEigEstimator lsrkStep_DomEigCreate(void* arkode_mem) /* Allocate and fill domeig_q vector with random data */ /* TODO: check if we have to clone or just passing yn is ok! */ step_mem->domeig_q = N_VClone(ark_mem->yn); - step_mem->domeig_maxl = DOMEIG_MAXL_DEFAULT; + step_mem->domeig_krydim = DOMEIG_KRYLOV_DIM_DEFAULT; step_mem->domeig_power_of_A = DOMEIG_POWER_OF_A_DEFAULT; step_mem->domeig_maxiters = DOMEIG_MAX_NUMBER_OF_POWER_ITERS_DEFAULT; @@ -2343,7 +2343,7 @@ SUNDomEigEstimator lsrkStep_DomEigCreate(void* arkode_mem) else if (step_mem->internal_domeigest_type == ARKODE_LSRK_ARNOLDI_ITERATION) { #ifdef SUNDIALS_BLAS_LAPACK_ENABLED - DEE = SUNDomEigEst_ArnI(step_mem->domeig_q, step_mem->domeig_maxl, + DEE = SUNDomEigEst_ArnI(step_mem->domeig_q, step_mem->domeig_krydim, ark_mem->sunctx); if (DEE == NULL) { diff --git a/src/arkode/arkode_lsrkstep_impl.h b/src/arkode/arkode_lsrkstep_impl.h index 506eb7177d..9ae4da5761 100644 --- a/src/arkode/arkode_lsrkstep_impl.h +++ b/src/arkode/arkode_lsrkstep_impl.h @@ -35,7 +35,7 @@ extern "C" { #define STAGE_MAX_LIMIT_DEFAULT 200 #define DOM_EIG_SAFETY_DEFAULT SUN_RCONST(1.01) #define DOM_EIG_FREQ_DEFAULT 25 -#define DOMEIG_MAXL_DEFAULT 3 +#define DOMEIG_KRYLOV_DIM_DEFAULT 3 #define DOMEIG_POWER_OF_A_DEFAULT 0 #define DOMEIG_MAX_NUMBER_OF_POWER_ITERS_DEFAULT 100 @@ -168,7 +168,7 @@ typedef struct ARKodeLSRKStepMemRec ARKODE_LSRKInternal_DomEigEst_Type internal_domeigest_type; /* Internal DomEig estimator type*/ SUNDomEigEstimator DEE; /* DomEig estimator*/ N_Vector domeig_q; /* DomEig initial q vector*/ - int domeig_maxl; /* Krylov subspace dimension */ + int domeig_krydim; /* Krylov subspace dimension */ int domeig_power_of_A; /* Power of A for the warm-up */ int domeig_maxiters; /* Max number of Power Iterations */ diff --git a/src/arkode/arkode_lsrkstep_io.c b/src/arkode/arkode_lsrkstep_io.c index eff5c896b4..23dd4d9ff9 100644 --- a/src/arkode/arkode_lsrkstep_io.c +++ b/src/arkode/arkode_lsrkstep_io.c @@ -580,7 +580,7 @@ int lsrkStep_SetDefaults(ARKodeMem ark_mem) step_mem->spectral_radius_min = ZERO; step_mem->dom_eig_safety = DOM_EIG_SAFETY_DEFAULT; step_mem->dom_eig_freq = DOM_EIG_FREQ_DEFAULT; - step_mem->domeig_maxl = DOMEIG_MAXL_DEFAULT; + step_mem->domeig_krydim = DOMEIG_KRYLOV_DIM_DEFAULT; step_mem->domeig_power_of_A = DOMEIG_POWER_OF_A_DEFAULT; /* Flags */ diff --git a/src/sundials/sundials_domeigestimator.c b/src/sundials/sundials_domeigestimator.c index 8385518e9a..be5477626c 100644 --- a/src/sundials/sundials_domeigestimator.c +++ b/src/sundials/sundials_domeigestimator.c @@ -109,6 +109,16 @@ SUNErrCode SUNDomEigEstSetATimes(SUNDomEigEstimator DEE, void* A_data, return (ier); } +SUNErrCode SUNDomEigEstSetNumPreProcess(SUNDomEigEstimator DEE, sunindextype numofperprocess) +{ + SUNErrCode ier; + SUNDIALS_MARK_FUNCTION_BEGIN(getSUNProfiler(DEE)); + if (DEE->ops->setnumofperprocess) { ier = DEE->ops->setnumofperprocess(DEE, numofperprocess); } + else { ier = SUN_SUCCESS; } + SUNDIALS_MARK_FUNCTION_END(getSUNProfiler(DEE)); + return (ier); +} + SUNErrCode SUNDomEigEstInitialize(SUNDomEigEstimator DEE) { SUNErrCode ier; diff --git a/src/sundomeigest/ArnI/sundomeigest_arni.c b/src/sundomeigest/ArnI/sundomeigest_arni.c index c87b6ef0bc..0385461d96 100644 --- a/src/sundomeigest/ArnI/sundomeigest_arni.c +++ b/src/sundomeigest/ArnI/sundomeigest_arni.c @@ -74,7 +74,7 @@ SUNDomEigEstimator SUNDomEigEst_ArnI(N_Vector q, sunindextype maxl, DEE->ops->gettype = SUNDomEigEst_ArnIGetType; DEE->ops->setatimes = SUNDomEigEstSetATimes_ArnI; DEE->ops->setmaxpoweriter = NULL; - DEE->ops->setnumofperprocess = SUNDomEigEstSetNumofPreProcess_ArnI; + DEE->ops->setnumofperprocess = SUNDomEigEstSetNumPreProcess_ArnI; DEE->ops->initialize = SUNDomEigEstInitialize_ArnI; DEE->ops->preprocess = SUNDomEigEstPreProcess_ArnI; DEE->ops->computehess = SUNDomEigEstComputeHess_ArnI; @@ -196,7 +196,7 @@ SUNErrCode SUNDomEigEstSetATimes_ArnI(SUNDomEigEstimator DEE, void* A_data, return SUN_SUCCESS; } -SUNErrCode SUNDomEigEstSetNumofPreProcess_ArnI(SUNDomEigEstimator DEE, +SUNErrCode SUNDomEigEstSetNumPreProcess_ArnI(SUNDomEigEstimator DEE, sunindextype numofperprocess) { SUNFunctionBegin(DEE->sunctx); diff --git a/src/sundomeigest/PI/sundomeigest_pi.c b/src/sundomeigest/PI/sundomeigest_pi.c index bb5993d2a4..d2279fd1ed 100644 --- a/src/sundomeigest/PI/sundomeigest_pi.c +++ b/src/sundomeigest/PI/sundomeigest_pi.c @@ -74,7 +74,7 @@ SUNDomEigEstimator SUNDomEigEst_PI(N_Vector q, sunindextype max_powiter, DEE->ops->gettype = SUNDomEigEst_PIGetType; DEE->ops->setatimes = SUNDomEigEstSetATimes_PI; DEE->ops->setmaxpoweriter = SUNDomEigEst_PISetMaxPowerIter; - DEE->ops->setnumofperprocess = SUNDomEigEstSetNumofPreProcess_PI; + DEE->ops->setnumofperprocess = SUNDomEigEstSetNumPreProcess_PI; DEE->ops->initialize = SUNDomEigEstInitialize_PI; DEE->ops->preprocess = SUNDomEigEstPreProcess_PI; DEE->ops->computehess = NULL; @@ -159,7 +159,7 @@ SUNErrCode SUNDomEigEstInitialize_PI(SUNDomEigEstimator DEE) return SUN_SUCCESS; } -SUNErrCode SUNDomEigEstSetNumofPreProcess_PI(SUNDomEigEstimator DEE, +SUNErrCode SUNDomEigEstSetNumPreProcess_PI(SUNDomEigEstimator DEE, sunindextype numofperprocess) { SUNFunctionBegin(DEE->sunctx); diff --git a/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c b/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c index d8a0720bfd..63d8c40d6f 100644 --- a/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c +++ b/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c @@ -11,19 +11,15 @@ * SPDX-License-Identifier: BSD-3-Clause * SUNDIALS Copyright End * ----------------------------------------------------------------- - * These test functions check some components of an DomEig iteration + * These test functions check some components of Arnoldi Iteration * module implementation. * ----------------------------------------------------------------- */ #include -#include #include -#include #include -#include -#include #include #include "../test_sundomeigest.h" @@ -39,9 +35,11 @@ typedef struct { sunindextype N; /* problem size */ - N_Vector d; /* matrix diagonal */ - sunrealtype real_part; /* nondiagonal entries of the matrix */ - sunrealtype imag_part; /* nondiagonal entries of the matrix */ + N_Vector diag; /* matrix diagonal */ + + /* nondiagonal entries of the matrix that lead to the complex conjugate eigenvalues */ + sunrealtype real_part; + sunrealtype imag_part; } UserData; /* private functions */ @@ -49,23 +47,25 @@ typedef struct int ATimes(void* ProbData, N_Vector v, N_Vector z); /* checks function return values */ int check_flag(void* flagvalue, const char* funcname, int opt); -/* uniform random number generator in [0,1] */ -int check_vector(N_Vector X, N_Vector Y, sunrealtype tol); - -/* global copy of the problem size (for check_vector routine) */ -sunindextype problem_size; /* ---------------------------------------------------------------------- * DomEig Module Testing Routine * --------------------------------------------------------------------*/ int main(int argc, char* argv[]) { - int passfail = 0; /* overall pass/fail flag */ - N_Vector q; /* test vectors */ - UserData ProbData; /* problem data structure */ - int maxl, power_of_A; + int fails = 0; /* counter for test failures */ + int passfail = 0; /* overall pass/fail flag */ + SUNDomEigEstimator DEE = NULL; /* domeig estimator object */ + N_Vector q; /* test vectors */ + UserData ProbData; /* problem data structure */ + int power_of_A; /* Power of A for the warm-up */ + int krydim; /* Krylov subspace dimension */ + int print_timing; /* timing output flag */ + suncomplextype dom_eig; /* computed domeig value */ + suncomplextype true_dom_eig; /* true domeig value */ SUNContext sunctx; - sunrealtype tolerans = 1.0e-2; + sunrealtype rel_tol = 1.0e-2; /* relative tol for pass/fail */ + sunrealtype rel_error; if (SUNContext_Create(SUN_COMM_NULL, &sunctx)) { @@ -73,24 +73,23 @@ int main(int argc, char* argv[]) return (-1); } - /* check inputs: local problem size */ - if (argc < 4) + /* check inputs: local problem size, timing flag */ + if (argc < 5) { - printf("ERROR: TWO (2) Inputs required:\n"); + printf("ERROR: TWO (4) Inputs required:\n"); printf(" Problem size should be >0\n"); printf(" Krylov subspace dimension should be >0\n"); printf(" Number of preprocessing should be >= 0\n"); return 1; } ProbData.N = (sunindextype)atol(argv[1]); - problem_size = ProbData.N; if (ProbData.N <= 0) { printf("ERROR: Problem size must be a positive integer\n"); return 1; } - maxl = atoi(argv[2]); - if (maxl <= 0) + krydim = atoi(argv[2]); + if (krydim <= 0) { printf("ERROR: Krylov subspace dimension must be a positive integer\n"); return 1; @@ -101,83 +100,81 @@ int main(int argc, char* argv[]) printf("ERROR: Number of preprocessing must be a nonnegative integer\n"); return 1; } + print_timing = atoi(argv[4]); + SetTiming(print_timing); + printf("\nDomEig module test:\n"); printf(" Problem size = %ld\n", (long int)ProbData.N); - printf(" Krylov subspace dimension = %i\n", maxl); + printf(" Krylov subspace dimension = %i\n", krydim); printf(" Number of preprocessing = %i\n", power_of_A); + printf(" Timing output flag = %i\n\n", print_timing); /* Create vectors */ q = N_VNew_Serial(ProbData.N, sunctx); if (check_flag(q, "N_VNew_Serial", 0)) { return 1; } - ProbData.d = N_VClone(q); - if (check_flag(ProbData.d, "N_VClone", 0)) { return 1; } - - /* Fill q vector with 1s */ - N_VConst(SUN_RCONST(1.0), q); + ProbData.diag = N_VClone(q); + if (check_flag(ProbData.diag, "N_VClone", 0)) { return 1; } /* Fill matrix diagonal and problem data */ - // real diag is factor*[3 4 5 ... N 0 0] - // suncomplextype diag is [ realpart imagpart; - // -imagpart realpart] - sunrealtype* v = N_VGetArrayPointer(ProbData.d); + // real diag is [3 4 5 ... N 0 0]*factor + // 2x2 block marix attached to the last two diagonals is + // [ realpart imagpart; + // [-imagpart realpart] + // This setup allows two types of dominant eigenvalues (real and complex) + // based on the "factor" and the problem dimension N. + sunrealtype* v = N_VGetArrayPointer(ProbData.diag); int i; - for (i = 0; i < ProbData.N - 2; i++) { v[i] = factor * (i + 3); } - + for (i = 0; i < ProbData.N - 2; i++) + { + v[i] = factor * (i + 3); + } + // Set the probem data corresponding to 2x2 block marix ProbData.real_part = realpart; ProbData.imag_part = imagpart; - /* Create DomEig estimator*/ - SUNDomEigEstimator DEE = NULL; - - DEE = SUNDomEigEst_ArnI(q, maxl, sunctx); + /* Create Arnoldi DomEig estimator*/ + DEE = SUNDomEigEst_ArnI(q, krydim, sunctx); if (check_flag(DEE, "SUNDomEigEst_ArnI", 0)) { return 1; } - /* Set Atimes*/ - passfail = DEE->ops->setatimes(DEE, &ProbData, ATimes); - if (check_flag(&passfail, "setatimes", 1)) { return 1; } + fails += Test_SUNDomEigEstGetType(DEE, SUNDOMEIG_ARNOLDI, 0); + fails += Test_SUNDomEigEstSetATimes(DEE, &ProbData, ATimes, 0); + fails += Test_SUNDomEigEstSetATimes(DEE, &ProbData, ATimes, 0); + fails += Test_SUNDomEigEstSetNumPreProcess(DEE, power_of_A, 0); + fails += Test_SUNDomEigEstInitialize(DEE, 0); + fails += Test_SUNDomEigEstPreProcess(DEE, 0); + fails += Test_SUNDomEigEstComputeHess(DEE, 0); + fails += Test_SUNDomEigEstimate(DEE, &dom_eig, 0); - /* Set the number of preprocessings */ - if (DEE->ops->setnumofperprocess != NULL) + if (fails) { - passfail = DEE->ops->setnumofperprocess(DEE, power_of_A); - if (check_flag(&passfail, "setnumofperprocess", 1)) { return 1; } + printf("FAIL: SUNDomEigEst_ArnI module failed %i initialization tests\n\n", + fails); + return 1; + } + else + { + printf("SUCCESS: SUNDomEigEst_ArnI module passed all initialization tests\n\n"); } - /* Initialize the estimator */ - passfail = DEE->ops->initialize(DEE); - if (check_flag(&passfail, "initialize", 1)) { return 1; } - - /* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ - passfail = DEE->ops->preprocess(DEE); - if (check_flag(&passfail, "preprocess", 1)) { return 1; } - - /* Compute the Hessenberg matrix Hes */ - passfail = DEE->ops->computehess(DEE); - if (check_flag(&passfail, "computehess", 1)) { return 1; } - - /* Estimate the dominant eigenvalue */ - suncomplextype dom_eig; - passfail = DEE->ops->estimate(DEE, &dom_eig); - if (check_flag(&passfail, "estimate", 1)) { return 1; } - + /* First check if the computed eigenvalue has a nonzero magnitute */ sunrealtype norm_of_dom_eig = SUNRsqrt(dom_eig.real * dom_eig.real + dom_eig.imag * dom_eig.imag); if (norm_of_dom_eig < SUN_SMALL_REAL) { - printf("FAIL: Dominant Eigenvalue Test Failed"); + printf("FAIL: Dominant Eigenvalue Test Failed\n\n"); return 1; } - suncomplextype true_dom_eig; - /* Identify true_dom_eig based on given parameters*/ - if (SUNRsqrt(realpart * realpart + imagpart * imagpart) > - -1.0 * factor * ProbData.N) + /* Identify the true_dom_eig based on given parameters*/ + if (SUNRsqrt(realpart * realpart + imagpart * imagpart) > -factor * ProbData.N) { + /* Dominant eigenvalue corresponds to the 2x2 block marix */ true_dom_eig.real = realpart; true_dom_eig.imag = imagpart; } else { + /* Dominant eigenvalue corresponds to the maximum real value at the diagonal */ true_dom_eig.real = factor * ProbData.N; true_dom_eig.imag = ZERO; } @@ -187,27 +184,26 @@ int main(int argc, char* argv[]) printf(" true dominant eigenvalue = %20.4lf + %20.4lfi\n", true_dom_eig.real, true_dom_eig.imag); - /* Compare the estimated dom_eig with true_dom_eig*/ - sunrealtype error = SUNRsqrt( + /* Compare the estimated dom_eig with the true_dom_eig*/ + rel_error = SUNRsqrt( (dom_eig.real - true_dom_eig.real) * (dom_eig.real - true_dom_eig.real) + (dom_eig.imag - true_dom_eig.imag) * (dom_eig.imag - true_dom_eig.imag)); - error /= norm_of_dom_eig; + rel_error /= norm_of_dom_eig; - if (error < tolerans) + if (rel_error < rel_tol && passfail == 0) { - printf("\n\nPASS: relative error = %lf\n", error); - return 0; + printf("\n\nPASS: relative error = %lf\n\n", rel_error); } else { - printf("\n\nFAIL: relative error = %lf\n", error); - return 0; + printf("\n\nFAIL: relative error = %lf\n\n", rel_error); + passfail += 1; } /* Free solver and vectors */ N_VDestroy(q); - N_VDestroy(ProbData.d); + N_VDestroy(ProbData.diag); SUNContext_Free(&sunctx); DEE->ops->free(DEE); @@ -235,7 +231,7 @@ int ATimes(void* Data, N_Vector v_vec, N_Vector z_vec) N = ProbData->N; real_part = ProbData->real_part; imag_part = ProbData->imag_part; - diag = N_VGetArrayPointer(ProbData->d); + diag = N_VGetArrayPointer(ProbData->diag); if (check_flag(diag, "N_VGetArrayPointer", 0)) { return 1; } /* perform product on the diagonal part of the matrix */ diff --git a/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c b/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c index 341be8cfcc..23020e7bee 100644 --- a/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c +++ b/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c @@ -11,19 +11,15 @@ * SPDX-License-Identifier: BSD-3-Clause * SUNDIALS Copyright End * ----------------------------------------------------------------- - * These test functions check some components of an DomEig iteration + * These test functions check some components of Power Iteration * module implementation. * ----------------------------------------------------------------- */ #include -#include #include -#include #include -#include -#include #include #include "../test_sundomeigest.h" diff --git a/test/unit_tests/sundomeigest/test_sundomeigest.c b/test/unit_tests/sundomeigest/test_sundomeigest.c index 3a24c963fa..f8f4c38439 100644 --- a/test/unit_tests/sundomeigest/test_sundomeigest.c +++ b/test/unit_tests/sundomeigest/test_sundomeigest.c @@ -89,6 +89,8 @@ int Test_SUNDomEigEstSetATimes(SUNDomEigEstimator DEE, void* ATdata, { printf(">>> FAILED test -- SUNDomEigEstSetATimes returned %d on Proc %d \n", failure, myid); + PRINT_TIME(" SUNDomEigEstSetATimes Time: %22.15e \n \n", + stop_time - start_time); return (1); } else if (myid == 0) @@ -101,6 +103,34 @@ int Test_SUNDomEigEstSetATimes(SUNDomEigEstimator DEE, void* ATdata, return (0); } +int Test_SUNDomEigEstSetNumPreProcess(SUNDomEigEstimator DEE, int power_of_A, int myid) +{ + int failure; + double start_time, stop_time; + + /* try calling SUNDomEigEstSetNumPreProcess routine: should pass/fail based on expected input */ + start_time = get_time(); + failure = SUNDomEigEstSetNumPreProcess(DEE, power_of_A); + // sync_device(); + stop_time = get_time(); + + if (failure) + { + printf(">>> FAILED test -- SUNDomEigEstSetNumPreProcess check, Proc %d \n", myid); + PRINT_TIME(" SUNDomEigEstSetNumPreProcess Time: %22.15e \n \n", + stop_time - start_time); + return (1); + } + else if (myid == 0) + { + printf(" PASSED test -- SUNDomEigEstSetNumPreProcess \n"); + PRINT_TIME(" SUNDomEigEstSetNumPreProcess Time: %22.15e \n \n", + stop_time - start_time); + } + + return (0); +} + /* ---------------------------------------------------------------------- * SUNDomEigEstInitialize Test * --------------------------------------------------------------------*/ @@ -136,6 +166,28 @@ int Test_SUNDomEigEstInitialize(SUNDomEigEstimator DEE, int myid) * --------------------------------------------------------------------*/ int Test_SUNDomEigEstPreProcess(SUNDomEigEstimator DEE, int myid) { + int failure; + double start_time, stop_time; + + start_time = get_time(); + failure = SUNDomEigEstPreProcess(DEE); + // sync_device(); + stop_time = get_time(); + + if (failure) + { + printf(">>> FAILED test -- SUNDomEigEstPreProcess check, Proc %d \n", myid); + PRINT_TIME(" SUNDomEigEstPreProcess Time: %22.15e \n \n", + stop_time - start_time); + return (1); + } + else if (myid == 0) + { + printf(" PASSED test -- SUNDomEigEstPreProcess \n"); + PRINT_TIME(" SUNDomEigEstPreProcess Time: %22.15e \n \n", + stop_time - start_time); + } + return (0); } @@ -144,13 +196,62 @@ int Test_SUNDomEigEstPreProcess(SUNDomEigEstimator DEE, int myid) * --------------------------------------------------------------------*/ int Test_SUNDomEigEstComputeHess(SUNDomEigEstimator DEE, int myid) { + int failure; + double start_time, stop_time; + + start_time = get_time(); + failure = SUNDomEigEstComputeHess(DEE); + // sync_device(); + stop_time = get_time(); + + if (failure) + { + printf(">>> FAILED test -- SUNDomEigEstComputeHess check, Proc %d \n", myid); + PRINT_TIME(" SUNDomEigEstComputeHess Time: %22.15e \n \n", + stop_time - start_time); + return (1); + } + else if (myid == 0) + { + printf(" PASSED test -- SUNDomEigEstComputeHess \n"); + PRINT_TIME(" SUNDomEigEstComputeHess Time: %22.15e \n \n", + stop_time - start_time); + } + return (0); } /* ---------------------------------------------------------------------- * SUNDomEigEstimate Test * --------------------------------------------------------------------*/ -int Test_SUNDomEigEstimate(SUNDomEigEstimator DEE, int myid) { return (0); } +int Test_SUNDomEigEstimate(SUNDomEigEstimator DEE, suncomplextype* dom_eig, int myid) +{ + int failure; + suncomplextype estimated_dom_eig; + double start_time, stop_time; + + start_time = get_time(); + failure = SUNDomEigEstimate(DEE, &estimated_dom_eig); + *dom_eig = estimated_dom_eig; + // sync_device(); + stop_time = get_time(); + + if (failure) + { + printf(">>> FAILED test -- SUNDomEigEstimate check, Proc %d \n", myid); + PRINT_TIME(" SUNDomEigEstimate Time: %22.15e \n \n", + stop_time - start_time); + return (1); + } + else if (myid == 0) + { + printf(" PASSED test -- SUNDomEigEstimate \n"); + PRINT_TIME(" SUNDomEigEstimate Time: %22.15e \n \n", + stop_time - start_time); + } + + return (0); +} /* ====================================================================== * Private functions diff --git a/test/unit_tests/sundomeigest/test_sundomeigest.h b/test/unit_tests/sundomeigest/test_sundomeigest.h index cd4ca26916..46bef3f07d 100644 --- a/test/unit_tests/sundomeigest/test_sundomeigest.h +++ b/test/unit_tests/sundomeigest/test_sundomeigest.h @@ -28,7 +28,6 @@ extern "C" { #endif /* Forward declarations for implementation specific utility functions */ -int check_vector(N_Vector expected, N_Vector computed, sunrealtype tol); // void sync_device(void); /* Test function declarations */ @@ -36,10 +35,11 @@ int Test_SUNDomEigEstGetType(SUNDomEigEstimator DEE, SUNDomEigEstimator_Type suntype, int myid); int Test_SUNDomEigEstSetATimes(SUNDomEigEstimator DEE, void* ATdata, SUNATimesFn ATimes, int myid); +int Test_SUNDomEigEstSetNumPreProcess(SUNDomEigEstimator DEE, int power_of_A, int myid); int Test_SUNDomEigEstInitialize(SUNDomEigEstimator DEE, int myid); int Test_SUNDomEigEstPreProcess(SUNDomEigEstimator DEE, int myid); int Test_SUNDomEigEstComputeHess(SUNDomEigEstimator DEE, int myid); -int Test_SUNDomEigEstimate(SUNDomEigEstimator DEE, int myid); +int Test_SUNDomEigEstimate(SUNDomEigEstimator DEE, suncomplextype* dom_eig, int myid); /* Timing function */ void SetTiming(int onoff); From 2a16f1ae0ee7a1819d3f5b5606a266479d4f889f Mon Sep 17 00:00:00 2001 From: maggul Date: Sat, 14 Jun 2025 13:26:59 -0500 Subject: [PATCH 042/128] unit tests --- .../arni/test_sundomeigest_arni.c | 1 - .../sundomeigest/pi/test_sundomeigest_pi.c | 168 +++++++++--------- 2 files changed, 87 insertions(+), 82 deletions(-) diff --git a/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c b/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c index 63d8c40d6f..0bf0fb25e1 100644 --- a/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c +++ b/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c @@ -138,7 +138,6 @@ int main(int argc, char* argv[]) fails += Test_SUNDomEigEstGetType(DEE, SUNDOMEIG_ARNOLDI, 0); fails += Test_SUNDomEigEstSetATimes(DEE, &ProbData, ATimes, 0); - fails += Test_SUNDomEigEstSetATimes(DEE, &ProbData, ATimes, 0); fails += Test_SUNDomEigEstSetNumPreProcess(DEE, power_of_A, 0); fails += Test_SUNDomEigEstInitialize(DEE, 0); fails += Test_SUNDomEigEstPreProcess(DEE, 0); diff --git a/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c b/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c index 23020e7bee..ba4c16af87 100644 --- a/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c +++ b/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c @@ -27,17 +27,17 @@ /* constants */ #define ZERO SUN_RCONST(0.0) -#define factor (-100.0) -#define realpart (-30000.0) -#define imagpart (0.0) +#define factor (-100.0) +#define diagonal (-30000.0) +#define nondiagonal (-10000.0) /* user data structure */ typedef struct { sunindextype N; /* problem size */ - N_Vector d; /* matrix diagonal */ - sunrealtype real_part; /* nondiagonal entries of the matrix */ - sunrealtype imag_part; /* nondiagonal entries of the matrix */ + N_Vector diag; /* matrix diagonal */ + sunrealtype A11; /* diagonal entries of the matrix */ + sunrealtype A12; /* nondiagonal entries of the matrix */ } UserData; /* private functions */ @@ -45,23 +45,25 @@ typedef struct int ATimes(void* ProbData, N_Vector v, N_Vector z); /* checks function return values */ int check_flag(void* flagvalue, const char* funcname, int opt); -/* uniform random number generator in [0,1] */ -int check_vector(N_Vector X, N_Vector Y, sunrealtype tol); - -/* global copy of the problem size (for check_vector routine) */ -sunindextype problem_size; /* ---------------------------------------------------------------------- * DomEig Module Testing Routine * --------------------------------------------------------------------*/ int main(int argc, char* argv[]) { - int passfail = 0; /* overall pass/fail flag */ - N_Vector q; /* test vectors */ - UserData ProbData; /* problem data structure */ - int maxl, power_of_A; + int fails = 0; /* counter for test failures */ + int passfail = 0; /* overall pass/fail flag */ + SUNDomEigEstimator DEE = NULL; /* domeig estimator object */ + N_Vector q; /* test vectors */ + UserData ProbData; /* problem data structure */ + int power_of_A; /* Power of A for the warm-up */ + int maxl; /* max power iteration */ + int print_timing; /* timing output flag */ + suncomplextype dom_eig; /* computed domeig value */ + suncomplextype true_dom_eig; /* true domeig value */ SUNContext sunctx; - sunrealtype tolerans = 1.0e-2; + sunrealtype rel_tol = 1.0e-2; /* relative tol for pass/fail */ + sunrealtype rel_error; if (SUNContext_Create(SUN_COMM_NULL, &sunctx)) { @@ -69,17 +71,16 @@ int main(int argc, char* argv[]) return (-1); } - /* check inputs: local problem size */ - if (argc < 4) + /* check inputs: local problem size, timing flag */ + if (argc < 5) { - printf("ERROR: TWO (2) Inputs required:\n"); + printf("ERROR: TWO (4) Inputs required:\n"); printf(" Problem size should be >0\n"); - printf(" Krylov subspace dimension should be >0\n"); + printf(" Maximum number of power iterations should be >0\n"); printf(" Number of preprocessing should be >= 0\n"); return 1; } ProbData.N = (sunindextype)atol(argv[1]); - problem_size = ProbData.N; if (ProbData.N <= 0) { printf("ERROR: Problem size must be a positive integer\n"); @@ -88,7 +89,7 @@ int main(int argc, char* argv[]) maxl = atoi(argv[2]); if (maxl <= 0) { - printf("ERROR: Krylov subspace dimension must be a positive integer\n"); + printf("ERROR: Maximum number of power iterations must be a positive integer\n"); return 1; } power_of_A = atoi(argv[3]); @@ -97,80 +98,86 @@ int main(int argc, char* argv[]) printf("ERROR: Number of preprocessing must be a nonnegative integer\n"); return 1; } + print_timing = atoi(argv[4]); + SetTiming(print_timing); + printf("\nDomEig module test:\n"); printf(" Problem size = %ld\n", (long int)ProbData.N); - printf(" Krylov subspace dimension = %i\n", maxl); + printf(" Number of power iterations = %i\n", maxl); printf(" Number of preprocessing = %i\n", power_of_A); + printf(" Timing output flag = %i\n\n", print_timing); /* Create vectors */ q = N_VNew_Serial(ProbData.N, sunctx); if (check_flag(q, "N_VNew_Serial", 0)) { return 1; } - ProbData.d = N_VClone(q); - if (check_flag(ProbData.d, "N_VClone", 0)) { return 1; } - - /* Fill q vector with 1s */ - N_VConst(SUN_RCONST(1.0), q); + ProbData.diag = N_VClone(q); + if (check_flag(ProbData.diag, "N_VClone", 0)) { return 1; } /* Fill matrix diagonal and problem data */ - // real diag is factor*[3 4 5 ... N 0 0] - // suncomplextype diag is [ realpart imagpart; - // -imagpart realpart] - sunrealtype* v = N_VGetArrayPointer(ProbData.d); + // real diag is [3 4 5 ... N 0 0]*factor + // 2x2 block marix attached to the last two diagonals is + // [ A11 A12 ] + // [ A12 A11 ] + // This setup allows two different dominant eigenvalues + // based on the "factor" and the problem dimension N. + // 2x2 block has eigenvalues A11 + A12 and A11 - A12 + sunrealtype* v = N_VGetArrayPointer(ProbData.diag); int i; - for (i = 0; i < ProbData.N - 2; i++) { v[i] = factor * (i + 3); } - - ProbData.real_part = realpart; - ProbData.imag_part = imagpart; + for (i = 0; i < ProbData.N - 2; i++) + { + v[i] = factor * (i + 3); + } - /* Create DomEig estimator*/ - SUNDomEigEstimator DEE = NULL; + // Set the probem data corresponding to 2x2 block marix + ProbData.A11 = diagonal; + ProbData.A12 = nondiagonal; + /* Create Arnoldi DomEig estimator*/ DEE = SUNDomEigEst_PI(q, maxl, sunctx); if (check_flag(DEE, "SUNDomEigEst_PI", 0)) { return 1; } - /* Set Atimes*/ - passfail = DEE->ops->setatimes(DEE, &ProbData, ATimes); - if (check_flag(&passfail, "setatimes", 1)) { return 1; } + fails += Test_SUNDomEigEstGetType(DEE, SUNDOMEIG_POWER, 0); + fails += Test_SUNDomEigEstSetATimes(DEE, &ProbData, ATimes, 0); + fails += Test_SUNDomEigEstSetNumPreProcess(DEE, power_of_A, 0); + fails += Test_SUNDomEigEstInitialize(DEE, 0); + fails += Test_SUNDomEigEstPreProcess(DEE, 0); + fails += Test_SUNDomEigEstComputeHess(DEE, 0); + fails += Test_SUNDomEigEstimate(DEE, &dom_eig, 0); - /* Set the number of preprocessings */ - if (DEE->ops->setnumofperprocess != NULL) + if (fails) { - passfail = DEE->ops->setnumofperprocess(DEE, power_of_A); - if (check_flag(&passfail, "setnumofperprocess", 1)) { return 1; } + printf("FAIL: SUNDomEigEst_PI module failed %i initialization tests\n\n", + fails); + return 1; + } + else + { + printf("SUCCESS: SUNDomEigEst_PI module passed all initialization tests\n\n"); } - /* Initialize the estimator */ - passfail = DEE->ops->initialize(DEE); - if (check_flag(&passfail, "initialize", 1)) { return 1; } - - /* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ - passfail = DEE->ops->preprocess(DEE); - if (check_flag(&passfail, "preprocess", 1)) { return 1; } - - /* Estimate the dominant eigenvalue */ - suncomplextype dom_eig; - passfail = DEE->ops->estimate(DEE, &dom_eig); - if (check_flag(&passfail, "estimate", 1)) { return 1; } - + /* First check if the computed eigenvalue has a nonzero magnitute */ sunrealtype norm_of_dom_eig = SUNRsqrt(dom_eig.real * dom_eig.real + dom_eig.imag * dom_eig.imag); if (norm_of_dom_eig < SUN_SMALL_REAL) { - printf("FAIL: Dominant Eigenvalue Test Failed"); + printf("FAIL: Dominant Eigenvalue Test Failed\n\n"); return 1; } - suncomplextype true_dom_eig; + // We ensure real eigenvalues due to symmetry. + // If A11 + A12 is larger than factor*ProbData.N, + // the dominant eigenvalue must be A11 + A12, + // factor*ProbData.N; otherwise. + /* Identify true_dom_eig based on given parameters*/ - if (SUNRsqrt(realpart * realpart + imagpart * imagpart) > - -1.0 * factor * ProbData.N) + if (fabs(diagonal + nondiagonal) < fabs(factor * ProbData.N)) { - true_dom_eig.real = realpart; - true_dom_eig.imag = imagpart; + true_dom_eig.real = factor * ProbData.N; + true_dom_eig.imag = ZERO; } else { - true_dom_eig.real = factor * ProbData.N; + true_dom_eig.real = diagonal + nondiagonal; true_dom_eig.imag = ZERO; } @@ -179,27 +186,26 @@ int main(int argc, char* argv[]) printf(" true dominant eigenvalue = %20.4lf + %20.4lfi\n", true_dom_eig.real, true_dom_eig.imag); - /* Compare the estimated dom_eig with true_dom_eig*/ - sunrealtype error = SUNRsqrt( + /* Compare the estimated dom_eig with the true_dom_eig*/ + rel_error = SUNRsqrt( (dom_eig.real - true_dom_eig.real) * (dom_eig.real - true_dom_eig.real) + (dom_eig.imag - true_dom_eig.imag) * (dom_eig.imag - true_dom_eig.imag)); - error /= norm_of_dom_eig; + rel_error /= norm_of_dom_eig; - if (error < tolerans) + if (rel_error < rel_tol && passfail == 0) { - printf("\n\nPASS: relative error = %lf\n", error); - return 0; + printf("\n\nPASS: relative error = %lf\n\n", rel_error); } else { - printf("\n\nFAIL: relative error = %lf\n", error); - return 0; + printf("\n\nFAIL: relative error = %lf\n\n", rel_error); + passfail += 1; } /* Free solver and vectors */ N_VDestroy(q); - N_VDestroy(ProbData.d); + N_VDestroy(ProbData.diag); SUNContext_Free(&sunctx); DEE->ops->free(DEE); @@ -214,7 +220,7 @@ int main(int argc, char* argv[]) int ATimes(void* Data, N_Vector v_vec, N_Vector z_vec) { /* local variables */ - sunrealtype *v, *z, *diag, real_part, imag_part; + sunrealtype *v, *z, *diag, a11, a12; sunindextype i, N; UserData* ProbData; @@ -224,18 +230,18 @@ int ATimes(void* Data, N_Vector v_vec, N_Vector z_vec) if (check_flag(v, "N_VGetArrayPointer", 0)) { return 1; } z = N_VGetArrayPointer(z_vec); if (check_flag(z, "N_VGetArrayPointer", 0)) { return 1; } - N = ProbData->N; - real_part = ProbData->real_part; - imag_part = ProbData->imag_part; - diag = N_VGetArrayPointer(ProbData->d); + N = ProbData->N; + a11 = ProbData->A11; + a12 = ProbData->A12; + diag = N_VGetArrayPointer(ProbData->diag); if (check_flag(diag, "N_VGetArrayPointer", 0)) { return 1; } /* perform product on the diagonal part of the matrix */ for (i = 0; i < N - 2; i++) { z[i] = diag[i] * v[i]; } /* perform product at the non-diagonal last two rows */ - z[N - 2] = v[N - 2] * real_part + v[N - 1] * imag_part; - z[N - 1] = v[N - 1] * real_part - v[N - 2] * imag_part; + z[N - 2] = v[N - 2] * a11 + v[N - 1] * a12; + z[N - 1] = v[N - 1] * a11 + v[N - 2] * a12; /* return with success */ return 0; } From 66202d3d0daa9b72c5a6355ad15ff0e7bb698ff7 Mon Sep 17 00:00:00 2001 From: maggul Date: Tue, 17 Jun 2025 10:20:06 -0500 Subject: [PATCH 043/128] doc files and set/get routines --- .../source/sundomeigest/ARKODE_interface.rst | 132 +++++ .../sundomeigest/SUNDomEigEst_API_link.rst | 13 + .../sundomeigest/SUNDomEigEst_links.rst | 15 + .../guide/source/sundomeigest/index.rst | 23 + .../source/sundomeigest/CVODE_interface.rst | 84 +++ .../sundomeigest/SUNDomEigEst_API_link.rst | 13 + .../sundomeigest/SUNDomEigEst_links.rst | 15 + doc/cvode/guide/source/sundomeigest/index.rst | 23 + .../source/sundomeigest/CVODES_interface.rst | 84 +++ .../sundomeigest/SUNDomEigEst_API_link.rst | 13 + .../sundomeigest/SUNDomEigEst_links.rst | 15 + .../guide/source/sundomeigest/index.rst | 23 + .../source/sundomeigest/IDA_interface.rst | 84 +++ .../sundomeigest/SUNDomEigEst_API_link.rst | 13 + .../sundomeigest/SUNDomEigEst_links.rst | 15 + doc/ida/guide/source/sundomeigest/index.rst | 23 + .../source/sundomeigest/IDAS_interface.rst | 84 +++ .../sundomeigest/SUNDomEigEst_API_link.rst | 13 + .../sundomeigest/SUNDomEigEst_links.rst | 15 + doc/idas/guide/source/sundomeigest/index.rst | 23 + .../source/sundomeigest/KINSOL_interface.rst | 84 +++ .../sundomeigest/SUNDomEigEst_API_link.rst | 13 + .../sundomeigest/SUNDomEigEst_links.rst | 15 + .../guide/source/sundomeigest/index.rst | 23 + doc/shared/sundials.bib | 27 + doc/shared/sundomeigest/SUNDomEigEst_API.rst | 552 ++++++++++++++++++ doc/shared/sundomeigest/SUNDomEigEst_ARNI.rst | 172 ++++++ .../sundomeigest/SUNDomEigEst_Examples.rst | 65 +++ .../SUNDomEigEst_Introduction.rst | 63 ++ doc/shared/sundomeigest/SUNDomEigEst_PI.rst | 157 +++++ doc/sundials/biblio.bib | 27 + doc/superbuild/source/index.rst | 1 + .../sundomeigest/SUNDomEigEst_API_link.rst | 13 + .../sundomeigest/SUNDomEigEst_links.rst | 15 + .../SUNDomEigEst_package_links.rst | 19 + doc/superbuild/source/sundomeigest/index.rst | 22 + include/sundials/sundials_domeigestimator.h | 29 +- include/sundials/sundials_errors.h | 16 +- include/sundomeigest/sundomeigest_arni.h | 13 +- include/sundomeigest/sundomeigest_pi.h | 22 +- src/sundials/sundials_domeigestimator.c | 64 +- src/sundomeigest/ArnI/sundomeigest_arni.c | 77 +-- src/sundomeigest/PI/sundomeigest_pi.c | 58 +- .../sundomeigest/arni/CMakeLists.txt | 6 +- .../arni/test_sundomeigest_arni.c | 23 +- .../unit_tests/sundomeigest/pi/CMakeLists.txt | 5 +- .../sundomeigest/pi/test_sundomeigest_pi.c | 29 +- .../sundomeigest/test_sundomeigest.c | 117 +++- .../sundomeigest/test_sundomeigest.h | 6 +- 49 files changed, 2349 insertions(+), 107 deletions(-) create mode 100644 doc/arkode/guide/source/sundomeigest/ARKODE_interface.rst create mode 100644 doc/arkode/guide/source/sundomeigest/SUNDomEigEst_API_link.rst create mode 100644 doc/arkode/guide/source/sundomeigest/SUNDomEigEst_links.rst create mode 100644 doc/arkode/guide/source/sundomeigest/index.rst create mode 100644 doc/cvode/guide/source/sundomeigest/CVODE_interface.rst create mode 100644 doc/cvode/guide/source/sundomeigest/SUNDomEigEst_API_link.rst create mode 100644 doc/cvode/guide/source/sundomeigest/SUNDomEigEst_links.rst create mode 100644 doc/cvode/guide/source/sundomeigest/index.rst create mode 100644 doc/cvodes/guide/source/sundomeigest/CVODES_interface.rst create mode 100644 doc/cvodes/guide/source/sundomeigest/SUNDomEigEst_API_link.rst create mode 100644 doc/cvodes/guide/source/sundomeigest/SUNDomEigEst_links.rst create mode 100644 doc/cvodes/guide/source/sundomeigest/index.rst create mode 100644 doc/ida/guide/source/sundomeigest/IDA_interface.rst create mode 100644 doc/ida/guide/source/sundomeigest/SUNDomEigEst_API_link.rst create mode 100644 doc/ida/guide/source/sundomeigest/SUNDomEigEst_links.rst create mode 100644 doc/ida/guide/source/sundomeigest/index.rst create mode 100644 doc/idas/guide/source/sundomeigest/IDAS_interface.rst create mode 100644 doc/idas/guide/source/sundomeigest/SUNDomEigEst_API_link.rst create mode 100644 doc/idas/guide/source/sundomeigest/SUNDomEigEst_links.rst create mode 100644 doc/idas/guide/source/sundomeigest/index.rst create mode 100644 doc/kinsol/guide/source/sundomeigest/KINSOL_interface.rst create mode 100644 doc/kinsol/guide/source/sundomeigest/SUNDomEigEst_API_link.rst create mode 100644 doc/kinsol/guide/source/sundomeigest/SUNDomEigEst_links.rst create mode 100644 doc/kinsol/guide/source/sundomeigest/index.rst create mode 100644 doc/shared/sundomeigest/SUNDomEigEst_API.rst create mode 100644 doc/shared/sundomeigest/SUNDomEigEst_ARNI.rst create mode 100644 doc/shared/sundomeigest/SUNDomEigEst_Examples.rst create mode 100644 doc/shared/sundomeigest/SUNDomEigEst_Introduction.rst create mode 100644 doc/shared/sundomeigest/SUNDomEigEst_PI.rst create mode 100644 doc/superbuild/source/sundomeigest/SUNDomEigEst_API_link.rst create mode 100644 doc/superbuild/source/sundomeigest/SUNDomEigEst_links.rst create mode 100644 doc/superbuild/source/sundomeigest/SUNDomEigEst_package_links.rst create mode 100644 doc/superbuild/source/sundomeigest/index.rst diff --git a/doc/arkode/guide/source/sundomeigest/ARKODE_interface.rst b/doc/arkode/guide/source/sundomeigest/ARKODE_interface.rst new file mode 100644 index 0000000000..8a4a706cb3 --- /dev/null +++ b/doc/arkode/guide/source/sundomeigest/ARKODE_interface.rst @@ -0,0 +1,132 @@ +.. ---------------------------------------------------------------- + Programmer(s): Mustafa Aggul @ SMU + ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2025, Lawrence Livermore National Security + and Southern Methodist University. + All rights reserved. + + See the top-level LICENSE and NOTICE files for details. + + SPDX-License-Identifier: BSD-3-Clause + SUNDIALS Copyright End + ---------------------------------------------------------------- + +.. _SUNDomEigEst.ARKODE: + +ARKODE SUNDomEigEstimator interface +============================================== + +In :numref:`SUNDomEigEst.ARKODE.Usage`, we list the SUNDomEigEst module functions used +within the ARKDEE interface. We emphasize that the ARKODE user does not need to know +detailed usage of dominant eigenvalue estomator functions by the ARKODE code modules +in order to use ARKODE. The information is presented as an implementation detail for +the interested reader. + +.. _SUNDomEigEst.ARKODE.Usage: +.. table:: List of SUNDomEigEst functions called by the ARKODE dominant eigenvalue + estimator interface, depending on the self-identified "id" reported from + :c:func:`SUNDomEigEstGetID`. Functions marked with "X" are required; + functions marked with "O" are only called if they are non-``NULL`` and + functions marked with "N/A" are not applicable in the ``SUNDomEigEstimator`` + implementation that is being used. + :align: center + + +----------------------------------------------------+---------------------+---------------------+ + | Routine | POWER ITERATION | ARNOLDI ITERATION | + | | | | + +====================================================+=====================+=====================+ + | :c:func:`SUNDomEigEstGetID` | O | O | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstSetATimes` | X | X | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstSetMaxPowerIter` | O | O | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstSetNumPreProcess` | O | O | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstInitialize` | X | X | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstPreProcess` | O | O | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstComputeHess`\ :sup:`1` | N/A | X | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstimate` | X | X | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstNumIters`\ :sup:`2` | O | N/A | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstRes`\ :sup:`3` | O | N/A | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstFree`\ :sup:`4` | | | + +----------------------------------------------------+---------------------+---------------------+ + + +Notes: + +1. :c:func:`SUNDomEigEstComputeHess()` might or might not be required depending on + ``SUNDomEigEstimator`` implementation that is being used. This flag must be left + ``NULL`` if it is not applicable for an estimator. + +2. :c:func:`SUNDomEigEstNumIters()` is only used to accumulate overall + iterative estimator statistics. If it is not implemented by + the ``SUNDomEigEstimator`` module, then ARKDEE will consider all + estimates as requiring zero iterations. + +3. Although :c:func:`SUNDomEigEstRes()` is optional, if it is not + implemented by the ``SUNDomEigEstimator`` then ARKDEE will consider all + estimates a being *exact*. + +4. Although ARKDEE does not call :c:func:`SUNDomEigEstFree()` + directly, this routine should be available for users to call when + cleaning up from a simulation. + +Since there are a wide range of potential SUNDomEigEst use cases, the following +subsections describe some details of the ARKDEE interface, in the case that +interested users wish to develop custom SUNDomEigEst modules. + + +.. _SUNDomEigEst.Custom: + +Providing a custom SUNDomEigEstimator +------------------------------------- + +In certain instances, users may wish to provide a custom SUNDomEigEst +implementation to ARKODE in order to leverage the structure of a problem. While +the "standard" API for these routines is typically sufficient for most users, +others may need additional ARKODE-specific information on top of what is +provided. For these purposes, we note the following advanced output functions +available in ARKStep and MRIStep: + + +**ARKStep advanced outputs**: when solving the Newton nonlinear system of +equations in predictor-corrector form, + +.. math:: + \begin{array}{ll} + G(z_{cor}) \equiv z_{cor} - \gamma f^I\left(t^I_{n,i}, z_{i} \right) - \tilde{a}_i = 0 &\qquad \text{[$M=I$]},\\ + G(z_{cor}) \equiv M z_{cor} - \gamma f^I\left(t^I_{n,i}, z_{i} \right) - \tilde{a}_i = 0 &\qquad \text{[$M$ static]},\\ + G(z_{cor}) \equiv M(t^I_{n,i}) (z_{cor} - \tilde{a}_i) - \gamma f^I\left(t^I_{n,i}, z_{i}\right) = 0 &\qquad \text{[$M$ time-dependent]}. + \end{array} + +* :c:func:`ARKStepGetCurrentTime()` -- when called within the computation of a + step (i.e., within a solve) this returns :math:`t^I_{n,i}`. Otherwise the + current internal solution time is returned. +* :c:func:`ARKStepGetCurrentState()` -- when called within the computation of a + step (i.e., within a solve) this returns the current stage vector + :math:`z_{i} = z_{cor} + z_{pred}`. Otherwise the current internal solution + is returned. +* :c:func:`ARKStepGetCurrentMassMatrix()` -- returns :math:`M(t)`. + + +**MRIStep advanced outputs**: when solving the Newton nonlinear system of +equations in predictor-corrector form, + +.. math:: + G(z_{cor}) \equiv z_{cor} - \gamma f^I\left(t^S_{n,i}, z_{i}\right) - \tilde{a}_i = 0 + +* :c:func:`MRIStepGetCurrentTime()` -- when called within the computation of a + step (i.e., within a solve) this returns :math:`t^S_{n,i}`. Otherwise the + current internal solution time is returned. +* :c:func:`MRIStepGetCurrentState()` -- when called within the computation of a + step (i.e., within a solve) this returns the current stage vector + :math:`z_{i} = z_{cor} + z_{pred}`. Otherwise the current internal solution + is returned. diff --git a/doc/arkode/guide/source/sundomeigest/SUNDomEigEst_API_link.rst b/doc/arkode/guide/source/sundomeigest/SUNDomEigEst_API_link.rst new file mode 100644 index 0000000000..63131049d7 --- /dev/null +++ b/doc/arkode/guide/source/sundomeigest/SUNDomEigEst_API_link.rst @@ -0,0 +1,13 @@ +.. ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2025, Lawrence Livermore National Security + and Southern Methodist University. + All rights reserved. + + See the top-level LICENSE and NOTICE files for details. + + SPDX-License-Identifier: BSD-3-Clause + SUNDIALS Copyright End + ---------------------------------------------------------------- + +.. include:: ../../../shared/sundomeigest/SUNDomEigEst_API.rst diff --git a/doc/arkode/guide/source/sundomeigest/SUNDomEigEst_links.rst b/doc/arkode/guide/source/sundomeigest/SUNDomEigEst_links.rst new file mode 100644 index 0000000000..68de7d1878 --- /dev/null +++ b/doc/arkode/guide/source/sundomeigest/SUNDomEigEst_links.rst @@ -0,0 +1,15 @@ +.. ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2025, Lawrence Livermore National Security + and Southern Methodist University. + All rights reserved. + + See the top-level LICENSE and NOTICE files for details. + + SPDX-License-Identifier: BSD-3-Clause + SUNDIALS Copyright End + ---------------------------------------------------------------- + +.. include:: ../../../shared/sundomeigest/SUNDomEigEst_PI.rst +.. include:: ../../../shared/sundomeigest/SUNDomEigEst_ARNI.rst +.. include:: ../../../shared/sundomeigest/SUNDomEigEst_Examples.rst diff --git a/doc/arkode/guide/source/sundomeigest/index.rst b/doc/arkode/guide/source/sundomeigest/index.rst new file mode 100644 index 0000000000..9fd31a169b --- /dev/null +++ b/doc/arkode/guide/source/sundomeigest/index.rst @@ -0,0 +1,23 @@ +.. ---------------------------------------------------------------- + Mustafa Aggul @ SMU + ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2025, Lawrence Livermore National Security + and Southern Methodist University. + All rights reserved. + + See the top-level LICENSE and NOTICE files for details. + + SPDX-License-Identifier: BSD-3-Clause + SUNDIALS Copyright End + ---------------------------------------------------------------- + +.. include:: ../../../../shared/sundomeigest/SUNDomEigEst_Introduction.rst + +.. toctree:: + :maxdepth: 1 + + SUNDomEigEst_API_link.rst + ARKODE_interface + SUNDomEigEst_links.rst + diff --git a/doc/cvode/guide/source/sundomeigest/CVODE_interface.rst b/doc/cvode/guide/source/sundomeigest/CVODE_interface.rst new file mode 100644 index 0000000000..8ae82e6aaa --- /dev/null +++ b/doc/cvode/guide/source/sundomeigest/CVODE_interface.rst @@ -0,0 +1,84 @@ +.. ---------------------------------------------------------------- + Programmer(s): Mustafa Aggul @ SMU + ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2025, Lawrence Livermore National Security + and Southern Methodist University. + All rights reserved. + + See the top-level LICENSE and NOTICE files for details. + + SPDX-License-Identifier: BSD-3-Clause + SUNDIALS Copyright End + ---------------------------------------------------------------- + +.. _SUNDomEigEst.CVODE: + +CVODE SUNDomEigEstimator interface +============================================== + +In :numref:`SUNDomEigEst.CVODE.Usage`, we list the SUNDomEigEst module functions used +within the CVDEE interface. We emphasize that the CVODE user does not need to know +detailed usage of dominant eigenvalue estomator functions by the CVODE code modules +in order to use CVODE. The information is presented as an implementation detail for +the interested reader. + +.. _SUNDomEigEst.CVODE.Usage: +.. table:: List of SUNDomEigEst functions called by the CVODE dominant eigenvalue + estimator interface, depending on the self-identified "id" reported from + :c:func:`SUNDomEigEstGetID`. Functions marked with "X" are required; + functions marked with "O" are only called if they are non-``NULL`` and + functions marked with "N/A" are not applicable in the ``SUNDomEigEstimator`` + implementation that is being used. + :align: center + + +----------------------------------------------------+---------------------+---------------------+ + | Routine | POWER ITERATION | ARNOLDI ITERATION | + | | | | + +====================================================+=====================+=====================+ + | :c:func:`SUNDomEigEstGetID` | O | O | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstSetATimes` | X | X | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstSetMaxPowerIter` | O | O | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstSetNumPreProcess` | O | O | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstInitialize` | X | X | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstPreProcess` | O | O | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstComputeHess`\ :sup:`1` | N/A | X | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstimate` | X | X | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstNumIters`\ :sup:`2` | O | N/A | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstRes`\ :sup:`3` | O | N/A | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstFree`\ :sup:`4` | | | + +----------------------------------------------------+---------------------+---------------------+ + + +Notes: + +1. :c:func:`SUNDomEigEstComputeHess()` might or might not be required depending on + ``SUNDomEigEstimator`` implementation that is being used. This flag must be left + ``NULL`` if it is not applicable for an estimator. + +2. :c:func:`SUNDomEigEstNumIters()` is only used to accumulate overall + iterative estimator statistics. If it is not implemented by + the ``SUNDomEigEstimator`` module, then CVDEE will consider all + estimates as requiring zero iterations. + +3. Although :c:func:`SUNDomEigEstRes()` is optional, if it is not + implemented by the ``SUNDomEigEstimator`` then CVDEE will consider all + estimates a being *exact*. + +4. Although CVDEE does not call :c:func:`SUNDomEigEstFree()` + directly, this routine should be available for users to call when + cleaning up from a simulation. + +Since there are a wide range of potential SUNDomEigEst use cases, the following +subsections describe some details of the CVDEE interface, in the case that +interested users wish to develop custom SUNDomEigEst modules. diff --git a/doc/cvode/guide/source/sundomeigest/SUNDomEigEst_API_link.rst b/doc/cvode/guide/source/sundomeigest/SUNDomEigEst_API_link.rst new file mode 100644 index 0000000000..63131049d7 --- /dev/null +++ b/doc/cvode/guide/source/sundomeigest/SUNDomEigEst_API_link.rst @@ -0,0 +1,13 @@ +.. ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2025, Lawrence Livermore National Security + and Southern Methodist University. + All rights reserved. + + See the top-level LICENSE and NOTICE files for details. + + SPDX-License-Identifier: BSD-3-Clause + SUNDIALS Copyright End + ---------------------------------------------------------------- + +.. include:: ../../../shared/sundomeigest/SUNDomEigEst_API.rst diff --git a/doc/cvode/guide/source/sundomeigest/SUNDomEigEst_links.rst b/doc/cvode/guide/source/sundomeigest/SUNDomEigEst_links.rst new file mode 100644 index 0000000000..68de7d1878 --- /dev/null +++ b/doc/cvode/guide/source/sundomeigest/SUNDomEigEst_links.rst @@ -0,0 +1,15 @@ +.. ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2025, Lawrence Livermore National Security + and Southern Methodist University. + All rights reserved. + + See the top-level LICENSE and NOTICE files for details. + + SPDX-License-Identifier: BSD-3-Clause + SUNDIALS Copyright End + ---------------------------------------------------------------- + +.. include:: ../../../shared/sundomeigest/SUNDomEigEst_PI.rst +.. include:: ../../../shared/sundomeigest/SUNDomEigEst_ARNI.rst +.. include:: ../../../shared/sundomeigest/SUNDomEigEst_Examples.rst diff --git a/doc/cvode/guide/source/sundomeigest/index.rst b/doc/cvode/guide/source/sundomeigest/index.rst new file mode 100644 index 0000000000..99283f5ef8 --- /dev/null +++ b/doc/cvode/guide/source/sundomeigest/index.rst @@ -0,0 +1,23 @@ +.. ---------------------------------------------------------------- + Daniel R. Reynolds @ SMU + ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2025, Lawrence Livermore National Security + and Southern Methodist University. + All rights reserved. + + See the top-level LICENSE and NOTICE files for details. + + SPDX-License-Identifier: BSD-3-Clause + SUNDIALS Copyright End + ---------------------------------------------------------------- + +.. include:: ../../../../shared/sundomeigest/SUNDomEigEst_Introduction.rst + +.. toctree:: + :maxdepth: 1 + + SUNDomEigEst_API_link.rst + CVODE_interface + SUNDomEigEst_links.rst + diff --git a/doc/cvodes/guide/source/sundomeigest/CVODES_interface.rst b/doc/cvodes/guide/source/sundomeigest/CVODES_interface.rst new file mode 100644 index 0000000000..7300d21c44 --- /dev/null +++ b/doc/cvodes/guide/source/sundomeigest/CVODES_interface.rst @@ -0,0 +1,84 @@ +.. ---------------------------------------------------------------- + Programmer(s): Mustafa Aggul @ SMU + ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2025, Lawrence Livermore National Security + and Southern Methodist University. + All rights reserved. + + See the top-level LICENSE and NOTICE files for details. + + SPDX-License-Identifier: BSD-3-Clause + SUNDIALS Copyright End + ---------------------------------------------------------------- + +.. _SUNDomEigEst.CVODES: + +CVODES SUNDomEigEstimator interface +============================================== + +In :numref:`SUNDomEigEst.CVODES.Usage`, we list the SUNDomEigEst module functions used +within the CVDEE interface. We emphasize that the CVODES user does not need to know +detailed usage of dominant eigenvalue estomator functions by the CVODES code modules +in order to use CVODES. The information is presented as an implementation detail for +the interested reader. + +.. _SUNDomEigEst.CVODES.Usage: +.. table:: List of SUNDomEigEst functions called by the CVODES dominant eigenvalue + estimator interface, depending on the self-identified "id" reported from + :c:func:`SUNDomEigEstGetID`. Functions marked with "X" are required; + functions marked with "O" are only called if they are non-``NULL`` and + functions marked with "N/A" are not applicable in the ``SUNDomEigEstimator`` + implementation that is being used. + :align: center + + +----------------------------------------------------+---------------------+---------------------+ + | Routine | POWER ITERATION | ARNOLDI ITERATION | + | | | | + +====================================================+=====================+=====================+ + | :c:func:`SUNDomEigEstGetID` | O | O | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstSetATimes` | X | X | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstSetMaxPowerIter` | O | O | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstSetNumPreProcess` | O | O | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstInitialize` | X | X | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstPreProcess` | O | O | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstComputeHess`\ :sup:`1` | N/A | X | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstimate` | X | X | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstNumIters`\ :sup:`2` | O | N/A | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstRes`\ :sup:`3` | O | N/A | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstFree`\ :sup:`4` | | | + +----------------------------------------------------+---------------------+---------------------+ + + +Notes: + +1. :c:func:`SUNDomEigEstComputeHess()` might or might not be required depending on + ``SUNDomEigEstimator`` implementation that is being used. This flag must be left + ``NULL`` if it is not applicable for an estimator. + +2. :c:func:`SUNDomEigEstNumIters()` is only used to accumulate overall + iterative estimator statistics. If it is not implemented by + the ``SUNDomEigEstimator`` module, then CVDEE will consider all + estimates as requiring zero iterations. + +3. Although :c:func:`SUNDomEigEstRes()` is optional, if it is not + implemented by the ``SUNDomEigEstimator`` then CVDEE will consider all + estimates a being *exact*. + +4. Although CVDEE does not call :c:func:`SUNDomEigEstFree()` + directly, this routine should be available for users to call when + cleaning up from a simulation. + +Since there are a wide range of potential SUNDomEigEst use cases, the following +subsections describe some details of the CVDEE interface, in the case that +interested users wish to develop custom SUNDomEigEst modules. diff --git a/doc/cvodes/guide/source/sundomeigest/SUNDomEigEst_API_link.rst b/doc/cvodes/guide/source/sundomeigest/SUNDomEigEst_API_link.rst new file mode 100644 index 0000000000..63131049d7 --- /dev/null +++ b/doc/cvodes/guide/source/sundomeigest/SUNDomEigEst_API_link.rst @@ -0,0 +1,13 @@ +.. ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2025, Lawrence Livermore National Security + and Southern Methodist University. + All rights reserved. + + See the top-level LICENSE and NOTICE files for details. + + SPDX-License-Identifier: BSD-3-Clause + SUNDIALS Copyright End + ---------------------------------------------------------------- + +.. include:: ../../../shared/sundomeigest/SUNDomEigEst_API.rst diff --git a/doc/cvodes/guide/source/sundomeigest/SUNDomEigEst_links.rst b/doc/cvodes/guide/source/sundomeigest/SUNDomEigEst_links.rst new file mode 100644 index 0000000000..68de7d1878 --- /dev/null +++ b/doc/cvodes/guide/source/sundomeigest/SUNDomEigEst_links.rst @@ -0,0 +1,15 @@ +.. ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2025, Lawrence Livermore National Security + and Southern Methodist University. + All rights reserved. + + See the top-level LICENSE and NOTICE files for details. + + SPDX-License-Identifier: BSD-3-Clause + SUNDIALS Copyright End + ---------------------------------------------------------------- + +.. include:: ../../../shared/sundomeigest/SUNDomEigEst_PI.rst +.. include:: ../../../shared/sundomeigest/SUNDomEigEst_ARNI.rst +.. include:: ../../../shared/sundomeigest/SUNDomEigEst_Examples.rst diff --git a/doc/cvodes/guide/source/sundomeigest/index.rst b/doc/cvodes/guide/source/sundomeigest/index.rst new file mode 100644 index 0000000000..95b0cf7bd6 --- /dev/null +++ b/doc/cvodes/guide/source/sundomeigest/index.rst @@ -0,0 +1,23 @@ +.. ---------------------------------------------------------------- + Mustafa Aggul @ SMU + ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2025, Lawrence Livermore National Security + and Southern Methodist University. + All rights reserved. + + See the top-level LICENSE and NOTICE files for details. + + SPDX-License-Identifier: BSD-3-Clause + SUNDIALS Copyright End + ---------------------------------------------------------------- + +.. include:: ../../../../shared/sundomeigest/SUNDomEigEst_Introduction.rst + +.. toctree:: + :maxdepth: 1 + + SUNDomEigEst_API_link.rst + CVODES_interface + SUNDomEigEst_links.rst + diff --git a/doc/ida/guide/source/sundomeigest/IDA_interface.rst b/doc/ida/guide/source/sundomeigest/IDA_interface.rst new file mode 100644 index 0000000000..1e3a10d441 --- /dev/null +++ b/doc/ida/guide/source/sundomeigest/IDA_interface.rst @@ -0,0 +1,84 @@ +.. ---------------------------------------------------------------- + Programmer(s): Mustafa Aggul @ SMU + ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2025, Lawrence Livermore National Security + and Southern Methodist University. + All rights reserved. + + See the top-level LICENSE and NOTICE files for details. + + SPDX-License-Identifier: BSD-3-Clause + SUNDIALS Copyright End + ---------------------------------------------------------------- + +.. _SUNDomEigEst.IDA: + +IDA SUNDomEigEstimator interface +============================================== + +In :numref:`SUNDomEigEst.IDA.Usage`, we list the SUNDomEigEst module functions used +within the IDADEE interface. We emphasize that the IDA user does not need to know +detailed usage of dominant eigenvalue estomator functions by the IDA code modules +in order to use IDA. The information is presented as an implementation detail for +the interested reader. + +.. _SUNDomEigEst.IDA.Usage: +.. table:: List of SUNDomEigEst functions called by the IDA dominant eigenvalue + estimator interface, depending on the self-identified "id" reported from + :c:func:`SUNDomEigEstGetID`. Functions marked with "X" are required; + functions marked with "O" are only called if they are non-``NULL`` and + functions marked with "N/A" are not applicable in the ``SUNDomEigEstimator`` + implementation that is being used. + :align: center + + +----------------------------------------------------+---------------------+---------------------+ + | Routine | POWER ITERATION | ARNOLDI ITERATION | + | | | | + +====================================================+=====================+=====================+ + | :c:func:`SUNDomEigEstGetID` | O | O | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstSetATimes` | X | X | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstSetMaxPowerIter` | O | O | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstSetNumPreProcess` | O | O | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstInitialize` | X | X | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstPreProcess` | O | O | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstComputeHess`\ :sup:`1` | N/A | X | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstimate` | X | X | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstNumIters`\ :sup:`2` | O | N/A | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstRes`\ :sup:`3` | O | N/A | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstFree`\ :sup:`4` | | | + +----------------------------------------------------+---------------------+---------------------+ + + +Notes: + +1. :c:func:`SUNDomEigEstComputeHess()` might or might not be required depending on + ``SUNDomEigEstimator`` implementation that is being used. This flag must be left + ``NULL`` if it is not applicable for an estimator. + +2. :c:func:`SUNDomEigEstNumIters()` is only used to accumulate overall + iterative estimator statistics. If it is not implemented by + the ``SUNDomEigEstimator`` module, then IDADEE will consider all + estimates as requiring zero iterations. + +3. Although :c:func:`SUNDomEigEstRes()` is optional, if it is not + implemented by the ``SUNDomEigEstimator`` then IDADEE will consider all + estimates a being *exact*. + +4. Although IDADEE does not call :c:func:`SUNDomEigEstFree()` + directly, this routine should be available for users to call when + cleaning up from a simulation. + +Since there are a wide range of potential SUNDomEigEst use cases, the following +subsections describe some details of the IDADEE interface, in the case that +interested users wish to develop custom SUNDomEigEst modules. diff --git a/doc/ida/guide/source/sundomeigest/SUNDomEigEst_API_link.rst b/doc/ida/guide/source/sundomeigest/SUNDomEigEst_API_link.rst new file mode 100644 index 0000000000..63131049d7 --- /dev/null +++ b/doc/ida/guide/source/sundomeigest/SUNDomEigEst_API_link.rst @@ -0,0 +1,13 @@ +.. ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2025, Lawrence Livermore National Security + and Southern Methodist University. + All rights reserved. + + See the top-level LICENSE and NOTICE files for details. + + SPDX-License-Identifier: BSD-3-Clause + SUNDIALS Copyright End + ---------------------------------------------------------------- + +.. include:: ../../../shared/sundomeigest/SUNDomEigEst_API.rst diff --git a/doc/ida/guide/source/sundomeigest/SUNDomEigEst_links.rst b/doc/ida/guide/source/sundomeigest/SUNDomEigEst_links.rst new file mode 100644 index 0000000000..68de7d1878 --- /dev/null +++ b/doc/ida/guide/source/sundomeigest/SUNDomEigEst_links.rst @@ -0,0 +1,15 @@ +.. ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2025, Lawrence Livermore National Security + and Southern Methodist University. + All rights reserved. + + See the top-level LICENSE and NOTICE files for details. + + SPDX-License-Identifier: BSD-3-Clause + SUNDIALS Copyright End + ---------------------------------------------------------------- + +.. include:: ../../../shared/sundomeigest/SUNDomEigEst_PI.rst +.. include:: ../../../shared/sundomeigest/SUNDomEigEst_ARNI.rst +.. include:: ../../../shared/sundomeigest/SUNDomEigEst_Examples.rst diff --git a/doc/ida/guide/source/sundomeigest/index.rst b/doc/ida/guide/source/sundomeigest/index.rst new file mode 100644 index 0000000000..98910fb203 --- /dev/null +++ b/doc/ida/guide/source/sundomeigest/index.rst @@ -0,0 +1,23 @@ +.. ---------------------------------------------------------------- + Daniel R. Reynolds @ SMU + ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2025, Lawrence Livermore National Security + and Southern Methodist University. + All rights reserved. + + See the top-level LICENSE and NOTICE files for details. + + SPDX-License-Identifier: BSD-3-Clause + SUNDIALS Copyright End + ---------------------------------------------------------------- + +.. include:: ../../../../shared/sundomeigest/SUNDomEigEst_Introduction.rst + +.. toctree:: + :maxdepth: 1 + + SUNDomEigEst_API_link.rst + IDA_interface + SUNDomEigEst_links.rst + diff --git a/doc/idas/guide/source/sundomeigest/IDAS_interface.rst b/doc/idas/guide/source/sundomeigest/IDAS_interface.rst new file mode 100644 index 0000000000..bc28fbfe97 --- /dev/null +++ b/doc/idas/guide/source/sundomeigest/IDAS_interface.rst @@ -0,0 +1,84 @@ +.. ---------------------------------------------------------------- + Programmer(s): Mustafa Aggul @ SMU + ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2025, Lawrence Livermore National Security + and Southern Methodist University. + All rights reserved. + + See the top-level LICENSE and NOTICE files for details. + + SPDX-License-Identifier: BSD-3-Clause + SUNDIALS Copyright End + ---------------------------------------------------------------- + +.. _SUNDomEigEst.IDAS: + +IDAS SUNDomEigEstimator interface +============================================== + +In :numref:`SUNDomEigEst.IDAS.Usage`, we list the SUNDomEigEst module functions used +within the IDADEE interface. We emphasize that the IDAS user does not need to know +detailed usage of dominant eigenvalue estomator functions by the IDAS code modules +in order to use IDAS. The information is presented as an implementation detail for +the interested reader. + +.. _SUNDomEigEst.IDAS.Usage: +.. table:: List of SUNDomEigEst functions called by the IDAS dominant eigenvalue + estimator interface, depending on the self-identified "id" reported from + :c:func:`SUNDomEigEstGetID`. Functions marked with "X" are required; + functions marked with "O" are only called if they are non-``NULL`` and + functions marked with "N/A" are not applicable in the ``SUNDomEigEstimator`` + implementation that is being used. + :align: center + + +----------------------------------------------------+---------------------+---------------------+ + | Routine | POWER ITERATION | ARNOLDI ITERATION | + | | | | + +====================================================+=====================+=====================+ + | :c:func:`SUNDomEigEstGetID` | O | O | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstSetATimes` | X | X | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstSetMaxPowerIter` | O | O | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstSetNumPreProcess` | O | O | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstInitialize` | X | X | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstPreProcess` | O | O | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstComputeHess`\ :sup:`1` | N/A | X | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstimate` | X | X | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstNumIters`\ :sup:`2` | O | N/A | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstRes`\ :sup:`3` | O | N/A | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstFree`\ :sup:`4` | | | + +----------------------------------------------------+---------------------+---------------------+ + + +Notes: + +1. :c:func:`SUNDomEigEstComputeHess()` might or might not be required depending on + ``SUNDomEigEstimator`` implementation that is being used. This flag must be left + ``NULL`` if it is not applicable for an estimator. + +2. :c:func:`SUNDomEigEstNumIters()` is only used to accumulate overall + iterative estimator statistics. If it is not implemented by + the ``SUNDomEigEstimator`` module, then IDADEE will consider all + estimates as requiring zero iterations. + +3. Although :c:func:`SUNDomEigEstRes()` is optional, if it is not + implemented by the ``SUNDomEigEstimator`` then IDADEE will consider all + estimates a being *exact*. + +4. Although IDADEE does not call :c:func:`SUNDomEigEstFree()` + directly, this routine should be available for users to call when + cleaning up from a simulation. + +Since there are a wide range of potential SUNDomEigEst use cases, the following +subsections describe some details of the IDADEE interface, in the case that +interested users wish to develop custom SUNDomEigEst modules. diff --git a/doc/idas/guide/source/sundomeigest/SUNDomEigEst_API_link.rst b/doc/idas/guide/source/sundomeigest/SUNDomEigEst_API_link.rst new file mode 100644 index 0000000000..63131049d7 --- /dev/null +++ b/doc/idas/guide/source/sundomeigest/SUNDomEigEst_API_link.rst @@ -0,0 +1,13 @@ +.. ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2025, Lawrence Livermore National Security + and Southern Methodist University. + All rights reserved. + + See the top-level LICENSE and NOTICE files for details. + + SPDX-License-Identifier: BSD-3-Clause + SUNDIALS Copyright End + ---------------------------------------------------------------- + +.. include:: ../../../shared/sundomeigest/SUNDomEigEst_API.rst diff --git a/doc/idas/guide/source/sundomeigest/SUNDomEigEst_links.rst b/doc/idas/guide/source/sundomeigest/SUNDomEigEst_links.rst new file mode 100644 index 0000000000..68de7d1878 --- /dev/null +++ b/doc/idas/guide/source/sundomeigest/SUNDomEigEst_links.rst @@ -0,0 +1,15 @@ +.. ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2025, Lawrence Livermore National Security + and Southern Methodist University. + All rights reserved. + + See the top-level LICENSE and NOTICE files for details. + + SPDX-License-Identifier: BSD-3-Clause + SUNDIALS Copyright End + ---------------------------------------------------------------- + +.. include:: ../../../shared/sundomeigest/SUNDomEigEst_PI.rst +.. include:: ../../../shared/sundomeigest/SUNDomEigEst_ARNI.rst +.. include:: ../../../shared/sundomeigest/SUNDomEigEst_Examples.rst diff --git a/doc/idas/guide/source/sundomeigest/index.rst b/doc/idas/guide/source/sundomeigest/index.rst new file mode 100644 index 0000000000..80c978ad64 --- /dev/null +++ b/doc/idas/guide/source/sundomeigest/index.rst @@ -0,0 +1,23 @@ +.. ---------------------------------------------------------------- + Daniel R. Reynolds @ SMU + ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2025, Lawrence Livermore National Security + and Southern Methodist University. + All rights reserved. + + See the top-level LICENSE and NOTICE files for details. + + SPDX-License-Identifier: BSD-3-Clause + SUNDIALS Copyright End + ---------------------------------------------------------------- + +.. include:: ../../../../shared/sundomeigest/SUNDomEigEst_Introduction.rst + +.. toctree:: + :maxdepth: 1 + + SUNDomEigEst_API_link.rst + IDAS_interface + SUNDomEigEst_links.rst + diff --git a/doc/kinsol/guide/source/sundomeigest/KINSOL_interface.rst b/doc/kinsol/guide/source/sundomeigest/KINSOL_interface.rst new file mode 100644 index 0000000000..34c8681d30 --- /dev/null +++ b/doc/kinsol/guide/source/sundomeigest/KINSOL_interface.rst @@ -0,0 +1,84 @@ +.. ---------------------------------------------------------------- + Programmer(s): Mustafa Aggul @ SMU + ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2025, Lawrence Livermore National Security + and Southern Methodist University. + All rights reserved. + + See the top-level LICENSE and NOTICE files for details. + + SPDX-License-Identifier: BSD-3-Clause + SUNDIALS Copyright End + ---------------------------------------------------------------- + +.. _SUNDomEigEst.KINSOL: + +KINSOL SUNDomEigEstimator interface +============================================== + +In :numref:`SUNDomEigEst.KINSOL.Usage`, we list the SUNDomEigEst module functions used +within the KINDEE interface. We emphasize that the KINSOL user does not need to know +detailed usage of dominant eigenvalue estomator functions by the KINSOL code modules +in order to use KINSOL. The information is presented as an implementation detail for +the interested reader. + +.. _SUNDomEigEst.KINSOL.Usage: +.. table:: List of SUNDomEigEst functions called by the KINSOL dominant eigenvalue + estimator interface, depending on the self-identified "id" reported from + :c:func:`SUNDomEigEstGetID`. Functions marked with "X" are required; + functions marked with "O" are only called if they are non-``NULL`` and + functions marked with "N/A" are not applicable in the ``SUNDomEigEstimator`` + implementation that is being used. + :align: center + + +----------------------------------------------------+---------------------+---------------------+ + | Routine | POWER ITERATION | ARNOLDI ITERATION | + | | | | + +====================================================+=====================+=====================+ + | :c:func:`SUNDomEigEstGetID` | O | O | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstSetATimes` | X | X | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstSetMaxPowerIter` | O | O | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstSetNumPreProcess` | O | O | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstInitialize` | X | X | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstPreProcess` | O | O | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstComputeHess`\ :sup:`1` | N/A | X | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstimate` | X | X | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstNumIters`\ :sup:`2` | O | N/A | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstRes`\ :sup:`3` | O | N/A | + +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstFree`\ :sup:`4` | | | + +----------------------------------------------------+---------------------+---------------------+ + + +Notes: + +1. :c:func:`SUNDomEigEstComputeHess()` might or might not be required depending on + ``SUNDomEigEstimator`` implementation that is being used. This flag must be left + ``NULL`` if it is not applicable for an estimator. + +2. :c:func:`SUNDomEigEstNumIters()` is only used to accumulate overall + iterative estimator statistics. If it is not implemented by + the ``SUNDomEigEstimator`` module, then KINDEE will consider all + estimates as requiring zero iterations. + +3. Although :c:func:`SUNDomEigEstRes()` is optional, if it is not + implemented by the ``SUNDomEigEstimator`` then KINDEE will consider all + estimates a being *exact*. + +4. Although KINDEE does not call :c:func:`SUNDomEigEstFree()` + directly, this routine should be available for users to call when + cleaning up from a simulation. + +Since there are a wide range of potential SUNDomEigEst use cases, the following +subsections describe some details of the KINDEE interface, in the case that +interested users wish to develop custom SUNDomEigEst modules. diff --git a/doc/kinsol/guide/source/sundomeigest/SUNDomEigEst_API_link.rst b/doc/kinsol/guide/source/sundomeigest/SUNDomEigEst_API_link.rst new file mode 100644 index 0000000000..63131049d7 --- /dev/null +++ b/doc/kinsol/guide/source/sundomeigest/SUNDomEigEst_API_link.rst @@ -0,0 +1,13 @@ +.. ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2025, Lawrence Livermore National Security + and Southern Methodist University. + All rights reserved. + + See the top-level LICENSE and NOTICE files for details. + + SPDX-License-Identifier: BSD-3-Clause + SUNDIALS Copyright End + ---------------------------------------------------------------- + +.. include:: ../../../shared/sundomeigest/SUNDomEigEst_API.rst diff --git a/doc/kinsol/guide/source/sundomeigest/SUNDomEigEst_links.rst b/doc/kinsol/guide/source/sundomeigest/SUNDomEigEst_links.rst new file mode 100644 index 0000000000..68de7d1878 --- /dev/null +++ b/doc/kinsol/guide/source/sundomeigest/SUNDomEigEst_links.rst @@ -0,0 +1,15 @@ +.. ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2025, Lawrence Livermore National Security + and Southern Methodist University. + All rights reserved. + + See the top-level LICENSE and NOTICE files for details. + + SPDX-License-Identifier: BSD-3-Clause + SUNDIALS Copyright End + ---------------------------------------------------------------- + +.. include:: ../../../shared/sundomeigest/SUNDomEigEst_PI.rst +.. include:: ../../../shared/sundomeigest/SUNDomEigEst_ARNI.rst +.. include:: ../../../shared/sundomeigest/SUNDomEigEst_Examples.rst diff --git a/doc/kinsol/guide/source/sundomeigest/index.rst b/doc/kinsol/guide/source/sundomeigest/index.rst new file mode 100644 index 0000000000..a7fb4e8d30 --- /dev/null +++ b/doc/kinsol/guide/source/sundomeigest/index.rst @@ -0,0 +1,23 @@ +.. ---------------------------------------------------------------- + Mustafa Aggul @ SMU + ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2025, Lawrence Livermore National Security + and Southern Methodist University. + All rights reserved. + + See the top-level LICENSE and NOTICE files for details. + + SPDX-License-Identifier: BSD-3-Clause + SUNDIALS Copyright End + ---------------------------------------------------------------- + +.. include:: ../../../../shared/sundomeigest/SUNDomEigEst_Introduction.rst + +.. toctree:: + :maxdepth: 1 + + SUNDomEigEst_API_link.rst + KINSOL_interface + SUNDomEigEst_links.rst + diff --git a/doc/shared/sundials.bib b/doc/shared/sundials.bib index 599a901100..68a3cdb7ed 100644 --- a/doc/shared/sundials.bib +++ b/doc/shared/sundials.bib @@ -2645,3 +2645,30 @@ @article{rackauckas2020universal journal={arXiv preprint arXiv:2001.04385}, year={2020} } + +% +% Arnoldi Iteration +% + +@article{arnoldi51, + title={The principle of minimized iterations in the solution of the matrix eigenvalue problem}, + author={Arnoldi, W. E.}, + journal={Quarterly of Applied Mathematics}, + volume={9}, + number={1}, + pages={17--29}, + year={1951} +} + +% +% Power Iteration +% + +@article{vonmises29, + title={Praktische Verfahren der Gleichungsauflösung}, + author={von Mises, Richard and Pollaczek-Geiringer, Hilda}, + journal={Zeitschrift für Angewandte Mathematik und Mechanik}, + volume={9}, + pages={152--164}, + year={1929} +} \ No newline at end of file diff --git a/doc/shared/sundomeigest/SUNDomEigEst_API.rst b/doc/shared/sundomeigest/SUNDomEigEst_API.rst new file mode 100644 index 0000000000..86c07f450c --- /dev/null +++ b/doc/shared/sundomeigest/SUNDomEigEst_API.rst @@ -0,0 +1,552 @@ +.. + Mustafa Aggul @ SMU + ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2025, Lawrence Livermore National Security + and Southern Methodist University. + All rights reserved. + + See the top-level LICENSE and NOTICE files for details. + + SPDX-License-Identifier: BSD-3-Clause + SUNDIALS Copyright End + ---------------------------------------------------------------- + +.. _SUNDomEigEst.API: + +The SUNDomEigEstimator API +============================= + +The SUNDomEigEst API defines several dominant eigenvalue estimation operations that enable +SUNDIALS packages to utilize this API. These functions can be divided into +three categories. The first are the core dominant eigenvalue estimation functions. The +second consist of "set" routines to supply the dominant eigenvalue estimatitor with functions +provided by the SUNDIALS packages and to modify estimator parameters. The +final group consists of "get" routines for retrieving dominant eigenvalue estimation +statistics. All of these functions are defined in the header file +``sundials/sundials_domeigestimator.h``. + + +.. _SUNDomEigEst.CoreFn: + +SUNDomEigEstimator core functions +----------------------------------------------------- + +The core dominant eigenvalue estimatimator functions consist of several **required** +functions: :c:func:`SUNDomEigEstSetATimes` provides a :c:type:`SUNATimesFn` function pointer, +as well as a ``void*`` pointer to a data structure used by this routine, +:c:func:`SUNDomEigEstInitialize` initializes the estimator object once +all estimator-specific options have been set, and :c:func:`SUNDomEigEstimate` estimates +the dominant eigenvalue. + +The remaining **optional** functions returns the estimator ID (:c:func:`SUNDomEigEstGetID`), +preprocess the estimator object to "warm-up" the estimator for a more appropriate initial vector +for iterations (:c:func:`SUNDomEigEstPreProcess`), computes Hessenberg matrix (when necessary) +(:c:func:`SUNDomEigEstComputeHess`), and destroy an estimator object (:c:func:`SUNDomEigEstFree`). + + +.. c:function:: SUNErrCode SUNDomEigEstInitialize(SUNDomEigEstimator DEE) + + *Required.* + + Performs dominant eigenvalue estimatimator initialization (assuming that all + estimator-specific options have been set). + + **Return value:** + + A :c:type:`SUNErrCode`. + + **Usage:** + + .. code-block:: c + + retval = SUNDomEigEstInitialize(DEE); + + +.. c:function:: SUNErrCode SUNDomEigEstComputeHess(SUNDomEigEstimator DEE) + + *Required* for some estimators (ARNOLDI) and *not applicable* for others (POWER) + + Performs Hessenberg matrix computation (assuming that the estimator is + already initialized). + + **Return value:** + + Zero for a successful call, a positive value for a recoverable failure, + and a negative value for an unrecoverable failure. Ideally this should + return one of the generic error codes listed in + :numref:`SUNDomEigEst.ErrorCodes`. + + **Usage:** + + .. code-block:: c + + retval = SUNDomEigEstComputeHess(DEE); + + +.. c:function:: SUNErrCode SUNDomEigEstimate(SUNDomEigEstimator DEE, suncomplextype* dom_eig) + + This *required* function estimates the dominant eigenvalue, + :math:`\lambda_{\max} = \lambda` such that + :math:`|\lambda| = \max\{|\lambda_i| : A \vec{v_i} = \lambda_i \vec{v_i}, \ \vec{v_i} \neq \vec{0} \}`. + + **Arguments:** + + * *DEE* -- a SUNDomEigEst object. + * *dom_eig* -- a ``SUNMatrix`` object. + + **Return value:** + + Zero for a successful call, a positive value for a recoverable failure, + and a negative value for an unrecoverable failure. Ideally this should + return one of the generic error codes listed in + :numref:`SUNDomEigEst.ErrorCodes`. + + **Usage:** + + .. code-block:: c + + retval = SUNDomEigEstimate(DEE, dom_eig); + + + +.. c:function:: SUNErrCode SUNDomEigEstFree(SUNDomEigEstimator DEE) + + Frees memory allocated by the dominant eigenvalue estimatimator. + + **Return value:** + + A :c:type:`SUNErrCode`. + + **Usage:** + + .. code-block:: c + + retval = SUNDomEigEstFree(DEE); + + +.. _SUNDomEigEst.SetFn: + +SUNDomEigEstimator "set" functions +------------------------------------- + +The following functions supply dominant eigenvalue estimatimator modules with +functions defined by the SUNDIALS packages and modify estimator parameters. +Only the routine for setting the matrix-vector product routine is required. +Otherwise, all other set functions are optional. SUNDomEigEst implementations +that do not provide the functionality for any optional routine should leave the corresponding +function pointer ``NULL`` instead of supplying a dummy routine. + + +.. c:function:: SUNErrCode SUNDomEigEstSetATimes(SUNDomEigEstimator DEE, void* A_data, SUNATimesFn ATimes) + + *Required.* + + Provides a :c:type:`SUNATimesFn` function pointer, as well as a ``void*`` + pointer to a data structure used by this routine, to the dominant eigenvalue estimatimator object + *DEE*. SUNDIALS packages call this function to set the matrix-vector product function to either + an estimator-provided difference-quotient via vector operations or a user-supplied + estimator-specific routine. + + **Return value:** + + A :c:type:`SUNErrCode`. + + **Usage:** + + .. code-block:: c + + retval = SUNDomEigEstSetATimes(DEE, A_data, ATimes); + + +.. c:function:: SUNErrCode SUNDomEigEstSetMaxPowerIter(SUNDomEigEstimator DEE, sunindextype max_powiter) + + This *optional* routine sets the number of max power iterations. + + **Return value:** + + A :c:type:`SUNErrCode`. + + **Usage:** + + .. code-block:: c + + retval = SUNDomEigEstSetMaxPowerIter(DEE, max_powiter); + + +.. c:function:: SUNErrCode SUNDomEigEstSetTol(SUNDomEigEstimator DEE, sunrealtype tol) + + This *optional* routine sets the estimator tolerance. + + **Return value:** + + A :c:type:`SUNErrCode`. + + **Usage:** + + .. code-block:: c + + retval = SUNDomEigEstSetTol(DEE, tol); + + +.. c:function:: SUNErrCode SUNDomEigEstPreProcess(SUNDomEigEstimator DEE) + + This *optional* routine executes the "warm-up" matrix-vector multiplications, + whose number is set by (:c:func:`SUNDomEigEstSetNumPreProcess`). + + **Return value:** + + A :c:type:`SUNErrCode`. + + **Usage:** + + .. code-block:: c + + retval = SUNDomEigEstPreProcess(DEE); + + +.. c:function:: SUNErrCode SUNDomEigEstSetNumPreProcess(SUNDomEigEstimator DEE, sunindextype numofperprocess) + + This *optional* routine should set the number of "warm-up" matrix-vector multiplications, + which then should be executed by (:c:func:`SUNDomEigEstPreProcess`). + + **Return value:** + + A :c:type:`SUNErrCode`. + + **Usage:** + + .. code-block:: c + + retval = SUNDomEigEstSetNumPreProcess(DEE, numofperprocess); + + +.. _SUNDomEigEst.GetFn: + +SUNDomEigEstimator "get" functions +---------------------------------- + +The following functions allow SUNDIALS packages to retrieve results from a +dominant eigenvalue estimatimate. *All routines are optional.* + + +.. c:function:: SUNDomEigEstimator_ID SUNDomEigEstGetID(SUNDomEigEstimator DEE) + + This *optional* routine returns a non-negative estimator identifier (of type ``int``) + for the dominant eigenvalue estimator *DEE*. + + **Return value:** + + Non-negative estimator identifier (of type ``int``), defined by the + enumeration ``SUNDomEigEstimator_ID``, with values shown in + :numref:`SUNDomEigEst.API.IDs` and defined in the ``sundials_domeigestimator.h`` + header file. + + **Usage:** + + .. code-block:: c + + id = SUNDomEigEstGetID(DEE); + + .. note:: + + It is recommended that a user-supplied ``SUNDomEigEstimator`` return the + ``SUNDSOMEIGESTIMATOR_CUSTOM`` identifier. + + +.. c:function:: int SUNDomEigEstNumIters(SUNDomEigEstimator DEE) + + This *optional* routine should return the number of estimator + iterations performed in the most-recent "estimator" call. + + **Usage:** + + .. code-block:: c + + its = SUNDomEigEstNumIters(DEE); + + +.. c:function:: sunrealtype SUNDomEigEstRes(SUNDomEigEstimator DEE) + + This *optional* routine should return the final residual from + the most-recent "estimator" call. + + **Usage:** + + .. code-block:: c + + res = SUNDomEigEstRes(DEE); + + +.. _SUNDomEigEst.SUNSuppliedFn: + +Functions provided by SUNDIALS packages +--------------------------------------------- + +To interface with SUNDomEigEst modules, the SUNDIALS packages supply +a routine for evaluating the matrix-vector product. This package-provided +routine translate between the user-supplied ODE, DAE, or linear and nonlinear +systems and the generic dominant eigenvalue estimatimator API. The +function types for these routines are defined in the header file +``sundials/sundials_iterative.h``, and are described below. + + +.. c:type:: int (*SUNATimesFn)(void *A_data, N_Vector v, N_Vector z) + + Computes the action of a matrix on a vector, performing the + operation :math:`z \gets Av`. Memory for *z* will already be + allocated prior to calling this function. The parameter + *A_data* is a pointer to any information about :math:`A` which + the function needs in order to do its job. The vector :math:`v` + should be left unchanged. + + **Return value:** + + Zero for a successful call, and non-zero upon failure. + + +.. _SUNDomEigEst.ReturnCodes: + +SUNDomEigEstimator return codes +------------------------------------ + +The functions provided to SUNDomEigEst modules by each SUNDIALS package, +and functions within the SUNDIALS-provided SUNDomEigEst implementations, +utilize a common set of return codes, listed in +:numref:`SUNDomEigEst.ErrorCodes`. These adhere to a common pattern: + +* 0 indicates success +* a positive value corresponds to a recoverable failure, and +* a negative value indicates a non-recoverable failure. + +Aside from this pattern, the actual values of each error code +provide additional information to the user in case of an estimatitor +failure. + +TODO:Add the right list here! + +.. _SUNDomEigEst.ErrorCodes: +.. table:: SUNDomEigEst error codes + :align: center + + +------------------------------------+-------+---------------------------------------------------+ + | Error code | Value | Meaning | + +====================================+=======+===================================================+ + | ``SUN_SUCCESS`` | 0 | successful call or converged estimate | + +------------------------------------+-------+---------------------------------------------------+ + | ``SUN_ERR_DEE_BAD_NVECTOR`` | -9973 | bad NVector | + +------------------------------------+-------+---------------------------------------------------+ + | ``SUN_ERR_DEE_NULL_ATIMES`` | -9972 | the ``Atimes`` function is ``NULL`` | + +------------------------------------+-------+---------------------------------------------------+ + | ``SUN_ERR_DEE_ATIMES_FAIL_REC`` | -9971 | an unrecoverable failure occurred in the | + | | | ``ATimes`` routine | + +------------------------------------+-------+---------------------------------------------------+ + | ``SUN_ERR_DEE_ATIMES_FAIL_UNREC`` | -9970 | a recoverable failure occurred in the | + | | | ``ATimes`` routine | + +------------------------------------+-------+---------------------------------------------------+ + | ``SUN_ERR_DEE_NULL_HES`` | -9969 | the Hessenberg matrix is ``NULL`` | + +------------------------------------+-------+---------------------------------------------------+ + | ``SUN_ERR_DEE_NULL_MEM`` | -9968 | the DEE memory is ``NULL`` | + +------------------------------------+-------+---------------------------------------------------+ + | ``SUN_ERR_DEE_NULL_CONTENT`` | -9967 | the DEE content is ``NULL`` | + +------------------------------------+-------+---------------------------------------------------+ + | ``SUN_ERR_DEE_LAPACK_FAIL`` | -9966 | LAPACK ``_dgeev`` function failure | + | | | | + +------------------------------------+-------+---------------------------------------------------+ + + + +.. _SUNDomEigEst.Generic: + +The generic SUNDomEigEstimator module +----------------------------------------- + +SUNDIALS packages interact with dominant eigenvalue estimatitor implementations through the +:c:type:`SUNDomEigEstimator` class. A :c:type:`SUNDomEigEstimator` is a pointer to the +:c:struct:`_generic_SUNDomEigEstimator` structure: + +.. c:type:: struct _generic_SUNDomEigEstimator *SUNDomEigEstimator + +.. c:struct:: _generic_SUNDomEigEstimator + + The structure defining the SUNDIALS dominant eigenvalue estimatitor class. + + .. c:member:: void *content + + Pointer to the dominant eigenvalue estimatitor-specific member data + + .. c:member:: SUNDomEigEstimator_Ops ops + + A virtual table of dominant eigenvalue estimatitor operations provided by a specific + implementation + + .. c:member:: SUNContext sunctx + + The SUNDIALS simulation context + +The virtual table structure is defined as + +.. c:type:: struct _generic_SUNDomEigEstimator_Ops *SUNDomEigEstimator_Ops + +.. c:struct:: _generic_SUNDomEigEstimator_Ops + + The structure defining :c:type:`SUNDomEigEstimator` operations. + + .. c:member:: SUNDomEigEstimator_ID (*getid)(SUNDomEigEstimator) + + The function implementing :c:func:`SUNDomEigEstGetID` + + .. c:member:: SUNErrCode (*setatimes)(SUNDomEigEstimator, void*, SUNATimesFn) + + The function implementing :c:func:`SUNDomEigEstSetATimes` + + .. c:member:: SUNErrCode (*setmaxpoweriter)(SUNDomEigEstimator, sunindextype) + + The function implementing :c:func:`SUNDomEigEstSetMaxPowerIter` + + .. c:member:: SUNErrCode (*settol)(SUNDomEigEstimator, sunrealtype) + + The function implementing :c:func:`SUNDomEigEstSetTol` + + .. c:member:: SUNErrCode (*setnumofperprocess)(SUNDomEigEstimator, sunindextype) + + The function implementing :c:func:`SUNDomEigEstSetNumPreProcess` + + .. c:member:: SUNErrCode (*initialize)(SUNDomEigEstimator) + + The function implementing :c:func:`SUNDomEigEstInitialize` + + .. c:member:: SUNErrCode (*preprocess)(SUNDomEigEstimator) + + The function implementing :c:func:`SUNDomEigEstPreProcess` + + .. c:member:: SUNErrCode (*computehess)(SUNDomEigEstimator) + + The function implementing :c:func:`SUNDomEigEstComputeHess` + + .. c:member:: SUNErrCode (*estimate)(SUNDomEigEstimator, suncomplextype*) + + The function implementing :c:func:`SUNDomEigEstimate` + + .. c:member:: sunindextype (*getnumofiters)(SUNDomEigEstimator) + + The function implementing :c:func:`SUNDomEigEstNumIters` + + .. c:member:: sunrealtype (*res)(SUNDomEigEstimator) + + The function implementing :c:func:`SUNDomEigEstRes` + + .. c:member:: SUNErrCode (*free)(SUNDomEigEstimator) + + The function implementing :c:func:`SUNDomEigEstFree` + +The generic SUNDomEigEst class defines and implements the dominant eigenvalue estimatitor +operations defined in :numref:`SUNDomEigEst.CoreFn` -- :numref:`SUNDomEigEst.GetFn`. +These routines are in fact only wrappers to the dominant eigenvalue estimatitor operations +defined by a particular SUNDomEigEst implementation, which are accessed through +the *ops* field of the ``SUNDomEigEstimator`` structure. To illustrate this +point we show below the implementation of a typical dominant eigenvalue estimatitor operation +from the ``SUNDomEigEstimator`` base class, namely :c:func:`SUNDomEigEstInitialize`, +that initializes a ``SUNDomEigEstimator`` object for use after it has been +created and configured, and returns a flag denoting a successful or failed +operation: + +.. code-block:: c + + SUNErrCode SUNDomEigEstInitialize(SUNDomEigEstimator DEE) + { + return ((SUNErrCode) DEE->ops->initialize(DEE)); + } + + +.. _SUNDomEigEst.API.Custom: + +Implementing a custom SUNDomEigEstimator module +-------------------------------------------------- + +A particular implementation of the ``SUNDomEigEstimator`` module must: + +* Specify the *content* field of the SUNDomEigEst module. + +* Define and implement the required dominant eigenvalue estimatitor operations. + + .. note:: + + The names of these routines should be unique to that + implementation in order to permit using more than one + SUNDomEigEst module (each with different ``SUNDomEigEstimator`` + internal data representations) in the same code. + +* Define and implement user-callable constructor and destructor + routines to create and free a ``SUNDomEigEstimator`` with + the new *content* field and with *ops* pointing to the + new dominant eigenvalue estimatitor operations. + +We note that the function pointers for all unsupported optional +routines should be set to ``NULL`` in the *ops* structure. This +allows the SUNDIALS package that is using the SUNDomEigEst object +to know whether the associated functionality is supported. + +To aid in the creation of custom ``SUNDomEigEstimator`` modules the generic +``SUNDomEigEstimator`` module provides the utility function +:c:func:`SUNDomEigEstNewEmpty`. When used in custom ``SUNDomEigEstimator`` +constructors this function will ease the introduction of any new optional dominant +eigenvalue estimatitor operations to the ``SUNDomEigEstimator`` API by ensuring that only required +operations need to be set. + +.. c:function:: SUNDomEigEstimator SUNDomEigEstNewEmpty(SUNContext sunctx) + + This function allocates a new generic ``SUNDomEigEstimator`` object and + initializes its content pointer and the function pointers in the operations + structure to ``NULL``. + + **Return value:** + + If successful, this function returns a ``SUNDomEigEstimator`` object. + If an error occurs when allocating the object, then this routine will + return ``NULL``. + +.. c:function:: void SUNDomEigEstFreeEmpty(SUNDomEigEstimator DEE) + + This routine frees the generic ``SUNDomEigEstimator`` object, under the + assumption that any implementation-specific data that was allocated + within the underlying content structure has already been freed. + It will additionally test whether the ops pointer is ``NULL``, + and, if it is not, it will free it as well. + + **Arguments:** + + * *DEE* -- a SUNDomEigEstimator object + + +Additionally, a ``SUNDomEigEstimator`` implementation *may* do the following: + +* Define and implement additional user-callable "set" routines + acting on the ``SUNDomEigEstimator``, e.g., for setting various + configuration options to tune the dominant eigenvalue estimatitor + for a particular problem. + +* Provide additional user-callable "get" routines acting on the + ``SUNDomEigEstimator`` object, e.g., for returning various estimator + statistics. + + +.. c:enum:: SUNDomEigEstimator_ID + + Each SUNDomEigEst implementation included in SUNDIALS has a unique identifier + specified in enumeration and shown in :numref:`SUNDomEigEst.API.IDs`. It is + recommended that a user-supplied SUNDomEigEst implementation use the + ``SUNDSOMEIGESTIMATOR_CUSTOM`` identifier. + +.. _SUNDomEigEst.API.IDs: +.. table:: Identifiers associated with :c:type:`SUNDomEigEstimator` + modules supplied with SUNDIALS + :align: center + + ================================== ======================================================= ============ + SUNDomEigEst ID Dominant eigenvalue estimatitor type ID Value + ================================== ======================================================= ============ + SUNDSOMEIGESTIMATOR_POWER Power Iteration (internal) 0 + SUNDSOMEIGESTIMATOR_ARNOLDI Arnoldi Iteration (internal) 1 + SUNDSOMEIGESTIMATOR_CUSTOM User-provided custom dominant eigenvalue estimatitor 15 + ================================== ======================================================= ============ \ No newline at end of file diff --git a/doc/shared/sundomeigest/SUNDomEigEst_ARNI.rst b/doc/shared/sundomeigest/SUNDomEigEst_ARNI.rst new file mode 100644 index 0000000000..b71b6a9aab --- /dev/null +++ b/doc/shared/sundomeigest/SUNDomEigEst_ARNI.rst @@ -0,0 +1,172 @@ +.. + Programmer(s): Mustafa Aggul @ SMU + ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2025, Lawrence Livermore National Security + and Southern Methodist University. + All rights reserved. + + See the top-level LICENSE and NOTICE files for details. + + SPDX-License-Identifier: BSD-3-Clause + SUNDIALS Copyright End + ---------------------------------------------------------------- + +.. _SUNDomEigEst.ARNI: + +The SUNDomEigEst_ARNI Module +====================================== + +The SUNDomEigEst_ARNI implementation of the ``SUNDomEigEstimator`` class performs +the Arnoldi Iteration :cite:p:`arnoldi51` method; this is an iterative dominant +eigenvalue estimator that is designed to be compatible with any ``N_Vector`` +implementation that supports a minimal subset of operations + +TODO:Check the list. +(:c:func:`N_VClone()`, :c:func:`N_VDotProd()`, :c:func:`N_VScale()`, +:c:func:`N_VLinearSum()`, :c:func:`N_VProd()`, and +:c:func:`N_VDestroy()`). ARNI requires a prefixed amount of +memory that depends on the user provided dimension of Krylov subspaces. + +The matrix :math:`A` is not required explicitly; only routines +that provide :math:`A` as operator is required. + + +.. _SUNDomEigEst.ARNI.Usage: + +SUNDomEigEst_ARNI Usage +--------------------- + +The header file to be included when using this module is +``sundomeigest/sundomeigest_arni.h``. The SUNDomEigEst_ARNI module is accessible from all SUNDIALS solvers +*without* linking to the ``libsundials_sundomeigestarni`` module library after enabling LAPACK package. +This LAPACK dependence is limitted to the ``dgeev_`` function after computing Hessenberg matrix internally. + +The module SUNDomEigEst_ARNI provides the following user-callable routines: + + +.. c:function:: SUNDomEigEstimator SUNDomEigEst_ArnI(N_Vector q, sunindextype krydim, SUNContext sunctx) + + This constructor function creates and allocates memory for an ARNI + ``SUNDomEigEstimator``. + + **Arguments:** + * *q* -- a template vector. + * *krydim* -- the dimension of the Krylov subspaces. + * *sunctx* -- the :c:type:`SUNContext` object (see :numref:`SUNDIALS.SUNContext`) + + **Return value:** + If successful, a ``SUNDomEigEstimator`` object. If *q* is + incompatible, this routine will return ``NULL``. + + **Notes:** + This routine will perform consistency checks to ensure that it is + called with a consistent ``N_Vector`` implementation (i.e. that it + supplies the requisite vector operations). + + A ``krydim`` argument that is :math:`\leq 2` will result in the default + value (3). + + +.. c:function:: SUNErrCode SUNDomEigEstComputeHess_ArnI(SUNDomEigEstimator DEE) + + This function computes the Hessenberg matrix. + + **Return value:** + + A :c:type:`SUNErrCode`. + + **Notes:** + This routine can be called with (:c:func:`SUNDomEigEstPreProcess`) as well. + It must be called after initialization (:c:func:`SUNDomEigEstInitialize`), + and also preprocess (if requested) should be performed (:c:func:`SUNDomEigEstPreProcess`) + before calling this function. + + +.. _SUNDomEigEst.ARNI.Description: + +SUNDomEigEst_ARNI Description +--------------------------- + + +The SUNDomEigEst_ARNI module defines the *content* field of a +``SUNDomEigEstimator`` to be the following structure: + +.. code-block:: c + + struct _SUNDomEigEstimatorContent_ArnI { + SUNATimesFn ATimes; + void* ATdata; + N_Vector* V; + N_Vector q; + sunindextype krydim; + sunindextype power_of_A; + sunrealtype* LAPACK_A; + sunrealtype* LAPACK_wr; + sunrealtype* LAPACK_wi; + sunrealtype* LAPACK_work; + suncomplextype* LAPACK_arr; + sunrealtype** Hes; + }; + + +These entries of the *content* field contain the following +information: + +* ``ATimes`` - function pointer to perform :math:`Av` product, + +* ``ATData`` - pointer to structure for ``ATimes``, + +* ``V, q`` - ``N_Vector`` used for workspace by the ARNI algorithm. + +* ``krydim`` - dimension of Krylov subspaces (default is 3), + +* ``power_of_A`` - number of preprocessing (default is 0), + +* ``LAPACK_A, LAPACK_wr, LAPACK_wi, LAPACK_work`` - ``sunrealtype`` used for workspace by LAPACK, + +* ``LAPACK_arr`` - ``suncomplextype`` used for workspace by LAPACK, + +* ``Hes`` - Hessenberg matrix, + + +This estimator is constructed to perform the following operations: + +* During construction all ``N_Vector`` estimator data is allocated, with + vectors cloned from a template ``N_Vector`` that is input, and + default generic estimator parameters are set. + +* User-facing "set" routines may be called to modify default + estimator parameters. + +* Additional "set" routines are called by the SUNDIALS estimator + that interfaces with SUNDomEigEst_ARNI to supply the + ``ATimes`` function pointers and the related data ``ATData``. + +* In the "initialize" call, the estimator parameters are checked + for validity and ARNI estimator memory is allocated. + +* In the "preprocess" call, the initial random vector :math:`q_0` is warmed up + :math:`k=` ``power_of_A`` times as :math:`q_1 = \frac{Aq_0}{||Aq_0||} \cdots q_k = \frac{Aq_{k-1}}{||Aq_{k-1}||}`. + +* In the "estimate" call the ARNI estimator is performed. + +The SUNDomEigEst_ARNI module defines implementations of all +dominant eigenvalue estimator operations listed in +:numref:`SUNDomEigEst.API`: + +* ``SUNDomEigEst_ArnIGetID`` + +* ``SUNDomEigEstSetATimes_ArnI`` + +* ``SUNDomEigEstInitialize_ArnI`` + +* ``SUNDomEigEstSetNumPreProcess_ArnI`` + +* ``SUNDomEigEstPreProcess_ArnI`` + +* ``SUNDomEigEstComputeHess_ArnI`` + +* ``SUNDomEigEstimate_ArnI`` + +* ``SUNDomEigEstFree_ArnI`` diff --git a/doc/shared/sundomeigest/SUNDomEigEst_Examples.rst b/doc/shared/sundomeigest/SUNDomEigEst_Examples.rst new file mode 100644 index 0000000000..832d3b4db1 --- /dev/null +++ b/doc/shared/sundomeigest/SUNDomEigEst_Examples.rst @@ -0,0 +1,65 @@ +.. + Programmer(s): Mustafa Aggul @ SMU + ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2025, Lawrence Livermore National Security + and Southern Methodist University. + All rights reserved. + + See the top-level LICENSE and NOTICE files for details. + + SPDX-License-Identifier: BSD-3-Clause + SUNDIALS Copyright End + ---------------------------------------------------------------- + +.. _SUNDomEigEst.Examples: + +SUNDomEigEstimator Examples +====================================== + +There are ``SUNDomEigEstimator`` examples that may be installed for each +implementation; these make use of the functions in ``test_sundomeigest.c``. +These example functions show simple usage of the ``SUNDomEigEstimator`` family +of modules. The inputs to the examples depend on the estimator type, +and are output to ``stdout`` if the example is run without the +appropriate number of command-line arguments. + +The following is a list of the example functions in ``test_sundomeigest.c``: + +* ``Test_SUNDomEigEstGetID``: Verifies the returned estimator identifier against + the value that should be returned. + +* ``Test_SUNDomEigEstSetATimes`` Verifies that ``SUNDomEigEstSetATimes`` can + be called and returns successfully. + +* ``Test_SUNDomEigEstSetNumPreProcess`` Verifies that + ``SUNDomEigEstSetNumPreProcess`` can be called and returns successfully. + +* ``Test_SUNDomEigEstInitialize``: Verifies that ``SUNDomEigEstInitialize`` + can be called and returns successfully. + +* ``Test_SUNDomEigEstPreProcess``: Verifies that ``SUNDomEigEstPreProcess`` + can be called and returns successfully. + +* ``Test_SUNDomEigEstComputeHess``: Verifies that ``SUNDomEigEstComputeHess`` + can be called and returns successfully. + +* ``Test_SUNDomEigEstimate``: Verifies that ``SUNDomEigEstimate`` + can be called and returns successfully. Estimated dominant eigenvalue is + :math:`\lambda_{\max} = \lambda` such that + :math:`|\lambda| = \max\{|\lambda_i| : A \vec{v_i} = \lambda_i \vec{v_i}, \ \vec{v_i} \neq \vec{0} \}`. + This test compares the estimated dominant eigenvalue to the known value + and returns a passing flag if the estimation is within a specified relative + tolerance; otherwise, it returns a failure flag. + + +We'll note that these tests should be performed in a particular +order. For all estimators, +``Test_SUNDomEigEstSetATimes`` must be called +before ``Test_SUNDomEigEstInitialize``, which must be called +before ``Test_SUNDomEigEstPreProcess`` (if applicable). +``Test_SUNDomEigEstComputeHess`` (if the estimator requires) +must be called next and before ``Test_SUNDomEigEstimate``. +For the estimator stats ``Test_SUNDomEigEstNumIters`` and ``Test_SUNDomEigEstRes`` +should be called after ``Test_SUNDomEigEstimate``. +These are called in the appropriate order in all of the example problems. diff --git a/doc/shared/sundomeigest/SUNDomEigEst_Introduction.rst b/doc/shared/sundomeigest/SUNDomEigEst_Introduction.rst new file mode 100644 index 0000000000..76bab4d554 --- /dev/null +++ b/doc/shared/sundomeigest/SUNDomEigEst_Introduction.rst @@ -0,0 +1,63 @@ +.. ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2025, Lawrence Livermore National Security + and Southern Methodist University. + All rights reserved. + + See the top-level LICENSE and NOTICE files for details. + + SPDX-License-Identifier: BSD-3-Clause + SUNDIALS Copyright End + ---------------------------------------------------------------- + +.. _SUNDomEigEst: + +############################## +Dominant Eigenvalue Estimators +############################## + +For problems that require the dominant eigenvalue of a matrix (Jacobian), +the SUNDIALS packages operate using generic dominant eigenvalue estimator modules +defined through the :c:type:`SUNDomEigEstimator`, or "SUNDomEigEst", API. +This allows SUNDIALS packages to utilize any valid SUNDomEigEst +implementation that provides a set of required functions. These +functions can be divided into three categories. The first are the core +estimator functions. The second group consists of "set" routines +to supply the dominant eigenvalue estimator object with functions provided by the +SUNDIALS package, or for modification of estimator parameters. The last +group consists of "get" routines for retrieving artifacts (statistics, +residual, etc.) from the estimator. All of these functions +are defined in the header file ``sundials/sundials_domeigestimator.h``. + +The implementations provided with SUNDIALS work in coordination +with the SUNDIALS :c:type:`N_Vector`, and optionally :c:type:`SUNMatrix`, +modules to provide a set of compatible data structures for the estimator. +Moreover, advanced users can provide a customized ``SUNDomEigEstimator`` +implementation to any SUNDIALS package, particularly in cases where they +provide their own ``N_Vector`` and/or ``SUNMatrix`` modules. + +While Krylov-based estimators preset the number of Krylov subspace +dimensions, resulting in a tolerance-free estimation, SUNDIALS requires +that iterative estimators stop when the residual meets a prescribed +tolerance, i.e., + +.. math:: + + ||\lambda_{k+1} - \lambda_k|| < \text{tol}. + +For users interested in providing their own SUNDomEigEst module, the +following section presents the SUNDomEigEst API and its implementation +beginning with the definition of SUNDomEigEst functions in +:numref:`SUNDomEigEst.CoreFn` -- :numref:`SUNDomEigEst.GetFn`. This is followed by +the definition of functions supplied to an estimator implementation in +:numref:`SUNDomEigEst.SUNSuppliedFn`. The estimator return codes are described +in :numref:`SUNDomEigEst.ErrorCodes`. The ``SUNDomEigEstimator`` type and the +generic SUNDomEigEst module are defined in :numref:`SUNDomEigEst.Generic`. +:numref:`SUNDomEigEst.API.Custom` lists the requirements for supplying a custom +SUNDomEigEst module and discusses some intended use cases. Users wishing to +supply their own SUNDomEigEst module are encouraged to use the SUNDomEigEst +implementations provided with SUNDIALS as a template for supplying custom +dominant eigenvalue estimator modules. The section that then follows describes +the SUNDomEigEst functions required by this SUNDIALS package, and provides +additional package specific details. Then the remaining sections of this +chapter present the SUNDomEigEst modules provided with SUNDIALS. diff --git a/doc/shared/sundomeigest/SUNDomEigEst_PI.rst b/doc/shared/sundomeigest/SUNDomEigEst_PI.rst new file mode 100644 index 0000000000..7028119cbe --- /dev/null +++ b/doc/shared/sundomeigest/SUNDomEigEst_PI.rst @@ -0,0 +1,157 @@ +.. + Programmer(s): Mustafa Aggul @ SMU + ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2025, Lawrence Livermore National Security + and Southern Methodist University. + All rights reserved. + + See the top-level LICENSE and NOTICE files for details. + + SPDX-License-Identifier: BSD-3-Clause + SUNDIALS Copyright End + ---------------------------------------------------------------- + +.. _SUNDomEigEst.PI: + +The SUNDomEigEst_PI Module +====================================== + +The SUNDomEigEst_PI implementation of the ``SUNDomEigEstimator`` class performs +the Power Iteration :cite:p:`vonmises29` method; this is an iterative dominant +eigenvalue estimator that is designed to be compatible with any ``N_Vector`` +implementation that supports a minimal subset of operations + +TODO:Check the list. +(:c:func:`N_VClone()`, :c:func:`N_VDotProd()`, :c:func:`N_VScale()`, +:c:func:`N_VLinearSum()`, :c:func:`N_VProd()`, and +:c:func:`N_VDestroy()`). PI requires a fixed amount of memory regardless of +the number of Iterations. + +The matrix :math:`A` is not required explicitly; only routines +that provide :math:`A` as operator is required. + + +.. _SUNDomEigEst.PI.Usage: + +SUNDomEigEst_PI Usage +--------------------- + +The header file to be included when using this module is +``sundomeigest/sundomeigest_pi.h``. The SUNDomEigEst_PI module is accessible from all SUNDIALS solvers +*without* linking to the ``libsundials_sundomeigestpi`` module library. + +The module SUNDomEigEst_PI provides the following user-callable routines: + + +.. c:function:: SUNDomEigEstimator SUNDomEigEst_PI(N_Vector q, sunindextype max_powiter, SUNContext sunctx) + + This constructor function creates and allocates memory for a PI + ``SUNDomEigEstimator``. + + **Arguments:** + * *q* -- a template vector. + * *max_powiter* -- maximum number of power iterations. + * *sunctx* -- the :c:type:`SUNContext` object (see :numref:`SUNDIALS.SUNContext`) + + **Return value:** + If successful, a ``SUNDomEigEstimator`` object. If *q* is + incompatible, this routine will return ``NULL``. + + **Notes:** + This routine will perform consistency checks to ensure that it is + called with a consistent ``N_Vector`` implementation (i.e. that it + supplies the requisite vector operations). + + A ``max_powiter`` argument that is :math:`\le0` will result in the default + value (100). + + +.. _SUNDomEigEst.PI.Description: + +SUNDomEigEst_PI Description +--------------------------- + + +The SUNDomEigEst_PI module defines the *content* field of a +``SUNDomEigEstimator`` to be the following structure: + +.. code-block:: c + + struct _SUNDomEigEstimatorContent_PI { + SUNATimesFn ATimes; + void* ATdata; + N_Vector* V; + N_Vector q; + sunindextype max_powiter; + sunindextype power_of_A; + sunrealtype powiter_tol; + sunrealtype res; + sunindextype numiters; + }; + + +These entries of the *content* field contain the following +information: + +* ``ATimes`` - function pointer to perform :math:`Av` product, + +* ``ATData`` - pointer to structure for ``ATimes``, + +* ``V, q`` - ``N_Vector`` used for workspace by the PI algorithm. + +* ``max_powiter`` - maximum number of power iterations (default is 100), + +* ``power_of_A`` - number of preprocessing (default is 0), + +* ``powiter_tol`` - convergence criteria for the power iteration (default is 0.01), + +* ``res`` - current residual of power iterations, + +* ``numiters`` - current number of power iterations. + + +This estimator is constructed to perform the following operations: + +* During construction all ``N_Vector`` estimator data is allocated, with + vectors cloned from a template ``N_Vector`` that is input, and + default generic estimator parameters are set. + +* User-facing "set" routines may be called to modify default + estimator parameters. + +* Additional "set" routines are called by the SUNDIALS estimator + that interfaces with SUNDomEigEst_PI to supply the + ``ATimes`` function pointers and the related data ``ATData``. + +* In the "initialize" call, the estimator parameters are checked + for validity and PI estimator memory is allocated. + +* In the "preprocess" call, the initial random vector :math:`q_0` is warmed up + :math:`k=` ``power_of_A`` times as :math:`q_1 = \frac{Aq_0}{||Aq_0||} \cdots q_k = \frac{Aq_{k-1}}{||Aq_{k-1}||}`. + +* In the "estimate" call the PI estimator is performed. + +The SUNDomEigEst_PI module defines implementations of all +dominant eigenvalue estimator operations listed in +:numref:`SUNDomEigEst.API`: + +* ``SUNDomEigEst_PIGetID`` + +* ``SUNDomEigEstSetATimes_PI`` + +* ``SUNDomEigEstInitialize_PI`` + +* ``SUNDomEigEstSetNumPreProcess_PI`` + +* ``SUNDomEigEst_PISetMaxPowerIter`` + +* ``SUNDomEigEstPreProcess_PI`` + +* ``SUNDomEigEstimate_PI`` + +* ``SUNDomEigEstNumIters_PI`` + +* ``SUNDomEigEstRes_PI`` + +* ``SUNDomEigEstFree_PI`` diff --git a/doc/sundials/biblio.bib b/doc/sundials/biblio.bib index 420b7e8a58..8ffe13abe5 100644 --- a/doc/sundials/biblio.bib +++ b/doc/sundials/biblio.bib @@ -1659,3 +1659,30 @@ @article{edwards2014kokkos issn = {0743-7315}, doi = {10.1016/j.jpdc.2014.07.003} } + +% +% Arnoldi Iteration +% + +@article{arnoldi51, + title={The principle of minimized iterations in the solution of the matrix eigenvalue problem}, + author={Arnoldi, W. E.}, + journal={Quarterly of Applied Mathematics}, + volume={9}, + number={1}, + pages={17--29}, + year={1951} +} + +% +% Power Iteration +% + +@article{vonmises29, + title={Praktische Verfahren der Gleichungsauflösung}, + author={von Mises, Richard and Pollaczek-Geiringer, Hilda}, + journal={Zeitschrift für Angewandte Mathematik und Mechanik}, + volume={9}, + pages={152--164}, + year={1929} +} \ No newline at end of file diff --git a/doc/superbuild/source/index.rst b/doc/superbuild/source/index.rst index ab4d377820..b7bf2c3c6c 100644 --- a/doc/superbuild/source/index.rst +++ b/doc/superbuild/source/index.rst @@ -189,6 +189,7 @@ SUNDIALS License and Notices sunmatrix/index.rst sunlinsol/index.rst sunnonlinsol/index.rst + sundomeigest/index.rst sunadaptcontroller/index.rst sunstepper/index.rst sunadjoint/index.rst diff --git a/doc/superbuild/source/sundomeigest/SUNDomEigEst_API_link.rst b/doc/superbuild/source/sundomeigest/SUNDomEigEst_API_link.rst new file mode 100644 index 0000000000..63131049d7 --- /dev/null +++ b/doc/superbuild/source/sundomeigest/SUNDomEigEst_API_link.rst @@ -0,0 +1,13 @@ +.. ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2025, Lawrence Livermore National Security + and Southern Methodist University. + All rights reserved. + + See the top-level LICENSE and NOTICE files for details. + + SPDX-License-Identifier: BSD-3-Clause + SUNDIALS Copyright End + ---------------------------------------------------------------- + +.. include:: ../../../shared/sundomeigest/SUNDomEigEst_API.rst diff --git a/doc/superbuild/source/sundomeigest/SUNDomEigEst_links.rst b/doc/superbuild/source/sundomeigest/SUNDomEigEst_links.rst new file mode 100644 index 0000000000..68de7d1878 --- /dev/null +++ b/doc/superbuild/source/sundomeigest/SUNDomEigEst_links.rst @@ -0,0 +1,15 @@ +.. ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2025, Lawrence Livermore National Security + and Southern Methodist University. + All rights reserved. + + See the top-level LICENSE and NOTICE files for details. + + SPDX-License-Identifier: BSD-3-Clause + SUNDIALS Copyright End + ---------------------------------------------------------------- + +.. include:: ../../../shared/sundomeigest/SUNDomEigEst_PI.rst +.. include:: ../../../shared/sundomeigest/SUNDomEigEst_ARNI.rst +.. include:: ../../../shared/sundomeigest/SUNDomEigEst_Examples.rst diff --git a/doc/superbuild/source/sundomeigest/SUNDomEigEst_package_links.rst b/doc/superbuild/source/sundomeigest/SUNDomEigEst_package_links.rst new file mode 100644 index 0000000000..f5059d03ad --- /dev/null +++ b/doc/superbuild/source/sundomeigest/SUNDomEigEst_package_links.rst @@ -0,0 +1,19 @@ +.. + ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2025, Lawrence Livermore National Security + and Southern Methodist University. + All rights reserved. + + See the top-level LICENSE and NOTICE files for details. + + SPDX-License-Identifier: BSD-3-Clause + SUNDIALS Copyright End + ---------------------------------------------------------------- + +.. include:: ../../../arkode/guide/source/sundomeigest/ARKODE_interface.rst +.. include:: ../../../cvode/guide/source/sundomeigest/CVODE_interface.rst +.. include:: ../../../cvodes/guide/source/sundomeigest/CVODES_interface.rst +.. include:: ../../../ida/guide/source/sundomeigest/IDA_interface.rst +.. include:: ../../../idas/guide/source/sundomeigest/IDAS_interface.rst +.. include:: ../../../kinsol/guide/source/sundomeigest/KINSOL_interface.rst \ No newline at end of file diff --git a/doc/superbuild/source/sundomeigest/index.rst b/doc/superbuild/source/sundomeigest/index.rst new file mode 100644 index 0000000000..465400617a --- /dev/null +++ b/doc/superbuild/source/sundomeigest/index.rst @@ -0,0 +1,22 @@ +.. + Mustafa Aggul @ SMU + ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2025, Lawrence Livermore National Security + and Southern Methodist University. + All rights reserved. + + See the top-level LICENSE and NOTICE files for details. + + SPDX-License-Identifier: BSD-3-Clause + SUNDIALS Copyright End + ---------------------------------------------------------------- + +.. include:: ../../../shared/sundomeigest/SUNDomEigEst_Introduction.rst + +.. toctree:: + :maxdepth: 1 + + SUNDomEigEst_API_link.rst + SUNDomEigEst_package_links.rst + SUNDomEigEst_links.rst \ No newline at end of file diff --git a/include/sundials/sundials_domeigestimator.h b/include/sundials/sundials_domeigestimator.h index 63eb21b807..9b94ff0792 100644 --- a/include/sundials/sundials_domeigestimator.h +++ b/include/sundials/sundials_domeigestimator.h @@ -43,9 +43,9 @@ typedef struct typedef enum { - SUNDOMEIG_POWER, - SUNDOMEIG_ARNOLDI -} SUNDomEigEstimator_Type; + SUNDSOMEIGESTIMATOR_POWER, + SUNDSOMEIGESTIMATOR_ARNOLDI +} SUNDomEigEstimator_ID; /* ----------------------------------------------------------------- * Generic definition of SUNDomEigEstimator @@ -60,15 +60,17 @@ typedef _SUNDIALS_STRUCT_ _generic_SUNDomEigEstimator* SUNDomEigEstimator; /* Structure containing function pointers to estimator operations */ struct _generic_SUNDomEigEstimator_Ops { - SUNDomEigEstimator_Type (*gettype)(SUNDomEigEstimator); + SUNDomEigEstimator_ID (*getid)(SUNDomEigEstimator); SUNErrCode (*setatimes)(SUNDomEigEstimator, void*, SUNATimesFn); SUNErrCode (*setmaxpoweriter)(SUNDomEigEstimator, sunindextype); SUNErrCode (*setnumofperprocess)(SUNDomEigEstimator, sunindextype); + SUNErrCode (*settol)(SUNDomEigEstimator, sunrealtype); SUNErrCode (*initialize)(SUNDomEigEstimator); SUNErrCode (*preprocess)(SUNDomEigEstimator); SUNErrCode (*computehess)(SUNDomEigEstimator); SUNErrCode (*estimate)(SUNDomEigEstimator, suncomplextype*); - sunindextype (*getnumofiters)(SUNDomEigEstimator); + SUNErrCode (*getnumofiters)(SUNDomEigEstimator, sunindextype*); + SUNErrCode (*getres)(SUNDomEigEstimator, sunrealtype*); SUNErrCode (*free)(SUNDomEigEstimator); }; @@ -93,15 +95,22 @@ SUNDIALS_EXPORT void SUNDomEigEstFreeEmpty(SUNDomEigEstimator DEE); SUNDIALS_EXPORT -SUNDomEigEstimator_Type SUNDomEigEstGetType(SUNDomEigEstimator DEE); +SUNDomEigEstimator_ID SUNDomEigEstGetID(SUNDomEigEstimator DEE); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstSetATimes(SUNDomEigEstimator DEE, void* A_data, SUNATimesFn ATimes); +SUNDIALS_EXPORT +SUNErrCode SUNDomEigEstSetMaxPowerIter(SUNDomEigEstimator DEE, + sunindextype max_powiter); + SUNDIALS_EXPORT SUNErrCode SUNDomEigEstSetNumPreProcess(SUNDomEigEstimator DEE, - sunindextype numofperprocess); + sunindextype numofperprocess); + +SUNDIALS_EXPORT +SUNErrCode SUNDomEigEstSetTol(SUNDomEigEstimator DEE, sunrealtype tol); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstInitialize(SUNDomEigEstimator DEE); @@ -115,6 +124,12 @@ SUNErrCode SUNDomEigEstComputeHess(SUNDomEigEstimator DEE); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstimate(SUNDomEigEstimator DEE, suncomplextype* dom_eig); +SUNDIALS_EXPORT +SUNErrCode SUNDomEigEstNumIters(SUNDomEigEstimator DEE, sunindextype* niter); + +SUNDIALS_EXPORT +SUNErrCode SUNDomEigEstRes(SUNDomEigEstimator DEE, sunrealtype* res); + #ifdef __cplusplus } #endif diff --git a/include/sundials/sundials_errors.h b/include/sundials/sundials_errors.h index 0709d1d843..dbd46b83c3 100644 --- a/include/sundials/sundials_errors.h +++ b/include/sundials/sundials_errors.h @@ -70,14 +70,14 @@ ENTRY(SUN_ERR_CHECKPOINT_MISMATCH, "the expected time for the checkpoint " \ "and the stored time do not match") \ \ - ENTRY(SUN_ERR_DOMEIG_BAD_NVECTOR, "Bad NVector") \ - ENTRY(SUN_ERR_DOMEIG_NULL_ATIMES, "ATimes is null") \ - ENTRY(SUN_ERR_DOMEIG_NULL_HES, "Hessenberg matrix is null") \ - ENTRY(SUN_ERR_DOMEIG_NOT_ENOUGH_ITER, "Number of Krylov subspace is not " \ - "enough (< 2)") \ - ENTRY(SUN_ERR_DOMEIG_ATIMES_FAIL_REC, "Atimes recoverable failure") \ - ENTRY(SUN_ERR_DOMEIG_ATIMES_FAIL_UNREC, "Atimes unrecoverable failure") \ - ENTRY(SUN_ERR_DOMEIG_LAPACK_FAIL, "LAPACK dgeev function failure") \ + ENTRY(SUN_ERR_DEE_BAD_NVECTOR, "Bad NVector") \ + ENTRY(SUN_ERR_DEE_NULL_ATIMES, "ATimes is null") \ + ENTRY(SUN_ERR_DEE_ATIMES_FAIL_REC, "Atimes recoverable failure") \ + ENTRY(SUN_ERR_DEE_ATIMES_FAIL_UNREC, "Atimes unrecoverable failure") \ + ENTRY(SUN_ERR_DEE_NULL_HES, "Hessenberg matrix is null") \ + ENTRY(SUN_ERR_DEE_NULL_MEM, "Domimant eigenvalue estimator memory is null") \ + ENTRY(SUN_ERR_DEE_NULL_CONTENT, "DDE content is null") \ + ENTRY(SUN_ERR_DEE_LAPACK_FAIL, "LAPACK _dgeev function failure") \ \ ENTRY(SUN_ERR_SUNCTX_CORRUPT, "SUNContext is NULL or corrupt") \ \ diff --git a/include/sundomeigest/sundomeigest_arni.h b/include/sundomeigest/sundomeigest_arni.h index c73c63b4d7..19717d00ab 100644 --- a/include/sundomeigest/sundomeigest_arni.h +++ b/include/sundomeigest/sundomeigest_arni.h @@ -31,7 +31,7 @@ extern "C" { #endif /* Default Arnoldi Iteration parameters */ -#define SUNDOMEIGEST_ARN_MAXL_DEFAULT 3 +#define SUNDOMEIGEST_ARN_KRYLDIM_DEFAULT 3 #define SUNDOMEIGEST_PI_POWER_OF_A_DEFAULT 10 #define SUNDOMEIGEST_LAPACK_FAIL "Error: LAPACK dgeev failed with info = %d\n" @@ -46,7 +46,7 @@ struct _SUNDomEigEstimatorContent_ArnI N_Vector *V, q; /* Krylov subspace vectors */ - sunindextype maxl; /* Krylov subspace dimension */ + sunindextype krydim; /* Krylov subspace dimension */ sunindextype power_of_A; /* Power of A in the preprocessing; initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ sunrealtype* LAPACK_A; /* The vector which holds rows of the Hessenberg matrix in the given order */ @@ -65,11 +65,11 @@ typedef struct _SUNDomEigEstimatorContent_ArnI* SUNDomEigEstimatorContent_ArnI; * --------------------------------------- */ SUNDIALS_EXPORT -SUNDomEigEstimator SUNDomEigEst_ArnI(N_Vector q, sunindextype maxl, +SUNDomEigEstimator SUNDomEigEst_ArnI(N_Vector q, sunindextype krydim, SUNContext sunctx); SUNDIALS_EXPORT -SUNDomEigEstimator_Type SUNDomEigEst_ArnIGetType(SUNDomEigEstimator DEE); +SUNDomEigEstimator_ID SUNDomEigEst_ArnIGetID(SUNDomEigEstimator DEE); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstSetATimes_ArnI(SUNDomEigEstimator DEE, void* A_data, @@ -80,7 +80,7 @@ SUNErrCode SUNDomEigEstInitialize_ArnI(SUNDomEigEstimator DEE); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstSetNumPreProcess_ArnI(SUNDomEigEstimator DEE, - sunindextype numofperprocess); + sunindextype numofperprocess); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstPreProcess_ArnI(SUNDomEigEstimator DEE); @@ -95,9 +95,6 @@ SUNErrCode SUNDomEigEstimate_ArnI(SUNDomEigEstimator DEE, SUNDIALS_EXPORT SUNErrCode SUNDomEigEstFree_ArnI(SUNDomEigEstimator DEE); -SUNDIALS_EXPORT -sunindextype SUNDomEigEstNumIters_ArnI(SUNDomEigEstimator DEE); - #ifdef __cplusplus } #endif diff --git a/include/sundomeigest/sundomeigest_pi.h b/include/sundomeigest/sundomeigest_pi.h index bf0120c58a..3fe113202f 100644 --- a/include/sundomeigest/sundomeigest_pi.h +++ b/include/sundomeigest/sundomeigest_pi.h @@ -32,7 +32,7 @@ extern "C" { /* Default Power Iteration parameters */ #define SUNDOMEIGEST_PI_TOL_DEFAULT SUN_RCONST(0.01) #define SUNDOMEIGEST_MAX_PI_DEFAULT 100 -#define SUNDOMEIGEST_PI_POWER_OF_A_DEFAULT 10 +#define SUNDOMEIGEST_PI_POWER_OF_A_DEFAULT 0 /* ----------------------------------------------------- * Power Iteration Implementation of SUNDomEigEstimator @@ -48,9 +48,9 @@ struct _SUNDomEigEstimatorContent_PI sunindextype power_of_A; /* Power of A in the preprocessing; initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ sunrealtype powiter_tol; /* Convergence criteria for the power iteration */ - sunrealtype resnorm; /* Current residual of power iterations */ + sunrealtype res; /* Current residual of power iterations */ sunindextype max_powiter; /* Maximum number of power iterations */ - sunindextype numiters; /* Number of power iterations */ + sunindextype numiters; /* Current number of power iterations */ }; typedef struct _SUNDomEigEstimatorContent_PI* SUNDomEigEstimatorContent_PI; @@ -64,18 +64,21 @@ SUNDomEigEstimator SUNDomEigEst_PI(N_Vector q, sunindextype max_powiter, SUNContext sunctx); SUNDIALS_EXPORT -SUNDomEigEstimator_Type SUNDomEigEst_PIGetType(SUNDomEigEstimator DEE); +SUNDomEigEstimator_ID SUNDomEigEst_PIGetID(SUNDomEigEstimator DEE); + +SUNDIALS_EXPORT +SUNErrCode SUNDomEigEstSetATimes_PI(SUNDomEigEstimator DEE, void* A_data, + SUNATimesFn ATimes); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstInitialize_PI(SUNDomEigEstimator DEE); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstSetNumPreProcess_PI(SUNDomEigEstimator DEE, - sunindextype numofperprocess); + sunindextype numofperprocess); SUNDIALS_EXPORT -SUNErrCode SUNDomEigEstSetATimes_PI(SUNDomEigEstimator DEE, void* A_data, - SUNATimesFn ATimes); +SUNErrCode SUNDomEigEstSetTol_PI(SUNDomEigEstimator DEE, sunrealtype tol); SUNDIALS_EXPORT SUNErrCode SUNDomEigEst_PISetMaxPowerIter(SUNDomEigEstimator DEE, @@ -88,7 +91,10 @@ SUNDIALS_EXPORT SUNErrCode SUNDomEigEstimate_PI(SUNDomEigEstimator DEE, suncomplextype* dom_eig); SUNDIALS_EXPORT -sunindextype SUNDomEigEstNumIters_PI(SUNDomEigEstimator DEE); +SUNErrCode SUNDomEigEstNumIters_PI(SUNDomEigEstimator DEE, sunindextype* niter); + +SUNDIALS_EXPORT +SUNErrCode SUNDomEigEstRes_PI(SUNDomEigEstimator DEE, sunrealtype* res); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstFree_PI(SUNDomEigEstimator DEE); diff --git a/src/sundials/sundials_domeigestimator.c b/src/sundials/sundials_domeigestimator.c index be5477626c..c3b495fa79 100644 --- a/src/sundials/sundials_domeigestimator.c +++ b/src/sundials/sundials_domeigestimator.c @@ -54,7 +54,7 @@ SUNDomEigEstimator SUNDomEigEstNewEmpty(SUNContext sunctx) SUNAssertNull(ops, SUN_ERR_MALLOC_FAIL); /* initialize operations to NULL */ - ops->gettype = NULL; + ops->getid = NULL; ops->setatimes = NULL; ops->setnumofperprocess = NULL; ops->initialize = NULL; @@ -93,9 +93,9 @@ void SUNDomEigEstFreeEmpty(SUNDomEigEstimator DEE) * Functions in the 'ops' structure * -----------------------------------------------------------------*/ -SUNDomEigEstimator_Type SUNDomEigEstGetType(SUNDomEigEstimator DEE) +SUNDomEigEstimator_ID SUNDomEigEstGetID(SUNDomEigEstimator DEE) { - return (DEE->ops->gettype(DEE)); + return (DEE->ops->getid(DEE)); } SUNErrCode SUNDomEigEstSetATimes(SUNDomEigEstimator DEE, void* A_data, @@ -109,6 +109,16 @@ SUNErrCode SUNDomEigEstSetATimes(SUNDomEigEstimator DEE, void* A_data, return (ier); } +SUNErrCode SUNDomEigEstSetMaxPowerIter(SUNDomEigEstimator DEE, sunindextype max_powiter) +{ + SUNErrCode ier; + SUNDIALS_MARK_FUNCTION_BEGIN(getSUNProfiler(DEE)); + if (DEE->ops->setmaxpoweriter) { ier = DEE->ops->setmaxpoweriter(DEE, max_powiter); } + else { ier = SUN_SUCCESS; } + SUNDIALS_MARK_FUNCTION_END(getSUNProfiler(DEE)); + return (ier); +} + SUNErrCode SUNDomEigEstSetNumPreProcess(SUNDomEigEstimator DEE, sunindextype numofperprocess) { SUNErrCode ier; @@ -119,6 +129,16 @@ SUNErrCode SUNDomEigEstSetNumPreProcess(SUNDomEigEstimator DEE, sunindextype num return (ier); } +SUNErrCode SUNDomEigEstSetTol_ArnI(SUNDomEigEstimator DEE, sunrealtype tol) +{ + SUNErrCode ier; + SUNDIALS_MARK_FUNCTION_BEGIN(getSUNProfiler(DEE)); + if (DEE->ops->settol) { ier = DEE->ops->settol(DEE, tol); } + else { ier = SUN_SUCCESS; } + SUNDIALS_MARK_FUNCTION_END(getSUNProfiler(DEE)); + return (ier); +} + SUNErrCode SUNDomEigEstInitialize(SUNDomEigEstimator DEE) { SUNErrCode ier; @@ -158,3 +178,41 @@ SUNErrCode SUNDomEigEstimate(SUNDomEigEstimator DEE, suncomplextype* dom_eig) SUNDIALS_MARK_FUNCTION_END(getSUNProfiler(DEE)); return (ier); } + +SUNErrCode SUNDomEigEstNumIters(SUNDomEigEstimator DEE, sunindextype* niter) +{ + SUNErrCode ier; + int num_iters; + SUNDIALS_MARK_FUNCTION_BEGIN(getSUNProfiler(DEE)); + if (DEE->ops->getnumofiters) + { + ier = DEE->ops->getnumofiters(DEE, &num_iters); + *niter = num_iters; + } + else + { + *niter = 0; + ier = SUN_SUCCESS; + } + SUNDIALS_MARK_FUNCTION_END(getSUNProfiler(DEE)); + return (ier); +} + +SUNErrCode SUNDomEigEstRes(SUNDomEigEstimator DEE, sunrealtype* res) +{ + SUNErrCode ier; + sunrealtype residual; + SUNDIALS_MARK_FUNCTION_BEGIN(getSUNProfiler(DEE)); + if (DEE->ops->getres) + { + ier = DEE->ops->getres(DEE, &residual); + *res = residual; + } + else + { + *res = SUN_RCONST(0.0); + ier = SUN_SUCCESS; + } + SUNDIALS_MARK_FUNCTION_END(getSUNProfiler(DEE)); + return (ier); +} \ No newline at end of file diff --git a/src/sundomeigest/ArnI/sundomeigest_arni.c b/src/sundomeigest/ArnI/sundomeigest_arni.c index 0385461d96..d6592c4219 100644 --- a/src/sundomeigest/ArnI/sundomeigest_arni.c +++ b/src/sundomeigest/ArnI/sundomeigest_arni.c @@ -48,22 +48,25 @@ * Function to create a new ArnI estimator */ -SUNDomEigEstimator SUNDomEigEst_ArnI(N_Vector q, sunindextype maxl, +SUNDomEigEstimator SUNDomEigEst_ArnI(N_Vector q, sunindextype krydim, SUNContext sunctx) { SUNFunctionBegin(sunctx); SUNDomEigEstimator DEE; SUNDomEigEstimatorContent_ArnI content; - /* Check if maxl >= 2 */ - SUNAssertNull(maxl >= 2, SUN_ERR_DOMEIG_NOT_ENOUGH_ITER); + /* Check if krydim >= 2 */ + if(krydim < 3) + { + krydim = SUNDOMEIGEST_ARN_KRYLDIM_DEFAULT; + } /* check for legal q; if illegal return NULL */ // TO DO: check required vector operations SUNAssertNull(!((q->ops->nvclone == NULL) || (q->ops->nvdestroy == NULL) || (q->ops->nvdotprod == NULL) || (q->ops->nvscale == NULL) || (q->ops->nvgetlength == NULL) || (q->ops->nvspace == NULL)), - SUN_ERR_DOMEIG_BAD_NVECTOR); + SUN_ERR_DEE_BAD_NVECTOR); /* Create dominant eigenvalue estimator */ DEE = NULL; @@ -71,15 +74,17 @@ SUNDomEigEstimator SUNDomEigEst_ArnI(N_Vector q, sunindextype maxl, SUNCheckLastErrNull(); /* Attach operations */ - DEE->ops->gettype = SUNDomEigEst_ArnIGetType; + DEE->ops->getid = SUNDomEigEst_ArnIGetID; DEE->ops->setatimes = SUNDomEigEstSetATimes_ArnI; DEE->ops->setmaxpoweriter = NULL; + DEE->ops->settol = NULL; DEE->ops->setnumofperprocess = SUNDomEigEstSetNumPreProcess_ArnI; DEE->ops->initialize = SUNDomEigEstInitialize_ArnI; DEE->ops->preprocess = SUNDomEigEstPreProcess_ArnI; DEE->ops->computehess = SUNDomEigEstComputeHess_ArnI; DEE->ops->estimate = SUNDomEigEstimate_ArnI; DEE->ops->getnumofiters = NULL; + DEE->ops->getres = NULL; DEE->ops->free = SUNDomEigEstFree_ArnI; /* Create content */ @@ -95,7 +100,7 @@ SUNDomEigEstimator SUNDomEigEst_ArnI(N_Vector q, sunindextype maxl, content->ATdata = NULL; content->V = NULL; content->q = NULL; - content->maxl = maxl; + content->krydim = krydim; content->power_of_A = 0; content->LAPACK_A = NULL; content->LAPACK_wr = NULL; @@ -108,7 +113,7 @@ SUNDomEigEstimator SUNDomEigEst_ArnI(N_Vector q, sunindextype maxl, content->q = N_VClone(q); SUNCheckLastErrNull(); - content->V = N_VCloneVectorArray(maxl + 1, q); + content->V = N_VCloneVectorArray(krydim + 1, q); SUNCheckLastErrNull(); return (DEE); @@ -120,39 +125,39 @@ SUNDomEigEstimator SUNDomEigEst_ArnI(N_Vector q, sunindextype maxl, * ----------------------------------------------------------------- */ -SUNDomEigEstimator_Type SUNDomEigEst_ArnIGetType( +SUNDomEigEstimator_ID SUNDomEigEst_ArnIGetID( SUNDIALS_MAYBE_UNUSED SUNDomEigEstimator DEE) { - return (SUNDOMEIG_ARNOLDI); + return (SUNDSOMEIGESTIMATOR_ARNOLDI); } SUNErrCode SUNDomEigEstInitialize_ArnI(SUNDomEigEstimator DEE) { SUNFunctionBegin(DEE->sunctx); - if (ArnI_CONTENT(DEE)->maxl < 2) + if (ArnI_CONTENT(DEE)->krydim < 2) { - ArnI_CONTENT(DEE)->maxl = SUNDOMEIGEST_ARN_MAXL_DEFAULT; + ArnI_CONTENT(DEE)->krydim = SUNDOMEIGEST_ARN_KRYLDIM_DEFAULT; } if (ArnI_CONTENT(DEE)->power_of_A < 0) { ArnI_CONTENT(DEE)->power_of_A = SUNDOMEIGEST_PI_POWER_OF_A_DEFAULT; } - SUNAssert(ArnI_CONTENT(DEE)->ATimes, SUN_ERR_ARG_CORRUPT); + SUNAssert(ArnI_CONTENT(DEE)->ATimes, SUN_ERR_DEE_NULL_ATIMES); SUNAssert(ArnI_CONTENT(DEE)->V, SUN_ERR_ARG_CORRUPT); SUNAssert(ArnI_CONTENT(DEE)->q, SUN_ERR_ARG_CORRUPT); ArnI_CONTENT(DEE)->LAPACK_A = (sunrealtype*)malloc( - (ArnI_CONTENT(DEE)->maxl * ArnI_CONTENT(DEE)->maxl) * sizeof(sunrealtype)); + (ArnI_CONTENT(DEE)->krydim * ArnI_CONTENT(DEE)->krydim) * sizeof(sunrealtype)); ArnI_CONTENT(DEE)->LAPACK_wr = - malloc(ArnI_CONTENT(DEE)->maxl * sizeof(sunrealtype)); + malloc(ArnI_CONTENT(DEE)->krydim * sizeof(sunrealtype)); ArnI_CONTENT(DEE)->LAPACK_wi = - malloc(ArnI_CONTENT(DEE)->maxl * sizeof(sunrealtype)); + malloc(ArnI_CONTENT(DEE)->krydim * sizeof(sunrealtype)); ArnI_CONTENT(DEE)->LAPACK_work = - malloc((4 * ArnI_CONTENT(DEE)->maxl) * sizeof(sunrealtype)); + malloc((4 * ArnI_CONTENT(DEE)->krydim) * sizeof(sunrealtype)); ArnI_CONTENT(DEE)->LAPACK_arr = - (suncomplextype*)malloc(ArnI_CONTENT(DEE)->maxl * sizeof(suncomplextype)); + (suncomplextype*)malloc(ArnI_CONTENT(DEE)->krydim * sizeof(suncomplextype)); N_VRandom(ArnI_CONTENT(DEE)->q); SUNCheckLastErr(); @@ -162,13 +167,13 @@ SUNErrCode SUNDomEigEstInitialize_ArnI(SUNDomEigEstimator DEE) { sunindextype k; ArnI_CONTENT(DEE)->Hes = (sunrealtype**)malloc( - (ArnI_CONTENT(DEE)->maxl + 1) * sizeof(sunrealtype*)); + (ArnI_CONTENT(DEE)->krydim + 1) * sizeof(sunrealtype*)); - for (k = 0; k <= ArnI_CONTENT(DEE)->maxl; k++) + for (k = 0; k <= ArnI_CONTENT(DEE)->krydim; k++) { ArnI_CONTENT(DEE)->Hes[k] = NULL; ArnI_CONTENT(DEE)->Hes[k] = - (sunrealtype*)malloc(ArnI_CONTENT(DEE)->maxl * sizeof(sunrealtype)); + (sunrealtype*)malloc(ArnI_CONTENT(DEE)->krydim * sizeof(sunrealtype)); } } @@ -210,7 +215,7 @@ SUNErrCode SUNDomEigEstPreProcess_ArnI(SUNDomEigEstimator DEE) { SUNFunctionBegin(DEE->sunctx); - SUNAssert(ArnI_CONTENT(DEE)->ATimes, SUN_ERR_ARG_CORRUPT); + SUNAssert(ArnI_CONTENT(DEE)->ATimes, SUN_ERR_DEE_NULL_ATIMES); SUNAssert(ArnI_CONTENT(DEE)->V, SUN_ERR_ARG_CORRUPT); SUNAssert(ArnI_CONTENT(DEE)->q, SUN_ERR_ARG_CORRUPT); @@ -225,8 +230,8 @@ SUNErrCode SUNDomEigEstPreProcess_ArnI(SUNDomEigEstimator DEE) ArnI_CONTENT(DEE)->q); if (retval != 0) { - if (retval < 0) { return SUN_ERR_DOMEIG_ATIMES_FAIL_UNREC; } - else { return SUN_ERR_DOMEIG_ATIMES_FAIL_REC; } + if (retval < 0) { return SUN_ERR_DEE_ATIMES_FAIL_UNREC; } + else { return SUN_ERR_DEE_ATIMES_FAIL_REC; } } normq = N_VDotProd(ArnI_CONTENT(DEE)->q, ArnI_CONTENT(DEE)->q); SUNCheckLastErr(); @@ -243,22 +248,22 @@ SUNErrCode SUNDomEigEstComputeHess_ArnI(SUNDomEigEstimator DEE) { SUNFunctionBegin(DEE->sunctx); - SUNAssert(ArnI_CONTENT(DEE)->ATimes, SUN_ERR_ARG_CORRUPT); + SUNAssert(ArnI_CONTENT(DEE)->ATimes, SUN_ERR_DEE_NULL_ATIMES); SUNAssert(ArnI_CONTENT(DEE)->V, SUN_ERR_ARG_CORRUPT); SUNAssert(ArnI_CONTENT(DEE)->q, SUN_ERR_ARG_CORRUPT); - SUNAssert(ArnI_CONTENT(DEE)->Hes, SUN_ERR_ARG_CORRUPT); + SUNAssert(ArnI_CONTENT(DEE)->Hes, SUN_ERR_DEE_NULL_HES); sunindextype retval, i, j; /* Initialize the Hessenberg matrix Hes with zeros */ - for (i = 0; i < ArnI_CONTENT(DEE)->maxl; i++) + for (i = 0; i < ArnI_CONTENT(DEE)->krydim; i++) { - for (j = 0; j < ArnI_CONTENT(DEE)->maxl; j++) + for (j = 0; j < ArnI_CONTENT(DEE)->krydim; j++) { ArnI_CONTENT(DEE)->Hes[i][j] = ZERO; } } - for (i = 0; i < ArnI_CONTENT(DEE)->maxl; i++) + for (i = 0; i < ArnI_CONTENT(DEE)->krydim; i++) { /* Compute the next Krylov vector */ retval = ArnI_CONTENT(DEE)->ATimes(ArnI_CONTENT(DEE)->ATdata, @@ -266,12 +271,12 @@ SUNErrCode SUNDomEigEstComputeHess_ArnI(SUNDomEigEstimator DEE) ArnI_CONTENT(DEE)->V[i + 1]); if (retval != 0) { - if (retval < 0) { return SUN_ERR_DOMEIG_ATIMES_FAIL_UNREC; } - else { return SUN_ERR_DOMEIG_ATIMES_FAIL_REC; } + if (retval < 0) { return SUN_ERR_DEE_ATIMES_FAIL_UNREC; } + else { return SUN_ERR_DEE_ATIMES_FAIL_REC; } } SUNCheckCall(SUNModifiedGS(ArnI_CONTENT(DEE)->V, ArnI_CONTENT(DEE)->Hes, - i + 1, ArnI_CONTENT(DEE)->maxl, + i + 1, ArnI_CONTENT(DEE)->krydim, &(ArnI_CONTENT(DEE)->Hes[i + 1][i]))); /* Unitize the computed orthogonal vector */ @@ -288,16 +293,16 @@ SUNErrCode SUNDomEigEstimate_ArnI(SUNDomEigEstimator DEE, suncomplextype* dom_ei SUNFunctionBegin(DEE->sunctx); SUNAssert(dom_eig, SUN_ERR_ARG_CORRUPT); - SUNAssert(ArnI_CONTENT(DEE)->ATimes, SUN_ERR_ARG_CORRUPT); + SUNAssert(ArnI_CONTENT(DEE)->ATimes, SUN_ERR_DEE_NULL_ATIMES); SUNAssert(ArnI_CONTENT(DEE)->V, SUN_ERR_ARG_CORRUPT); SUNAssert(ArnI_CONTENT(DEE)->q, SUN_ERR_ARG_CORRUPT); - SUNAssert(ArnI_CONTENT(DEE)->Hes, SUN_ERR_ARG_CORRUPT); + SUNAssert(ArnI_CONTENT(DEE)->Hes, SUN_ERR_DEE_NULL_HES); suncomplextype dom_eig_new; dom_eig_new.real = ZERO; dom_eig_new.imag = ZERO; - int n = ArnI_CONTENT(DEE)->maxl; + int n = ArnI_CONTENT(DEE)->krydim; /* Reshape the Hessenberg matrix as an input vector for the LAPACK dgeev_ function */ sunindextype i, j, k = 0; @@ -325,7 +330,7 @@ SUNErrCode SUNDomEigEstimate_ArnI(SUNDomEigEstimator DEE, suncomplextype* dom_ei { printf(SUNDOMEIGEST_LAPACK_FAIL, info); - return SUN_ERR_DOMEIG_LAPACK_FAIL; + return SUN_ERR_DEE_LAPACK_FAIL; } /* order the eigenvalues by their magnitude */ @@ -345,7 +350,7 @@ SUNErrCode SUNDomEigEstimate_ArnI(SUNDomEigEstimator DEE, suncomplextype* dom_ei ArnI_CONTENT(DEE)->LAPACK_wi[i] = ArnI_CONTENT(DEE)->LAPACK_arr[i].imag; } - // alternatively we can return a vector of all computed dom_eigs (up to maxl) + // alternatively we can return a vector of all computed dom_eigs (up to krydim) // TODO: Get opinions /* Copy the dominant eigenvalue */ diff --git a/src/sundomeigest/PI/sundomeigest_pi.c b/src/sundomeigest/PI/sundomeigest_pi.c index d2279fd1ed..1c3c648304 100644 --- a/src/sundomeigest/PI/sundomeigest_pi.c +++ b/src/sundomeigest/PI/sundomeigest_pi.c @@ -60,7 +60,7 @@ SUNDomEigEstimator SUNDomEigEst_PI(N_Vector q, sunindextype max_powiter, SUNAssertNull(!((q->ops->nvclone == NULL) || (q->ops->nvdestroy == NULL) || (q->ops->nvdotprod == NULL) || (q->ops->nvscale == NULL) || (q->ops->nvgetlength == NULL) || (q->ops->nvspace == NULL)), - SUN_ERR_DOMEIG_BAD_NVECTOR); + SUN_ERR_DEE_BAD_NVECTOR); /* check for max_powiter values; if illegal use defaults */ if (max_powiter <= 0) { max_powiter = SUNDOMEIGEST_MAX_PI_DEFAULT; } @@ -71,15 +71,17 @@ SUNDomEigEstimator SUNDomEigEst_PI(N_Vector q, sunindextype max_powiter, SUNCheckLastErrNull(); /* Attach operations */ - DEE->ops->gettype = SUNDomEigEst_PIGetType; + DEE->ops->getid = SUNDomEigEst_PIGetID; DEE->ops->setatimes = SUNDomEigEstSetATimes_PI; DEE->ops->setmaxpoweriter = SUNDomEigEst_PISetMaxPowerIter; + DEE->ops->settol = SUNDomEigEstSetTol_PI; DEE->ops->setnumofperprocess = SUNDomEigEstSetNumPreProcess_PI; DEE->ops->initialize = SUNDomEigEstInitialize_PI; DEE->ops->preprocess = SUNDomEigEstPreProcess_PI; DEE->ops->computehess = NULL; DEE->ops->estimate = SUNDomEigEstimate_PI; DEE->ops->getnumofiters = SUNDomEigEstNumIters_PI; + DEE->ops->getres = SUNDomEigEstRes_PI; DEE->ops->free = SUNDomEigEstFree_PI; /* Create content */ @@ -97,7 +99,7 @@ SUNDomEigEstimator SUNDomEigEst_PI(N_Vector q, sunindextype max_powiter, content->q = NULL; content->power_of_A = 0; content->powiter_tol = ZERO; - content->resnorm = ZERO; + content->res = ZERO; content->max_powiter = max_powiter; content->numiters = 0; @@ -117,10 +119,10 @@ SUNDomEigEstimator SUNDomEigEst_PI(N_Vector q, sunindextype max_powiter, * ----------------------------------------------------------------- */ -SUNDomEigEstimator_Type SUNDomEigEst_PIGetType( +SUNDomEigEstimator_ID SUNDomEigEst_PIGetID( SUNDIALS_MAYBE_UNUSED SUNDomEigEstimator DEE) { - return (SUNDOMEIG_POWER); + return (SUNDSOMEIGESTIMATOR_POWER); } SUNErrCode SUNDomEigEstInitialize_PI(SUNDomEigEstimator DEE) @@ -169,6 +171,16 @@ SUNErrCode SUNDomEigEstSetNumPreProcess_PI(SUNDomEigEstimator DEE, return SUN_SUCCESS; } +SUNErrCode SUNDomEigEstSetTol_PI(SUNDomEigEstimator DEE, + sunrealtype tol) +{ + SUNFunctionBegin(DEE->sunctx); + + /* set the tolerance */ + PI_CONTENT(DEE)->powiter_tol = tol; + return SUN_SUCCESS; +} + SUNErrCode SUNDomEigEstSetATimes_PI(SUNDomEigEstimator DEE, void* A_data, SUNATimesFn ATimes) { @@ -212,8 +224,8 @@ SUNErrCode SUNDomEigEstPreProcess_PI(SUNDomEigEstimator DEE) PI_CONTENT(DEE)->V, PI_CONTENT(DEE)->q); if (retval != 0) { - if (retval < 0) { return SUN_ERR_DOMEIG_ATIMES_FAIL_UNREC; } - else { return SUN_ERR_DOMEIG_ATIMES_FAIL_REC; } + if (retval < 0) { return SUN_ERR_DEE_ATIMES_FAIL_UNREC; } + else { return SUN_ERR_DEE_ATIMES_FAIL_REC; } } normq = N_VDotProd(PI_CONTENT(DEE)->q, PI_CONTENT(DEE)->q); SUNCheckLastErr(); @@ -252,17 +264,20 @@ SUNErrCode SUNDomEigEstimate_PI(SUNDomEigEstimator DEE, suncomplextype* dom_eig) PI_CONTENT(DEE)->V, PI_CONTENT(DEE)->q); if (retval != 0) { - if (retval < 0) { return SUN_ERR_DOMEIG_ATIMES_FAIL_UNREC; } - else { return SUN_ERR_DOMEIG_ATIMES_FAIL_REC; } + if (retval < 0) { return SUN_ERR_DEE_ATIMES_FAIL_UNREC; } + else { return SUN_ERR_DEE_ATIMES_FAIL_REC; } } dom_eig_new.real = N_VDotProd(PI_CONTENT(DEE)->V, PI_CONTENT(DEE)->q); //Rayleigh quotient SUNCheckLastErr(); - PI_CONTENT(DEE)->resnorm = fabs(dom_eig_new.real - dom_eig_old.real); + PI_CONTENT(DEE)->res = fabs(dom_eig_new.real - dom_eig_old.real); - if (PI_CONTENT(DEE)->resnorm < PI_CONTENT(DEE)->powiter_tol) { break; } + if (PI_CONTENT(DEE)->res < PI_CONTENT(DEE)->powiter_tol) + { + break; + } normq = N_VDotProd(PI_CONTENT(DEE)->q, PI_CONTENT(DEE)->q); SUNCheckLastErr(); @@ -280,9 +295,26 @@ SUNErrCode SUNDomEigEstimate_PI(SUNDomEigEstimator DEE, suncomplextype* dom_eig) return SUN_SUCCESS; } -sunindextype SUNDomEigEstNumIters_PI(SUNDomEigEstimator DEE) +SUNErrCode SUNDomEigEstNumIters_PI(SUNDomEigEstimator DEE, sunindextype* niter) { - return PI_CONTENT(DEE)->numiters; + SUNFunctionBegin(DEE->sunctx); + SUNAssert(DEE, SUN_ERR_DEE_NULL_MEM); + SUNAssert(PI_CONTENT(DEE), SUN_ERR_DEE_NULL_CONTENT); + + *niter = PI_CONTENT(DEE)->numiters; + + return SUN_SUCCESS; +} + +SUNErrCode SUNDomEigEstRes_PI(SUNDomEigEstimator DEE, sunrealtype* res) +{ + SUNFunctionBegin(DEE->sunctx); + SUNAssert(DEE, SUN_ERR_DEE_NULL_MEM); + SUNAssert(PI_CONTENT(DEE), SUN_ERR_DEE_NULL_CONTENT); + + *res = PI_CONTENT(DEE)->res; + + return SUN_SUCCESS; } SUNErrCode SUNDomEigEstFree_PI(SUNDomEigEstimator DEE) diff --git a/test/unit_tests/sundomeigest/arni/CMakeLists.txt b/test/unit_tests/sundomeigest/arni/CMakeLists.txt index ed5ec0fda4..0dbbdad326 100644 --- a/test/unit_tests/sundomeigest/arni/CMakeLists.txt +++ b/test/unit_tests/sundomeigest/arni/CMakeLists.txt @@ -19,9 +19,9 @@ # Examples using SUNDIALS ArnI dominant eigenvalue estimator set(sundomeigest_arni_examples - "test_sundomeigest_arni\;100 10 10\;" - "test_sundomeigest_arni\;1000 10 10\;" - "test_sundomeigest_arni\;10000 10 10\;") + "test_sundomeigest_arni\;100 10 10 0\;" + "test_sundomeigest_arni\;1000 10 10 0\;" + "test_sundomeigest_arni\;10000 10 10 0\;") # Dependencies for dominant eigenvalue examples set(sundomeigest_arni_dependencies test_sundomeigest) diff --git a/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c b/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c index 0bf0fb25e1..45876f44d4 100644 --- a/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c +++ b/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c @@ -59,8 +59,11 @@ int main(int argc, char* argv[]) N_Vector q; /* test vectors */ UserData ProbData; /* problem data structure */ int power_of_A; /* Power of A for the warm-up */ + int max_powiter; /* max power iteration */ int krydim; /* Krylov subspace dimension */ + int niter; /* number of iterations */ int print_timing; /* timing output flag */ + sunrealtype res; /* current residual */ suncomplextype dom_eig; /* computed domeig value */ suncomplextype true_dom_eig; /* true domeig value */ SUNContext sunctx; @@ -136,13 +139,31 @@ int main(int argc, char* argv[]) DEE = SUNDomEigEst_ArnI(q, krydim, sunctx); if (check_flag(DEE, "SUNDomEigEst_ArnI", 0)) { return 1; } - fails += Test_SUNDomEigEstGetType(DEE, SUNDOMEIG_ARNOLDI, 0); + fails += Test_SUNDomEigEstGetID(DEE, SUNDSOMEIGESTIMATOR_ARNOLDI, 0); fails += Test_SUNDomEigEstSetATimes(DEE, &ProbData, ATimes, 0); fails += Test_SUNDomEigEstSetNumPreProcess(DEE, power_of_A, 0); + // SUNDomEigEstSetMaxPowerIter is not an option for Arnoldi iteration. + // It should return with SUN_SUCCESS + max_powiter = krydim; + fails += Test_SUNDomEigEstSetMaxPowerIter(DEE, max_powiter, 0); fails += Test_SUNDomEigEstInitialize(DEE, 0); fails += Test_SUNDomEigEstPreProcess(DEE, 0); fails += Test_SUNDomEigEstComputeHess(DEE, 0); fails += Test_SUNDomEigEstimate(DEE, &dom_eig, 0); + // SUNDomEigEstNumIters and SUNDomEigEstRes are not options for + // Arnoldi iteration. They should return with 0 + fails += Test_SUNDomEigEstNumIters(DEE, &niter, 0); + if(niter != 0) + { + printf(" >>> FAILED test -- SUNDomEigEstNumIters return value\n"); + fails++; + } + fails += Test_SUNDomEigEstRes(DEE, &res, 0); + if(res > SUN_SMALL_REAL) + { + printf(" >>> FAILED test -- Test_SUNDomEigEstRes return value\n"); + fails++; + } if (fails) { diff --git a/test/unit_tests/sundomeigest/pi/CMakeLists.txt b/test/unit_tests/sundomeigest/pi/CMakeLists.txt index fb5e09b360..8f24d82f02 100644 --- a/test/unit_tests/sundomeigest/pi/CMakeLists.txt +++ b/test/unit_tests/sundomeigest/pi/CMakeLists.txt @@ -19,8 +19,9 @@ # Examples using SUNDIALS PI dominant eigenvalue estimator set(sundomeigest_pi_examples - "test_sundomeigest_pi\;100 10 10\;" "test_sundomeigest_pi\;1000 10 10\;" - "test_sundomeigest_pi\;10000 10 10\;") + "test_sundomeigest_pi\;100 10 10 0\;" + "test_sundomeigest_pi\;1000 10 10 0\;" + "test_sundomeigest_pi\;10000 10 10 0\;") # Dependencies for dominant eigenvalue examples set(sundomeigest_pi_dependencies test_sundomeigest) diff --git a/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c b/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c index ba4c16af87..509ef224e4 100644 --- a/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c +++ b/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c @@ -57,8 +57,10 @@ int main(int argc, char* argv[]) N_Vector q; /* test vectors */ UserData ProbData; /* problem data structure */ int power_of_A; /* Power of A for the warm-up */ - int maxl; /* max power iteration */ + int max_powiter; /* max power iteration */ + int niter; /* number of iterations */ int print_timing; /* timing output flag */ + sunrealtype res; /* current residual */ suncomplextype dom_eig; /* computed domeig value */ suncomplextype true_dom_eig; /* true domeig value */ SUNContext sunctx; @@ -86,8 +88,8 @@ int main(int argc, char* argv[]) printf("ERROR: Problem size must be a positive integer\n"); return 1; } - maxl = atoi(argv[2]); - if (maxl <= 0) + max_powiter = atoi(argv[2]); + if (max_powiter <= 0) { printf("ERROR: Maximum number of power iterations must be a positive integer\n"); return 1; @@ -103,7 +105,7 @@ int main(int argc, char* argv[]) printf("\nDomEig module test:\n"); printf(" Problem size = %ld\n", (long int)ProbData.N); - printf(" Number of power iterations = %i\n", maxl); + printf(" Number of power iterations = %i\n", max_powiter); printf(" Number of preprocessing = %i\n", power_of_A); printf(" Timing output flag = %i\n\n", print_timing); @@ -133,16 +135,31 @@ int main(int argc, char* argv[]) ProbData.A12 = nondiagonal; /* Create Arnoldi DomEig estimator*/ - DEE = SUNDomEigEst_PI(q, maxl, sunctx); + DEE = SUNDomEigEst_PI(q, max_powiter, sunctx); if (check_flag(DEE, "SUNDomEigEst_PI", 0)) { return 1; } - fails += Test_SUNDomEigEstGetType(DEE, SUNDOMEIG_POWER, 0); + fails += Test_SUNDomEigEstGetID(DEE, SUNDSOMEIGESTIMATOR_POWER, 0); fails += Test_SUNDomEigEstSetATimes(DEE, &ProbData, ATimes, 0); fails += Test_SUNDomEigEstSetNumPreProcess(DEE, power_of_A, 0); + fails += Test_SUNDomEigEstSetMaxPowerIter(DEE, max_powiter, 0); fails += Test_SUNDomEigEstInitialize(DEE, 0); fails += Test_SUNDomEigEstPreProcess(DEE, 0); + // Test_SUNDomEigEstComputeHess is not an option for power iteration. + // It should return with SUN_SUCCESS fails += Test_SUNDomEigEstComputeHess(DEE, 0); fails += Test_SUNDomEigEstimate(DEE, &dom_eig, 0); + fails += Test_SUNDomEigEstNumIters(DEE, &niter, 0); + if(niter == 0) + { + printf(" >>> FAILED test -- SUNDomEigEstNumIters return value\n"); + fails++; + } + fails += Test_SUNDomEigEstRes(DEE, &res, 0); + if(res < SUN_SMALL_REAL) + { + printf(" >>> FAILED test -- Test_SUNDomEigEstRes return value\n"); + fails++; + } if (fails) { diff --git a/test/unit_tests/sundomeigest/test_sundomeigest.c b/test/unit_tests/sundomeigest/test_sundomeigest.c index f8f4c38439..4b5c72c047 100644 --- a/test/unit_tests/sundomeigest/test_sundomeigest.c +++ b/test/unit_tests/sundomeigest/test_sundomeigest.c @@ -40,30 +40,30 @@ int print_time = 0; if (print_time) printf(format, time) /* ---------------------------------------------------------------------- - * SUNDomEigEstGetType Test + * SUNDomEigEstGetID Test * --------------------------------------------------------------------*/ -int Test_SUNDomEigEstGetType(SUNDomEigEstimator DEE, - SUNDomEigEstimator_Type suntype, int myid) +int Test_SUNDomEigEstGetID(SUNDomEigEstimator DEE, + SUNDomEigEstimator_ID suntype, int myid) { double start_time, stop_time; - SUNDomEigEstimator_Type myesttype; + SUNDomEigEstimator_ID myestid; start_time = get_time(); - myesttype = SUNDomEigEstGetType(DEE); + myestid = SUNDomEigEstGetID(DEE); // sync_device(); stop_time = get_time(); - if (suntype != myesttype) + if (suntype != myestid) { - printf(">>> FAILED test -- SUNDomEigEstGetType, Proc %d \n", myid); - PRINT_TIME(" SUNDomEigEstGetType Time: %22.15e \n \n", + printf(">>> FAILED test -- SUNDomEigEstGetID, Proc %d \n", myid); + PRINT_TIME(" SUNDomEigEstGetID Time: %22.15e \n \n", stop_time - start_time); return (1); } else if (myid == 0) { - printf(" PASSED test -- SUNDomEigEstGetType \n"); - PRINT_TIME(" SUNDomEigEstGetType Time: %22.15e \n \n", + printf(" PASSED test -- SUNDomEigEstGetID \n"); + PRINT_TIME(" SUNDomEigEstGetID Time: %22.15e \n \n", stop_time - start_time); } @@ -103,6 +103,39 @@ int Test_SUNDomEigEstSetATimes(SUNDomEigEstimator DEE, void* ATdata, return (0); } + +/* ---------------------------------------------------------------------- + * SUNDomEigEstSetMaxPowerIter Test + * --------------------------------------------------------------------*/ +int Test_SUNDomEigEstSetMaxPowerIter(SUNDomEigEstimator DEE, sunindextype max_powiter, int myid) +{ + int failure; + double start_time, stop_time; + + /* try calling SetMaxPowerIter routine: should pass/fail based on expected input */ + start_time = get_time(); + failure = SUNDomEigEstSetMaxPowerIter(DEE, max_powiter); + // sync_device(); + stop_time = get_time(); + + if (failure) + { + printf(">>> FAILED test -- SUNDomEigEstSetMaxPowerIter returned %d on Proc %d \n", + failure, myid); + PRINT_TIME(" SUNDomEigEstSetMaxPowerIter Time: %22.15e \n \n", + stop_time - start_time); + return (1); + } + else if (myid == 0) + { + printf(" PASSED test -- SUNDomEigEstSetMaxPowerIter \n"); + PRINT_TIME(" SUNDomEigEstSetMaxPowerIter Time: %22.15e \n \n", + stop_time - start_time); + } + + return (0); +} + int Test_SUNDomEigEstSetNumPreProcess(SUNDomEigEstimator DEE, int power_of_A, int myid) { int failure; @@ -253,6 +286,70 @@ int Test_SUNDomEigEstimate(SUNDomEigEstimator DEE, suncomplextype* dom_eig, int return (0); } +/* ---------------------------------------------------------------------- + * SUNDomEigEstNumIters Test + * --------------------------------------------------------------------*/ +int Test_SUNDomEigEstNumIters(SUNDomEigEstimator DEE, int* niter, int myid) +{ + int failure; + int num_iters; + double start_time, stop_time; + + start_time = get_time(); + failure = SUNDomEigEstNumIters(DEE, &num_iters); + *niter = num_iters; + // sync_device(); + stop_time = get_time(); + + if (failure) + { + printf(">>> FAILED test -- SUNDomEigEstNumIters check, Proc %d \n", myid); + PRINT_TIME(" SUNDomEigEstNumIters Time: %22.15e \n \n", + stop_time - start_time); + return (1); + } + else if (myid == 0) + { + printf(" PASSED test -- SUNDomEigEstNumIters \n"); + PRINT_TIME(" SUNDomEigEstNumIters Time: %22.15e \n \n", + stop_time - start_time); + } + + return (0); +} + +/* ---------------------------------------------------------------------- + * SUNDomEigEstRes Test + * --------------------------------------------------------------------*/ +int Test_SUNDomEigEstRes(SUNDomEigEstimator DEE, sunrealtype* res, int myid) +{ + int failure; + sunrealtype residual; + double start_time, stop_time; + + start_time = get_time(); + failure = SUNDomEigEstRes(DEE, &residual); + *res = residual; + // sync_device(); + stop_time = get_time(); + + if (failure) + { + printf(">>> FAILED test -- SUNDomEigEstRes check, Proc %d \n", myid); + PRINT_TIME(" SUNDomEigEstRes Time: %22.15e \n \n", + stop_time - start_time); + return (1); + } + else if (myid == 0) + { + printf(" PASSED test -- SUNDomEigEstRes \n"); + PRINT_TIME(" SUNDomEigEstRes Time: %22.15e \n \n", + stop_time - start_time); + } + + return (0); +} + /* ====================================================================== * Private functions * ====================================================================*/ diff --git a/test/unit_tests/sundomeigest/test_sundomeigest.h b/test/unit_tests/sundomeigest/test_sundomeigest.h index 46bef3f07d..dfafbfb53f 100644 --- a/test/unit_tests/sundomeigest/test_sundomeigest.h +++ b/test/unit_tests/sundomeigest/test_sundomeigest.h @@ -31,8 +31,8 @@ extern "C" { // void sync_device(void); /* Test function declarations */ -int Test_SUNDomEigEstGetType(SUNDomEigEstimator DEE, - SUNDomEigEstimator_Type suntype, int myid); +int Test_SUNDomEigEstGetID(SUNDomEigEstimator DEE, + SUNDomEigEstimator_ID suntype, int myid); int Test_SUNDomEigEstSetATimes(SUNDomEigEstimator DEE, void* ATdata, SUNATimesFn ATimes, int myid); int Test_SUNDomEigEstSetNumPreProcess(SUNDomEigEstimator DEE, int power_of_A, int myid); @@ -40,6 +40,8 @@ int Test_SUNDomEigEstInitialize(SUNDomEigEstimator DEE, int myid); int Test_SUNDomEigEstPreProcess(SUNDomEigEstimator DEE, int myid); int Test_SUNDomEigEstComputeHess(SUNDomEigEstimator DEE, int myid); int Test_SUNDomEigEstimate(SUNDomEigEstimator DEE, suncomplextype* dom_eig, int myid); +int Test_SUNDomEigEstNumIters(SUNDomEigEstimator DEE, int* niter, int myid); +int Test_SUNDomEigEstRes(SUNDomEigEstimator DEE, sunrealtype* res, int myid); /* Timing function */ void SetTiming(int onoff); From 477c50d4af5ac87a54002619bba0ea6f263b4d92 Mon Sep 17 00:00:00 2001 From: maggul Date: Tue, 17 Jun 2025 12:19:54 -0500 Subject: [PATCH 044/128] CI debug and power_of_A to numwarmups change --- doc/shared/sundomeigest/SUNDomEigEst_ARNI.rst | 10 +++++----- doc/shared/sundomeigest/SUNDomEigEst_PI.rst | 6 +++--- include/sundials/sundials_domeigestimator.h | 3 +++ include/sundomeigest/sundomeigest_arni.h | 3 +-- include/sundomeigest/sundomeigest_pi.h | 3 +-- src/arkode/arkode_lsrkstep.c | 6 +++--- src/arkode/arkode_lsrkstep_impl.h | 3 +-- src/arkode/arkode_lsrkstep_io.c | 2 +- src/sundials/sundials_domeigestimator.c | 2 +- src/sundomeigest/ArnI/sundomeigest_arni.c | 12 ++++++------ src/sundomeigest/PI/sundomeigest_pi.c | 12 ++++++------ .../sundomeigest/arni/test_sundomeigest_arni.c | 12 ++++++------ .../sundomeigest/pi/test_sundomeigest_pi.c | 10 +++++----- test/unit_tests/sundomeigest/test_sundomeigest.c | 4 ++-- test/unit_tests/sundomeigest/test_sundomeigest.h | 4 +++- 15 files changed, 47 insertions(+), 45 deletions(-) diff --git a/doc/shared/sundomeigest/SUNDomEigEst_ARNI.rst b/doc/shared/sundomeigest/SUNDomEigEst_ARNI.rst index b71b6a9aab..4b3e602dab 100644 --- a/doc/shared/sundomeigest/SUNDomEigEst_ARNI.rst +++ b/doc/shared/sundomeigest/SUNDomEigEst_ARNI.rst @@ -35,7 +35,7 @@ that provide :math:`A` as operator is required. .. _SUNDomEigEst.ARNI.Usage: SUNDomEigEst_ARNI Usage ---------------------- +----------------------- The header file to be included when using this module is ``sundomeigest/sundomeigest_arni.h``. The SUNDomEigEst_ARNI module is accessible from all SUNDIALS solvers @@ -86,7 +86,7 @@ The module SUNDomEigEst_ARNI provides the following user-callable routines: .. _SUNDomEigEst.ARNI.Description: SUNDomEigEst_ARNI Description ---------------------------- +----------------------------- The SUNDomEigEst_ARNI module defines the *content* field of a @@ -100,7 +100,7 @@ The SUNDomEigEst_ARNI module defines the *content* field of a N_Vector* V; N_Vector q; sunindextype krydim; - sunindextype power_of_A; + sunindextype numwarmups; sunrealtype* LAPACK_A; sunrealtype* LAPACK_wr; sunrealtype* LAPACK_wi; @@ -121,7 +121,7 @@ information: * ``krydim`` - dimension of Krylov subspaces (default is 3), -* ``power_of_A`` - number of preprocessing (default is 0), +* ``numwarmups`` - number of preprocessing warmups (default is 0), * ``LAPACK_A, LAPACK_wr, LAPACK_wi, LAPACK_work`` - ``sunrealtype`` used for workspace by LAPACK, @@ -147,7 +147,7 @@ This estimator is constructed to perform the following operations: for validity and ARNI estimator memory is allocated. * In the "preprocess" call, the initial random vector :math:`q_0` is warmed up - :math:`k=` ``power_of_A`` times as :math:`q_1 = \frac{Aq_0}{||Aq_0||} \cdots q_k = \frac{Aq_{k-1}}{||Aq_{k-1}||}`. + :math:`k=` ``numwarmups`` times as :math:`q_1 = \frac{Aq_0}{||Aq_0||} \cdots q_k = \frac{Aq_{k-1}}{||Aq_{k-1}||}`. * In the "estimate" call the ARNI estimator is performed. diff --git a/doc/shared/sundomeigest/SUNDomEigEst_PI.rst b/doc/shared/sundomeigest/SUNDomEigEst_PI.rst index 7028119cbe..8b34fee76c 100644 --- a/doc/shared/sundomeigest/SUNDomEigEst_PI.rst +++ b/doc/shared/sundomeigest/SUNDomEigEst_PI.rst @@ -84,7 +84,7 @@ The SUNDomEigEst_PI module defines the *content* field of a N_Vector* V; N_Vector q; sunindextype max_powiter; - sunindextype power_of_A; + sunindextype numwarmups; sunrealtype powiter_tol; sunrealtype res; sunindextype numiters; @@ -102,7 +102,7 @@ information: * ``max_powiter`` - maximum number of power iterations (default is 100), -* ``power_of_A`` - number of preprocessing (default is 0), +* ``numwarmups`` - number of preprocessing warmups (default is 0), * ``powiter_tol`` - convergence criteria for the power iteration (default is 0.01), @@ -128,7 +128,7 @@ This estimator is constructed to perform the following operations: for validity and PI estimator memory is allocated. * In the "preprocess" call, the initial random vector :math:`q_0` is warmed up - :math:`k=` ``power_of_A`` times as :math:`q_1 = \frac{Aq_0}{||Aq_0||} \cdots q_k = \frac{Aq_{k-1}}{||Aq_{k-1}||}`. + :math:`k=` ``numwarmups`` times as :math:`q_1 = \frac{Aq_0}{||Aq_0||} \cdots q_k = \frac{Aq_{k-1}}{||Aq_{k-1}||}`. * In the "estimate" call the PI estimator is performed. diff --git a/include/sundials/sundials_domeigestimator.h b/include/sundials/sundials_domeigestimator.h index 9b94ff0792..dca6cb5dba 100644 --- a/include/sundials/sundials_domeigestimator.h +++ b/include/sundials/sundials_domeigestimator.h @@ -30,6 +30,9 @@ extern "C" { #endif +/* Default estimator parameters */ +#define SUNDOMEIGEST_NUM_OF_WARMUPS_DEFAULT 0 + // Struct to hold the real and imaginary parts typedef struct { diff --git a/include/sundomeigest/sundomeigest_arni.h b/include/sundomeigest/sundomeigest_arni.h index 19717d00ab..c70c53432b 100644 --- a/include/sundomeigest/sundomeigest_arni.h +++ b/include/sundomeigest/sundomeigest_arni.h @@ -32,7 +32,6 @@ extern "C" { /* Default Arnoldi Iteration parameters */ #define SUNDOMEIGEST_ARN_KRYLDIM_DEFAULT 3 -#define SUNDOMEIGEST_PI_POWER_OF_A_DEFAULT 10 #define SUNDOMEIGEST_LAPACK_FAIL "Error: LAPACK dgeev failed with info = %d\n" /* ----------------------------------------------------- @@ -47,7 +46,7 @@ struct _SUNDomEigEstimatorContent_ArnI N_Vector *V, q; /* Krylov subspace vectors */ sunindextype krydim; /* Krylov subspace dimension */ - sunindextype power_of_A; /* Power of A in the preprocessing; initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ + sunindextype numwarmups; /* Power of A in the preprocessing; initial q = A^{numwarmups}q/||A^{numwarmups}q|| */ sunrealtype* LAPACK_A; /* The vector which holds rows of the Hessenberg matrix in the given order */ sunrealtype* LAPACK_wr; /* Real parts of eigenvalues */ diff --git a/include/sundomeigest/sundomeigest_pi.h b/include/sundomeigest/sundomeigest_pi.h index 3fe113202f..7f2ee9dec9 100644 --- a/include/sundomeigest/sundomeigest_pi.h +++ b/include/sundomeigest/sundomeigest_pi.h @@ -32,7 +32,6 @@ extern "C" { /* Default Power Iteration parameters */ #define SUNDOMEIGEST_PI_TOL_DEFAULT SUN_RCONST(0.01) #define SUNDOMEIGEST_MAX_PI_DEFAULT 100 -#define SUNDOMEIGEST_PI_POWER_OF_A_DEFAULT 0 /* ----------------------------------------------------- * Power Iteration Implementation of SUNDomEigEstimator @@ -45,7 +44,7 @@ struct _SUNDomEigEstimatorContent_PI N_Vector V, q; /* workspace vectors */ - sunindextype power_of_A; /* Power of A in the preprocessing; initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ + sunindextype numwarmups; /* Power of A in the preprocessing; initial q = A^{numwarmups}q/||A^{numwarmups}q|| */ sunrealtype powiter_tol; /* Convergence criteria for the power iteration */ sunrealtype res; /* Current residual of power iterations */ diff --git a/src/arkode/arkode_lsrkstep.c b/src/arkode/arkode_lsrkstep.c index f1da108b07..b8d7500b9b 100644 --- a/src/arkode/arkode_lsrkstep.c +++ b/src/arkode/arkode_lsrkstep.c @@ -2318,7 +2318,7 @@ SUNDomEigEstimator lsrkStep_DomEigCreate(void* arkode_mem) /* TODO: check if we have to clone or just passing yn is ok! */ step_mem->domeig_q = N_VClone(ark_mem->yn); step_mem->domeig_krydim = DOMEIG_KRYLOV_DIM_DEFAULT; - step_mem->domeig_power_of_A = DOMEIG_POWER_OF_A_DEFAULT; + step_mem->numwarmups = SUNDOMEIGEST_NUM_OF_WARMUPS_DEFAULT; step_mem->domeig_maxiters = DOMEIG_MAX_NUMBER_OF_POWER_ITERS_DEFAULT; /* Enforce the power iteration if the problem size < 3 */ @@ -2398,7 +2398,7 @@ SUNDomEigEstimator lsrkStep_DomEigCreate(void* arkode_mem) /* Set the number of preprocessings */ if (DEE->ops->setnumofperprocess != NULL) { - retval = DEE->ops->setnumofperprocess(DEE, step_mem->domeig_power_of_A); + retval = DEE->ops->setnumofperprocess(DEE, step_mem->numwarmups); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, @@ -2439,7 +2439,7 @@ suncomplextype lsrkStep_DomEigEstimate(void* arkode_mem, SUNDomEigEstimator DEE) return dom_eig; } - /* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ + /* Set the initial q = A^{numwarmups}q/||A^{numwarmups}q|| */ if (DEE->ops->preprocess != NULL) { retval = DEE->ops->preprocess(DEE); diff --git a/src/arkode/arkode_lsrkstep_impl.h b/src/arkode/arkode_lsrkstep_impl.h index 9ae4da5761..392cf0e7f8 100644 --- a/src/arkode/arkode_lsrkstep_impl.h +++ b/src/arkode/arkode_lsrkstep_impl.h @@ -36,7 +36,6 @@ extern "C" { #define DOM_EIG_SAFETY_DEFAULT SUN_RCONST(1.01) #define DOM_EIG_FREQ_DEFAULT 25 #define DOMEIG_KRYLOV_DIM_DEFAULT 3 -#define DOMEIG_POWER_OF_A_DEFAULT 0 #define DOMEIG_MAX_NUMBER_OF_POWER_ITERS_DEFAULT 100 /*=============================================================== @@ -169,7 +168,7 @@ typedef struct ARKodeLSRKStepMemRec SUNDomEigEstimator DEE; /* DomEig estimator*/ N_Vector domeig_q; /* DomEig initial q vector*/ int domeig_krydim; /* Krylov subspace dimension */ - int domeig_power_of_A; /* Power of A for the warm-up */ + int numwarmups; /* Power of A in the preprocessing; initial q = A^{numwarmups}q/||A^{numwarmups}q|| */ int domeig_maxiters; /* Max number of Power Iterations */ /* Flags */ diff --git a/src/arkode/arkode_lsrkstep_io.c b/src/arkode/arkode_lsrkstep_io.c index 23dd4d9ff9..cdf8e611d3 100644 --- a/src/arkode/arkode_lsrkstep_io.c +++ b/src/arkode/arkode_lsrkstep_io.c @@ -581,7 +581,7 @@ int lsrkStep_SetDefaults(ARKodeMem ark_mem) step_mem->dom_eig_safety = DOM_EIG_SAFETY_DEFAULT; step_mem->dom_eig_freq = DOM_EIG_FREQ_DEFAULT; step_mem->domeig_krydim = DOMEIG_KRYLOV_DIM_DEFAULT; - step_mem->domeig_power_of_A = DOMEIG_POWER_OF_A_DEFAULT; + step_mem->numwarmups = SUNDOMEIGEST_NUM_OF_WARMUPS_DEFAULT; /* Flags */ step_mem->dom_eig_update = SUNTRUE; diff --git a/src/sundials/sundials_domeigestimator.c b/src/sundials/sundials_domeigestimator.c index c3b495fa79..e173397daa 100644 --- a/src/sundials/sundials_domeigestimator.c +++ b/src/sundials/sundials_domeigestimator.c @@ -182,7 +182,7 @@ SUNErrCode SUNDomEigEstimate(SUNDomEigEstimator DEE, suncomplextype* dom_eig) SUNErrCode SUNDomEigEstNumIters(SUNDomEigEstimator DEE, sunindextype* niter) { SUNErrCode ier; - int num_iters; + sunindextype num_iters; SUNDIALS_MARK_FUNCTION_BEGIN(getSUNProfiler(DEE)); if (DEE->ops->getnumofiters) { diff --git a/src/sundomeigest/ArnI/sundomeigest_arni.c b/src/sundomeigest/ArnI/sundomeigest_arni.c index d6592c4219..99152fdf0f 100644 --- a/src/sundomeigest/ArnI/sundomeigest_arni.c +++ b/src/sundomeigest/ArnI/sundomeigest_arni.c @@ -101,7 +101,7 @@ SUNDomEigEstimator SUNDomEigEst_ArnI(N_Vector q, sunindextype krydim, content->V = NULL; content->q = NULL; content->krydim = krydim; - content->power_of_A = 0; + content->numwarmups = 0; content->LAPACK_A = NULL; content->LAPACK_wr = NULL; content->LAPACK_wi = NULL; @@ -139,9 +139,9 @@ SUNErrCode SUNDomEigEstInitialize_ArnI(SUNDomEigEstimator DEE) { ArnI_CONTENT(DEE)->krydim = SUNDOMEIGEST_ARN_KRYLDIM_DEFAULT; } - if (ArnI_CONTENT(DEE)->power_of_A < 0) + if (ArnI_CONTENT(DEE)->numwarmups < 0) { - ArnI_CONTENT(DEE)->power_of_A = SUNDOMEIGEST_PI_POWER_OF_A_DEFAULT; + ArnI_CONTENT(DEE)->numwarmups = SUNDOMEIGEST_NUM_OF_WARMUPS_DEFAULT; } SUNAssert(ArnI_CONTENT(DEE)->ATimes, SUN_ERR_DEE_NULL_ATIMES); @@ -207,7 +207,7 @@ SUNErrCode SUNDomEigEstSetNumPreProcess_ArnI(SUNDomEigEstimator DEE, SUNFunctionBegin(DEE->sunctx); /* set the number of warmups */ - ArnI_CONTENT(DEE)->power_of_A = numofperprocess; + ArnI_CONTENT(DEE)->numwarmups = numofperprocess; return SUN_SUCCESS; } @@ -222,8 +222,8 @@ SUNErrCode SUNDomEigEstPreProcess_ArnI(SUNDomEigEstimator DEE) sunrealtype normq; sunindextype i, retval; - /* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ - for (i = 0; i < ArnI_CONTENT(DEE)->power_of_A; i++) + /* Set the initial q = A^{numwarmups}q/||A^{numwarmups}q|| */ + for (i = 0; i < ArnI_CONTENT(DEE)->numwarmups; i++) { retval = ArnI_CONTENT(DEE)->ATimes(ArnI_CONTENT(DEE)->ATdata, ArnI_CONTENT(DEE)->V[0], diff --git a/src/sundomeigest/PI/sundomeigest_pi.c b/src/sundomeigest/PI/sundomeigest_pi.c index 1c3c648304..591ffd7f0a 100644 --- a/src/sundomeigest/PI/sundomeigest_pi.c +++ b/src/sundomeigest/PI/sundomeigest_pi.c @@ -97,7 +97,7 @@ SUNDomEigEstimator SUNDomEigEst_PI(N_Vector q, sunindextype max_powiter, content->ATdata = NULL; content->V = NULL; content->q = NULL; - content->power_of_A = 0; + content->numwarmups = 0; content->powiter_tol = ZERO; content->res = ZERO; content->max_powiter = max_powiter; @@ -133,9 +133,9 @@ SUNErrCode SUNDomEigEstInitialize_PI(SUNDomEigEstimator DEE) { PI_CONTENT(DEE)->powiter_tol = SUNDOMEIGEST_PI_TOL_DEFAULT; } - if (PI_CONTENT(DEE)->power_of_A <= 0) + if (PI_CONTENT(DEE)->numwarmups <= 0) { - PI_CONTENT(DEE)->power_of_A = SUNDOMEIGEST_PI_POWER_OF_A_DEFAULT; + PI_CONTENT(DEE)->numwarmups = SUNDOMEIGEST_NUM_OF_WARMUPS_DEFAULT; } if (PI_CONTENT(DEE)->max_powiter <= 0) { @@ -167,7 +167,7 @@ SUNErrCode SUNDomEigEstSetNumPreProcess_PI(SUNDomEigEstimator DEE, SUNFunctionBegin(DEE->sunctx); /* set the number of warmups */ - PI_CONTENT(DEE)->power_of_A = numofperprocess; + PI_CONTENT(DEE)->numwarmups = numofperprocess; return SUN_SUCCESS; } @@ -217,8 +217,8 @@ SUNErrCode SUNDomEigEstPreProcess_PI(SUNDomEigEstimator DEE) sunrealtype normq; sunindextype i, retval; - /* Set the initial q = A^{power_of_A}q/||A^{power_of_A}q|| */ - for (i = 0; i < PI_CONTENT(DEE)->power_of_A; i++) + /* Set the initial q = A^{numwarmups}q/||A^{numwarmups}q|| */ + for (i = 0; i < PI_CONTENT(DEE)->numwarmups; i++) { retval = PI_CONTENT(DEE)->ATimes(PI_CONTENT(DEE)->ATdata, PI_CONTENT(DEE)->V, PI_CONTENT(DEE)->q); diff --git a/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c b/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c index 45876f44d4..f49a39e805 100644 --- a/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c +++ b/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c @@ -58,7 +58,7 @@ int main(int argc, char* argv[]) SUNDomEigEstimator DEE = NULL; /* domeig estimator object */ N_Vector q; /* test vectors */ UserData ProbData; /* problem data structure */ - int power_of_A; /* Power of A for the warm-up */ + int numwarmups; /* Number of the preprocessing warmups */ int max_powiter; /* max power iteration */ int krydim; /* Krylov subspace dimension */ int niter; /* number of iterations */ @@ -97,10 +97,10 @@ int main(int argc, char* argv[]) printf("ERROR: Krylov subspace dimension must be a positive integer\n"); return 1; } - power_of_A = atoi(argv[3]); - if (power_of_A < 0) + numwarmups = atoi(argv[3]); + if (numwarmups < 0) { - printf("ERROR: Number of preprocessing must be a nonnegative integer\n"); + printf("ERROR: Number of preprocessing warmups must be a nonnegative integer\n"); return 1; } print_timing = atoi(argv[4]); @@ -109,7 +109,7 @@ int main(int argc, char* argv[]) printf("\nDomEig module test:\n"); printf(" Problem size = %ld\n", (long int)ProbData.N); printf(" Krylov subspace dimension = %i\n", krydim); - printf(" Number of preprocessing = %i\n", power_of_A); + printf(" Number of preprocessing = %i\n", numwarmups); printf(" Timing output flag = %i\n\n", print_timing); /* Create vectors */ @@ -141,7 +141,7 @@ int main(int argc, char* argv[]) fails += Test_SUNDomEigEstGetID(DEE, SUNDSOMEIGESTIMATOR_ARNOLDI, 0); fails += Test_SUNDomEigEstSetATimes(DEE, &ProbData, ATimes, 0); - fails += Test_SUNDomEigEstSetNumPreProcess(DEE, power_of_A, 0); + fails += Test_SUNDomEigEstSetNumPreProcess(DEE, numwarmups, 0); // SUNDomEigEstSetMaxPowerIter is not an option for Arnoldi iteration. // It should return with SUN_SUCCESS max_powiter = krydim; diff --git a/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c b/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c index 509ef224e4..856dabbdf3 100644 --- a/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c +++ b/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c @@ -56,7 +56,7 @@ int main(int argc, char* argv[]) SUNDomEigEstimator DEE = NULL; /* domeig estimator object */ N_Vector q; /* test vectors */ UserData ProbData; /* problem data structure */ - int power_of_A; /* Power of A for the warm-up */ + int numwarmups; /* Number of the preprocessing warmups */ int max_powiter; /* max power iteration */ int niter; /* number of iterations */ int print_timing; /* timing output flag */ @@ -94,8 +94,8 @@ int main(int argc, char* argv[]) printf("ERROR: Maximum number of power iterations must be a positive integer\n"); return 1; } - power_of_A = atoi(argv[3]); - if (power_of_A < 0) + numwarmups = atoi(argv[3]); + if (numwarmups < 0) { printf("ERROR: Number of preprocessing must be a nonnegative integer\n"); return 1; @@ -106,7 +106,7 @@ int main(int argc, char* argv[]) printf("\nDomEig module test:\n"); printf(" Problem size = %ld\n", (long int)ProbData.N); printf(" Number of power iterations = %i\n", max_powiter); - printf(" Number of preprocessing = %i\n", power_of_A); + printf(" Number of preprocessing = %i\n", numwarmups); printf(" Timing output flag = %i\n\n", print_timing); /* Create vectors */ @@ -140,7 +140,7 @@ int main(int argc, char* argv[]) fails += Test_SUNDomEigEstGetID(DEE, SUNDSOMEIGESTIMATOR_POWER, 0); fails += Test_SUNDomEigEstSetATimes(DEE, &ProbData, ATimes, 0); - fails += Test_SUNDomEigEstSetNumPreProcess(DEE, power_of_A, 0); + fails += Test_SUNDomEigEstSetNumPreProcess(DEE, numwarmups, 0); fails += Test_SUNDomEigEstSetMaxPowerIter(DEE, max_powiter, 0); fails += Test_SUNDomEigEstInitialize(DEE, 0); fails += Test_SUNDomEigEstPreProcess(DEE, 0); diff --git a/test/unit_tests/sundomeigest/test_sundomeigest.c b/test/unit_tests/sundomeigest/test_sundomeigest.c index 4b5c72c047..c9a891d314 100644 --- a/test/unit_tests/sundomeigest/test_sundomeigest.c +++ b/test/unit_tests/sundomeigest/test_sundomeigest.c @@ -136,14 +136,14 @@ int Test_SUNDomEigEstSetMaxPowerIter(SUNDomEigEstimator DEE, sunindextype max_po return (0); } -int Test_SUNDomEigEstSetNumPreProcess(SUNDomEigEstimator DEE, int power_of_A, int myid) +int Test_SUNDomEigEstSetNumPreProcess(SUNDomEigEstimator DEE, int numwarmups, int myid) { int failure; double start_time, stop_time; /* try calling SUNDomEigEstSetNumPreProcess routine: should pass/fail based on expected input */ start_time = get_time(); - failure = SUNDomEigEstSetNumPreProcess(DEE, power_of_A); + failure = SUNDomEigEstSetNumPreProcess(DEE, numwarmups); // sync_device(); stop_time = get_time(); diff --git a/test/unit_tests/sundomeigest/test_sundomeigest.h b/test/unit_tests/sundomeigest/test_sundomeigest.h index dfafbfb53f..c5bf056e8a 100644 --- a/test/unit_tests/sundomeigest/test_sundomeigest.h +++ b/test/unit_tests/sundomeigest/test_sundomeigest.h @@ -35,7 +35,9 @@ int Test_SUNDomEigEstGetID(SUNDomEigEstimator DEE, SUNDomEigEstimator_ID suntype, int myid); int Test_SUNDomEigEstSetATimes(SUNDomEigEstimator DEE, void* ATdata, SUNATimesFn ATimes, int myid); -int Test_SUNDomEigEstSetNumPreProcess(SUNDomEigEstimator DEE, int power_of_A, int myid); +int Test_SUNDomEigEstSetMaxPowerIter(SUNDomEigEstimator DEE, + sunindextype max_powiter, int myid); +int Test_SUNDomEigEstSetNumPreProcess(SUNDomEigEstimator DEE, int numwarmups, int myid); int Test_SUNDomEigEstInitialize(SUNDomEigEstimator DEE, int myid); int Test_SUNDomEigEstPreProcess(SUNDomEigEstimator DEE, int myid); int Test_SUNDomEigEstComputeHess(SUNDomEigEstimator DEE, int myid); From 8461e44122f6cf489e0d14b77796fbf22c161729 Mon Sep 17 00:00:00 2001 From: maggul Date: Tue, 17 Jun 2025 12:21:44 -0500 Subject: [PATCH 045/128] new line at the end --- src/sundials/sundials_domeigestimator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sundials/sundials_domeigestimator.c b/src/sundials/sundials_domeigestimator.c index e173397daa..30cdd10dd3 100644 --- a/src/sundials/sundials_domeigestimator.c +++ b/src/sundials/sundials_domeigestimator.c @@ -215,4 +215,4 @@ SUNErrCode SUNDomEigEstRes(SUNDomEigEstimator DEE, sunrealtype* res) } SUNDIALS_MARK_FUNCTION_END(getSUNProfiler(DEE)); return (ier); -} \ No newline at end of file +} From 90016a92069f5ae52fc92d25fdf625023041358d Mon Sep 17 00:00:00 2001 From: maggul Date: Tue, 17 Jun 2025 14:06:39 -0500 Subject: [PATCH 046/128] CI debugs --- doc/shared/sundomeigest/SUNDomEigEst_ARNI.rst | 2 +- include/sundials/sundials_domeigestimator.h | 12 +++++----- include/sundomeigest/sundomeigest_arni.h | 8 +++---- include/sundomeigest/sundomeigest_pi.h | 14 +++++------ .../fmod_int32/fsundials_core_mod.f90 | 23 ++++++++++--------- .../fmod_int64/fsundials_core_mod.f90 | 23 ++++++++++--------- src/sundials/sundials_domeigestimator.c | 18 ++++----------- src/sundomeigest/ArnI/sundomeigest_arni.c | 6 ++--- src/sundomeigest/PI/sundomeigest_pi.c | 8 +++---- .../sundomeigest/arni/CMakeLists.txt | 7 +++--- .../arni/test_sundomeigest_arni.c | 6 ++--- .../unit_tests/sundomeigest/pi/CMakeLists.txt | 7 +++--- .../sundomeigest/pi/test_sundomeigest_pi.c | 4 ++-- 13 files changed, 66 insertions(+), 72 deletions(-) diff --git a/doc/shared/sundomeigest/SUNDomEigEst_ARNI.rst b/doc/shared/sundomeigest/SUNDomEigEst_ARNI.rst index 4b3e602dab..9ba817e2e3 100644 --- a/doc/shared/sundomeigest/SUNDomEigEst_ARNI.rst +++ b/doc/shared/sundomeigest/SUNDomEigEst_ARNI.rst @@ -40,7 +40,7 @@ SUNDomEigEst_ARNI Usage The header file to be included when using this module is ``sundomeigest/sundomeigest_arni.h``. The SUNDomEigEst_ARNI module is accessible from all SUNDIALS solvers *without* linking to the ``libsundials_sundomeigestarni`` module library after enabling LAPACK package. -This LAPACK dependence is limitted to the ``dgeev_`` function after computing Hessenberg matrix internally. +This LAPACK dependence is limited to the ``dgeev_`` function after computing Hessenberg matrix internally. The module SUNDomEigEst_ARNI provides the following user-callable routines: diff --git a/include/sundials/sundials_domeigestimator.h b/include/sundials/sundials_domeigestimator.h index dca6cb5dba..4970980b5a 100644 --- a/include/sundials/sundials_domeigestimator.h +++ b/include/sundials/sundials_domeigestimator.h @@ -65,14 +65,14 @@ struct _generic_SUNDomEigEstimator_Ops { SUNDomEigEstimator_ID (*getid)(SUNDomEigEstimator); SUNErrCode (*setatimes)(SUNDomEigEstimator, void*, SUNATimesFn); - SUNErrCode (*setmaxpoweriter)(SUNDomEigEstimator, sunindextype); - SUNErrCode (*setnumofperprocess)(SUNDomEigEstimator, sunindextype); + SUNErrCode (*setmaxpoweriter)(SUNDomEigEstimator, int); + SUNErrCode (*setnumofperprocess)(SUNDomEigEstimator, int); SUNErrCode (*settol)(SUNDomEigEstimator, sunrealtype); SUNErrCode (*initialize)(SUNDomEigEstimator); SUNErrCode (*preprocess)(SUNDomEigEstimator); SUNErrCode (*computehess)(SUNDomEigEstimator); SUNErrCode (*estimate)(SUNDomEigEstimator, suncomplextype*); - SUNErrCode (*getnumofiters)(SUNDomEigEstimator, sunindextype*); + SUNErrCode (*getnumofiters)(SUNDomEigEstimator, int*); SUNErrCode (*getres)(SUNDomEigEstimator, sunrealtype*); SUNErrCode (*free)(SUNDomEigEstimator); }; @@ -106,11 +106,11 @@ SUNErrCode SUNDomEigEstSetATimes(SUNDomEigEstimator DEE, void* A_data, SUNDIALS_EXPORT SUNErrCode SUNDomEigEstSetMaxPowerIter(SUNDomEigEstimator DEE, - sunindextype max_powiter); + int max_powiter); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstSetNumPreProcess(SUNDomEigEstimator DEE, - sunindextype numofperprocess); + int numofperprocess); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstSetTol(SUNDomEigEstimator DEE, sunrealtype tol); @@ -128,7 +128,7 @@ SUNDIALS_EXPORT SUNErrCode SUNDomEigEstimate(SUNDomEigEstimator DEE, suncomplextype* dom_eig); SUNDIALS_EXPORT -SUNErrCode SUNDomEigEstNumIters(SUNDomEigEstimator DEE, sunindextype* niter); +SUNErrCode SUNDomEigEstNumIters(SUNDomEigEstimator DEE, int* niter); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstRes(SUNDomEigEstimator DEE, sunrealtype* res); diff --git a/include/sundomeigest/sundomeigest_arni.h b/include/sundomeigest/sundomeigest_arni.h index c70c53432b..80f75e6ae7 100644 --- a/include/sundomeigest/sundomeigest_arni.h +++ b/include/sundomeigest/sundomeigest_arni.h @@ -45,8 +45,8 @@ struct _SUNDomEigEstimatorContent_ArnI N_Vector *V, q; /* Krylov subspace vectors */ - sunindextype krydim; /* Krylov subspace dimension */ - sunindextype numwarmups; /* Power of A in the preprocessing; initial q = A^{numwarmups}q/||A^{numwarmups}q|| */ + int krydim; /* Krylov subspace dimension */ + int numwarmups; /* Power of A in the preprocessing; initial q = A^{numwarmups}q/||A^{numwarmups}q|| */ sunrealtype* LAPACK_A; /* The vector which holds rows of the Hessenberg matrix in the given order */ sunrealtype* LAPACK_wr; /* Real parts of eigenvalues */ @@ -64,7 +64,7 @@ typedef struct _SUNDomEigEstimatorContent_ArnI* SUNDomEigEstimatorContent_ArnI; * --------------------------------------- */ SUNDIALS_EXPORT -SUNDomEigEstimator SUNDomEigEst_ArnI(N_Vector q, sunindextype krydim, +SUNDomEigEstimator SUNDomEigEst_ArnI(N_Vector q, int krydim, SUNContext sunctx); SUNDIALS_EXPORT @@ -79,7 +79,7 @@ SUNErrCode SUNDomEigEstInitialize_ArnI(SUNDomEigEstimator DEE); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstSetNumPreProcess_ArnI(SUNDomEigEstimator DEE, - sunindextype numofperprocess); + int numofperprocess); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstPreProcess_ArnI(SUNDomEigEstimator DEE); diff --git a/include/sundomeigest/sundomeigest_pi.h b/include/sundomeigest/sundomeigest_pi.h index 7f2ee9dec9..22a23fdfb9 100644 --- a/include/sundomeigest/sundomeigest_pi.h +++ b/include/sundomeigest/sundomeigest_pi.h @@ -44,12 +44,12 @@ struct _SUNDomEigEstimatorContent_PI N_Vector V, q; /* workspace vectors */ - sunindextype numwarmups; /* Power of A in the preprocessing; initial q = A^{numwarmups}q/||A^{numwarmups}q|| */ + int numwarmups; /* Power of A in the preprocessing; initial q = A^{numwarmups}q/||A^{numwarmups}q|| */ sunrealtype powiter_tol; /* Convergence criteria for the power iteration */ sunrealtype res; /* Current residual of power iterations */ - sunindextype max_powiter; /* Maximum number of power iterations */ - sunindextype numiters; /* Current number of power iterations */ + int max_powiter; /* Maximum number of power iterations */ + int numiters; /* Current number of power iterations */ }; typedef struct _SUNDomEigEstimatorContent_PI* SUNDomEigEstimatorContent_PI; @@ -59,7 +59,7 @@ typedef struct _SUNDomEigEstimatorContent_PI* SUNDomEigEstimatorContent_PI; * --------------------------------------- */ SUNDIALS_EXPORT -SUNDomEigEstimator SUNDomEigEst_PI(N_Vector q, sunindextype max_powiter, +SUNDomEigEstimator SUNDomEigEst_PI(N_Vector q, int max_powiter, SUNContext sunctx); SUNDIALS_EXPORT @@ -74,14 +74,14 @@ SUNErrCode SUNDomEigEstInitialize_PI(SUNDomEigEstimator DEE); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstSetNumPreProcess_PI(SUNDomEigEstimator DEE, - sunindextype numofperprocess); + int numofperprocess); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstSetTol_PI(SUNDomEigEstimator DEE, sunrealtype tol); SUNDIALS_EXPORT SUNErrCode SUNDomEigEst_PISetMaxPowerIter(SUNDomEigEstimator DEE, - sunindextype max_powiter); + int max_powiter); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstPreProcess_PI(SUNDomEigEstimator DEE); @@ -90,7 +90,7 @@ SUNDIALS_EXPORT SUNErrCode SUNDomEigEstimate_PI(SUNDomEigEstimator DEE, suncomplextype* dom_eig); SUNDIALS_EXPORT -SUNErrCode SUNDomEigEstNumIters_PI(SUNDomEigEstimator DEE, sunindextype* niter); +SUNErrCode SUNDomEigEstNumIters_PI(SUNDomEigEstimator DEE, int* niter); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstRes_PI(SUNDomEigEstimator DEE, sunrealtype* res); diff --git a/src/sundials/fmod_int32/fsundials_core_mod.f90 b/src/sundials/fmod_int32/fsundials_core_mod.f90 index 51b6a0ec2e..4dc4121ea1 100644 --- a/src/sundials/fmod_int32/fsundials_core_mod.f90 +++ b/src/sundials/fmod_int32/fsundials_core_mod.f90 @@ -90,13 +90,14 @@ module fsundials_core_mod enumerator :: SUN_ERR_ADJOINT_STEPPERINVALIDSTOP enumerator :: SUN_ERR_CHECKPOINT_NOT_FOUND enumerator :: SUN_ERR_CHECKPOINT_MISMATCH - enumerator :: SUN_ERR_DOMEIG_BAD_NVECTOR - enumerator :: SUN_ERR_DOMEIG_NULL_ATIMES - enumerator :: SUN_ERR_DOMEIG_NULL_HES - enumerator :: SUN_ERR_DOMEIG_NOT_ENOUGH_ITER - enumerator :: SUN_ERR_DOMEIG_ATIMES_FAIL_REC - enumerator :: SUN_ERR_DOMEIG_ATIMES_FAIL_UNREC - enumerator :: SUN_ERR_DOMEIG_LAPACK_FAIL + enumerator :: SUN_ERR_DEE_BAD_NVECTOR + enumerator :: SUN_ERR_DEE_NULL_ATIMES + enumerator :: SUN_ERR_DEE_ATIMES_FAIL_REC + enumerator :: SUN_ERR_DEE_ATIMES_FAIL_UNREC + enumerator :: SUN_ERR_DEE_NULL_HES + enumerator :: SUN_ERR_DEE_NULL_MEM + enumerator :: SUN_ERR_DEE_NULL_CONTENT + enumerator :: SUN_ERR_DEE_LAPACK_FAIL enumerator :: SUN_ERR_SUNCTX_CORRUPT enumerator :: SUN_ERR_MPI_FAIL enumerator :: SUN_ERR_UNREACHABLE @@ -109,10 +110,10 @@ module fsundials_core_mod SUN_ERR_MEM_FAIL, SUN_ERR_MALLOC_FAIL, SUN_ERR_EXT_FAIL, SUN_ERR_DESTROY_FAIL, SUN_ERR_NOT_IMPLEMENTED, & SUN_ERR_USER_FCN_FAIL, SUN_ERR_DATANODE_NODENOTFOUND, SUN_ERR_PROFILER_MAPFULL, SUN_ERR_PROFILER_MAPGET, & SUN_ERR_PROFILER_MAPINSERT, SUN_ERR_PROFILER_MAPKEYNOTFOUND, SUN_ERR_PROFILER_MAPSORT, SUN_ERR_ADJOINT_STEPPERFAILED, & - SUN_ERR_ADJOINT_STEPPERINVALIDSTOP, SUN_ERR_CHECKPOINT_NOT_FOUND, SUN_ERR_CHECKPOINT_MISMATCH, SUN_ERR_DOMEIG_BAD_NVECTOR, & - SUN_ERR_DOMEIG_NULL_ATIMES, SUN_ERR_DOMEIG_NULL_HES, SUN_ERR_DOMEIG_NOT_ENOUGH_ITER, SUN_ERR_DOMEIG_ATIMES_FAIL_REC, & - SUN_ERR_DOMEIG_ATIMES_FAIL_UNREC, SUN_ERR_DOMEIG_LAPACK_FAIL, SUN_ERR_SUNCTX_CORRUPT, SUN_ERR_MPI_FAIL, SUN_ERR_UNREACHABLE, & - SUN_ERR_UNKNOWN, SUN_ERR_MAXIMUM, SUN_SUCCESS + SUN_ERR_ADJOINT_STEPPERINVALIDSTOP, SUN_ERR_CHECKPOINT_NOT_FOUND, SUN_ERR_CHECKPOINT_MISMATCH, SUN_ERR_DEE_BAD_NVECTOR, & + SUN_ERR_DEE_NULL_ATIMES, SUN_ERR_DEE_ATIMES_FAIL_REC, SUN_ERR_DEE_ATIMES_FAIL_UNREC, SUN_ERR_DEE_NULL_HES, & + SUN_ERR_DEE_NULL_MEM, SUN_ERR_DEE_NULL_CONTENT, SUN_ERR_DEE_LAPACK_FAIL, SUN_ERR_SUNCTX_CORRUPT, SUN_ERR_MPI_FAIL, & + SUN_ERR_UNREACHABLE, SUN_ERR_UNKNOWN, SUN_ERR_MAXIMUM, SUN_SUCCESS type, bind(C) :: SwigArrayWrapper type(C_PTR), public :: data = C_NULL_PTR integer(C_SIZE_T), public :: size = 0 diff --git a/src/sundials/fmod_int64/fsundials_core_mod.f90 b/src/sundials/fmod_int64/fsundials_core_mod.f90 index 03902629e0..416e45718e 100644 --- a/src/sundials/fmod_int64/fsundials_core_mod.f90 +++ b/src/sundials/fmod_int64/fsundials_core_mod.f90 @@ -90,13 +90,14 @@ module fsundials_core_mod enumerator :: SUN_ERR_ADJOINT_STEPPERINVALIDSTOP enumerator :: SUN_ERR_CHECKPOINT_NOT_FOUND enumerator :: SUN_ERR_CHECKPOINT_MISMATCH - enumerator :: SUN_ERR_DOMEIG_BAD_NVECTOR - enumerator :: SUN_ERR_DOMEIG_NULL_ATIMES - enumerator :: SUN_ERR_DOMEIG_NULL_HES - enumerator :: SUN_ERR_DOMEIG_NOT_ENOUGH_ITER - enumerator :: SUN_ERR_DOMEIG_ATIMES_FAIL_REC - enumerator :: SUN_ERR_DOMEIG_ATIMES_FAIL_UNREC - enumerator :: SUN_ERR_DOMEIG_LAPACK_FAIL + enumerator :: SUN_ERR_DEE_BAD_NVECTOR + enumerator :: SUN_ERR_DEE_NULL_ATIMES + enumerator :: SUN_ERR_DEE_ATIMES_FAIL_REC + enumerator :: SUN_ERR_DEE_ATIMES_FAIL_UNREC + enumerator :: SUN_ERR_DEE_NULL_HES + enumerator :: SUN_ERR_DEE_NULL_MEM + enumerator :: SUN_ERR_DEE_NULL_CONTENT + enumerator :: SUN_ERR_DEE_LAPACK_FAIL enumerator :: SUN_ERR_SUNCTX_CORRUPT enumerator :: SUN_ERR_MPI_FAIL enumerator :: SUN_ERR_UNREACHABLE @@ -109,10 +110,10 @@ module fsundials_core_mod SUN_ERR_MEM_FAIL, SUN_ERR_MALLOC_FAIL, SUN_ERR_EXT_FAIL, SUN_ERR_DESTROY_FAIL, SUN_ERR_NOT_IMPLEMENTED, & SUN_ERR_USER_FCN_FAIL, SUN_ERR_DATANODE_NODENOTFOUND, SUN_ERR_PROFILER_MAPFULL, SUN_ERR_PROFILER_MAPGET, & SUN_ERR_PROFILER_MAPINSERT, SUN_ERR_PROFILER_MAPKEYNOTFOUND, SUN_ERR_PROFILER_MAPSORT, SUN_ERR_ADJOINT_STEPPERFAILED, & - SUN_ERR_ADJOINT_STEPPERINVALIDSTOP, SUN_ERR_CHECKPOINT_NOT_FOUND, SUN_ERR_CHECKPOINT_MISMATCH, SUN_ERR_DOMEIG_BAD_NVECTOR, & - SUN_ERR_DOMEIG_NULL_ATIMES, SUN_ERR_DOMEIG_NULL_HES, SUN_ERR_DOMEIG_NOT_ENOUGH_ITER, SUN_ERR_DOMEIG_ATIMES_FAIL_REC, & - SUN_ERR_DOMEIG_ATIMES_FAIL_UNREC, SUN_ERR_DOMEIG_LAPACK_FAIL, SUN_ERR_SUNCTX_CORRUPT, SUN_ERR_MPI_FAIL, SUN_ERR_UNREACHABLE, & - SUN_ERR_UNKNOWN, SUN_ERR_MAXIMUM, SUN_SUCCESS + SUN_ERR_ADJOINT_STEPPERINVALIDSTOP, SUN_ERR_CHECKPOINT_NOT_FOUND, SUN_ERR_CHECKPOINT_MISMATCH, SUN_ERR_DEE_BAD_NVECTOR, & + SUN_ERR_DEE_NULL_ATIMES, SUN_ERR_DEE_ATIMES_FAIL_REC, SUN_ERR_DEE_ATIMES_FAIL_UNREC, SUN_ERR_DEE_NULL_HES, & + SUN_ERR_DEE_NULL_MEM, SUN_ERR_DEE_NULL_CONTENT, SUN_ERR_DEE_LAPACK_FAIL, SUN_ERR_SUNCTX_CORRUPT, SUN_ERR_MPI_FAIL, & + SUN_ERR_UNREACHABLE, SUN_ERR_UNKNOWN, SUN_ERR_MAXIMUM, SUN_SUCCESS type, bind(C) :: SwigArrayWrapper type(C_PTR), public :: data = C_NULL_PTR integer(C_SIZE_T), public :: size = 0 diff --git a/src/sundials/sundials_domeigestimator.c b/src/sundials/sundials_domeigestimator.c index 30cdd10dd3..897febe332 100644 --- a/src/sundials/sundials_domeigestimator.c +++ b/src/sundials/sundials_domeigestimator.c @@ -109,7 +109,7 @@ SUNErrCode SUNDomEigEstSetATimes(SUNDomEigEstimator DEE, void* A_data, return (ier); } -SUNErrCode SUNDomEigEstSetMaxPowerIter(SUNDomEigEstimator DEE, sunindextype max_powiter) +SUNErrCode SUNDomEigEstSetMaxPowerIter(SUNDomEigEstimator DEE, int max_powiter) { SUNErrCode ier; SUNDIALS_MARK_FUNCTION_BEGIN(getSUNProfiler(DEE)); @@ -119,7 +119,7 @@ SUNErrCode SUNDomEigEstSetMaxPowerIter(SUNDomEigEstimator DEE, sunindextype max_ return (ier); } -SUNErrCode SUNDomEigEstSetNumPreProcess(SUNDomEigEstimator DEE, sunindextype numofperprocess) +SUNErrCode SUNDomEigEstSetNumPreProcess(SUNDomEigEstimator DEE, int numofperprocess) { SUNErrCode ier; SUNDIALS_MARK_FUNCTION_BEGIN(getSUNProfiler(DEE)); @@ -129,16 +129,6 @@ SUNErrCode SUNDomEigEstSetNumPreProcess(SUNDomEigEstimator DEE, sunindextype num return (ier); } -SUNErrCode SUNDomEigEstSetTol_ArnI(SUNDomEigEstimator DEE, sunrealtype tol) -{ - SUNErrCode ier; - SUNDIALS_MARK_FUNCTION_BEGIN(getSUNProfiler(DEE)); - if (DEE->ops->settol) { ier = DEE->ops->settol(DEE, tol); } - else { ier = SUN_SUCCESS; } - SUNDIALS_MARK_FUNCTION_END(getSUNProfiler(DEE)); - return (ier); -} - SUNErrCode SUNDomEigEstInitialize(SUNDomEigEstimator DEE) { SUNErrCode ier; @@ -179,10 +169,10 @@ SUNErrCode SUNDomEigEstimate(SUNDomEigEstimator DEE, suncomplextype* dom_eig) return (ier); } -SUNErrCode SUNDomEigEstNumIters(SUNDomEigEstimator DEE, sunindextype* niter) +SUNErrCode SUNDomEigEstNumIters(SUNDomEigEstimator DEE, int* niter) { SUNErrCode ier; - sunindextype num_iters; + int num_iters; SUNDIALS_MARK_FUNCTION_BEGIN(getSUNProfiler(DEE)); if (DEE->ops->getnumofiters) { diff --git a/src/sundomeigest/ArnI/sundomeigest_arni.c b/src/sundomeigest/ArnI/sundomeigest_arni.c index 99152fdf0f..e36c5f3fef 100644 --- a/src/sundomeigest/ArnI/sundomeigest_arni.c +++ b/src/sundomeigest/ArnI/sundomeigest_arni.c @@ -48,7 +48,7 @@ * Function to create a new ArnI estimator */ -SUNDomEigEstimator SUNDomEigEst_ArnI(N_Vector q, sunindextype krydim, +SUNDomEigEstimator SUNDomEigEst_ArnI(N_Vector q, int krydim, SUNContext sunctx) { SUNFunctionBegin(sunctx); @@ -165,7 +165,7 @@ SUNErrCode SUNDomEigEstInitialize_ArnI(SUNDomEigEstimator DEE) /* Hessenberg matrix Hes */ if (ArnI_CONTENT(DEE)->Hes == NULL) { - sunindextype k; + int k; ArnI_CONTENT(DEE)->Hes = (sunrealtype**)malloc( (ArnI_CONTENT(DEE)->krydim + 1) * sizeof(sunrealtype*)); @@ -202,7 +202,7 @@ SUNErrCode SUNDomEigEstSetATimes_ArnI(SUNDomEigEstimator DEE, void* A_data, } SUNErrCode SUNDomEigEstSetNumPreProcess_ArnI(SUNDomEigEstimator DEE, - sunindextype numofperprocess) + int numofperprocess) { SUNFunctionBegin(DEE->sunctx); diff --git a/src/sundomeigest/PI/sundomeigest_pi.c b/src/sundomeigest/PI/sundomeigest_pi.c index 591ffd7f0a..fa53b06065 100644 --- a/src/sundomeigest/PI/sundomeigest_pi.c +++ b/src/sundomeigest/PI/sundomeigest_pi.c @@ -48,7 +48,7 @@ * Function to create a new PI estimator */ -SUNDomEigEstimator SUNDomEigEst_PI(N_Vector q, sunindextype max_powiter, +SUNDomEigEstimator SUNDomEigEst_PI(N_Vector q, int max_powiter, SUNContext sunctx) { SUNFunctionBegin(sunctx); @@ -162,7 +162,7 @@ SUNErrCode SUNDomEigEstInitialize_PI(SUNDomEigEstimator DEE) } SUNErrCode SUNDomEigEstSetNumPreProcess_PI(SUNDomEigEstimator DEE, - sunindextype numofperprocess) + int numofperprocess) { SUNFunctionBegin(DEE->sunctx); @@ -194,7 +194,7 @@ SUNErrCode SUNDomEigEstSetATimes_PI(SUNDomEigEstimator DEE, void* A_data, } SUNErrCode SUNDomEigEst_PISetMaxPowerIter(SUNDomEigEstimator DEE, - sunindextype max_powiter) + int max_powiter) { SUNFunctionBegin(DEE->sunctx); @@ -295,7 +295,7 @@ SUNErrCode SUNDomEigEstimate_PI(SUNDomEigEstimator DEE, suncomplextype* dom_eig) return SUN_SUCCESS; } -SUNErrCode SUNDomEigEstNumIters_PI(SUNDomEigEstimator DEE, sunindextype* niter) +SUNErrCode SUNDomEigEstNumIters_PI(SUNDomEigEstimator DEE, int* niter) { SUNFunctionBegin(DEE->sunctx); SUNAssert(DEE, SUN_ERR_DEE_NULL_MEM); diff --git a/test/unit_tests/sundomeigest/arni/CMakeLists.txt b/test/unit_tests/sundomeigest/arni/CMakeLists.txt index 0dbbdad326..6eb6a6277c 100644 --- a/test/unit_tests/sundomeigest/arni/CMakeLists.txt +++ b/test/unit_tests/sundomeigest/arni/CMakeLists.txt @@ -19,9 +19,10 @@ # Examples using SUNDIALS ArnI dominant eigenvalue estimator set(sundomeigest_arni_examples - "test_sundomeigest_arni\;100 10 10 0\;" - "test_sundomeigest_arni\;1000 10 10 0\;" - "test_sundomeigest_arni\;10000 10 10 0\;") + "test_sundomeigest_arni\;100 3 20 0\;" + "test_sundomeigest_arni\;1000 3 20 0\;" + "test_sundomeigest_arni\;10000 3 20 0\;" + "test_sundomeigest_arni\;100000 3 20 0\;") # Dependencies for dominant eigenvalue examples set(sundomeigest_arni_dependencies test_sundomeigest) diff --git a/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c b/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c index f49a39e805..71019d534a 100644 --- a/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c +++ b/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c @@ -120,7 +120,7 @@ int main(int argc, char* argv[]) /* Fill matrix diagonal and problem data */ // real diag is [3 4 5 ... N 0 0]*factor - // 2x2 block marix attached to the last two diagonals is + // 2x2 block matrix attached to the last two diagonals is // [ realpart imagpart; // [-imagpart realpart] // This setup allows two types of dominant eigenvalues (real and complex) @@ -131,7 +131,7 @@ int main(int argc, char* argv[]) { v[i] = factor * (i + 3); } - // Set the probem data corresponding to 2x2 block marix + // Set the problem data corresponding to 2x2 block matrix ProbData.real_part = realpart; ProbData.imag_part = imagpart; @@ -188,7 +188,7 @@ int main(int argc, char* argv[]) /* Identify the true_dom_eig based on given parameters*/ if (SUNRsqrt(realpart * realpart + imagpart * imagpart) > -factor * ProbData.N) { - /* Dominant eigenvalue corresponds to the 2x2 block marix */ + /* Dominant eigenvalue corresponds to the 2x2 block matrix */ true_dom_eig.real = realpart; true_dom_eig.imag = imagpart; } diff --git a/test/unit_tests/sundomeigest/pi/CMakeLists.txt b/test/unit_tests/sundomeigest/pi/CMakeLists.txt index 8f24d82f02..bf6fcc5909 100644 --- a/test/unit_tests/sundomeigest/pi/CMakeLists.txt +++ b/test/unit_tests/sundomeigest/pi/CMakeLists.txt @@ -19,9 +19,10 @@ # Examples using SUNDIALS PI dominant eigenvalue estimator set(sundomeigest_pi_examples - "test_sundomeigest_pi\;100 10 10 0\;" - "test_sundomeigest_pi\;1000 10 10 0\;" - "test_sundomeigest_pi\;10000 10 10 0\;") + "test_sundomeigest_pi\;100 100 0 0\;" + "test_sundomeigest_pi\;1000 100 0 0\;" + "test_sundomeigest_pi\;10000 100 0 0\;" + "test_sundomeigest_pi\;10000 10 90 0\;") # Dependencies for dominant eigenvalue examples set(sundomeigest_pi_dependencies test_sundomeigest) diff --git a/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c b/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c index 856dabbdf3..73645816ea 100644 --- a/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c +++ b/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c @@ -117,7 +117,7 @@ int main(int argc, char* argv[]) /* Fill matrix diagonal and problem data */ // real diag is [3 4 5 ... N 0 0]*factor - // 2x2 block marix attached to the last two diagonals is + // 2x2 block matrix attached to the last two diagonals is // [ A11 A12 ] // [ A12 A11 ] // This setup allows two different dominant eigenvalues @@ -130,7 +130,7 @@ int main(int argc, char* argv[]) v[i] = factor * (i + 3); } - // Set the probem data corresponding to 2x2 block marix + // Set the problem data corresponding to 2x2 block matrix ProbData.A11 = diagonal; ProbData.A12 = nondiagonal; From 84898ac2b884e5abc68720e49e951c0791890803 Mon Sep 17 00:00:00 2001 From: maggul Date: Tue, 17 Jun 2025 14:11:32 -0500 Subject: [PATCH 047/128] format patch --- include/sundials/sundials_domeigestimator.h | 5 ++- include/sundomeigest/sundomeigest_arni.h | 7 ++--- include/sundomeigest/sundomeigest_pi.h | 14 ++++----- src/arkode/arkode_lsrkstep.c | 8 ++--- src/arkode/arkode_lsrkstep_impl.h | 4 +-- src/nvector/parhyp/nvector_parhyp.c | 2 +- src/sundials/sundials_domeigestimator.c | 21 ++++++++----- src/sundomeigest/ArnI/sundomeigest_arni.c | 8 ++--- src/sundomeigest/PI/sundomeigest_pi.c | 14 +++------ .../arni/test_sundomeigest_arni.c | 27 ++++++++-------- .../sundomeigest/pi/test_sundomeigest_pi.c | 31 +++++++++---------- .../sundomeigest/test_sundomeigest.c | 28 +++++++++-------- .../sundomeigest/test_sundomeigest.h | 6 ++-- 13 files changed, 86 insertions(+), 89 deletions(-) diff --git a/include/sundials/sundials_domeigestimator.h b/include/sundials/sundials_domeigestimator.h index 4970980b5a..32eaf18dd7 100644 --- a/include/sundials/sundials_domeigestimator.h +++ b/include/sundials/sundials_domeigestimator.h @@ -31,7 +31,7 @@ extern "C" { #endif /* Default estimator parameters */ -#define SUNDOMEIGEST_NUM_OF_WARMUPS_DEFAULT 0 +#define SUNDOMEIGEST_NUM_OF_WARMUPS_DEFAULT 0 // Struct to hold the real and imaginary parts typedef struct @@ -105,8 +105,7 @@ SUNErrCode SUNDomEigEstSetATimes(SUNDomEigEstimator DEE, void* A_data, SUNATimesFn ATimes); SUNDIALS_EXPORT -SUNErrCode SUNDomEigEstSetMaxPowerIter(SUNDomEigEstimator DEE, - int max_powiter); +SUNErrCode SUNDomEigEstSetMaxPowerIter(SUNDomEigEstimator DEE, int max_powiter); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstSetNumPreProcess(SUNDomEigEstimator DEE, diff --git a/include/sundomeigest/sundomeigest_arni.h b/include/sundomeigest/sundomeigest_arni.h index 80f75e6ae7..b7c38fbaeb 100644 --- a/include/sundomeigest/sundomeigest_arni.h +++ b/include/sundomeigest/sundomeigest_arni.h @@ -31,8 +31,8 @@ extern "C" { #endif /* Default Arnoldi Iteration parameters */ -#define SUNDOMEIGEST_ARN_KRYLDIM_DEFAULT 3 -#define SUNDOMEIGEST_LAPACK_FAIL "Error: LAPACK dgeev failed with info = %d\n" +#define SUNDOMEIGEST_ARN_KRYLDIM_DEFAULT 3 +#define SUNDOMEIGEST_LAPACK_FAIL "Error: LAPACK dgeev failed with info = %d\n" /* ----------------------------------------------------- * Arnoldi Iteration Implementation of SUNDomEigEstimator @@ -64,8 +64,7 @@ typedef struct _SUNDomEigEstimatorContent_ArnI* SUNDomEigEstimatorContent_ArnI; * --------------------------------------- */ SUNDIALS_EXPORT -SUNDomEigEstimator SUNDomEigEst_ArnI(N_Vector q, int krydim, - SUNContext sunctx); +SUNDomEigEstimator SUNDomEigEst_ArnI(N_Vector q, int krydim, SUNContext sunctx); SUNDIALS_EXPORT SUNDomEigEstimator_ID SUNDomEigEst_ArnIGetID(SUNDomEigEstimator DEE); diff --git a/include/sundomeigest/sundomeigest_pi.h b/include/sundomeigest/sundomeigest_pi.h index 22a23fdfb9..4378425a31 100644 --- a/include/sundomeigest/sundomeigest_pi.h +++ b/include/sundomeigest/sundomeigest_pi.h @@ -30,8 +30,8 @@ extern "C" { #endif /* Default Power Iteration parameters */ -#define SUNDOMEIGEST_PI_TOL_DEFAULT SUN_RCONST(0.01) -#define SUNDOMEIGEST_MAX_PI_DEFAULT 100 +#define SUNDOMEIGEST_PI_TOL_DEFAULT SUN_RCONST(0.01) +#define SUNDOMEIGEST_MAX_PI_DEFAULT 100 /* ----------------------------------------------------- * Power Iteration Implementation of SUNDomEigEstimator @@ -44,12 +44,12 @@ struct _SUNDomEigEstimatorContent_PI N_Vector V, q; /* workspace vectors */ - int numwarmups; /* Power of A in the preprocessing; initial q = A^{numwarmups}q/||A^{numwarmups}q|| */ + int numwarmups; /* Power of A in the preprocessing; initial q = A^{numwarmups}q/||A^{numwarmups}q|| */ - sunrealtype powiter_tol; /* Convergence criteria for the power iteration */ - sunrealtype res; /* Current residual of power iterations */ - int max_powiter; /* Maximum number of power iterations */ - int numiters; /* Current number of power iterations */ + sunrealtype powiter_tol; /* Convergence criteria for the power iteration */ + sunrealtype res; /* Current residual of power iterations */ + int max_powiter; /* Maximum number of power iterations */ + int numiters; /* Current number of power iterations */ }; typedef struct _SUNDomEigEstimatorContent_PI* SUNDomEigEstimatorContent_PI; diff --git a/src/arkode/arkode_lsrkstep.c b/src/arkode/arkode_lsrkstep.c index b8d7500b9b..b039409898 100644 --- a/src/arkode/arkode_lsrkstep.c +++ b/src/arkode/arkode_lsrkstep.c @@ -2316,10 +2316,10 @@ SUNDomEigEstimator lsrkStep_DomEigCreate(void* arkode_mem) /* Allocate and fill domeig_q vector with random data */ /* TODO: check if we have to clone or just passing yn is ok! */ - step_mem->domeig_q = N_VClone(ark_mem->yn); - step_mem->domeig_krydim = DOMEIG_KRYLOV_DIM_DEFAULT; - step_mem->numwarmups = SUNDOMEIGEST_NUM_OF_WARMUPS_DEFAULT; - step_mem->domeig_maxiters = DOMEIG_MAX_NUMBER_OF_POWER_ITERS_DEFAULT; + step_mem->domeig_q = N_VClone(ark_mem->yn); + step_mem->domeig_krydim = DOMEIG_KRYLOV_DIM_DEFAULT; + step_mem->numwarmups = SUNDOMEIGEST_NUM_OF_WARMUPS_DEFAULT; + step_mem->domeig_maxiters = DOMEIG_MAX_NUMBER_OF_POWER_ITERS_DEFAULT; /* Enforce the power iteration if the problem size < 3 */ if (step_mem->internal_domeigest_type == ARKODE_LSRK_ARNOLDI_ITERATION && diff --git a/src/arkode/arkode_lsrkstep_impl.h b/src/arkode/arkode_lsrkstep_impl.h index 392cf0e7f8..939fe9efd2 100644 --- a/src/arkode/arkode_lsrkstep_impl.h +++ b/src/arkode/arkode_lsrkstep_impl.h @@ -168,8 +168,8 @@ typedef struct ARKodeLSRKStepMemRec SUNDomEigEstimator DEE; /* DomEig estimator*/ N_Vector domeig_q; /* DomEig initial q vector*/ int domeig_krydim; /* Krylov subspace dimension */ - int numwarmups; /* Power of A in the preprocessing; initial q = A^{numwarmups}q/||A^{numwarmups}q|| */ - int domeig_maxiters; /* Max number of Power Iterations */ + int numwarmups; /* Power of A in the preprocessing; initial q = A^{numwarmups}q/||A^{numwarmups}q|| */ + int domeig_maxiters; /* Max number of Power Iterations */ /* Flags */ sunbooleantype dom_eig_update; /* flag indicating new dom_eig is needed */ diff --git a/src/nvector/parhyp/nvector_parhyp.c b/src/nvector/parhyp/nvector_parhyp.c index e7d6bb15b4..a2bf513c19 100644 --- a/src/nvector/parhyp/nvector_parhyp.c +++ b/src/nvector/parhyp/nvector_parhyp.c @@ -237,7 +237,7 @@ N_Vector N_VNewEmpty_ParHyp(MPI_Comm comm, sunindextype local_length, /* Seed random number generator with MPI rank ID to ensure distinct streams */ SUNCheckMPICallNull(MPI_Comm_rank(comm, &myid)); - srand(myid+1); + srand(myid + 1); return (v); } diff --git a/src/sundials/sundials_domeigestimator.c b/src/sundials/sundials_domeigestimator.c index 897febe332..ec57407b74 100644 --- a/src/sundials/sundials_domeigestimator.c +++ b/src/sundials/sundials_domeigestimator.c @@ -113,17 +113,24 @@ SUNErrCode SUNDomEigEstSetMaxPowerIter(SUNDomEigEstimator DEE, int max_powiter) { SUNErrCode ier; SUNDIALS_MARK_FUNCTION_BEGIN(getSUNProfiler(DEE)); - if (DEE->ops->setmaxpoweriter) { ier = DEE->ops->setmaxpoweriter(DEE, max_powiter); } + if (DEE->ops->setmaxpoweriter) + { + ier = DEE->ops->setmaxpoweriter(DEE, max_powiter); + } else { ier = SUN_SUCCESS; } SUNDIALS_MARK_FUNCTION_END(getSUNProfiler(DEE)); return (ier); } -SUNErrCode SUNDomEigEstSetNumPreProcess(SUNDomEigEstimator DEE, int numofperprocess) +SUNErrCode SUNDomEigEstSetNumPreProcess(SUNDomEigEstimator DEE, + int numofperprocess) { SUNErrCode ier; SUNDIALS_MARK_FUNCTION_BEGIN(getSUNProfiler(DEE)); - if (DEE->ops->setnumofperprocess) { ier = DEE->ops->setnumofperprocess(DEE, numofperprocess); } + if (DEE->ops->setnumofperprocess) + { + ier = DEE->ops->setnumofperprocess(DEE, numofperprocess); + } else { ier = SUN_SUCCESS; } SUNDIALS_MARK_FUNCTION_END(getSUNProfiler(DEE)); return (ier); @@ -176,13 +183,13 @@ SUNErrCode SUNDomEigEstNumIters(SUNDomEigEstimator DEE, int* niter) SUNDIALS_MARK_FUNCTION_BEGIN(getSUNProfiler(DEE)); if (DEE->ops->getnumofiters) { - ier = DEE->ops->getnumofiters(DEE, &num_iters); + ier = DEE->ops->getnumofiters(DEE, &num_iters); *niter = num_iters; } else { *niter = 0; - ier = SUN_SUCCESS; + ier = SUN_SUCCESS; } SUNDIALS_MARK_FUNCTION_END(getSUNProfiler(DEE)); return (ier); @@ -195,13 +202,13 @@ SUNErrCode SUNDomEigEstRes(SUNDomEigEstimator DEE, sunrealtype* res) SUNDIALS_MARK_FUNCTION_BEGIN(getSUNProfiler(DEE)); if (DEE->ops->getres) { - ier = DEE->ops->getres(DEE, &residual); + ier = DEE->ops->getres(DEE, &residual); *res = residual; } else { *res = SUN_RCONST(0.0); - ier = SUN_SUCCESS; + ier = SUN_SUCCESS; } SUNDIALS_MARK_FUNCTION_END(getSUNProfiler(DEE)); return (ier); diff --git a/src/sundomeigest/ArnI/sundomeigest_arni.c b/src/sundomeigest/ArnI/sundomeigest_arni.c index e36c5f3fef..2fb2c8b9b0 100644 --- a/src/sundomeigest/ArnI/sundomeigest_arni.c +++ b/src/sundomeigest/ArnI/sundomeigest_arni.c @@ -48,18 +48,14 @@ * Function to create a new ArnI estimator */ -SUNDomEigEstimator SUNDomEigEst_ArnI(N_Vector q, int krydim, - SUNContext sunctx) +SUNDomEigEstimator SUNDomEigEst_ArnI(N_Vector q, int krydim, SUNContext sunctx) { SUNFunctionBegin(sunctx); SUNDomEigEstimator DEE; SUNDomEigEstimatorContent_ArnI content; /* Check if krydim >= 2 */ - if(krydim < 3) - { - krydim = SUNDOMEIGEST_ARN_KRYLDIM_DEFAULT; - } + if (krydim < 3) { krydim = SUNDOMEIGEST_ARN_KRYLDIM_DEFAULT; } /* check for legal q; if illegal return NULL */ // TO DO: check required vector operations diff --git a/src/sundomeigest/PI/sundomeigest_pi.c b/src/sundomeigest/PI/sundomeigest_pi.c index fa53b06065..ab68c85f40 100644 --- a/src/sundomeigest/PI/sundomeigest_pi.c +++ b/src/sundomeigest/PI/sundomeigest_pi.c @@ -48,8 +48,7 @@ * Function to create a new PI estimator */ -SUNDomEigEstimator SUNDomEigEst_PI(N_Vector q, int max_powiter, - SUNContext sunctx) +SUNDomEigEstimator SUNDomEigEst_PI(N_Vector q, int max_powiter, SUNContext sunctx) { SUNFunctionBegin(sunctx); SUNDomEigEstimator DEE; @@ -171,8 +170,7 @@ SUNErrCode SUNDomEigEstSetNumPreProcess_PI(SUNDomEigEstimator DEE, return SUN_SUCCESS; } -SUNErrCode SUNDomEigEstSetTol_PI(SUNDomEigEstimator DEE, - sunrealtype tol) +SUNErrCode SUNDomEigEstSetTol_PI(SUNDomEigEstimator DEE, sunrealtype tol) { SUNFunctionBegin(DEE->sunctx); @@ -193,8 +191,7 @@ SUNErrCode SUNDomEigEstSetATimes_PI(SUNDomEigEstimator DEE, void* A_data, return SUN_SUCCESS; } -SUNErrCode SUNDomEigEst_PISetMaxPowerIter(SUNDomEigEstimator DEE, - int max_powiter) +SUNErrCode SUNDomEigEst_PISetMaxPowerIter(SUNDomEigEstimator DEE, int max_powiter) { SUNFunctionBegin(DEE->sunctx); @@ -274,10 +271,7 @@ SUNErrCode SUNDomEigEstimate_PI(SUNDomEigEstimator DEE, suncomplextype* dom_eig) PI_CONTENT(DEE)->res = fabs(dom_eig_new.real - dom_eig_old.real); - if (PI_CONTENT(DEE)->res < PI_CONTENT(DEE)->powiter_tol) - { - break; - } + if (PI_CONTENT(DEE)->res < PI_CONTENT(DEE)->powiter_tol) { break; } normq = N_VDotProd(PI_CONTENT(DEE)->q, PI_CONTENT(DEE)->q); SUNCheckLastErr(); diff --git a/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c b/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c index 71019d534a..6ff7356111 100644 --- a/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c +++ b/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c @@ -34,8 +34,8 @@ /* user data structure */ typedef struct { - sunindextype N; /* problem size */ - N_Vector diag; /* matrix diagonal */ + sunindextype N; /* problem size */ + N_Vector diag; /* matrix diagonal */ /* nondiagonal entries of the matrix that lead to the complex conjugate eigenvalues */ sunrealtype real_part; @@ -53,8 +53,8 @@ int check_flag(void* flagvalue, const char* funcname, int opt); * --------------------------------------------------------------------*/ int main(int argc, char* argv[]) { - int fails = 0; /* counter for test failures */ - int passfail = 0; /* overall pass/fail flag */ + int fails = 0; /* counter for test failures */ + int passfail = 0; /* overall pass/fail flag */ SUNDomEigEstimator DEE = NULL; /* domeig estimator object */ N_Vector q; /* test vectors */ UserData ProbData; /* problem data structure */ @@ -67,7 +67,7 @@ int main(int argc, char* argv[]) suncomplextype dom_eig; /* computed domeig value */ suncomplextype true_dom_eig; /* true domeig value */ SUNContext sunctx; - sunrealtype rel_tol = 1.0e-2; /* relative tol for pass/fail */ + sunrealtype rel_tol = 1.0e-2; /* relative tol for pass/fail */ sunrealtype rel_error; if (SUNContext_Create(SUN_COMM_NULL, &sunctx)) @@ -85,7 +85,7 @@ int main(int argc, char* argv[]) printf(" Number of preprocessing should be >= 0\n"); return 1; } - ProbData.N = (sunindextype)atol(argv[1]); + ProbData.N = (sunindextype)atol(argv[1]); if (ProbData.N <= 0) { printf("ERROR: Problem size must be a positive integer\n"); @@ -100,7 +100,8 @@ int main(int argc, char* argv[]) numwarmups = atoi(argv[3]); if (numwarmups < 0) { - printf("ERROR: Number of preprocessing warmups must be a nonnegative integer\n"); + printf( + "ERROR: Number of preprocessing warmups must be a nonnegative integer\n"); return 1; } print_timing = atoi(argv[4]); @@ -127,10 +128,7 @@ int main(int argc, char* argv[]) // based on the "factor" and the problem dimension N. sunrealtype* v = N_VGetArrayPointer(ProbData.diag); int i; - for (i = 0; i < ProbData.N - 2; i++) - { - v[i] = factor * (i + 3); - } + for (i = 0; i < ProbData.N - 2; i++) { v[i] = factor * (i + 3); } // Set the problem data corresponding to 2x2 block matrix ProbData.real_part = realpart; ProbData.imag_part = imagpart; @@ -153,13 +151,13 @@ int main(int argc, char* argv[]) // SUNDomEigEstNumIters and SUNDomEigEstRes are not options for // Arnoldi iteration. They should return with 0 fails += Test_SUNDomEigEstNumIters(DEE, &niter, 0); - if(niter != 0) + if (niter != 0) { printf(" >>> FAILED test -- SUNDomEigEstNumIters return value\n"); fails++; } fails += Test_SUNDomEigEstRes(DEE, &res, 0); - if(res > SUN_SMALL_REAL) + if (res > SUN_SMALL_REAL) { printf(" >>> FAILED test -- Test_SUNDomEigEstRes return value\n"); fails++; @@ -173,7 +171,8 @@ int main(int argc, char* argv[]) } else { - printf("SUCCESS: SUNDomEigEst_ArnI module passed all initialization tests\n\n"); + printf( + "SUCCESS: SUNDomEigEst_ArnI module passed all initialization tests\n\n"); } /* First check if the computed eigenvalue has a nonzero magnitute */ diff --git a/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c b/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c index 73645816ea..d0a5c2a9ab 100644 --- a/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c +++ b/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c @@ -34,10 +34,10 @@ /* user data structure */ typedef struct { - sunindextype N; /* problem size */ - N_Vector diag; /* matrix diagonal */ - sunrealtype A11; /* diagonal entries of the matrix */ - sunrealtype A12; /* nondiagonal entries of the matrix */ + sunindextype N; /* problem size */ + N_Vector diag; /* matrix diagonal */ + sunrealtype A11; /* diagonal entries of the matrix */ + sunrealtype A12; /* nondiagonal entries of the matrix */ } UserData; /* private functions */ @@ -51,8 +51,8 @@ int check_flag(void* flagvalue, const char* funcname, int opt); * --------------------------------------------------------------------*/ int main(int argc, char* argv[]) { - int fails = 0; /* counter for test failures */ - int passfail = 0; /* overall pass/fail flag */ + int fails = 0; /* counter for test failures */ + int passfail = 0; /* overall pass/fail flag */ SUNDomEigEstimator DEE = NULL; /* domeig estimator object */ N_Vector q; /* test vectors */ UserData ProbData; /* problem data structure */ @@ -64,7 +64,7 @@ int main(int argc, char* argv[]) suncomplextype dom_eig; /* computed domeig value */ suncomplextype true_dom_eig; /* true domeig value */ SUNContext sunctx; - sunrealtype rel_tol = 1.0e-2; /* relative tol for pass/fail */ + sunrealtype rel_tol = 1.0e-2; /* relative tol for pass/fail */ sunrealtype rel_error; if (SUNContext_Create(SUN_COMM_NULL, &sunctx)) @@ -82,7 +82,7 @@ int main(int argc, char* argv[]) printf(" Number of preprocessing should be >= 0\n"); return 1; } - ProbData.N = (sunindextype)atol(argv[1]); + ProbData.N = (sunindextype)atol(argv[1]); if (ProbData.N <= 0) { printf("ERROR: Problem size must be a positive integer\n"); @@ -91,7 +91,8 @@ int main(int argc, char* argv[]) max_powiter = atoi(argv[2]); if (max_powiter <= 0) { - printf("ERROR: Maximum number of power iterations must be a positive integer\n"); + printf( + "ERROR: Maximum number of power iterations must be a positive integer\n"); return 1; } numwarmups = atoi(argv[3]); @@ -125,10 +126,7 @@ int main(int argc, char* argv[]) // 2x2 block has eigenvalues A11 + A12 and A11 - A12 sunrealtype* v = N_VGetArrayPointer(ProbData.diag); int i; - for (i = 0; i < ProbData.N - 2; i++) - { - v[i] = factor * (i + 3); - } + for (i = 0; i < ProbData.N - 2; i++) { v[i] = factor * (i + 3); } // Set the problem data corresponding to 2x2 block matrix ProbData.A11 = diagonal; @@ -149,13 +147,13 @@ int main(int argc, char* argv[]) fails += Test_SUNDomEigEstComputeHess(DEE, 0); fails += Test_SUNDomEigEstimate(DEE, &dom_eig, 0); fails += Test_SUNDomEigEstNumIters(DEE, &niter, 0); - if(niter == 0) + if (niter == 0) { printf(" >>> FAILED test -- SUNDomEigEstNumIters return value\n"); fails++; } fails += Test_SUNDomEigEstRes(DEE, &res, 0); - if(res < SUN_SMALL_REAL) + if (res < SUN_SMALL_REAL) { printf(" >>> FAILED test -- Test_SUNDomEigEstRes return value\n"); fails++; @@ -169,7 +167,8 @@ int main(int argc, char* argv[]) } else { - printf("SUCCESS: SUNDomEigEst_PI module passed all initialization tests\n\n"); + printf( + "SUCCESS: SUNDomEigEst_PI module passed all initialization tests\n\n"); } /* First check if the computed eigenvalue has a nonzero magnitute */ diff --git a/test/unit_tests/sundomeigest/test_sundomeigest.c b/test/unit_tests/sundomeigest/test_sundomeigest.c index c9a891d314..085c377ee4 100644 --- a/test/unit_tests/sundomeigest/test_sundomeigest.c +++ b/test/unit_tests/sundomeigest/test_sundomeigest.c @@ -43,13 +43,13 @@ int print_time = 0; * SUNDomEigEstGetID Test * --------------------------------------------------------------------*/ int Test_SUNDomEigEstGetID(SUNDomEigEstimator DEE, - SUNDomEigEstimator_ID suntype, int myid) + SUNDomEigEstimator_ID suntype, int myid) { double start_time, stop_time; SUNDomEigEstimator_ID myestid; start_time = get_time(); - myestid = SUNDomEigEstGetID(DEE); + myestid = SUNDomEigEstGetID(DEE); // sync_device(); stop_time = get_time(); @@ -103,11 +103,11 @@ int Test_SUNDomEigEstSetATimes(SUNDomEigEstimator DEE, void* ATdata, return (0); } - /* ---------------------------------------------------------------------- * SUNDomEigEstSetMaxPowerIter Test * --------------------------------------------------------------------*/ -int Test_SUNDomEigEstSetMaxPowerIter(SUNDomEigEstimator DEE, sunindextype max_powiter, int myid) +int Test_SUNDomEigEstSetMaxPowerIter(SUNDomEigEstimator DEE, + sunindextype max_powiter, int myid) { int failure; double start_time, stop_time; @@ -120,7 +120,8 @@ int Test_SUNDomEigEstSetMaxPowerIter(SUNDomEigEstimator DEE, sunindextype max_po if (failure) { - printf(">>> FAILED test -- SUNDomEigEstSetMaxPowerIter returned %d on Proc %d \n", + printf(">>> FAILED test -- SUNDomEigEstSetMaxPowerIter returned %d on Proc " + "%d \n", failure, myid); PRINT_TIME(" SUNDomEigEstSetMaxPowerIter Time: %22.15e \n \n", stop_time - start_time); @@ -136,7 +137,8 @@ int Test_SUNDomEigEstSetMaxPowerIter(SUNDomEigEstimator DEE, sunindextype max_po return (0); } -int Test_SUNDomEigEstSetNumPreProcess(SUNDomEigEstimator DEE, int numwarmups, int myid) +int Test_SUNDomEigEstSetNumPreProcess(SUNDomEigEstimator DEE, int numwarmups, + int myid) { int failure; double start_time, stop_time; @@ -149,7 +151,8 @@ int Test_SUNDomEigEstSetNumPreProcess(SUNDomEigEstimator DEE, int numwarmups, in if (failure) { - printf(">>> FAILED test -- SUNDomEigEstSetNumPreProcess check, Proc %d \n", myid); + printf(">>> FAILED test -- SUNDomEigEstSetNumPreProcess check, Proc %d \n", + myid); PRINT_TIME(" SUNDomEigEstSetNumPreProcess Time: %22.15e \n \n", stop_time - start_time); return (1); @@ -257,7 +260,8 @@ int Test_SUNDomEigEstComputeHess(SUNDomEigEstimator DEE, int myid) /* ---------------------------------------------------------------------- * SUNDomEigEstimate Test * --------------------------------------------------------------------*/ -int Test_SUNDomEigEstimate(SUNDomEigEstimator DEE, suncomplextype* dom_eig, int myid) +int Test_SUNDomEigEstimate(SUNDomEigEstimator DEE, suncomplextype* dom_eig, + int myid) { int failure; suncomplextype estimated_dom_eig; @@ -265,7 +269,7 @@ int Test_SUNDomEigEstimate(SUNDomEigEstimator DEE, suncomplextype* dom_eig, int start_time = get_time(); failure = SUNDomEigEstimate(DEE, &estimated_dom_eig); - *dom_eig = estimated_dom_eig; + *dom_eig = estimated_dom_eig; // sync_device(); stop_time = get_time(); @@ -336,15 +340,13 @@ int Test_SUNDomEigEstRes(SUNDomEigEstimator DEE, sunrealtype* res, int myid) if (failure) { printf(">>> FAILED test -- SUNDomEigEstRes check, Proc %d \n", myid); - PRINT_TIME(" SUNDomEigEstRes Time: %22.15e \n \n", - stop_time - start_time); + PRINT_TIME(" SUNDomEigEstRes Time: %22.15e \n \n", stop_time - start_time); return (1); } else if (myid == 0) { printf(" PASSED test -- SUNDomEigEstRes \n"); - PRINT_TIME(" SUNDomEigEstRes Time: %22.15e \n \n", - stop_time - start_time); + PRINT_TIME(" SUNDomEigEstRes Time: %22.15e \n \n", stop_time - start_time); } return (0); diff --git a/test/unit_tests/sundomeigest/test_sundomeigest.h b/test/unit_tests/sundomeigest/test_sundomeigest.h index c5bf056e8a..ca5cceb2ff 100644 --- a/test/unit_tests/sundomeigest/test_sundomeigest.h +++ b/test/unit_tests/sundomeigest/test_sundomeigest.h @@ -37,11 +37,13 @@ int Test_SUNDomEigEstSetATimes(SUNDomEigEstimator DEE, void* ATdata, SUNATimesFn ATimes, int myid); int Test_SUNDomEigEstSetMaxPowerIter(SUNDomEigEstimator DEE, sunindextype max_powiter, int myid); -int Test_SUNDomEigEstSetNumPreProcess(SUNDomEigEstimator DEE, int numwarmups, int myid); +int Test_SUNDomEigEstSetNumPreProcess(SUNDomEigEstimator DEE, int numwarmups, + int myid); int Test_SUNDomEigEstInitialize(SUNDomEigEstimator DEE, int myid); int Test_SUNDomEigEstPreProcess(SUNDomEigEstimator DEE, int myid); int Test_SUNDomEigEstComputeHess(SUNDomEigEstimator DEE, int myid); -int Test_SUNDomEigEstimate(SUNDomEigEstimator DEE, suncomplextype* dom_eig, int myid); +int Test_SUNDomEigEstimate(SUNDomEigEstimator DEE, suncomplextype* dom_eig, + int myid); int Test_SUNDomEigEstNumIters(SUNDomEigEstimator DEE, int* niter, int myid); int Test_SUNDomEigEstRes(SUNDomEigEstimator DEE, sunrealtype* res, int myid); From 91304820061e6c77924d50921fc14d8dce14194b Mon Sep 17 00:00:00 2001 From: maggul Date: Tue, 17 Jun 2025 16:06:06 -0500 Subject: [PATCH 048/128] output files --- test/answers | 2 +- test/unit_tests/sundomeigest/pi/CMakeLists.txt | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/answers b/test/answers index fce92b3bd2..e0b267ebad 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit fce92b3bd28a0f1ed759de27c38273736334d387 +Subproject commit e0b267ebad014a0d99ba0152743dc4e2fbedc66b diff --git a/test/unit_tests/sundomeigest/pi/CMakeLists.txt b/test/unit_tests/sundomeigest/pi/CMakeLists.txt index bf6fcc5909..f9192ff6ed 100644 --- a/test/unit_tests/sundomeigest/pi/CMakeLists.txt +++ b/test/unit_tests/sundomeigest/pi/CMakeLists.txt @@ -19,10 +19,10 @@ # Examples using SUNDIALS PI dominant eigenvalue estimator set(sundomeigest_pi_examples - "test_sundomeigest_pi\;100 100 0 0\;" - "test_sundomeigest_pi\;1000 100 0 0\;" - "test_sundomeigest_pi\;10000 100 0 0\;" - "test_sundomeigest_pi\;10000 10 90 0\;") + "test_sundomeigest_pi\;100 100 0 0\;exclude-single" + "test_sundomeigest_pi\;1000 100 0 0\;exclude-single" + "test_sundomeigest_pi\;10000 100 0 0\;exclude-single" + "test_sundomeigest_pi\;10000 10 90 0\;exclude-single") # Dependencies for dominant eigenvalue examples set(sundomeigest_pi_dependencies test_sundomeigest) From 67f67409a80b3c447f87fc89017406789987aff1 Mon Sep 17 00:00:00 2001 From: maggul Date: Wed, 18 Jun 2025 17:04:11 -0500 Subject: [PATCH 049/128] suncomplextype to lambdaR + i lambdaI --- .../priv/sundials_domeigestimator_impl.h | 1 - include/sundials/sundials_domeigestimator.h | 12 +-- include/sundomeigest/sundomeigest_arni.h | 5 +- include/sundomeigest/sundomeigest_pi.h | 2 +- src/arkode/arkode_lsrkstep.c | 42 ++++------- src/arkode/arkode_lsrkstep_impl.h | 2 +- src/sundials/sundials_domeigestimator.c | 4 +- src/sundomeigest/ArnI/sundomeigest_arni.c | 75 ++++++++++--------- src/sundomeigest/PI/sundomeigest_pi.c | 24 +++--- .../arni/test_sundomeigest_arni.c | 30 ++++---- .../sundomeigest/pi/test_sundomeigest_pi.c | 26 +++---- .../sundomeigest/test_sundomeigest.c | 7 +- .../sundomeigest/test_sundomeigest.h | 3 +- 13 files changed, 102 insertions(+), 131 deletions(-) diff --git a/include/sundials/priv/sundials_domeigestimator_impl.h b/include/sundials/priv/sundials_domeigestimator_impl.h index 6cbce49ba6..0950d78774 100644 --- a/include/sundials/priv/sundials_domeigestimator_impl.h +++ b/include/sundials/priv/sundials_domeigestimator_impl.h @@ -30,7 +30,6 @@ extern "C" { ===============================================================*/ SUNErrCode domeig_CheckNVector(N_Vector tmpl); -sunrealtype domeig_Magnitude(const suncomplextype* c); int domeig_Compare(const void* a, const void* b); /* diff --git a/include/sundials/sundials_domeigestimator.h b/include/sundials/sundials_domeigestimator.h index 32eaf18dd7..53d238a5af 100644 --- a/include/sundials/sundials_domeigestimator.h +++ b/include/sundials/sundials_domeigestimator.h @@ -33,13 +33,6 @@ extern "C" { /* Default estimator parameters */ #define SUNDOMEIGEST_NUM_OF_WARMUPS_DEFAULT 0 -// Struct to hold the real and imaginary parts -typedef struct -{ - sunrealtype real; - sunrealtype imag; -} suncomplextype; - /* ----------------------------------------------------------------- * Implemented SUNDomEigEstimator types * ----------------------------------------------------------------- */ @@ -71,7 +64,7 @@ struct _generic_SUNDomEigEstimator_Ops SUNErrCode (*initialize)(SUNDomEigEstimator); SUNErrCode (*preprocess)(SUNDomEigEstimator); SUNErrCode (*computehess)(SUNDomEigEstimator); - SUNErrCode (*estimate)(SUNDomEigEstimator, suncomplextype*); + SUNErrCode (*estimate)(SUNDomEigEstimator, sunrealtype*, sunrealtype*); SUNErrCode (*getnumofiters)(SUNDomEigEstimator, int*); SUNErrCode (*getres)(SUNDomEigEstimator, sunrealtype*); SUNErrCode (*free)(SUNDomEigEstimator); @@ -124,7 +117,8 @@ SUNDIALS_EXPORT SUNErrCode SUNDomEigEstComputeHess(SUNDomEigEstimator DEE); SUNDIALS_EXPORT -SUNErrCode SUNDomEigEstimate(SUNDomEigEstimator DEE, suncomplextype* dom_eig); +SUNErrCode SUNDomEigEstimate(SUNDomEigEstimator DEE, sunrealtype* lambdaR, + sunrealtype* lambdaI); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstNumIters(SUNDomEigEstimator DEE, int* niter); diff --git a/include/sundomeigest/sundomeigest_arni.h b/include/sundomeigest/sundomeigest_arni.h index b7c38fbaeb..8983f8648b 100644 --- a/include/sundomeigest/sundomeigest_arni.h +++ b/include/sundomeigest/sundomeigest_arni.h @@ -52,7 +52,7 @@ struct _SUNDomEigEstimatorContent_ArnI sunrealtype* LAPACK_wr; /* Real parts of eigenvalues */ sunrealtype* LAPACK_wi; /* Imaginary parts of eigenvalues */ sunrealtype* LAPACK_work; /* Workspace array */ - suncomplextype* LAPACK_arr; /* an array to sort eigenvalues*/ + sunrealtype** LAPACK_arr; /* an array to sort eigenvalues*/ sunrealtype** Hes; /* Hessenberg matrix Hes */ }; @@ -87,8 +87,7 @@ SUNDIALS_EXPORT SUNErrCode SUNDomEigEstComputeHess_ArnI(SUNDomEigEstimator DEE); SUNDIALS_EXPORT -SUNErrCode SUNDomEigEstimate_ArnI(SUNDomEigEstimator DEE, - suncomplextype* dom_eig); +SUNErrCode SUNDomEigEstimate_ArnI(SUNDomEigEstimator DEE, sunrealtype* lambdaR, sunrealtype* lambdaI); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstFree_ArnI(SUNDomEigEstimator DEE); diff --git a/include/sundomeigest/sundomeigest_pi.h b/include/sundomeigest/sundomeigest_pi.h index 4378425a31..120a9903e3 100644 --- a/include/sundomeigest/sundomeigest_pi.h +++ b/include/sundomeigest/sundomeigest_pi.h @@ -87,7 +87,7 @@ SUNDIALS_EXPORT SUNErrCode SUNDomEigEstPreProcess_PI(SUNDomEigEstimator DEE); SUNDIALS_EXPORT -SUNErrCode SUNDomEigEstimate_PI(SUNDomEigEstimator DEE, suncomplextype* dom_eig); +SUNErrCode SUNDomEigEstimate_PI(SUNDomEigEstimator DEE, sunrealtype* lambdaR, sunrealtype* lambdaI); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstNumIters_PI(SUNDomEigEstimator DEE, int* niter); diff --git a/src/arkode/arkode_lsrkstep.c b/src/arkode/arkode_lsrkstep.c index b039409898..a1cc2814b0 100644 --- a/src/arkode/arkode_lsrkstep.c +++ b/src/arkode/arkode_lsrkstep.c @@ -2206,8 +2206,6 @@ int lsrkStep_ComputeNewDomEig(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem) { int retval = SUN_SUCCESS; - suncomplextype dom_eig; - if (step_mem->dom_eig_fn != NULL) { retval = step_mem->dom_eig_fn(ark_mem->tn, ark_mem->ycur, ark_mem->fn, @@ -2224,19 +2222,14 @@ int lsrkStep_ComputeNewDomEig(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem) } else if (step_mem->DEE != NULL) { - dom_eig = lsrkStep_DomEigEstimate(ark_mem, step_mem->DEE); - if ((dom_eig.real * dom_eig.real + dom_eig.imag * dom_eig.imag) < - SUN_SMALL_REAL) + retval = lsrkStep_DomEigEstimate(ark_mem, step_mem->DEE, &step_mem->lambdaR, &step_mem->lambdaI); + step_mem->dom_eig_num_evals++; + if (retval != ARK_SUCCESS) { - arkProcessError(ark_mem, ARK_DOMEIG_FAIL, __LINE__, __func__, __FILE__, - "Unable to estimate the dominant eigenvalue: DomEig " - "estimation returned an error"); - return ARK_DOMEIG_FAIL; + arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, + MSG_ARK_INTERNAL_DOMEIG_FAIL); + return ARK_INTERNAL_DOMEIG_FAIL; } - step_mem->dom_eig_num_evals++; - - step_mem->lambdaR = dom_eig.real; - step_mem->lambdaI = dom_eig.imag; } else { @@ -2415,20 +2408,16 @@ SUNDomEigEstimator lsrkStep_DomEigCreate(void* arkode_mem) This routine estimates the dominant eigenvalue. ---------------------------------------------------------------*/ -suncomplextype lsrkStep_DomEigEstimate(void* arkode_mem, SUNDomEigEstimator DEE) +int lsrkStep_DomEigEstimate(void* arkode_mem, SUNDomEigEstimator DEE, sunrealtype* lambdaR, sunrealtype* lambdaI) { ARKodeMem ark_mem; - suncomplextype dom_eig; - dom_eig.real = ZERO; - dom_eig.imag = ZERO; - int retval; if (arkode_mem == NULL) { arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, MSG_ARK_NO_MEM); - return dom_eig; + return ARK_MEM_NULL; } ark_mem = (ARKodeMem)arkode_mem; @@ -2436,7 +2425,7 @@ suncomplextype lsrkStep_DomEigEstimate(void* arkode_mem, SUNDomEigEstimator DEE) { arkProcessError(NULL, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, MSG_ARK_NULL_SUNCTX); - return dom_eig; + return ARK_ILL_INPUT; } /* Set the initial q = A^{numwarmups}q/||A^{numwarmups}q|| */ @@ -2448,7 +2437,7 @@ suncomplextype lsrkStep_DomEigEstimate(void* arkode_mem, SUNDomEigEstimator DEE) arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, MSG_ARK_INTERNAL_DOMEIG_FAIL); - return dom_eig; + return ARK_INTERNAL_DOMEIG_FAIL; } } @@ -2461,23 +2450,20 @@ suncomplextype lsrkStep_DomEigEstimate(void* arkode_mem, SUNDomEigEstimator DEE) arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, MSG_ARK_INTERNAL_DOMEIG_FAIL); - return dom_eig; + return ARK_INTERNAL_DOMEIG_FAIL; } } - retval = DEE->ops->estimate(DEE, &dom_eig); + retval = DEE->ops->estimate(DEE, lambdaR, lambdaI); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, MSG_ARK_INTERNAL_DOMEIG_FAIL); - dom_eig.real = ZERO; - dom_eig.imag = ZERO; - - return dom_eig; + return ARK_INTERNAL_DOMEIG_FAIL; } - return dom_eig; + return ARK_SUCCESS; } /*--------------------------------------------------------------- diff --git a/src/arkode/arkode_lsrkstep_impl.h b/src/arkode/arkode_lsrkstep_impl.h index 939fe9efd2..eb117d071b 100644 --- a/src/arkode/arkode_lsrkstep_impl.h +++ b/src/arkode/arkode_lsrkstep_impl.h @@ -221,7 +221,7 @@ void lsrkStep_DomEigUpdateLogic(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem, sunrealtype dsm); int lsrkStep_ComputeNewDomEig(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem); SUNDomEigEstimator lsrkStep_DomEigCreate(void* arkode_mem); -suncomplextype lsrkStep_DomEigEstimate(void* arkode_mem, SUNDomEigEstimator DEE); +int lsrkStep_DomEigEstimate(void* arkode_mem, SUNDomEigEstimator DEE, sunrealtype* lambdaR, sunrealtype* lambdaI); int lsrkStep_DQJtimes(void* arkode_mem, N_Vector v, N_Vector Jv); /*=============================================================== diff --git a/src/sundials/sundials_domeigestimator.c b/src/sundials/sundials_domeigestimator.c index ec57407b74..673f9ccf12 100644 --- a/src/sundials/sundials_domeigestimator.c +++ b/src/sundials/sundials_domeigestimator.c @@ -166,11 +166,11 @@ SUNErrCode SUNDomEigEstComputeHess(SUNDomEigEstimator DEE) return (ier); } -SUNErrCode SUNDomEigEstimate(SUNDomEigEstimator DEE, suncomplextype* dom_eig) +SUNErrCode SUNDomEigEstimate(SUNDomEigEstimator DEE, sunrealtype* lambdaR, sunrealtype* lambdaI) { SUNErrCode ier; SUNDIALS_MARK_FUNCTION_BEGIN(getSUNProfiler(DEE)); - if (DEE->ops->estimate) { ier = DEE->ops->estimate(DEE, dom_eig); } + if (DEE->ops->estimate) { ier = DEE->ops->estimate(DEE, lambdaR, lambdaI); } else { ier = SUN_SUCCESS; } SUNDIALS_MARK_FUNCTION_END(getSUNProfiler(DEE)); return (ier); diff --git a/src/sundomeigest/ArnI/sundomeigest_arni.c b/src/sundomeigest/ArnI/sundomeigest_arni.c index 2fb2c8b9b0..335832b6e2 100644 --- a/src/sundomeigest/ArnI/sundomeigest_arni.c +++ b/src/sundomeigest/ArnI/sundomeigest_arni.c @@ -152,28 +152,37 @@ SUNErrCode SUNDomEigEstInitialize_ArnI(SUNDomEigEstimator DEE) malloc(ArnI_CONTENT(DEE)->krydim * sizeof(sunrealtype)); ArnI_CONTENT(DEE)->LAPACK_work = malloc((4 * ArnI_CONTENT(DEE)->krydim) * sizeof(sunrealtype)); - ArnI_CONTENT(DEE)->LAPACK_arr = - (suncomplextype*)malloc(ArnI_CONTENT(DEE)->krydim * sizeof(suncomplextype)); - N_VRandom(ArnI_CONTENT(DEE)->q); - SUNCheckLastErr(); + + int k; + + /* LAPACK array */ + if (ArnI_CONTENT(DEE)->LAPACK_arr == NULL) + { + ArnI_CONTENT(DEE)->LAPACK_arr = (sunrealtype**)malloc(ArnI_CONTENT(DEE)->krydim * sizeof(sunrealtype*)); + + for (k = 0; k < ArnI_CONTENT(DEE)->krydim; k++) + { + ArnI_CONTENT(DEE)->LAPACK_arr[k] = (sunrealtype*)malloc(2 * sizeof(sunrealtype)); + } + } /* Hessenberg matrix Hes */ if (ArnI_CONTENT(DEE)->Hes == NULL) { - int k; ArnI_CONTENT(DEE)->Hes = (sunrealtype**)malloc( (ArnI_CONTENT(DEE)->krydim + 1) * sizeof(sunrealtype*)); for (k = 0; k <= ArnI_CONTENT(DEE)->krydim; k++) { - ArnI_CONTENT(DEE)->Hes[k] = NULL; ArnI_CONTENT(DEE)->Hes[k] = (sunrealtype*)malloc(ArnI_CONTENT(DEE)->krydim * sizeof(sunrealtype)); } } /* Initialize the vector V[0] */ + N_VRandom(ArnI_CONTENT(DEE)->q); + SUNCheckLastErr(); sunrealtype normq = N_VDotProd(ArnI_CONTENT(DEE)->q, ArnI_CONTENT(DEE)->q); SUNCheckLastErr(); @@ -284,20 +293,17 @@ SUNErrCode SUNDomEigEstComputeHess_ArnI(SUNDomEigEstimator DEE) return SUN_SUCCESS; } -SUNErrCode SUNDomEigEstimate_ArnI(SUNDomEigEstimator DEE, suncomplextype* dom_eig) +SUNErrCode SUNDomEigEstimate_ArnI(SUNDomEigEstimator DEE, sunrealtype* lambdaR, sunrealtype* lambdaI) { SUNFunctionBegin(DEE->sunctx); - SUNAssert(dom_eig, SUN_ERR_ARG_CORRUPT); + SUNAssert(lambdaR, SUN_ERR_ARG_CORRUPT); + SUNAssert(lambdaI, SUN_ERR_ARG_CORRUPT); SUNAssert(ArnI_CONTENT(DEE)->ATimes, SUN_ERR_DEE_NULL_ATIMES); SUNAssert(ArnI_CONTENT(DEE)->V, SUN_ERR_ARG_CORRUPT); SUNAssert(ArnI_CONTENT(DEE)->q, SUN_ERR_ARG_CORRUPT); SUNAssert(ArnI_CONTENT(DEE)->Hes, SUN_ERR_DEE_NULL_HES); - suncomplextype dom_eig_new; - dom_eig_new.real = ZERO; - dom_eig_new.imag = ZERO; - int n = ArnI_CONTENT(DEE)->krydim; /* Reshape the Hessenberg matrix as an input vector for the LAPACK dgeev_ function */ @@ -332,28 +338,19 @@ SUNErrCode SUNDomEigEstimate_ArnI(SUNDomEigEstimator DEE, suncomplextype* dom_ei /* order the eigenvalues by their magnitude */ for (i = 0; i < n; i++) { - ArnI_CONTENT(DEE)->LAPACK_arr[i].real = ArnI_CONTENT(DEE)->LAPACK_wr[i]; - ArnI_CONTENT(DEE)->LAPACK_arr[i].imag = ArnI_CONTENT(DEE)->LAPACK_wi[i]; + ArnI_CONTENT(DEE)->LAPACK_arr[i][0] = ArnI_CONTENT(DEE)->LAPACK_wr[i]; + ArnI_CONTENT(DEE)->LAPACK_arr[i][1] = ArnI_CONTENT(DEE)->LAPACK_wi[i]; } /* Sort the array using qsort */ - qsort(ArnI_CONTENT(DEE)->LAPACK_arr, n, sizeof(suncomplextype), domeig_Compare); - - /* Update the original arrays */ - for (i = 0; i < n; i++) - { - ArnI_CONTENT(DEE)->LAPACK_wr[i] = ArnI_CONTENT(DEE)->LAPACK_arr[i].real; - ArnI_CONTENT(DEE)->LAPACK_wi[i] = ArnI_CONTENT(DEE)->LAPACK_arr[i].imag; - } + qsort(ArnI_CONTENT(DEE)->LAPACK_arr, n, sizeof(ArnI_CONTENT(DEE)->LAPACK_arr[0]), domeig_Compare); // alternatively we can return a vector of all computed dom_eigs (up to krydim) // TODO: Get opinions /* Copy the dominant eigenvalue */ - dom_eig_new.real = ArnI_CONTENT(DEE)->LAPACK_wr[0]; - dom_eig_new.imag = ArnI_CONTENT(DEE)->LAPACK_wi[0]; - - *dom_eig = dom_eig_new; + *lambdaR = ArnI_CONTENT(DEE)->LAPACK_arr[0][0]; + *lambdaI = ArnI_CONTENT(DEE)->LAPACK_arr[0][1]; return SUN_SUCCESS; } @@ -392,13 +389,25 @@ SUNErrCode SUNDomEigEstFree_ArnI(SUNDomEigEstimator DEE) free(ArnI_CONTENT(DEE)->LAPACK_wi); ArnI_CONTENT(DEE)->LAPACK_wi = NULL; } + + int k; + /* free LAPACK_arr */ if (ArnI_CONTENT(DEE)->LAPACK_arr != NULL) { + for (k = 0; k < ArnI_CONTENT(DEE)->krydim; k++) + { + free(ArnI_CONTENT(DEE)->LAPACK_arr[k]); + } free(ArnI_CONTENT(DEE)->LAPACK_arr); ArnI_CONTENT(DEE)->LAPACK_arr = NULL; } + /* free Hes */ if (ArnI_CONTENT(DEE)->Hes != NULL) { + for (k = 0; k <= ArnI_CONTENT(DEE)->krydim; k++) + { + free(ArnI_CONTENT(DEE)->Hes[k]); + } free(ArnI_CONTENT(DEE)->Hes); ArnI_CONTENT(DEE)->Hes = NULL; } @@ -416,18 +425,12 @@ SUNErrCode SUNDomEigEstFree_ArnI(SUNDomEigEstimator DEE) return SUN_SUCCESS; } -// Function to calculate the magnitude of a suncomplextype number -sunrealtype domeig_Magnitude(const suncomplextype* c) -{ - return sqrt(c->real * c->real + c->imag * c->imag); -} - // Comparison function for qsort int domeig_Compare(const void* a, const void* b) { - const suncomplextype* c1 = (const suncomplextype*)a; - const suncomplextype* c2 = (const suncomplextype*)b; - sunrealtype mag1 = domeig_Magnitude(c1); - sunrealtype mag2 = domeig_Magnitude(c2); + sunrealtype* c1 = *(sunrealtype**)a; + sunrealtype* c2 = *(sunrealtype**)b; + sunrealtype mag1 = SUNRsqrt(c1[0] * c1[0] + c1[1] * c1[1]); + sunrealtype mag2 = SUNRsqrt(c2[0] * c2[0] + c2[1] * c2[1]); return (mag2 > mag1) - (mag2 < mag1); // Descending order } diff --git a/src/sundomeigest/PI/sundomeigest_pi.c b/src/sundomeigest/PI/sundomeigest_pi.c index ab68c85f40..eed367210e 100644 --- a/src/sundomeigest/PI/sundomeigest_pi.c +++ b/src/sundomeigest/PI/sundomeigest_pi.c @@ -235,22 +235,19 @@ SUNErrCode SUNDomEigEstPreProcess_PI(SUNDomEigEstimator DEE) return SUN_SUCCESS; } -SUNErrCode SUNDomEigEstimate_PI(SUNDomEigEstimator DEE, suncomplextype* dom_eig) +SUNErrCode SUNDomEigEstimate_PI(SUNDomEigEstimator DEE, sunrealtype* lambdaR, sunrealtype* lambdaI) { SUNFunctionBegin(DEE->sunctx); - SUNAssert(dom_eig, SUN_ERR_ARG_CORRUPT); + SUNAssert(lambdaR, SUN_ERR_ARG_CORRUPT); + SUNAssert(lambdaI, SUN_ERR_ARG_CORRUPT); // Maybe NULL, should we allow? SUNAssert(PI_CONTENT(DEE)->ATimes, SUN_ERR_ARG_CORRUPT); SUNAssert(PI_CONTENT(DEE)->V, SUN_ERR_ARG_CORRUPT); SUNAssert(PI_CONTENT(DEE)->q, SUN_ERR_ARG_CORRUPT); SUNAssert((PI_CONTENT(DEE)->max_powiter >= 0), SUN_ERR_ARG_CORRUPT); - suncomplextype dom_eig_new, dom_eig_old; - - dom_eig_new.real = ZERO; - dom_eig_new.imag = ZERO; - dom_eig_old.real = ZERO; - dom_eig_old.imag = ZERO; + sunrealtype newlambdaR = ZERO; + sunrealtype oldlambdaR = ZERO; sunindextype retval, k; sunrealtype normq; @@ -265,11 +262,11 @@ SUNErrCode SUNDomEigEstimate_PI(SUNDomEigEstimator DEE, suncomplextype* dom_eig) else { return SUN_ERR_DEE_ATIMES_FAIL_REC; } } - dom_eig_new.real = N_VDotProd(PI_CONTENT(DEE)->V, - PI_CONTENT(DEE)->q); //Rayleigh quotient + newlambdaR = N_VDotProd(PI_CONTENT(DEE)->V, + PI_CONTENT(DEE)->q); //Rayleigh quotient SUNCheckLastErr(); - PI_CONTENT(DEE)->res = fabs(dom_eig_new.real - dom_eig_old.real); + PI_CONTENT(DEE)->res = fabs(newlambdaR - oldlambdaR); if (PI_CONTENT(DEE)->res < PI_CONTENT(DEE)->powiter_tol) { break; } @@ -280,10 +277,11 @@ SUNErrCode SUNDomEigEstimate_PI(SUNDomEigEstimator DEE, suncomplextype* dom_eig) N_VScale(ONE / normq, PI_CONTENT(DEE)->q, PI_CONTENT(DEE)->V); SUNCheckLastErr(); - dom_eig_old.real = dom_eig_new.real; + oldlambdaR = newlambdaR; } - *dom_eig = dom_eig_new; + *lambdaI = ZERO; + *lambdaR = newlambdaR; PI_CONTENT(DEE)->numiters = k; return SUN_SUCCESS; diff --git a/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c b/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c index 6ff7356111..70893b6363 100644 --- a/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c +++ b/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c @@ -64,8 +64,8 @@ int main(int argc, char* argv[]) int niter; /* number of iterations */ int print_timing; /* timing output flag */ sunrealtype res; /* current residual */ - suncomplextype dom_eig; /* computed domeig value */ - suncomplextype true_dom_eig; /* true domeig value */ + sunrealtype lambdaR, lambdaI; /* computed domeig parts */ + sunrealtype tlambdaR, tlambdaI;/* true domeig parts */ SUNContext sunctx; sunrealtype rel_tol = 1.0e-2; /* relative tol for pass/fail */ sunrealtype rel_error; @@ -147,7 +147,7 @@ int main(int argc, char* argv[]) fails += Test_SUNDomEigEstInitialize(DEE, 0); fails += Test_SUNDomEigEstPreProcess(DEE, 0); fails += Test_SUNDomEigEstComputeHess(DEE, 0); - fails += Test_SUNDomEigEstimate(DEE, &dom_eig, 0); + fails += Test_SUNDomEigEstimate(DEE, &lambdaR, &lambdaI, 0); // SUNDomEigEstNumIters and SUNDomEigEstRes are not options for // Arnoldi iteration. They should return with 0 fails += Test_SUNDomEigEstNumIters(DEE, &niter, 0); @@ -177,36 +177,34 @@ int main(int argc, char* argv[]) /* First check if the computed eigenvalue has a nonzero magnitute */ sunrealtype norm_of_dom_eig = - SUNRsqrt(dom_eig.real * dom_eig.real + dom_eig.imag * dom_eig.imag); + SUNRsqrt(lambdaR * lambdaR + lambdaI * lambdaI); if (norm_of_dom_eig < SUN_SMALL_REAL) { printf("FAIL: Dominant Eigenvalue Test Failed\n\n"); return 1; } - /* Identify the true_dom_eig based on given parameters*/ + /* Identify the tlambdaR and tlambdaI based on given parameters*/ if (SUNRsqrt(realpart * realpart + imagpart * imagpart) > -factor * ProbData.N) { /* Dominant eigenvalue corresponds to the 2x2 block matrix */ - true_dom_eig.real = realpart; - true_dom_eig.imag = imagpart; + tlambdaR = realpart; + tlambdaI = imagpart; } else { /* Dominant eigenvalue corresponds to the maximum real value at the diagonal */ - true_dom_eig.real = factor * ProbData.N; - true_dom_eig.imag = ZERO; + tlambdaR = factor * ProbData.N; + tlambdaI = ZERO; } - printf("\ncomputed dominant eigenvalue = %20.4lf + %20.4lfi\n", dom_eig.real, - dom_eig.imag); - printf(" true dominant eigenvalue = %20.4lf + %20.4lfi\n", - true_dom_eig.real, true_dom_eig.imag); + printf("\ncomputed dominant eigenvalue = %20.4lf + %20.4lfi\n", lambdaR, lambdaI); + printf(" true dominant eigenvalue = %20.4lf + %20.4lfi\n", tlambdaR, tlambdaI); - /* Compare the estimated dom_eig with the true_dom_eig*/ + /* Compare the estimated dom_eig with the tlambdaR and tlambdaI*/ rel_error = SUNRsqrt( - (dom_eig.real - true_dom_eig.real) * (dom_eig.real - true_dom_eig.real) + - (dom_eig.imag - true_dom_eig.imag) * (dom_eig.imag - true_dom_eig.imag)); + (lambdaR - tlambdaR) * (lambdaR - tlambdaR) + + (lambdaI - tlambdaI) * (lambdaI - tlambdaI)); rel_error /= norm_of_dom_eig; diff --git a/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c b/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c index d0a5c2a9ab..4fb2e66826 100644 --- a/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c +++ b/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c @@ -61,8 +61,8 @@ int main(int argc, char* argv[]) int niter; /* number of iterations */ int print_timing; /* timing output flag */ sunrealtype res; /* current residual */ - suncomplextype dom_eig; /* computed domeig value */ - suncomplextype true_dom_eig; /* true domeig value */ + sunrealtype lambdaR, lambdaI; /* computed domeig parts */ + sunrealtype tlambdaR, tlambdaI;/* true domeig parts */ SUNContext sunctx; sunrealtype rel_tol = 1.0e-2; /* relative tol for pass/fail */ sunrealtype rel_error; @@ -145,7 +145,7 @@ int main(int argc, char* argv[]) // Test_SUNDomEigEstComputeHess is not an option for power iteration. // It should return with SUN_SUCCESS fails += Test_SUNDomEigEstComputeHess(DEE, 0); - fails += Test_SUNDomEigEstimate(DEE, &dom_eig, 0); + fails += Test_SUNDomEigEstimate(DEE, &lambdaR, &lambdaI, 0); fails += Test_SUNDomEigEstNumIters(DEE, &niter, 0); if (niter == 0) { @@ -173,7 +173,7 @@ int main(int argc, char* argv[]) /* First check if the computed eigenvalue has a nonzero magnitute */ sunrealtype norm_of_dom_eig = - SUNRsqrt(dom_eig.real * dom_eig.real + dom_eig.imag * dom_eig.imag); + SUNRsqrt(lambdaR * lambdaR + lambdaI * lambdaI); if (norm_of_dom_eig < SUN_SMALL_REAL) { printf("FAIL: Dominant Eigenvalue Test Failed\n\n"); @@ -188,24 +188,22 @@ int main(int argc, char* argv[]) /* Identify true_dom_eig based on given parameters*/ if (fabs(diagonal + nondiagonal) < fabs(factor * ProbData.N)) { - true_dom_eig.real = factor * ProbData.N; - true_dom_eig.imag = ZERO; + tlambdaR = factor * ProbData.N; + tlambdaI = ZERO; } else { - true_dom_eig.real = diagonal + nondiagonal; - true_dom_eig.imag = ZERO; + tlambdaR = diagonal + nondiagonal; + tlambdaI = ZERO; } - printf("\ncomputed dominant eigenvalue = %20.4lf + %20.4lfi\n", dom_eig.real, - dom_eig.imag); - printf(" true dominant eigenvalue = %20.4lf + %20.4lfi\n", - true_dom_eig.real, true_dom_eig.imag); + printf("\ncomputed dominant eigenvalue = %20.4lf + %20.4lfi\n", lambdaR, lambdaI); + printf(" true dominant eigenvalue = %20.4lf + %20.4lfi\n", tlambdaR, tlambdaI); /* Compare the estimated dom_eig with the true_dom_eig*/ rel_error = SUNRsqrt( - (dom_eig.real - true_dom_eig.real) * (dom_eig.real - true_dom_eig.real) + - (dom_eig.imag - true_dom_eig.imag) * (dom_eig.imag - true_dom_eig.imag)); + (lambdaR - tlambdaR) * (lambdaR - tlambdaR) + + (lambdaI - tlambdaI) * (lambdaI - tlambdaI)); rel_error /= norm_of_dom_eig; diff --git a/test/unit_tests/sundomeigest/test_sundomeigest.c b/test/unit_tests/sundomeigest/test_sundomeigest.c index 085c377ee4..7f7b665dd5 100644 --- a/test/unit_tests/sundomeigest/test_sundomeigest.c +++ b/test/unit_tests/sundomeigest/test_sundomeigest.c @@ -260,16 +260,13 @@ int Test_SUNDomEigEstComputeHess(SUNDomEigEstimator DEE, int myid) /* ---------------------------------------------------------------------- * SUNDomEigEstimate Test * --------------------------------------------------------------------*/ -int Test_SUNDomEigEstimate(SUNDomEigEstimator DEE, suncomplextype* dom_eig, - int myid) +int Test_SUNDomEigEstimate(SUNDomEigEstimator DEE, sunrealtype* lambdaR, sunrealtype* lambdaI, int myid) { int failure; - suncomplextype estimated_dom_eig; double start_time, stop_time; start_time = get_time(); - failure = SUNDomEigEstimate(DEE, &estimated_dom_eig); - *dom_eig = estimated_dom_eig; + failure = SUNDomEigEstimate(DEE, lambdaR, lambdaI); // sync_device(); stop_time = get_time(); diff --git a/test/unit_tests/sundomeigest/test_sundomeigest.h b/test/unit_tests/sundomeigest/test_sundomeigest.h index ca5cceb2ff..7c1e5c08f0 100644 --- a/test/unit_tests/sundomeigest/test_sundomeigest.h +++ b/test/unit_tests/sundomeigest/test_sundomeigest.h @@ -42,8 +42,7 @@ int Test_SUNDomEigEstSetNumPreProcess(SUNDomEigEstimator DEE, int numwarmups, int Test_SUNDomEigEstInitialize(SUNDomEigEstimator DEE, int myid); int Test_SUNDomEigEstPreProcess(SUNDomEigEstimator DEE, int myid); int Test_SUNDomEigEstComputeHess(SUNDomEigEstimator DEE, int myid); -int Test_SUNDomEigEstimate(SUNDomEigEstimator DEE, suncomplextype* dom_eig, - int myid); +int Test_SUNDomEigEstimate(SUNDomEigEstimator DEE, sunrealtype* lambdaR, sunrealtype* lambdaI, int myid); int Test_SUNDomEigEstNumIters(SUNDomEigEstimator DEE, int* niter, int myid); int Test_SUNDomEigEstRes(SUNDomEigEstimator DEE, sunrealtype* res, int myid); From c415504ecdddbd41b1386d4a9d593620801acf32 Mon Sep 17 00:00:00 2001 From: maggul Date: Wed, 18 Jun 2025 17:29:05 -0500 Subject: [PATCH 050/128] answers repo update --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index e0b267ebad..4a93bf57fe 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit e0b267ebad014a0d99ba0152743dc4e2fbedc66b +Subproject commit 4a93bf57fe3f593045a03ed84f3985c13543d0db From eee9a5088e7e55ae69760c62e0ab990b863ee7b6 Mon Sep 17 00:00:00 2001 From: maggul Date: Wed, 18 Jun 2025 19:14:20 -0500 Subject: [PATCH 051/128] formatting --- include/sundomeigest/sundomeigest_arni.h | 11 ++--- include/sundomeigest/sundomeigest_pi.h | 3 +- src/arkode/arkode_lsrkstep.c | 10 +++-- src/arkode/arkode_lsrkstep_impl.h | 3 +- src/sundials/sundials_domeigestimator.c | 3 +- src/sundomeigest/ArnI/sundomeigest_arni.c | 21 +++++----- src/sundomeigest/PI/sundomeigest_pi.c | 3 +- test/answers | 2 +- .../arni/test_sundomeigest_arni.c | 40 +++++++++---------- .../sundomeigest/pi/test_sundomeigest_pi.c | 38 +++++++++--------- .../sundomeigest/test_sundomeigest.c | 3 +- .../sundomeigest/test_sundomeigest.h | 3 +- 12 files changed, 76 insertions(+), 64 deletions(-) diff --git a/include/sundomeigest/sundomeigest_arni.h b/include/sundomeigest/sundomeigest_arni.h index 8983f8648b..02d7567471 100644 --- a/include/sundomeigest/sundomeigest_arni.h +++ b/include/sundomeigest/sundomeigest_arni.h @@ -49,10 +49,10 @@ struct _SUNDomEigEstimatorContent_ArnI int numwarmups; /* Power of A in the preprocessing; initial q = A^{numwarmups}q/||A^{numwarmups}q|| */ sunrealtype* LAPACK_A; /* The vector which holds rows of the Hessenberg matrix in the given order */ - sunrealtype* LAPACK_wr; /* Real parts of eigenvalues */ - sunrealtype* LAPACK_wi; /* Imaginary parts of eigenvalues */ - sunrealtype* LAPACK_work; /* Workspace array */ - sunrealtype** LAPACK_arr; /* an array to sort eigenvalues*/ + sunrealtype* LAPACK_wr; /* Real parts of eigenvalues */ + sunrealtype* LAPACK_wi; /* Imaginary parts of eigenvalues */ + sunrealtype* LAPACK_work; /* Workspace array */ + sunrealtype** LAPACK_arr; /* an array to sort eigenvalues*/ sunrealtype** Hes; /* Hessenberg matrix Hes */ }; @@ -87,7 +87,8 @@ SUNDIALS_EXPORT SUNErrCode SUNDomEigEstComputeHess_ArnI(SUNDomEigEstimator DEE); SUNDIALS_EXPORT -SUNErrCode SUNDomEigEstimate_ArnI(SUNDomEigEstimator DEE, sunrealtype* lambdaR, sunrealtype* lambdaI); +SUNErrCode SUNDomEigEstimate_ArnI(SUNDomEigEstimator DEE, sunrealtype* lambdaR, + sunrealtype* lambdaI); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstFree_ArnI(SUNDomEigEstimator DEE); diff --git a/include/sundomeigest/sundomeigest_pi.h b/include/sundomeigest/sundomeigest_pi.h index 120a9903e3..f4e506b184 100644 --- a/include/sundomeigest/sundomeigest_pi.h +++ b/include/sundomeigest/sundomeigest_pi.h @@ -87,7 +87,8 @@ SUNDIALS_EXPORT SUNErrCode SUNDomEigEstPreProcess_PI(SUNDomEigEstimator DEE); SUNDIALS_EXPORT -SUNErrCode SUNDomEigEstimate_PI(SUNDomEigEstimator DEE, sunrealtype* lambdaR, sunrealtype* lambdaI); +SUNErrCode SUNDomEigEstimate_PI(SUNDomEigEstimator DEE, sunrealtype* lambdaR, + sunrealtype* lambdaI); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstNumIters_PI(SUNDomEigEstimator DEE, int* niter); diff --git a/src/arkode/arkode_lsrkstep.c b/src/arkode/arkode_lsrkstep.c index a1cc2814b0..4212f3a942 100644 --- a/src/arkode/arkode_lsrkstep.c +++ b/src/arkode/arkode_lsrkstep.c @@ -2222,12 +2222,13 @@ int lsrkStep_ComputeNewDomEig(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem) } else if (step_mem->DEE != NULL) { - retval = lsrkStep_DomEigEstimate(ark_mem, step_mem->DEE, &step_mem->lambdaR, &step_mem->lambdaI); + retval = lsrkStep_DomEigEstimate(ark_mem, step_mem->DEE, &step_mem->lambdaR, + &step_mem->lambdaI); step_mem->dom_eig_num_evals++; if (retval != ARK_SUCCESS) { - arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, __FILE__, - MSG_ARK_INTERNAL_DOMEIG_FAIL); + arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, + __FILE__, MSG_ARK_INTERNAL_DOMEIG_FAIL); return ARK_INTERNAL_DOMEIG_FAIL; } } @@ -2408,7 +2409,8 @@ SUNDomEigEstimator lsrkStep_DomEigCreate(void* arkode_mem) This routine estimates the dominant eigenvalue. ---------------------------------------------------------------*/ -int lsrkStep_DomEigEstimate(void* arkode_mem, SUNDomEigEstimator DEE, sunrealtype* lambdaR, sunrealtype* lambdaI) +int lsrkStep_DomEigEstimate(void* arkode_mem, SUNDomEigEstimator DEE, + sunrealtype* lambdaR, sunrealtype* lambdaI) { ARKodeMem ark_mem; diff --git a/src/arkode/arkode_lsrkstep_impl.h b/src/arkode/arkode_lsrkstep_impl.h index eb117d071b..55a664bb0f 100644 --- a/src/arkode/arkode_lsrkstep_impl.h +++ b/src/arkode/arkode_lsrkstep_impl.h @@ -221,7 +221,8 @@ void lsrkStep_DomEigUpdateLogic(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem, sunrealtype dsm); int lsrkStep_ComputeNewDomEig(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem); SUNDomEigEstimator lsrkStep_DomEigCreate(void* arkode_mem); -int lsrkStep_DomEigEstimate(void* arkode_mem, SUNDomEigEstimator DEE, sunrealtype* lambdaR, sunrealtype* lambdaI); +int lsrkStep_DomEigEstimate(void* arkode_mem, SUNDomEigEstimator DEE, + sunrealtype* lambdaR, sunrealtype* lambdaI); int lsrkStep_DQJtimes(void* arkode_mem, N_Vector v, N_Vector Jv); /*=============================================================== diff --git a/src/sundials/sundials_domeigestimator.c b/src/sundials/sundials_domeigestimator.c index 673f9ccf12..0b87cd36f0 100644 --- a/src/sundials/sundials_domeigestimator.c +++ b/src/sundials/sundials_domeigestimator.c @@ -166,7 +166,8 @@ SUNErrCode SUNDomEigEstComputeHess(SUNDomEigEstimator DEE) return (ier); } -SUNErrCode SUNDomEigEstimate(SUNDomEigEstimator DEE, sunrealtype* lambdaR, sunrealtype* lambdaI) +SUNErrCode SUNDomEigEstimate(SUNDomEigEstimator DEE, sunrealtype* lambdaR, + sunrealtype* lambdaI) { SUNErrCode ier; SUNDIALS_MARK_FUNCTION_BEGIN(getSUNProfiler(DEE)); diff --git a/src/sundomeigest/ArnI/sundomeigest_arni.c b/src/sundomeigest/ArnI/sundomeigest_arni.c index 335832b6e2..593b9183a9 100644 --- a/src/sundomeigest/ArnI/sundomeigest_arni.c +++ b/src/sundomeigest/ArnI/sundomeigest_arni.c @@ -153,17 +153,18 @@ SUNErrCode SUNDomEigEstInitialize_ArnI(SUNDomEigEstimator DEE) ArnI_CONTENT(DEE)->LAPACK_work = malloc((4 * ArnI_CONTENT(DEE)->krydim) * sizeof(sunrealtype)); - int k; /* LAPACK array */ if (ArnI_CONTENT(DEE)->LAPACK_arr == NULL) { - ArnI_CONTENT(DEE)->LAPACK_arr = (sunrealtype**)malloc(ArnI_CONTENT(DEE)->krydim * sizeof(sunrealtype*)); + ArnI_CONTENT(DEE)->LAPACK_arr = + (sunrealtype**)malloc(ArnI_CONTENT(DEE)->krydim * sizeof(sunrealtype*)); for (k = 0; k < ArnI_CONTENT(DEE)->krydim; k++) { - ArnI_CONTENT(DEE)->LAPACK_arr[k] = (sunrealtype*)malloc(2 * sizeof(sunrealtype)); + ArnI_CONTENT(DEE)->LAPACK_arr[k] = + (sunrealtype*)malloc(2 * sizeof(sunrealtype)); } } @@ -293,7 +294,8 @@ SUNErrCode SUNDomEigEstComputeHess_ArnI(SUNDomEigEstimator DEE) return SUN_SUCCESS; } -SUNErrCode SUNDomEigEstimate_ArnI(SUNDomEigEstimator DEE, sunrealtype* lambdaR, sunrealtype* lambdaI) +SUNErrCode SUNDomEigEstimate_ArnI(SUNDomEigEstimator DEE, sunrealtype* lambdaR, + sunrealtype* lambdaI) { SUNFunctionBegin(DEE->sunctx); @@ -343,7 +345,8 @@ SUNErrCode SUNDomEigEstimate_ArnI(SUNDomEigEstimator DEE, sunrealtype* lambdaR, } /* Sort the array using qsort */ - qsort(ArnI_CONTENT(DEE)->LAPACK_arr, n, sizeof(ArnI_CONTENT(DEE)->LAPACK_arr[0]), domeig_Compare); + qsort(ArnI_CONTENT(DEE)->LAPACK_arr, n, + sizeof(ArnI_CONTENT(DEE)->LAPACK_arr[0]), domeig_Compare); // alternatively we can return a vector of all computed dom_eigs (up to krydim) // TODO: Get opinions @@ -428,9 +431,9 @@ SUNErrCode SUNDomEigEstFree_ArnI(SUNDomEigEstimator DEE) // Comparison function for qsort int domeig_Compare(const void* a, const void* b) { - sunrealtype* c1 = *(sunrealtype**)a; - sunrealtype* c2 = *(sunrealtype**)b; - sunrealtype mag1 = SUNRsqrt(c1[0] * c1[0] + c1[1] * c1[1]); - sunrealtype mag2 = SUNRsqrt(c2[0] * c2[0] + c2[1] * c2[1]); + const sunrealtype* c1 = *(const sunrealtype* const*)a; + const sunrealtype* c2 = *(const sunrealtype* const*)b; + sunrealtype mag1 = SUNRsqrt(c1[0] * c1[0] + c1[1] * c1[1]); + sunrealtype mag2 = SUNRsqrt(c2[0] * c2[0] + c2[1] * c2[1]); return (mag2 > mag1) - (mag2 < mag1); // Descending order } diff --git a/src/sundomeigest/PI/sundomeigest_pi.c b/src/sundomeigest/PI/sundomeigest_pi.c index eed367210e..74c10a85cc 100644 --- a/src/sundomeigest/PI/sundomeigest_pi.c +++ b/src/sundomeigest/PI/sundomeigest_pi.c @@ -235,7 +235,8 @@ SUNErrCode SUNDomEigEstPreProcess_PI(SUNDomEigEstimator DEE) return SUN_SUCCESS; } -SUNErrCode SUNDomEigEstimate_PI(SUNDomEigEstimator DEE, sunrealtype* lambdaR, sunrealtype* lambdaI) +SUNErrCode SUNDomEigEstimate_PI(SUNDomEigEstimator DEE, sunrealtype* lambdaR, + sunrealtype* lambdaI) { SUNFunctionBegin(DEE->sunctx); diff --git a/test/answers b/test/answers index 4a93bf57fe..e7ec8ffa3e 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit 4a93bf57fe3f593045a03ed84f3985c13543d0db +Subproject commit e7ec8ffa3e685df8a09c796efc7e9c4a5a9f088b diff --git a/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c b/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c index 70893b6363..00e315ab01 100644 --- a/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c +++ b/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c @@ -53,19 +53,19 @@ int check_flag(void* flagvalue, const char* funcname, int opt); * --------------------------------------------------------------------*/ int main(int argc, char* argv[]) { - int fails = 0; /* counter for test failures */ - int passfail = 0; /* overall pass/fail flag */ - SUNDomEigEstimator DEE = NULL; /* domeig estimator object */ - N_Vector q; /* test vectors */ - UserData ProbData; /* problem data structure */ - int numwarmups; /* Number of the preprocessing warmups */ - int max_powiter; /* max power iteration */ - int krydim; /* Krylov subspace dimension */ - int niter; /* number of iterations */ - int print_timing; /* timing output flag */ - sunrealtype res; /* current residual */ - sunrealtype lambdaR, lambdaI; /* computed domeig parts */ - sunrealtype tlambdaR, tlambdaI;/* true domeig parts */ + int fails = 0; /* counter for test failures */ + int passfail = 0; /* overall pass/fail flag */ + SUNDomEigEstimator DEE = NULL; /* domeig estimator object */ + N_Vector q; /* test vectors */ + UserData ProbData; /* problem data structure */ + int numwarmups; /* Number of the preprocessing warmups */ + int max_powiter; /* max power iteration */ + int krydim; /* Krylov subspace dimension */ + int niter; /* number of iterations */ + int print_timing; /* timing output flag */ + sunrealtype res; /* current residual */ + sunrealtype lambdaR, lambdaI; /* computed domeig parts */ + sunrealtype tlambdaR, tlambdaI; /* true domeig parts */ SUNContext sunctx; sunrealtype rel_tol = 1.0e-2; /* relative tol for pass/fail */ sunrealtype rel_error; @@ -176,8 +176,7 @@ int main(int argc, char* argv[]) } /* First check if the computed eigenvalue has a nonzero magnitute */ - sunrealtype norm_of_dom_eig = - SUNRsqrt(lambdaR * lambdaR + lambdaI * lambdaI); + sunrealtype norm_of_dom_eig = SUNRsqrt(lambdaR * lambdaR + lambdaI * lambdaI); if (norm_of_dom_eig < SUN_SMALL_REAL) { printf("FAIL: Dominant Eigenvalue Test Failed\n\n"); @@ -198,13 +197,14 @@ int main(int argc, char* argv[]) tlambdaI = ZERO; } - printf("\ncomputed dominant eigenvalue = %20.4lf + %20.4lfi\n", lambdaR, lambdaI); - printf(" true dominant eigenvalue = %20.4lf + %20.4lfi\n", tlambdaR, tlambdaI); + printf("\ncomputed dominant eigenvalue = %20.4lf + %20.4lfi\n", lambdaR, + lambdaI); + printf(" true dominant eigenvalue = %20.4lf + %20.4lfi\n", tlambdaR, + tlambdaI); /* Compare the estimated dom_eig with the tlambdaR and tlambdaI*/ - rel_error = SUNRsqrt( - (lambdaR - tlambdaR) * (lambdaR - tlambdaR) + - (lambdaI - tlambdaI) * (lambdaI - tlambdaI)); + rel_error = SUNRsqrt((lambdaR - tlambdaR) * (lambdaR - tlambdaR) + + (lambdaI - tlambdaI) * (lambdaI - tlambdaI)); rel_error /= norm_of_dom_eig; diff --git a/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c b/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c index 4fb2e66826..af7bab1954 100644 --- a/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c +++ b/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c @@ -51,18 +51,18 @@ int check_flag(void* flagvalue, const char* funcname, int opt); * --------------------------------------------------------------------*/ int main(int argc, char* argv[]) { - int fails = 0; /* counter for test failures */ - int passfail = 0; /* overall pass/fail flag */ - SUNDomEigEstimator DEE = NULL; /* domeig estimator object */ - N_Vector q; /* test vectors */ - UserData ProbData; /* problem data structure */ - int numwarmups; /* Number of the preprocessing warmups */ - int max_powiter; /* max power iteration */ - int niter; /* number of iterations */ - int print_timing; /* timing output flag */ - sunrealtype res; /* current residual */ - sunrealtype lambdaR, lambdaI; /* computed domeig parts */ - sunrealtype tlambdaR, tlambdaI;/* true domeig parts */ + int fails = 0; /* counter for test failures */ + int passfail = 0; /* overall pass/fail flag */ + SUNDomEigEstimator DEE = NULL; /* domeig estimator object */ + N_Vector q; /* test vectors */ + UserData ProbData; /* problem data structure */ + int numwarmups; /* Number of the preprocessing warmups */ + int max_powiter; /* max power iteration */ + int niter; /* number of iterations */ + int print_timing; /* timing output flag */ + sunrealtype res; /* current residual */ + sunrealtype lambdaR, lambdaI; /* computed domeig parts */ + sunrealtype tlambdaR, tlambdaI; /* true domeig parts */ SUNContext sunctx; sunrealtype rel_tol = 1.0e-2; /* relative tol for pass/fail */ sunrealtype rel_error; @@ -172,8 +172,7 @@ int main(int argc, char* argv[]) } /* First check if the computed eigenvalue has a nonzero magnitute */ - sunrealtype norm_of_dom_eig = - SUNRsqrt(lambdaR * lambdaR + lambdaI * lambdaI); + sunrealtype norm_of_dom_eig = SUNRsqrt(lambdaR * lambdaR + lambdaI * lambdaI); if (norm_of_dom_eig < SUN_SMALL_REAL) { printf("FAIL: Dominant Eigenvalue Test Failed\n\n"); @@ -197,13 +196,14 @@ int main(int argc, char* argv[]) tlambdaI = ZERO; } - printf("\ncomputed dominant eigenvalue = %20.4lf + %20.4lfi\n", lambdaR, lambdaI); - printf(" true dominant eigenvalue = %20.4lf + %20.4lfi\n", tlambdaR, tlambdaI); + printf("\ncomputed dominant eigenvalue = %20.4lf + %20.4lfi\n", lambdaR, + lambdaI); + printf(" true dominant eigenvalue = %20.4lf + %20.4lfi\n", tlambdaR, + tlambdaI); /* Compare the estimated dom_eig with the true_dom_eig*/ - rel_error = SUNRsqrt( - (lambdaR - tlambdaR) * (lambdaR - tlambdaR) + - (lambdaI - tlambdaI) * (lambdaI - tlambdaI)); + rel_error = SUNRsqrt((lambdaR - tlambdaR) * (lambdaR - tlambdaR) + + (lambdaI - tlambdaI) * (lambdaI - tlambdaI)); rel_error /= norm_of_dom_eig; diff --git a/test/unit_tests/sundomeigest/test_sundomeigest.c b/test/unit_tests/sundomeigest/test_sundomeigest.c index 7f7b665dd5..b2762a24fe 100644 --- a/test/unit_tests/sundomeigest/test_sundomeigest.c +++ b/test/unit_tests/sundomeigest/test_sundomeigest.c @@ -260,7 +260,8 @@ int Test_SUNDomEigEstComputeHess(SUNDomEigEstimator DEE, int myid) /* ---------------------------------------------------------------------- * SUNDomEigEstimate Test * --------------------------------------------------------------------*/ -int Test_SUNDomEigEstimate(SUNDomEigEstimator DEE, sunrealtype* lambdaR, sunrealtype* lambdaI, int myid) +int Test_SUNDomEigEstimate(SUNDomEigEstimator DEE, sunrealtype* lambdaR, + sunrealtype* lambdaI, int myid) { int failure; double start_time, stop_time; diff --git a/test/unit_tests/sundomeigest/test_sundomeigest.h b/test/unit_tests/sundomeigest/test_sundomeigest.h index 7c1e5c08f0..f7b60fadc4 100644 --- a/test/unit_tests/sundomeigest/test_sundomeigest.h +++ b/test/unit_tests/sundomeigest/test_sundomeigest.h @@ -42,7 +42,8 @@ int Test_SUNDomEigEstSetNumPreProcess(SUNDomEigEstimator DEE, int numwarmups, int Test_SUNDomEigEstInitialize(SUNDomEigEstimator DEE, int myid); int Test_SUNDomEigEstPreProcess(SUNDomEigEstimator DEE, int myid); int Test_SUNDomEigEstComputeHess(SUNDomEigEstimator DEE, int myid); -int Test_SUNDomEigEstimate(SUNDomEigEstimator DEE, sunrealtype* lambdaR, sunrealtype* lambdaI, int myid); +int Test_SUNDomEigEstimate(SUNDomEigEstimator DEE, sunrealtype* lambdaR, + sunrealtype* lambdaI, int myid); int Test_SUNDomEigEstNumIters(SUNDomEigEstimator DEE, int* niter, int myid); int Test_SUNDomEigEstRes(SUNDomEigEstimator DEE, sunrealtype* res, int myid); From 3288aba9ddeee93410ee2826779e3ad2de870957 Mon Sep 17 00:00:00 2001 From: maggul Date: Wed, 18 Jun 2025 22:26:38 -0500 Subject: [PATCH 052/128] CI Debug --- .../priv/sundials_domeigestimator_impl.h | 8 ++++++- src/sundomeigest/ArnI/sundomeigest_arni.c | 24 +++++++++++++++---- .../unit_tests/sundomeigest/pi/CMakeLists.txt | 8 +++---- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/include/sundials/priv/sundials_domeigestimator_impl.h b/include/sundials/priv/sundials_domeigestimator_impl.h index 0950d78774..70ef5dc603 100644 --- a/include/sundials/priv/sundials_domeigestimator_impl.h +++ b/include/sundials/priv/sundials_domeigestimator_impl.h @@ -37,11 +37,17 @@ int domeig_Compare(const void* a, const void* b); * LAPACK function * ----------------------------------------------------------------- */ - +#if defined(SUNDIALS_DOUBLE_PRECISION) || defined(SUNDIALS_EXTENDED_PRECISION) extern void dgeev_(char* jobvl, char* jobvr, int* n, sunrealtype* a, int* lda, sunrealtype* wr, sunrealtype* wi, sunrealtype* vl, int* ldvl, sunrealtype* vr, int* ldvr, sunrealtype* work, int* lwork, int* info); +#elif defined(SUNDIALS_SINGLE_PRECISION) +extern void sgeev_(char* jobvl, char* jobvr, int* n, sunrealtype* a, int* lda, + sunrealtype* wr, sunrealtype* wi, sunrealtype* vl, int* ldvl, + sunrealtype* vr, int* ldvr, sunrealtype* work, int* lwork, + int* info); +#endif #ifdef __cplusplus } diff --git a/src/sundomeigest/ArnI/sundomeigest_arni.c b/src/sundomeigest/ArnI/sundomeigest_arni.c index 593b9183a9..21448ad23c 100644 --- a/src/sundomeigest/ArnI/sundomeigest_arni.c +++ b/src/sundomeigest/ArnI/sundomeigest_arni.c @@ -325,10 +325,24 @@ SUNErrCode SUNDomEigEstimate_ArnI(SUNDomEigEstimator DEE, sunrealtype* lambdaR, char jobvl = 'N'; // Do not compute left eigenvectors char jobvr = 'N'; // Do not compute right eigenvectors - /* Call LAPACK's dgeev function */ + /* Call LAPACK's dgeev function + return info values refer to + = 0: successful exit + < 0: if INFO = -i, the i-th argument had an illegal value. + > 0: if INFO = i, the QR algorithm failed to compute all the + eigenvalues, and no eigenvectors have been computed; + elements i+1:N of LAPACK_wr and LAPACK_wi contain + eigenvalues which have converged. + */ +#if defined(SUNDIALS_DOUBLE_PRECISION) || defined(SUNDIALS_EXTENDED_PRECISION) dgeev_(&jobvl, &jobvr, &n, ArnI_CONTENT(DEE)->LAPACK_A, &lda, ArnI_CONTENT(DEE)->LAPACK_wr, ArnI_CONTENT(DEE)->LAPACK_wi, NULL, &ldvl, NULL, &ldvr, ArnI_CONTENT(DEE)->LAPACK_work, &lwork, &info); +#elif defined(SUNDIALS_SINGLE_PRECISION) + sgeev_(&jobvl, &jobvr, &n, ArnI_CONTENT(DEE)->LAPACK_A, &lda, + ArnI_CONTENT(DEE)->LAPACK_wr, ArnI_CONTENT(DEE)->LAPACK_wi, NULL, + &ldvl, NULL, &ldvr, ArnI_CONTENT(DEE)->LAPACK_work, &lwork, &info); +#endif if (info != 0) { @@ -431,9 +445,9 @@ SUNErrCode SUNDomEigEstFree_ArnI(SUNDomEigEstimator DEE) // Comparison function for qsort int domeig_Compare(const void* a, const void* b) { - const sunrealtype* c1 = *(const sunrealtype* const*)a; - const sunrealtype* c2 = *(const sunrealtype* const*)b; - sunrealtype mag1 = SUNRsqrt(c1[0] * c1[0] + c1[1] * c1[1]); - sunrealtype mag2 = SUNRsqrt(c2[0] * c2[0] + c2[1] * c2[1]); + const sunrealtype* c1 = *(sunrealtype**)a; + const sunrealtype* c2 = *(sunrealtype**)b; + sunrealtype mag1 = SUNRsqrt(c1[0] * c1[0] + c1[1] * c1[1]); + sunrealtype mag2 = SUNRsqrt(c2[0] * c2[0] + c2[1] * c2[1]); return (mag2 > mag1) - (mag2 < mag1); // Descending order } diff --git a/test/unit_tests/sundomeigest/pi/CMakeLists.txt b/test/unit_tests/sundomeigest/pi/CMakeLists.txt index f9192ff6ed..bc0760228c 100644 --- a/test/unit_tests/sundomeigest/pi/CMakeLists.txt +++ b/test/unit_tests/sundomeigest/pi/CMakeLists.txt @@ -19,10 +19,10 @@ # Examples using SUNDIALS PI dominant eigenvalue estimator set(sundomeigest_pi_examples - "test_sundomeigest_pi\;100 100 0 0\;exclude-single" - "test_sundomeigest_pi\;1000 100 0 0\;exclude-single" - "test_sundomeigest_pi\;10000 100 0 0\;exclude-single" - "test_sundomeigest_pi\;10000 10 90 0\;exclude-single") + "test_sundomeigest_pi\;100 100 0 0\;" + "test_sundomeigest_pi\;1000 100 0 0\;" + "test_sundomeigest_pi\;10000 100 0 0\;" + "test_sundomeigest_pi\;100000 100 0 0\;") # Dependencies for dominant eigenvalue examples set(sundomeigest_pi_dependencies test_sundomeigest) From 7d6090e299851f9437035a7c12a1ce361e5b5a5d Mon Sep 17 00:00:00 2001 From: maggul Date: Thu, 19 Jun 2025 00:30:34 -0500 Subject: [PATCH 053/128] CI Debug --- src/arkode/arkode_lsrkstep.c | 5 +++++ src/sundomeigest/ArnI/sundomeigest_arni.c | 5 +++-- test/answers | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/arkode/arkode_lsrkstep.c b/src/arkode/arkode_lsrkstep.c index 4212f3a942..ca051b6cd2 100644 --- a/src/arkode/arkode_lsrkstep.c +++ b/src/arkode/arkode_lsrkstep.c @@ -2014,6 +2014,11 @@ void lsrkStep_Free(ARKodeMem ark_mem) step_mem->Xvecs = NULL; ark_mem->liw -= step_mem->nfusedopvecs; } + /* free DEE */ + if(step_mem->DEE != NULL) + { + step_mem->DEE->ops->free(step_mem->DEE); + } /* free the time stepper module itself */ free(ark_mem->step_mem); diff --git a/src/sundomeigest/ArnI/sundomeigest_arni.c b/src/sundomeigest/ArnI/sundomeigest_arni.c index 21448ad23c..0a4361dbb7 100644 --- a/src/sundomeigest/ArnI/sundomeigest_arni.c +++ b/src/sundomeigest/ArnI/sundomeigest_arni.c @@ -445,8 +445,9 @@ SUNErrCode SUNDomEigEstFree_ArnI(SUNDomEigEstimator DEE) // Comparison function for qsort int domeig_Compare(const void* a, const void* b) { - const sunrealtype* c1 = *(sunrealtype**)a; - const sunrealtype* c2 = *(sunrealtype**)b; + const sunrealtype* c1 = *(const sunrealtype* const *)a; + const sunrealtype* c2 = *(const sunrealtype* const *)b; + sunrealtype mag1 = SUNRsqrt(c1[0] * c1[0] + c1[1] * c1[1]); sunrealtype mag2 = SUNRsqrt(c2[0] * c2[0] + c2[1] * c2[1]); return (mag2 > mag1) - (mag2 < mag1); // Descending order diff --git a/test/answers b/test/answers index e7ec8ffa3e..d95b1a3b53 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit e7ec8ffa3e685df8a09c796efc7e9c4a5a9f088b +Subproject commit d95b1a3b531b0844854c0e08343c2d1addaf23aa From 073cd8d0bae08d0c532ae406d62e3f1b886aed4c Mon Sep 17 00:00:00 2001 From: maggul Date: Thu, 19 Jun 2025 00:49:33 -0500 Subject: [PATCH 054/128] memory leak issue --- src/arkode/arkode_lsrkstep.c | 10 ++-------- src/arkode/arkode_lsrkstep_impl.h | 1 - 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/arkode/arkode_lsrkstep.c b/src/arkode/arkode_lsrkstep.c index ca051b6cd2..435b4a69b7 100644 --- a/src/arkode/arkode_lsrkstep.c +++ b/src/arkode/arkode_lsrkstep.c @@ -202,9 +202,6 @@ void* lsrkStep_Create_Commons(ARKRhsFn rhs, sunrealtype t0, N_Vector y0, /* Set NULL for DEE */ step_mem->DEE = NULL; - /* Set NULL for domeig_q */ - step_mem->domeig_q = NULL; - /* Initialize all the counters */ step_mem->nfe = 0; step_mem->nfeDQ = 0; @@ -2313,9 +2310,6 @@ SUNDomEigEstimator lsrkStep_DomEigCreate(void* arkode_mem) step_mem->domeig_rhs = step_mem->fe; - /* Allocate and fill domeig_q vector with random data */ - /* TODO: check if we have to clone or just passing yn is ok! */ - step_mem->domeig_q = N_VClone(ark_mem->yn); step_mem->domeig_krydim = DOMEIG_KRYLOV_DIM_DEFAULT; step_mem->numwarmups = SUNDOMEIGEST_NUM_OF_WARMUPS_DEFAULT; step_mem->domeig_maxiters = DOMEIG_MAX_NUMBER_OF_POWER_ITERS_DEFAULT; @@ -2330,7 +2324,7 @@ SUNDomEigEstimator lsrkStep_DomEigCreate(void* arkode_mem) /* Create the internal DomEigEst */ if (step_mem->internal_domeigest_type == ARKODE_LSRK_POWER_ITERATION) { - DEE = SUNDomEigEst_PI(step_mem->domeig_q, step_mem->domeig_maxiters, + DEE = SUNDomEigEst_PI(ark_mem->yn, step_mem->domeig_maxiters, ark_mem->sunctx); if (DEE == NULL) { @@ -2342,7 +2336,7 @@ SUNDomEigEstimator lsrkStep_DomEigCreate(void* arkode_mem) else if (step_mem->internal_domeigest_type == ARKODE_LSRK_ARNOLDI_ITERATION) { #ifdef SUNDIALS_BLAS_LAPACK_ENABLED - DEE = SUNDomEigEst_ArnI(step_mem->domeig_q, step_mem->domeig_krydim, + DEE = SUNDomEigEst_ArnI(ark_mem->yn, step_mem->domeig_krydim, ark_mem->sunctx); if (DEE == NULL) { diff --git a/src/arkode/arkode_lsrkstep_impl.h b/src/arkode/arkode_lsrkstep_impl.h index 55a664bb0f..453236429c 100644 --- a/src/arkode/arkode_lsrkstep_impl.h +++ b/src/arkode/arkode_lsrkstep_impl.h @@ -166,7 +166,6 @@ typedef struct ARKodeLSRKStepMemRec ARKODE_LSRKInternal_DomEigEst_Type internal_domeigest_type; /* Internal DomEig estimator type*/ SUNDomEigEstimator DEE; /* DomEig estimator*/ - N_Vector domeig_q; /* DomEig initial q vector*/ int domeig_krydim; /* Krylov subspace dimension */ int numwarmups; /* Power of A in the preprocessing; initial q = A^{numwarmups}q/||A^{numwarmups}q|| */ int domeig_maxiters; /* Max number of Power Iterations */ From 002a51845ff7b0ffb0fa371870d1e9565f8d4de9 Mon Sep 17 00:00:00 2001 From: maggul Date: Thu, 19 Jun 2025 01:58:10 -0500 Subject: [PATCH 055/128] include path update - suncomplextype removal from docs --- .../sundomeigest/SUNDomEigEst_API_link.rst | 2 +- .../sundomeigest/SUNDomEigEst_links.rst | 6 ++--- .../sundomeigest/SUNDomEigEst_API_link.rst | 2 +- .../sundomeigest/SUNDomEigEst_links.rst | 6 ++--- .../sundomeigest/SUNDomEigEst_API_link.rst | 2 +- .../sundomeigest/SUNDomEigEst_links.rst | 6 ++--- .../sundomeigest/SUNDomEigEst_API_link.rst | 2 +- .../sundomeigest/SUNDomEigEst_links.rst | 6 ++--- .../sundomeigest/SUNDomEigEst_API_link.rst | 2 +- .../sundomeigest/SUNDomEigEst_links.rst | 6 ++--- .../sundomeigest/SUNDomEigEst_API_link.rst | 2 +- .../sundomeigest/SUNDomEigEst_links.rst | 6 ++--- doc/shared/sundomeigest/SUNDomEigEst_API.rst | 26 +++++-------------- doc/shared/sundomeigest/SUNDomEigEst_ARNI.rst | 4 +-- 14 files changed, 32 insertions(+), 46 deletions(-) diff --git a/doc/arkode/guide/source/sundomeigest/SUNDomEigEst_API_link.rst b/doc/arkode/guide/source/sundomeigest/SUNDomEigEst_API_link.rst index 63131049d7..b4bab47f00 100644 --- a/doc/arkode/guide/source/sundomeigest/SUNDomEigEst_API_link.rst +++ b/doc/arkode/guide/source/sundomeigest/SUNDomEigEst_API_link.rst @@ -10,4 +10,4 @@ SUNDIALS Copyright End ---------------------------------------------------------------- -.. include:: ../../../shared/sundomeigest/SUNDomEigEst_API.rst +.. include:: ../../../../shared/sundomeigest/SUNDomEigEst_API.rst diff --git a/doc/arkode/guide/source/sundomeigest/SUNDomEigEst_links.rst b/doc/arkode/guide/source/sundomeigest/SUNDomEigEst_links.rst index 68de7d1878..6ed23337b2 100644 --- a/doc/arkode/guide/source/sundomeigest/SUNDomEigEst_links.rst +++ b/doc/arkode/guide/source/sundomeigest/SUNDomEigEst_links.rst @@ -10,6 +10,6 @@ SUNDIALS Copyright End ---------------------------------------------------------------- -.. include:: ../../../shared/sundomeigest/SUNDomEigEst_PI.rst -.. include:: ../../../shared/sundomeigest/SUNDomEigEst_ARNI.rst -.. include:: ../../../shared/sundomeigest/SUNDomEigEst_Examples.rst +.. include:: ../../../../shared/sundomeigest/SUNDomEigEst_PI.rst +.. include:: ../../../../shared/sundomeigest/SUNDomEigEst_ARNI.rst +.. include:: ../../../../shared/sundomeigest/SUNDomEigEst_Examples.rst diff --git a/doc/cvode/guide/source/sundomeigest/SUNDomEigEst_API_link.rst b/doc/cvode/guide/source/sundomeigest/SUNDomEigEst_API_link.rst index 63131049d7..b4bab47f00 100644 --- a/doc/cvode/guide/source/sundomeigest/SUNDomEigEst_API_link.rst +++ b/doc/cvode/guide/source/sundomeigest/SUNDomEigEst_API_link.rst @@ -10,4 +10,4 @@ SUNDIALS Copyright End ---------------------------------------------------------------- -.. include:: ../../../shared/sundomeigest/SUNDomEigEst_API.rst +.. include:: ../../../../shared/sundomeigest/SUNDomEigEst_API.rst diff --git a/doc/cvode/guide/source/sundomeigest/SUNDomEigEst_links.rst b/doc/cvode/guide/source/sundomeigest/SUNDomEigEst_links.rst index 68de7d1878..6ed23337b2 100644 --- a/doc/cvode/guide/source/sundomeigest/SUNDomEigEst_links.rst +++ b/doc/cvode/guide/source/sundomeigest/SUNDomEigEst_links.rst @@ -10,6 +10,6 @@ SUNDIALS Copyright End ---------------------------------------------------------------- -.. include:: ../../../shared/sundomeigest/SUNDomEigEst_PI.rst -.. include:: ../../../shared/sundomeigest/SUNDomEigEst_ARNI.rst -.. include:: ../../../shared/sundomeigest/SUNDomEigEst_Examples.rst +.. include:: ../../../../shared/sundomeigest/SUNDomEigEst_PI.rst +.. include:: ../../../../shared/sundomeigest/SUNDomEigEst_ARNI.rst +.. include:: ../../../../shared/sundomeigest/SUNDomEigEst_Examples.rst diff --git a/doc/cvodes/guide/source/sundomeigest/SUNDomEigEst_API_link.rst b/doc/cvodes/guide/source/sundomeigest/SUNDomEigEst_API_link.rst index 63131049d7..b4bab47f00 100644 --- a/doc/cvodes/guide/source/sundomeigest/SUNDomEigEst_API_link.rst +++ b/doc/cvodes/guide/source/sundomeigest/SUNDomEigEst_API_link.rst @@ -10,4 +10,4 @@ SUNDIALS Copyright End ---------------------------------------------------------------- -.. include:: ../../../shared/sundomeigest/SUNDomEigEst_API.rst +.. include:: ../../../../shared/sundomeigest/SUNDomEigEst_API.rst diff --git a/doc/cvodes/guide/source/sundomeigest/SUNDomEigEst_links.rst b/doc/cvodes/guide/source/sundomeigest/SUNDomEigEst_links.rst index 68de7d1878..6ed23337b2 100644 --- a/doc/cvodes/guide/source/sundomeigest/SUNDomEigEst_links.rst +++ b/doc/cvodes/guide/source/sundomeigest/SUNDomEigEst_links.rst @@ -10,6 +10,6 @@ SUNDIALS Copyright End ---------------------------------------------------------------- -.. include:: ../../../shared/sundomeigest/SUNDomEigEst_PI.rst -.. include:: ../../../shared/sundomeigest/SUNDomEigEst_ARNI.rst -.. include:: ../../../shared/sundomeigest/SUNDomEigEst_Examples.rst +.. include:: ../../../../shared/sundomeigest/SUNDomEigEst_PI.rst +.. include:: ../../../../shared/sundomeigest/SUNDomEigEst_ARNI.rst +.. include:: ../../../../shared/sundomeigest/SUNDomEigEst_Examples.rst diff --git a/doc/ida/guide/source/sundomeigest/SUNDomEigEst_API_link.rst b/doc/ida/guide/source/sundomeigest/SUNDomEigEst_API_link.rst index 63131049d7..b4bab47f00 100644 --- a/doc/ida/guide/source/sundomeigest/SUNDomEigEst_API_link.rst +++ b/doc/ida/guide/source/sundomeigest/SUNDomEigEst_API_link.rst @@ -10,4 +10,4 @@ SUNDIALS Copyright End ---------------------------------------------------------------- -.. include:: ../../../shared/sundomeigest/SUNDomEigEst_API.rst +.. include:: ../../../../shared/sundomeigest/SUNDomEigEst_API.rst diff --git a/doc/ida/guide/source/sundomeigest/SUNDomEigEst_links.rst b/doc/ida/guide/source/sundomeigest/SUNDomEigEst_links.rst index 68de7d1878..6ed23337b2 100644 --- a/doc/ida/guide/source/sundomeigest/SUNDomEigEst_links.rst +++ b/doc/ida/guide/source/sundomeigest/SUNDomEigEst_links.rst @@ -10,6 +10,6 @@ SUNDIALS Copyright End ---------------------------------------------------------------- -.. include:: ../../../shared/sundomeigest/SUNDomEigEst_PI.rst -.. include:: ../../../shared/sundomeigest/SUNDomEigEst_ARNI.rst -.. include:: ../../../shared/sundomeigest/SUNDomEigEst_Examples.rst +.. include:: ../../../../shared/sundomeigest/SUNDomEigEst_PI.rst +.. include:: ../../../../shared/sundomeigest/SUNDomEigEst_ARNI.rst +.. include:: ../../../../shared/sundomeigest/SUNDomEigEst_Examples.rst diff --git a/doc/idas/guide/source/sundomeigest/SUNDomEigEst_API_link.rst b/doc/idas/guide/source/sundomeigest/SUNDomEigEst_API_link.rst index 63131049d7..b4bab47f00 100644 --- a/doc/idas/guide/source/sundomeigest/SUNDomEigEst_API_link.rst +++ b/doc/idas/guide/source/sundomeigest/SUNDomEigEst_API_link.rst @@ -10,4 +10,4 @@ SUNDIALS Copyright End ---------------------------------------------------------------- -.. include:: ../../../shared/sundomeigest/SUNDomEigEst_API.rst +.. include:: ../../../../shared/sundomeigest/SUNDomEigEst_API.rst diff --git a/doc/idas/guide/source/sundomeigest/SUNDomEigEst_links.rst b/doc/idas/guide/source/sundomeigest/SUNDomEigEst_links.rst index 68de7d1878..6ed23337b2 100644 --- a/doc/idas/guide/source/sundomeigest/SUNDomEigEst_links.rst +++ b/doc/idas/guide/source/sundomeigest/SUNDomEigEst_links.rst @@ -10,6 +10,6 @@ SUNDIALS Copyright End ---------------------------------------------------------------- -.. include:: ../../../shared/sundomeigest/SUNDomEigEst_PI.rst -.. include:: ../../../shared/sundomeigest/SUNDomEigEst_ARNI.rst -.. include:: ../../../shared/sundomeigest/SUNDomEigEst_Examples.rst +.. include:: ../../../../shared/sundomeigest/SUNDomEigEst_PI.rst +.. include:: ../../../../shared/sundomeigest/SUNDomEigEst_ARNI.rst +.. include:: ../../../../shared/sundomeigest/SUNDomEigEst_Examples.rst diff --git a/doc/kinsol/guide/source/sundomeigest/SUNDomEigEst_API_link.rst b/doc/kinsol/guide/source/sundomeigest/SUNDomEigEst_API_link.rst index 63131049d7..b4bab47f00 100644 --- a/doc/kinsol/guide/source/sundomeigest/SUNDomEigEst_API_link.rst +++ b/doc/kinsol/guide/source/sundomeigest/SUNDomEigEst_API_link.rst @@ -10,4 +10,4 @@ SUNDIALS Copyright End ---------------------------------------------------------------- -.. include:: ../../../shared/sundomeigest/SUNDomEigEst_API.rst +.. include:: ../../../../shared/sundomeigest/SUNDomEigEst_API.rst diff --git a/doc/kinsol/guide/source/sundomeigest/SUNDomEigEst_links.rst b/doc/kinsol/guide/source/sundomeigest/SUNDomEigEst_links.rst index 68de7d1878..6ed23337b2 100644 --- a/doc/kinsol/guide/source/sundomeigest/SUNDomEigEst_links.rst +++ b/doc/kinsol/guide/source/sundomeigest/SUNDomEigEst_links.rst @@ -10,6 +10,6 @@ SUNDIALS Copyright End ---------------------------------------------------------------- -.. include:: ../../../shared/sundomeigest/SUNDomEigEst_PI.rst -.. include:: ../../../shared/sundomeigest/SUNDomEigEst_ARNI.rst -.. include:: ../../../shared/sundomeigest/SUNDomEigEst_Examples.rst +.. include:: ../../../../shared/sundomeigest/SUNDomEigEst_PI.rst +.. include:: ../../../../shared/sundomeigest/SUNDomEigEst_ARNI.rst +.. include:: ../../../../shared/sundomeigest/SUNDomEigEst_Examples.rst diff --git a/doc/shared/sundomeigest/SUNDomEigEst_API.rst b/doc/shared/sundomeigest/SUNDomEigEst_API.rst index 86c07f450c..b24aa40e9f 100644 --- a/doc/shared/sundomeigest/SUNDomEigEst_API.rst +++ b/doc/shared/sundomeigest/SUNDomEigEst_API.rst @@ -84,7 +84,7 @@ for iterations (:c:func:`SUNDomEigEstPreProcess`), computes Hessenberg matrix (w retval = SUNDomEigEstComputeHess(DEE); -.. c:function:: SUNErrCode SUNDomEigEstimate(SUNDomEigEstimator DEE, suncomplextype* dom_eig) +.. c:function:: SUNErrCode SUNDomEigEstimate(SUNDomEigEstimator DEE, sunrealtype* lambdaR, sunrealtype* lambdaI) This *required* function estimates the dominant eigenvalue, :math:`\lambda_{\max} = \lambda` such that @@ -93,7 +93,8 @@ for iterations (:c:func:`SUNDomEigEstPreProcess`), computes Hessenberg matrix (w **Arguments:** * *DEE* -- a SUNDomEigEst object. - * *dom_eig* -- a ``SUNMatrix`` object. + * *lambdaR* -- The real part of the dominant eigenvalue + * *lambdaI* -- The imaginary part of the dominant eigenvalue **Return value:** @@ -284,26 +285,11 @@ Functions provided by SUNDIALS packages --------------------------------------------- To interface with SUNDomEigEst modules, the SUNDIALS packages supply -a routine for evaluating the matrix-vector product. This package-provided +a routine (:c:type:`SUNATimesFn`) for evaluating the matrix-vector product. This package-provided routine translate between the user-supplied ODE, DAE, or linear and nonlinear systems and the generic dominant eigenvalue estimatimator API. The function types for these routines are defined in the header file -``sundials/sundials_iterative.h``, and are described below. - - -.. c:type:: int (*SUNATimesFn)(void *A_data, N_Vector v, N_Vector z) - - Computes the action of a matrix on a vector, performing the - operation :math:`z \gets Av`. Memory for *z* will already be - allocated prior to calling this function. The parameter - *A_data* is a pointer to any information about :math:`A` which - the function needs in order to do its job. The vector :math:`v` - should be left unchanged. - - **Return value:** - - Zero for a successful call, and non-zero upon failure. - +``sundials/sundials_iterative.h``. .. _SUNDomEigEst.ReturnCodes: @@ -424,7 +410,7 @@ The virtual table structure is defined as The function implementing :c:func:`SUNDomEigEstComputeHess` - .. c:member:: SUNErrCode (*estimate)(SUNDomEigEstimator, suncomplextype*) + .. c:member:: SUNErrCode (*estimate)(SUNDomEigEstimator, sunrealtype*, sunrealtype*) The function implementing :c:func:`SUNDomEigEstimate` diff --git a/doc/shared/sundomeigest/SUNDomEigEst_ARNI.rst b/doc/shared/sundomeigest/SUNDomEigEst_ARNI.rst index 9ba817e2e3..50891f6de6 100644 --- a/doc/shared/sundomeigest/SUNDomEigEst_ARNI.rst +++ b/doc/shared/sundomeigest/SUNDomEigEst_ARNI.rst @@ -105,7 +105,7 @@ The SUNDomEigEst_ARNI module defines the *content* field of a sunrealtype* LAPACK_wr; sunrealtype* LAPACK_wi; sunrealtype* LAPACK_work; - suncomplextype* LAPACK_arr; + sunrealtype** LAPACK_arr; sunrealtype** Hes; }; @@ -125,7 +125,7 @@ information: * ``LAPACK_A, LAPACK_wr, LAPACK_wi, LAPACK_work`` - ``sunrealtype`` used for workspace by LAPACK, -* ``LAPACK_arr`` - ``suncomplextype`` used for workspace by LAPACK, +* ``LAPACK_arr`` - storage for the estimated dominant eigenvalues, * ``Hes`` - Hessenberg matrix, From 84f85e1e6c387f4df7332b856f470360359ffb9a Mon Sep 17 00:00:00 2001 From: maggul Date: Thu, 19 Jun 2025 02:15:08 -0500 Subject: [PATCH 056/128] formatting --- src/arkode/arkode_lsrkstep.c | 5 +---- src/sundomeigest/ArnI/sundomeigest_arni.c | 8 ++++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/arkode/arkode_lsrkstep.c b/src/arkode/arkode_lsrkstep.c index 435b4a69b7..e029d427d0 100644 --- a/src/arkode/arkode_lsrkstep.c +++ b/src/arkode/arkode_lsrkstep.c @@ -2012,10 +2012,7 @@ void lsrkStep_Free(ARKodeMem ark_mem) ark_mem->liw -= step_mem->nfusedopvecs; } /* free DEE */ - if(step_mem->DEE != NULL) - { - step_mem->DEE->ops->free(step_mem->DEE); - } + if (step_mem->DEE != NULL) { step_mem->DEE->ops->free(step_mem->DEE); } /* free the time stepper module itself */ free(ark_mem->step_mem); diff --git a/src/sundomeigest/ArnI/sundomeigest_arni.c b/src/sundomeigest/ArnI/sundomeigest_arni.c index 0a4361dbb7..1b71ce4ed7 100644 --- a/src/sundomeigest/ArnI/sundomeigest_arni.c +++ b/src/sundomeigest/ArnI/sundomeigest_arni.c @@ -445,10 +445,10 @@ SUNErrCode SUNDomEigEstFree_ArnI(SUNDomEigEstimator DEE) // Comparison function for qsort int domeig_Compare(const void* a, const void* b) { - const sunrealtype* c1 = *(const sunrealtype* const *)a; - const sunrealtype* c2 = *(const sunrealtype* const *)b; + const sunrealtype* c1 = *(const sunrealtype* const*)a; + const sunrealtype* c2 = *(const sunrealtype* const*)b; - sunrealtype mag1 = SUNRsqrt(c1[0] * c1[0] + c1[1] * c1[1]); - sunrealtype mag2 = SUNRsqrt(c2[0] * c2[0] + c2[1] * c2[1]); + sunrealtype mag1 = SUNRsqrt(c1[0] * c1[0] + c1[1] * c1[1]); + sunrealtype mag2 = SUNRsqrt(c2[0] * c2[0] + c2[1] * c2[1]); return (mag2 > mag1) - (mag2 < mag1); // Descending order } From 9001c033146ac8a585fa2b0611e53b82f53dc4b9 Mon Sep 17 00:00:00 2001 From: maggul Date: Thu, 19 Jun 2025 17:52:06 -0500 Subject: [PATCH 057/128] Bulk updates --- .../ark_analytic_lsrk_internal_domeig.c | 4 +- include/arkode/arkode.h | 2 +- include/arkode/arkode_lsrkstep.h | 13 +- .../priv/sundials_domeigestimator_impl.h | 4 +- include/sundials/sundials_domeigestimator.h | 9 +- include/sundials/sundials_errors.h | 6 +- src/arkode/arkode_impl.h | 4 +- src/arkode/arkode_lsrkstep.c | 89 +- src/arkode/arkode_lsrkstep_impl.h | 14 +- src/arkode/arkode_lsrkstep_io.c | 69 +- src/arkode/fmod_int32/farkode_lsrkstep_mod.c | 48 +- .../fmod_int32/farkode_lsrkstep_mod.f90 | 136 +- src/arkode/fmod_int32/farkode_mod.f90 | 1344 ++++++++--------- src/arkode/fmod_int64/farkode_lsrkstep_mod.c | 48 +- .../fmod_int64/farkode_lsrkstep_mod.f90 | 136 +- src/arkode/fmod_int64/farkode_mod.f90 | 1344 ++++++++--------- src/cvode/CMakeLists.txt | 14 +- src/cvodes/CMakeLists.txt | 14 +- src/ida/CMakeLists.txt | 14 +- src/idas/CMakeLists.txt | 14 +- src/kinsol/CMakeLists.txt | 14 +- src/sundials/CMakeLists.txt | 2 +- src/sundials/sundials_domeigestimator.c | 18 +- src/sundomeigest/ArnI/sundomeigest_arni.c | 6 +- src/sundomeigest/PI/sundomeigest_pi.c | 2 +- 25 files changed, 1732 insertions(+), 1636 deletions(-) diff --git a/examples/arkode/C_serial/ark_analytic_lsrk_internal_domeig.c b/examples/arkode/C_serial/ark_analytic_lsrk_internal_domeig.c index 60f45d690e..2bb4dfc4f5 100644 --- a/examples/arkode/C_serial/ark_analytic_lsrk_internal_domeig.c +++ b/examples/arkode/C_serial/ark_analytic_lsrk_internal_domeig.c @@ -33,7 +33,7 @@ * larger than 100 the problem becomes quite stiff. * * This program solves the problem with the LSRK method using internal - * dominant eigenvalue module for eigenvalue estimation. + * SUNDIALS dominant eigenvalue estimation (DEE) module. * Output is printed every 1.0 units of time (10 total). * Run statistics (optional outputs) are printed at the end. *-----------------------------------------------------------------*/ @@ -154,7 +154,7 @@ int main(void) flag = ARKodeSStolerances(arkode_mem, reltol, abstol); if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } - /* Specify NULL spectral radius function */ + /* Specify NULL spectral radius function for internal DEE*/ flag = LSRKStepSetDomEigFn(arkode_mem, NULL); if (check_flag(&flag, "LSRKStepSetDomEigFn", 1)) { return 1; } diff --git a/include/arkode/arkode.h b/include/arkode/arkode.h index b0a443970c..bc7ca051c5 100644 --- a/include/arkode/arkode.h +++ b/include/arkode/arkode.h @@ -152,7 +152,7 @@ extern "C" { #define ARK_ADJ_RECOMPUTE_FAIL -54 #define ARK_SUNADJSTEPPER_ERR -55 -#define ARK_INTERNAL_DOMEIG_FAIL -56 +#define ARK_DEE_FAIL -56 #define ARK_UNRECOGNIZED_ERROR -99 diff --git a/include/arkode/arkode_lsrkstep.h b/include/arkode/arkode_lsrkstep.h index fce3c4adac..b204bb0ab0 100644 --- a/include/arkode/arkode_lsrkstep.h +++ b/include/arkode/arkode_lsrkstep.h @@ -18,7 +18,6 @@ #define _LSRKSTEP_H #include -#include #ifdef __cplusplus /* wrapper to enable C++ usage */ extern "C" { @@ -42,12 +41,6 @@ typedef enum ARKODE_LSRK_SSP_10_4 } ARKODE_LSRKMethodType; -typedef enum -{ - ARKODE_LSRK_POWER_ITERATION, - ARKODE_LSRK_ARNOLDI_ITERATION -} ARKODE_LSRKInternal_DomEigEst_Type; - /* ------------------- * Exported Functions * ------------------- */ @@ -82,8 +75,8 @@ SUNDIALS_EXPORT int LSRKStepSetSSPMethodByName(void* arkode_mem, SUNDIALS_EXPORT int LSRKStepSetDomEigFn(void* arkode_mem, ARKDomEigFn dom_eig); -SUNDIALS_EXPORT int LSRKStepSetInternalDomEigEstType( - void* arkode_mem, ARKODE_LSRKInternal_DomEigEst_Type dom_eig_type); +SUNDIALS_EXPORT int LSRKStepSetDEECreateWithID( + void* arkode_mem, SUNDomEigEstimator_ID DEE_id); SUNDIALS_EXPORT int LSRKStepSetDomEigFrequency(void* arkode_mem, long int nsteps); @@ -102,6 +95,8 @@ SUNDIALS_EXPORT int LSRKStepGetNumDomEigUpdates(void* arkode_mem, SUNDIALS_EXPORT int LSRKStepGetMaxNumStages(void* arkode_mem, int* stage_max); +SUNDIALS_EXPORT int LSRKStepGetNumRHSinDQ(void* arkode_mem, int* nfeDQ); + #ifdef __cplusplus } #endif diff --git a/include/sundials/priv/sundials_domeigestimator_impl.h b/include/sundials/priv/sundials_domeigestimator_impl.h index 70ef5dc603..963b7505fd 100644 --- a/include/sundials/priv/sundials_domeigestimator_impl.h +++ b/include/sundials/priv/sundials_domeigestimator_impl.h @@ -18,7 +18,6 @@ #ifndef _DOMEIG_IMPL_H #define _DOMEIG_IMPL_H -#include #include #ifdef __cplusplus /* wrapper to enable C++ usage */ @@ -29,8 +28,7 @@ extern "C" { DOMEIG module private function prototypes ===============================================================*/ -SUNErrCode domeig_CheckNVector(N_Vector tmpl); -int domeig_Compare(const void* a, const void* b); +int sundomeigest_Compare(const void* a, const void* b); /* * ----------------------------------------------------------------- diff --git a/include/sundials/sundials_domeigestimator.h b/include/sundials/sundials_domeigestimator.h index 53d238a5af..e559cab2bc 100644 --- a/include/sundials/sundials_domeigestimator.h +++ b/include/sundials/sundials_domeigestimator.h @@ -31,7 +31,7 @@ extern "C" { #endif /* Default estimator parameters */ -#define SUNDOMEIGEST_NUM_OF_WARMUPS_DEFAULT 0 +#define DEE_NUM_OF_WARMUPS_DEFAULT 0 /* ----------------------------------------------------------------- * Implemented SUNDomEigEstimator types @@ -44,7 +44,7 @@ typedef enum } SUNDomEigEstimator_ID; /* ----------------------------------------------------------------- - * Generic definition of SUNDomEigEstimator + * Generic definition of SUNDomEigEstimator (DEE) * ----------------------------------------------------------------- */ /* Forward reference for pointer to SUNDomEigEstimator_Ops object */ @@ -70,7 +70,7 @@ struct _generic_SUNDomEigEstimator_Ops SUNErrCode (*free)(SUNDomEigEstimator); }; -/* A estimator is a structure with an implementation-dependent +/* An estimator is a structure with an implementation-dependent 'content' field, and a pointer to a structure of estimator operations corresponding to that implementation. */ struct _generic_SUNDomEigEstimator @@ -126,6 +126,9 @@ SUNErrCode SUNDomEigEstNumIters(SUNDomEigEstimator DEE, int* niter); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstRes(SUNDomEigEstimator DEE, sunrealtype* res); +SUNDIALS_EXPORT +SUNErrCode SUNDomEigEstFree(SUNDomEigEstimator DEE); + #ifdef __cplusplus } #endif diff --git a/include/sundials/sundials_errors.h b/include/sundials/sundials_errors.h index dbd46b83c3..89bf26d810 100644 --- a/include/sundials/sundials_errors.h +++ b/include/sundials/sundials_errors.h @@ -75,9 +75,11 @@ ENTRY(SUN_ERR_DEE_ATIMES_FAIL_REC, "Atimes recoverable failure") \ ENTRY(SUN_ERR_DEE_ATIMES_FAIL_UNREC, "Atimes unrecoverable failure") \ ENTRY(SUN_ERR_DEE_NULL_HES, "Hessenberg matrix is null") \ - ENTRY(SUN_ERR_DEE_NULL_MEM, "Domimant eigenvalue estimator memory is null") \ + ENTRY(SUN_ERR_DEE_NULL_MEM, "DEE memory is null") \ ENTRY(SUN_ERR_DEE_NULL_CONTENT, "DDE content is null") \ - ENTRY(SUN_ERR_DEE_LAPACK_FAIL, "LAPACK _dgeev function failure") \ + ENTRY(SUN_ERR_DEE_LAPACK_FAIL, "LAPACK _dgeev/_sgeev function failure") \ + ENTRY(SUN_ERR_DEE_NULL_ESTIMATE, "Estimate function ptr is NULL") \ + ENTRY(SUN_ERR_DEE_NULL_FREE, "Free function ptr is NULL") \ \ ENTRY(SUN_ERR_SUNCTX_CORRUPT, "SUNContext is NULL or corrupt") \ \ diff --git a/src/arkode/arkode_impl.h b/src/arkode/arkode_impl.h index 59a0e976c9..d631bfd4e2 100644 --- a/src/arkode/arkode_impl.h +++ b/src/arkode/arkode_impl.h @@ -823,9 +823,7 @@ int arkGetLastKFlag(void* arkode_mem, int* last_kflag); "JacPFn or JPvpFn was provided, but the number of subvectors in y is not " \ "2. To perform ASA w.r.t. parameters, one subvector should be the state " \ "vector, and the other should be the parameter vector." - -#define MSG_ARK_INTERNAL_DOMEIG_FAIL \ - "Internal domeig iteration for the dominant eigenvalue estimation failed. " +#define MSG_ARK_DEE_FAIL "Dominant eigenvalue estimator (DEE) failed. " /*=============================================================== diff --git a/src/arkode/arkode_lsrkstep.c b/src/arkode/arkode_lsrkstep.c index e029d427d0..cd5b233b82 100644 --- a/src/arkode/arkode_lsrkstep.c +++ b/src/arkode/arkode_lsrkstep.c @@ -191,10 +191,9 @@ void* lsrkStep_Create_Commons(ARKRhsFn rhs, sunrealtype t0, N_Vector y0, /* Copy the input parameters into ARKODE state */ step_mem->fe = rhs; - step_mem->domeig_rhs = NULL; /* Set internal DomEigEst type */ - step_mem->internal_domeigest_type = ARKODE_LSRK_POWER_ITERATION; + step_mem->DDE_ID = SUNDSOMEIGESTIMATOR_POWER; /* Set NULL for dom_eig_fn */ step_mem->dom_eig_fn = NULL; @@ -2226,9 +2225,9 @@ int lsrkStep_ComputeNewDomEig(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem) step_mem->dom_eig_num_evals++; if (retval != ARK_SUCCESS) { - arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, - __FILE__, MSG_ARK_INTERNAL_DOMEIG_FAIL); - return ARK_INTERNAL_DOMEIG_FAIL; + arkProcessError(ark_mem, ARK_DEE_FAIL, __LINE__, __func__, + __FILE__, MSG_ARK_DEE_FAIL); + return ARK_DEE_FAIL; } } else @@ -2305,53 +2304,50 @@ SUNDomEigEstimator lsrkStep_DomEigCreate(void* arkode_mem) return NULL; } - step_mem->domeig_rhs = step_mem->fe; - - step_mem->domeig_krydim = DOMEIG_KRYLOV_DIM_DEFAULT; - step_mem->numwarmups = SUNDOMEIGEST_NUM_OF_WARMUPS_DEFAULT; - step_mem->domeig_maxiters = DOMEIG_MAX_NUMBER_OF_POWER_ITERS_DEFAULT; + step_mem->dee_krydim = DEE_KRYLOV_DIM_DEFAULT; + step_mem->dee_numwarmups = DEE_NUM_OF_WARMUPS_DEFAULT; + step_mem->dee_maxiters = DEE_MAX_NUMBER_OF_POWER_ITERS_DEFAULT; /* Enforce the power iteration if the problem size < 3 */ - if (step_mem->internal_domeigest_type == ARKODE_LSRK_ARNOLDI_ITERATION && + if (step_mem->DDE_ID == SUNDSOMEIGESTIMATOR_ARNOLDI && ark_mem->yn->ops->nvgetlength(ark_mem->yn) < 3) { - step_mem->internal_domeigest_type = ARKODE_LSRK_POWER_ITERATION; + step_mem->DDE_ID = SUNDSOMEIGESTIMATOR_POWER; } /* Create the internal DomEigEst */ - if (step_mem->internal_domeigest_type == ARKODE_LSRK_POWER_ITERATION) + if (step_mem->DDE_ID == SUNDSOMEIGESTIMATOR_POWER) { - DEE = SUNDomEigEst_PI(ark_mem->yn, step_mem->domeig_maxiters, + DEE = SUNDomEigEst_PI(ark_mem->yn, step_mem->dee_maxiters, ark_mem->sunctx); if (DEE == NULL) { - arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, - __FILE__, MSG_ARK_INTERNAL_DOMEIG_FAIL); + arkProcessError(ark_mem, ARK_DEE_FAIL, __LINE__, __func__, + __FILE__, "ARKODE failed to create a DDE: Creation routine returned NULL DDE"); return NULL; } } - else if (step_mem->internal_domeigest_type == ARKODE_LSRK_ARNOLDI_ITERATION) + else if (step_mem->DDE_ID == SUNDSOMEIGESTIMATOR_ARNOLDI) { #ifdef SUNDIALS_BLAS_LAPACK_ENABLED - DEE = SUNDomEigEst_ArnI(ark_mem->yn, step_mem->domeig_krydim, - ark_mem->sunctx); + DEE = SUNDomEigEst_ArnI(ark_mem->yn, step_mem->dee_krydim, ark_mem->sunctx); if (DEE == NULL) { - arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, - __FILE__, MSG_ARK_INTERNAL_DOMEIG_FAIL); + arkProcessError(ark_mem, ARK_DEE_FAIL, __LINE__, __func__, + __FILE__, "ARKODE failed to create a DDE: Creation routine returned NULL DDE"); return NULL; } #else - arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, + arkProcessError(ark_mem, ARK_DEE_FAIL, __LINE__, __func__, __FILE__, - "Internal Arnoldi iteration requires LAPACK package"); + "Sundials Arnoldi DDE requires LAPACK package"); return NULL; #endif } else { - arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, - __FILE__, "Attempted to create an internal domeig estimator with an unknown type"); + arkProcessError(ark_mem, ARK_DEE_FAIL, __LINE__, __func__, + __FILE__, "Attempted to create a DDE with an unknown type"); return NULL; } @@ -2359,19 +2355,19 @@ SUNDomEigEstimator lsrkStep_DomEigCreate(void* arkode_mem) retval = DEE->ops->setatimes(DEE, arkode_mem, lsrkStep_DQJtimes); if (retval != ARK_SUCCESS) { - arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, - __FILE__, MSG_ARK_INTERNAL_DOMEIG_FAIL); + arkProcessError(ark_mem, ARK_DEE_FAIL, __LINE__, __func__, + __FILE__, MSG_ARK_DEE_FAIL); return NULL; } /* Set Max Power Itetations*/ if (DEE->ops->setmaxpoweriter != NULL) { - retval = DEE->ops->setmaxpoweriter(DEE, step_mem->domeig_maxiters); + retval = DEE->ops->setmaxpoweriter(DEE, step_mem->dee_maxiters); if (retval != ARK_SUCCESS) { - arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, - __FILE__, MSG_ARK_INTERNAL_DOMEIG_FAIL); + arkProcessError(ark_mem, ARK_DEE_FAIL, __LINE__, __func__, + __FILE__, MSG_ARK_DEE_FAIL); return NULL; } } @@ -2380,19 +2376,19 @@ SUNDomEigEstimator lsrkStep_DomEigCreate(void* arkode_mem) retval = DEE->ops->initialize(DEE); if (retval != ARK_SUCCESS) { - arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, - __FILE__, MSG_ARK_INTERNAL_DOMEIG_FAIL); + arkProcessError(ark_mem, ARK_DEE_FAIL, __LINE__, __func__, + __FILE__, MSG_ARK_DEE_FAIL); return NULL; } /* Set the number of preprocessings */ if (DEE->ops->setnumofperprocess != NULL) { - retval = DEE->ops->setnumofperprocess(DEE, step_mem->numwarmups); + retval = DEE->ops->setnumofperprocess(DEE, step_mem->dee_numwarmups); if (retval != ARK_SUCCESS) { - arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, - __FILE__, MSG_ARK_INTERNAL_DOMEIG_FAIL); + arkProcessError(ark_mem, ARK_DEE_FAIL, __LINE__, __func__, + __FILE__, MSG_ARK_DEE_FAIL); return NULL; } } @@ -2426,16 +2422,16 @@ int lsrkStep_DomEigEstimate(void* arkode_mem, SUNDomEigEstimator DEE, return ARK_ILL_INPUT; } - /* Set the initial q = A^{numwarmups}q/||A^{numwarmups}q|| */ + /* Set the initial q = A^{dee_numwarmups}q/||A^{dee_numwarmups}q|| */ if (DEE->ops->preprocess != NULL) { retval = DEE->ops->preprocess(DEE); if (retval != ARK_SUCCESS) { - arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, - __FILE__, MSG_ARK_INTERNAL_DOMEIG_FAIL); + arkProcessError(ark_mem, ARK_DEE_FAIL, __LINE__, __func__, + __FILE__, MSG_ARK_DEE_FAIL); - return ARK_INTERNAL_DOMEIG_FAIL; + return ARK_DEE_FAIL; } } @@ -2445,20 +2441,20 @@ int lsrkStep_DomEigEstimate(void* arkode_mem, SUNDomEigEstimator DEE, retval = DEE->ops->computehess(DEE); if (retval != ARK_SUCCESS) { - arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, - __FILE__, MSG_ARK_INTERNAL_DOMEIG_FAIL); + arkProcessError(ark_mem, ARK_DEE_FAIL, __LINE__, __func__, + __FILE__, MSG_ARK_DEE_FAIL); - return ARK_INTERNAL_DOMEIG_FAIL; + return ARK_DEE_FAIL; } } retval = DEE->ops->estimate(DEE, lambdaR, lambdaI); if (retval != ARK_SUCCESS) { - arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, - __FILE__, MSG_ARK_INTERNAL_DOMEIG_FAIL); + arkProcessError(ark_mem, ARK_DEE_FAIL, __LINE__, __func__, + __FILE__, MSG_ARK_DEE_FAIL); - return ARK_INTERNAL_DOMEIG_FAIL; + return ARK_DEE_FAIL; } return ARK_SUCCESS; @@ -2507,7 +2503,8 @@ int lsrkStep_DQJtimes(void* arkode_mem, N_Vector v, N_Vector Jv) N_VLinearSum(sig, v, ONE, y, work); /* Set Jv = f(tn, y+sig*v) */ - retval = step_mem->domeig_rhs(t, work, Jv, ark_mem->user_data); + //TODO:Needs to be update when LSRK Supports IMEX + retval = step_mem->fe(t, work, Jv, ark_mem->user_data); step_mem->nfeDQ++; if (retval == 0) { break; } if (retval < 0) { return (-1); } diff --git a/src/arkode/arkode_lsrkstep_impl.h b/src/arkode/arkode_lsrkstep_impl.h index 453236429c..a260d49ad5 100644 --- a/src/arkode/arkode_lsrkstep_impl.h +++ b/src/arkode/arkode_lsrkstep_impl.h @@ -19,7 +19,6 @@ #define _ARKODE_LSRKSTEP_IMPL_H #include -#include #include #ifdef SUNDIALS_BLAS_LAPACK_ENABLED @@ -35,8 +34,8 @@ extern "C" { #define STAGE_MAX_LIMIT_DEFAULT 200 #define DOM_EIG_SAFETY_DEFAULT SUN_RCONST(1.01) #define DOM_EIG_FREQ_DEFAULT 25 -#define DOMEIG_KRYLOV_DIM_DEFAULT 3 -#define DOMEIG_MAX_NUMBER_OF_POWER_ITERS_DEFAULT 100 +#define DEE_KRYLOV_DIM_DEFAULT 3 +#define DEE_MAX_NUMBER_OF_POWER_ITERS_DEFAULT 100 /*=============================================================== LSRK time step module private math function macros @@ -136,7 +135,6 @@ typedef struct ARKodeLSRKStepMemRec { /* LSRK problem specification */ ARKRhsFn fe; - ARKRhsFn domeig_rhs; ARKDomEigFn dom_eig_fn; int q; /* method order */ @@ -164,11 +162,11 @@ typedef struct ARKodeLSRKStepMemRec sunrealtype dom_eig_safety; /* some safety factor for the user provided dom_eig*/ long int dom_eig_freq; /* indicates dom_eig update after dom_eig_freq successful steps*/ - ARKODE_LSRKInternal_DomEigEst_Type internal_domeigest_type; /* Internal DomEig estimator type*/ + SUNDomEigEstimator_ID DDE_ID; /* DEE ID */ SUNDomEigEstimator DEE; /* DomEig estimator*/ - int domeig_krydim; /* Krylov subspace dimension */ - int numwarmups; /* Power of A in the preprocessing; initial q = A^{numwarmups}q/||A^{numwarmups}q|| */ - int domeig_maxiters; /* Max number of Power Iterations */ + int dee_krydim; /* Krylov subspace dimension */ + int dee_numwarmups; /* Power of A in the preprocessing; initial q = A^{dee_numwarmups}q/||A^{dee_numwarmups}q|| */ + int dee_maxiters; /* Max number of Power Iterations */ /* Flags */ sunbooleantype dom_eig_update; /* flag indicating new dom_eig is needed */ diff --git a/src/arkode/arkode_lsrkstep_io.c b/src/arkode/arkode_lsrkstep_io.c index cdf8e611d3..ec82fcff7e 100644 --- a/src/arkode/arkode_lsrkstep_io.c +++ b/src/arkode/arkode_lsrkstep_io.c @@ -218,18 +218,18 @@ int LSRKStepSetDomEigFn(void* arkode_mem, ARKDomEigFn dom_eig) else { /* Set the default internal dominant eigenvalue estimator type */ - if (step_mem->internal_domeigest_type != ARKODE_LSRK_ARNOLDI_ITERATION) + if (step_mem->DDE_ID != SUNDSOMEIGESTIMATOR_ARNOLDI) { - step_mem->internal_domeigest_type = ARKODE_LSRK_POWER_ITERATION; + step_mem->DDE_ID = SUNDSOMEIGESTIMATOR_POWER; } /* Create an internal dominant eigenvalue estimator */ step_mem->DEE = lsrkStep_DomEigCreate(arkode_mem); if (step_mem->DEE == NULL) { - arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, - __FILE__, "Internal DomEigEstimator is NULL"); - return ARK_INTERNAL_DOMEIG_FAIL; + arkProcessError(ark_mem, ARK_DEE_FAIL, __LINE__, __func__, + __FILE__, "ARKODE failed to create a DDE: Creation routine returned NULL DDE"); + return ARK_DEE_FAIL; } return ARK_SUCCESS; @@ -237,10 +237,10 @@ int LSRKStepSetDomEigFn(void* arkode_mem, ARKDomEigFn dom_eig) } /*--------------------------------------------------------------- - LSRKStepSetInternalDomEigEstType sets internal DomEigEst type. + LSRKStepSetDEECreateWithID creates DomEigEst with ID. ---------------------------------------------------------------*/ -SUNDIALS_EXPORT int LSRKStepSetInternalDomEigEstType( - void* arkode_mem, ARKODE_LSRKInternal_DomEigEst_Type dom_eig_type) +SUNDIALS_EXPORT int LSRKStepSetDEECreateWithID( + void* arkode_mem, SUNDomEigEstimator_ID DEE_id) { ARKodeMem ark_mem; ARKodeLSRKStepMem step_mem; @@ -251,36 +251,36 @@ SUNDIALS_EXPORT int LSRKStepSetInternalDomEigEstType( &step_mem); if (retval != ARK_SUCCESS) { return retval; } - if (dom_eig_type == ARKODE_LSRK_POWER_ITERATION) + if (DEE_id == SUNDSOMEIGESTIMATOR_POWER) { - step_mem->internal_domeigest_type = ARKODE_LSRK_POWER_ITERATION; + step_mem->DDE_ID = SUNDSOMEIGESTIMATOR_POWER; /* Create internal dominant eigenvalue estimator -- PI */ if (step_mem->DEE == NULL) { step_mem->DEE = lsrkStep_DomEigCreate(arkode_mem); } } - else if (dom_eig_type == ARKODE_LSRK_ARNOLDI_ITERATION) + else if (DEE_id == SUNDSOMEIGESTIMATOR_ARNOLDI) { #ifdef SUNDIALS_BLAS_LAPACK_ENABLED - step_mem->internal_domeigest_type = ARKODE_LSRK_ARNOLDI_ITERATION; + step_mem->DDE_ID = SUNDSOMEIGESTIMATOR_ARNOLDI; /* Create an internal dominant eigenvalue estimator -- ArnI*/ if (step_mem->DEE == NULL) { step_mem->DEE = lsrkStep_DomEigCreate(arkode_mem); } #else - arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, + arkProcessError(ark_mem, ARK_DEE_FAIL, __LINE__, __func__, __FILE__, - "Internal Arnoldi iteration requires LAPACK package"); - return ARK_INTERNAL_DOMEIG_FAIL; + "Sundials Arnoldi DDE requires LAPACK package"); + return ARK_DEE_FAIL; #endif } else { - arkProcessError(ark_mem, ARK_INTERNAL_DOMEIG_FAIL, __LINE__, __func__, - __FILE__, "Attempted to set an internal domeig estimator with an unknown type"); - return ARK_INTERNAL_DOMEIG_FAIL; + arkProcessError(ark_mem, ARK_DEE_FAIL, __LINE__, __func__, + __FILE__, "Attempted to set a DDE with an unknown type"); + return ARK_DEE_FAIL; } return ARK_SUCCESS; } @@ -548,6 +548,35 @@ int LSRKStepGetMaxNumStages(void* arkode_mem, int* stage_max) return ARK_SUCCESS; } +/*--------------------------------------------------------------- + LSRKStepGetNumRHSinDQ: + + Returns the number of RHS evals in DQ Jacobian computations + ---------------------------------------------------------------*/ +SUNDIALS_EXPORT int LSRKStepGetNumRHSinDQ(void* arkode_mem, int* nfeDQ) +{ + ARKodeMem ark_mem; + ARKodeLSRKStepMem step_mem; + int retval; + + /* access ARKodeMem and ARKodeLSRKStepMem structures */ + retval = lsrkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, + &step_mem); + if (retval != ARK_SUCCESS) { return retval; } + + if (nfeDQ == NULL) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "nfeDQ cannot be NULL"); + return ARK_ILL_INPUT; + } + + /* get values from step_mem */ + *nfeDQ = step_mem->nfeDQ; + + return ARK_SUCCESS; +} + /*=============================================================== Private functions attached to ARKODE ===============================================================*/ @@ -580,8 +609,8 @@ int lsrkStep_SetDefaults(ARKodeMem ark_mem) step_mem->spectral_radius_min = ZERO; step_mem->dom_eig_safety = DOM_EIG_SAFETY_DEFAULT; step_mem->dom_eig_freq = DOM_EIG_FREQ_DEFAULT; - step_mem->domeig_krydim = DOMEIG_KRYLOV_DIM_DEFAULT; - step_mem->numwarmups = SUNDOMEIGEST_NUM_OF_WARMUPS_DEFAULT; + step_mem->dee_krydim = DEE_KRYLOV_DIM_DEFAULT; + step_mem->dee_numwarmups = DEE_NUM_OF_WARMUPS_DEFAULT; /* Flags */ step_mem->dom_eig_update = SUNTRUE; diff --git a/src/arkode/fmod_int32/farkode_lsrkstep_mod.c b/src/arkode/fmod_int32/farkode_lsrkstep_mod.c index f9c7cdf3eb..ba2f9a5d5e 100644 --- a/src/arkode/fmod_int32/farkode_lsrkstep_mod.c +++ b/src/arkode/fmod_int32/farkode_lsrkstep_mod.c @@ -192,15 +192,15 @@ * the fortran.cxx file. */ #define SWIG_contract_assert(RETURNNULL, EXPR, MSG) \ - if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); } + if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); } -#define SWIGVERSION 0x040000 +#define SWIGVERSION 0x040000 #define SWIG_VERSION SWIGVERSION -#define SWIG_as_voidptr(a) (void *)((const void *)(a)) -#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) +#define SWIG_as_voidptr(a) (void *)((const void *)(a)) +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) #include "arkode/arkode_lsrkstep.h" @@ -237,7 +237,7 @@ SWIGEXPORT void * _wrap_FLSRKStepCreateSTS(ARKRhsFn farg1, double const *farg2, N_Vector arg3 = (N_Vector) 0 ; SUNContext arg4 = (SUNContext) 0 ; void *result = 0 ; - + arg1 = (ARKRhsFn)(farg1); arg2 = (sunrealtype)(*farg2); arg3 = (N_Vector)(farg3); @@ -255,7 +255,7 @@ SWIGEXPORT void * _wrap_FLSRKStepCreateSSP(ARKRhsFn farg1, double const *farg2, N_Vector arg3 = (N_Vector) 0 ; SUNContext arg4 = (SUNContext) 0 ; void *result = 0 ; - + arg1 = (ARKRhsFn)(farg1); arg2 = (sunrealtype)(*farg2); arg3 = (N_Vector)(farg3); @@ -273,7 +273,7 @@ SWIGEXPORT int _wrap_FLSRKStepReInitSTS(void *farg1, ARKRhsFn farg2, double cons sunrealtype arg3 ; N_Vector arg4 = (N_Vector) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (ARKRhsFn)(farg2); arg3 = (sunrealtype)(*farg3); @@ -291,7 +291,7 @@ SWIGEXPORT int _wrap_FLSRKStepReInitSSP(void *farg1, ARKRhsFn farg2, double cons sunrealtype arg3 ; N_Vector arg4 = (N_Vector) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (ARKRhsFn)(farg2); arg3 = (sunrealtype)(*farg3); @@ -307,7 +307,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetSTSMethod(void *farg1, int const *farg2) { void *arg1 = (void *) 0 ; ARKODE_LSRKMethodType arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (ARKODE_LSRKMethodType)(*farg2); result = (int)LSRKStepSetSTSMethod(arg1,arg2); @@ -321,7 +321,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetSSPMethod(void *farg1, int const *farg2) { void *arg1 = (void *) 0 ; ARKODE_LSRKMethodType arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (ARKODE_LSRKMethodType)(*farg2); result = (int)LSRKStepSetSSPMethod(arg1,arg2); @@ -335,7 +335,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetSTSMethodByName(void *farg1, SwigArrayWrapper * void *arg1 = (void *) 0 ; char *arg2 = (char *) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (char *)(farg2->data); result = (int)LSRKStepSetSTSMethodByName(arg1,(char const *)arg2); @@ -349,7 +349,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetSSPMethodByName(void *farg1, SwigArrayWrapper * void *arg1 = (void *) 0 ; char *arg2 = (char *) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (char *)(farg2->data); result = (int)LSRKStepSetSSPMethodByName(arg1,(char const *)arg2); @@ -363,7 +363,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetDomEigFn(void *farg1, ARKDomEigFn farg2) { void *arg1 = (void *) 0 ; ARKDomEigFn arg2 = (ARKDomEigFn) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (ARKDomEigFn)(farg2); result = (int)LSRKStepSetDomEigFn(arg1,arg2); @@ -372,15 +372,15 @@ SWIGEXPORT int _wrap_FLSRKStepSetDomEigFn(void *farg1, ARKDomEigFn farg2) { } -SWIGEXPORT int _wrap_FLSRKStepSetInternalDomEigEstType(void *farg1, int const *farg2) { +SWIGEXPORT int _wrap_FLSRKStepSetDEECreateWithID(void *farg1, int const *farg2) { int fresult ; void *arg1 = (void *) 0 ; - ARKODE_LSRKInternal_DomEigEst_Type arg2 ; + SUNDomEigEstimator_ID arg2 ; int result; - + arg1 = (void *)(farg1); - arg2 = (ARKODE_LSRKInternal_DomEigEst_Type)(*farg2); - result = (int)LSRKStepSetInternalDomEigEstType(arg1,arg2); + arg2 = (SUNDomEigEstimator_ID)(*farg2); + result = (int)LSRKStepSetDEECreateWithID(arg1,arg2); fresult = (int)(result); return fresult; } @@ -391,7 +391,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetDomEigFrequency(void *farg1, long const *farg2) void *arg1 = (void *) 0 ; long arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (long)(*farg2); result = (int)LSRKStepSetDomEigFrequency(arg1,arg2); @@ -405,7 +405,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetMaxNumStages(void *farg1, int const *farg2) { void *arg1 = (void *) 0 ; int arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (int)(*farg2); result = (int)LSRKStepSetMaxNumStages(arg1,arg2); @@ -419,7 +419,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetDomEigSafetyFactor(void *farg1, double const *f void *arg1 = (void *) 0 ; sunrealtype arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (sunrealtype)(*farg2); result = (int)LSRKStepSetDomEigSafetyFactor(arg1,arg2); @@ -433,7 +433,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetNumSSPStages(void *farg1, int const *farg2) { void *arg1 = (void *) 0 ; int arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (int)(*farg2); result = (int)LSRKStepSetNumSSPStages(arg1,arg2); @@ -447,7 +447,7 @@ SWIGEXPORT int _wrap_FLSRKStepGetNumDomEigUpdates(void *farg1, long *farg2) { void *arg1 = (void *) 0 ; long *arg2 = (long *) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (long *)(farg2); result = (int)LSRKStepGetNumDomEigUpdates(arg1,arg2); @@ -461,7 +461,7 @@ SWIGEXPORT int _wrap_FLSRKStepGetMaxNumStages(void *farg1, int *farg2) { void *arg1 = (void *) 0 ; int *arg2 = (int *) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (int *)(farg2); result = (int)LSRKStepGetMaxNumStages(arg1,arg2); diff --git a/src/arkode/fmod_int32/farkode_lsrkstep_mod.f90 b/src/arkode/fmod_int32/farkode_lsrkstep_mod.f90 index 6781a3e5bd..a9f10a03bf 100644 --- a/src/arkode/fmod_int32/farkode_lsrkstep_mod.f90 +++ b/src/arkode/fmod_int32/farkode_lsrkstep_mod.f90 @@ -36,13 +36,13 @@ module farkode_lsrkstep_mod end enum integer, parameter, public :: ARKODE_LSRKMethodType = kind(ARKODE_LSRK_RKC_2) public :: ARKODE_LSRK_RKC_2, ARKODE_LSRK_RKL_2, ARKODE_LSRK_SSP_S_2, ARKODE_LSRK_SSP_S_3, ARKODE_LSRK_SSP_10_4 - ! typedef enum ARKODE_LSRKInternal_DomEigEst_Type + ! typedef enum SUNDomEigEstimator_ID enum, bind(c) - enumerator :: ARKODE_LSRK_POWER_ITERATION - enumerator :: ARKODE_LSRK_ARNOLDI_ITERATION + enumerator :: SUNDSOMEIGESTIMATOR_POWER + enumerator :: SUNDSOMEIGESTIMATOR_ARNOLDI end enum - integer, parameter, public :: ARKODE_LSRKInternal_DomEigEst_Type = kind(ARKODE_LSRK_POWER_ITERATION) - public :: ARKODE_LSRK_POWER_ITERATION, ARKODE_LSRK_ARNOLDI_ITERATION + integer, parameter, public :: SUNDomEigEstimator_ID = kind(SUNDSOMEIGESTIMATOR_POWER) + public :: SUNDSOMEIGESTIMATOR_POWER, SUNDSOMEIGESTIMATOR_ARNOLDI public :: FLSRKStepCreateSTS public :: FLSRKStepCreateSSP public :: FLSRKStepReInitSTS @@ -56,7 +56,7 @@ module farkode_lsrkstep_mod public :: FLSRKStepSetSTSMethodByName public :: FLSRKStepSetSSPMethodByName public :: FLSRKStepSetDomEigFn - public :: FLSRKStepSetInternalDomEigEstType + public :: FLSRKStepSetDEECreateWithID public :: FLSRKStepSetDomEigFrequency public :: FLSRKStepSetMaxNumStages public :: FLSRKStepSetDomEigSafetyFactor @@ -157,8 +157,8 @@ function swigc_FLSRKStepSetDomEigFn(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FLSRKStepSetInternalDomEigEstType(farg1, farg2) & -bind(C, name="_wrap_FLSRKStepSetInternalDomEigEstType") & +function swigc_FLSRKStepSetDEECreateWithID(farg1, farg2) & +bind(C, name="_wrap_FLSRKStepSetDEECreateWithID") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 @@ -233,11 +233,11 @@ function FLSRKStepCreateSTS(rhs, t0, y0, sunctx) & real(C_DOUBLE), intent(in) :: t0 type(N_Vector), target, intent(inout) :: y0 type(C_PTR) :: sunctx -type(C_PTR) :: fresult -type(C_FUNPTR) :: farg1 -real(C_DOUBLE) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 +type(C_PTR) :: fresult +type(C_FUNPTR) :: farg1 +real(C_DOUBLE) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 farg1 = rhs farg2 = t0 @@ -255,11 +255,11 @@ function FLSRKStepCreateSSP(rhs, t0, y0, sunctx) & real(C_DOUBLE), intent(in) :: t0 type(N_Vector), target, intent(inout) :: y0 type(C_PTR) :: sunctx -type(C_PTR) :: fresult -type(C_FUNPTR) :: farg1 -real(C_DOUBLE) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 +type(C_PTR) :: fresult +type(C_FUNPTR) :: farg1 +real(C_DOUBLE) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 farg1 = rhs farg2 = t0 @@ -277,11 +277,11 @@ function FLSRKStepReInitSTS(arkode_mem, rhs, t0, y0) & type(C_FUNPTR), intent(in), value :: rhs real(C_DOUBLE), intent(in) :: t0 type(N_Vector), target, intent(inout) :: y0 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -real(C_DOUBLE) :: farg3 -type(C_PTR) :: farg4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +real(C_DOUBLE) :: farg3 +type(C_PTR) :: farg4 farg1 = arkode_mem farg2 = rhs @@ -299,11 +299,11 @@ function FLSRKStepReInitSSP(arkode_mem, rhs, t0, y0) & type(C_FUNPTR), intent(in), value :: rhs real(C_DOUBLE), intent(in) :: t0 type(N_Vector), target, intent(inout) :: y0 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -real(C_DOUBLE) :: farg3 -type(C_PTR) :: farg4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +real(C_DOUBLE) :: farg3 +type(C_PTR) :: farg4 farg1 = arkode_mem farg2 = rhs @@ -319,9 +319,9 @@ function FLSRKStepSetSTSMethod(arkode_mem, method) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(ARKODE_LSRKMethodType), intent(in) :: method -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = method @@ -335,9 +335,9 @@ function FLSRKStepSetSSPMethod(arkode_mem, method) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(ARKODE_LSRKMethodType), intent(in) :: method -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = method @@ -370,9 +370,9 @@ function FLSRKStepSetSTSMethodByName(arkode_mem, emethod) & type(C_PTR) :: arkode_mem character(kind=C_CHAR, len=*), target :: emethod character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 farg1 = arkode_mem call SWIG_string_to_chararray(emethod, farg2_chars, farg2) @@ -387,9 +387,9 @@ function FLSRKStepSetSSPMethodByName(arkode_mem, emethod) & type(C_PTR) :: arkode_mem character(kind=C_CHAR, len=*), target :: emethod character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 farg1 = arkode_mem call SWIG_string_to_chararray(emethod, farg2_chars, farg2) @@ -403,9 +403,9 @@ function FLSRKStepSetDomEigFn(arkode_mem, dom_eig) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: dom_eig -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = dom_eig @@ -413,19 +413,19 @@ function FLSRKStepSetDomEigFn(arkode_mem, dom_eig) & swig_result = fresult end function -function FLSRKStepSetInternalDomEigEstType(arkode_mem, dom_eig_type) & +function FLSRKStepSetDEECreateWithID(arkode_mem, DEE_id) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -integer(ARKODE_LSRKInternal_DomEigEst_Type), intent(in) :: dom_eig_type -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(SUNDomEigEstimator_ID), intent(in) :: DEE_id +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem -farg2 = dom_eig_type -fresult = swigc_FLSRKStepSetInternalDomEigEstType(farg1, farg2) +farg2 = DEE_id +fresult = swigc_FLSRKStepSetDEECreateWithID(farg1, farg2) swig_result = fresult end function @@ -435,9 +435,9 @@ function FLSRKStepSetDomEigFrequency(arkode_mem, nsteps) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), intent(in) :: nsteps -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_LONG) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_LONG) :: farg2 farg1 = arkode_mem farg2 = nsteps @@ -451,9 +451,9 @@ function FLSRKStepSetMaxNumStages(arkode_mem, stage_max_limit) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: stage_max_limit -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = stage_max_limit @@ -467,9 +467,9 @@ function FLSRKStepSetDomEigSafetyFactor(arkode_mem, dom_eig_safety) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: dom_eig_safety -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = dom_eig_safety @@ -483,9 +483,9 @@ function FLSRKStepSetNumSSPStages(arkode_mem, num_of_stages) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: num_of_stages -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = num_of_stages @@ -499,9 +499,9 @@ function FLSRKStepGetNumDomEigUpdates(arkode_mem, dom_eig_num_evals) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: dom_eig_num_evals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(dom_eig_num_evals(1)) @@ -515,9 +515,9 @@ function FLSRKStepGetMaxNumStages(arkode_mem, stage_max) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), dimension(*), target, intent(inout) :: stage_max -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(stage_max(1)) diff --git a/src/arkode/fmod_int32/farkode_mod.f90 b/src/arkode/fmod_int32/farkode_mod.f90 index 64806e3695..5ab1cc1363 100644 --- a/src/arkode/fmod_int32/farkode_mod.f90 +++ b/src/arkode/fmod_int32/farkode_mod.f90 @@ -101,7 +101,7 @@ module farkode_mod integer(C_INT), parameter, public :: ARK_ADJ_CHECKPOINT_FAIL = -53_C_INT integer(C_INT), parameter, public :: ARK_ADJ_RECOMPUTE_FAIL = -54_C_INT integer(C_INT), parameter, public :: ARK_SUNADJSTEPPER_ERR = -55_C_INT - integer(C_INT), parameter, public :: ARK_INTERNAL_DOMEIG_FAIL = -56_C_INT + integer(C_INT), parameter, public :: ARK_DEE_FAIL = -56_C_INT integer(C_INT), parameter, public :: ARK_UNRECOGNIZED_ERROR = -99_C_INT ! typedef enum ARKRelaxSolver enum, bind(c) @@ -2520,13 +2520,13 @@ function FARKodeResize(arkode_mem, ynew, hscale, t0, resize, resize_data) & real(C_DOUBLE), intent(in) :: t0 type(C_FUNPTR), intent(in), value :: resize type(C_PTR) :: resize_data -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -real(C_DOUBLE) :: farg3 -real(C_DOUBLE) :: farg4 -type(C_FUNPTR) :: farg5 -type(C_PTR) :: farg6 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +real(C_DOUBLE) :: farg3 +real(C_DOUBLE) :: farg4 +type(C_FUNPTR) :: farg5 +type(C_PTR) :: farg6 farg1 = arkode_mem farg2 = c_loc(ynew) @@ -2545,10 +2545,10 @@ function FARKodeReset(arkode_mem, tr, yr) & type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: tr type(N_Vector), target, intent(inout) :: yr -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = tr @@ -2563,9 +2563,9 @@ function FARKodeCreateMRIStepInnerStepper(arkode_mem, stepper) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_PTR), target, intent(inout) :: stepper -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(stepper) @@ -2580,10 +2580,10 @@ function FARKodeSStolerances(arkode_mem, reltol, abstol) & type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: reltol real(C_DOUBLE), intent(in) :: abstol -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 farg1 = arkode_mem farg2 = reltol @@ -2599,10 +2599,10 @@ function FARKodeSVtolerances(arkode_mem, reltol, abstol) & type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: reltol type(N_Vector), target, intent(inout) :: abstol -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = reltol @@ -2617,9 +2617,9 @@ function FARKodeWFtolerances(arkode_mem, efun) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: efun -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = efun @@ -2633,9 +2633,9 @@ function FARKodeResStolerance(arkode_mem, rabstol) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: rabstol -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = rabstol @@ -2649,9 +2649,9 @@ function FARKodeResVtolerance(arkode_mem, rabstol) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(N_Vector), target, intent(inout) :: rabstol -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(rabstol) @@ -2665,9 +2665,9 @@ function FARKodeResFtolerance(arkode_mem, rfun) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: rfun -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = rfun @@ -2682,10 +2682,10 @@ function FARKodeRootInit(arkode_mem, nrtfn, g) & type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: nrtfn type(C_FUNPTR), intent(in), value :: g -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 -type(C_FUNPTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 +type(C_FUNPTR) :: farg3 farg1 = arkode_mem farg2 = nrtfn @@ -2700,9 +2700,9 @@ function FARKodeSetRootDirection(arkode_mem, rootdir) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), dimension(*), target, intent(inout) :: rootdir -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(rootdir(1)) @@ -2715,8 +2715,8 @@ function FARKodeSetNoInactiveRootWarn(arkode_mem) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -integer(C_INT) :: fresult -type(C_PTR) :: farg1 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 farg1 = arkode_mem fresult = swigc_FARKodeSetNoInactiveRootWarn(farg1) @@ -2728,8 +2728,8 @@ function FARKodeSetDefaults(arkode_mem) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -integer(C_INT) :: fresult -type(C_PTR) :: farg1 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 farg1 = arkode_mem fresult = swigc_FARKodeSetDefaults(farg1) @@ -2742,9 +2742,9 @@ function FARKodeSetOrder(arkode_mem, maxord) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: maxord -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = maxord @@ -2758,9 +2758,9 @@ function FARKodeSetInterpolantType(arkode_mem, itype) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: itype -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = itype @@ -2774,9 +2774,9 @@ function FARKodeSetInterpolantDegree(arkode_mem, degree) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: degree -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = degree @@ -2790,9 +2790,9 @@ function FARKodeSetMaxNumSteps(arkode_mem, mxsteps) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), intent(in) :: mxsteps -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_LONG) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_LONG) :: farg2 farg1 = arkode_mem farg2 = mxsteps @@ -2806,9 +2806,9 @@ function FARKodeSetInterpolateStopTime(arkode_mem, interp) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: interp -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = interp @@ -2822,9 +2822,9 @@ function FARKodeSetStopTime(arkode_mem, tstop) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: tstop -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = tstop @@ -2837,8 +2837,8 @@ function FARKodeClearStopTime(arkode_mem) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -integer(C_INT) :: fresult -type(C_PTR) :: farg1 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 farg1 = arkode_mem fresult = swigc_FARKodeClearStopTime(farg1) @@ -2851,9 +2851,9 @@ function FARKodeSetFixedStep(arkode_mem, hfixed) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: hfixed -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = hfixed @@ -2867,9 +2867,9 @@ function FARKodeSetStepDirection(arkode_mem, stepdir) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: stepdir -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = stepdir @@ -2883,9 +2883,9 @@ function FARKodeSetUserData(arkode_mem, user_data) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_PTR) :: user_data -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = user_data @@ -2899,9 +2899,9 @@ function FARKodeSetPostprocessStepFn(arkode_mem, processstep) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: processstep -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = processstep @@ -2915,9 +2915,9 @@ function FARKodeSetPostprocessStageFn(arkode_mem, processstage) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: processstage -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = processstage @@ -2931,9 +2931,9 @@ function FARKodeSetNonlinearSolver(arkode_mem, nls) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(SUNNonlinearSolver), target, intent(inout) :: nls -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nls) @@ -2947,9 +2947,9 @@ function FARKodeSetLinear(arkode_mem, timedepend) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: timedepend -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = timedepend @@ -2962,8 +2962,8 @@ function FARKodeSetNonlinear(arkode_mem) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -integer(C_INT) :: fresult -type(C_PTR) :: farg1 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 farg1 = arkode_mem fresult = swigc_FARKodeSetNonlinear(farg1) @@ -2976,9 +2976,9 @@ function FARKodeSetAutonomous(arkode_mem, autonomous) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: autonomous -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = autonomous @@ -2992,9 +2992,9 @@ function FARKodeSetNlsRhsFn(arkode_mem, nls_fi) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: nls_fi -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = nls_fi @@ -3008,9 +3008,9 @@ function FARKodeSetDeduceImplicitRhs(arkode_mem, deduce) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: deduce -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = deduce @@ -3024,9 +3024,9 @@ function FARKodeSetNonlinCRDown(arkode_mem, crdown) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: crdown -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = crdown @@ -3040,9 +3040,9 @@ function FARKodeSetNonlinRDiv(arkode_mem, rdiv) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: rdiv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = rdiv @@ -3056,9 +3056,9 @@ function FARKodeSetDeltaGammaMax(arkode_mem, dgmax) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: dgmax -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = dgmax @@ -3072,9 +3072,9 @@ function FARKodeSetLSetupFrequency(arkode_mem, msbp) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: msbp -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = msbp @@ -3088,9 +3088,9 @@ function FARKodeSetPredictorMethod(arkode_mem, method) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: method -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = method @@ -3104,9 +3104,9 @@ function FARKodeSetMaxNonlinIters(arkode_mem, maxcor) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: maxcor -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = maxcor @@ -3120,9 +3120,9 @@ function FARKodeSetMaxConvFails(arkode_mem, maxncf) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: maxncf -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = maxncf @@ -3136,9 +3136,9 @@ function FARKodeSetNonlinConvCoef(arkode_mem, nlscoef) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: nlscoef -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = nlscoef @@ -3152,9 +3152,9 @@ function FARKodeSetStagePredictFn(arkode_mem, predictstage) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: predictstage -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = predictstage @@ -3168,9 +3168,9 @@ function FARKodeSetAdaptController(arkode_mem, c) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(SUNAdaptController), target, intent(inout) :: c -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(c) @@ -3203,9 +3203,9 @@ function FARKodeSetAdaptControllerByName(arkode_mem, cname) & type(C_PTR) :: arkode_mem character(kind=C_CHAR, len=*), target :: cname character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 farg1 = arkode_mem call SWIG_string_to_chararray(cname, farg2_chars, farg2) @@ -3219,9 +3219,9 @@ function FARKodeSetAdaptivityAdjustment(arkode_mem, adjust) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: adjust -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = adjust @@ -3235,9 +3235,9 @@ function FARKodeSetCFLFraction(arkode_mem, cfl_frac) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: cfl_frac -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = cfl_frac @@ -3251,9 +3251,9 @@ function FARKodeSetErrorBias(arkode_mem, bias) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: bias -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = bias @@ -3267,9 +3267,9 @@ function FARKodeSetSafetyFactor(arkode_mem, safety) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: safety -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = safety @@ -3283,9 +3283,9 @@ function FARKodeSetMaxGrowth(arkode_mem, mx_growth) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: mx_growth -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = mx_growth @@ -3299,9 +3299,9 @@ function FARKodeSetMinReduction(arkode_mem, eta_min) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: eta_min -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = eta_min @@ -3316,10 +3316,10 @@ function FARKodeSetFixedStepBounds(arkode_mem, lb, ub) & type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: lb real(C_DOUBLE), intent(in) :: ub -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 farg1 = arkode_mem farg2 = lb @@ -3334,9 +3334,9 @@ function FARKodeSetMaxFirstGrowth(arkode_mem, etamx1) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: etamx1 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = etamx1 @@ -3350,9 +3350,9 @@ function FARKodeSetMaxEFailGrowth(arkode_mem, etamxf) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: etamxf -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = etamxf @@ -3366,9 +3366,9 @@ function FARKodeSetSmallNumEFails(arkode_mem, small_nef) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: small_nef -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = small_nef @@ -3382,9 +3382,9 @@ function FARKodeSetMaxCFailGrowth(arkode_mem, etacf) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: etacf -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = etacf @@ -3399,10 +3399,10 @@ function FARKodeSetStabilityFn(arkode_mem, estab, estab_data) & type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: estab type(C_PTR) :: estab_data -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = estab @@ -3417,9 +3417,9 @@ function FARKodeSetMaxErrTestFails(arkode_mem, maxnef) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: maxnef -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = maxnef @@ -3433,9 +3433,9 @@ function FARKodeSetConstraints(arkode_mem, constraints) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(N_Vector), target, intent(inout) :: constraints -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(constraints) @@ -3449,9 +3449,9 @@ function FARKodeSetMaxHnilWarns(arkode_mem, mxhnil) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: mxhnil -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = mxhnil @@ -3465,9 +3465,9 @@ function FARKodeSetInitStep(arkode_mem, hin) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: hin -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = hin @@ -3481,9 +3481,9 @@ function FARKodeSetMinStep(arkode_mem, hmin) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: hmin -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = hmin @@ -3497,9 +3497,9 @@ function FARKodeSetMaxStep(arkode_mem, hmax) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: hmax -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = hmax @@ -3513,9 +3513,9 @@ function FARKodeSetMaxNumConstrFails(arkode_mem, maxfails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: maxfails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = maxfails @@ -3529,9 +3529,9 @@ function FARKodeSetAdjointCheckpointScheme(arkode_mem, checkpoint_scheme) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_PTR) :: checkpoint_scheme -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = checkpoint_scheme @@ -3545,9 +3545,9 @@ function FARKodeSetAdjointCheckpointIndex(arkode_mem, step_index) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), intent(in) :: step_index -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_LONG) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_LONG) :: farg2 farg1 = arkode_mem farg2 = step_index @@ -3561,9 +3561,9 @@ function FARKodeSetUseCompensatedSums(arkode_mem, onoff) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: onoff -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = onoff @@ -3577,9 +3577,9 @@ function FARKodeSetAccumulatedErrorType(arkode_mem, accum_type) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(ARKAccumError), intent(in) :: accum_type -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = accum_type @@ -3592,8 +3592,8 @@ function FARKodeResetAccumulatedError(arkode_mem) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -integer(C_INT) :: fresult -type(C_PTR) :: farg1 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 farg1 = arkode_mem fresult = swigc_FARKodeResetAccumulatedError(farg1) @@ -3609,12 +3609,12 @@ function FARKodeEvolve(arkode_mem, tout, yout, tret, itask) & type(N_Vector), target, intent(inout) :: yout real(C_DOUBLE), dimension(*), target, intent(inout) :: tret integer(C_INT), intent(in) :: itask -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 -integer(C_INT) :: farg5 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 +integer(C_INT) :: farg5 farg1 = arkode_mem farg2 = tout @@ -3633,11 +3633,11 @@ function FARKodeGetDky(arkode_mem, t, k, dky) & real(C_DOUBLE), intent(in) :: t integer(C_INT), intent(in) :: k type(N_Vector), target, intent(inout) :: dky -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -integer(C_INT) :: farg3 -type(C_PTR) :: farg4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +integer(C_INT) :: farg3 +type(C_PTR) :: farg4 farg1 = arkode_mem farg2 = t @@ -3654,10 +3654,10 @@ function FARKodeComputeState(arkode_mem, zcor, z) & type(C_PTR) :: arkode_mem type(N_Vector), target, intent(inout) :: zcor type(N_Vector), target, intent(inout) :: z -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = c_loc(zcor) @@ -3673,10 +3673,10 @@ function FARKodeGetNumRhsEvals(arkode_mem, partition_index, num_rhs_evals) & type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: partition_index integer(C_LONG), dimension(*), target, intent(inout) :: num_rhs_evals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = partition_index @@ -3691,9 +3691,9 @@ function FARKodeGetNumStepAttempts(arkode_mem, step_attempts) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: step_attempts -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(step_attempts(1)) @@ -3708,10 +3708,10 @@ function FARKodeGetWorkSpace(arkode_mem, lenrw, leniw) & type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: lenrw integer(C_LONG), dimension(*), target, intent(inout) :: leniw -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = c_loc(lenrw(1)) @@ -3726,9 +3726,9 @@ function FARKodeGetNumSteps(arkode_mem, nsteps) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nsteps -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nsteps(1)) @@ -3742,9 +3742,9 @@ function FARKodeGetLastStep(arkode_mem, hlast) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), dimension(*), target, intent(inout) :: hlast -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(hlast(1)) @@ -3758,9 +3758,9 @@ function FARKodeGetCurrentStep(arkode_mem, hcur) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), dimension(*), target, intent(inout) :: hcur -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(hcur(1)) @@ -3774,9 +3774,9 @@ function FARKodeGetStepDirection(arkode_mem, stepdir) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), dimension(*), target, intent(inout) :: stepdir -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(stepdir(1)) @@ -3790,9 +3790,9 @@ function FARKodeGetErrWeights(arkode_mem, eweight) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(N_Vector), target, intent(inout) :: eweight -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(eweight) @@ -3806,9 +3806,9 @@ function FARKodeGetNumGEvals(arkode_mem, ngevals) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: ngevals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(ngevals(1)) @@ -3822,9 +3822,9 @@ function FARKodeGetRootInfo(arkode_mem, rootsfound) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), dimension(*), target, intent(inout) :: rootsfound -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(rootsfound(1)) @@ -3838,9 +3838,9 @@ function FARKodeGetUserData(arkode_mem, user_data) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_PTR), target, intent(inout) :: user_data -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(user_data) @@ -3855,10 +3855,10 @@ function FARKodePrintAllStats(arkode_mem, outfile, fmt) & type(C_PTR) :: arkode_mem type(C_PTR) :: outfile integer(SUNOutputFormat), intent(in) :: fmt -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -integer(C_INT) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +integer(C_INT) :: farg3 farg1 = arkode_mem farg2 = outfile @@ -3886,8 +3886,8 @@ function FARKodeGetReturnFlagName(flag) & use, intrinsic :: ISO_C_BINDING character(kind=C_CHAR, len=:), allocatable :: swig_result integer(C_LONG), intent(in) :: flag -type(SwigArrayWrapper) :: fresult -integer(C_LONG) :: farg1 +type(SwigArrayWrapper) :: fresult +integer(C_LONG) :: farg1 farg1 = flag fresult = swigc_FARKodeGetReturnFlagName(farg1) @@ -3901,9 +3901,9 @@ function FARKodeWriteParameters(arkode_mem, fp) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_PTR) :: fp -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = fp @@ -3917,9 +3917,9 @@ function FARKodeGetNumExpSteps(arkode_mem, expsteps) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: expsteps -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(expsteps(1)) @@ -3933,9 +3933,9 @@ function FARKodeGetNumAccSteps(arkode_mem, accsteps) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: accsteps -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(accsteps(1)) @@ -3949,9 +3949,9 @@ function FARKodeGetNumErrTestFails(arkode_mem, netfails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: netfails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(netfails(1)) @@ -3965,9 +3965,9 @@ function FARKodeGetEstLocalErrors(arkode_mem, ele) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(N_Vector), target, intent(inout) :: ele -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(ele) @@ -3981,9 +3981,9 @@ function FARKodeGetActualInitStep(arkode_mem, hinused) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), dimension(*), target, intent(inout) :: hinused -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(hinused(1)) @@ -3997,9 +3997,9 @@ function FARKodeGetTolScaleFactor(arkode_mem, tolsfac) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), dimension(*), target, intent(inout) :: tolsfac -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(tolsfac(1)) @@ -4013,9 +4013,9 @@ function FARKodeGetNumConstrFails(arkode_mem, nconstrfails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nconstrfails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nconstrfails(1)) @@ -4033,13 +4033,13 @@ function FARKodeGetStepStats(arkode_mem, nsteps, hinused, hlast, hcur, tcur) & real(C_DOUBLE), dimension(*), target, intent(inout) :: hlast real(C_DOUBLE), dimension(*), target, intent(inout) :: hcur real(C_DOUBLE), dimension(*), target, intent(inout) :: tcur -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 -type(C_PTR) :: farg5 -type(C_PTR) :: farg6 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 +type(C_PTR) :: farg5 +type(C_PTR) :: farg6 farg1 = arkode_mem farg2 = c_loc(nsteps(1)) @@ -4057,9 +4057,9 @@ function FARKodeGetAccumulatedError(arkode_mem, accum_error) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), dimension(*), target, intent(inout) :: accum_error -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(accum_error(1)) @@ -4073,9 +4073,9 @@ function FARKodeGetNumLinSolvSetups(arkode_mem, nlinsetups) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nlinsetups -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nlinsetups(1)) @@ -4089,9 +4089,9 @@ function FARKodeGetCurrentTime(arkode_mem, tcur) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), dimension(*), target, intent(inout) :: tcur -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(tcur(1)) @@ -4105,9 +4105,9 @@ function FARKodeGetCurrentState(arkode_mem, state) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_PTR) :: state -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = state @@ -4121,9 +4121,9 @@ function FARKodeGetCurrentGamma(arkode_mem, gamma) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), dimension(*), target, intent(inout) :: gamma -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(gamma(1)) @@ -4143,15 +4143,15 @@ function FARKodeGetNonlinearSystemData(arkode_mem, tcur, zpred, z, fi, gamma, sd real(C_DOUBLE), dimension(*), target, intent(inout) :: gamma type(C_PTR) :: sdata type(C_PTR), target, intent(inout) :: user_data -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 -type(C_PTR) :: farg5 -type(C_PTR) :: farg6 -type(C_PTR) :: farg7 -type(C_PTR) :: farg8 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 +type(C_PTR) :: farg5 +type(C_PTR) :: farg6 +type(C_PTR) :: farg7 +type(C_PTR) :: farg8 farg1 = arkode_mem farg2 = c_loc(tcur(1)) @@ -4171,9 +4171,9 @@ function FARKodeGetNumNonlinSolvIters(arkode_mem, nniters) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nniters -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nniters(1)) @@ -4187,9 +4187,9 @@ function FARKodeGetNumNonlinSolvConvFails(arkode_mem, nnfails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nnfails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nnfails(1)) @@ -4204,10 +4204,10 @@ function FARKodeGetNonlinSolvStats(arkode_mem, nniters, nnfails) & type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nniters integer(C_LONG), dimension(*), target, intent(inout) :: nnfails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = c_loc(nniters(1)) @@ -4222,9 +4222,9 @@ function FARKodeGetNumStepSolveFails(arkode_mem, nncfails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nncfails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nncfails(1)) @@ -4238,9 +4238,9 @@ function FARKodeGetJac(arkode_mem, j) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_PTR), target, intent(inout) :: j -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(j) @@ -4254,9 +4254,9 @@ function FARKodeGetJacTime(arkode_mem, t_j) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), dimension(*), target, intent(inout) :: t_j -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(t_j(1)) @@ -4270,9 +4270,9 @@ function FARKodeGetJacNumSteps(arkode_mem, nst_j) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nst_j -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nst_j(1)) @@ -4287,10 +4287,10 @@ function FARKodeGetLinWorkSpace(arkode_mem, lenrwls, leniwls) & type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: lenrwls integer(C_LONG), dimension(*), target, intent(inout) :: leniwls -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = c_loc(lenrwls(1)) @@ -4305,9 +4305,9 @@ function FARKodeGetNumJacEvals(arkode_mem, njevals) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: njevals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(njevals(1)) @@ -4321,9 +4321,9 @@ function FARKodeGetNumPrecEvals(arkode_mem, npevals) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: npevals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(npevals(1)) @@ -4337,9 +4337,9 @@ function FARKodeGetNumPrecSolves(arkode_mem, npsolves) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: npsolves -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(npsolves(1)) @@ -4353,9 +4353,9 @@ function FARKodeGetNumLinIters(arkode_mem, nliters) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nliters -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nliters(1)) @@ -4369,9 +4369,9 @@ function FARKodeGetNumLinConvFails(arkode_mem, nlcfails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nlcfails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nlcfails(1)) @@ -4385,9 +4385,9 @@ function FARKodeGetNumJTSetupEvals(arkode_mem, njtsetups) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: njtsetups -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(njtsetups(1)) @@ -4401,9 +4401,9 @@ function FARKodeGetNumJtimesEvals(arkode_mem, njvevals) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: njvevals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(njvevals(1)) @@ -4417,9 +4417,9 @@ function FARKodeGetNumLinRhsEvals(arkode_mem, nfevalsls) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nfevalsls -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nfevalsls(1)) @@ -4433,9 +4433,9 @@ function FARKodeGetLastLinFlag(arkode_mem, flag) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: flag -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(flag(1)) @@ -4448,8 +4448,8 @@ function FARKodeGetLinReturnFlagName(flag) & use, intrinsic :: ISO_C_BINDING character(kind=C_CHAR, len=:), allocatable :: swig_result integer(C_LONG), intent(in) :: flag -type(SwigArrayWrapper) :: fresult -integer(C_LONG) :: farg1 +type(SwigArrayWrapper) :: fresult +integer(C_LONG) :: farg1 farg1 = flag fresult = swigc_FARKodeGetLinReturnFlagName(farg1) @@ -4463,9 +4463,9 @@ function FARKodeGetCurrentMassMatrix(arkode_mem, m) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_PTR), target, intent(inout) :: m -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(m) @@ -4479,9 +4479,9 @@ function FARKodeGetResWeights(arkode_mem, rweight) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(N_Vector), target, intent(inout) :: rweight -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(rweight) @@ -4496,10 +4496,10 @@ function FARKodeGetMassWorkSpace(arkode_mem, lenrwmls, leniwmls) & type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: lenrwmls integer(C_LONG), dimension(*), target, intent(inout) :: leniwmls -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = c_loc(lenrwmls(1)) @@ -4514,9 +4514,9 @@ function FARKodeGetNumMassSetups(arkode_mem, nmsetups) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nmsetups -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nmsetups(1)) @@ -4530,9 +4530,9 @@ function FARKodeGetNumMassMultSetups(arkode_mem, nmvsetups) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nmvsetups -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nmvsetups(1)) @@ -4546,9 +4546,9 @@ function FARKodeGetNumMassMult(arkode_mem, nmvevals) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nmvevals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nmvevals(1)) @@ -4562,9 +4562,9 @@ function FARKodeGetNumMassSolves(arkode_mem, nmsolves) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nmsolves -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nmsolves(1)) @@ -4578,9 +4578,9 @@ function FARKodeGetNumMassPrecEvals(arkode_mem, nmpevals) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nmpevals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nmpevals(1)) @@ -4594,9 +4594,9 @@ function FARKodeGetNumMassPrecSolves(arkode_mem, nmpsolves) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nmpsolves -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nmpsolves(1)) @@ -4610,9 +4610,9 @@ function FARKodeGetNumMassIters(arkode_mem, nmiters) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nmiters -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nmiters(1)) @@ -4626,9 +4626,9 @@ function FARKodeGetNumMassConvFails(arkode_mem, nmcfails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nmcfails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nmcfails(1)) @@ -4642,9 +4642,9 @@ function FARKodeGetNumMTSetups(arkode_mem, nmtsetups) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nmtsetups -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nmtsetups(1)) @@ -4658,9 +4658,9 @@ function FARKodeGetLastMassFlag(arkode_mem, flag) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: flag -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(flag(1)) @@ -4671,7 +4671,7 @@ function FARKodeGetLastMassFlag(arkode_mem, flag) & subroutine FARKodeFree(arkode_mem) use, intrinsic :: ISO_C_BINDING type(C_PTR), target, intent(inout) :: arkode_mem -type(C_PTR) :: farg1 +type(C_PTR) :: farg1 farg1 = c_loc(arkode_mem) call swigc_FARKodeFree(farg1) @@ -4681,8 +4681,8 @@ subroutine FARKodePrintMem(arkode_mem, outfile) use, intrinsic :: ISO_C_BINDING type(C_PTR) :: arkode_mem type(C_PTR) :: outfile -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = outfile @@ -4696,10 +4696,10 @@ function FARKodeSetRelaxFn(arkode_mem, rfn, rjac) & type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: rfn type(C_FUNPTR), intent(in), value :: rjac -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -type(C_FUNPTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +type(C_FUNPTR) :: farg3 farg1 = arkode_mem farg2 = rfn @@ -4714,9 +4714,9 @@ function FARKodeSetRelaxEtaFail(arkode_mem, eta_rf) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: eta_rf -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = eta_rf @@ -4730,9 +4730,9 @@ function FARKodeSetRelaxLowerBound(arkode_mem, lower) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: lower -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = lower @@ -4746,9 +4746,9 @@ function FARKodeSetRelaxMaxFails(arkode_mem, max_fails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: max_fails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = max_fails @@ -4762,9 +4762,9 @@ function FARKodeSetRelaxMaxIters(arkode_mem, max_iters) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: max_iters -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = max_iters @@ -4778,9 +4778,9 @@ function FARKodeSetRelaxSolver(arkode_mem, solver) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(ARKRelaxSolver), intent(in) :: solver -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = solver @@ -4794,9 +4794,9 @@ function FARKodeSetRelaxResTol(arkode_mem, res_tol) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: res_tol -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = res_tol @@ -4811,10 +4811,10 @@ function FARKodeSetRelaxTol(arkode_mem, rel_tol, abs_tol) & type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: rel_tol real(C_DOUBLE), intent(in) :: abs_tol -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 farg1 = arkode_mem farg2 = rel_tol @@ -4829,9 +4829,9 @@ function FARKodeSetRelaxUpperBound(arkode_mem, upper) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: upper -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = upper @@ -4845,9 +4845,9 @@ function FARKodeGetNumRelaxFnEvals(arkode_mem, r_evals) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: r_evals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(r_evals(1)) @@ -4861,9 +4861,9 @@ function FARKodeGetNumRelaxJacEvals(arkode_mem, j_evals) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: j_evals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(j_evals(1)) @@ -4877,9 +4877,9 @@ function FARKodeGetNumRelaxFails(arkode_mem, relax_fails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: relax_fails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(relax_fails(1)) @@ -4893,9 +4893,9 @@ function FARKodeGetNumRelaxBoundFails(arkode_mem, fails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: fails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(fails(1)) @@ -4909,9 +4909,9 @@ function FARKodeGetNumRelaxSolveFails(arkode_mem, fails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: fails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(fails(1)) @@ -4925,9 +4925,9 @@ function FARKodeGetNumRelaxSolveIters(arkode_mem, iters) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: iters -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(iters(1)) @@ -4941,9 +4941,9 @@ function FARKodeCreateSUNStepper(arkode_mem, stepper) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_PTR), target, intent(inout) :: stepper -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(stepper) @@ -4959,11 +4959,11 @@ function FARKBandPrecInit(arkode_mem, n, mu, ml) & integer(C_INT32_T), intent(in) :: n integer(C_INT32_T), intent(in) :: mu integer(C_INT32_T), intent(in) :: ml -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT32_T) :: farg2 -integer(C_INT32_T) :: farg3 -integer(C_INT32_T) :: farg4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT32_T) :: farg2 +integer(C_INT32_T) :: farg3 +integer(C_INT32_T) :: farg4 farg1 = arkode_mem farg2 = n @@ -4980,10 +4980,10 @@ function FARKBandPrecGetWorkSpace(arkode_mem, lenrwls, leniwls) & type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: lenrwls integer(C_LONG), dimension(*), target, intent(inout) :: leniwls -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = c_loc(lenrwls(1)) @@ -4998,9 +4998,9 @@ function FARKBandPrecGetNumRhsEvals(arkode_mem, nfevalsbp) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nfevalsbp -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nfevalsbp(1)) @@ -5021,16 +5021,16 @@ function FARKBBDPrecInit(arkode_mem, nlocal, mudq, mldq, mukeep, mlkeep, dqrely, real(C_DOUBLE), intent(in) :: dqrely type(C_FUNPTR), intent(in), value :: gloc type(C_FUNPTR), intent(in), value :: cfn -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT32_T) :: farg2 -integer(C_INT32_T) :: farg3 -integer(C_INT32_T) :: farg4 -integer(C_INT32_T) :: farg5 -integer(C_INT32_T) :: farg6 -real(C_DOUBLE) :: farg7 -type(C_FUNPTR) :: farg8 -type(C_FUNPTR) :: farg9 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT32_T) :: farg2 +integer(C_INT32_T) :: farg3 +integer(C_INT32_T) :: farg4 +integer(C_INT32_T) :: farg5 +integer(C_INT32_T) :: farg6 +real(C_DOUBLE) :: farg7 +type(C_FUNPTR) :: farg8 +type(C_FUNPTR) :: farg9 farg1 = arkode_mem farg2 = nlocal @@ -5053,11 +5053,11 @@ function FARKBBDPrecReInit(arkode_mem, mudq, mldq, dqrely) & integer(C_INT32_T), intent(in) :: mudq integer(C_INT32_T), intent(in) :: mldq real(C_DOUBLE), intent(in) :: dqrely -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT32_T) :: farg2 -integer(C_INT32_T) :: farg3 -real(C_DOUBLE) :: farg4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT32_T) :: farg2 +integer(C_INT32_T) :: farg3 +real(C_DOUBLE) :: farg4 farg1 = arkode_mem farg2 = mudq @@ -5074,10 +5074,10 @@ function FARKBBDPrecGetWorkSpace(arkode_mem, lenrwbbdp, leniwbbdp) & type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: lenrwbbdp integer(C_LONG), dimension(*), target, intent(inout) :: leniwbbdp -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = c_loc(lenrwbbdp(1)) @@ -5092,9 +5092,9 @@ function FARKBBDPrecGetNumGfnEvals(arkode_mem, ngevalsbbdp) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: ngevalsbbdp -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(ngevalsbbdp(1)) @@ -5106,8 +5106,8 @@ subroutine swigf_ARKodeButcherTableMem_q_set(self, q) use, intrinsic :: ISO_C_BINDING class(ARKodeButcherTableMem), intent(in) :: self integer(C_INT), intent(in) :: q -type(SwigClassWrapper) :: farg1 -integer(C_INT) :: farg2 +type(SwigClassWrapper) :: farg1 +integer(C_INT) :: farg2 farg1 = self%swigdata farg2 = q @@ -5119,8 +5119,8 @@ function swigf_ARKodeButcherTableMem_q_get(self) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result class(ARKodeButcherTableMem), intent(in) :: self -integer(C_INT) :: fresult -type(SwigClassWrapper) :: farg1 +integer(C_INT) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeButcherTableMem_q_get(farg1) @@ -5131,8 +5131,8 @@ subroutine swigf_ARKodeButcherTableMem_p_set(self, p) use, intrinsic :: ISO_C_BINDING class(ARKodeButcherTableMem), intent(in) :: self integer(C_INT), intent(in) :: p -type(SwigClassWrapper) :: farg1 -integer(C_INT) :: farg2 +type(SwigClassWrapper) :: farg1 +integer(C_INT) :: farg2 farg1 = self%swigdata farg2 = p @@ -5144,8 +5144,8 @@ function swigf_ARKodeButcherTableMem_p_get(self) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result class(ARKodeButcherTableMem), intent(in) :: self -integer(C_INT) :: fresult -type(SwigClassWrapper) :: farg1 +integer(C_INT) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeButcherTableMem_p_get(farg1) @@ -5156,8 +5156,8 @@ subroutine swigf_ARKodeButcherTableMem_stages_set(self, stages) use, intrinsic :: ISO_C_BINDING class(ARKodeButcherTableMem), intent(in) :: self integer(C_INT), intent(in) :: stages -type(SwigClassWrapper) :: farg1 -integer(C_INT) :: farg2 +type(SwigClassWrapper) :: farg1 +integer(C_INT) :: farg2 farg1 = self%swigdata farg2 = stages @@ -5169,8 +5169,8 @@ function swigf_ARKodeButcherTableMem_stages_get(self) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result class(ARKodeButcherTableMem), intent(in) :: self -integer(C_INT) :: fresult -type(SwigClassWrapper) :: farg1 +integer(C_INT) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeButcherTableMem_stages_get(farg1) @@ -5181,8 +5181,8 @@ subroutine swigf_ARKodeButcherTableMem_A_set(self, a) use, intrinsic :: ISO_C_BINDING class(ARKodeButcherTableMem), intent(in) :: self type(C_PTR), target, intent(inout) :: a -type(SwigClassWrapper) :: farg1 -type(C_PTR) :: farg2 +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: farg2 farg1 = self%swigdata farg2 = c_loc(a) @@ -5194,8 +5194,8 @@ function swigf_ARKodeButcherTableMem_A_get(self) & use, intrinsic :: ISO_C_BINDING type(C_PTR), pointer :: swig_result class(ARKodeButcherTableMem), intent(in) :: self -type(C_PTR) :: fresult -type(SwigClassWrapper) :: farg1 +type(C_PTR) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeButcherTableMem_A_get(farg1) @@ -5206,8 +5206,8 @@ subroutine swigf_ARKodeButcherTableMem_c_set(self, c) use, intrinsic :: ISO_C_BINDING class(ARKodeButcherTableMem), intent(in) :: self real(C_DOUBLE), dimension(*), target, intent(inout) :: c -type(SwigClassWrapper) :: farg1 -type(C_PTR) :: farg2 +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: farg2 farg1 = self%swigdata farg2 = c_loc(c(1)) @@ -5219,8 +5219,8 @@ function swigf_ARKodeButcherTableMem_c_get(self) & use, intrinsic :: ISO_C_BINDING real(C_DOUBLE), dimension(:), pointer :: swig_result class(ARKodeButcherTableMem), intent(in) :: self -type(C_PTR) :: fresult -type(SwigClassWrapper) :: farg1 +type(C_PTR) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeButcherTableMem_c_get(farg1) @@ -5231,8 +5231,8 @@ subroutine swigf_ARKodeButcherTableMem_b_set(self, b) use, intrinsic :: ISO_C_BINDING class(ARKodeButcherTableMem), intent(in) :: self real(C_DOUBLE), dimension(*), target, intent(inout) :: b -type(SwigClassWrapper) :: farg1 -type(C_PTR) :: farg2 +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: farg2 farg1 = self%swigdata farg2 = c_loc(b(1)) @@ -5244,8 +5244,8 @@ function swigf_ARKodeButcherTableMem_b_get(self) & use, intrinsic :: ISO_C_BINDING real(C_DOUBLE), dimension(:), pointer :: swig_result class(ARKodeButcherTableMem), intent(in) :: self -type(C_PTR) :: fresult -type(SwigClassWrapper) :: farg1 +type(C_PTR) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeButcherTableMem_b_get(farg1) @@ -5256,8 +5256,8 @@ subroutine swigf_ARKodeButcherTableMem_d_set(self, d) use, intrinsic :: ISO_C_BINDING class(ARKodeButcherTableMem), intent(in) :: self real(C_DOUBLE), dimension(*), target, intent(inout) :: d -type(SwigClassWrapper) :: farg1 -type(C_PTR) :: farg2 +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: farg2 farg1 = self%swigdata farg2 = c_loc(d(1)) @@ -5269,8 +5269,8 @@ function swigf_ARKodeButcherTableMem_d_get(self) & use, intrinsic :: ISO_C_BINDING real(C_DOUBLE), dimension(:), pointer :: swig_result class(ARKodeButcherTableMem), intent(in) :: self -type(C_PTR) :: fresult -type(SwigClassWrapper) :: farg1 +type(C_PTR) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeButcherTableMem_d_get(farg1) @@ -5281,7 +5281,7 @@ function swigf_create_ARKodeButcherTableMem() & result(self) use, intrinsic :: ISO_C_BINDING type(ARKodeButcherTableMem) :: self -type(SwigClassWrapper) :: fresult +type(SwigClassWrapper) :: fresult fresult = swigc_new_ARKodeButcherTableMem() self%swigdata = fresult @@ -5290,7 +5290,7 @@ function swigf_create_ARKodeButcherTableMem() & subroutine swigf_release_ARKodeButcherTableMem(self) use, intrinsic :: ISO_C_BINDING class(ARKodeButcherTableMem), intent(inout) :: self -type(SwigClassWrapper) :: farg1 +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata if (btest(farg1%cmemflags, swig_cmem_own_bit)) then @@ -5305,8 +5305,8 @@ subroutine swigf_ARKodeButcherTableMem_op_assign__(self, other) use, intrinsic :: ISO_C_BINDING class(ARKodeButcherTableMem), intent(inout) :: self type(ARKodeButcherTableMem), intent(in) :: other -type(SwigClassWrapper) :: farg1 -type(SwigClassWrapper) :: farg2 +type(SwigClassWrapper) :: farg1 +type(SwigClassWrapper) :: farg2 farg1 = self%swigdata farg2 = other%swigdata @@ -5320,9 +5320,9 @@ function FARKodeButcherTable_Alloc(stages, embedded) & type(C_PTR) :: swig_result integer(C_INT), intent(in) :: stages integer(C_INT), intent(in) :: embedded -type(C_PTR) :: fresult -integer(C_INT) :: farg1 -integer(C_INT) :: farg2 +type(C_PTR) :: fresult +integer(C_INT) :: farg1 +integer(C_INT) :: farg2 farg1 = stages farg2 = embedded @@ -5341,14 +5341,14 @@ function FARKodeButcherTable_Create(s, q, p, c, a, b, d) & real(C_DOUBLE), dimension(*), target, intent(inout) :: a real(C_DOUBLE), dimension(*), target, intent(inout) :: b real(C_DOUBLE), dimension(*), target, intent(inout) :: d -type(C_PTR) :: fresult -integer(C_INT) :: farg1 -integer(C_INT) :: farg2 -integer(C_INT) :: farg3 -type(C_PTR) :: farg4 -type(C_PTR) :: farg5 -type(C_PTR) :: farg6 -type(C_PTR) :: farg7 +type(C_PTR) :: fresult +integer(C_INT) :: farg1 +integer(C_INT) :: farg2 +integer(C_INT) :: farg3 +type(C_PTR) :: farg4 +type(C_PTR) :: farg5 +type(C_PTR) :: farg6 +type(C_PTR) :: farg7 farg1 = s farg2 = q @@ -5366,8 +5366,8 @@ function FARKodeButcherTable_Copy(b) & use, intrinsic :: ISO_C_BINDING type(C_PTR) :: swig_result type(C_PTR) :: b -type(C_PTR) :: fresult -type(C_PTR) :: farg1 +type(C_PTR) :: fresult +type(C_PTR) :: farg1 farg1 = b fresult = swigc_FARKodeButcherTable_Copy(farg1) @@ -5379,9 +5379,9 @@ subroutine FARKodeButcherTable_Space(b, liw, lrw) type(C_PTR) :: b integer(C_INT32_T), dimension(*), target, intent(inout) :: liw integer(C_INT32_T), dimension(*), target, intent(inout) :: lrw -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = b farg2 = c_loc(liw(1)) @@ -5392,7 +5392,7 @@ subroutine FARKodeButcherTable_Space(b, liw, lrw) subroutine FARKodeButcherTable_Free(b) use, intrinsic :: ISO_C_BINDING type(C_PTR) :: b -type(C_PTR) :: farg1 +type(C_PTR) :: farg1 farg1 = b call swigc_FARKodeButcherTable_Free(farg1) @@ -5402,8 +5402,8 @@ subroutine FARKodeButcherTable_Write(b, outfile) use, intrinsic :: ISO_C_BINDING type(C_PTR) :: b type(C_PTR) :: outfile -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = b farg2 = outfile @@ -5415,8 +5415,8 @@ function FARKodeButcherTable_IsStifflyAccurate(b) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: b -integer(C_INT) :: fresult -type(C_PTR) :: farg1 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 farg1 = b fresult = swigc_FARKodeButcherTable_IsStifflyAccurate(farg1) @@ -5431,11 +5431,11 @@ function FARKodeButcherTable_CheckOrder(b, q, p, outfile) & integer(C_INT), dimension(*), target, intent(inout) :: q integer(C_INT), dimension(*), target, intent(inout) :: p type(C_PTR) :: outfile -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 farg1 = b farg2 = c_loc(q(1)) @@ -5454,12 +5454,12 @@ function FARKodeButcherTable_CheckARKOrder(b1, b2, q, p, outfile) & integer(C_INT), dimension(*), target, intent(inout) :: q integer(C_INT), dimension(*), target, intent(inout) :: p type(C_PTR) :: outfile -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 -type(C_PTR) :: farg5 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 +type(C_PTR) :: farg5 farg1 = b1 farg2 = b2 @@ -5475,8 +5475,8 @@ function FARKodeButcherTable_LoadDIRK(imethod) & use, intrinsic :: ISO_C_BINDING type(C_PTR) :: swig_result integer(ARKODE_DIRKTableID), intent(in) :: imethod -type(C_PTR) :: fresult -integer(C_INT) :: farg1 +type(C_PTR) :: fresult +integer(C_INT) :: farg1 farg1 = imethod fresult = swigc_FARKodeButcherTable_LoadDIRK(farg1) @@ -5489,8 +5489,8 @@ function FARKodeButcherTable_LoadDIRKByName(imethod) & type(C_PTR) :: swig_result character(kind=C_CHAR, len=*), target :: imethod character(kind=C_CHAR), dimension(:), allocatable, target :: farg1_chars -type(C_PTR) :: fresult -type(SwigArrayWrapper) :: farg1 +type(C_PTR) :: fresult +type(SwigArrayWrapper) :: farg1 call SWIG_string_to_chararray(imethod, farg1_chars, farg1) fresult = swigc_FARKodeButcherTable_LoadDIRKByName(farg1) @@ -5502,8 +5502,8 @@ function FARKodeButcherTable_DIRKIDToName(imethod) & use, intrinsic :: ISO_C_BINDING character(kind=C_CHAR, len=:), allocatable :: swig_result integer(ARKODE_DIRKTableID), intent(in) :: imethod -type(SwigArrayWrapper) :: fresult -integer(C_INT) :: farg1 +type(SwigArrayWrapper) :: fresult +integer(C_INT) :: farg1 farg1 = imethod fresult = swigc_FARKodeButcherTable_DIRKIDToName(farg1) @@ -5516,8 +5516,8 @@ function FARKodeButcherTable_LoadERK(emethod) & use, intrinsic :: ISO_C_BINDING type(C_PTR) :: swig_result integer(ARKODE_ERKTableID), intent(in) :: emethod -type(C_PTR) :: fresult -integer(C_INT) :: farg1 +type(C_PTR) :: fresult +integer(C_INT) :: farg1 farg1 = emethod fresult = swigc_FARKodeButcherTable_LoadERK(farg1) @@ -5530,8 +5530,8 @@ function FARKodeButcherTable_LoadERKByName(emethod) & type(C_PTR) :: swig_result character(kind=C_CHAR, len=*), target :: emethod character(kind=C_CHAR), dimension(:), allocatable, target :: farg1_chars -type(C_PTR) :: fresult -type(SwigArrayWrapper) :: farg1 +type(C_PTR) :: fresult +type(SwigArrayWrapper) :: farg1 call SWIG_string_to_chararray(emethod, farg1_chars, farg1) fresult = swigc_FARKodeButcherTable_LoadERKByName(farg1) @@ -5543,8 +5543,8 @@ function FARKodeButcherTable_ERKIDToName(emethod) & use, intrinsic :: ISO_C_BINDING character(kind=C_CHAR, len=:), allocatable :: swig_result integer(ARKODE_ERKTableID), intent(in) :: emethod -type(SwigArrayWrapper) :: fresult -integer(C_INT) :: farg1 +type(SwigArrayWrapper) :: fresult +integer(C_INT) :: farg1 farg1 = emethod fresult = swigc_FARKodeButcherTable_ERKIDToName(farg1) @@ -5556,8 +5556,8 @@ subroutine swigf_ARKodeSPRKTableMem_q_set(self, q) use, intrinsic :: ISO_C_BINDING class(ARKodeSPRKTableMem), intent(in) :: self integer(C_INT), intent(in) :: q -type(SwigClassWrapper) :: farg1 -integer(C_INT) :: farg2 +type(SwigClassWrapper) :: farg1 +integer(C_INT) :: farg2 farg1 = self%swigdata farg2 = q @@ -5569,8 +5569,8 @@ function swigf_ARKodeSPRKTableMem_q_get(self) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result class(ARKodeSPRKTableMem), intent(in) :: self -integer(C_INT) :: fresult -type(SwigClassWrapper) :: farg1 +integer(C_INT) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeSPRKTableMem_q_get(farg1) @@ -5581,8 +5581,8 @@ subroutine swigf_ARKodeSPRKTableMem_stages_set(self, stages) use, intrinsic :: ISO_C_BINDING class(ARKodeSPRKTableMem), intent(in) :: self integer(C_INT), intent(in) :: stages -type(SwigClassWrapper) :: farg1 -integer(C_INT) :: farg2 +type(SwigClassWrapper) :: farg1 +integer(C_INT) :: farg2 farg1 = self%swigdata farg2 = stages @@ -5594,8 +5594,8 @@ function swigf_ARKodeSPRKTableMem_stages_get(self) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result class(ARKodeSPRKTableMem), intent(in) :: self -integer(C_INT) :: fresult -type(SwigClassWrapper) :: farg1 +integer(C_INT) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeSPRKTableMem_stages_get(farg1) @@ -5606,8 +5606,8 @@ subroutine swigf_ARKodeSPRKTableMem_a_set(self, a) use, intrinsic :: ISO_C_BINDING class(ARKodeSPRKTableMem), intent(in) :: self real(C_DOUBLE), dimension(*), target, intent(inout) :: a -type(SwigClassWrapper) :: farg1 -type(C_PTR) :: farg2 +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: farg2 farg1 = self%swigdata farg2 = c_loc(a(1)) @@ -5619,8 +5619,8 @@ function swigf_ARKodeSPRKTableMem_a_get(self) & use, intrinsic :: ISO_C_BINDING real(C_DOUBLE), dimension(:), pointer :: swig_result class(ARKodeSPRKTableMem), intent(in) :: self -type(C_PTR) :: fresult -type(SwigClassWrapper) :: farg1 +type(C_PTR) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeSPRKTableMem_a_get(farg1) @@ -5631,8 +5631,8 @@ subroutine swigf_ARKodeSPRKTableMem_ahat_set(self, ahat) use, intrinsic :: ISO_C_BINDING class(ARKodeSPRKTableMem), intent(in) :: self real(C_DOUBLE), dimension(*), target, intent(inout) :: ahat -type(SwigClassWrapper) :: farg1 -type(C_PTR) :: farg2 +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: farg2 farg1 = self%swigdata farg2 = c_loc(ahat(1)) @@ -5644,8 +5644,8 @@ function swigf_ARKodeSPRKTableMem_ahat_get(self) & use, intrinsic :: ISO_C_BINDING real(C_DOUBLE), dimension(:), pointer :: swig_result class(ARKodeSPRKTableMem), intent(in) :: self -type(C_PTR) :: fresult -type(SwigClassWrapper) :: farg1 +type(C_PTR) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeSPRKTableMem_ahat_get(farg1) @@ -5656,7 +5656,7 @@ function swigf_create_ARKodeSPRKTableMem() & result(self) use, intrinsic :: ISO_C_BINDING type(ARKodeSPRKTableMem) :: self -type(SwigClassWrapper) :: fresult +type(SwigClassWrapper) :: fresult fresult = swigc_new_ARKodeSPRKTableMem() self%swigdata = fresult @@ -5665,7 +5665,7 @@ function swigf_create_ARKodeSPRKTableMem() & subroutine swigf_release_ARKodeSPRKTableMem(self) use, intrinsic :: ISO_C_BINDING class(ARKodeSPRKTableMem), intent(inout) :: self -type(SwigClassWrapper) :: farg1 +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata if (btest(farg1%cmemflags, swig_cmem_own_bit)) then @@ -5680,8 +5680,8 @@ subroutine swigf_ARKodeSPRKTableMem_op_assign__(self, other) use, intrinsic :: ISO_C_BINDING class(ARKodeSPRKTableMem), intent(inout) :: self type(ARKodeSPRKTableMem), intent(in) :: other -type(SwigClassWrapper) :: farg1 -type(SwigClassWrapper) :: farg2 +type(SwigClassWrapper) :: farg1 +type(SwigClassWrapper) :: farg2 farg1 = self%swigdata farg2 = other%swigdata @@ -5697,11 +5697,11 @@ function FARKodeSPRKTable_Create(s, q, a, ahat) & integer(C_INT), intent(in) :: q real(C_DOUBLE), dimension(*), target, intent(inout) :: a real(C_DOUBLE), dimension(*), target, intent(inout) :: ahat -type(C_PTR) :: fresult -integer(C_INT) :: farg1 -integer(C_INT) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 +type(C_PTR) :: fresult +integer(C_INT) :: farg1 +integer(C_INT) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 farg1 = s farg2 = q @@ -5716,8 +5716,8 @@ function FARKodeSPRKTable_Alloc(stages) & use, intrinsic :: ISO_C_BINDING type(C_PTR) :: swig_result integer(C_INT), intent(in) :: stages -type(C_PTR) :: fresult -integer(C_INT) :: farg1 +type(C_PTR) :: fresult +integer(C_INT) :: farg1 farg1 = stages fresult = swigc_FARKodeSPRKTable_Alloc(farg1) @@ -5729,8 +5729,8 @@ function FARKodeSPRKTable_Load(id) & use, intrinsic :: ISO_C_BINDING type(C_PTR) :: swig_result integer(ARKODE_SPRKMethodID), intent(in) :: id -type(C_PTR) :: fresult -integer(C_INT) :: farg1 +type(C_PTR) :: fresult +integer(C_INT) :: farg1 farg1 = id fresult = swigc_FARKodeSPRKTable_Load(farg1) @@ -5743,8 +5743,8 @@ function FARKodeSPRKTable_LoadByName(method) & type(C_PTR) :: swig_result character(kind=C_CHAR, len=*), target :: method character(kind=C_CHAR), dimension(:), allocatable, target :: farg1_chars -type(C_PTR) :: fresult -type(SwigArrayWrapper) :: farg1 +type(C_PTR) :: fresult +type(SwigArrayWrapper) :: farg1 call SWIG_string_to_chararray(method, farg1_chars, farg1) fresult = swigc_FARKodeSPRKTable_LoadByName(farg1) @@ -5756,8 +5756,8 @@ function FARKodeSPRKTable_Copy(that_sprk_storage) & use, intrinsic :: ISO_C_BINDING type(C_PTR) :: swig_result type(C_PTR) :: that_sprk_storage -type(C_PTR) :: fresult -type(C_PTR) :: farg1 +type(C_PTR) :: fresult +type(C_PTR) :: farg1 farg1 = that_sprk_storage fresult = swigc_FARKodeSPRKTable_Copy(farg1) @@ -5768,8 +5768,8 @@ subroutine FARKodeSPRKTable_Write(sprk_table, outfile) use, intrinsic :: ISO_C_BINDING type(C_PTR) :: sprk_table type(C_PTR) :: outfile -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = sprk_table farg2 = outfile @@ -5781,9 +5781,9 @@ subroutine FARKodeSPRKTable_Space(sprk_storage, liw, lrw) type(C_PTR) :: sprk_storage integer(C_INT32_T), dimension(*), target, intent(inout) :: liw integer(C_INT32_T), dimension(*), target, intent(inout) :: lrw -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = sprk_storage farg2 = c_loc(liw(1)) @@ -5794,7 +5794,7 @@ subroutine FARKodeSPRKTable_Space(sprk_storage, liw, lrw) subroutine FARKodeSPRKTable_Free(sprk_storage) use, intrinsic :: ISO_C_BINDING type(C_PTR) :: sprk_storage -type(C_PTR) :: farg1 +type(C_PTR) :: farg1 farg1 = sprk_storage call swigc_FARKodeSPRKTable_Free(farg1) @@ -5807,10 +5807,10 @@ function FARKodeSPRKTable_ToButcher(sprk_storage, a_ptr, b_ptr) & type(C_PTR) :: sprk_storage type(C_PTR), target, intent(inout) :: a_ptr type(C_PTR), target, intent(inout) :: b_ptr -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = sprk_storage farg2 = c_loc(a_ptr) @@ -5826,10 +5826,10 @@ function FARKodeSetLinearSolver(arkode_mem, ls, a) & type(C_PTR) :: arkode_mem type(SUNLinearSolver), target, intent(inout) :: ls type(SUNMatrix), target, intent(inout) :: a -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = c_loc(ls) @@ -5846,11 +5846,11 @@ function FARKodeSetMassLinearSolver(arkode_mem, ls, m, time_dep) & type(SUNLinearSolver), target, intent(inout) :: ls type(SUNMatrix), target, intent(inout) :: m integer(C_INT), intent(in) :: time_dep -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 -integer(C_INT) :: farg4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 +integer(C_INT) :: farg4 farg1 = arkode_mem farg2 = c_loc(ls) @@ -5866,9 +5866,9 @@ function FARKodeSetJacFn(arkode_mem, jac) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: jac -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = jac @@ -5882,9 +5882,9 @@ function FARKodeSetMassFn(arkode_mem, mass) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: mass -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = mass @@ -5898,9 +5898,9 @@ function FARKodeSetJacEvalFrequency(arkode_mem, msbj) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), intent(in) :: msbj -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_LONG) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_LONG) :: farg2 farg1 = arkode_mem farg2 = msbj @@ -5914,9 +5914,9 @@ function FARKodeSetLinearSolutionScaling(arkode_mem, onoff) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: onoff -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = onoff @@ -5930,9 +5930,9 @@ function FARKodeSetEpsLin(arkode_mem, eplifac) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: eplifac -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = eplifac @@ -5946,9 +5946,9 @@ function FARKodeSetMassEpsLin(arkode_mem, eplifac) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: eplifac -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = eplifac @@ -5962,9 +5962,9 @@ function FARKodeSetLSNormFactor(arkode_mem, nrmfac) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: nrmfac -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = nrmfac @@ -5978,9 +5978,9 @@ function FARKodeSetMassLSNormFactor(arkode_mem, nrmfac) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: nrmfac -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = nrmfac @@ -5995,10 +5995,10 @@ function FARKodeSetPreconditioner(arkode_mem, psetup, psolve) & type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: psetup type(C_FUNPTR), intent(in), value :: psolve -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -type(C_FUNPTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +type(C_FUNPTR) :: farg3 farg1 = arkode_mem farg2 = psetup @@ -6014,10 +6014,10 @@ function FARKodeSetMassPreconditioner(arkode_mem, psetup, psolve) & type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: psetup type(C_FUNPTR), intent(in), value :: psolve -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -type(C_FUNPTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +type(C_FUNPTR) :: farg3 farg1 = arkode_mem farg2 = psetup @@ -6033,10 +6033,10 @@ function FARKodeSetJacTimes(arkode_mem, jtsetup, jtimes) & type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: jtsetup type(C_FUNPTR), intent(in), value :: jtimes -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -type(C_FUNPTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +type(C_FUNPTR) :: farg3 farg1 = arkode_mem farg2 = jtsetup @@ -6051,9 +6051,9 @@ function FARKodeSetJacTimesRhsFn(arkode_mem, jtimesrhsfn) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: jtimesrhsfn -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = jtimesrhsfn @@ -6069,11 +6069,11 @@ function FARKodeSetMassTimes(arkode_mem, msetup, mtimes, mtimes_data) & type(C_FUNPTR), intent(in), value :: msetup type(C_FUNPTR), intent(in), value :: mtimes type(C_PTR) :: mtimes_data -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -type(C_FUNPTR) :: farg3 -type(C_PTR) :: farg4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +type(C_FUNPTR) :: farg3 +type(C_PTR) :: farg4 farg1 = arkode_mem farg2 = msetup @@ -6089,9 +6089,9 @@ function FARKodeSetLinSysFn(arkode_mem, linsys) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: linsys -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = linsys diff --git a/src/arkode/fmod_int64/farkode_lsrkstep_mod.c b/src/arkode/fmod_int64/farkode_lsrkstep_mod.c index f9c7cdf3eb..ba2f9a5d5e 100644 --- a/src/arkode/fmod_int64/farkode_lsrkstep_mod.c +++ b/src/arkode/fmod_int64/farkode_lsrkstep_mod.c @@ -192,15 +192,15 @@ * the fortran.cxx file. */ #define SWIG_contract_assert(RETURNNULL, EXPR, MSG) \ - if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); } + if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); } -#define SWIGVERSION 0x040000 +#define SWIGVERSION 0x040000 #define SWIG_VERSION SWIGVERSION -#define SWIG_as_voidptr(a) (void *)((const void *)(a)) -#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) +#define SWIG_as_voidptr(a) (void *)((const void *)(a)) +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) #include "arkode/arkode_lsrkstep.h" @@ -237,7 +237,7 @@ SWIGEXPORT void * _wrap_FLSRKStepCreateSTS(ARKRhsFn farg1, double const *farg2, N_Vector arg3 = (N_Vector) 0 ; SUNContext arg4 = (SUNContext) 0 ; void *result = 0 ; - + arg1 = (ARKRhsFn)(farg1); arg2 = (sunrealtype)(*farg2); arg3 = (N_Vector)(farg3); @@ -255,7 +255,7 @@ SWIGEXPORT void * _wrap_FLSRKStepCreateSSP(ARKRhsFn farg1, double const *farg2, N_Vector arg3 = (N_Vector) 0 ; SUNContext arg4 = (SUNContext) 0 ; void *result = 0 ; - + arg1 = (ARKRhsFn)(farg1); arg2 = (sunrealtype)(*farg2); arg3 = (N_Vector)(farg3); @@ -273,7 +273,7 @@ SWIGEXPORT int _wrap_FLSRKStepReInitSTS(void *farg1, ARKRhsFn farg2, double cons sunrealtype arg3 ; N_Vector arg4 = (N_Vector) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (ARKRhsFn)(farg2); arg3 = (sunrealtype)(*farg3); @@ -291,7 +291,7 @@ SWIGEXPORT int _wrap_FLSRKStepReInitSSP(void *farg1, ARKRhsFn farg2, double cons sunrealtype arg3 ; N_Vector arg4 = (N_Vector) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (ARKRhsFn)(farg2); arg3 = (sunrealtype)(*farg3); @@ -307,7 +307,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetSTSMethod(void *farg1, int const *farg2) { void *arg1 = (void *) 0 ; ARKODE_LSRKMethodType arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (ARKODE_LSRKMethodType)(*farg2); result = (int)LSRKStepSetSTSMethod(arg1,arg2); @@ -321,7 +321,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetSSPMethod(void *farg1, int const *farg2) { void *arg1 = (void *) 0 ; ARKODE_LSRKMethodType arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (ARKODE_LSRKMethodType)(*farg2); result = (int)LSRKStepSetSSPMethod(arg1,arg2); @@ -335,7 +335,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetSTSMethodByName(void *farg1, SwigArrayWrapper * void *arg1 = (void *) 0 ; char *arg2 = (char *) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (char *)(farg2->data); result = (int)LSRKStepSetSTSMethodByName(arg1,(char const *)arg2); @@ -349,7 +349,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetSSPMethodByName(void *farg1, SwigArrayWrapper * void *arg1 = (void *) 0 ; char *arg2 = (char *) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (char *)(farg2->data); result = (int)LSRKStepSetSSPMethodByName(arg1,(char const *)arg2); @@ -363,7 +363,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetDomEigFn(void *farg1, ARKDomEigFn farg2) { void *arg1 = (void *) 0 ; ARKDomEigFn arg2 = (ARKDomEigFn) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (ARKDomEigFn)(farg2); result = (int)LSRKStepSetDomEigFn(arg1,arg2); @@ -372,15 +372,15 @@ SWIGEXPORT int _wrap_FLSRKStepSetDomEigFn(void *farg1, ARKDomEigFn farg2) { } -SWIGEXPORT int _wrap_FLSRKStepSetInternalDomEigEstType(void *farg1, int const *farg2) { +SWIGEXPORT int _wrap_FLSRKStepSetDEECreateWithID(void *farg1, int const *farg2) { int fresult ; void *arg1 = (void *) 0 ; - ARKODE_LSRKInternal_DomEigEst_Type arg2 ; + SUNDomEigEstimator_ID arg2 ; int result; - + arg1 = (void *)(farg1); - arg2 = (ARKODE_LSRKInternal_DomEigEst_Type)(*farg2); - result = (int)LSRKStepSetInternalDomEigEstType(arg1,arg2); + arg2 = (SUNDomEigEstimator_ID)(*farg2); + result = (int)LSRKStepSetDEECreateWithID(arg1,arg2); fresult = (int)(result); return fresult; } @@ -391,7 +391,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetDomEigFrequency(void *farg1, long const *farg2) void *arg1 = (void *) 0 ; long arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (long)(*farg2); result = (int)LSRKStepSetDomEigFrequency(arg1,arg2); @@ -405,7 +405,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetMaxNumStages(void *farg1, int const *farg2) { void *arg1 = (void *) 0 ; int arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (int)(*farg2); result = (int)LSRKStepSetMaxNumStages(arg1,arg2); @@ -419,7 +419,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetDomEigSafetyFactor(void *farg1, double const *f void *arg1 = (void *) 0 ; sunrealtype arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (sunrealtype)(*farg2); result = (int)LSRKStepSetDomEigSafetyFactor(arg1,arg2); @@ -433,7 +433,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetNumSSPStages(void *farg1, int const *farg2) { void *arg1 = (void *) 0 ; int arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (int)(*farg2); result = (int)LSRKStepSetNumSSPStages(arg1,arg2); @@ -447,7 +447,7 @@ SWIGEXPORT int _wrap_FLSRKStepGetNumDomEigUpdates(void *farg1, long *farg2) { void *arg1 = (void *) 0 ; long *arg2 = (long *) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (long *)(farg2); result = (int)LSRKStepGetNumDomEigUpdates(arg1,arg2); @@ -461,7 +461,7 @@ SWIGEXPORT int _wrap_FLSRKStepGetMaxNumStages(void *farg1, int *farg2) { void *arg1 = (void *) 0 ; int *arg2 = (int *) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (int *)(farg2); result = (int)LSRKStepGetMaxNumStages(arg1,arg2); diff --git a/src/arkode/fmod_int64/farkode_lsrkstep_mod.f90 b/src/arkode/fmod_int64/farkode_lsrkstep_mod.f90 index 6781a3e5bd..a9f10a03bf 100644 --- a/src/arkode/fmod_int64/farkode_lsrkstep_mod.f90 +++ b/src/arkode/fmod_int64/farkode_lsrkstep_mod.f90 @@ -36,13 +36,13 @@ module farkode_lsrkstep_mod end enum integer, parameter, public :: ARKODE_LSRKMethodType = kind(ARKODE_LSRK_RKC_2) public :: ARKODE_LSRK_RKC_2, ARKODE_LSRK_RKL_2, ARKODE_LSRK_SSP_S_2, ARKODE_LSRK_SSP_S_3, ARKODE_LSRK_SSP_10_4 - ! typedef enum ARKODE_LSRKInternal_DomEigEst_Type + ! typedef enum SUNDomEigEstimator_ID enum, bind(c) - enumerator :: ARKODE_LSRK_POWER_ITERATION - enumerator :: ARKODE_LSRK_ARNOLDI_ITERATION + enumerator :: SUNDSOMEIGESTIMATOR_POWER + enumerator :: SUNDSOMEIGESTIMATOR_ARNOLDI end enum - integer, parameter, public :: ARKODE_LSRKInternal_DomEigEst_Type = kind(ARKODE_LSRK_POWER_ITERATION) - public :: ARKODE_LSRK_POWER_ITERATION, ARKODE_LSRK_ARNOLDI_ITERATION + integer, parameter, public :: SUNDomEigEstimator_ID = kind(SUNDSOMEIGESTIMATOR_POWER) + public :: SUNDSOMEIGESTIMATOR_POWER, SUNDSOMEIGESTIMATOR_ARNOLDI public :: FLSRKStepCreateSTS public :: FLSRKStepCreateSSP public :: FLSRKStepReInitSTS @@ -56,7 +56,7 @@ module farkode_lsrkstep_mod public :: FLSRKStepSetSTSMethodByName public :: FLSRKStepSetSSPMethodByName public :: FLSRKStepSetDomEigFn - public :: FLSRKStepSetInternalDomEigEstType + public :: FLSRKStepSetDEECreateWithID public :: FLSRKStepSetDomEigFrequency public :: FLSRKStepSetMaxNumStages public :: FLSRKStepSetDomEigSafetyFactor @@ -157,8 +157,8 @@ function swigc_FLSRKStepSetDomEigFn(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FLSRKStepSetInternalDomEigEstType(farg1, farg2) & -bind(C, name="_wrap_FLSRKStepSetInternalDomEigEstType") & +function swigc_FLSRKStepSetDEECreateWithID(farg1, farg2) & +bind(C, name="_wrap_FLSRKStepSetDEECreateWithID") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 @@ -233,11 +233,11 @@ function FLSRKStepCreateSTS(rhs, t0, y0, sunctx) & real(C_DOUBLE), intent(in) :: t0 type(N_Vector), target, intent(inout) :: y0 type(C_PTR) :: sunctx -type(C_PTR) :: fresult -type(C_FUNPTR) :: farg1 -real(C_DOUBLE) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 +type(C_PTR) :: fresult +type(C_FUNPTR) :: farg1 +real(C_DOUBLE) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 farg1 = rhs farg2 = t0 @@ -255,11 +255,11 @@ function FLSRKStepCreateSSP(rhs, t0, y0, sunctx) & real(C_DOUBLE), intent(in) :: t0 type(N_Vector), target, intent(inout) :: y0 type(C_PTR) :: sunctx -type(C_PTR) :: fresult -type(C_FUNPTR) :: farg1 -real(C_DOUBLE) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 +type(C_PTR) :: fresult +type(C_FUNPTR) :: farg1 +real(C_DOUBLE) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 farg1 = rhs farg2 = t0 @@ -277,11 +277,11 @@ function FLSRKStepReInitSTS(arkode_mem, rhs, t0, y0) & type(C_FUNPTR), intent(in), value :: rhs real(C_DOUBLE), intent(in) :: t0 type(N_Vector), target, intent(inout) :: y0 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -real(C_DOUBLE) :: farg3 -type(C_PTR) :: farg4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +real(C_DOUBLE) :: farg3 +type(C_PTR) :: farg4 farg1 = arkode_mem farg2 = rhs @@ -299,11 +299,11 @@ function FLSRKStepReInitSSP(arkode_mem, rhs, t0, y0) & type(C_FUNPTR), intent(in), value :: rhs real(C_DOUBLE), intent(in) :: t0 type(N_Vector), target, intent(inout) :: y0 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -real(C_DOUBLE) :: farg3 -type(C_PTR) :: farg4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +real(C_DOUBLE) :: farg3 +type(C_PTR) :: farg4 farg1 = arkode_mem farg2 = rhs @@ -319,9 +319,9 @@ function FLSRKStepSetSTSMethod(arkode_mem, method) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(ARKODE_LSRKMethodType), intent(in) :: method -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = method @@ -335,9 +335,9 @@ function FLSRKStepSetSSPMethod(arkode_mem, method) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(ARKODE_LSRKMethodType), intent(in) :: method -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = method @@ -370,9 +370,9 @@ function FLSRKStepSetSTSMethodByName(arkode_mem, emethod) & type(C_PTR) :: arkode_mem character(kind=C_CHAR, len=*), target :: emethod character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 farg1 = arkode_mem call SWIG_string_to_chararray(emethod, farg2_chars, farg2) @@ -387,9 +387,9 @@ function FLSRKStepSetSSPMethodByName(arkode_mem, emethod) & type(C_PTR) :: arkode_mem character(kind=C_CHAR, len=*), target :: emethod character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 farg1 = arkode_mem call SWIG_string_to_chararray(emethod, farg2_chars, farg2) @@ -403,9 +403,9 @@ function FLSRKStepSetDomEigFn(arkode_mem, dom_eig) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: dom_eig -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = dom_eig @@ -413,19 +413,19 @@ function FLSRKStepSetDomEigFn(arkode_mem, dom_eig) & swig_result = fresult end function -function FLSRKStepSetInternalDomEigEstType(arkode_mem, dom_eig_type) & +function FLSRKStepSetDEECreateWithID(arkode_mem, DEE_id) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -integer(ARKODE_LSRKInternal_DomEigEst_Type), intent(in) :: dom_eig_type -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(SUNDomEigEstimator_ID), intent(in) :: DEE_id +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem -farg2 = dom_eig_type -fresult = swigc_FLSRKStepSetInternalDomEigEstType(farg1, farg2) +farg2 = DEE_id +fresult = swigc_FLSRKStepSetDEECreateWithID(farg1, farg2) swig_result = fresult end function @@ -435,9 +435,9 @@ function FLSRKStepSetDomEigFrequency(arkode_mem, nsteps) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), intent(in) :: nsteps -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_LONG) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_LONG) :: farg2 farg1 = arkode_mem farg2 = nsteps @@ -451,9 +451,9 @@ function FLSRKStepSetMaxNumStages(arkode_mem, stage_max_limit) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: stage_max_limit -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = stage_max_limit @@ -467,9 +467,9 @@ function FLSRKStepSetDomEigSafetyFactor(arkode_mem, dom_eig_safety) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: dom_eig_safety -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = dom_eig_safety @@ -483,9 +483,9 @@ function FLSRKStepSetNumSSPStages(arkode_mem, num_of_stages) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: num_of_stages -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = num_of_stages @@ -499,9 +499,9 @@ function FLSRKStepGetNumDomEigUpdates(arkode_mem, dom_eig_num_evals) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: dom_eig_num_evals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(dom_eig_num_evals(1)) @@ -515,9 +515,9 @@ function FLSRKStepGetMaxNumStages(arkode_mem, stage_max) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), dimension(*), target, intent(inout) :: stage_max -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(stage_max(1)) diff --git a/src/arkode/fmod_int64/farkode_mod.f90 b/src/arkode/fmod_int64/farkode_mod.f90 index 15c63e16db..c2015d52a6 100644 --- a/src/arkode/fmod_int64/farkode_mod.f90 +++ b/src/arkode/fmod_int64/farkode_mod.f90 @@ -101,7 +101,7 @@ module farkode_mod integer(C_INT), parameter, public :: ARK_ADJ_CHECKPOINT_FAIL = -53_C_INT integer(C_INT), parameter, public :: ARK_ADJ_RECOMPUTE_FAIL = -54_C_INT integer(C_INT), parameter, public :: ARK_SUNADJSTEPPER_ERR = -55_C_INT - integer(C_INT), parameter, public :: ARK_INTERNAL_DOMEIG_FAIL = -56_C_INT + integer(C_INT), parameter, public :: ARK_DEE_FAIL = -56_C_INT integer(C_INT), parameter, public :: ARK_UNRECOGNIZED_ERROR = -99_C_INT ! typedef enum ARKRelaxSolver enum, bind(c) @@ -2520,13 +2520,13 @@ function FARKodeResize(arkode_mem, ynew, hscale, t0, resize, resize_data) & real(C_DOUBLE), intent(in) :: t0 type(C_FUNPTR), intent(in), value :: resize type(C_PTR) :: resize_data -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -real(C_DOUBLE) :: farg3 -real(C_DOUBLE) :: farg4 -type(C_FUNPTR) :: farg5 -type(C_PTR) :: farg6 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +real(C_DOUBLE) :: farg3 +real(C_DOUBLE) :: farg4 +type(C_FUNPTR) :: farg5 +type(C_PTR) :: farg6 farg1 = arkode_mem farg2 = c_loc(ynew) @@ -2545,10 +2545,10 @@ function FARKodeReset(arkode_mem, tr, yr) & type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: tr type(N_Vector), target, intent(inout) :: yr -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = tr @@ -2563,9 +2563,9 @@ function FARKodeCreateMRIStepInnerStepper(arkode_mem, stepper) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_PTR), target, intent(inout) :: stepper -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(stepper) @@ -2580,10 +2580,10 @@ function FARKodeSStolerances(arkode_mem, reltol, abstol) & type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: reltol real(C_DOUBLE), intent(in) :: abstol -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 farg1 = arkode_mem farg2 = reltol @@ -2599,10 +2599,10 @@ function FARKodeSVtolerances(arkode_mem, reltol, abstol) & type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: reltol type(N_Vector), target, intent(inout) :: abstol -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = reltol @@ -2617,9 +2617,9 @@ function FARKodeWFtolerances(arkode_mem, efun) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: efun -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = efun @@ -2633,9 +2633,9 @@ function FARKodeResStolerance(arkode_mem, rabstol) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: rabstol -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = rabstol @@ -2649,9 +2649,9 @@ function FARKodeResVtolerance(arkode_mem, rabstol) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(N_Vector), target, intent(inout) :: rabstol -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(rabstol) @@ -2665,9 +2665,9 @@ function FARKodeResFtolerance(arkode_mem, rfun) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: rfun -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = rfun @@ -2682,10 +2682,10 @@ function FARKodeRootInit(arkode_mem, nrtfn, g) & type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: nrtfn type(C_FUNPTR), intent(in), value :: g -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 -type(C_FUNPTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 +type(C_FUNPTR) :: farg3 farg1 = arkode_mem farg2 = nrtfn @@ -2700,9 +2700,9 @@ function FARKodeSetRootDirection(arkode_mem, rootdir) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), dimension(*), target, intent(inout) :: rootdir -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(rootdir(1)) @@ -2715,8 +2715,8 @@ function FARKodeSetNoInactiveRootWarn(arkode_mem) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -integer(C_INT) :: fresult -type(C_PTR) :: farg1 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 farg1 = arkode_mem fresult = swigc_FARKodeSetNoInactiveRootWarn(farg1) @@ -2728,8 +2728,8 @@ function FARKodeSetDefaults(arkode_mem) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -integer(C_INT) :: fresult -type(C_PTR) :: farg1 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 farg1 = arkode_mem fresult = swigc_FARKodeSetDefaults(farg1) @@ -2742,9 +2742,9 @@ function FARKodeSetOrder(arkode_mem, maxord) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: maxord -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = maxord @@ -2758,9 +2758,9 @@ function FARKodeSetInterpolantType(arkode_mem, itype) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: itype -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = itype @@ -2774,9 +2774,9 @@ function FARKodeSetInterpolantDegree(arkode_mem, degree) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: degree -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = degree @@ -2790,9 +2790,9 @@ function FARKodeSetMaxNumSteps(arkode_mem, mxsteps) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), intent(in) :: mxsteps -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_LONG) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_LONG) :: farg2 farg1 = arkode_mem farg2 = mxsteps @@ -2806,9 +2806,9 @@ function FARKodeSetInterpolateStopTime(arkode_mem, interp) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: interp -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = interp @@ -2822,9 +2822,9 @@ function FARKodeSetStopTime(arkode_mem, tstop) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: tstop -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = tstop @@ -2837,8 +2837,8 @@ function FARKodeClearStopTime(arkode_mem) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -integer(C_INT) :: fresult -type(C_PTR) :: farg1 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 farg1 = arkode_mem fresult = swigc_FARKodeClearStopTime(farg1) @@ -2851,9 +2851,9 @@ function FARKodeSetFixedStep(arkode_mem, hfixed) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: hfixed -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = hfixed @@ -2867,9 +2867,9 @@ function FARKodeSetStepDirection(arkode_mem, stepdir) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: stepdir -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = stepdir @@ -2883,9 +2883,9 @@ function FARKodeSetUserData(arkode_mem, user_data) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_PTR) :: user_data -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = user_data @@ -2899,9 +2899,9 @@ function FARKodeSetPostprocessStepFn(arkode_mem, processstep) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: processstep -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = processstep @@ -2915,9 +2915,9 @@ function FARKodeSetPostprocessStageFn(arkode_mem, processstage) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: processstage -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = processstage @@ -2931,9 +2931,9 @@ function FARKodeSetNonlinearSolver(arkode_mem, nls) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(SUNNonlinearSolver), target, intent(inout) :: nls -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nls) @@ -2947,9 +2947,9 @@ function FARKodeSetLinear(arkode_mem, timedepend) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: timedepend -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = timedepend @@ -2962,8 +2962,8 @@ function FARKodeSetNonlinear(arkode_mem) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -integer(C_INT) :: fresult -type(C_PTR) :: farg1 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 farg1 = arkode_mem fresult = swigc_FARKodeSetNonlinear(farg1) @@ -2976,9 +2976,9 @@ function FARKodeSetAutonomous(arkode_mem, autonomous) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: autonomous -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = autonomous @@ -2992,9 +2992,9 @@ function FARKodeSetNlsRhsFn(arkode_mem, nls_fi) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: nls_fi -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = nls_fi @@ -3008,9 +3008,9 @@ function FARKodeSetDeduceImplicitRhs(arkode_mem, deduce) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: deduce -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = deduce @@ -3024,9 +3024,9 @@ function FARKodeSetNonlinCRDown(arkode_mem, crdown) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: crdown -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = crdown @@ -3040,9 +3040,9 @@ function FARKodeSetNonlinRDiv(arkode_mem, rdiv) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: rdiv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = rdiv @@ -3056,9 +3056,9 @@ function FARKodeSetDeltaGammaMax(arkode_mem, dgmax) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: dgmax -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = dgmax @@ -3072,9 +3072,9 @@ function FARKodeSetLSetupFrequency(arkode_mem, msbp) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: msbp -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = msbp @@ -3088,9 +3088,9 @@ function FARKodeSetPredictorMethod(arkode_mem, method) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: method -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = method @@ -3104,9 +3104,9 @@ function FARKodeSetMaxNonlinIters(arkode_mem, maxcor) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: maxcor -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = maxcor @@ -3120,9 +3120,9 @@ function FARKodeSetMaxConvFails(arkode_mem, maxncf) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: maxncf -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = maxncf @@ -3136,9 +3136,9 @@ function FARKodeSetNonlinConvCoef(arkode_mem, nlscoef) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: nlscoef -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = nlscoef @@ -3152,9 +3152,9 @@ function FARKodeSetStagePredictFn(arkode_mem, predictstage) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: predictstage -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = predictstage @@ -3168,9 +3168,9 @@ function FARKodeSetAdaptController(arkode_mem, c) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(SUNAdaptController), target, intent(inout) :: c -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(c) @@ -3203,9 +3203,9 @@ function FARKodeSetAdaptControllerByName(arkode_mem, cname) & type(C_PTR) :: arkode_mem character(kind=C_CHAR, len=*), target :: cname character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 farg1 = arkode_mem call SWIG_string_to_chararray(cname, farg2_chars, farg2) @@ -3219,9 +3219,9 @@ function FARKodeSetAdaptivityAdjustment(arkode_mem, adjust) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: adjust -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = adjust @@ -3235,9 +3235,9 @@ function FARKodeSetCFLFraction(arkode_mem, cfl_frac) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: cfl_frac -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = cfl_frac @@ -3251,9 +3251,9 @@ function FARKodeSetErrorBias(arkode_mem, bias) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: bias -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = bias @@ -3267,9 +3267,9 @@ function FARKodeSetSafetyFactor(arkode_mem, safety) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: safety -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = safety @@ -3283,9 +3283,9 @@ function FARKodeSetMaxGrowth(arkode_mem, mx_growth) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: mx_growth -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = mx_growth @@ -3299,9 +3299,9 @@ function FARKodeSetMinReduction(arkode_mem, eta_min) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: eta_min -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = eta_min @@ -3316,10 +3316,10 @@ function FARKodeSetFixedStepBounds(arkode_mem, lb, ub) & type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: lb real(C_DOUBLE), intent(in) :: ub -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 farg1 = arkode_mem farg2 = lb @@ -3334,9 +3334,9 @@ function FARKodeSetMaxFirstGrowth(arkode_mem, etamx1) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: etamx1 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = etamx1 @@ -3350,9 +3350,9 @@ function FARKodeSetMaxEFailGrowth(arkode_mem, etamxf) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: etamxf -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = etamxf @@ -3366,9 +3366,9 @@ function FARKodeSetSmallNumEFails(arkode_mem, small_nef) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: small_nef -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = small_nef @@ -3382,9 +3382,9 @@ function FARKodeSetMaxCFailGrowth(arkode_mem, etacf) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: etacf -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = etacf @@ -3399,10 +3399,10 @@ function FARKodeSetStabilityFn(arkode_mem, estab, estab_data) & type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: estab type(C_PTR) :: estab_data -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = estab @@ -3417,9 +3417,9 @@ function FARKodeSetMaxErrTestFails(arkode_mem, maxnef) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: maxnef -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = maxnef @@ -3433,9 +3433,9 @@ function FARKodeSetConstraints(arkode_mem, constraints) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(N_Vector), target, intent(inout) :: constraints -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(constraints) @@ -3449,9 +3449,9 @@ function FARKodeSetMaxHnilWarns(arkode_mem, mxhnil) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: mxhnil -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = mxhnil @@ -3465,9 +3465,9 @@ function FARKodeSetInitStep(arkode_mem, hin) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: hin -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = hin @@ -3481,9 +3481,9 @@ function FARKodeSetMinStep(arkode_mem, hmin) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: hmin -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = hmin @@ -3497,9 +3497,9 @@ function FARKodeSetMaxStep(arkode_mem, hmax) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: hmax -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = hmax @@ -3513,9 +3513,9 @@ function FARKodeSetMaxNumConstrFails(arkode_mem, maxfails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: maxfails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = maxfails @@ -3529,9 +3529,9 @@ function FARKodeSetAdjointCheckpointScheme(arkode_mem, checkpoint_scheme) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_PTR) :: checkpoint_scheme -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = checkpoint_scheme @@ -3545,9 +3545,9 @@ function FARKodeSetAdjointCheckpointIndex(arkode_mem, step_index) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), intent(in) :: step_index -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_LONG) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_LONG) :: farg2 farg1 = arkode_mem farg2 = step_index @@ -3561,9 +3561,9 @@ function FARKodeSetUseCompensatedSums(arkode_mem, onoff) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: onoff -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = onoff @@ -3577,9 +3577,9 @@ function FARKodeSetAccumulatedErrorType(arkode_mem, accum_type) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(ARKAccumError), intent(in) :: accum_type -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = accum_type @@ -3592,8 +3592,8 @@ function FARKodeResetAccumulatedError(arkode_mem) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -integer(C_INT) :: fresult -type(C_PTR) :: farg1 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 farg1 = arkode_mem fresult = swigc_FARKodeResetAccumulatedError(farg1) @@ -3609,12 +3609,12 @@ function FARKodeEvolve(arkode_mem, tout, yout, tret, itask) & type(N_Vector), target, intent(inout) :: yout real(C_DOUBLE), dimension(*), target, intent(inout) :: tret integer(C_INT), intent(in) :: itask -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 -integer(C_INT) :: farg5 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 +integer(C_INT) :: farg5 farg1 = arkode_mem farg2 = tout @@ -3633,11 +3633,11 @@ function FARKodeGetDky(arkode_mem, t, k, dky) & real(C_DOUBLE), intent(in) :: t integer(C_INT), intent(in) :: k type(N_Vector), target, intent(inout) :: dky -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -integer(C_INT) :: farg3 -type(C_PTR) :: farg4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +integer(C_INT) :: farg3 +type(C_PTR) :: farg4 farg1 = arkode_mem farg2 = t @@ -3654,10 +3654,10 @@ function FARKodeComputeState(arkode_mem, zcor, z) & type(C_PTR) :: arkode_mem type(N_Vector), target, intent(inout) :: zcor type(N_Vector), target, intent(inout) :: z -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = c_loc(zcor) @@ -3673,10 +3673,10 @@ function FARKodeGetNumRhsEvals(arkode_mem, partition_index, num_rhs_evals) & type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: partition_index integer(C_LONG), dimension(*), target, intent(inout) :: num_rhs_evals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = partition_index @@ -3691,9 +3691,9 @@ function FARKodeGetNumStepAttempts(arkode_mem, step_attempts) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: step_attempts -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(step_attempts(1)) @@ -3708,10 +3708,10 @@ function FARKodeGetWorkSpace(arkode_mem, lenrw, leniw) & type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: lenrw integer(C_LONG), dimension(*), target, intent(inout) :: leniw -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = c_loc(lenrw(1)) @@ -3726,9 +3726,9 @@ function FARKodeGetNumSteps(arkode_mem, nsteps) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nsteps -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nsteps(1)) @@ -3742,9 +3742,9 @@ function FARKodeGetLastStep(arkode_mem, hlast) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), dimension(*), target, intent(inout) :: hlast -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(hlast(1)) @@ -3758,9 +3758,9 @@ function FARKodeGetCurrentStep(arkode_mem, hcur) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), dimension(*), target, intent(inout) :: hcur -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(hcur(1)) @@ -3774,9 +3774,9 @@ function FARKodeGetStepDirection(arkode_mem, stepdir) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), dimension(*), target, intent(inout) :: stepdir -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(stepdir(1)) @@ -3790,9 +3790,9 @@ function FARKodeGetErrWeights(arkode_mem, eweight) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(N_Vector), target, intent(inout) :: eweight -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(eweight) @@ -3806,9 +3806,9 @@ function FARKodeGetNumGEvals(arkode_mem, ngevals) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: ngevals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(ngevals(1)) @@ -3822,9 +3822,9 @@ function FARKodeGetRootInfo(arkode_mem, rootsfound) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), dimension(*), target, intent(inout) :: rootsfound -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(rootsfound(1)) @@ -3838,9 +3838,9 @@ function FARKodeGetUserData(arkode_mem, user_data) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_PTR), target, intent(inout) :: user_data -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(user_data) @@ -3855,10 +3855,10 @@ function FARKodePrintAllStats(arkode_mem, outfile, fmt) & type(C_PTR) :: arkode_mem type(C_PTR) :: outfile integer(SUNOutputFormat), intent(in) :: fmt -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -integer(C_INT) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +integer(C_INT) :: farg3 farg1 = arkode_mem farg2 = outfile @@ -3886,8 +3886,8 @@ function FARKodeGetReturnFlagName(flag) & use, intrinsic :: ISO_C_BINDING character(kind=C_CHAR, len=:), allocatable :: swig_result integer(C_LONG), intent(in) :: flag -type(SwigArrayWrapper) :: fresult -integer(C_LONG) :: farg1 +type(SwigArrayWrapper) :: fresult +integer(C_LONG) :: farg1 farg1 = flag fresult = swigc_FARKodeGetReturnFlagName(farg1) @@ -3901,9 +3901,9 @@ function FARKodeWriteParameters(arkode_mem, fp) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_PTR) :: fp -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = fp @@ -3917,9 +3917,9 @@ function FARKodeGetNumExpSteps(arkode_mem, expsteps) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: expsteps -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(expsteps(1)) @@ -3933,9 +3933,9 @@ function FARKodeGetNumAccSteps(arkode_mem, accsteps) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: accsteps -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(accsteps(1)) @@ -3949,9 +3949,9 @@ function FARKodeGetNumErrTestFails(arkode_mem, netfails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: netfails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(netfails(1)) @@ -3965,9 +3965,9 @@ function FARKodeGetEstLocalErrors(arkode_mem, ele) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(N_Vector), target, intent(inout) :: ele -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(ele) @@ -3981,9 +3981,9 @@ function FARKodeGetActualInitStep(arkode_mem, hinused) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), dimension(*), target, intent(inout) :: hinused -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(hinused(1)) @@ -3997,9 +3997,9 @@ function FARKodeGetTolScaleFactor(arkode_mem, tolsfac) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), dimension(*), target, intent(inout) :: tolsfac -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(tolsfac(1)) @@ -4013,9 +4013,9 @@ function FARKodeGetNumConstrFails(arkode_mem, nconstrfails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nconstrfails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nconstrfails(1)) @@ -4033,13 +4033,13 @@ function FARKodeGetStepStats(arkode_mem, nsteps, hinused, hlast, hcur, tcur) & real(C_DOUBLE), dimension(*), target, intent(inout) :: hlast real(C_DOUBLE), dimension(*), target, intent(inout) :: hcur real(C_DOUBLE), dimension(*), target, intent(inout) :: tcur -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 -type(C_PTR) :: farg5 -type(C_PTR) :: farg6 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 +type(C_PTR) :: farg5 +type(C_PTR) :: farg6 farg1 = arkode_mem farg2 = c_loc(nsteps(1)) @@ -4057,9 +4057,9 @@ function FARKodeGetAccumulatedError(arkode_mem, accum_error) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), dimension(*), target, intent(inout) :: accum_error -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(accum_error(1)) @@ -4073,9 +4073,9 @@ function FARKodeGetNumLinSolvSetups(arkode_mem, nlinsetups) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nlinsetups -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nlinsetups(1)) @@ -4089,9 +4089,9 @@ function FARKodeGetCurrentTime(arkode_mem, tcur) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), dimension(*), target, intent(inout) :: tcur -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(tcur(1)) @@ -4105,9 +4105,9 @@ function FARKodeGetCurrentState(arkode_mem, state) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_PTR) :: state -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = state @@ -4121,9 +4121,9 @@ function FARKodeGetCurrentGamma(arkode_mem, gamma) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), dimension(*), target, intent(inout) :: gamma -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(gamma(1)) @@ -4143,15 +4143,15 @@ function FARKodeGetNonlinearSystemData(arkode_mem, tcur, zpred, z, fi, gamma, sd real(C_DOUBLE), dimension(*), target, intent(inout) :: gamma type(C_PTR) :: sdata type(C_PTR), target, intent(inout) :: user_data -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 -type(C_PTR) :: farg5 -type(C_PTR) :: farg6 -type(C_PTR) :: farg7 -type(C_PTR) :: farg8 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 +type(C_PTR) :: farg5 +type(C_PTR) :: farg6 +type(C_PTR) :: farg7 +type(C_PTR) :: farg8 farg1 = arkode_mem farg2 = c_loc(tcur(1)) @@ -4171,9 +4171,9 @@ function FARKodeGetNumNonlinSolvIters(arkode_mem, nniters) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nniters -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nniters(1)) @@ -4187,9 +4187,9 @@ function FARKodeGetNumNonlinSolvConvFails(arkode_mem, nnfails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nnfails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nnfails(1)) @@ -4204,10 +4204,10 @@ function FARKodeGetNonlinSolvStats(arkode_mem, nniters, nnfails) & type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nniters integer(C_LONG), dimension(*), target, intent(inout) :: nnfails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = c_loc(nniters(1)) @@ -4222,9 +4222,9 @@ function FARKodeGetNumStepSolveFails(arkode_mem, nncfails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nncfails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nncfails(1)) @@ -4238,9 +4238,9 @@ function FARKodeGetJac(arkode_mem, j) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_PTR), target, intent(inout) :: j -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(j) @@ -4254,9 +4254,9 @@ function FARKodeGetJacTime(arkode_mem, t_j) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), dimension(*), target, intent(inout) :: t_j -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(t_j(1)) @@ -4270,9 +4270,9 @@ function FARKodeGetJacNumSteps(arkode_mem, nst_j) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nst_j -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nst_j(1)) @@ -4287,10 +4287,10 @@ function FARKodeGetLinWorkSpace(arkode_mem, lenrwls, leniwls) & type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: lenrwls integer(C_LONG), dimension(*), target, intent(inout) :: leniwls -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = c_loc(lenrwls(1)) @@ -4305,9 +4305,9 @@ function FARKodeGetNumJacEvals(arkode_mem, njevals) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: njevals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(njevals(1)) @@ -4321,9 +4321,9 @@ function FARKodeGetNumPrecEvals(arkode_mem, npevals) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: npevals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(npevals(1)) @@ -4337,9 +4337,9 @@ function FARKodeGetNumPrecSolves(arkode_mem, npsolves) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: npsolves -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(npsolves(1)) @@ -4353,9 +4353,9 @@ function FARKodeGetNumLinIters(arkode_mem, nliters) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nliters -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nliters(1)) @@ -4369,9 +4369,9 @@ function FARKodeGetNumLinConvFails(arkode_mem, nlcfails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nlcfails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nlcfails(1)) @@ -4385,9 +4385,9 @@ function FARKodeGetNumJTSetupEvals(arkode_mem, njtsetups) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: njtsetups -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(njtsetups(1)) @@ -4401,9 +4401,9 @@ function FARKodeGetNumJtimesEvals(arkode_mem, njvevals) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: njvevals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(njvevals(1)) @@ -4417,9 +4417,9 @@ function FARKodeGetNumLinRhsEvals(arkode_mem, nfevalsls) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nfevalsls -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nfevalsls(1)) @@ -4433,9 +4433,9 @@ function FARKodeGetLastLinFlag(arkode_mem, flag) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: flag -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(flag(1)) @@ -4448,8 +4448,8 @@ function FARKodeGetLinReturnFlagName(flag) & use, intrinsic :: ISO_C_BINDING character(kind=C_CHAR, len=:), allocatable :: swig_result integer(C_LONG), intent(in) :: flag -type(SwigArrayWrapper) :: fresult -integer(C_LONG) :: farg1 +type(SwigArrayWrapper) :: fresult +integer(C_LONG) :: farg1 farg1 = flag fresult = swigc_FARKodeGetLinReturnFlagName(farg1) @@ -4463,9 +4463,9 @@ function FARKodeGetCurrentMassMatrix(arkode_mem, m) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_PTR), target, intent(inout) :: m -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(m) @@ -4479,9 +4479,9 @@ function FARKodeGetResWeights(arkode_mem, rweight) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(N_Vector), target, intent(inout) :: rweight -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(rweight) @@ -4496,10 +4496,10 @@ function FARKodeGetMassWorkSpace(arkode_mem, lenrwmls, leniwmls) & type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: lenrwmls integer(C_LONG), dimension(*), target, intent(inout) :: leniwmls -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = c_loc(lenrwmls(1)) @@ -4514,9 +4514,9 @@ function FARKodeGetNumMassSetups(arkode_mem, nmsetups) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nmsetups -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nmsetups(1)) @@ -4530,9 +4530,9 @@ function FARKodeGetNumMassMultSetups(arkode_mem, nmvsetups) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nmvsetups -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nmvsetups(1)) @@ -4546,9 +4546,9 @@ function FARKodeGetNumMassMult(arkode_mem, nmvevals) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nmvevals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nmvevals(1)) @@ -4562,9 +4562,9 @@ function FARKodeGetNumMassSolves(arkode_mem, nmsolves) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nmsolves -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nmsolves(1)) @@ -4578,9 +4578,9 @@ function FARKodeGetNumMassPrecEvals(arkode_mem, nmpevals) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nmpevals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nmpevals(1)) @@ -4594,9 +4594,9 @@ function FARKodeGetNumMassPrecSolves(arkode_mem, nmpsolves) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nmpsolves -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nmpsolves(1)) @@ -4610,9 +4610,9 @@ function FARKodeGetNumMassIters(arkode_mem, nmiters) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nmiters -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nmiters(1)) @@ -4626,9 +4626,9 @@ function FARKodeGetNumMassConvFails(arkode_mem, nmcfails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nmcfails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nmcfails(1)) @@ -4642,9 +4642,9 @@ function FARKodeGetNumMTSetups(arkode_mem, nmtsetups) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nmtsetups -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nmtsetups(1)) @@ -4658,9 +4658,9 @@ function FARKodeGetLastMassFlag(arkode_mem, flag) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: flag -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(flag(1)) @@ -4671,7 +4671,7 @@ function FARKodeGetLastMassFlag(arkode_mem, flag) & subroutine FARKodeFree(arkode_mem) use, intrinsic :: ISO_C_BINDING type(C_PTR), target, intent(inout) :: arkode_mem -type(C_PTR) :: farg1 +type(C_PTR) :: farg1 farg1 = c_loc(arkode_mem) call swigc_FARKodeFree(farg1) @@ -4681,8 +4681,8 @@ subroutine FARKodePrintMem(arkode_mem, outfile) use, intrinsic :: ISO_C_BINDING type(C_PTR) :: arkode_mem type(C_PTR) :: outfile -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = outfile @@ -4696,10 +4696,10 @@ function FARKodeSetRelaxFn(arkode_mem, rfn, rjac) & type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: rfn type(C_FUNPTR), intent(in), value :: rjac -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -type(C_FUNPTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +type(C_FUNPTR) :: farg3 farg1 = arkode_mem farg2 = rfn @@ -4714,9 +4714,9 @@ function FARKodeSetRelaxEtaFail(arkode_mem, eta_rf) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: eta_rf -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = eta_rf @@ -4730,9 +4730,9 @@ function FARKodeSetRelaxLowerBound(arkode_mem, lower) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: lower -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = lower @@ -4746,9 +4746,9 @@ function FARKodeSetRelaxMaxFails(arkode_mem, max_fails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: max_fails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = max_fails @@ -4762,9 +4762,9 @@ function FARKodeSetRelaxMaxIters(arkode_mem, max_iters) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: max_iters -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = max_iters @@ -4778,9 +4778,9 @@ function FARKodeSetRelaxSolver(arkode_mem, solver) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(ARKRelaxSolver), intent(in) :: solver -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = solver @@ -4794,9 +4794,9 @@ function FARKodeSetRelaxResTol(arkode_mem, res_tol) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: res_tol -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = res_tol @@ -4811,10 +4811,10 @@ function FARKodeSetRelaxTol(arkode_mem, rel_tol, abs_tol) & type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: rel_tol real(C_DOUBLE), intent(in) :: abs_tol -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 farg1 = arkode_mem farg2 = rel_tol @@ -4829,9 +4829,9 @@ function FARKodeSetRelaxUpperBound(arkode_mem, upper) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: upper -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = upper @@ -4845,9 +4845,9 @@ function FARKodeGetNumRelaxFnEvals(arkode_mem, r_evals) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: r_evals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(r_evals(1)) @@ -4861,9 +4861,9 @@ function FARKodeGetNumRelaxJacEvals(arkode_mem, j_evals) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: j_evals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(j_evals(1)) @@ -4877,9 +4877,9 @@ function FARKodeGetNumRelaxFails(arkode_mem, relax_fails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: relax_fails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(relax_fails(1)) @@ -4893,9 +4893,9 @@ function FARKodeGetNumRelaxBoundFails(arkode_mem, fails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: fails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(fails(1)) @@ -4909,9 +4909,9 @@ function FARKodeGetNumRelaxSolveFails(arkode_mem, fails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: fails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(fails(1)) @@ -4925,9 +4925,9 @@ function FARKodeGetNumRelaxSolveIters(arkode_mem, iters) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: iters -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(iters(1)) @@ -4941,9 +4941,9 @@ function FARKodeCreateSUNStepper(arkode_mem, stepper) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_PTR), target, intent(inout) :: stepper -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(stepper) @@ -4959,11 +4959,11 @@ function FARKBandPrecInit(arkode_mem, n, mu, ml) & integer(C_INT64_T), intent(in) :: n integer(C_INT64_T), intent(in) :: mu integer(C_INT64_T), intent(in) :: ml -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT64_T) :: farg2 -integer(C_INT64_T) :: farg3 -integer(C_INT64_T) :: farg4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT64_T) :: farg2 +integer(C_INT64_T) :: farg3 +integer(C_INT64_T) :: farg4 farg1 = arkode_mem farg2 = n @@ -4980,10 +4980,10 @@ function FARKBandPrecGetWorkSpace(arkode_mem, lenrwls, leniwls) & type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: lenrwls integer(C_LONG), dimension(*), target, intent(inout) :: leniwls -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = c_loc(lenrwls(1)) @@ -4998,9 +4998,9 @@ function FARKBandPrecGetNumRhsEvals(arkode_mem, nfevalsbp) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nfevalsbp -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nfevalsbp(1)) @@ -5021,16 +5021,16 @@ function FARKBBDPrecInit(arkode_mem, nlocal, mudq, mldq, mukeep, mlkeep, dqrely, real(C_DOUBLE), intent(in) :: dqrely type(C_FUNPTR), intent(in), value :: gloc type(C_FUNPTR), intent(in), value :: cfn -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT64_T) :: farg2 -integer(C_INT64_T) :: farg3 -integer(C_INT64_T) :: farg4 -integer(C_INT64_T) :: farg5 -integer(C_INT64_T) :: farg6 -real(C_DOUBLE) :: farg7 -type(C_FUNPTR) :: farg8 -type(C_FUNPTR) :: farg9 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT64_T) :: farg2 +integer(C_INT64_T) :: farg3 +integer(C_INT64_T) :: farg4 +integer(C_INT64_T) :: farg5 +integer(C_INT64_T) :: farg6 +real(C_DOUBLE) :: farg7 +type(C_FUNPTR) :: farg8 +type(C_FUNPTR) :: farg9 farg1 = arkode_mem farg2 = nlocal @@ -5053,11 +5053,11 @@ function FARKBBDPrecReInit(arkode_mem, mudq, mldq, dqrely) & integer(C_INT64_T), intent(in) :: mudq integer(C_INT64_T), intent(in) :: mldq real(C_DOUBLE), intent(in) :: dqrely -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT64_T) :: farg2 -integer(C_INT64_T) :: farg3 -real(C_DOUBLE) :: farg4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT64_T) :: farg2 +integer(C_INT64_T) :: farg3 +real(C_DOUBLE) :: farg4 farg1 = arkode_mem farg2 = mudq @@ -5074,10 +5074,10 @@ function FARKBBDPrecGetWorkSpace(arkode_mem, lenrwbbdp, leniwbbdp) & type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: lenrwbbdp integer(C_LONG), dimension(*), target, intent(inout) :: leniwbbdp -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = c_loc(lenrwbbdp(1)) @@ -5092,9 +5092,9 @@ function FARKBBDPrecGetNumGfnEvals(arkode_mem, ngevalsbbdp) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: ngevalsbbdp -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(ngevalsbbdp(1)) @@ -5106,8 +5106,8 @@ subroutine swigf_ARKodeButcherTableMem_q_set(self, q) use, intrinsic :: ISO_C_BINDING class(ARKodeButcherTableMem), intent(in) :: self integer(C_INT), intent(in) :: q -type(SwigClassWrapper) :: farg1 -integer(C_INT) :: farg2 +type(SwigClassWrapper) :: farg1 +integer(C_INT) :: farg2 farg1 = self%swigdata farg2 = q @@ -5119,8 +5119,8 @@ function swigf_ARKodeButcherTableMem_q_get(self) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result class(ARKodeButcherTableMem), intent(in) :: self -integer(C_INT) :: fresult -type(SwigClassWrapper) :: farg1 +integer(C_INT) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeButcherTableMem_q_get(farg1) @@ -5131,8 +5131,8 @@ subroutine swigf_ARKodeButcherTableMem_p_set(self, p) use, intrinsic :: ISO_C_BINDING class(ARKodeButcherTableMem), intent(in) :: self integer(C_INT), intent(in) :: p -type(SwigClassWrapper) :: farg1 -integer(C_INT) :: farg2 +type(SwigClassWrapper) :: farg1 +integer(C_INT) :: farg2 farg1 = self%swigdata farg2 = p @@ -5144,8 +5144,8 @@ function swigf_ARKodeButcherTableMem_p_get(self) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result class(ARKodeButcherTableMem), intent(in) :: self -integer(C_INT) :: fresult -type(SwigClassWrapper) :: farg1 +integer(C_INT) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeButcherTableMem_p_get(farg1) @@ -5156,8 +5156,8 @@ subroutine swigf_ARKodeButcherTableMem_stages_set(self, stages) use, intrinsic :: ISO_C_BINDING class(ARKodeButcherTableMem), intent(in) :: self integer(C_INT), intent(in) :: stages -type(SwigClassWrapper) :: farg1 -integer(C_INT) :: farg2 +type(SwigClassWrapper) :: farg1 +integer(C_INT) :: farg2 farg1 = self%swigdata farg2 = stages @@ -5169,8 +5169,8 @@ function swigf_ARKodeButcherTableMem_stages_get(self) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result class(ARKodeButcherTableMem), intent(in) :: self -integer(C_INT) :: fresult -type(SwigClassWrapper) :: farg1 +integer(C_INT) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeButcherTableMem_stages_get(farg1) @@ -5181,8 +5181,8 @@ subroutine swigf_ARKodeButcherTableMem_A_set(self, a) use, intrinsic :: ISO_C_BINDING class(ARKodeButcherTableMem), intent(in) :: self type(C_PTR), target, intent(inout) :: a -type(SwigClassWrapper) :: farg1 -type(C_PTR) :: farg2 +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: farg2 farg1 = self%swigdata farg2 = c_loc(a) @@ -5194,8 +5194,8 @@ function swigf_ARKodeButcherTableMem_A_get(self) & use, intrinsic :: ISO_C_BINDING type(C_PTR), pointer :: swig_result class(ARKodeButcherTableMem), intent(in) :: self -type(C_PTR) :: fresult -type(SwigClassWrapper) :: farg1 +type(C_PTR) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeButcherTableMem_A_get(farg1) @@ -5206,8 +5206,8 @@ subroutine swigf_ARKodeButcherTableMem_c_set(self, c) use, intrinsic :: ISO_C_BINDING class(ARKodeButcherTableMem), intent(in) :: self real(C_DOUBLE), dimension(*), target, intent(inout) :: c -type(SwigClassWrapper) :: farg1 -type(C_PTR) :: farg2 +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: farg2 farg1 = self%swigdata farg2 = c_loc(c(1)) @@ -5219,8 +5219,8 @@ function swigf_ARKodeButcherTableMem_c_get(self) & use, intrinsic :: ISO_C_BINDING real(C_DOUBLE), dimension(:), pointer :: swig_result class(ARKodeButcherTableMem), intent(in) :: self -type(C_PTR) :: fresult -type(SwigClassWrapper) :: farg1 +type(C_PTR) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeButcherTableMem_c_get(farg1) @@ -5231,8 +5231,8 @@ subroutine swigf_ARKodeButcherTableMem_b_set(self, b) use, intrinsic :: ISO_C_BINDING class(ARKodeButcherTableMem), intent(in) :: self real(C_DOUBLE), dimension(*), target, intent(inout) :: b -type(SwigClassWrapper) :: farg1 -type(C_PTR) :: farg2 +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: farg2 farg1 = self%swigdata farg2 = c_loc(b(1)) @@ -5244,8 +5244,8 @@ function swigf_ARKodeButcherTableMem_b_get(self) & use, intrinsic :: ISO_C_BINDING real(C_DOUBLE), dimension(:), pointer :: swig_result class(ARKodeButcherTableMem), intent(in) :: self -type(C_PTR) :: fresult -type(SwigClassWrapper) :: farg1 +type(C_PTR) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeButcherTableMem_b_get(farg1) @@ -5256,8 +5256,8 @@ subroutine swigf_ARKodeButcherTableMem_d_set(self, d) use, intrinsic :: ISO_C_BINDING class(ARKodeButcherTableMem), intent(in) :: self real(C_DOUBLE), dimension(*), target, intent(inout) :: d -type(SwigClassWrapper) :: farg1 -type(C_PTR) :: farg2 +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: farg2 farg1 = self%swigdata farg2 = c_loc(d(1)) @@ -5269,8 +5269,8 @@ function swigf_ARKodeButcherTableMem_d_get(self) & use, intrinsic :: ISO_C_BINDING real(C_DOUBLE), dimension(:), pointer :: swig_result class(ARKodeButcherTableMem), intent(in) :: self -type(C_PTR) :: fresult -type(SwigClassWrapper) :: farg1 +type(C_PTR) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeButcherTableMem_d_get(farg1) @@ -5281,7 +5281,7 @@ function swigf_create_ARKodeButcherTableMem() & result(self) use, intrinsic :: ISO_C_BINDING type(ARKodeButcherTableMem) :: self -type(SwigClassWrapper) :: fresult +type(SwigClassWrapper) :: fresult fresult = swigc_new_ARKodeButcherTableMem() self%swigdata = fresult @@ -5290,7 +5290,7 @@ function swigf_create_ARKodeButcherTableMem() & subroutine swigf_release_ARKodeButcherTableMem(self) use, intrinsic :: ISO_C_BINDING class(ARKodeButcherTableMem), intent(inout) :: self -type(SwigClassWrapper) :: farg1 +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata if (btest(farg1%cmemflags, swig_cmem_own_bit)) then @@ -5305,8 +5305,8 @@ subroutine swigf_ARKodeButcherTableMem_op_assign__(self, other) use, intrinsic :: ISO_C_BINDING class(ARKodeButcherTableMem), intent(inout) :: self type(ARKodeButcherTableMem), intent(in) :: other -type(SwigClassWrapper) :: farg1 -type(SwigClassWrapper) :: farg2 +type(SwigClassWrapper) :: farg1 +type(SwigClassWrapper) :: farg2 farg1 = self%swigdata farg2 = other%swigdata @@ -5320,9 +5320,9 @@ function FARKodeButcherTable_Alloc(stages, embedded) & type(C_PTR) :: swig_result integer(C_INT), intent(in) :: stages integer(C_INT), intent(in) :: embedded -type(C_PTR) :: fresult -integer(C_INT) :: farg1 -integer(C_INT) :: farg2 +type(C_PTR) :: fresult +integer(C_INT) :: farg1 +integer(C_INT) :: farg2 farg1 = stages farg2 = embedded @@ -5341,14 +5341,14 @@ function FARKodeButcherTable_Create(s, q, p, c, a, b, d) & real(C_DOUBLE), dimension(*), target, intent(inout) :: a real(C_DOUBLE), dimension(*), target, intent(inout) :: b real(C_DOUBLE), dimension(*), target, intent(inout) :: d -type(C_PTR) :: fresult -integer(C_INT) :: farg1 -integer(C_INT) :: farg2 -integer(C_INT) :: farg3 -type(C_PTR) :: farg4 -type(C_PTR) :: farg5 -type(C_PTR) :: farg6 -type(C_PTR) :: farg7 +type(C_PTR) :: fresult +integer(C_INT) :: farg1 +integer(C_INT) :: farg2 +integer(C_INT) :: farg3 +type(C_PTR) :: farg4 +type(C_PTR) :: farg5 +type(C_PTR) :: farg6 +type(C_PTR) :: farg7 farg1 = s farg2 = q @@ -5366,8 +5366,8 @@ function FARKodeButcherTable_Copy(b) & use, intrinsic :: ISO_C_BINDING type(C_PTR) :: swig_result type(C_PTR) :: b -type(C_PTR) :: fresult -type(C_PTR) :: farg1 +type(C_PTR) :: fresult +type(C_PTR) :: farg1 farg1 = b fresult = swigc_FARKodeButcherTable_Copy(farg1) @@ -5379,9 +5379,9 @@ subroutine FARKodeButcherTable_Space(b, liw, lrw) type(C_PTR) :: b integer(C_INT64_T), dimension(*), target, intent(inout) :: liw integer(C_INT64_T), dimension(*), target, intent(inout) :: lrw -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = b farg2 = c_loc(liw(1)) @@ -5392,7 +5392,7 @@ subroutine FARKodeButcherTable_Space(b, liw, lrw) subroutine FARKodeButcherTable_Free(b) use, intrinsic :: ISO_C_BINDING type(C_PTR) :: b -type(C_PTR) :: farg1 +type(C_PTR) :: farg1 farg1 = b call swigc_FARKodeButcherTable_Free(farg1) @@ -5402,8 +5402,8 @@ subroutine FARKodeButcherTable_Write(b, outfile) use, intrinsic :: ISO_C_BINDING type(C_PTR) :: b type(C_PTR) :: outfile -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = b farg2 = outfile @@ -5415,8 +5415,8 @@ function FARKodeButcherTable_IsStifflyAccurate(b) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: b -integer(C_INT) :: fresult -type(C_PTR) :: farg1 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 farg1 = b fresult = swigc_FARKodeButcherTable_IsStifflyAccurate(farg1) @@ -5431,11 +5431,11 @@ function FARKodeButcherTable_CheckOrder(b, q, p, outfile) & integer(C_INT), dimension(*), target, intent(inout) :: q integer(C_INT), dimension(*), target, intent(inout) :: p type(C_PTR) :: outfile -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 farg1 = b farg2 = c_loc(q(1)) @@ -5454,12 +5454,12 @@ function FARKodeButcherTable_CheckARKOrder(b1, b2, q, p, outfile) & integer(C_INT), dimension(*), target, intent(inout) :: q integer(C_INT), dimension(*), target, intent(inout) :: p type(C_PTR) :: outfile -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 -type(C_PTR) :: farg5 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 +type(C_PTR) :: farg5 farg1 = b1 farg2 = b2 @@ -5475,8 +5475,8 @@ function FARKodeButcherTable_LoadDIRK(imethod) & use, intrinsic :: ISO_C_BINDING type(C_PTR) :: swig_result integer(ARKODE_DIRKTableID), intent(in) :: imethod -type(C_PTR) :: fresult -integer(C_INT) :: farg1 +type(C_PTR) :: fresult +integer(C_INT) :: farg1 farg1 = imethod fresult = swigc_FARKodeButcherTable_LoadDIRK(farg1) @@ -5489,8 +5489,8 @@ function FARKodeButcherTable_LoadDIRKByName(imethod) & type(C_PTR) :: swig_result character(kind=C_CHAR, len=*), target :: imethod character(kind=C_CHAR), dimension(:), allocatable, target :: farg1_chars -type(C_PTR) :: fresult -type(SwigArrayWrapper) :: farg1 +type(C_PTR) :: fresult +type(SwigArrayWrapper) :: farg1 call SWIG_string_to_chararray(imethod, farg1_chars, farg1) fresult = swigc_FARKodeButcherTable_LoadDIRKByName(farg1) @@ -5502,8 +5502,8 @@ function FARKodeButcherTable_DIRKIDToName(imethod) & use, intrinsic :: ISO_C_BINDING character(kind=C_CHAR, len=:), allocatable :: swig_result integer(ARKODE_DIRKTableID), intent(in) :: imethod -type(SwigArrayWrapper) :: fresult -integer(C_INT) :: farg1 +type(SwigArrayWrapper) :: fresult +integer(C_INT) :: farg1 farg1 = imethod fresult = swigc_FARKodeButcherTable_DIRKIDToName(farg1) @@ -5516,8 +5516,8 @@ function FARKodeButcherTable_LoadERK(emethod) & use, intrinsic :: ISO_C_BINDING type(C_PTR) :: swig_result integer(ARKODE_ERKTableID), intent(in) :: emethod -type(C_PTR) :: fresult -integer(C_INT) :: farg1 +type(C_PTR) :: fresult +integer(C_INT) :: farg1 farg1 = emethod fresult = swigc_FARKodeButcherTable_LoadERK(farg1) @@ -5530,8 +5530,8 @@ function FARKodeButcherTable_LoadERKByName(emethod) & type(C_PTR) :: swig_result character(kind=C_CHAR, len=*), target :: emethod character(kind=C_CHAR), dimension(:), allocatable, target :: farg1_chars -type(C_PTR) :: fresult -type(SwigArrayWrapper) :: farg1 +type(C_PTR) :: fresult +type(SwigArrayWrapper) :: farg1 call SWIG_string_to_chararray(emethod, farg1_chars, farg1) fresult = swigc_FARKodeButcherTable_LoadERKByName(farg1) @@ -5543,8 +5543,8 @@ function FARKodeButcherTable_ERKIDToName(emethod) & use, intrinsic :: ISO_C_BINDING character(kind=C_CHAR, len=:), allocatable :: swig_result integer(ARKODE_ERKTableID), intent(in) :: emethod -type(SwigArrayWrapper) :: fresult -integer(C_INT) :: farg1 +type(SwigArrayWrapper) :: fresult +integer(C_INT) :: farg1 farg1 = emethod fresult = swigc_FARKodeButcherTable_ERKIDToName(farg1) @@ -5556,8 +5556,8 @@ subroutine swigf_ARKodeSPRKTableMem_q_set(self, q) use, intrinsic :: ISO_C_BINDING class(ARKodeSPRKTableMem), intent(in) :: self integer(C_INT), intent(in) :: q -type(SwigClassWrapper) :: farg1 -integer(C_INT) :: farg2 +type(SwigClassWrapper) :: farg1 +integer(C_INT) :: farg2 farg1 = self%swigdata farg2 = q @@ -5569,8 +5569,8 @@ function swigf_ARKodeSPRKTableMem_q_get(self) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result class(ARKodeSPRKTableMem), intent(in) :: self -integer(C_INT) :: fresult -type(SwigClassWrapper) :: farg1 +integer(C_INT) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeSPRKTableMem_q_get(farg1) @@ -5581,8 +5581,8 @@ subroutine swigf_ARKodeSPRKTableMem_stages_set(self, stages) use, intrinsic :: ISO_C_BINDING class(ARKodeSPRKTableMem), intent(in) :: self integer(C_INT), intent(in) :: stages -type(SwigClassWrapper) :: farg1 -integer(C_INT) :: farg2 +type(SwigClassWrapper) :: farg1 +integer(C_INT) :: farg2 farg1 = self%swigdata farg2 = stages @@ -5594,8 +5594,8 @@ function swigf_ARKodeSPRKTableMem_stages_get(self) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result class(ARKodeSPRKTableMem), intent(in) :: self -integer(C_INT) :: fresult -type(SwigClassWrapper) :: farg1 +integer(C_INT) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeSPRKTableMem_stages_get(farg1) @@ -5606,8 +5606,8 @@ subroutine swigf_ARKodeSPRKTableMem_a_set(self, a) use, intrinsic :: ISO_C_BINDING class(ARKodeSPRKTableMem), intent(in) :: self real(C_DOUBLE), dimension(*), target, intent(inout) :: a -type(SwigClassWrapper) :: farg1 -type(C_PTR) :: farg2 +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: farg2 farg1 = self%swigdata farg2 = c_loc(a(1)) @@ -5619,8 +5619,8 @@ function swigf_ARKodeSPRKTableMem_a_get(self) & use, intrinsic :: ISO_C_BINDING real(C_DOUBLE), dimension(:), pointer :: swig_result class(ARKodeSPRKTableMem), intent(in) :: self -type(C_PTR) :: fresult -type(SwigClassWrapper) :: farg1 +type(C_PTR) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeSPRKTableMem_a_get(farg1) @@ -5631,8 +5631,8 @@ subroutine swigf_ARKodeSPRKTableMem_ahat_set(self, ahat) use, intrinsic :: ISO_C_BINDING class(ARKodeSPRKTableMem), intent(in) :: self real(C_DOUBLE), dimension(*), target, intent(inout) :: ahat -type(SwigClassWrapper) :: farg1 -type(C_PTR) :: farg2 +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: farg2 farg1 = self%swigdata farg2 = c_loc(ahat(1)) @@ -5644,8 +5644,8 @@ function swigf_ARKodeSPRKTableMem_ahat_get(self) & use, intrinsic :: ISO_C_BINDING real(C_DOUBLE), dimension(:), pointer :: swig_result class(ARKodeSPRKTableMem), intent(in) :: self -type(C_PTR) :: fresult -type(SwigClassWrapper) :: farg1 +type(C_PTR) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeSPRKTableMem_ahat_get(farg1) @@ -5656,7 +5656,7 @@ function swigf_create_ARKodeSPRKTableMem() & result(self) use, intrinsic :: ISO_C_BINDING type(ARKodeSPRKTableMem) :: self -type(SwigClassWrapper) :: fresult +type(SwigClassWrapper) :: fresult fresult = swigc_new_ARKodeSPRKTableMem() self%swigdata = fresult @@ -5665,7 +5665,7 @@ function swigf_create_ARKodeSPRKTableMem() & subroutine swigf_release_ARKodeSPRKTableMem(self) use, intrinsic :: ISO_C_BINDING class(ARKodeSPRKTableMem), intent(inout) :: self -type(SwigClassWrapper) :: farg1 +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata if (btest(farg1%cmemflags, swig_cmem_own_bit)) then @@ -5680,8 +5680,8 @@ subroutine swigf_ARKodeSPRKTableMem_op_assign__(self, other) use, intrinsic :: ISO_C_BINDING class(ARKodeSPRKTableMem), intent(inout) :: self type(ARKodeSPRKTableMem), intent(in) :: other -type(SwigClassWrapper) :: farg1 -type(SwigClassWrapper) :: farg2 +type(SwigClassWrapper) :: farg1 +type(SwigClassWrapper) :: farg2 farg1 = self%swigdata farg2 = other%swigdata @@ -5697,11 +5697,11 @@ function FARKodeSPRKTable_Create(s, q, a, ahat) & integer(C_INT), intent(in) :: q real(C_DOUBLE), dimension(*), target, intent(inout) :: a real(C_DOUBLE), dimension(*), target, intent(inout) :: ahat -type(C_PTR) :: fresult -integer(C_INT) :: farg1 -integer(C_INT) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 +type(C_PTR) :: fresult +integer(C_INT) :: farg1 +integer(C_INT) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 farg1 = s farg2 = q @@ -5716,8 +5716,8 @@ function FARKodeSPRKTable_Alloc(stages) & use, intrinsic :: ISO_C_BINDING type(C_PTR) :: swig_result integer(C_INT), intent(in) :: stages -type(C_PTR) :: fresult -integer(C_INT) :: farg1 +type(C_PTR) :: fresult +integer(C_INT) :: farg1 farg1 = stages fresult = swigc_FARKodeSPRKTable_Alloc(farg1) @@ -5729,8 +5729,8 @@ function FARKodeSPRKTable_Load(id) & use, intrinsic :: ISO_C_BINDING type(C_PTR) :: swig_result integer(ARKODE_SPRKMethodID), intent(in) :: id -type(C_PTR) :: fresult -integer(C_INT) :: farg1 +type(C_PTR) :: fresult +integer(C_INT) :: farg1 farg1 = id fresult = swigc_FARKodeSPRKTable_Load(farg1) @@ -5743,8 +5743,8 @@ function FARKodeSPRKTable_LoadByName(method) & type(C_PTR) :: swig_result character(kind=C_CHAR, len=*), target :: method character(kind=C_CHAR), dimension(:), allocatable, target :: farg1_chars -type(C_PTR) :: fresult -type(SwigArrayWrapper) :: farg1 +type(C_PTR) :: fresult +type(SwigArrayWrapper) :: farg1 call SWIG_string_to_chararray(method, farg1_chars, farg1) fresult = swigc_FARKodeSPRKTable_LoadByName(farg1) @@ -5756,8 +5756,8 @@ function FARKodeSPRKTable_Copy(that_sprk_storage) & use, intrinsic :: ISO_C_BINDING type(C_PTR) :: swig_result type(C_PTR) :: that_sprk_storage -type(C_PTR) :: fresult -type(C_PTR) :: farg1 +type(C_PTR) :: fresult +type(C_PTR) :: farg1 farg1 = that_sprk_storage fresult = swigc_FARKodeSPRKTable_Copy(farg1) @@ -5768,8 +5768,8 @@ subroutine FARKodeSPRKTable_Write(sprk_table, outfile) use, intrinsic :: ISO_C_BINDING type(C_PTR) :: sprk_table type(C_PTR) :: outfile -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = sprk_table farg2 = outfile @@ -5781,9 +5781,9 @@ subroutine FARKodeSPRKTable_Space(sprk_storage, liw, lrw) type(C_PTR) :: sprk_storage integer(C_INT64_T), dimension(*), target, intent(inout) :: liw integer(C_INT64_T), dimension(*), target, intent(inout) :: lrw -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = sprk_storage farg2 = c_loc(liw(1)) @@ -5794,7 +5794,7 @@ subroutine FARKodeSPRKTable_Space(sprk_storage, liw, lrw) subroutine FARKodeSPRKTable_Free(sprk_storage) use, intrinsic :: ISO_C_BINDING type(C_PTR) :: sprk_storage -type(C_PTR) :: farg1 +type(C_PTR) :: farg1 farg1 = sprk_storage call swigc_FARKodeSPRKTable_Free(farg1) @@ -5807,10 +5807,10 @@ function FARKodeSPRKTable_ToButcher(sprk_storage, a_ptr, b_ptr) & type(C_PTR) :: sprk_storage type(C_PTR), target, intent(inout) :: a_ptr type(C_PTR), target, intent(inout) :: b_ptr -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = sprk_storage farg2 = c_loc(a_ptr) @@ -5826,10 +5826,10 @@ function FARKodeSetLinearSolver(arkode_mem, ls, a) & type(C_PTR) :: arkode_mem type(SUNLinearSolver), target, intent(inout) :: ls type(SUNMatrix), target, intent(inout) :: a -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = c_loc(ls) @@ -5846,11 +5846,11 @@ function FARKodeSetMassLinearSolver(arkode_mem, ls, m, time_dep) & type(SUNLinearSolver), target, intent(inout) :: ls type(SUNMatrix), target, intent(inout) :: m integer(C_INT), intent(in) :: time_dep -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 -integer(C_INT) :: farg4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 +integer(C_INT) :: farg4 farg1 = arkode_mem farg2 = c_loc(ls) @@ -5866,9 +5866,9 @@ function FARKodeSetJacFn(arkode_mem, jac) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: jac -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = jac @@ -5882,9 +5882,9 @@ function FARKodeSetMassFn(arkode_mem, mass) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: mass -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = mass @@ -5898,9 +5898,9 @@ function FARKodeSetJacEvalFrequency(arkode_mem, msbj) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), intent(in) :: msbj -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_LONG) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_LONG) :: farg2 farg1 = arkode_mem farg2 = msbj @@ -5914,9 +5914,9 @@ function FARKodeSetLinearSolutionScaling(arkode_mem, onoff) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: onoff -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = onoff @@ -5930,9 +5930,9 @@ function FARKodeSetEpsLin(arkode_mem, eplifac) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: eplifac -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = eplifac @@ -5946,9 +5946,9 @@ function FARKodeSetMassEpsLin(arkode_mem, eplifac) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: eplifac -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = eplifac @@ -5962,9 +5962,9 @@ function FARKodeSetLSNormFactor(arkode_mem, nrmfac) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: nrmfac -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = nrmfac @@ -5978,9 +5978,9 @@ function FARKodeSetMassLSNormFactor(arkode_mem, nrmfac) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: nrmfac -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = nrmfac @@ -5995,10 +5995,10 @@ function FARKodeSetPreconditioner(arkode_mem, psetup, psolve) & type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: psetup type(C_FUNPTR), intent(in), value :: psolve -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -type(C_FUNPTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +type(C_FUNPTR) :: farg3 farg1 = arkode_mem farg2 = psetup @@ -6014,10 +6014,10 @@ function FARKodeSetMassPreconditioner(arkode_mem, psetup, psolve) & type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: psetup type(C_FUNPTR), intent(in), value :: psolve -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -type(C_FUNPTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +type(C_FUNPTR) :: farg3 farg1 = arkode_mem farg2 = psetup @@ -6033,10 +6033,10 @@ function FARKodeSetJacTimes(arkode_mem, jtsetup, jtimes) & type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: jtsetup type(C_FUNPTR), intent(in), value :: jtimes -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -type(C_FUNPTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +type(C_FUNPTR) :: farg3 farg1 = arkode_mem farg2 = jtsetup @@ -6051,9 +6051,9 @@ function FARKodeSetJacTimesRhsFn(arkode_mem, jtimesrhsfn) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: jtimesrhsfn -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = jtimesrhsfn @@ -6069,11 +6069,11 @@ function FARKodeSetMassTimes(arkode_mem, msetup, mtimes, mtimes_data) & type(C_FUNPTR), intent(in), value :: msetup type(C_FUNPTR), intent(in), value :: mtimes type(C_PTR) :: mtimes_data -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -type(C_FUNPTR) :: farg3 -type(C_PTR) :: farg4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +type(C_FUNPTR) :: farg3 +type(C_PTR) :: farg4 farg1 = arkode_mem farg2 = msetup @@ -6089,9 +6089,9 @@ function FARKodeSetLinSysFn(arkode_mem, linsys) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: linsys -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = linsys diff --git a/src/cvode/CMakeLists.txt b/src/cvode/CMakeLists.txt index 703818ac6d..69bdfbbced 100644 --- a/src/cvode/CMakeLists.txt +++ b/src/cvode/CMakeLists.txt @@ -75,13 +75,24 @@ if(SUNDIALS_BUILD_PACKAGE_FUSED_KERNELS) set(_fused_link_lib sundials_cvode_fused_stubs) endif() +# Add variable DOMEIG_OBJECT_LIBRARIES +set(DOMEIG_OBJECT_LIBRARIES sundials_sundomeigestpi_obj) + +if(ENABLE_LAPACK) + list(APPEND DOMEIG_OBJECT_LIBRARIES sundials_sundomeigestarni_obj) + set(LAPACK_LIBRARY LAPACK::LAPACK) + if(CMAKE_VERSION VERSION_LESS 3.20) + list(APPEND LAPACK_LIBRARY BLAS::BLAS) + endif() +endif() + # Create the library sundials_add_library( sundials_cvode SOURCES ${cvode_SOURCES} HEADERS ${cvode_HEADERS} INCLUDE_SUBDIR cvode - LINK_LIBRARIES PUBLIC sundials_core + LINK_LIBRARIES PUBLIC sundials_core PRIVATE ${LAPACK_LIBRARY} OBJECT_LIBRARIES sundials_sunmemsys_obj sundials_nvecserial_obj @@ -97,6 +108,7 @@ sundials_add_library( sundials_sunlinsolpcg_obj sundials_sunnonlinsolnewton_obj sundials_sunnonlinsolfixedpoint_obj + ${DOMEIG_OBJECT_LIBRARIES} LINK_LIBRARIES # Link to stubs so examples work. PRIVATE ${_fused_link_lib} OUTPUT_NAME sundials_cvode diff --git a/src/cvodes/CMakeLists.txt b/src/cvodes/CMakeLists.txt index 83ecbf9b7a..9e9578aa02 100644 --- a/src/cvodes/CMakeLists.txt +++ b/src/cvodes/CMakeLists.txt @@ -38,6 +38,17 @@ set(cvodes_SOURCES set(cvodes_HEADERS cvodes.h cvodes_bandpre.h cvodes_bbdpre.h cvodes_diag.h cvodes_ls.h cvodes_proj.h) +# Add variable DOMEIG_OBJECT_LIBRARIES +set(DOMEIG_OBJECT_LIBRARIES sundials_sundomeigestpi_obj) + +if(ENABLE_LAPACK) + list(APPEND DOMEIG_OBJECT_LIBRARIES sundials_sundomeigestarni_obj) + set(LAPACK_LIBRARY LAPACK::LAPACK) + if(CMAKE_VERSION VERSION_LESS 3.20) + list(APPEND LAPACK_LIBRARY BLAS::BLAS) + endif() +endif() + # Add prefix with complete path to the CVODES header files add_prefix(${SUNDIALS_SOURCE_DIR}/include/cvodes/ cvodes_HEADERS) @@ -47,7 +58,7 @@ sundials_add_library( SOURCES ${cvodes_SOURCES} HEADERS ${cvodes_HEADERS} INCLUDE_SUBDIR cvodes - LINK_LIBRARIES PUBLIC sundials_core + LINK_LIBRARIES PUBLIC sundials_core PRIVATE ${LAPACK_LIBRARY} OBJECT_LIBRARIES sundials_sunmemsys_obj sundials_nvecserial_obj @@ -63,6 +74,7 @@ sundials_add_library( sundials_sunlinsolpcg_obj sundials_sunnonlinsolnewton_obj sundials_sunnonlinsolfixedpoint_obj + ${DOMEIG_OBJECT_LIBRARIES} OUTPUT_NAME sundials_cvodes VERSION ${cvodeslib_VERSION} SOVERSION ${cvodeslib_SOVERSION}) diff --git a/src/ida/CMakeLists.txt b/src/ida/CMakeLists.txt index 53902e76ac..58d1dbaefb 100644 --- a/src/ida/CMakeLists.txt +++ b/src/ida/CMakeLists.txt @@ -23,6 +23,17 @@ set(ida_SOURCES ida.c ida_bbdpre.c ida_ic.c ida_io.c ida_ls.c ida_nls.c) # Add variable ida_HEADERS with the exported IDA header files set(ida_HEADERS ida.h ida_bbdpre.h ida_ls.h) +# Add variable DOMEIG_OBJECT_LIBRARIES +set(DOMEIG_OBJECT_LIBRARIES sundials_sundomeigestpi_obj) + +if(ENABLE_LAPACK) + list(APPEND DOMEIG_OBJECT_LIBRARIES sundials_sundomeigestarni_obj) + set(LAPACK_LIBRARY LAPACK::LAPACK) + if(CMAKE_VERSION VERSION_LESS 3.20) + list(APPEND LAPACK_LIBRARY BLAS::BLAS) + endif() +endif() + # Add prefix with complete path to the IDA header files add_prefix(${SUNDIALS_SOURCE_DIR}/include/ida/ ida_HEADERS) @@ -32,7 +43,7 @@ sundials_add_library( SOURCES ${ida_SOURCES} HEADERS ${ida_HEADERS} INCLUDE_SUBDIR ida - LINK_LIBRARIES PUBLIC sundials_core + LINK_LIBRARIES PUBLIC sundials_core PRIVATE ${LAPACK_LIBRARY} OBJECT_LIBRARIES sundials_sunmemsys_obj sundials_nvecserial_obj @@ -48,6 +59,7 @@ sundials_add_library( sundials_sunlinsolpcg_obj sundials_sunnonlinsolnewton_obj sundials_sunnonlinsolfixedpoint_obj + ${DOMEIG_OBJECT_LIBRARIES} OUTPUT_NAME sundials_ida VERSION ${idalib_VERSION} SOVERSION ${idalib_SOVERSION}) diff --git a/src/idas/CMakeLists.txt b/src/idas/CMakeLists.txt index 7b9f71f92b..d289bc146f 100644 --- a/src/idas/CMakeLists.txt +++ b/src/idas/CMakeLists.txt @@ -33,6 +33,17 @@ set(idas_SOURCES # Add variable idas_HEADERS with the exported IDAS header files set(idas_HEADERS idas.h idas_bbdpre.h idas_ls.h) +# Add variable DOMEIG_OBJECT_LIBRARIES +set(DOMEIG_OBJECT_LIBRARIES sundials_sundomeigestpi_obj) + +if(ENABLE_LAPACK) + list(APPEND DOMEIG_OBJECT_LIBRARIES sundials_sundomeigestarni_obj) + set(LAPACK_LIBRARY LAPACK::LAPACK) + if(CMAKE_VERSION VERSION_LESS 3.20) + list(APPEND LAPACK_LIBRARY BLAS::BLAS) + endif() +endif() + # Add prefix with complete path to the IDAS header files add_prefix(${SUNDIALS_SOURCE_DIR}/include/idas/ idas_HEADERS) @@ -42,7 +53,7 @@ sundials_add_library( SOURCES ${idas_SOURCES} HEADERS ${idas_HEADERS} INCLUDE_SUBDIR idas - LINK_LIBRARIES PUBLIC sundials_core + LINK_LIBRARIES PUBLIC sundials_core PRIVATE ${LAPACK_LIBRARY} OBJECT_LIBRARIES sundials_sunmemsys_obj sundials_nvecserial_obj @@ -58,6 +69,7 @@ sundials_add_library( sundials_sunlinsolpcg_obj sundials_sunnonlinsolnewton_obj sundials_sunnonlinsolfixedpoint_obj + ${DOMEIG_OBJECT_LIBRARIES} OUTPUT_NAME sundials_idas VERSION ${idaslib_VERSION} SOVERSION ${idaslib_SOVERSION}) diff --git a/src/kinsol/CMakeLists.txt b/src/kinsol/CMakeLists.txt index e3c8a8bb77..e3abe24838 100644 --- a/src/kinsol/CMakeLists.txt +++ b/src/kinsol/CMakeLists.txt @@ -23,6 +23,17 @@ set(kinsol_SOURCES kinsol.c kinsol_bbdpre.c kinsol_io.c kinsol_ls.c) # Add variable kinsol_HEADERS with the exported KINSOL header files set(kinsol_HEADERS kinsol.h kinsol_bbdpre.h kinsol_ls.h) +# Add variable DOMEIG_OBJECT_LIBRARIES +set(DOMEIG_OBJECT_LIBRARIES sundials_sundomeigestpi_obj) + +if(ENABLE_LAPACK) + list(APPEND DOMEIG_OBJECT_LIBRARIES sundials_sundomeigestarni_obj) + set(LAPACK_LIBRARY LAPACK::LAPACK) + if(CMAKE_VERSION VERSION_LESS 3.20) + list(APPEND LAPACK_LIBRARY BLAS::BLAS) + endif() +endif() + # Add prefix with complete path to the KINSOL header files add_prefix(${SUNDIALS_SOURCE_DIR}/include/kinsol/ kinsol_HEADERS) @@ -32,7 +43,7 @@ sundials_add_library( SOURCES ${kinsol_SOURCES} HEADERS ${kinsol_HEADERS} INCLUDE_SUBDIR kinsol - LINK_LIBRARIES PUBLIC sundials_core + LINK_LIBRARIES PUBLIC sundials_core PRIVATE ${LAPACK_LIBRARY} OBJECT_LIBRARIES sundials_sunmemsys_obj sundials_nvecserial_obj @@ -46,6 +57,7 @@ sundials_add_library( sundials_sunlinsolspgmr_obj sundials_sunlinsolsptfqmr_obj sundials_sunlinsolpcg_obj + ${DOMEIG_OBJECT_LIBRARIES} OUTPUT_NAME sundials_kinsol VERSION ${kinsollib_VERSION} SOVERSION ${kinsollib_SOVERSION}) diff --git a/src/sundials/CMakeLists.txt b/src/sundials/CMakeLists.txt index 980a840cbf..26fa56fd34 100644 --- a/src/sundials/CMakeLists.txt +++ b/src/sundials/CMakeLists.txt @@ -135,7 +135,7 @@ sundials_add_library( SOURCES ${sundials_SOURCES} HEADERS ${sundials_HEADERS} INCLUDE_SUBDIR sundials - LINK_LIBRARIES ${_link_mpi_if_needed} ${_link_lapack_if_needed} + LINK_LIBRARIES ${_link_mpi_if_needed} ${_link_lapack_if_needed} #TODO: Do we need to link lapack here? OUTPUT_NAME sundials_core VERSION ${sundialslib_VERSION} SOVERSION ${sundialslib_SOVERSION}) diff --git a/src/sundials/sundials_domeigestimator.c b/src/sundials/sundials_domeigestimator.c index 0b87cd36f0..9721db4b47 100644 --- a/src/sundials/sundials_domeigestimator.c +++ b/src/sundials/sundials_domeigestimator.c @@ -172,7 +172,7 @@ SUNErrCode SUNDomEigEstimate(SUNDomEigEstimator DEE, sunrealtype* lambdaR, SUNErrCode ier; SUNDIALS_MARK_FUNCTION_BEGIN(getSUNProfiler(DEE)); if (DEE->ops->estimate) { ier = DEE->ops->estimate(DEE, lambdaR, lambdaI); } - else { ier = SUN_SUCCESS; } + else { ier = SUN_ERR_DEE_NULL_ESTIMATE; } SUNDIALS_MARK_FUNCTION_END(getSUNProfiler(DEE)); return (ier); } @@ -214,3 +214,19 @@ SUNErrCode SUNDomEigEstRes(SUNDomEigEstimator DEE, sunrealtype* res) SUNDIALS_MARK_FUNCTION_END(getSUNProfiler(DEE)); return (ier); } + +SUNErrCode SUNDomEigEstFree(SUNDomEigEstimator DEE) +{ + SUNErrCode ier; + SUNDIALS_MARK_FUNCTION_BEGIN(getSUNProfiler(DEE)); + if (DEE->ops->free) + { + ier = DEE->ops->free(DEE); + } + else + { + ier = SUN_ERR_DEE_NULL_FREE; + } + SUNDIALS_MARK_FUNCTION_END(getSUNProfiler(DEE)); + return (ier); +} \ No newline at end of file diff --git a/src/sundomeigest/ArnI/sundomeigest_arni.c b/src/sundomeigest/ArnI/sundomeigest_arni.c index 1b71ce4ed7..5809f82a98 100644 --- a/src/sundomeigest/ArnI/sundomeigest_arni.c +++ b/src/sundomeigest/ArnI/sundomeigest_arni.c @@ -137,7 +137,7 @@ SUNErrCode SUNDomEigEstInitialize_ArnI(SUNDomEigEstimator DEE) } if (ArnI_CONTENT(DEE)->numwarmups < 0) { - ArnI_CONTENT(DEE)->numwarmups = SUNDOMEIGEST_NUM_OF_WARMUPS_DEFAULT; + ArnI_CONTENT(DEE)->numwarmups = DEE_NUM_OF_WARMUPS_DEFAULT; } SUNAssert(ArnI_CONTENT(DEE)->ATimes, SUN_ERR_DEE_NULL_ATIMES); @@ -360,7 +360,7 @@ SUNErrCode SUNDomEigEstimate_ArnI(SUNDomEigEstimator DEE, sunrealtype* lambdaR, /* Sort the array using qsort */ qsort(ArnI_CONTENT(DEE)->LAPACK_arr, n, - sizeof(ArnI_CONTENT(DEE)->LAPACK_arr[0]), domeig_Compare); + sizeof(ArnI_CONTENT(DEE)->LAPACK_arr[0]), sundomeigest_Compare); // alternatively we can return a vector of all computed dom_eigs (up to krydim) // TODO: Get opinions @@ -443,7 +443,7 @@ SUNErrCode SUNDomEigEstFree_ArnI(SUNDomEigEstimator DEE) } // Comparison function for qsort -int domeig_Compare(const void* a, const void* b) +int sundomeigest_Compare(const void* a, const void* b) { const sunrealtype* c1 = *(const sunrealtype* const*)a; const sunrealtype* c2 = *(const sunrealtype* const*)b; diff --git a/src/sundomeigest/PI/sundomeigest_pi.c b/src/sundomeigest/PI/sundomeigest_pi.c index 74c10a85cc..a36ef8b828 100644 --- a/src/sundomeigest/PI/sundomeigest_pi.c +++ b/src/sundomeigest/PI/sundomeigest_pi.c @@ -134,7 +134,7 @@ SUNErrCode SUNDomEigEstInitialize_PI(SUNDomEigEstimator DEE) } if (PI_CONTENT(DEE)->numwarmups <= 0) { - PI_CONTENT(DEE)->numwarmups = SUNDOMEIGEST_NUM_OF_WARMUPS_DEFAULT; + PI_CONTENT(DEE)->numwarmups = DEE_NUM_OF_WARMUPS_DEFAULT; } if (PI_CONTENT(DEE)->max_powiter <= 0) { From 9a6a61cc720d59486eee76aa2ae37d4fb1558e2a Mon Sep 17 00:00:00 2001 From: maggul Date: Thu, 19 Jun 2025 18:02:29 -0500 Subject: [PATCH 058/128] newline at end of file --- src/sundials/sundials_domeigestimator.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sundials/sundials_domeigestimator.c b/src/sundials/sundials_domeigestimator.c index 9721db4b47..b5f9043566 100644 --- a/src/sundials/sundials_domeigestimator.c +++ b/src/sundials/sundials_domeigestimator.c @@ -229,4 +229,5 @@ SUNErrCode SUNDomEigEstFree(SUNDomEigEstimator DEE) } SUNDIALS_MARK_FUNCTION_END(getSUNProfiler(DEE)); return (ier); -} \ No newline at end of file +} + From d73dcd7424b2109b031ead457bd1b893aee46c3a Mon Sep 17 00:00:00 2001 From: maggul Date: Thu, 19 Jun 2025 22:31:31 -0500 Subject: [PATCH 059/128] Bulk updates 2 --- doc/shared/sundomeigest/SUNDomEigEst_PI.rst | 2 +- include/arkode/arkode.h | 2 +- include/arkode/arkode_lsrkstep.h | 6 +- include/sundials/sundials_domeigestimator.h | 4 +- include/sundomeigest/sundomeigest_pi.h | 2 +- src/arkode/arkode_lsrkstep.c | 44 +- src/arkode/arkode_lsrkstep_impl.h | 14 +- src/arkode/arkode_lsrkstep_io.c | 13 +- src/arkode/fmod_int32/farkode_lsrkstep_mod.c | 88 +- .../fmod_int32/farkode_lsrkstep_mod.f90 | 165 +- src/arkode/fmod_int32/farkode_mod.f90 | 1342 ++++++++--------- src/arkode/fmod_int64/farkode_lsrkstep_mod.c | 88 +- .../fmod_int64/farkode_lsrkstep_mod.f90 | 165 +- src/arkode/fmod_int64/farkode_mod.f90 | 1342 ++++++++--------- src/sundials/CMakeLists.txt | 4 +- .../fmod_int32/fsundials_core_mod.f90 | 6 +- .../fmod_int64/fsundials_core_mod.f90 | 6 +- src/sundials/sundials_domeigestimator.c | 38 +- src/sundomeigest/ArnI/sundomeigest_arni.c | 26 +- src/sundomeigest/PI/sundomeigest_pi.c | 30 +- .../arni/test_sundomeigest_arni.c | 32 +- .../sundomeigest/pi/test_sundomeigest_pi.c | 32 +- .../sundomeigest/test_sundomeigest.c | 7 - .../sundomeigest/test_sundomeigest.h | 1 - 24 files changed, 1795 insertions(+), 1664 deletions(-) diff --git a/doc/shared/sundomeigest/SUNDomEigEst_PI.rst b/doc/shared/sundomeigest/SUNDomEigEst_PI.rst index 8b34fee76c..f5a4c2cc7e 100644 --- a/doc/shared/sundomeigest/SUNDomEigEst_PI.rst +++ b/doc/shared/sundomeigest/SUNDomEigEst_PI.rst @@ -144,7 +144,7 @@ dominant eigenvalue estimator operations listed in * ``SUNDomEigEstSetNumPreProcess_PI`` -* ``SUNDomEigEst_PISetMaxPowerIter`` +* ``SUNDomEigEstSetMaxPowerIter_PI`` * ``SUNDomEigEstPreProcess_PI`` diff --git a/include/arkode/arkode.h b/include/arkode/arkode.h index bc7ca051c5..226feac363 100644 --- a/include/arkode/arkode.h +++ b/include/arkode/arkode.h @@ -152,7 +152,7 @@ extern "C" { #define ARK_ADJ_RECOMPUTE_FAIL -54 #define ARK_SUNADJSTEPPER_ERR -55 -#define ARK_DEE_FAIL -56 +#define ARK_DEE_FAIL -56 #define ARK_UNRECOGNIZED_ERROR -99 diff --git a/include/arkode/arkode_lsrkstep.h b/include/arkode/arkode_lsrkstep.h index b204bb0ab0..e30d1a3466 100644 --- a/include/arkode/arkode_lsrkstep.h +++ b/include/arkode/arkode_lsrkstep.h @@ -75,8 +75,8 @@ SUNDIALS_EXPORT int LSRKStepSetSSPMethodByName(void* arkode_mem, SUNDIALS_EXPORT int LSRKStepSetDomEigFn(void* arkode_mem, ARKDomEigFn dom_eig); -SUNDIALS_EXPORT int LSRKStepSetDEECreateWithID( - void* arkode_mem, SUNDomEigEstimator_ID DEE_id); +SUNDIALS_EXPORT int LSRKStepSetDEECreateWithID(void* arkode_mem, + SUNDomEigEstimator_ID DEE_id); SUNDIALS_EXPORT int LSRKStepSetDomEigFrequency(void* arkode_mem, long int nsteps); @@ -95,7 +95,7 @@ SUNDIALS_EXPORT int LSRKStepGetNumDomEigUpdates(void* arkode_mem, SUNDIALS_EXPORT int LSRKStepGetMaxNumStages(void* arkode_mem, int* stage_max); -SUNDIALS_EXPORT int LSRKStepGetNumRHSinDQ(void* arkode_mem, int* nfeDQ); +SUNDIALS_EXPORT int LSRKStepGetNumRHSinDQ(void* arkode_mem, long int* nfeDQ); #ifdef __cplusplus } diff --git a/include/sundials/sundials_domeigestimator.h b/include/sundials/sundials_domeigestimator.h index e559cab2bc..f6bb2d416c 100644 --- a/include/sundials/sundials_domeigestimator.h +++ b/include/sundials/sundials_domeigestimator.h @@ -98,7 +98,7 @@ SUNErrCode SUNDomEigEstSetATimes(SUNDomEigEstimator DEE, void* A_data, SUNATimesFn ATimes); SUNDIALS_EXPORT -SUNErrCode SUNDomEigEstSetMaxPowerIter(SUNDomEigEstimator DEE, int max_powiter); +SUNErrCode SUNDomEigEstInitialize(SUNDomEigEstimator DEE); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstSetNumPreProcess(SUNDomEigEstimator DEE, @@ -108,7 +108,7 @@ SUNDIALS_EXPORT SUNErrCode SUNDomEigEstSetTol(SUNDomEigEstimator DEE, sunrealtype tol); SUNDIALS_EXPORT -SUNErrCode SUNDomEigEstInitialize(SUNDomEigEstimator DEE); +SUNErrCode SUNDomEigEstSetMaxPowerIter(SUNDomEigEstimator DEE, int max_powiter); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstPreProcess(SUNDomEigEstimator DEE); diff --git a/include/sundomeigest/sundomeigest_pi.h b/include/sundomeigest/sundomeigest_pi.h index f4e506b184..226beddd06 100644 --- a/include/sundomeigest/sundomeigest_pi.h +++ b/include/sundomeigest/sundomeigest_pi.h @@ -80,7 +80,7 @@ SUNDIALS_EXPORT SUNErrCode SUNDomEigEstSetTol_PI(SUNDomEigEstimator DEE, sunrealtype tol); SUNDIALS_EXPORT -SUNErrCode SUNDomEigEst_PISetMaxPowerIter(SUNDomEigEstimator DEE, +SUNErrCode SUNDomEigEstSetMaxPowerIter_PI(SUNDomEigEstimator DEE, int max_powiter); SUNDIALS_EXPORT diff --git a/src/arkode/arkode_lsrkstep.c b/src/arkode/arkode_lsrkstep.c index cd5b233b82..018decb274 100644 --- a/src/arkode/arkode_lsrkstep.c +++ b/src/arkode/arkode_lsrkstep.c @@ -190,7 +190,7 @@ void* lsrkStep_Create_Commons(ARKRhsFn rhs, sunrealtype t0, N_Vector y0, } /* Copy the input parameters into ARKODE state */ - step_mem->fe = rhs; + step_mem->fe = rhs; /* Set internal DomEigEst type */ step_mem->DDE_ID = SUNDSOMEIGESTIMATOR_POWER; @@ -2225,8 +2225,8 @@ int lsrkStep_ComputeNewDomEig(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem) step_mem->dom_eig_num_evals++; if (retval != ARK_SUCCESS) { - arkProcessError(ark_mem, ARK_DEE_FAIL, __LINE__, __func__, - __FILE__, MSG_ARK_DEE_FAIL); + arkProcessError(ark_mem, ARK_DEE_FAIL, __LINE__, __func__, __FILE__, + MSG_ARK_DEE_FAIL); return ARK_DEE_FAIL; } } @@ -2318,8 +2318,7 @@ SUNDomEigEstimator lsrkStep_DomEigCreate(void* arkode_mem) /* Create the internal DomEigEst */ if (step_mem->DDE_ID == SUNDSOMEIGESTIMATOR_POWER) { - DEE = SUNDomEigEst_PI(ark_mem->yn, step_mem->dee_maxiters, - ark_mem->sunctx); + DEE = SUNDomEigEst_PI(ark_mem->yn, step_mem->dee_maxiters, ark_mem->sunctx); if (DEE == NULL) { arkProcessError(ark_mem, ARK_DEE_FAIL, __LINE__, __func__, @@ -2338,16 +2337,15 @@ SUNDomEigEstimator lsrkStep_DomEigCreate(void* arkode_mem) return NULL; } #else - arkProcessError(ark_mem, ARK_DEE_FAIL, __LINE__, __func__, - __FILE__, + arkProcessError(ark_mem, ARK_DEE_FAIL, __LINE__, __func__, __FILE__, "Sundials Arnoldi DDE requires LAPACK package"); return NULL; #endif } else { - arkProcessError(ark_mem, ARK_DEE_FAIL, __LINE__, __func__, - __FILE__, "Attempted to create a DDE with an unknown type"); + arkProcessError(ark_mem, ARK_DEE_FAIL, __LINE__, __func__, __FILE__, + "Attempted to create a DDE with an unknown type"); return NULL; } @@ -2355,8 +2353,8 @@ SUNDomEigEstimator lsrkStep_DomEigCreate(void* arkode_mem) retval = DEE->ops->setatimes(DEE, arkode_mem, lsrkStep_DQJtimes); if (retval != ARK_SUCCESS) { - arkProcessError(ark_mem, ARK_DEE_FAIL, __LINE__, __func__, - __FILE__, MSG_ARK_DEE_FAIL); + arkProcessError(ark_mem, ARK_DEE_FAIL, __LINE__, __func__, __FILE__, + MSG_ARK_DEE_FAIL); return NULL; } @@ -2366,8 +2364,8 @@ SUNDomEigEstimator lsrkStep_DomEigCreate(void* arkode_mem) retval = DEE->ops->setmaxpoweriter(DEE, step_mem->dee_maxiters); if (retval != ARK_SUCCESS) { - arkProcessError(ark_mem, ARK_DEE_FAIL, __LINE__, __func__, - __FILE__, MSG_ARK_DEE_FAIL); + arkProcessError(ark_mem, ARK_DEE_FAIL, __LINE__, __func__, __FILE__, + MSG_ARK_DEE_FAIL); return NULL; } } @@ -2376,8 +2374,8 @@ SUNDomEigEstimator lsrkStep_DomEigCreate(void* arkode_mem) retval = DEE->ops->initialize(DEE); if (retval != ARK_SUCCESS) { - arkProcessError(ark_mem, ARK_DEE_FAIL, __LINE__, __func__, - __FILE__, MSG_ARK_DEE_FAIL); + arkProcessError(ark_mem, ARK_DEE_FAIL, __LINE__, __func__, __FILE__, + MSG_ARK_DEE_FAIL); return NULL; } @@ -2387,8 +2385,8 @@ SUNDomEigEstimator lsrkStep_DomEigCreate(void* arkode_mem) retval = DEE->ops->setnumofperprocess(DEE, step_mem->dee_numwarmups); if (retval != ARK_SUCCESS) { - arkProcessError(ark_mem, ARK_DEE_FAIL, __LINE__, __func__, - __FILE__, MSG_ARK_DEE_FAIL); + arkProcessError(ark_mem, ARK_DEE_FAIL, __LINE__, __func__, __FILE__, + MSG_ARK_DEE_FAIL); return NULL; } } @@ -2428,8 +2426,8 @@ int lsrkStep_DomEigEstimate(void* arkode_mem, SUNDomEigEstimator DEE, retval = DEE->ops->preprocess(DEE); if (retval != ARK_SUCCESS) { - arkProcessError(ark_mem, ARK_DEE_FAIL, __LINE__, __func__, - __FILE__, MSG_ARK_DEE_FAIL); + arkProcessError(ark_mem, ARK_DEE_FAIL, __LINE__, __func__, __FILE__, + MSG_ARK_DEE_FAIL); return ARK_DEE_FAIL; } @@ -2441,8 +2439,8 @@ int lsrkStep_DomEigEstimate(void* arkode_mem, SUNDomEigEstimator DEE, retval = DEE->ops->computehess(DEE); if (retval != ARK_SUCCESS) { - arkProcessError(ark_mem, ARK_DEE_FAIL, __LINE__, __func__, - __FILE__, MSG_ARK_DEE_FAIL); + arkProcessError(ark_mem, ARK_DEE_FAIL, __LINE__, __func__, __FILE__, + MSG_ARK_DEE_FAIL); return ARK_DEE_FAIL; } @@ -2451,8 +2449,8 @@ int lsrkStep_DomEigEstimate(void* arkode_mem, SUNDomEigEstimator DEE, retval = DEE->ops->estimate(DEE, lambdaR, lambdaI); if (retval != ARK_SUCCESS) { - arkProcessError(ark_mem, ARK_DEE_FAIL, __LINE__, __func__, - __FILE__, MSG_ARK_DEE_FAIL); + arkProcessError(ark_mem, ARK_DEE_FAIL, __LINE__, __func__, __FILE__, + MSG_ARK_DEE_FAIL); return ARK_DEE_FAIL; } diff --git a/src/arkode/arkode_lsrkstep_impl.h b/src/arkode/arkode_lsrkstep_impl.h index a260d49ad5..7d7d60d723 100644 --- a/src/arkode/arkode_lsrkstep_impl.h +++ b/src/arkode/arkode_lsrkstep_impl.h @@ -31,11 +31,11 @@ extern "C" { #endif -#define STAGE_MAX_LIMIT_DEFAULT 200 -#define DOM_EIG_SAFETY_DEFAULT SUN_RCONST(1.01) -#define DOM_EIG_FREQ_DEFAULT 25 -#define DEE_KRYLOV_DIM_DEFAULT 3 -#define DEE_MAX_NUMBER_OF_POWER_ITERS_DEFAULT 100 +#define STAGE_MAX_LIMIT_DEFAULT 200 +#define DOM_EIG_SAFETY_DEFAULT SUN_RCONST(1.01) +#define DOM_EIG_FREQ_DEFAULT 25 +#define DEE_KRYLOV_DIM_DEFAULT 3 +#define DEE_MAX_NUMBER_OF_POWER_ITERS_DEFAULT 100 /*=============================================================== LSRK time step module private math function macros @@ -163,8 +163,8 @@ typedef struct ARKodeLSRKStepMemRec long int dom_eig_freq; /* indicates dom_eig update after dom_eig_freq successful steps*/ SUNDomEigEstimator_ID DDE_ID; /* DEE ID */ - SUNDomEigEstimator DEE; /* DomEig estimator*/ - int dee_krydim; /* Krylov subspace dimension */ + SUNDomEigEstimator DEE; /* DomEig estimator*/ + int dee_krydim; /* Krylov subspace dimension */ int dee_numwarmups; /* Power of A in the preprocessing; initial q = A^{dee_numwarmups}q/||A^{dee_numwarmups}q|| */ int dee_maxiters; /* Max number of Power Iterations */ diff --git a/src/arkode/arkode_lsrkstep_io.c b/src/arkode/arkode_lsrkstep_io.c index ec82fcff7e..9b95652794 100644 --- a/src/arkode/arkode_lsrkstep_io.c +++ b/src/arkode/arkode_lsrkstep_io.c @@ -239,8 +239,8 @@ int LSRKStepSetDomEigFn(void* arkode_mem, ARKDomEigFn dom_eig) /*--------------------------------------------------------------- LSRKStepSetDEECreateWithID creates DomEigEst with ID. ---------------------------------------------------------------*/ -SUNDIALS_EXPORT int LSRKStepSetDEECreateWithID( - void* arkode_mem, SUNDomEigEstimator_ID DEE_id) +SUNDIALS_EXPORT int LSRKStepSetDEECreateWithID(void* arkode_mem, + SUNDomEigEstimator_ID DEE_id) { ARKodeMem ark_mem; ARKodeLSRKStepMem step_mem; @@ -270,16 +270,15 @@ SUNDIALS_EXPORT int LSRKStepSetDEECreateWithID( step_mem->DEE = lsrkStep_DomEigCreate(arkode_mem); } #else - arkProcessError(ark_mem, ARK_DEE_FAIL, __LINE__, __func__, - __FILE__, + arkProcessError(ark_mem, ARK_DEE_FAIL, __LINE__, __func__, __FILE__, "Sundials Arnoldi DDE requires LAPACK package"); return ARK_DEE_FAIL; #endif } else { - arkProcessError(ark_mem, ARK_DEE_FAIL, __LINE__, __func__, - __FILE__, "Attempted to set a DDE with an unknown type"); + arkProcessError(ark_mem, ARK_DEE_FAIL, __LINE__, __func__, __FILE__, + "Attempted to set a DDE with an unknown type"); return ARK_DEE_FAIL; } return ARK_SUCCESS; @@ -553,7 +552,7 @@ int LSRKStepGetMaxNumStages(void* arkode_mem, int* stage_max) Returns the number of RHS evals in DQ Jacobian computations ---------------------------------------------------------------*/ -SUNDIALS_EXPORT int LSRKStepGetNumRHSinDQ(void* arkode_mem, int* nfeDQ) +SUNDIALS_EXPORT int LSRKStepGetNumRHSinDQ(void* arkode_mem, long int* nfeDQ) { ARKodeMem ark_mem; ARKodeLSRKStepMem step_mem; diff --git a/src/arkode/fmod_int32/farkode_lsrkstep_mod.c b/src/arkode/fmod_int32/farkode_lsrkstep_mod.c index ba2f9a5d5e..c360ea74e8 100644 --- a/src/arkode/fmod_int32/farkode_lsrkstep_mod.c +++ b/src/arkode/fmod_int32/farkode_lsrkstep_mod.c @@ -178,6 +178,21 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_nonnull(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if (!(SWIG_CLASS_WRAPPER).cptr) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass null " TYPENAME " (class " FNAME ") " \ + "as a reference", RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -192,15 +207,15 @@ * the fortran.cxx file. */ #define SWIG_contract_assert(RETURNNULL, EXPR, MSG) \ - if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); } + if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); } -#define SWIGVERSION 0x040000 +#define SWIGVERSION 0x040000 #define SWIG_VERSION SWIGVERSION -#define SWIG_as_voidptr(a) (void *)((const void *)(a)) -#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) +#define SWIG_as_voidptr(a) (void *)((const void *)(a)) +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) #include "arkode/arkode_lsrkstep.h" @@ -230,6 +245,20 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { return result; } + +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + SWIGEXPORT void * _wrap_FLSRKStepCreateSTS(ARKRhsFn farg1, double const *farg2, N_Vector farg3, void *farg4) { void * fresult ; ARKRhsFn arg1 = (ARKRhsFn) 0 ; @@ -237,7 +266,7 @@ SWIGEXPORT void * _wrap_FLSRKStepCreateSTS(ARKRhsFn farg1, double const *farg2, N_Vector arg3 = (N_Vector) 0 ; SUNContext arg4 = (SUNContext) 0 ; void *result = 0 ; - + arg1 = (ARKRhsFn)(farg1); arg2 = (sunrealtype)(*farg2); arg3 = (N_Vector)(farg3); @@ -255,7 +284,7 @@ SWIGEXPORT void * _wrap_FLSRKStepCreateSSP(ARKRhsFn farg1, double const *farg2, N_Vector arg3 = (N_Vector) 0 ; SUNContext arg4 = (SUNContext) 0 ; void *result = 0 ; - + arg1 = (ARKRhsFn)(farg1); arg2 = (sunrealtype)(*farg2); arg3 = (N_Vector)(farg3); @@ -273,7 +302,7 @@ SWIGEXPORT int _wrap_FLSRKStepReInitSTS(void *farg1, ARKRhsFn farg2, double cons sunrealtype arg3 ; N_Vector arg4 = (N_Vector) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (ARKRhsFn)(farg2); arg3 = (sunrealtype)(*farg3); @@ -291,7 +320,7 @@ SWIGEXPORT int _wrap_FLSRKStepReInitSSP(void *farg1, ARKRhsFn farg2, double cons sunrealtype arg3 ; N_Vector arg4 = (N_Vector) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (ARKRhsFn)(farg2); arg3 = (sunrealtype)(*farg3); @@ -307,7 +336,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetSTSMethod(void *farg1, int const *farg2) { void *arg1 = (void *) 0 ; ARKODE_LSRKMethodType arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (ARKODE_LSRKMethodType)(*farg2); result = (int)LSRKStepSetSTSMethod(arg1,arg2); @@ -321,7 +350,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetSSPMethod(void *farg1, int const *farg2) { void *arg1 = (void *) 0 ; ARKODE_LSRKMethodType arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (ARKODE_LSRKMethodType)(*farg2); result = (int)LSRKStepSetSSPMethod(arg1,arg2); @@ -335,7 +364,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetSTSMethodByName(void *farg1, SwigArrayWrapper * void *arg1 = (void *) 0 ; char *arg2 = (char *) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (char *)(farg2->data); result = (int)LSRKStepSetSTSMethodByName(arg1,(char const *)arg2); @@ -349,7 +378,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetSSPMethodByName(void *farg1, SwigArrayWrapper * void *arg1 = (void *) 0 ; char *arg2 = (char *) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (char *)(farg2->data); result = (int)LSRKStepSetSSPMethodByName(arg1,(char const *)arg2); @@ -363,7 +392,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetDomEigFn(void *farg1, ARKDomEigFn farg2) { void *arg1 = (void *) 0 ; ARKDomEigFn arg2 = (ARKDomEigFn) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (ARKDomEigFn)(farg2); result = (int)LSRKStepSetDomEigFn(arg1,arg2); @@ -372,14 +401,15 @@ SWIGEXPORT int _wrap_FLSRKStepSetDomEigFn(void *farg1, ARKDomEigFn farg2) { } -SWIGEXPORT int _wrap_FLSRKStepSetDEECreateWithID(void *farg1, int const *farg2) { +SWIGEXPORT int _wrap_FLSRKStepSetDEECreateWithID(void *farg1, SwigClassWrapper const *farg2) { int fresult ; void *arg1 = (void *) 0 ; SUNDomEigEstimator_ID arg2 ; int result; - + arg1 = (void *)(farg1); - arg2 = (SUNDomEigEstimator_ID)(*farg2); + SWIG_check_nonnull(*farg2, "SUNDomEigEstimator_ID", "SWIGTYPE_p_SUNDomEigEstimator_ID", "LSRKStepSetDEECreateWithID(void *,SUNDomEigEstimator_ID)", return 0); + arg2 = *(SUNDomEigEstimator_ID *)(farg2->cptr); result = (int)LSRKStepSetDEECreateWithID(arg1,arg2); fresult = (int)(result); return fresult; @@ -391,7 +421,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetDomEigFrequency(void *farg1, long const *farg2) void *arg1 = (void *) 0 ; long arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (long)(*farg2); result = (int)LSRKStepSetDomEigFrequency(arg1,arg2); @@ -405,7 +435,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetMaxNumStages(void *farg1, int const *farg2) { void *arg1 = (void *) 0 ; int arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (int)(*farg2); result = (int)LSRKStepSetMaxNumStages(arg1,arg2); @@ -419,7 +449,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetDomEigSafetyFactor(void *farg1, double const *f void *arg1 = (void *) 0 ; sunrealtype arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (sunrealtype)(*farg2); result = (int)LSRKStepSetDomEigSafetyFactor(arg1,arg2); @@ -433,7 +463,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetNumSSPStages(void *farg1, int const *farg2) { void *arg1 = (void *) 0 ; int arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (int)(*farg2); result = (int)LSRKStepSetNumSSPStages(arg1,arg2); @@ -447,7 +477,7 @@ SWIGEXPORT int _wrap_FLSRKStepGetNumDomEigUpdates(void *farg1, long *farg2) { void *arg1 = (void *) 0 ; long *arg2 = (long *) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (long *)(farg2); result = (int)LSRKStepGetNumDomEigUpdates(arg1,arg2); @@ -461,7 +491,7 @@ SWIGEXPORT int _wrap_FLSRKStepGetMaxNumStages(void *farg1, int *farg2) { void *arg1 = (void *) 0 ; int *arg2 = (int *) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (int *)(farg2); result = (int)LSRKStepGetMaxNumStages(arg1,arg2); @@ -470,4 +500,18 @@ SWIGEXPORT int _wrap_FLSRKStepGetMaxNumStages(void *farg1, int *farg2) { } +SWIGEXPORT int _wrap_FLSRKStepGetNumRHSinDQ(void *farg1, int *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + int *arg2 = (int *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (int *)(farg2); + result = (int)LSRKStepGetNumRHSinDQ(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + diff --git a/src/arkode/fmod_int32/farkode_lsrkstep_mod.f90 b/src/arkode/fmod_int32/farkode_lsrkstep_mod.f90 index a9f10a03bf..cc763f6b0e 100644 --- a/src/arkode/fmod_int32/farkode_lsrkstep_mod.f90 +++ b/src/arkode/fmod_int32/farkode_lsrkstep_mod.f90 @@ -36,13 +36,6 @@ module farkode_lsrkstep_mod end enum integer, parameter, public :: ARKODE_LSRKMethodType = kind(ARKODE_LSRK_RKC_2) public :: ARKODE_LSRK_RKC_2, ARKODE_LSRK_RKL_2, ARKODE_LSRK_SSP_S_2, ARKODE_LSRK_SSP_S_3, ARKODE_LSRK_SSP_10_4 - ! typedef enum SUNDomEigEstimator_ID - enum, bind(c) - enumerator :: SUNDSOMEIGESTIMATOR_POWER - enumerator :: SUNDSOMEIGESTIMATOR_ARNOLDI - end enum - integer, parameter, public :: SUNDomEigEstimator_ID = kind(SUNDSOMEIGESTIMATOR_POWER) - public :: SUNDSOMEIGESTIMATOR_POWER, SUNDSOMEIGESTIMATOR_ARNOLDI public :: FLSRKStepCreateSTS public :: FLSRKStepCreateSSP public :: FLSRKStepReInitSTS @@ -56,6 +49,17 @@ module farkode_lsrkstep_mod public :: FLSRKStepSetSTSMethodByName public :: FLSRKStepSetSSPMethodByName public :: FLSRKStepSetDomEigFn + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_SUNDomEigEstimator_ID + type(SwigClassWrapper), public :: swigdata + end type public :: FLSRKStepSetDEECreateWithID public :: FLSRKStepSetDomEigFrequency public :: FLSRKStepSetMaxNumStages @@ -63,6 +67,7 @@ module farkode_lsrkstep_mod public :: FLSRKStepSetNumSSPStages public :: FLSRKStepGetNumDomEigUpdates public :: FLSRKStepGetMaxNumStages + public :: FLSRKStepGetNumRHSinDQ ! WRAPPER DECLARATIONS interface @@ -161,8 +166,9 @@ function swigc_FLSRKStepSetDEECreateWithID(farg1, farg2) & bind(C, name="_wrap_FLSRKStepSetDEECreateWithID") & result(fresult) use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper type(C_PTR), value :: farg1 -integer(C_INT), intent(in) :: farg2 +type(SwigClassWrapper) :: farg2 integer(C_INT) :: fresult end function @@ -220,6 +226,15 @@ function swigc_FLSRKStepGetMaxNumStages(farg1, farg2) & integer(C_INT) :: fresult end function +function swigc_FLSRKStepGetNumRHSinDQ(farg1, farg2) & +bind(C, name="_wrap_FLSRKStepGetNumRHSinDQ") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + end interface @@ -233,11 +248,11 @@ function FLSRKStepCreateSTS(rhs, t0, y0, sunctx) & real(C_DOUBLE), intent(in) :: t0 type(N_Vector), target, intent(inout) :: y0 type(C_PTR) :: sunctx -type(C_PTR) :: fresult -type(C_FUNPTR) :: farg1 -real(C_DOUBLE) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 +type(C_PTR) :: fresult +type(C_FUNPTR) :: farg1 +real(C_DOUBLE) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 farg1 = rhs farg2 = t0 @@ -255,11 +270,11 @@ function FLSRKStepCreateSSP(rhs, t0, y0, sunctx) & real(C_DOUBLE), intent(in) :: t0 type(N_Vector), target, intent(inout) :: y0 type(C_PTR) :: sunctx -type(C_PTR) :: fresult -type(C_FUNPTR) :: farg1 -real(C_DOUBLE) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 +type(C_PTR) :: fresult +type(C_FUNPTR) :: farg1 +real(C_DOUBLE) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 farg1 = rhs farg2 = t0 @@ -277,11 +292,11 @@ function FLSRKStepReInitSTS(arkode_mem, rhs, t0, y0) & type(C_FUNPTR), intent(in), value :: rhs real(C_DOUBLE), intent(in) :: t0 type(N_Vector), target, intent(inout) :: y0 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -real(C_DOUBLE) :: farg3 -type(C_PTR) :: farg4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +real(C_DOUBLE) :: farg3 +type(C_PTR) :: farg4 farg1 = arkode_mem farg2 = rhs @@ -299,11 +314,11 @@ function FLSRKStepReInitSSP(arkode_mem, rhs, t0, y0) & type(C_FUNPTR), intent(in), value :: rhs real(C_DOUBLE), intent(in) :: t0 type(N_Vector), target, intent(inout) :: y0 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -real(C_DOUBLE) :: farg3 -type(C_PTR) :: farg4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +real(C_DOUBLE) :: farg3 +type(C_PTR) :: farg4 farg1 = arkode_mem farg2 = rhs @@ -319,9 +334,9 @@ function FLSRKStepSetSTSMethod(arkode_mem, method) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(ARKODE_LSRKMethodType), intent(in) :: method -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = method @@ -335,9 +350,9 @@ function FLSRKStepSetSSPMethod(arkode_mem, method) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(ARKODE_LSRKMethodType), intent(in) :: method -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = method @@ -370,9 +385,9 @@ function FLSRKStepSetSTSMethodByName(arkode_mem, emethod) & type(C_PTR) :: arkode_mem character(kind=C_CHAR, len=*), target :: emethod character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 farg1 = arkode_mem call SWIG_string_to_chararray(emethod, farg2_chars, farg2) @@ -387,9 +402,9 @@ function FLSRKStepSetSSPMethodByName(arkode_mem, emethod) & type(C_PTR) :: arkode_mem character(kind=C_CHAR, len=*), target :: emethod character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 farg1 = arkode_mem call SWIG_string_to_chararray(emethod, farg2_chars, farg2) @@ -403,9 +418,9 @@ function FLSRKStepSetDomEigFn(arkode_mem, dom_eig) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: dom_eig -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = dom_eig @@ -413,18 +428,18 @@ function FLSRKStepSetDomEigFn(arkode_mem, dom_eig) & swig_result = fresult end function -function FLSRKStepSetDEECreateWithID(arkode_mem, DEE_id) & +function FLSRKStepSetDEECreateWithID(arkode_mem, dee_id) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -integer(SUNDomEigEstimator_ID), intent(in) :: DEE_id -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +type(SWIGTYPE_p_SUNDomEigEstimator_ID), intent(in) :: dee_id +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigClassWrapper) :: farg2 farg1 = arkode_mem -farg2 = DEE_id +farg2 = dee_id%swigdata fresult = swigc_FLSRKStepSetDEECreateWithID(farg1, farg2) swig_result = fresult end function @@ -435,9 +450,9 @@ function FLSRKStepSetDomEigFrequency(arkode_mem, nsteps) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), intent(in) :: nsteps -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_LONG) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_LONG) :: farg2 farg1 = arkode_mem farg2 = nsteps @@ -451,9 +466,9 @@ function FLSRKStepSetMaxNumStages(arkode_mem, stage_max_limit) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: stage_max_limit -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = stage_max_limit @@ -467,9 +482,9 @@ function FLSRKStepSetDomEigSafetyFactor(arkode_mem, dom_eig_safety) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: dom_eig_safety -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = dom_eig_safety @@ -483,9 +498,9 @@ function FLSRKStepSetNumSSPStages(arkode_mem, num_of_stages) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: num_of_stages -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = num_of_stages @@ -499,9 +514,9 @@ function FLSRKStepGetNumDomEigUpdates(arkode_mem, dom_eig_num_evals) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: dom_eig_num_evals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(dom_eig_num_evals(1)) @@ -515,9 +530,9 @@ function FLSRKStepGetMaxNumStages(arkode_mem, stage_max) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), dimension(*), target, intent(inout) :: stage_max -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(stage_max(1)) @@ -525,5 +540,21 @@ function FLSRKStepGetMaxNumStages(arkode_mem, stage_max) & swig_result = fresult end function +function FLSRKStepGetNumRHSinDQ(arkode_mem, nfedq) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT), dimension(*), target, intent(inout) :: nfedq +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(nfedq(1)) +fresult = swigc_FLSRKStepGetNumRHSinDQ(farg1, farg2) +swig_result = fresult +end function + end module diff --git a/src/arkode/fmod_int32/farkode_mod.f90 b/src/arkode/fmod_int32/farkode_mod.f90 index 5ab1cc1363..426332015a 100644 --- a/src/arkode/fmod_int32/farkode_mod.f90 +++ b/src/arkode/fmod_int32/farkode_mod.f90 @@ -2520,13 +2520,13 @@ function FARKodeResize(arkode_mem, ynew, hscale, t0, resize, resize_data) & real(C_DOUBLE), intent(in) :: t0 type(C_FUNPTR), intent(in), value :: resize type(C_PTR) :: resize_data -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -real(C_DOUBLE) :: farg3 -real(C_DOUBLE) :: farg4 -type(C_FUNPTR) :: farg5 -type(C_PTR) :: farg6 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +real(C_DOUBLE) :: farg3 +real(C_DOUBLE) :: farg4 +type(C_FUNPTR) :: farg5 +type(C_PTR) :: farg6 farg1 = arkode_mem farg2 = c_loc(ynew) @@ -2545,10 +2545,10 @@ function FARKodeReset(arkode_mem, tr, yr) & type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: tr type(N_Vector), target, intent(inout) :: yr -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = tr @@ -2563,9 +2563,9 @@ function FARKodeCreateMRIStepInnerStepper(arkode_mem, stepper) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_PTR), target, intent(inout) :: stepper -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(stepper) @@ -2580,10 +2580,10 @@ function FARKodeSStolerances(arkode_mem, reltol, abstol) & type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: reltol real(C_DOUBLE), intent(in) :: abstol -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 farg1 = arkode_mem farg2 = reltol @@ -2599,10 +2599,10 @@ function FARKodeSVtolerances(arkode_mem, reltol, abstol) & type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: reltol type(N_Vector), target, intent(inout) :: abstol -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = reltol @@ -2617,9 +2617,9 @@ function FARKodeWFtolerances(arkode_mem, efun) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: efun -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = efun @@ -2633,9 +2633,9 @@ function FARKodeResStolerance(arkode_mem, rabstol) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: rabstol -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = rabstol @@ -2649,9 +2649,9 @@ function FARKodeResVtolerance(arkode_mem, rabstol) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(N_Vector), target, intent(inout) :: rabstol -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(rabstol) @@ -2665,9 +2665,9 @@ function FARKodeResFtolerance(arkode_mem, rfun) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: rfun -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = rfun @@ -2682,10 +2682,10 @@ function FARKodeRootInit(arkode_mem, nrtfn, g) & type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: nrtfn type(C_FUNPTR), intent(in), value :: g -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 -type(C_FUNPTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 +type(C_FUNPTR) :: farg3 farg1 = arkode_mem farg2 = nrtfn @@ -2700,9 +2700,9 @@ function FARKodeSetRootDirection(arkode_mem, rootdir) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), dimension(*), target, intent(inout) :: rootdir -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(rootdir(1)) @@ -2715,8 +2715,8 @@ function FARKodeSetNoInactiveRootWarn(arkode_mem) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -integer(C_INT) :: fresult -type(C_PTR) :: farg1 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 farg1 = arkode_mem fresult = swigc_FARKodeSetNoInactiveRootWarn(farg1) @@ -2728,8 +2728,8 @@ function FARKodeSetDefaults(arkode_mem) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -integer(C_INT) :: fresult -type(C_PTR) :: farg1 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 farg1 = arkode_mem fresult = swigc_FARKodeSetDefaults(farg1) @@ -2742,9 +2742,9 @@ function FARKodeSetOrder(arkode_mem, maxord) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: maxord -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = maxord @@ -2758,9 +2758,9 @@ function FARKodeSetInterpolantType(arkode_mem, itype) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: itype -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = itype @@ -2774,9 +2774,9 @@ function FARKodeSetInterpolantDegree(arkode_mem, degree) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: degree -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = degree @@ -2790,9 +2790,9 @@ function FARKodeSetMaxNumSteps(arkode_mem, mxsteps) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), intent(in) :: mxsteps -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_LONG) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_LONG) :: farg2 farg1 = arkode_mem farg2 = mxsteps @@ -2806,9 +2806,9 @@ function FARKodeSetInterpolateStopTime(arkode_mem, interp) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: interp -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = interp @@ -2822,9 +2822,9 @@ function FARKodeSetStopTime(arkode_mem, tstop) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: tstop -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = tstop @@ -2837,8 +2837,8 @@ function FARKodeClearStopTime(arkode_mem) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -integer(C_INT) :: fresult -type(C_PTR) :: farg1 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 farg1 = arkode_mem fresult = swigc_FARKodeClearStopTime(farg1) @@ -2851,9 +2851,9 @@ function FARKodeSetFixedStep(arkode_mem, hfixed) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: hfixed -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = hfixed @@ -2867,9 +2867,9 @@ function FARKodeSetStepDirection(arkode_mem, stepdir) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: stepdir -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = stepdir @@ -2883,9 +2883,9 @@ function FARKodeSetUserData(arkode_mem, user_data) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_PTR) :: user_data -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = user_data @@ -2899,9 +2899,9 @@ function FARKodeSetPostprocessStepFn(arkode_mem, processstep) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: processstep -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = processstep @@ -2915,9 +2915,9 @@ function FARKodeSetPostprocessStageFn(arkode_mem, processstage) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: processstage -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = processstage @@ -2931,9 +2931,9 @@ function FARKodeSetNonlinearSolver(arkode_mem, nls) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(SUNNonlinearSolver), target, intent(inout) :: nls -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nls) @@ -2947,9 +2947,9 @@ function FARKodeSetLinear(arkode_mem, timedepend) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: timedepend -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = timedepend @@ -2962,8 +2962,8 @@ function FARKodeSetNonlinear(arkode_mem) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -integer(C_INT) :: fresult -type(C_PTR) :: farg1 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 farg1 = arkode_mem fresult = swigc_FARKodeSetNonlinear(farg1) @@ -2976,9 +2976,9 @@ function FARKodeSetAutonomous(arkode_mem, autonomous) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: autonomous -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = autonomous @@ -2992,9 +2992,9 @@ function FARKodeSetNlsRhsFn(arkode_mem, nls_fi) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: nls_fi -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = nls_fi @@ -3008,9 +3008,9 @@ function FARKodeSetDeduceImplicitRhs(arkode_mem, deduce) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: deduce -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = deduce @@ -3024,9 +3024,9 @@ function FARKodeSetNonlinCRDown(arkode_mem, crdown) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: crdown -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = crdown @@ -3040,9 +3040,9 @@ function FARKodeSetNonlinRDiv(arkode_mem, rdiv) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: rdiv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = rdiv @@ -3056,9 +3056,9 @@ function FARKodeSetDeltaGammaMax(arkode_mem, dgmax) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: dgmax -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = dgmax @@ -3072,9 +3072,9 @@ function FARKodeSetLSetupFrequency(arkode_mem, msbp) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: msbp -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = msbp @@ -3088,9 +3088,9 @@ function FARKodeSetPredictorMethod(arkode_mem, method) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: method -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = method @@ -3104,9 +3104,9 @@ function FARKodeSetMaxNonlinIters(arkode_mem, maxcor) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: maxcor -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = maxcor @@ -3120,9 +3120,9 @@ function FARKodeSetMaxConvFails(arkode_mem, maxncf) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: maxncf -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = maxncf @@ -3136,9 +3136,9 @@ function FARKodeSetNonlinConvCoef(arkode_mem, nlscoef) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: nlscoef -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = nlscoef @@ -3152,9 +3152,9 @@ function FARKodeSetStagePredictFn(arkode_mem, predictstage) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: predictstage -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = predictstage @@ -3168,9 +3168,9 @@ function FARKodeSetAdaptController(arkode_mem, c) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(SUNAdaptController), target, intent(inout) :: c -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(c) @@ -3203,9 +3203,9 @@ function FARKodeSetAdaptControllerByName(arkode_mem, cname) & type(C_PTR) :: arkode_mem character(kind=C_CHAR, len=*), target :: cname character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 farg1 = arkode_mem call SWIG_string_to_chararray(cname, farg2_chars, farg2) @@ -3219,9 +3219,9 @@ function FARKodeSetAdaptivityAdjustment(arkode_mem, adjust) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: adjust -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = adjust @@ -3235,9 +3235,9 @@ function FARKodeSetCFLFraction(arkode_mem, cfl_frac) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: cfl_frac -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = cfl_frac @@ -3251,9 +3251,9 @@ function FARKodeSetErrorBias(arkode_mem, bias) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: bias -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = bias @@ -3267,9 +3267,9 @@ function FARKodeSetSafetyFactor(arkode_mem, safety) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: safety -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = safety @@ -3283,9 +3283,9 @@ function FARKodeSetMaxGrowth(arkode_mem, mx_growth) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: mx_growth -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = mx_growth @@ -3299,9 +3299,9 @@ function FARKodeSetMinReduction(arkode_mem, eta_min) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: eta_min -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = eta_min @@ -3316,10 +3316,10 @@ function FARKodeSetFixedStepBounds(arkode_mem, lb, ub) & type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: lb real(C_DOUBLE), intent(in) :: ub -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 farg1 = arkode_mem farg2 = lb @@ -3334,9 +3334,9 @@ function FARKodeSetMaxFirstGrowth(arkode_mem, etamx1) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: etamx1 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = etamx1 @@ -3350,9 +3350,9 @@ function FARKodeSetMaxEFailGrowth(arkode_mem, etamxf) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: etamxf -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = etamxf @@ -3366,9 +3366,9 @@ function FARKodeSetSmallNumEFails(arkode_mem, small_nef) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: small_nef -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = small_nef @@ -3382,9 +3382,9 @@ function FARKodeSetMaxCFailGrowth(arkode_mem, etacf) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: etacf -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = etacf @@ -3399,10 +3399,10 @@ function FARKodeSetStabilityFn(arkode_mem, estab, estab_data) & type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: estab type(C_PTR) :: estab_data -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = estab @@ -3417,9 +3417,9 @@ function FARKodeSetMaxErrTestFails(arkode_mem, maxnef) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: maxnef -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = maxnef @@ -3433,9 +3433,9 @@ function FARKodeSetConstraints(arkode_mem, constraints) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(N_Vector), target, intent(inout) :: constraints -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(constraints) @@ -3449,9 +3449,9 @@ function FARKodeSetMaxHnilWarns(arkode_mem, mxhnil) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: mxhnil -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = mxhnil @@ -3465,9 +3465,9 @@ function FARKodeSetInitStep(arkode_mem, hin) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: hin -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = hin @@ -3481,9 +3481,9 @@ function FARKodeSetMinStep(arkode_mem, hmin) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: hmin -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = hmin @@ -3497,9 +3497,9 @@ function FARKodeSetMaxStep(arkode_mem, hmax) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: hmax -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = hmax @@ -3513,9 +3513,9 @@ function FARKodeSetMaxNumConstrFails(arkode_mem, maxfails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: maxfails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = maxfails @@ -3529,9 +3529,9 @@ function FARKodeSetAdjointCheckpointScheme(arkode_mem, checkpoint_scheme) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_PTR) :: checkpoint_scheme -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = checkpoint_scheme @@ -3545,9 +3545,9 @@ function FARKodeSetAdjointCheckpointIndex(arkode_mem, step_index) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), intent(in) :: step_index -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_LONG) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_LONG) :: farg2 farg1 = arkode_mem farg2 = step_index @@ -3561,9 +3561,9 @@ function FARKodeSetUseCompensatedSums(arkode_mem, onoff) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: onoff -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = onoff @@ -3577,9 +3577,9 @@ function FARKodeSetAccumulatedErrorType(arkode_mem, accum_type) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(ARKAccumError), intent(in) :: accum_type -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = accum_type @@ -3592,8 +3592,8 @@ function FARKodeResetAccumulatedError(arkode_mem) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -integer(C_INT) :: fresult -type(C_PTR) :: farg1 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 farg1 = arkode_mem fresult = swigc_FARKodeResetAccumulatedError(farg1) @@ -3609,12 +3609,12 @@ function FARKodeEvolve(arkode_mem, tout, yout, tret, itask) & type(N_Vector), target, intent(inout) :: yout real(C_DOUBLE), dimension(*), target, intent(inout) :: tret integer(C_INT), intent(in) :: itask -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 -integer(C_INT) :: farg5 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 +integer(C_INT) :: farg5 farg1 = arkode_mem farg2 = tout @@ -3633,11 +3633,11 @@ function FARKodeGetDky(arkode_mem, t, k, dky) & real(C_DOUBLE), intent(in) :: t integer(C_INT), intent(in) :: k type(N_Vector), target, intent(inout) :: dky -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -integer(C_INT) :: farg3 -type(C_PTR) :: farg4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +integer(C_INT) :: farg3 +type(C_PTR) :: farg4 farg1 = arkode_mem farg2 = t @@ -3654,10 +3654,10 @@ function FARKodeComputeState(arkode_mem, zcor, z) & type(C_PTR) :: arkode_mem type(N_Vector), target, intent(inout) :: zcor type(N_Vector), target, intent(inout) :: z -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = c_loc(zcor) @@ -3673,10 +3673,10 @@ function FARKodeGetNumRhsEvals(arkode_mem, partition_index, num_rhs_evals) & type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: partition_index integer(C_LONG), dimension(*), target, intent(inout) :: num_rhs_evals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = partition_index @@ -3691,9 +3691,9 @@ function FARKodeGetNumStepAttempts(arkode_mem, step_attempts) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: step_attempts -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(step_attempts(1)) @@ -3708,10 +3708,10 @@ function FARKodeGetWorkSpace(arkode_mem, lenrw, leniw) & type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: lenrw integer(C_LONG), dimension(*), target, intent(inout) :: leniw -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = c_loc(lenrw(1)) @@ -3726,9 +3726,9 @@ function FARKodeGetNumSteps(arkode_mem, nsteps) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nsteps -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nsteps(1)) @@ -3742,9 +3742,9 @@ function FARKodeGetLastStep(arkode_mem, hlast) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), dimension(*), target, intent(inout) :: hlast -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(hlast(1)) @@ -3758,9 +3758,9 @@ function FARKodeGetCurrentStep(arkode_mem, hcur) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), dimension(*), target, intent(inout) :: hcur -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(hcur(1)) @@ -3774,9 +3774,9 @@ function FARKodeGetStepDirection(arkode_mem, stepdir) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), dimension(*), target, intent(inout) :: stepdir -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(stepdir(1)) @@ -3790,9 +3790,9 @@ function FARKodeGetErrWeights(arkode_mem, eweight) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(N_Vector), target, intent(inout) :: eweight -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(eweight) @@ -3806,9 +3806,9 @@ function FARKodeGetNumGEvals(arkode_mem, ngevals) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: ngevals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(ngevals(1)) @@ -3822,9 +3822,9 @@ function FARKodeGetRootInfo(arkode_mem, rootsfound) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), dimension(*), target, intent(inout) :: rootsfound -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(rootsfound(1)) @@ -3838,9 +3838,9 @@ function FARKodeGetUserData(arkode_mem, user_data) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_PTR), target, intent(inout) :: user_data -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(user_data) @@ -3855,10 +3855,10 @@ function FARKodePrintAllStats(arkode_mem, outfile, fmt) & type(C_PTR) :: arkode_mem type(C_PTR) :: outfile integer(SUNOutputFormat), intent(in) :: fmt -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -integer(C_INT) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +integer(C_INT) :: farg3 farg1 = arkode_mem farg2 = outfile @@ -3886,8 +3886,8 @@ function FARKodeGetReturnFlagName(flag) & use, intrinsic :: ISO_C_BINDING character(kind=C_CHAR, len=:), allocatable :: swig_result integer(C_LONG), intent(in) :: flag -type(SwigArrayWrapper) :: fresult -integer(C_LONG) :: farg1 +type(SwigArrayWrapper) :: fresult +integer(C_LONG) :: farg1 farg1 = flag fresult = swigc_FARKodeGetReturnFlagName(farg1) @@ -3901,9 +3901,9 @@ function FARKodeWriteParameters(arkode_mem, fp) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_PTR) :: fp -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = fp @@ -3917,9 +3917,9 @@ function FARKodeGetNumExpSteps(arkode_mem, expsteps) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: expsteps -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(expsteps(1)) @@ -3933,9 +3933,9 @@ function FARKodeGetNumAccSteps(arkode_mem, accsteps) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: accsteps -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(accsteps(1)) @@ -3949,9 +3949,9 @@ function FARKodeGetNumErrTestFails(arkode_mem, netfails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: netfails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(netfails(1)) @@ -3965,9 +3965,9 @@ function FARKodeGetEstLocalErrors(arkode_mem, ele) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(N_Vector), target, intent(inout) :: ele -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(ele) @@ -3981,9 +3981,9 @@ function FARKodeGetActualInitStep(arkode_mem, hinused) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), dimension(*), target, intent(inout) :: hinused -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(hinused(1)) @@ -3997,9 +3997,9 @@ function FARKodeGetTolScaleFactor(arkode_mem, tolsfac) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), dimension(*), target, intent(inout) :: tolsfac -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(tolsfac(1)) @@ -4013,9 +4013,9 @@ function FARKodeGetNumConstrFails(arkode_mem, nconstrfails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nconstrfails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nconstrfails(1)) @@ -4033,13 +4033,13 @@ function FARKodeGetStepStats(arkode_mem, nsteps, hinused, hlast, hcur, tcur) & real(C_DOUBLE), dimension(*), target, intent(inout) :: hlast real(C_DOUBLE), dimension(*), target, intent(inout) :: hcur real(C_DOUBLE), dimension(*), target, intent(inout) :: tcur -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 -type(C_PTR) :: farg5 -type(C_PTR) :: farg6 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 +type(C_PTR) :: farg5 +type(C_PTR) :: farg6 farg1 = arkode_mem farg2 = c_loc(nsteps(1)) @@ -4057,9 +4057,9 @@ function FARKodeGetAccumulatedError(arkode_mem, accum_error) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), dimension(*), target, intent(inout) :: accum_error -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(accum_error(1)) @@ -4073,9 +4073,9 @@ function FARKodeGetNumLinSolvSetups(arkode_mem, nlinsetups) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nlinsetups -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nlinsetups(1)) @@ -4089,9 +4089,9 @@ function FARKodeGetCurrentTime(arkode_mem, tcur) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), dimension(*), target, intent(inout) :: tcur -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(tcur(1)) @@ -4105,9 +4105,9 @@ function FARKodeGetCurrentState(arkode_mem, state) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_PTR) :: state -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = state @@ -4121,9 +4121,9 @@ function FARKodeGetCurrentGamma(arkode_mem, gamma) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), dimension(*), target, intent(inout) :: gamma -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(gamma(1)) @@ -4143,15 +4143,15 @@ function FARKodeGetNonlinearSystemData(arkode_mem, tcur, zpred, z, fi, gamma, sd real(C_DOUBLE), dimension(*), target, intent(inout) :: gamma type(C_PTR) :: sdata type(C_PTR), target, intent(inout) :: user_data -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 -type(C_PTR) :: farg5 -type(C_PTR) :: farg6 -type(C_PTR) :: farg7 -type(C_PTR) :: farg8 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 +type(C_PTR) :: farg5 +type(C_PTR) :: farg6 +type(C_PTR) :: farg7 +type(C_PTR) :: farg8 farg1 = arkode_mem farg2 = c_loc(tcur(1)) @@ -4171,9 +4171,9 @@ function FARKodeGetNumNonlinSolvIters(arkode_mem, nniters) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nniters -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nniters(1)) @@ -4187,9 +4187,9 @@ function FARKodeGetNumNonlinSolvConvFails(arkode_mem, nnfails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nnfails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nnfails(1)) @@ -4204,10 +4204,10 @@ function FARKodeGetNonlinSolvStats(arkode_mem, nniters, nnfails) & type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nniters integer(C_LONG), dimension(*), target, intent(inout) :: nnfails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = c_loc(nniters(1)) @@ -4222,9 +4222,9 @@ function FARKodeGetNumStepSolveFails(arkode_mem, nncfails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nncfails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nncfails(1)) @@ -4238,9 +4238,9 @@ function FARKodeGetJac(arkode_mem, j) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_PTR), target, intent(inout) :: j -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(j) @@ -4254,9 +4254,9 @@ function FARKodeGetJacTime(arkode_mem, t_j) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), dimension(*), target, intent(inout) :: t_j -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(t_j(1)) @@ -4270,9 +4270,9 @@ function FARKodeGetJacNumSteps(arkode_mem, nst_j) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nst_j -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nst_j(1)) @@ -4287,10 +4287,10 @@ function FARKodeGetLinWorkSpace(arkode_mem, lenrwls, leniwls) & type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: lenrwls integer(C_LONG), dimension(*), target, intent(inout) :: leniwls -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = c_loc(lenrwls(1)) @@ -4305,9 +4305,9 @@ function FARKodeGetNumJacEvals(arkode_mem, njevals) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: njevals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(njevals(1)) @@ -4321,9 +4321,9 @@ function FARKodeGetNumPrecEvals(arkode_mem, npevals) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: npevals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(npevals(1)) @@ -4337,9 +4337,9 @@ function FARKodeGetNumPrecSolves(arkode_mem, npsolves) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: npsolves -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(npsolves(1)) @@ -4353,9 +4353,9 @@ function FARKodeGetNumLinIters(arkode_mem, nliters) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nliters -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nliters(1)) @@ -4369,9 +4369,9 @@ function FARKodeGetNumLinConvFails(arkode_mem, nlcfails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nlcfails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nlcfails(1)) @@ -4385,9 +4385,9 @@ function FARKodeGetNumJTSetupEvals(arkode_mem, njtsetups) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: njtsetups -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(njtsetups(1)) @@ -4401,9 +4401,9 @@ function FARKodeGetNumJtimesEvals(arkode_mem, njvevals) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: njvevals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(njvevals(1)) @@ -4417,9 +4417,9 @@ function FARKodeGetNumLinRhsEvals(arkode_mem, nfevalsls) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nfevalsls -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nfevalsls(1)) @@ -4433,9 +4433,9 @@ function FARKodeGetLastLinFlag(arkode_mem, flag) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: flag -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(flag(1)) @@ -4448,8 +4448,8 @@ function FARKodeGetLinReturnFlagName(flag) & use, intrinsic :: ISO_C_BINDING character(kind=C_CHAR, len=:), allocatable :: swig_result integer(C_LONG), intent(in) :: flag -type(SwigArrayWrapper) :: fresult -integer(C_LONG) :: farg1 +type(SwigArrayWrapper) :: fresult +integer(C_LONG) :: farg1 farg1 = flag fresult = swigc_FARKodeGetLinReturnFlagName(farg1) @@ -4463,9 +4463,9 @@ function FARKodeGetCurrentMassMatrix(arkode_mem, m) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_PTR), target, intent(inout) :: m -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(m) @@ -4479,9 +4479,9 @@ function FARKodeGetResWeights(arkode_mem, rweight) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(N_Vector), target, intent(inout) :: rweight -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(rweight) @@ -4496,10 +4496,10 @@ function FARKodeGetMassWorkSpace(arkode_mem, lenrwmls, leniwmls) & type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: lenrwmls integer(C_LONG), dimension(*), target, intent(inout) :: leniwmls -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = c_loc(lenrwmls(1)) @@ -4514,9 +4514,9 @@ function FARKodeGetNumMassSetups(arkode_mem, nmsetups) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nmsetups -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nmsetups(1)) @@ -4530,9 +4530,9 @@ function FARKodeGetNumMassMultSetups(arkode_mem, nmvsetups) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nmvsetups -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nmvsetups(1)) @@ -4546,9 +4546,9 @@ function FARKodeGetNumMassMult(arkode_mem, nmvevals) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nmvevals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nmvevals(1)) @@ -4562,9 +4562,9 @@ function FARKodeGetNumMassSolves(arkode_mem, nmsolves) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nmsolves -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nmsolves(1)) @@ -4578,9 +4578,9 @@ function FARKodeGetNumMassPrecEvals(arkode_mem, nmpevals) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nmpevals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nmpevals(1)) @@ -4594,9 +4594,9 @@ function FARKodeGetNumMassPrecSolves(arkode_mem, nmpsolves) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nmpsolves -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nmpsolves(1)) @@ -4610,9 +4610,9 @@ function FARKodeGetNumMassIters(arkode_mem, nmiters) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nmiters -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nmiters(1)) @@ -4626,9 +4626,9 @@ function FARKodeGetNumMassConvFails(arkode_mem, nmcfails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nmcfails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nmcfails(1)) @@ -4642,9 +4642,9 @@ function FARKodeGetNumMTSetups(arkode_mem, nmtsetups) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nmtsetups -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nmtsetups(1)) @@ -4658,9 +4658,9 @@ function FARKodeGetLastMassFlag(arkode_mem, flag) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: flag -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(flag(1)) @@ -4671,7 +4671,7 @@ function FARKodeGetLastMassFlag(arkode_mem, flag) & subroutine FARKodeFree(arkode_mem) use, intrinsic :: ISO_C_BINDING type(C_PTR), target, intent(inout) :: arkode_mem -type(C_PTR) :: farg1 +type(C_PTR) :: farg1 farg1 = c_loc(arkode_mem) call swigc_FARKodeFree(farg1) @@ -4681,8 +4681,8 @@ subroutine FARKodePrintMem(arkode_mem, outfile) use, intrinsic :: ISO_C_BINDING type(C_PTR) :: arkode_mem type(C_PTR) :: outfile -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = outfile @@ -4696,10 +4696,10 @@ function FARKodeSetRelaxFn(arkode_mem, rfn, rjac) & type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: rfn type(C_FUNPTR), intent(in), value :: rjac -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -type(C_FUNPTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +type(C_FUNPTR) :: farg3 farg1 = arkode_mem farg2 = rfn @@ -4714,9 +4714,9 @@ function FARKodeSetRelaxEtaFail(arkode_mem, eta_rf) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: eta_rf -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = eta_rf @@ -4730,9 +4730,9 @@ function FARKodeSetRelaxLowerBound(arkode_mem, lower) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: lower -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = lower @@ -4746,9 +4746,9 @@ function FARKodeSetRelaxMaxFails(arkode_mem, max_fails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: max_fails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = max_fails @@ -4762,9 +4762,9 @@ function FARKodeSetRelaxMaxIters(arkode_mem, max_iters) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: max_iters -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = max_iters @@ -4778,9 +4778,9 @@ function FARKodeSetRelaxSolver(arkode_mem, solver) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(ARKRelaxSolver), intent(in) :: solver -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = solver @@ -4794,9 +4794,9 @@ function FARKodeSetRelaxResTol(arkode_mem, res_tol) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: res_tol -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = res_tol @@ -4811,10 +4811,10 @@ function FARKodeSetRelaxTol(arkode_mem, rel_tol, abs_tol) & type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: rel_tol real(C_DOUBLE), intent(in) :: abs_tol -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 farg1 = arkode_mem farg2 = rel_tol @@ -4829,9 +4829,9 @@ function FARKodeSetRelaxUpperBound(arkode_mem, upper) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: upper -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = upper @@ -4845,9 +4845,9 @@ function FARKodeGetNumRelaxFnEvals(arkode_mem, r_evals) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: r_evals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(r_evals(1)) @@ -4861,9 +4861,9 @@ function FARKodeGetNumRelaxJacEvals(arkode_mem, j_evals) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: j_evals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(j_evals(1)) @@ -4877,9 +4877,9 @@ function FARKodeGetNumRelaxFails(arkode_mem, relax_fails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: relax_fails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(relax_fails(1)) @@ -4893,9 +4893,9 @@ function FARKodeGetNumRelaxBoundFails(arkode_mem, fails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: fails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(fails(1)) @@ -4909,9 +4909,9 @@ function FARKodeGetNumRelaxSolveFails(arkode_mem, fails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: fails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(fails(1)) @@ -4925,9 +4925,9 @@ function FARKodeGetNumRelaxSolveIters(arkode_mem, iters) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: iters -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(iters(1)) @@ -4941,9 +4941,9 @@ function FARKodeCreateSUNStepper(arkode_mem, stepper) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_PTR), target, intent(inout) :: stepper -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(stepper) @@ -4959,11 +4959,11 @@ function FARKBandPrecInit(arkode_mem, n, mu, ml) & integer(C_INT32_T), intent(in) :: n integer(C_INT32_T), intent(in) :: mu integer(C_INT32_T), intent(in) :: ml -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT32_T) :: farg2 -integer(C_INT32_T) :: farg3 -integer(C_INT32_T) :: farg4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT32_T) :: farg2 +integer(C_INT32_T) :: farg3 +integer(C_INT32_T) :: farg4 farg1 = arkode_mem farg2 = n @@ -4980,10 +4980,10 @@ function FARKBandPrecGetWorkSpace(arkode_mem, lenrwls, leniwls) & type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: lenrwls integer(C_LONG), dimension(*), target, intent(inout) :: leniwls -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = c_loc(lenrwls(1)) @@ -4998,9 +4998,9 @@ function FARKBandPrecGetNumRhsEvals(arkode_mem, nfevalsbp) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nfevalsbp -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nfevalsbp(1)) @@ -5021,16 +5021,16 @@ function FARKBBDPrecInit(arkode_mem, nlocal, mudq, mldq, mukeep, mlkeep, dqrely, real(C_DOUBLE), intent(in) :: dqrely type(C_FUNPTR), intent(in), value :: gloc type(C_FUNPTR), intent(in), value :: cfn -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT32_T) :: farg2 -integer(C_INT32_T) :: farg3 -integer(C_INT32_T) :: farg4 -integer(C_INT32_T) :: farg5 -integer(C_INT32_T) :: farg6 -real(C_DOUBLE) :: farg7 -type(C_FUNPTR) :: farg8 -type(C_FUNPTR) :: farg9 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT32_T) :: farg2 +integer(C_INT32_T) :: farg3 +integer(C_INT32_T) :: farg4 +integer(C_INT32_T) :: farg5 +integer(C_INT32_T) :: farg6 +real(C_DOUBLE) :: farg7 +type(C_FUNPTR) :: farg8 +type(C_FUNPTR) :: farg9 farg1 = arkode_mem farg2 = nlocal @@ -5053,11 +5053,11 @@ function FARKBBDPrecReInit(arkode_mem, mudq, mldq, dqrely) & integer(C_INT32_T), intent(in) :: mudq integer(C_INT32_T), intent(in) :: mldq real(C_DOUBLE), intent(in) :: dqrely -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT32_T) :: farg2 -integer(C_INT32_T) :: farg3 -real(C_DOUBLE) :: farg4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT32_T) :: farg2 +integer(C_INT32_T) :: farg3 +real(C_DOUBLE) :: farg4 farg1 = arkode_mem farg2 = mudq @@ -5074,10 +5074,10 @@ function FARKBBDPrecGetWorkSpace(arkode_mem, lenrwbbdp, leniwbbdp) & type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: lenrwbbdp integer(C_LONG), dimension(*), target, intent(inout) :: leniwbbdp -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = c_loc(lenrwbbdp(1)) @@ -5092,9 +5092,9 @@ function FARKBBDPrecGetNumGfnEvals(arkode_mem, ngevalsbbdp) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: ngevalsbbdp -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(ngevalsbbdp(1)) @@ -5106,8 +5106,8 @@ subroutine swigf_ARKodeButcherTableMem_q_set(self, q) use, intrinsic :: ISO_C_BINDING class(ARKodeButcherTableMem), intent(in) :: self integer(C_INT), intent(in) :: q -type(SwigClassWrapper) :: farg1 -integer(C_INT) :: farg2 +type(SwigClassWrapper) :: farg1 +integer(C_INT) :: farg2 farg1 = self%swigdata farg2 = q @@ -5119,8 +5119,8 @@ function swigf_ARKodeButcherTableMem_q_get(self) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result class(ARKodeButcherTableMem), intent(in) :: self -integer(C_INT) :: fresult -type(SwigClassWrapper) :: farg1 +integer(C_INT) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeButcherTableMem_q_get(farg1) @@ -5131,8 +5131,8 @@ subroutine swigf_ARKodeButcherTableMem_p_set(self, p) use, intrinsic :: ISO_C_BINDING class(ARKodeButcherTableMem), intent(in) :: self integer(C_INT), intent(in) :: p -type(SwigClassWrapper) :: farg1 -integer(C_INT) :: farg2 +type(SwigClassWrapper) :: farg1 +integer(C_INT) :: farg2 farg1 = self%swigdata farg2 = p @@ -5144,8 +5144,8 @@ function swigf_ARKodeButcherTableMem_p_get(self) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result class(ARKodeButcherTableMem), intent(in) :: self -integer(C_INT) :: fresult -type(SwigClassWrapper) :: farg1 +integer(C_INT) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeButcherTableMem_p_get(farg1) @@ -5156,8 +5156,8 @@ subroutine swigf_ARKodeButcherTableMem_stages_set(self, stages) use, intrinsic :: ISO_C_BINDING class(ARKodeButcherTableMem), intent(in) :: self integer(C_INT), intent(in) :: stages -type(SwigClassWrapper) :: farg1 -integer(C_INT) :: farg2 +type(SwigClassWrapper) :: farg1 +integer(C_INT) :: farg2 farg1 = self%swigdata farg2 = stages @@ -5169,8 +5169,8 @@ function swigf_ARKodeButcherTableMem_stages_get(self) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result class(ARKodeButcherTableMem), intent(in) :: self -integer(C_INT) :: fresult -type(SwigClassWrapper) :: farg1 +integer(C_INT) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeButcherTableMem_stages_get(farg1) @@ -5181,8 +5181,8 @@ subroutine swigf_ARKodeButcherTableMem_A_set(self, a) use, intrinsic :: ISO_C_BINDING class(ARKodeButcherTableMem), intent(in) :: self type(C_PTR), target, intent(inout) :: a -type(SwigClassWrapper) :: farg1 -type(C_PTR) :: farg2 +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: farg2 farg1 = self%swigdata farg2 = c_loc(a) @@ -5194,8 +5194,8 @@ function swigf_ARKodeButcherTableMem_A_get(self) & use, intrinsic :: ISO_C_BINDING type(C_PTR), pointer :: swig_result class(ARKodeButcherTableMem), intent(in) :: self -type(C_PTR) :: fresult -type(SwigClassWrapper) :: farg1 +type(C_PTR) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeButcherTableMem_A_get(farg1) @@ -5206,8 +5206,8 @@ subroutine swigf_ARKodeButcherTableMem_c_set(self, c) use, intrinsic :: ISO_C_BINDING class(ARKodeButcherTableMem), intent(in) :: self real(C_DOUBLE), dimension(*), target, intent(inout) :: c -type(SwigClassWrapper) :: farg1 -type(C_PTR) :: farg2 +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: farg2 farg1 = self%swigdata farg2 = c_loc(c(1)) @@ -5219,8 +5219,8 @@ function swigf_ARKodeButcherTableMem_c_get(self) & use, intrinsic :: ISO_C_BINDING real(C_DOUBLE), dimension(:), pointer :: swig_result class(ARKodeButcherTableMem), intent(in) :: self -type(C_PTR) :: fresult -type(SwigClassWrapper) :: farg1 +type(C_PTR) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeButcherTableMem_c_get(farg1) @@ -5231,8 +5231,8 @@ subroutine swigf_ARKodeButcherTableMem_b_set(self, b) use, intrinsic :: ISO_C_BINDING class(ARKodeButcherTableMem), intent(in) :: self real(C_DOUBLE), dimension(*), target, intent(inout) :: b -type(SwigClassWrapper) :: farg1 -type(C_PTR) :: farg2 +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: farg2 farg1 = self%swigdata farg2 = c_loc(b(1)) @@ -5244,8 +5244,8 @@ function swigf_ARKodeButcherTableMem_b_get(self) & use, intrinsic :: ISO_C_BINDING real(C_DOUBLE), dimension(:), pointer :: swig_result class(ARKodeButcherTableMem), intent(in) :: self -type(C_PTR) :: fresult -type(SwigClassWrapper) :: farg1 +type(C_PTR) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeButcherTableMem_b_get(farg1) @@ -5256,8 +5256,8 @@ subroutine swigf_ARKodeButcherTableMem_d_set(self, d) use, intrinsic :: ISO_C_BINDING class(ARKodeButcherTableMem), intent(in) :: self real(C_DOUBLE), dimension(*), target, intent(inout) :: d -type(SwigClassWrapper) :: farg1 -type(C_PTR) :: farg2 +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: farg2 farg1 = self%swigdata farg2 = c_loc(d(1)) @@ -5269,8 +5269,8 @@ function swigf_ARKodeButcherTableMem_d_get(self) & use, intrinsic :: ISO_C_BINDING real(C_DOUBLE), dimension(:), pointer :: swig_result class(ARKodeButcherTableMem), intent(in) :: self -type(C_PTR) :: fresult -type(SwigClassWrapper) :: farg1 +type(C_PTR) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeButcherTableMem_d_get(farg1) @@ -5281,7 +5281,7 @@ function swigf_create_ARKodeButcherTableMem() & result(self) use, intrinsic :: ISO_C_BINDING type(ARKodeButcherTableMem) :: self -type(SwigClassWrapper) :: fresult +type(SwigClassWrapper) :: fresult fresult = swigc_new_ARKodeButcherTableMem() self%swigdata = fresult @@ -5290,7 +5290,7 @@ function swigf_create_ARKodeButcherTableMem() & subroutine swigf_release_ARKodeButcherTableMem(self) use, intrinsic :: ISO_C_BINDING class(ARKodeButcherTableMem), intent(inout) :: self -type(SwigClassWrapper) :: farg1 +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata if (btest(farg1%cmemflags, swig_cmem_own_bit)) then @@ -5305,8 +5305,8 @@ subroutine swigf_ARKodeButcherTableMem_op_assign__(self, other) use, intrinsic :: ISO_C_BINDING class(ARKodeButcherTableMem), intent(inout) :: self type(ARKodeButcherTableMem), intent(in) :: other -type(SwigClassWrapper) :: farg1 -type(SwigClassWrapper) :: farg2 +type(SwigClassWrapper) :: farg1 +type(SwigClassWrapper) :: farg2 farg1 = self%swigdata farg2 = other%swigdata @@ -5320,9 +5320,9 @@ function FARKodeButcherTable_Alloc(stages, embedded) & type(C_PTR) :: swig_result integer(C_INT), intent(in) :: stages integer(C_INT), intent(in) :: embedded -type(C_PTR) :: fresult -integer(C_INT) :: farg1 -integer(C_INT) :: farg2 +type(C_PTR) :: fresult +integer(C_INT) :: farg1 +integer(C_INT) :: farg2 farg1 = stages farg2 = embedded @@ -5341,14 +5341,14 @@ function FARKodeButcherTable_Create(s, q, p, c, a, b, d) & real(C_DOUBLE), dimension(*), target, intent(inout) :: a real(C_DOUBLE), dimension(*), target, intent(inout) :: b real(C_DOUBLE), dimension(*), target, intent(inout) :: d -type(C_PTR) :: fresult -integer(C_INT) :: farg1 -integer(C_INT) :: farg2 -integer(C_INT) :: farg3 -type(C_PTR) :: farg4 -type(C_PTR) :: farg5 -type(C_PTR) :: farg6 -type(C_PTR) :: farg7 +type(C_PTR) :: fresult +integer(C_INT) :: farg1 +integer(C_INT) :: farg2 +integer(C_INT) :: farg3 +type(C_PTR) :: farg4 +type(C_PTR) :: farg5 +type(C_PTR) :: farg6 +type(C_PTR) :: farg7 farg1 = s farg2 = q @@ -5366,8 +5366,8 @@ function FARKodeButcherTable_Copy(b) & use, intrinsic :: ISO_C_BINDING type(C_PTR) :: swig_result type(C_PTR) :: b -type(C_PTR) :: fresult -type(C_PTR) :: farg1 +type(C_PTR) :: fresult +type(C_PTR) :: farg1 farg1 = b fresult = swigc_FARKodeButcherTable_Copy(farg1) @@ -5379,9 +5379,9 @@ subroutine FARKodeButcherTable_Space(b, liw, lrw) type(C_PTR) :: b integer(C_INT32_T), dimension(*), target, intent(inout) :: liw integer(C_INT32_T), dimension(*), target, intent(inout) :: lrw -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = b farg2 = c_loc(liw(1)) @@ -5392,7 +5392,7 @@ subroutine FARKodeButcherTable_Space(b, liw, lrw) subroutine FARKodeButcherTable_Free(b) use, intrinsic :: ISO_C_BINDING type(C_PTR) :: b -type(C_PTR) :: farg1 +type(C_PTR) :: farg1 farg1 = b call swigc_FARKodeButcherTable_Free(farg1) @@ -5402,8 +5402,8 @@ subroutine FARKodeButcherTable_Write(b, outfile) use, intrinsic :: ISO_C_BINDING type(C_PTR) :: b type(C_PTR) :: outfile -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = b farg2 = outfile @@ -5415,8 +5415,8 @@ function FARKodeButcherTable_IsStifflyAccurate(b) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: b -integer(C_INT) :: fresult -type(C_PTR) :: farg1 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 farg1 = b fresult = swigc_FARKodeButcherTable_IsStifflyAccurate(farg1) @@ -5431,11 +5431,11 @@ function FARKodeButcherTable_CheckOrder(b, q, p, outfile) & integer(C_INT), dimension(*), target, intent(inout) :: q integer(C_INT), dimension(*), target, intent(inout) :: p type(C_PTR) :: outfile -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 farg1 = b farg2 = c_loc(q(1)) @@ -5454,12 +5454,12 @@ function FARKodeButcherTable_CheckARKOrder(b1, b2, q, p, outfile) & integer(C_INT), dimension(*), target, intent(inout) :: q integer(C_INT), dimension(*), target, intent(inout) :: p type(C_PTR) :: outfile -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 -type(C_PTR) :: farg5 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 +type(C_PTR) :: farg5 farg1 = b1 farg2 = b2 @@ -5475,8 +5475,8 @@ function FARKodeButcherTable_LoadDIRK(imethod) & use, intrinsic :: ISO_C_BINDING type(C_PTR) :: swig_result integer(ARKODE_DIRKTableID), intent(in) :: imethod -type(C_PTR) :: fresult -integer(C_INT) :: farg1 +type(C_PTR) :: fresult +integer(C_INT) :: farg1 farg1 = imethod fresult = swigc_FARKodeButcherTable_LoadDIRK(farg1) @@ -5489,8 +5489,8 @@ function FARKodeButcherTable_LoadDIRKByName(imethod) & type(C_PTR) :: swig_result character(kind=C_CHAR, len=*), target :: imethod character(kind=C_CHAR), dimension(:), allocatable, target :: farg1_chars -type(C_PTR) :: fresult -type(SwigArrayWrapper) :: farg1 +type(C_PTR) :: fresult +type(SwigArrayWrapper) :: farg1 call SWIG_string_to_chararray(imethod, farg1_chars, farg1) fresult = swigc_FARKodeButcherTable_LoadDIRKByName(farg1) @@ -5502,8 +5502,8 @@ function FARKodeButcherTable_DIRKIDToName(imethod) & use, intrinsic :: ISO_C_BINDING character(kind=C_CHAR, len=:), allocatable :: swig_result integer(ARKODE_DIRKTableID), intent(in) :: imethod -type(SwigArrayWrapper) :: fresult -integer(C_INT) :: farg1 +type(SwigArrayWrapper) :: fresult +integer(C_INT) :: farg1 farg1 = imethod fresult = swigc_FARKodeButcherTable_DIRKIDToName(farg1) @@ -5516,8 +5516,8 @@ function FARKodeButcherTable_LoadERK(emethod) & use, intrinsic :: ISO_C_BINDING type(C_PTR) :: swig_result integer(ARKODE_ERKTableID), intent(in) :: emethod -type(C_PTR) :: fresult -integer(C_INT) :: farg1 +type(C_PTR) :: fresult +integer(C_INT) :: farg1 farg1 = emethod fresult = swigc_FARKodeButcherTable_LoadERK(farg1) @@ -5530,8 +5530,8 @@ function FARKodeButcherTable_LoadERKByName(emethod) & type(C_PTR) :: swig_result character(kind=C_CHAR, len=*), target :: emethod character(kind=C_CHAR), dimension(:), allocatable, target :: farg1_chars -type(C_PTR) :: fresult -type(SwigArrayWrapper) :: farg1 +type(C_PTR) :: fresult +type(SwigArrayWrapper) :: farg1 call SWIG_string_to_chararray(emethod, farg1_chars, farg1) fresult = swigc_FARKodeButcherTable_LoadERKByName(farg1) @@ -5543,8 +5543,8 @@ function FARKodeButcherTable_ERKIDToName(emethod) & use, intrinsic :: ISO_C_BINDING character(kind=C_CHAR, len=:), allocatable :: swig_result integer(ARKODE_ERKTableID), intent(in) :: emethod -type(SwigArrayWrapper) :: fresult -integer(C_INT) :: farg1 +type(SwigArrayWrapper) :: fresult +integer(C_INT) :: farg1 farg1 = emethod fresult = swigc_FARKodeButcherTable_ERKIDToName(farg1) @@ -5556,8 +5556,8 @@ subroutine swigf_ARKodeSPRKTableMem_q_set(self, q) use, intrinsic :: ISO_C_BINDING class(ARKodeSPRKTableMem), intent(in) :: self integer(C_INT), intent(in) :: q -type(SwigClassWrapper) :: farg1 -integer(C_INT) :: farg2 +type(SwigClassWrapper) :: farg1 +integer(C_INT) :: farg2 farg1 = self%swigdata farg2 = q @@ -5569,8 +5569,8 @@ function swigf_ARKodeSPRKTableMem_q_get(self) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result class(ARKodeSPRKTableMem), intent(in) :: self -integer(C_INT) :: fresult -type(SwigClassWrapper) :: farg1 +integer(C_INT) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeSPRKTableMem_q_get(farg1) @@ -5581,8 +5581,8 @@ subroutine swigf_ARKodeSPRKTableMem_stages_set(self, stages) use, intrinsic :: ISO_C_BINDING class(ARKodeSPRKTableMem), intent(in) :: self integer(C_INT), intent(in) :: stages -type(SwigClassWrapper) :: farg1 -integer(C_INT) :: farg2 +type(SwigClassWrapper) :: farg1 +integer(C_INT) :: farg2 farg1 = self%swigdata farg2 = stages @@ -5594,8 +5594,8 @@ function swigf_ARKodeSPRKTableMem_stages_get(self) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result class(ARKodeSPRKTableMem), intent(in) :: self -integer(C_INT) :: fresult -type(SwigClassWrapper) :: farg1 +integer(C_INT) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeSPRKTableMem_stages_get(farg1) @@ -5606,8 +5606,8 @@ subroutine swigf_ARKodeSPRKTableMem_a_set(self, a) use, intrinsic :: ISO_C_BINDING class(ARKodeSPRKTableMem), intent(in) :: self real(C_DOUBLE), dimension(*), target, intent(inout) :: a -type(SwigClassWrapper) :: farg1 -type(C_PTR) :: farg2 +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: farg2 farg1 = self%swigdata farg2 = c_loc(a(1)) @@ -5619,8 +5619,8 @@ function swigf_ARKodeSPRKTableMem_a_get(self) & use, intrinsic :: ISO_C_BINDING real(C_DOUBLE), dimension(:), pointer :: swig_result class(ARKodeSPRKTableMem), intent(in) :: self -type(C_PTR) :: fresult -type(SwigClassWrapper) :: farg1 +type(C_PTR) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeSPRKTableMem_a_get(farg1) @@ -5631,8 +5631,8 @@ subroutine swigf_ARKodeSPRKTableMem_ahat_set(self, ahat) use, intrinsic :: ISO_C_BINDING class(ARKodeSPRKTableMem), intent(in) :: self real(C_DOUBLE), dimension(*), target, intent(inout) :: ahat -type(SwigClassWrapper) :: farg1 -type(C_PTR) :: farg2 +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: farg2 farg1 = self%swigdata farg2 = c_loc(ahat(1)) @@ -5644,8 +5644,8 @@ function swigf_ARKodeSPRKTableMem_ahat_get(self) & use, intrinsic :: ISO_C_BINDING real(C_DOUBLE), dimension(:), pointer :: swig_result class(ARKodeSPRKTableMem), intent(in) :: self -type(C_PTR) :: fresult -type(SwigClassWrapper) :: farg1 +type(C_PTR) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeSPRKTableMem_ahat_get(farg1) @@ -5656,7 +5656,7 @@ function swigf_create_ARKodeSPRKTableMem() & result(self) use, intrinsic :: ISO_C_BINDING type(ARKodeSPRKTableMem) :: self -type(SwigClassWrapper) :: fresult +type(SwigClassWrapper) :: fresult fresult = swigc_new_ARKodeSPRKTableMem() self%swigdata = fresult @@ -5665,7 +5665,7 @@ function swigf_create_ARKodeSPRKTableMem() & subroutine swigf_release_ARKodeSPRKTableMem(self) use, intrinsic :: ISO_C_BINDING class(ARKodeSPRKTableMem), intent(inout) :: self -type(SwigClassWrapper) :: farg1 +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata if (btest(farg1%cmemflags, swig_cmem_own_bit)) then @@ -5680,8 +5680,8 @@ subroutine swigf_ARKodeSPRKTableMem_op_assign__(self, other) use, intrinsic :: ISO_C_BINDING class(ARKodeSPRKTableMem), intent(inout) :: self type(ARKodeSPRKTableMem), intent(in) :: other -type(SwigClassWrapper) :: farg1 -type(SwigClassWrapper) :: farg2 +type(SwigClassWrapper) :: farg1 +type(SwigClassWrapper) :: farg2 farg1 = self%swigdata farg2 = other%swigdata @@ -5697,11 +5697,11 @@ function FARKodeSPRKTable_Create(s, q, a, ahat) & integer(C_INT), intent(in) :: q real(C_DOUBLE), dimension(*), target, intent(inout) :: a real(C_DOUBLE), dimension(*), target, intent(inout) :: ahat -type(C_PTR) :: fresult -integer(C_INT) :: farg1 -integer(C_INT) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 +type(C_PTR) :: fresult +integer(C_INT) :: farg1 +integer(C_INT) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 farg1 = s farg2 = q @@ -5716,8 +5716,8 @@ function FARKodeSPRKTable_Alloc(stages) & use, intrinsic :: ISO_C_BINDING type(C_PTR) :: swig_result integer(C_INT), intent(in) :: stages -type(C_PTR) :: fresult -integer(C_INT) :: farg1 +type(C_PTR) :: fresult +integer(C_INT) :: farg1 farg1 = stages fresult = swigc_FARKodeSPRKTable_Alloc(farg1) @@ -5729,8 +5729,8 @@ function FARKodeSPRKTable_Load(id) & use, intrinsic :: ISO_C_BINDING type(C_PTR) :: swig_result integer(ARKODE_SPRKMethodID), intent(in) :: id -type(C_PTR) :: fresult -integer(C_INT) :: farg1 +type(C_PTR) :: fresult +integer(C_INT) :: farg1 farg1 = id fresult = swigc_FARKodeSPRKTable_Load(farg1) @@ -5743,8 +5743,8 @@ function FARKodeSPRKTable_LoadByName(method) & type(C_PTR) :: swig_result character(kind=C_CHAR, len=*), target :: method character(kind=C_CHAR), dimension(:), allocatable, target :: farg1_chars -type(C_PTR) :: fresult -type(SwigArrayWrapper) :: farg1 +type(C_PTR) :: fresult +type(SwigArrayWrapper) :: farg1 call SWIG_string_to_chararray(method, farg1_chars, farg1) fresult = swigc_FARKodeSPRKTable_LoadByName(farg1) @@ -5756,8 +5756,8 @@ function FARKodeSPRKTable_Copy(that_sprk_storage) & use, intrinsic :: ISO_C_BINDING type(C_PTR) :: swig_result type(C_PTR) :: that_sprk_storage -type(C_PTR) :: fresult -type(C_PTR) :: farg1 +type(C_PTR) :: fresult +type(C_PTR) :: farg1 farg1 = that_sprk_storage fresult = swigc_FARKodeSPRKTable_Copy(farg1) @@ -5768,8 +5768,8 @@ subroutine FARKodeSPRKTable_Write(sprk_table, outfile) use, intrinsic :: ISO_C_BINDING type(C_PTR) :: sprk_table type(C_PTR) :: outfile -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = sprk_table farg2 = outfile @@ -5781,9 +5781,9 @@ subroutine FARKodeSPRKTable_Space(sprk_storage, liw, lrw) type(C_PTR) :: sprk_storage integer(C_INT32_T), dimension(*), target, intent(inout) :: liw integer(C_INT32_T), dimension(*), target, intent(inout) :: lrw -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = sprk_storage farg2 = c_loc(liw(1)) @@ -5794,7 +5794,7 @@ subroutine FARKodeSPRKTable_Space(sprk_storage, liw, lrw) subroutine FARKodeSPRKTable_Free(sprk_storage) use, intrinsic :: ISO_C_BINDING type(C_PTR) :: sprk_storage -type(C_PTR) :: farg1 +type(C_PTR) :: farg1 farg1 = sprk_storage call swigc_FARKodeSPRKTable_Free(farg1) @@ -5807,10 +5807,10 @@ function FARKodeSPRKTable_ToButcher(sprk_storage, a_ptr, b_ptr) & type(C_PTR) :: sprk_storage type(C_PTR), target, intent(inout) :: a_ptr type(C_PTR), target, intent(inout) :: b_ptr -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = sprk_storage farg2 = c_loc(a_ptr) @@ -5826,10 +5826,10 @@ function FARKodeSetLinearSolver(arkode_mem, ls, a) & type(C_PTR) :: arkode_mem type(SUNLinearSolver), target, intent(inout) :: ls type(SUNMatrix), target, intent(inout) :: a -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = c_loc(ls) @@ -5846,11 +5846,11 @@ function FARKodeSetMassLinearSolver(arkode_mem, ls, m, time_dep) & type(SUNLinearSolver), target, intent(inout) :: ls type(SUNMatrix), target, intent(inout) :: m integer(C_INT), intent(in) :: time_dep -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 -integer(C_INT) :: farg4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 +integer(C_INT) :: farg4 farg1 = arkode_mem farg2 = c_loc(ls) @@ -5866,9 +5866,9 @@ function FARKodeSetJacFn(arkode_mem, jac) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: jac -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = jac @@ -5882,9 +5882,9 @@ function FARKodeSetMassFn(arkode_mem, mass) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: mass -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = mass @@ -5898,9 +5898,9 @@ function FARKodeSetJacEvalFrequency(arkode_mem, msbj) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), intent(in) :: msbj -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_LONG) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_LONG) :: farg2 farg1 = arkode_mem farg2 = msbj @@ -5914,9 +5914,9 @@ function FARKodeSetLinearSolutionScaling(arkode_mem, onoff) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: onoff -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = onoff @@ -5930,9 +5930,9 @@ function FARKodeSetEpsLin(arkode_mem, eplifac) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: eplifac -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = eplifac @@ -5946,9 +5946,9 @@ function FARKodeSetMassEpsLin(arkode_mem, eplifac) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: eplifac -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = eplifac @@ -5962,9 +5962,9 @@ function FARKodeSetLSNormFactor(arkode_mem, nrmfac) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: nrmfac -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = nrmfac @@ -5978,9 +5978,9 @@ function FARKodeSetMassLSNormFactor(arkode_mem, nrmfac) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: nrmfac -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = nrmfac @@ -5995,10 +5995,10 @@ function FARKodeSetPreconditioner(arkode_mem, psetup, psolve) & type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: psetup type(C_FUNPTR), intent(in), value :: psolve -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -type(C_FUNPTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +type(C_FUNPTR) :: farg3 farg1 = arkode_mem farg2 = psetup @@ -6014,10 +6014,10 @@ function FARKodeSetMassPreconditioner(arkode_mem, psetup, psolve) & type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: psetup type(C_FUNPTR), intent(in), value :: psolve -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -type(C_FUNPTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +type(C_FUNPTR) :: farg3 farg1 = arkode_mem farg2 = psetup @@ -6033,10 +6033,10 @@ function FARKodeSetJacTimes(arkode_mem, jtsetup, jtimes) & type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: jtsetup type(C_FUNPTR), intent(in), value :: jtimes -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -type(C_FUNPTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +type(C_FUNPTR) :: farg3 farg1 = arkode_mem farg2 = jtsetup @@ -6051,9 +6051,9 @@ function FARKodeSetJacTimesRhsFn(arkode_mem, jtimesrhsfn) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: jtimesrhsfn -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = jtimesrhsfn @@ -6069,11 +6069,11 @@ function FARKodeSetMassTimes(arkode_mem, msetup, mtimes, mtimes_data) & type(C_FUNPTR), intent(in), value :: msetup type(C_FUNPTR), intent(in), value :: mtimes type(C_PTR) :: mtimes_data -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -type(C_FUNPTR) :: farg3 -type(C_PTR) :: farg4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +type(C_FUNPTR) :: farg3 +type(C_PTR) :: farg4 farg1 = arkode_mem farg2 = msetup @@ -6089,9 +6089,9 @@ function FARKodeSetLinSysFn(arkode_mem, linsys) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: linsys -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = linsys diff --git a/src/arkode/fmod_int64/farkode_lsrkstep_mod.c b/src/arkode/fmod_int64/farkode_lsrkstep_mod.c index ba2f9a5d5e..c360ea74e8 100644 --- a/src/arkode/fmod_int64/farkode_lsrkstep_mod.c +++ b/src/arkode/fmod_int64/farkode_lsrkstep_mod.c @@ -178,6 +178,21 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_nonnull(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if (!(SWIG_CLASS_WRAPPER).cptr) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass null " TYPENAME " (class " FNAME ") " \ + "as a reference", RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -192,15 +207,15 @@ * the fortran.cxx file. */ #define SWIG_contract_assert(RETURNNULL, EXPR, MSG) \ - if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); } + if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); } -#define SWIGVERSION 0x040000 +#define SWIGVERSION 0x040000 #define SWIG_VERSION SWIGVERSION -#define SWIG_as_voidptr(a) (void *)((const void *)(a)) -#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) +#define SWIG_as_voidptr(a) (void *)((const void *)(a)) +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) #include "arkode/arkode_lsrkstep.h" @@ -230,6 +245,20 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { return result; } + +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + SWIGEXPORT void * _wrap_FLSRKStepCreateSTS(ARKRhsFn farg1, double const *farg2, N_Vector farg3, void *farg4) { void * fresult ; ARKRhsFn arg1 = (ARKRhsFn) 0 ; @@ -237,7 +266,7 @@ SWIGEXPORT void * _wrap_FLSRKStepCreateSTS(ARKRhsFn farg1, double const *farg2, N_Vector arg3 = (N_Vector) 0 ; SUNContext arg4 = (SUNContext) 0 ; void *result = 0 ; - + arg1 = (ARKRhsFn)(farg1); arg2 = (sunrealtype)(*farg2); arg3 = (N_Vector)(farg3); @@ -255,7 +284,7 @@ SWIGEXPORT void * _wrap_FLSRKStepCreateSSP(ARKRhsFn farg1, double const *farg2, N_Vector arg3 = (N_Vector) 0 ; SUNContext arg4 = (SUNContext) 0 ; void *result = 0 ; - + arg1 = (ARKRhsFn)(farg1); arg2 = (sunrealtype)(*farg2); arg3 = (N_Vector)(farg3); @@ -273,7 +302,7 @@ SWIGEXPORT int _wrap_FLSRKStepReInitSTS(void *farg1, ARKRhsFn farg2, double cons sunrealtype arg3 ; N_Vector arg4 = (N_Vector) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (ARKRhsFn)(farg2); arg3 = (sunrealtype)(*farg3); @@ -291,7 +320,7 @@ SWIGEXPORT int _wrap_FLSRKStepReInitSSP(void *farg1, ARKRhsFn farg2, double cons sunrealtype arg3 ; N_Vector arg4 = (N_Vector) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (ARKRhsFn)(farg2); arg3 = (sunrealtype)(*farg3); @@ -307,7 +336,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetSTSMethod(void *farg1, int const *farg2) { void *arg1 = (void *) 0 ; ARKODE_LSRKMethodType arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (ARKODE_LSRKMethodType)(*farg2); result = (int)LSRKStepSetSTSMethod(arg1,arg2); @@ -321,7 +350,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetSSPMethod(void *farg1, int const *farg2) { void *arg1 = (void *) 0 ; ARKODE_LSRKMethodType arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (ARKODE_LSRKMethodType)(*farg2); result = (int)LSRKStepSetSSPMethod(arg1,arg2); @@ -335,7 +364,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetSTSMethodByName(void *farg1, SwigArrayWrapper * void *arg1 = (void *) 0 ; char *arg2 = (char *) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (char *)(farg2->data); result = (int)LSRKStepSetSTSMethodByName(arg1,(char const *)arg2); @@ -349,7 +378,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetSSPMethodByName(void *farg1, SwigArrayWrapper * void *arg1 = (void *) 0 ; char *arg2 = (char *) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (char *)(farg2->data); result = (int)LSRKStepSetSSPMethodByName(arg1,(char const *)arg2); @@ -363,7 +392,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetDomEigFn(void *farg1, ARKDomEigFn farg2) { void *arg1 = (void *) 0 ; ARKDomEigFn arg2 = (ARKDomEigFn) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (ARKDomEigFn)(farg2); result = (int)LSRKStepSetDomEigFn(arg1,arg2); @@ -372,14 +401,15 @@ SWIGEXPORT int _wrap_FLSRKStepSetDomEigFn(void *farg1, ARKDomEigFn farg2) { } -SWIGEXPORT int _wrap_FLSRKStepSetDEECreateWithID(void *farg1, int const *farg2) { +SWIGEXPORT int _wrap_FLSRKStepSetDEECreateWithID(void *farg1, SwigClassWrapper const *farg2) { int fresult ; void *arg1 = (void *) 0 ; SUNDomEigEstimator_ID arg2 ; int result; - + arg1 = (void *)(farg1); - arg2 = (SUNDomEigEstimator_ID)(*farg2); + SWIG_check_nonnull(*farg2, "SUNDomEigEstimator_ID", "SWIGTYPE_p_SUNDomEigEstimator_ID", "LSRKStepSetDEECreateWithID(void *,SUNDomEigEstimator_ID)", return 0); + arg2 = *(SUNDomEigEstimator_ID *)(farg2->cptr); result = (int)LSRKStepSetDEECreateWithID(arg1,arg2); fresult = (int)(result); return fresult; @@ -391,7 +421,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetDomEigFrequency(void *farg1, long const *farg2) void *arg1 = (void *) 0 ; long arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (long)(*farg2); result = (int)LSRKStepSetDomEigFrequency(arg1,arg2); @@ -405,7 +435,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetMaxNumStages(void *farg1, int const *farg2) { void *arg1 = (void *) 0 ; int arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (int)(*farg2); result = (int)LSRKStepSetMaxNumStages(arg1,arg2); @@ -419,7 +449,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetDomEigSafetyFactor(void *farg1, double const *f void *arg1 = (void *) 0 ; sunrealtype arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (sunrealtype)(*farg2); result = (int)LSRKStepSetDomEigSafetyFactor(arg1,arg2); @@ -433,7 +463,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetNumSSPStages(void *farg1, int const *farg2) { void *arg1 = (void *) 0 ; int arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (int)(*farg2); result = (int)LSRKStepSetNumSSPStages(arg1,arg2); @@ -447,7 +477,7 @@ SWIGEXPORT int _wrap_FLSRKStepGetNumDomEigUpdates(void *farg1, long *farg2) { void *arg1 = (void *) 0 ; long *arg2 = (long *) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (long *)(farg2); result = (int)LSRKStepGetNumDomEigUpdates(arg1,arg2); @@ -461,7 +491,7 @@ SWIGEXPORT int _wrap_FLSRKStepGetMaxNumStages(void *farg1, int *farg2) { void *arg1 = (void *) 0 ; int *arg2 = (int *) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (int *)(farg2); result = (int)LSRKStepGetMaxNumStages(arg1,arg2); @@ -470,4 +500,18 @@ SWIGEXPORT int _wrap_FLSRKStepGetMaxNumStages(void *farg1, int *farg2) { } +SWIGEXPORT int _wrap_FLSRKStepGetNumRHSinDQ(void *farg1, int *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + int *arg2 = (int *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (int *)(farg2); + result = (int)LSRKStepGetNumRHSinDQ(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + diff --git a/src/arkode/fmod_int64/farkode_lsrkstep_mod.f90 b/src/arkode/fmod_int64/farkode_lsrkstep_mod.f90 index a9f10a03bf..cc763f6b0e 100644 --- a/src/arkode/fmod_int64/farkode_lsrkstep_mod.f90 +++ b/src/arkode/fmod_int64/farkode_lsrkstep_mod.f90 @@ -36,13 +36,6 @@ module farkode_lsrkstep_mod end enum integer, parameter, public :: ARKODE_LSRKMethodType = kind(ARKODE_LSRK_RKC_2) public :: ARKODE_LSRK_RKC_2, ARKODE_LSRK_RKL_2, ARKODE_LSRK_SSP_S_2, ARKODE_LSRK_SSP_S_3, ARKODE_LSRK_SSP_10_4 - ! typedef enum SUNDomEigEstimator_ID - enum, bind(c) - enumerator :: SUNDSOMEIGESTIMATOR_POWER - enumerator :: SUNDSOMEIGESTIMATOR_ARNOLDI - end enum - integer, parameter, public :: SUNDomEigEstimator_ID = kind(SUNDSOMEIGESTIMATOR_POWER) - public :: SUNDSOMEIGESTIMATOR_POWER, SUNDSOMEIGESTIMATOR_ARNOLDI public :: FLSRKStepCreateSTS public :: FLSRKStepCreateSSP public :: FLSRKStepReInitSTS @@ -56,6 +49,17 @@ module farkode_lsrkstep_mod public :: FLSRKStepSetSTSMethodByName public :: FLSRKStepSetSSPMethodByName public :: FLSRKStepSetDomEigFn + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_SUNDomEigEstimator_ID + type(SwigClassWrapper), public :: swigdata + end type public :: FLSRKStepSetDEECreateWithID public :: FLSRKStepSetDomEigFrequency public :: FLSRKStepSetMaxNumStages @@ -63,6 +67,7 @@ module farkode_lsrkstep_mod public :: FLSRKStepSetNumSSPStages public :: FLSRKStepGetNumDomEigUpdates public :: FLSRKStepGetMaxNumStages + public :: FLSRKStepGetNumRHSinDQ ! WRAPPER DECLARATIONS interface @@ -161,8 +166,9 @@ function swigc_FLSRKStepSetDEECreateWithID(farg1, farg2) & bind(C, name="_wrap_FLSRKStepSetDEECreateWithID") & result(fresult) use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper type(C_PTR), value :: farg1 -integer(C_INT), intent(in) :: farg2 +type(SwigClassWrapper) :: farg2 integer(C_INT) :: fresult end function @@ -220,6 +226,15 @@ function swigc_FLSRKStepGetMaxNumStages(farg1, farg2) & integer(C_INT) :: fresult end function +function swigc_FLSRKStepGetNumRHSinDQ(farg1, farg2) & +bind(C, name="_wrap_FLSRKStepGetNumRHSinDQ") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + end interface @@ -233,11 +248,11 @@ function FLSRKStepCreateSTS(rhs, t0, y0, sunctx) & real(C_DOUBLE), intent(in) :: t0 type(N_Vector), target, intent(inout) :: y0 type(C_PTR) :: sunctx -type(C_PTR) :: fresult -type(C_FUNPTR) :: farg1 -real(C_DOUBLE) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 +type(C_PTR) :: fresult +type(C_FUNPTR) :: farg1 +real(C_DOUBLE) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 farg1 = rhs farg2 = t0 @@ -255,11 +270,11 @@ function FLSRKStepCreateSSP(rhs, t0, y0, sunctx) & real(C_DOUBLE), intent(in) :: t0 type(N_Vector), target, intent(inout) :: y0 type(C_PTR) :: sunctx -type(C_PTR) :: fresult -type(C_FUNPTR) :: farg1 -real(C_DOUBLE) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 +type(C_PTR) :: fresult +type(C_FUNPTR) :: farg1 +real(C_DOUBLE) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 farg1 = rhs farg2 = t0 @@ -277,11 +292,11 @@ function FLSRKStepReInitSTS(arkode_mem, rhs, t0, y0) & type(C_FUNPTR), intent(in), value :: rhs real(C_DOUBLE), intent(in) :: t0 type(N_Vector), target, intent(inout) :: y0 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -real(C_DOUBLE) :: farg3 -type(C_PTR) :: farg4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +real(C_DOUBLE) :: farg3 +type(C_PTR) :: farg4 farg1 = arkode_mem farg2 = rhs @@ -299,11 +314,11 @@ function FLSRKStepReInitSSP(arkode_mem, rhs, t0, y0) & type(C_FUNPTR), intent(in), value :: rhs real(C_DOUBLE), intent(in) :: t0 type(N_Vector), target, intent(inout) :: y0 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -real(C_DOUBLE) :: farg3 -type(C_PTR) :: farg4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +real(C_DOUBLE) :: farg3 +type(C_PTR) :: farg4 farg1 = arkode_mem farg2 = rhs @@ -319,9 +334,9 @@ function FLSRKStepSetSTSMethod(arkode_mem, method) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(ARKODE_LSRKMethodType), intent(in) :: method -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = method @@ -335,9 +350,9 @@ function FLSRKStepSetSSPMethod(arkode_mem, method) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(ARKODE_LSRKMethodType), intent(in) :: method -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = method @@ -370,9 +385,9 @@ function FLSRKStepSetSTSMethodByName(arkode_mem, emethod) & type(C_PTR) :: arkode_mem character(kind=C_CHAR, len=*), target :: emethod character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 farg1 = arkode_mem call SWIG_string_to_chararray(emethod, farg2_chars, farg2) @@ -387,9 +402,9 @@ function FLSRKStepSetSSPMethodByName(arkode_mem, emethod) & type(C_PTR) :: arkode_mem character(kind=C_CHAR, len=*), target :: emethod character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 farg1 = arkode_mem call SWIG_string_to_chararray(emethod, farg2_chars, farg2) @@ -403,9 +418,9 @@ function FLSRKStepSetDomEigFn(arkode_mem, dom_eig) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: dom_eig -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = dom_eig @@ -413,18 +428,18 @@ function FLSRKStepSetDomEigFn(arkode_mem, dom_eig) & swig_result = fresult end function -function FLSRKStepSetDEECreateWithID(arkode_mem, DEE_id) & +function FLSRKStepSetDEECreateWithID(arkode_mem, dee_id) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -integer(SUNDomEigEstimator_ID), intent(in) :: DEE_id -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +type(SWIGTYPE_p_SUNDomEigEstimator_ID), intent(in) :: dee_id +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigClassWrapper) :: farg2 farg1 = arkode_mem -farg2 = DEE_id +farg2 = dee_id%swigdata fresult = swigc_FLSRKStepSetDEECreateWithID(farg1, farg2) swig_result = fresult end function @@ -435,9 +450,9 @@ function FLSRKStepSetDomEigFrequency(arkode_mem, nsteps) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), intent(in) :: nsteps -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_LONG) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_LONG) :: farg2 farg1 = arkode_mem farg2 = nsteps @@ -451,9 +466,9 @@ function FLSRKStepSetMaxNumStages(arkode_mem, stage_max_limit) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: stage_max_limit -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = stage_max_limit @@ -467,9 +482,9 @@ function FLSRKStepSetDomEigSafetyFactor(arkode_mem, dom_eig_safety) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: dom_eig_safety -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = dom_eig_safety @@ -483,9 +498,9 @@ function FLSRKStepSetNumSSPStages(arkode_mem, num_of_stages) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: num_of_stages -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = num_of_stages @@ -499,9 +514,9 @@ function FLSRKStepGetNumDomEigUpdates(arkode_mem, dom_eig_num_evals) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: dom_eig_num_evals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(dom_eig_num_evals(1)) @@ -515,9 +530,9 @@ function FLSRKStepGetMaxNumStages(arkode_mem, stage_max) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), dimension(*), target, intent(inout) :: stage_max -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(stage_max(1)) @@ -525,5 +540,21 @@ function FLSRKStepGetMaxNumStages(arkode_mem, stage_max) & swig_result = fresult end function +function FLSRKStepGetNumRHSinDQ(arkode_mem, nfedq) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT), dimension(*), target, intent(inout) :: nfedq +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(nfedq(1)) +fresult = swigc_FLSRKStepGetNumRHSinDQ(farg1, farg2) +swig_result = fresult +end function + end module diff --git a/src/arkode/fmod_int64/farkode_mod.f90 b/src/arkode/fmod_int64/farkode_mod.f90 index c2015d52a6..df2167c214 100644 --- a/src/arkode/fmod_int64/farkode_mod.f90 +++ b/src/arkode/fmod_int64/farkode_mod.f90 @@ -2520,13 +2520,13 @@ function FARKodeResize(arkode_mem, ynew, hscale, t0, resize, resize_data) & real(C_DOUBLE), intent(in) :: t0 type(C_FUNPTR), intent(in), value :: resize type(C_PTR) :: resize_data -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -real(C_DOUBLE) :: farg3 -real(C_DOUBLE) :: farg4 -type(C_FUNPTR) :: farg5 -type(C_PTR) :: farg6 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +real(C_DOUBLE) :: farg3 +real(C_DOUBLE) :: farg4 +type(C_FUNPTR) :: farg5 +type(C_PTR) :: farg6 farg1 = arkode_mem farg2 = c_loc(ynew) @@ -2545,10 +2545,10 @@ function FARKodeReset(arkode_mem, tr, yr) & type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: tr type(N_Vector), target, intent(inout) :: yr -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = tr @@ -2563,9 +2563,9 @@ function FARKodeCreateMRIStepInnerStepper(arkode_mem, stepper) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_PTR), target, intent(inout) :: stepper -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(stepper) @@ -2580,10 +2580,10 @@ function FARKodeSStolerances(arkode_mem, reltol, abstol) & type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: reltol real(C_DOUBLE), intent(in) :: abstol -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 farg1 = arkode_mem farg2 = reltol @@ -2599,10 +2599,10 @@ function FARKodeSVtolerances(arkode_mem, reltol, abstol) & type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: reltol type(N_Vector), target, intent(inout) :: abstol -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = reltol @@ -2617,9 +2617,9 @@ function FARKodeWFtolerances(arkode_mem, efun) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: efun -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = efun @@ -2633,9 +2633,9 @@ function FARKodeResStolerance(arkode_mem, rabstol) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: rabstol -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = rabstol @@ -2649,9 +2649,9 @@ function FARKodeResVtolerance(arkode_mem, rabstol) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(N_Vector), target, intent(inout) :: rabstol -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(rabstol) @@ -2665,9 +2665,9 @@ function FARKodeResFtolerance(arkode_mem, rfun) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: rfun -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = rfun @@ -2682,10 +2682,10 @@ function FARKodeRootInit(arkode_mem, nrtfn, g) & type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: nrtfn type(C_FUNPTR), intent(in), value :: g -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 -type(C_FUNPTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 +type(C_FUNPTR) :: farg3 farg1 = arkode_mem farg2 = nrtfn @@ -2700,9 +2700,9 @@ function FARKodeSetRootDirection(arkode_mem, rootdir) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), dimension(*), target, intent(inout) :: rootdir -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(rootdir(1)) @@ -2715,8 +2715,8 @@ function FARKodeSetNoInactiveRootWarn(arkode_mem) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -integer(C_INT) :: fresult -type(C_PTR) :: farg1 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 farg1 = arkode_mem fresult = swigc_FARKodeSetNoInactiveRootWarn(farg1) @@ -2728,8 +2728,8 @@ function FARKodeSetDefaults(arkode_mem) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -integer(C_INT) :: fresult -type(C_PTR) :: farg1 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 farg1 = arkode_mem fresult = swigc_FARKodeSetDefaults(farg1) @@ -2742,9 +2742,9 @@ function FARKodeSetOrder(arkode_mem, maxord) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: maxord -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = maxord @@ -2758,9 +2758,9 @@ function FARKodeSetInterpolantType(arkode_mem, itype) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: itype -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = itype @@ -2774,9 +2774,9 @@ function FARKodeSetInterpolantDegree(arkode_mem, degree) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: degree -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = degree @@ -2790,9 +2790,9 @@ function FARKodeSetMaxNumSteps(arkode_mem, mxsteps) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), intent(in) :: mxsteps -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_LONG) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_LONG) :: farg2 farg1 = arkode_mem farg2 = mxsteps @@ -2806,9 +2806,9 @@ function FARKodeSetInterpolateStopTime(arkode_mem, interp) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: interp -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = interp @@ -2822,9 +2822,9 @@ function FARKodeSetStopTime(arkode_mem, tstop) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: tstop -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = tstop @@ -2837,8 +2837,8 @@ function FARKodeClearStopTime(arkode_mem) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -integer(C_INT) :: fresult -type(C_PTR) :: farg1 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 farg1 = arkode_mem fresult = swigc_FARKodeClearStopTime(farg1) @@ -2851,9 +2851,9 @@ function FARKodeSetFixedStep(arkode_mem, hfixed) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: hfixed -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = hfixed @@ -2867,9 +2867,9 @@ function FARKodeSetStepDirection(arkode_mem, stepdir) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: stepdir -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = stepdir @@ -2883,9 +2883,9 @@ function FARKodeSetUserData(arkode_mem, user_data) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_PTR) :: user_data -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = user_data @@ -2899,9 +2899,9 @@ function FARKodeSetPostprocessStepFn(arkode_mem, processstep) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: processstep -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = processstep @@ -2915,9 +2915,9 @@ function FARKodeSetPostprocessStageFn(arkode_mem, processstage) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: processstage -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = processstage @@ -2931,9 +2931,9 @@ function FARKodeSetNonlinearSolver(arkode_mem, nls) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(SUNNonlinearSolver), target, intent(inout) :: nls -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nls) @@ -2947,9 +2947,9 @@ function FARKodeSetLinear(arkode_mem, timedepend) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: timedepend -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = timedepend @@ -2962,8 +2962,8 @@ function FARKodeSetNonlinear(arkode_mem) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -integer(C_INT) :: fresult -type(C_PTR) :: farg1 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 farg1 = arkode_mem fresult = swigc_FARKodeSetNonlinear(farg1) @@ -2976,9 +2976,9 @@ function FARKodeSetAutonomous(arkode_mem, autonomous) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: autonomous -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = autonomous @@ -2992,9 +2992,9 @@ function FARKodeSetNlsRhsFn(arkode_mem, nls_fi) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: nls_fi -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = nls_fi @@ -3008,9 +3008,9 @@ function FARKodeSetDeduceImplicitRhs(arkode_mem, deduce) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: deduce -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = deduce @@ -3024,9 +3024,9 @@ function FARKodeSetNonlinCRDown(arkode_mem, crdown) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: crdown -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = crdown @@ -3040,9 +3040,9 @@ function FARKodeSetNonlinRDiv(arkode_mem, rdiv) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: rdiv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = rdiv @@ -3056,9 +3056,9 @@ function FARKodeSetDeltaGammaMax(arkode_mem, dgmax) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: dgmax -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = dgmax @@ -3072,9 +3072,9 @@ function FARKodeSetLSetupFrequency(arkode_mem, msbp) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: msbp -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = msbp @@ -3088,9 +3088,9 @@ function FARKodeSetPredictorMethod(arkode_mem, method) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: method -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = method @@ -3104,9 +3104,9 @@ function FARKodeSetMaxNonlinIters(arkode_mem, maxcor) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: maxcor -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = maxcor @@ -3120,9 +3120,9 @@ function FARKodeSetMaxConvFails(arkode_mem, maxncf) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: maxncf -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = maxncf @@ -3136,9 +3136,9 @@ function FARKodeSetNonlinConvCoef(arkode_mem, nlscoef) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: nlscoef -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = nlscoef @@ -3152,9 +3152,9 @@ function FARKodeSetStagePredictFn(arkode_mem, predictstage) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: predictstage -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = predictstage @@ -3168,9 +3168,9 @@ function FARKodeSetAdaptController(arkode_mem, c) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(SUNAdaptController), target, intent(inout) :: c -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(c) @@ -3203,9 +3203,9 @@ function FARKodeSetAdaptControllerByName(arkode_mem, cname) & type(C_PTR) :: arkode_mem character(kind=C_CHAR, len=*), target :: cname character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 farg1 = arkode_mem call SWIG_string_to_chararray(cname, farg2_chars, farg2) @@ -3219,9 +3219,9 @@ function FARKodeSetAdaptivityAdjustment(arkode_mem, adjust) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: adjust -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = adjust @@ -3235,9 +3235,9 @@ function FARKodeSetCFLFraction(arkode_mem, cfl_frac) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: cfl_frac -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = cfl_frac @@ -3251,9 +3251,9 @@ function FARKodeSetErrorBias(arkode_mem, bias) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: bias -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = bias @@ -3267,9 +3267,9 @@ function FARKodeSetSafetyFactor(arkode_mem, safety) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: safety -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = safety @@ -3283,9 +3283,9 @@ function FARKodeSetMaxGrowth(arkode_mem, mx_growth) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: mx_growth -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = mx_growth @@ -3299,9 +3299,9 @@ function FARKodeSetMinReduction(arkode_mem, eta_min) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: eta_min -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = eta_min @@ -3316,10 +3316,10 @@ function FARKodeSetFixedStepBounds(arkode_mem, lb, ub) & type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: lb real(C_DOUBLE), intent(in) :: ub -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 farg1 = arkode_mem farg2 = lb @@ -3334,9 +3334,9 @@ function FARKodeSetMaxFirstGrowth(arkode_mem, etamx1) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: etamx1 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = etamx1 @@ -3350,9 +3350,9 @@ function FARKodeSetMaxEFailGrowth(arkode_mem, etamxf) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: etamxf -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = etamxf @@ -3366,9 +3366,9 @@ function FARKodeSetSmallNumEFails(arkode_mem, small_nef) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: small_nef -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = small_nef @@ -3382,9 +3382,9 @@ function FARKodeSetMaxCFailGrowth(arkode_mem, etacf) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: etacf -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = etacf @@ -3399,10 +3399,10 @@ function FARKodeSetStabilityFn(arkode_mem, estab, estab_data) & type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: estab type(C_PTR) :: estab_data -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = estab @@ -3417,9 +3417,9 @@ function FARKodeSetMaxErrTestFails(arkode_mem, maxnef) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: maxnef -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = maxnef @@ -3433,9 +3433,9 @@ function FARKodeSetConstraints(arkode_mem, constraints) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(N_Vector), target, intent(inout) :: constraints -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(constraints) @@ -3449,9 +3449,9 @@ function FARKodeSetMaxHnilWarns(arkode_mem, mxhnil) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: mxhnil -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = mxhnil @@ -3465,9 +3465,9 @@ function FARKodeSetInitStep(arkode_mem, hin) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: hin -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = hin @@ -3481,9 +3481,9 @@ function FARKodeSetMinStep(arkode_mem, hmin) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: hmin -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = hmin @@ -3497,9 +3497,9 @@ function FARKodeSetMaxStep(arkode_mem, hmax) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: hmax -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = hmax @@ -3513,9 +3513,9 @@ function FARKodeSetMaxNumConstrFails(arkode_mem, maxfails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: maxfails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = maxfails @@ -3529,9 +3529,9 @@ function FARKodeSetAdjointCheckpointScheme(arkode_mem, checkpoint_scheme) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_PTR) :: checkpoint_scheme -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = checkpoint_scheme @@ -3545,9 +3545,9 @@ function FARKodeSetAdjointCheckpointIndex(arkode_mem, step_index) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), intent(in) :: step_index -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_LONG) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_LONG) :: farg2 farg1 = arkode_mem farg2 = step_index @@ -3561,9 +3561,9 @@ function FARKodeSetUseCompensatedSums(arkode_mem, onoff) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: onoff -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = onoff @@ -3577,9 +3577,9 @@ function FARKodeSetAccumulatedErrorType(arkode_mem, accum_type) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(ARKAccumError), intent(in) :: accum_type -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = accum_type @@ -3592,8 +3592,8 @@ function FARKodeResetAccumulatedError(arkode_mem) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -integer(C_INT) :: fresult -type(C_PTR) :: farg1 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 farg1 = arkode_mem fresult = swigc_FARKodeResetAccumulatedError(farg1) @@ -3609,12 +3609,12 @@ function FARKodeEvolve(arkode_mem, tout, yout, tret, itask) & type(N_Vector), target, intent(inout) :: yout real(C_DOUBLE), dimension(*), target, intent(inout) :: tret integer(C_INT), intent(in) :: itask -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 -integer(C_INT) :: farg5 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 +integer(C_INT) :: farg5 farg1 = arkode_mem farg2 = tout @@ -3633,11 +3633,11 @@ function FARKodeGetDky(arkode_mem, t, k, dky) & real(C_DOUBLE), intent(in) :: t integer(C_INT), intent(in) :: k type(N_Vector), target, intent(inout) :: dky -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -integer(C_INT) :: farg3 -type(C_PTR) :: farg4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +integer(C_INT) :: farg3 +type(C_PTR) :: farg4 farg1 = arkode_mem farg2 = t @@ -3654,10 +3654,10 @@ function FARKodeComputeState(arkode_mem, zcor, z) & type(C_PTR) :: arkode_mem type(N_Vector), target, intent(inout) :: zcor type(N_Vector), target, intent(inout) :: z -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = c_loc(zcor) @@ -3673,10 +3673,10 @@ function FARKodeGetNumRhsEvals(arkode_mem, partition_index, num_rhs_evals) & type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: partition_index integer(C_LONG), dimension(*), target, intent(inout) :: num_rhs_evals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = partition_index @@ -3691,9 +3691,9 @@ function FARKodeGetNumStepAttempts(arkode_mem, step_attempts) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: step_attempts -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(step_attempts(1)) @@ -3708,10 +3708,10 @@ function FARKodeGetWorkSpace(arkode_mem, lenrw, leniw) & type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: lenrw integer(C_LONG), dimension(*), target, intent(inout) :: leniw -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = c_loc(lenrw(1)) @@ -3726,9 +3726,9 @@ function FARKodeGetNumSteps(arkode_mem, nsteps) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nsteps -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nsteps(1)) @@ -3742,9 +3742,9 @@ function FARKodeGetLastStep(arkode_mem, hlast) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), dimension(*), target, intent(inout) :: hlast -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(hlast(1)) @@ -3758,9 +3758,9 @@ function FARKodeGetCurrentStep(arkode_mem, hcur) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), dimension(*), target, intent(inout) :: hcur -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(hcur(1)) @@ -3774,9 +3774,9 @@ function FARKodeGetStepDirection(arkode_mem, stepdir) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), dimension(*), target, intent(inout) :: stepdir -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(stepdir(1)) @@ -3790,9 +3790,9 @@ function FARKodeGetErrWeights(arkode_mem, eweight) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(N_Vector), target, intent(inout) :: eweight -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(eweight) @@ -3806,9 +3806,9 @@ function FARKodeGetNumGEvals(arkode_mem, ngevals) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: ngevals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(ngevals(1)) @@ -3822,9 +3822,9 @@ function FARKodeGetRootInfo(arkode_mem, rootsfound) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), dimension(*), target, intent(inout) :: rootsfound -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(rootsfound(1)) @@ -3838,9 +3838,9 @@ function FARKodeGetUserData(arkode_mem, user_data) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_PTR), target, intent(inout) :: user_data -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(user_data) @@ -3855,10 +3855,10 @@ function FARKodePrintAllStats(arkode_mem, outfile, fmt) & type(C_PTR) :: arkode_mem type(C_PTR) :: outfile integer(SUNOutputFormat), intent(in) :: fmt -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -integer(C_INT) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +integer(C_INT) :: farg3 farg1 = arkode_mem farg2 = outfile @@ -3886,8 +3886,8 @@ function FARKodeGetReturnFlagName(flag) & use, intrinsic :: ISO_C_BINDING character(kind=C_CHAR, len=:), allocatable :: swig_result integer(C_LONG), intent(in) :: flag -type(SwigArrayWrapper) :: fresult -integer(C_LONG) :: farg1 +type(SwigArrayWrapper) :: fresult +integer(C_LONG) :: farg1 farg1 = flag fresult = swigc_FARKodeGetReturnFlagName(farg1) @@ -3901,9 +3901,9 @@ function FARKodeWriteParameters(arkode_mem, fp) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_PTR) :: fp -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = fp @@ -3917,9 +3917,9 @@ function FARKodeGetNumExpSteps(arkode_mem, expsteps) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: expsteps -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(expsteps(1)) @@ -3933,9 +3933,9 @@ function FARKodeGetNumAccSteps(arkode_mem, accsteps) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: accsteps -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(accsteps(1)) @@ -3949,9 +3949,9 @@ function FARKodeGetNumErrTestFails(arkode_mem, netfails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: netfails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(netfails(1)) @@ -3965,9 +3965,9 @@ function FARKodeGetEstLocalErrors(arkode_mem, ele) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(N_Vector), target, intent(inout) :: ele -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(ele) @@ -3981,9 +3981,9 @@ function FARKodeGetActualInitStep(arkode_mem, hinused) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), dimension(*), target, intent(inout) :: hinused -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(hinused(1)) @@ -3997,9 +3997,9 @@ function FARKodeGetTolScaleFactor(arkode_mem, tolsfac) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), dimension(*), target, intent(inout) :: tolsfac -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(tolsfac(1)) @@ -4013,9 +4013,9 @@ function FARKodeGetNumConstrFails(arkode_mem, nconstrfails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nconstrfails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nconstrfails(1)) @@ -4033,13 +4033,13 @@ function FARKodeGetStepStats(arkode_mem, nsteps, hinused, hlast, hcur, tcur) & real(C_DOUBLE), dimension(*), target, intent(inout) :: hlast real(C_DOUBLE), dimension(*), target, intent(inout) :: hcur real(C_DOUBLE), dimension(*), target, intent(inout) :: tcur -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 -type(C_PTR) :: farg5 -type(C_PTR) :: farg6 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 +type(C_PTR) :: farg5 +type(C_PTR) :: farg6 farg1 = arkode_mem farg2 = c_loc(nsteps(1)) @@ -4057,9 +4057,9 @@ function FARKodeGetAccumulatedError(arkode_mem, accum_error) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), dimension(*), target, intent(inout) :: accum_error -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(accum_error(1)) @@ -4073,9 +4073,9 @@ function FARKodeGetNumLinSolvSetups(arkode_mem, nlinsetups) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nlinsetups -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nlinsetups(1)) @@ -4089,9 +4089,9 @@ function FARKodeGetCurrentTime(arkode_mem, tcur) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), dimension(*), target, intent(inout) :: tcur -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(tcur(1)) @@ -4105,9 +4105,9 @@ function FARKodeGetCurrentState(arkode_mem, state) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_PTR) :: state -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = state @@ -4121,9 +4121,9 @@ function FARKodeGetCurrentGamma(arkode_mem, gamma) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), dimension(*), target, intent(inout) :: gamma -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(gamma(1)) @@ -4143,15 +4143,15 @@ function FARKodeGetNonlinearSystemData(arkode_mem, tcur, zpred, z, fi, gamma, sd real(C_DOUBLE), dimension(*), target, intent(inout) :: gamma type(C_PTR) :: sdata type(C_PTR), target, intent(inout) :: user_data -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 -type(C_PTR) :: farg5 -type(C_PTR) :: farg6 -type(C_PTR) :: farg7 -type(C_PTR) :: farg8 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 +type(C_PTR) :: farg5 +type(C_PTR) :: farg6 +type(C_PTR) :: farg7 +type(C_PTR) :: farg8 farg1 = arkode_mem farg2 = c_loc(tcur(1)) @@ -4171,9 +4171,9 @@ function FARKodeGetNumNonlinSolvIters(arkode_mem, nniters) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nniters -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nniters(1)) @@ -4187,9 +4187,9 @@ function FARKodeGetNumNonlinSolvConvFails(arkode_mem, nnfails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nnfails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nnfails(1)) @@ -4204,10 +4204,10 @@ function FARKodeGetNonlinSolvStats(arkode_mem, nniters, nnfails) & type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nniters integer(C_LONG), dimension(*), target, intent(inout) :: nnfails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = c_loc(nniters(1)) @@ -4222,9 +4222,9 @@ function FARKodeGetNumStepSolveFails(arkode_mem, nncfails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nncfails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nncfails(1)) @@ -4238,9 +4238,9 @@ function FARKodeGetJac(arkode_mem, j) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_PTR), target, intent(inout) :: j -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(j) @@ -4254,9 +4254,9 @@ function FARKodeGetJacTime(arkode_mem, t_j) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), dimension(*), target, intent(inout) :: t_j -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(t_j(1)) @@ -4270,9 +4270,9 @@ function FARKodeGetJacNumSteps(arkode_mem, nst_j) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nst_j -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nst_j(1)) @@ -4287,10 +4287,10 @@ function FARKodeGetLinWorkSpace(arkode_mem, lenrwls, leniwls) & type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: lenrwls integer(C_LONG), dimension(*), target, intent(inout) :: leniwls -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = c_loc(lenrwls(1)) @@ -4305,9 +4305,9 @@ function FARKodeGetNumJacEvals(arkode_mem, njevals) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: njevals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(njevals(1)) @@ -4321,9 +4321,9 @@ function FARKodeGetNumPrecEvals(arkode_mem, npevals) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: npevals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(npevals(1)) @@ -4337,9 +4337,9 @@ function FARKodeGetNumPrecSolves(arkode_mem, npsolves) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: npsolves -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(npsolves(1)) @@ -4353,9 +4353,9 @@ function FARKodeGetNumLinIters(arkode_mem, nliters) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nliters -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nliters(1)) @@ -4369,9 +4369,9 @@ function FARKodeGetNumLinConvFails(arkode_mem, nlcfails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nlcfails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nlcfails(1)) @@ -4385,9 +4385,9 @@ function FARKodeGetNumJTSetupEvals(arkode_mem, njtsetups) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: njtsetups -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(njtsetups(1)) @@ -4401,9 +4401,9 @@ function FARKodeGetNumJtimesEvals(arkode_mem, njvevals) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: njvevals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(njvevals(1)) @@ -4417,9 +4417,9 @@ function FARKodeGetNumLinRhsEvals(arkode_mem, nfevalsls) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nfevalsls -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nfevalsls(1)) @@ -4433,9 +4433,9 @@ function FARKodeGetLastLinFlag(arkode_mem, flag) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: flag -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(flag(1)) @@ -4448,8 +4448,8 @@ function FARKodeGetLinReturnFlagName(flag) & use, intrinsic :: ISO_C_BINDING character(kind=C_CHAR, len=:), allocatable :: swig_result integer(C_LONG), intent(in) :: flag -type(SwigArrayWrapper) :: fresult -integer(C_LONG) :: farg1 +type(SwigArrayWrapper) :: fresult +integer(C_LONG) :: farg1 farg1 = flag fresult = swigc_FARKodeGetLinReturnFlagName(farg1) @@ -4463,9 +4463,9 @@ function FARKodeGetCurrentMassMatrix(arkode_mem, m) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_PTR), target, intent(inout) :: m -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(m) @@ -4479,9 +4479,9 @@ function FARKodeGetResWeights(arkode_mem, rweight) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(N_Vector), target, intent(inout) :: rweight -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(rweight) @@ -4496,10 +4496,10 @@ function FARKodeGetMassWorkSpace(arkode_mem, lenrwmls, leniwmls) & type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: lenrwmls integer(C_LONG), dimension(*), target, intent(inout) :: leniwmls -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = c_loc(lenrwmls(1)) @@ -4514,9 +4514,9 @@ function FARKodeGetNumMassSetups(arkode_mem, nmsetups) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nmsetups -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nmsetups(1)) @@ -4530,9 +4530,9 @@ function FARKodeGetNumMassMultSetups(arkode_mem, nmvsetups) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nmvsetups -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nmvsetups(1)) @@ -4546,9 +4546,9 @@ function FARKodeGetNumMassMult(arkode_mem, nmvevals) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nmvevals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nmvevals(1)) @@ -4562,9 +4562,9 @@ function FARKodeGetNumMassSolves(arkode_mem, nmsolves) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nmsolves -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nmsolves(1)) @@ -4578,9 +4578,9 @@ function FARKodeGetNumMassPrecEvals(arkode_mem, nmpevals) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nmpevals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nmpevals(1)) @@ -4594,9 +4594,9 @@ function FARKodeGetNumMassPrecSolves(arkode_mem, nmpsolves) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nmpsolves -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nmpsolves(1)) @@ -4610,9 +4610,9 @@ function FARKodeGetNumMassIters(arkode_mem, nmiters) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nmiters -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nmiters(1)) @@ -4626,9 +4626,9 @@ function FARKodeGetNumMassConvFails(arkode_mem, nmcfails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nmcfails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nmcfails(1)) @@ -4642,9 +4642,9 @@ function FARKodeGetNumMTSetups(arkode_mem, nmtsetups) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nmtsetups -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nmtsetups(1)) @@ -4658,9 +4658,9 @@ function FARKodeGetLastMassFlag(arkode_mem, flag) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: flag -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(flag(1)) @@ -4671,7 +4671,7 @@ function FARKodeGetLastMassFlag(arkode_mem, flag) & subroutine FARKodeFree(arkode_mem) use, intrinsic :: ISO_C_BINDING type(C_PTR), target, intent(inout) :: arkode_mem -type(C_PTR) :: farg1 +type(C_PTR) :: farg1 farg1 = c_loc(arkode_mem) call swigc_FARKodeFree(farg1) @@ -4681,8 +4681,8 @@ subroutine FARKodePrintMem(arkode_mem, outfile) use, intrinsic :: ISO_C_BINDING type(C_PTR) :: arkode_mem type(C_PTR) :: outfile -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = outfile @@ -4696,10 +4696,10 @@ function FARKodeSetRelaxFn(arkode_mem, rfn, rjac) & type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: rfn type(C_FUNPTR), intent(in), value :: rjac -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -type(C_FUNPTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +type(C_FUNPTR) :: farg3 farg1 = arkode_mem farg2 = rfn @@ -4714,9 +4714,9 @@ function FARKodeSetRelaxEtaFail(arkode_mem, eta_rf) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: eta_rf -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = eta_rf @@ -4730,9 +4730,9 @@ function FARKodeSetRelaxLowerBound(arkode_mem, lower) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: lower -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = lower @@ -4746,9 +4746,9 @@ function FARKodeSetRelaxMaxFails(arkode_mem, max_fails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: max_fails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = max_fails @@ -4762,9 +4762,9 @@ function FARKodeSetRelaxMaxIters(arkode_mem, max_iters) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: max_iters -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = max_iters @@ -4778,9 +4778,9 @@ function FARKodeSetRelaxSolver(arkode_mem, solver) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(ARKRelaxSolver), intent(in) :: solver -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = solver @@ -4794,9 +4794,9 @@ function FARKodeSetRelaxResTol(arkode_mem, res_tol) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: res_tol -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = res_tol @@ -4811,10 +4811,10 @@ function FARKodeSetRelaxTol(arkode_mem, rel_tol, abs_tol) & type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: rel_tol real(C_DOUBLE), intent(in) :: abs_tol -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 farg1 = arkode_mem farg2 = rel_tol @@ -4829,9 +4829,9 @@ function FARKodeSetRelaxUpperBound(arkode_mem, upper) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: upper -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = upper @@ -4845,9 +4845,9 @@ function FARKodeGetNumRelaxFnEvals(arkode_mem, r_evals) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: r_evals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(r_evals(1)) @@ -4861,9 +4861,9 @@ function FARKodeGetNumRelaxJacEvals(arkode_mem, j_evals) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: j_evals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(j_evals(1)) @@ -4877,9 +4877,9 @@ function FARKodeGetNumRelaxFails(arkode_mem, relax_fails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: relax_fails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(relax_fails(1)) @@ -4893,9 +4893,9 @@ function FARKodeGetNumRelaxBoundFails(arkode_mem, fails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: fails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(fails(1)) @@ -4909,9 +4909,9 @@ function FARKodeGetNumRelaxSolveFails(arkode_mem, fails) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: fails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(fails(1)) @@ -4925,9 +4925,9 @@ function FARKodeGetNumRelaxSolveIters(arkode_mem, iters) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: iters -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(iters(1)) @@ -4941,9 +4941,9 @@ function FARKodeCreateSUNStepper(arkode_mem, stepper) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_PTR), target, intent(inout) :: stepper -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(stepper) @@ -4959,11 +4959,11 @@ function FARKBandPrecInit(arkode_mem, n, mu, ml) & integer(C_INT64_T), intent(in) :: n integer(C_INT64_T), intent(in) :: mu integer(C_INT64_T), intent(in) :: ml -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT64_T) :: farg2 -integer(C_INT64_T) :: farg3 -integer(C_INT64_T) :: farg4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT64_T) :: farg2 +integer(C_INT64_T) :: farg3 +integer(C_INT64_T) :: farg4 farg1 = arkode_mem farg2 = n @@ -4980,10 +4980,10 @@ function FARKBandPrecGetWorkSpace(arkode_mem, lenrwls, leniwls) & type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: lenrwls integer(C_LONG), dimension(*), target, intent(inout) :: leniwls -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = c_loc(lenrwls(1)) @@ -4998,9 +4998,9 @@ function FARKBandPrecGetNumRhsEvals(arkode_mem, nfevalsbp) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nfevalsbp -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nfevalsbp(1)) @@ -5021,16 +5021,16 @@ function FARKBBDPrecInit(arkode_mem, nlocal, mudq, mldq, mukeep, mlkeep, dqrely, real(C_DOUBLE), intent(in) :: dqrely type(C_FUNPTR), intent(in), value :: gloc type(C_FUNPTR), intent(in), value :: cfn -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT64_T) :: farg2 -integer(C_INT64_T) :: farg3 -integer(C_INT64_T) :: farg4 -integer(C_INT64_T) :: farg5 -integer(C_INT64_T) :: farg6 -real(C_DOUBLE) :: farg7 -type(C_FUNPTR) :: farg8 -type(C_FUNPTR) :: farg9 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT64_T) :: farg2 +integer(C_INT64_T) :: farg3 +integer(C_INT64_T) :: farg4 +integer(C_INT64_T) :: farg5 +integer(C_INT64_T) :: farg6 +real(C_DOUBLE) :: farg7 +type(C_FUNPTR) :: farg8 +type(C_FUNPTR) :: farg9 farg1 = arkode_mem farg2 = nlocal @@ -5053,11 +5053,11 @@ function FARKBBDPrecReInit(arkode_mem, mudq, mldq, dqrely) & integer(C_INT64_T), intent(in) :: mudq integer(C_INT64_T), intent(in) :: mldq real(C_DOUBLE), intent(in) :: dqrely -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT64_T) :: farg2 -integer(C_INT64_T) :: farg3 -real(C_DOUBLE) :: farg4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT64_T) :: farg2 +integer(C_INT64_T) :: farg3 +real(C_DOUBLE) :: farg4 farg1 = arkode_mem farg2 = mudq @@ -5074,10 +5074,10 @@ function FARKBBDPrecGetWorkSpace(arkode_mem, lenrwbbdp, leniwbbdp) & type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: lenrwbbdp integer(C_LONG), dimension(*), target, intent(inout) :: leniwbbdp -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = c_loc(lenrwbbdp(1)) @@ -5092,9 +5092,9 @@ function FARKBBDPrecGetNumGfnEvals(arkode_mem, ngevalsbbdp) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: ngevalsbbdp -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(ngevalsbbdp(1)) @@ -5106,8 +5106,8 @@ subroutine swigf_ARKodeButcherTableMem_q_set(self, q) use, intrinsic :: ISO_C_BINDING class(ARKodeButcherTableMem), intent(in) :: self integer(C_INT), intent(in) :: q -type(SwigClassWrapper) :: farg1 -integer(C_INT) :: farg2 +type(SwigClassWrapper) :: farg1 +integer(C_INT) :: farg2 farg1 = self%swigdata farg2 = q @@ -5119,8 +5119,8 @@ function swigf_ARKodeButcherTableMem_q_get(self) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result class(ARKodeButcherTableMem), intent(in) :: self -integer(C_INT) :: fresult -type(SwigClassWrapper) :: farg1 +integer(C_INT) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeButcherTableMem_q_get(farg1) @@ -5131,8 +5131,8 @@ subroutine swigf_ARKodeButcherTableMem_p_set(self, p) use, intrinsic :: ISO_C_BINDING class(ARKodeButcherTableMem), intent(in) :: self integer(C_INT), intent(in) :: p -type(SwigClassWrapper) :: farg1 -integer(C_INT) :: farg2 +type(SwigClassWrapper) :: farg1 +integer(C_INT) :: farg2 farg1 = self%swigdata farg2 = p @@ -5144,8 +5144,8 @@ function swigf_ARKodeButcherTableMem_p_get(self) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result class(ARKodeButcherTableMem), intent(in) :: self -integer(C_INT) :: fresult -type(SwigClassWrapper) :: farg1 +integer(C_INT) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeButcherTableMem_p_get(farg1) @@ -5156,8 +5156,8 @@ subroutine swigf_ARKodeButcherTableMem_stages_set(self, stages) use, intrinsic :: ISO_C_BINDING class(ARKodeButcherTableMem), intent(in) :: self integer(C_INT), intent(in) :: stages -type(SwigClassWrapper) :: farg1 -integer(C_INT) :: farg2 +type(SwigClassWrapper) :: farg1 +integer(C_INT) :: farg2 farg1 = self%swigdata farg2 = stages @@ -5169,8 +5169,8 @@ function swigf_ARKodeButcherTableMem_stages_get(self) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result class(ARKodeButcherTableMem), intent(in) :: self -integer(C_INT) :: fresult -type(SwigClassWrapper) :: farg1 +integer(C_INT) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeButcherTableMem_stages_get(farg1) @@ -5181,8 +5181,8 @@ subroutine swigf_ARKodeButcherTableMem_A_set(self, a) use, intrinsic :: ISO_C_BINDING class(ARKodeButcherTableMem), intent(in) :: self type(C_PTR), target, intent(inout) :: a -type(SwigClassWrapper) :: farg1 -type(C_PTR) :: farg2 +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: farg2 farg1 = self%swigdata farg2 = c_loc(a) @@ -5194,8 +5194,8 @@ function swigf_ARKodeButcherTableMem_A_get(self) & use, intrinsic :: ISO_C_BINDING type(C_PTR), pointer :: swig_result class(ARKodeButcherTableMem), intent(in) :: self -type(C_PTR) :: fresult -type(SwigClassWrapper) :: farg1 +type(C_PTR) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeButcherTableMem_A_get(farg1) @@ -5206,8 +5206,8 @@ subroutine swigf_ARKodeButcherTableMem_c_set(self, c) use, intrinsic :: ISO_C_BINDING class(ARKodeButcherTableMem), intent(in) :: self real(C_DOUBLE), dimension(*), target, intent(inout) :: c -type(SwigClassWrapper) :: farg1 -type(C_PTR) :: farg2 +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: farg2 farg1 = self%swigdata farg2 = c_loc(c(1)) @@ -5219,8 +5219,8 @@ function swigf_ARKodeButcherTableMem_c_get(self) & use, intrinsic :: ISO_C_BINDING real(C_DOUBLE), dimension(:), pointer :: swig_result class(ARKodeButcherTableMem), intent(in) :: self -type(C_PTR) :: fresult -type(SwigClassWrapper) :: farg1 +type(C_PTR) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeButcherTableMem_c_get(farg1) @@ -5231,8 +5231,8 @@ subroutine swigf_ARKodeButcherTableMem_b_set(self, b) use, intrinsic :: ISO_C_BINDING class(ARKodeButcherTableMem), intent(in) :: self real(C_DOUBLE), dimension(*), target, intent(inout) :: b -type(SwigClassWrapper) :: farg1 -type(C_PTR) :: farg2 +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: farg2 farg1 = self%swigdata farg2 = c_loc(b(1)) @@ -5244,8 +5244,8 @@ function swigf_ARKodeButcherTableMem_b_get(self) & use, intrinsic :: ISO_C_BINDING real(C_DOUBLE), dimension(:), pointer :: swig_result class(ARKodeButcherTableMem), intent(in) :: self -type(C_PTR) :: fresult -type(SwigClassWrapper) :: farg1 +type(C_PTR) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeButcherTableMem_b_get(farg1) @@ -5256,8 +5256,8 @@ subroutine swigf_ARKodeButcherTableMem_d_set(self, d) use, intrinsic :: ISO_C_BINDING class(ARKodeButcherTableMem), intent(in) :: self real(C_DOUBLE), dimension(*), target, intent(inout) :: d -type(SwigClassWrapper) :: farg1 -type(C_PTR) :: farg2 +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: farg2 farg1 = self%swigdata farg2 = c_loc(d(1)) @@ -5269,8 +5269,8 @@ function swigf_ARKodeButcherTableMem_d_get(self) & use, intrinsic :: ISO_C_BINDING real(C_DOUBLE), dimension(:), pointer :: swig_result class(ARKodeButcherTableMem), intent(in) :: self -type(C_PTR) :: fresult -type(SwigClassWrapper) :: farg1 +type(C_PTR) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeButcherTableMem_d_get(farg1) @@ -5281,7 +5281,7 @@ function swigf_create_ARKodeButcherTableMem() & result(self) use, intrinsic :: ISO_C_BINDING type(ARKodeButcherTableMem) :: self -type(SwigClassWrapper) :: fresult +type(SwigClassWrapper) :: fresult fresult = swigc_new_ARKodeButcherTableMem() self%swigdata = fresult @@ -5290,7 +5290,7 @@ function swigf_create_ARKodeButcherTableMem() & subroutine swigf_release_ARKodeButcherTableMem(self) use, intrinsic :: ISO_C_BINDING class(ARKodeButcherTableMem), intent(inout) :: self -type(SwigClassWrapper) :: farg1 +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata if (btest(farg1%cmemflags, swig_cmem_own_bit)) then @@ -5305,8 +5305,8 @@ subroutine swigf_ARKodeButcherTableMem_op_assign__(self, other) use, intrinsic :: ISO_C_BINDING class(ARKodeButcherTableMem), intent(inout) :: self type(ARKodeButcherTableMem), intent(in) :: other -type(SwigClassWrapper) :: farg1 -type(SwigClassWrapper) :: farg2 +type(SwigClassWrapper) :: farg1 +type(SwigClassWrapper) :: farg2 farg1 = self%swigdata farg2 = other%swigdata @@ -5320,9 +5320,9 @@ function FARKodeButcherTable_Alloc(stages, embedded) & type(C_PTR) :: swig_result integer(C_INT), intent(in) :: stages integer(C_INT), intent(in) :: embedded -type(C_PTR) :: fresult -integer(C_INT) :: farg1 -integer(C_INT) :: farg2 +type(C_PTR) :: fresult +integer(C_INT) :: farg1 +integer(C_INT) :: farg2 farg1 = stages farg2 = embedded @@ -5341,14 +5341,14 @@ function FARKodeButcherTable_Create(s, q, p, c, a, b, d) & real(C_DOUBLE), dimension(*), target, intent(inout) :: a real(C_DOUBLE), dimension(*), target, intent(inout) :: b real(C_DOUBLE), dimension(*), target, intent(inout) :: d -type(C_PTR) :: fresult -integer(C_INT) :: farg1 -integer(C_INT) :: farg2 -integer(C_INT) :: farg3 -type(C_PTR) :: farg4 -type(C_PTR) :: farg5 -type(C_PTR) :: farg6 -type(C_PTR) :: farg7 +type(C_PTR) :: fresult +integer(C_INT) :: farg1 +integer(C_INT) :: farg2 +integer(C_INT) :: farg3 +type(C_PTR) :: farg4 +type(C_PTR) :: farg5 +type(C_PTR) :: farg6 +type(C_PTR) :: farg7 farg1 = s farg2 = q @@ -5366,8 +5366,8 @@ function FARKodeButcherTable_Copy(b) & use, intrinsic :: ISO_C_BINDING type(C_PTR) :: swig_result type(C_PTR) :: b -type(C_PTR) :: fresult -type(C_PTR) :: farg1 +type(C_PTR) :: fresult +type(C_PTR) :: farg1 farg1 = b fresult = swigc_FARKodeButcherTable_Copy(farg1) @@ -5379,9 +5379,9 @@ subroutine FARKodeButcherTable_Space(b, liw, lrw) type(C_PTR) :: b integer(C_INT64_T), dimension(*), target, intent(inout) :: liw integer(C_INT64_T), dimension(*), target, intent(inout) :: lrw -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = b farg2 = c_loc(liw(1)) @@ -5392,7 +5392,7 @@ subroutine FARKodeButcherTable_Space(b, liw, lrw) subroutine FARKodeButcherTable_Free(b) use, intrinsic :: ISO_C_BINDING type(C_PTR) :: b -type(C_PTR) :: farg1 +type(C_PTR) :: farg1 farg1 = b call swigc_FARKodeButcherTable_Free(farg1) @@ -5402,8 +5402,8 @@ subroutine FARKodeButcherTable_Write(b, outfile) use, intrinsic :: ISO_C_BINDING type(C_PTR) :: b type(C_PTR) :: outfile -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = b farg2 = outfile @@ -5415,8 +5415,8 @@ function FARKodeButcherTable_IsStifflyAccurate(b) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: b -integer(C_INT) :: fresult -type(C_PTR) :: farg1 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 farg1 = b fresult = swigc_FARKodeButcherTable_IsStifflyAccurate(farg1) @@ -5431,11 +5431,11 @@ function FARKodeButcherTable_CheckOrder(b, q, p, outfile) & integer(C_INT), dimension(*), target, intent(inout) :: q integer(C_INT), dimension(*), target, intent(inout) :: p type(C_PTR) :: outfile -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 farg1 = b farg2 = c_loc(q(1)) @@ -5454,12 +5454,12 @@ function FARKodeButcherTable_CheckARKOrder(b1, b2, q, p, outfile) & integer(C_INT), dimension(*), target, intent(inout) :: q integer(C_INT), dimension(*), target, intent(inout) :: p type(C_PTR) :: outfile -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 -type(C_PTR) :: farg5 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 +type(C_PTR) :: farg5 farg1 = b1 farg2 = b2 @@ -5475,8 +5475,8 @@ function FARKodeButcherTable_LoadDIRK(imethod) & use, intrinsic :: ISO_C_BINDING type(C_PTR) :: swig_result integer(ARKODE_DIRKTableID), intent(in) :: imethod -type(C_PTR) :: fresult -integer(C_INT) :: farg1 +type(C_PTR) :: fresult +integer(C_INT) :: farg1 farg1 = imethod fresult = swigc_FARKodeButcherTable_LoadDIRK(farg1) @@ -5489,8 +5489,8 @@ function FARKodeButcherTable_LoadDIRKByName(imethod) & type(C_PTR) :: swig_result character(kind=C_CHAR, len=*), target :: imethod character(kind=C_CHAR), dimension(:), allocatable, target :: farg1_chars -type(C_PTR) :: fresult -type(SwigArrayWrapper) :: farg1 +type(C_PTR) :: fresult +type(SwigArrayWrapper) :: farg1 call SWIG_string_to_chararray(imethod, farg1_chars, farg1) fresult = swigc_FARKodeButcherTable_LoadDIRKByName(farg1) @@ -5502,8 +5502,8 @@ function FARKodeButcherTable_DIRKIDToName(imethod) & use, intrinsic :: ISO_C_BINDING character(kind=C_CHAR, len=:), allocatable :: swig_result integer(ARKODE_DIRKTableID), intent(in) :: imethod -type(SwigArrayWrapper) :: fresult -integer(C_INT) :: farg1 +type(SwigArrayWrapper) :: fresult +integer(C_INT) :: farg1 farg1 = imethod fresult = swigc_FARKodeButcherTable_DIRKIDToName(farg1) @@ -5516,8 +5516,8 @@ function FARKodeButcherTable_LoadERK(emethod) & use, intrinsic :: ISO_C_BINDING type(C_PTR) :: swig_result integer(ARKODE_ERKTableID), intent(in) :: emethod -type(C_PTR) :: fresult -integer(C_INT) :: farg1 +type(C_PTR) :: fresult +integer(C_INT) :: farg1 farg1 = emethod fresult = swigc_FARKodeButcherTable_LoadERK(farg1) @@ -5530,8 +5530,8 @@ function FARKodeButcherTable_LoadERKByName(emethod) & type(C_PTR) :: swig_result character(kind=C_CHAR, len=*), target :: emethod character(kind=C_CHAR), dimension(:), allocatable, target :: farg1_chars -type(C_PTR) :: fresult -type(SwigArrayWrapper) :: farg1 +type(C_PTR) :: fresult +type(SwigArrayWrapper) :: farg1 call SWIG_string_to_chararray(emethod, farg1_chars, farg1) fresult = swigc_FARKodeButcherTable_LoadERKByName(farg1) @@ -5543,8 +5543,8 @@ function FARKodeButcherTable_ERKIDToName(emethod) & use, intrinsic :: ISO_C_BINDING character(kind=C_CHAR, len=:), allocatable :: swig_result integer(ARKODE_ERKTableID), intent(in) :: emethod -type(SwigArrayWrapper) :: fresult -integer(C_INT) :: farg1 +type(SwigArrayWrapper) :: fresult +integer(C_INT) :: farg1 farg1 = emethod fresult = swigc_FARKodeButcherTable_ERKIDToName(farg1) @@ -5556,8 +5556,8 @@ subroutine swigf_ARKodeSPRKTableMem_q_set(self, q) use, intrinsic :: ISO_C_BINDING class(ARKodeSPRKTableMem), intent(in) :: self integer(C_INT), intent(in) :: q -type(SwigClassWrapper) :: farg1 -integer(C_INT) :: farg2 +type(SwigClassWrapper) :: farg1 +integer(C_INT) :: farg2 farg1 = self%swigdata farg2 = q @@ -5569,8 +5569,8 @@ function swigf_ARKodeSPRKTableMem_q_get(self) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result class(ARKodeSPRKTableMem), intent(in) :: self -integer(C_INT) :: fresult -type(SwigClassWrapper) :: farg1 +integer(C_INT) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeSPRKTableMem_q_get(farg1) @@ -5581,8 +5581,8 @@ subroutine swigf_ARKodeSPRKTableMem_stages_set(self, stages) use, intrinsic :: ISO_C_BINDING class(ARKodeSPRKTableMem), intent(in) :: self integer(C_INT), intent(in) :: stages -type(SwigClassWrapper) :: farg1 -integer(C_INT) :: farg2 +type(SwigClassWrapper) :: farg1 +integer(C_INT) :: farg2 farg1 = self%swigdata farg2 = stages @@ -5594,8 +5594,8 @@ function swigf_ARKodeSPRKTableMem_stages_get(self) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result class(ARKodeSPRKTableMem), intent(in) :: self -integer(C_INT) :: fresult -type(SwigClassWrapper) :: farg1 +integer(C_INT) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeSPRKTableMem_stages_get(farg1) @@ -5606,8 +5606,8 @@ subroutine swigf_ARKodeSPRKTableMem_a_set(self, a) use, intrinsic :: ISO_C_BINDING class(ARKodeSPRKTableMem), intent(in) :: self real(C_DOUBLE), dimension(*), target, intent(inout) :: a -type(SwigClassWrapper) :: farg1 -type(C_PTR) :: farg2 +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: farg2 farg1 = self%swigdata farg2 = c_loc(a(1)) @@ -5619,8 +5619,8 @@ function swigf_ARKodeSPRKTableMem_a_get(self) & use, intrinsic :: ISO_C_BINDING real(C_DOUBLE), dimension(:), pointer :: swig_result class(ARKodeSPRKTableMem), intent(in) :: self -type(C_PTR) :: fresult -type(SwigClassWrapper) :: farg1 +type(C_PTR) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeSPRKTableMem_a_get(farg1) @@ -5631,8 +5631,8 @@ subroutine swigf_ARKodeSPRKTableMem_ahat_set(self, ahat) use, intrinsic :: ISO_C_BINDING class(ARKodeSPRKTableMem), intent(in) :: self real(C_DOUBLE), dimension(*), target, intent(inout) :: ahat -type(SwigClassWrapper) :: farg1 -type(C_PTR) :: farg2 +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: farg2 farg1 = self%swigdata farg2 = c_loc(ahat(1)) @@ -5644,8 +5644,8 @@ function swigf_ARKodeSPRKTableMem_ahat_get(self) & use, intrinsic :: ISO_C_BINDING real(C_DOUBLE), dimension(:), pointer :: swig_result class(ARKodeSPRKTableMem), intent(in) :: self -type(C_PTR) :: fresult -type(SwigClassWrapper) :: farg1 +type(C_PTR) :: fresult +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata fresult = swigc_ARKodeSPRKTableMem_ahat_get(farg1) @@ -5656,7 +5656,7 @@ function swigf_create_ARKodeSPRKTableMem() & result(self) use, intrinsic :: ISO_C_BINDING type(ARKodeSPRKTableMem) :: self -type(SwigClassWrapper) :: fresult +type(SwigClassWrapper) :: fresult fresult = swigc_new_ARKodeSPRKTableMem() self%swigdata = fresult @@ -5665,7 +5665,7 @@ function swigf_create_ARKodeSPRKTableMem() & subroutine swigf_release_ARKodeSPRKTableMem(self) use, intrinsic :: ISO_C_BINDING class(ARKodeSPRKTableMem), intent(inout) :: self -type(SwigClassWrapper) :: farg1 +type(SwigClassWrapper) :: farg1 farg1 = self%swigdata if (btest(farg1%cmemflags, swig_cmem_own_bit)) then @@ -5680,8 +5680,8 @@ subroutine swigf_ARKodeSPRKTableMem_op_assign__(self, other) use, intrinsic :: ISO_C_BINDING class(ARKodeSPRKTableMem), intent(inout) :: self type(ARKodeSPRKTableMem), intent(in) :: other -type(SwigClassWrapper) :: farg1 -type(SwigClassWrapper) :: farg2 +type(SwigClassWrapper) :: farg1 +type(SwigClassWrapper) :: farg2 farg1 = self%swigdata farg2 = other%swigdata @@ -5697,11 +5697,11 @@ function FARKodeSPRKTable_Create(s, q, a, ahat) & integer(C_INT), intent(in) :: q real(C_DOUBLE), dimension(*), target, intent(inout) :: a real(C_DOUBLE), dimension(*), target, intent(inout) :: ahat -type(C_PTR) :: fresult -integer(C_INT) :: farg1 -integer(C_INT) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 +type(C_PTR) :: fresult +integer(C_INT) :: farg1 +integer(C_INT) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 farg1 = s farg2 = q @@ -5716,8 +5716,8 @@ function FARKodeSPRKTable_Alloc(stages) & use, intrinsic :: ISO_C_BINDING type(C_PTR) :: swig_result integer(C_INT), intent(in) :: stages -type(C_PTR) :: fresult -integer(C_INT) :: farg1 +type(C_PTR) :: fresult +integer(C_INT) :: farg1 farg1 = stages fresult = swigc_FARKodeSPRKTable_Alloc(farg1) @@ -5729,8 +5729,8 @@ function FARKodeSPRKTable_Load(id) & use, intrinsic :: ISO_C_BINDING type(C_PTR) :: swig_result integer(ARKODE_SPRKMethodID), intent(in) :: id -type(C_PTR) :: fresult -integer(C_INT) :: farg1 +type(C_PTR) :: fresult +integer(C_INT) :: farg1 farg1 = id fresult = swigc_FARKodeSPRKTable_Load(farg1) @@ -5743,8 +5743,8 @@ function FARKodeSPRKTable_LoadByName(method) & type(C_PTR) :: swig_result character(kind=C_CHAR, len=*), target :: method character(kind=C_CHAR), dimension(:), allocatable, target :: farg1_chars -type(C_PTR) :: fresult -type(SwigArrayWrapper) :: farg1 +type(C_PTR) :: fresult +type(SwigArrayWrapper) :: farg1 call SWIG_string_to_chararray(method, farg1_chars, farg1) fresult = swigc_FARKodeSPRKTable_LoadByName(farg1) @@ -5756,8 +5756,8 @@ function FARKodeSPRKTable_Copy(that_sprk_storage) & use, intrinsic :: ISO_C_BINDING type(C_PTR) :: swig_result type(C_PTR) :: that_sprk_storage -type(C_PTR) :: fresult -type(C_PTR) :: farg1 +type(C_PTR) :: fresult +type(C_PTR) :: farg1 farg1 = that_sprk_storage fresult = swigc_FARKodeSPRKTable_Copy(farg1) @@ -5768,8 +5768,8 @@ subroutine FARKodeSPRKTable_Write(sprk_table, outfile) use, intrinsic :: ISO_C_BINDING type(C_PTR) :: sprk_table type(C_PTR) :: outfile -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = sprk_table farg2 = outfile @@ -5781,9 +5781,9 @@ subroutine FARKodeSPRKTable_Space(sprk_storage, liw, lrw) type(C_PTR) :: sprk_storage integer(C_INT64_T), dimension(*), target, intent(inout) :: liw integer(C_INT64_T), dimension(*), target, intent(inout) :: lrw -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = sprk_storage farg2 = c_loc(liw(1)) @@ -5794,7 +5794,7 @@ subroutine FARKodeSPRKTable_Space(sprk_storage, liw, lrw) subroutine FARKodeSPRKTable_Free(sprk_storage) use, intrinsic :: ISO_C_BINDING type(C_PTR) :: sprk_storage -type(C_PTR) :: farg1 +type(C_PTR) :: farg1 farg1 = sprk_storage call swigc_FARKodeSPRKTable_Free(farg1) @@ -5807,10 +5807,10 @@ function FARKodeSPRKTable_ToButcher(sprk_storage, a_ptr, b_ptr) & type(C_PTR) :: sprk_storage type(C_PTR), target, intent(inout) :: a_ptr type(C_PTR), target, intent(inout) :: b_ptr -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = sprk_storage farg2 = c_loc(a_ptr) @@ -5826,10 +5826,10 @@ function FARKodeSetLinearSolver(arkode_mem, ls, a) & type(C_PTR) :: arkode_mem type(SUNLinearSolver), target, intent(inout) :: ls type(SUNMatrix), target, intent(inout) :: a -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 farg1 = arkode_mem farg2 = c_loc(ls) @@ -5846,11 +5846,11 @@ function FARKodeSetMassLinearSolver(arkode_mem, ls, m, time_dep) & type(SUNLinearSolver), target, intent(inout) :: ls type(SUNMatrix), target, intent(inout) :: m integer(C_INT), intent(in) :: time_dep -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 -integer(C_INT) :: farg4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 +integer(C_INT) :: farg4 farg1 = arkode_mem farg2 = c_loc(ls) @@ -5866,9 +5866,9 @@ function FARKodeSetJacFn(arkode_mem, jac) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: jac -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = jac @@ -5882,9 +5882,9 @@ function FARKodeSetMassFn(arkode_mem, mass) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: mass -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = mass @@ -5898,9 +5898,9 @@ function FARKodeSetJacEvalFrequency(arkode_mem, msbj) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), intent(in) :: msbj -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_LONG) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_LONG) :: farg2 farg1 = arkode_mem farg2 = msbj @@ -5914,9 +5914,9 @@ function FARKodeSetLinearSolutionScaling(arkode_mem, onoff) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: onoff -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = onoff @@ -5930,9 +5930,9 @@ function FARKodeSetEpsLin(arkode_mem, eplifac) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: eplifac -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = eplifac @@ -5946,9 +5946,9 @@ function FARKodeSetMassEpsLin(arkode_mem, eplifac) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: eplifac -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = eplifac @@ -5962,9 +5962,9 @@ function FARKodeSetLSNormFactor(arkode_mem, nrmfac) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: nrmfac -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = nrmfac @@ -5978,9 +5978,9 @@ function FARKodeSetMassLSNormFactor(arkode_mem, nrmfac) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: nrmfac -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = nrmfac @@ -5995,10 +5995,10 @@ function FARKodeSetPreconditioner(arkode_mem, psetup, psolve) & type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: psetup type(C_FUNPTR), intent(in), value :: psolve -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -type(C_FUNPTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +type(C_FUNPTR) :: farg3 farg1 = arkode_mem farg2 = psetup @@ -6014,10 +6014,10 @@ function FARKodeSetMassPreconditioner(arkode_mem, psetup, psolve) & type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: psetup type(C_FUNPTR), intent(in), value :: psolve -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -type(C_FUNPTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +type(C_FUNPTR) :: farg3 farg1 = arkode_mem farg2 = psetup @@ -6033,10 +6033,10 @@ function FARKodeSetJacTimes(arkode_mem, jtsetup, jtimes) & type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: jtsetup type(C_FUNPTR), intent(in), value :: jtimes -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -type(C_FUNPTR) :: farg3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +type(C_FUNPTR) :: farg3 farg1 = arkode_mem farg2 = jtsetup @@ -6051,9 +6051,9 @@ function FARKodeSetJacTimesRhsFn(arkode_mem, jtimesrhsfn) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: jtimesrhsfn -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = jtimesrhsfn @@ -6069,11 +6069,11 @@ function FARKodeSetMassTimes(arkode_mem, msetup, mtimes, mtimes_data) & type(C_FUNPTR), intent(in), value :: msetup type(C_FUNPTR), intent(in), value :: mtimes type(C_PTR) :: mtimes_data -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -type(C_FUNPTR) :: farg3 -type(C_PTR) :: farg4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +type(C_FUNPTR) :: farg3 +type(C_PTR) :: farg4 farg1 = arkode_mem farg2 = msetup @@ -6089,9 +6089,9 @@ function FARKodeSetLinSysFn(arkode_mem, linsys) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: linsys -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = linsys diff --git a/src/sundials/CMakeLists.txt b/src/sundials/CMakeLists.txt index 26fa56fd34..2e377590f3 100644 --- a/src/sundials/CMakeLists.txt +++ b/src/sundials/CMakeLists.txt @@ -135,7 +135,9 @@ sundials_add_library( SOURCES ${sundials_SOURCES} HEADERS ${sundials_HEADERS} INCLUDE_SUBDIR sundials - LINK_LIBRARIES ${_link_mpi_if_needed} ${_link_lapack_if_needed} #TODO: Do we need to link lapack here? + LINK_LIBRARIES + ${_link_mpi_if_needed} ${_link_lapack_if_needed} # TODO: Do we need to link + # lapack here? OUTPUT_NAME sundials_core VERSION ${sundialslib_VERSION} SOVERSION ${sundialslib_SOVERSION}) diff --git a/src/sundials/fmod_int32/fsundials_core_mod.f90 b/src/sundials/fmod_int32/fsundials_core_mod.f90 index 4dc4121ea1..16e52a13fb 100644 --- a/src/sundials/fmod_int32/fsundials_core_mod.f90 +++ b/src/sundials/fmod_int32/fsundials_core_mod.f90 @@ -98,6 +98,8 @@ module fsundials_core_mod enumerator :: SUN_ERR_DEE_NULL_MEM enumerator :: SUN_ERR_DEE_NULL_CONTENT enumerator :: SUN_ERR_DEE_LAPACK_FAIL + enumerator :: SUN_ERR_DEE_NULL_ESTIMATE + enumerator :: SUN_ERR_DEE_NULL_FREE enumerator :: SUN_ERR_SUNCTX_CORRUPT enumerator :: SUN_ERR_MPI_FAIL enumerator :: SUN_ERR_UNREACHABLE @@ -112,8 +114,8 @@ module fsundials_core_mod SUN_ERR_PROFILER_MAPINSERT, SUN_ERR_PROFILER_MAPKEYNOTFOUND, SUN_ERR_PROFILER_MAPSORT, SUN_ERR_ADJOINT_STEPPERFAILED, & SUN_ERR_ADJOINT_STEPPERINVALIDSTOP, SUN_ERR_CHECKPOINT_NOT_FOUND, SUN_ERR_CHECKPOINT_MISMATCH, SUN_ERR_DEE_BAD_NVECTOR, & SUN_ERR_DEE_NULL_ATIMES, SUN_ERR_DEE_ATIMES_FAIL_REC, SUN_ERR_DEE_ATIMES_FAIL_UNREC, SUN_ERR_DEE_NULL_HES, & - SUN_ERR_DEE_NULL_MEM, SUN_ERR_DEE_NULL_CONTENT, SUN_ERR_DEE_LAPACK_FAIL, SUN_ERR_SUNCTX_CORRUPT, SUN_ERR_MPI_FAIL, & - SUN_ERR_UNREACHABLE, SUN_ERR_UNKNOWN, SUN_ERR_MAXIMUM, SUN_SUCCESS + SUN_ERR_DEE_NULL_MEM, SUN_ERR_DEE_NULL_CONTENT, SUN_ERR_DEE_LAPACK_FAIL, SUN_ERR_DEE_NULL_ESTIMATE, SUN_ERR_DEE_NULL_FREE, & + SUN_ERR_SUNCTX_CORRUPT, SUN_ERR_MPI_FAIL, SUN_ERR_UNREACHABLE, SUN_ERR_UNKNOWN, SUN_ERR_MAXIMUM, SUN_SUCCESS type, bind(C) :: SwigArrayWrapper type(C_PTR), public :: data = C_NULL_PTR integer(C_SIZE_T), public :: size = 0 diff --git a/src/sundials/fmod_int64/fsundials_core_mod.f90 b/src/sundials/fmod_int64/fsundials_core_mod.f90 index 416e45718e..ec2a749cb1 100644 --- a/src/sundials/fmod_int64/fsundials_core_mod.f90 +++ b/src/sundials/fmod_int64/fsundials_core_mod.f90 @@ -98,6 +98,8 @@ module fsundials_core_mod enumerator :: SUN_ERR_DEE_NULL_MEM enumerator :: SUN_ERR_DEE_NULL_CONTENT enumerator :: SUN_ERR_DEE_LAPACK_FAIL + enumerator :: SUN_ERR_DEE_NULL_ESTIMATE + enumerator :: SUN_ERR_DEE_NULL_FREE enumerator :: SUN_ERR_SUNCTX_CORRUPT enumerator :: SUN_ERR_MPI_FAIL enumerator :: SUN_ERR_UNREACHABLE @@ -112,8 +114,8 @@ module fsundials_core_mod SUN_ERR_PROFILER_MAPINSERT, SUN_ERR_PROFILER_MAPKEYNOTFOUND, SUN_ERR_PROFILER_MAPSORT, SUN_ERR_ADJOINT_STEPPERFAILED, & SUN_ERR_ADJOINT_STEPPERINVALIDSTOP, SUN_ERR_CHECKPOINT_NOT_FOUND, SUN_ERR_CHECKPOINT_MISMATCH, SUN_ERR_DEE_BAD_NVECTOR, & SUN_ERR_DEE_NULL_ATIMES, SUN_ERR_DEE_ATIMES_FAIL_REC, SUN_ERR_DEE_ATIMES_FAIL_UNREC, SUN_ERR_DEE_NULL_HES, & - SUN_ERR_DEE_NULL_MEM, SUN_ERR_DEE_NULL_CONTENT, SUN_ERR_DEE_LAPACK_FAIL, SUN_ERR_SUNCTX_CORRUPT, SUN_ERR_MPI_FAIL, & - SUN_ERR_UNREACHABLE, SUN_ERR_UNKNOWN, SUN_ERR_MAXIMUM, SUN_SUCCESS + SUN_ERR_DEE_NULL_MEM, SUN_ERR_DEE_NULL_CONTENT, SUN_ERR_DEE_LAPACK_FAIL, SUN_ERR_DEE_NULL_ESTIMATE, SUN_ERR_DEE_NULL_FREE, & + SUN_ERR_SUNCTX_CORRUPT, SUN_ERR_MPI_FAIL, SUN_ERR_UNREACHABLE, SUN_ERR_UNKNOWN, SUN_ERR_MAXIMUM, SUN_SUCCESS type, bind(C) :: SwigArrayWrapper type(C_PTR), public :: data = C_NULL_PTR integer(C_SIZE_T), public :: size = 0 diff --git a/src/sundials/sundials_domeigestimator.c b/src/sundials/sundials_domeigestimator.c index b5f9043566..344e25c6c9 100644 --- a/src/sundials/sundials_domeigestimator.c +++ b/src/sundials/sundials_domeigestimator.c @@ -109,14 +109,11 @@ SUNErrCode SUNDomEigEstSetATimes(SUNDomEigEstimator DEE, void* A_data, return (ier); } -SUNErrCode SUNDomEigEstSetMaxPowerIter(SUNDomEigEstimator DEE, int max_powiter) +SUNErrCode SUNDomEigEstInitialize(SUNDomEigEstimator DEE) { SUNErrCode ier; SUNDIALS_MARK_FUNCTION_BEGIN(getSUNProfiler(DEE)); - if (DEE->ops->setmaxpoweriter) - { - ier = DEE->ops->setmaxpoweriter(DEE, max_powiter); - } + if (DEE->ops->initialize) { ier = DEE->ops->initialize(DEE); } else { ier = SUN_SUCCESS; } SUNDIALS_MARK_FUNCTION_END(getSUNProfiler(DEE)); return (ier); @@ -136,11 +133,27 @@ SUNErrCode SUNDomEigEstSetNumPreProcess(SUNDomEigEstimator DEE, return (ier); } -SUNErrCode SUNDomEigEstInitialize(SUNDomEigEstimator DEE) +SUNErrCode SUNDomEigEstSetTol(SUNDomEigEstimator DEE, sunrealtype tol) { SUNErrCode ier; SUNDIALS_MARK_FUNCTION_BEGIN(getSUNProfiler(DEE)); - if (DEE->ops->initialize) { ier = DEE->ops->initialize(DEE); } + if (DEE->ops->settol) + { + ier = DEE->ops->settol(DEE, tol); + } + else { ier = SUN_SUCCESS; } + SUNDIALS_MARK_FUNCTION_END(getSUNProfiler(DEE)); + return (ier); +} + +SUNErrCode SUNDomEigEstSetMaxPowerIter(SUNDomEigEstimator DEE, int max_powiter) +{ + SUNErrCode ier; + SUNDIALS_MARK_FUNCTION_BEGIN(getSUNProfiler(DEE)); + if (DEE->ops->setmaxpoweriter) + { + ier = DEE->ops->setmaxpoweriter(DEE, max_powiter); + } else { ier = SUN_SUCCESS; } SUNDIALS_MARK_FUNCTION_END(getSUNProfiler(DEE)); return (ier); @@ -219,15 +232,8 @@ SUNErrCode SUNDomEigEstFree(SUNDomEigEstimator DEE) { SUNErrCode ier; SUNDIALS_MARK_FUNCTION_BEGIN(getSUNProfiler(DEE)); - if (DEE->ops->free) - { - ier = DEE->ops->free(DEE); - } - else - { - ier = SUN_ERR_DEE_NULL_FREE; - } + if (DEE->ops->free) { ier = DEE->ops->free(DEE); } + else { ier = SUN_ERR_DEE_NULL_FREE; } SUNDIALS_MARK_FUNCTION_END(getSUNProfiler(DEE)); return (ier); } - diff --git a/src/sundomeigest/ArnI/sundomeigest_arni.c b/src/sundomeigest/ArnI/sundomeigest_arni.c index 5809f82a98..a4c77255aa 100644 --- a/src/sundomeigest/ArnI/sundomeigest_arni.c +++ b/src/sundomeigest/ArnI/sundomeigest_arni.c @@ -20,8 +20,6 @@ #include #include -#include -#include #include #include "sundials_logger_impl.h" @@ -127,6 +125,18 @@ SUNDomEigEstimator_ID SUNDomEigEst_ArnIGetID( return (SUNDSOMEIGESTIMATOR_ARNOLDI); } +SUNErrCode SUNDomEigEstSetATimes_ArnI(SUNDomEigEstimator DEE, void* A_data, + SUNATimesFn ATimes) +{ + SUNFunctionBegin(DEE->sunctx); + + /* set function pointers to integrator-supplied ATimes routine + and data, and return with success */ + ArnI_CONTENT(DEE)->ATimes = ATimes; + ArnI_CONTENT(DEE)->ATdata = A_data; + return SUN_SUCCESS; +} + SUNErrCode SUNDomEigEstInitialize_ArnI(SUNDomEigEstimator DEE) { SUNFunctionBegin(DEE->sunctx); @@ -195,18 +205,6 @@ SUNErrCode SUNDomEigEstInitialize_ArnI(SUNDomEigEstimator DEE) return SUN_SUCCESS; } -SUNErrCode SUNDomEigEstSetATimes_ArnI(SUNDomEigEstimator DEE, void* A_data, - SUNATimesFn ATimes) -{ - SUNFunctionBegin(DEE->sunctx); - - /* set function pointers to integrator-supplied ATimes routine - and data, and return with success */ - ArnI_CONTENT(DEE)->ATimes = ATimes; - ArnI_CONTENT(DEE)->ATdata = A_data; - return SUN_SUCCESS; -} - SUNErrCode SUNDomEigEstSetNumPreProcess_ArnI(SUNDomEigEstimator DEE, int numofperprocess) { diff --git a/src/sundomeigest/PI/sundomeigest_pi.c b/src/sundomeigest/PI/sundomeigest_pi.c index a36ef8b828..7f6fc00916 100644 --- a/src/sundomeigest/PI/sundomeigest_pi.c +++ b/src/sundomeigest/PI/sundomeigest_pi.c @@ -20,8 +20,6 @@ #include #include -#include -#include #include #include "sundials_logger_impl.h" @@ -72,7 +70,7 @@ SUNDomEigEstimator SUNDomEigEst_PI(N_Vector q, int max_powiter, SUNContext sunct /* Attach operations */ DEE->ops->getid = SUNDomEigEst_PIGetID; DEE->ops->setatimes = SUNDomEigEstSetATimes_PI; - DEE->ops->setmaxpoweriter = SUNDomEigEst_PISetMaxPowerIter; + DEE->ops->setmaxpoweriter = SUNDomEigEstSetMaxPowerIter_PI; DEE->ops->settol = SUNDomEigEstSetTol_PI; DEE->ops->setnumofperprocess = SUNDomEigEstSetNumPreProcess_PI; DEE->ops->initialize = SUNDomEigEstInitialize_PI; @@ -124,6 +122,18 @@ SUNDomEigEstimator_ID SUNDomEigEst_PIGetID( return (SUNDSOMEIGESTIMATOR_POWER); } +SUNErrCode SUNDomEigEstSetATimes_PI(SUNDomEigEstimator DEE, void* A_data, + SUNATimesFn ATimes) +{ + SUNFunctionBegin(DEE->sunctx); + + /* set function pointers to integrator-supplied ATimes routine + and data, and return with success */ + PI_CONTENT(DEE)->ATimes = ATimes; + PI_CONTENT(DEE)->ATdata = A_data; + return SUN_SUCCESS; +} + SUNErrCode SUNDomEigEstInitialize_PI(SUNDomEigEstimator DEE) { SUNFunctionBegin(DEE->sunctx); @@ -179,19 +189,7 @@ SUNErrCode SUNDomEigEstSetTol_PI(SUNDomEigEstimator DEE, sunrealtype tol) return SUN_SUCCESS; } -SUNErrCode SUNDomEigEstSetATimes_PI(SUNDomEigEstimator DEE, void* A_data, - SUNATimesFn ATimes) -{ - SUNFunctionBegin(DEE->sunctx); - - /* set function pointers to integrator-supplied ATimes routine - and data, and return with success */ - PI_CONTENT(DEE)->ATimes = ATimes; - PI_CONTENT(DEE)->ATdata = A_data; - return SUN_SUCCESS; -} - -SUNErrCode SUNDomEigEst_PISetMaxPowerIter(SUNDomEigEstimator DEE, int max_powiter) +SUNErrCode SUNDomEigEstSetMaxPowerIter_PI(SUNDomEigEstimator DEE, int max_powiter) { SUNFunctionBegin(DEE->sunctx); diff --git a/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c b/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c index 00e315ab01..a75a447f97 100644 --- a/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c +++ b/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c @@ -16,13 +16,9 @@ * ----------------------------------------------------------------- */ -#include -#include -#include - -#include - #include "../test_sundomeigest.h" +#include +#include /* constants */ #define ZERO SUN_RCONST(0.0) @@ -53,10 +49,9 @@ int check_flag(void* flagvalue, const char* funcname, int opt); * --------------------------------------------------------------------*/ int main(int argc, char* argv[]) { - int fails = 0; /* counter for test failures */ + int fails = 0; /* counter for test failures */ int passfail = 0; /* overall pass/fail flag */ SUNDomEigEstimator DEE = NULL; /* domeig estimator object */ - N_Vector q; /* test vectors */ UserData ProbData; /* problem data structure */ int numwarmups; /* Number of the preprocessing warmups */ int max_powiter; /* max power iteration */ @@ -79,8 +74,8 @@ int main(int argc, char* argv[]) /* check inputs: local problem size, timing flag */ if (argc < 5) { - printf("ERROR: TWO (4) Inputs required:\n"); - printf(" Problem size should be >0\n"); + printf("ERROR: FOUR (4) Inputs required:\n"); + printf(" Problem size should be >= 2\n"); printf(" Krylov subspace dimension should be >0\n"); printf(" Number of preprocessing should be >= 0\n"); return 1; @@ -114,10 +109,8 @@ int main(int argc, char* argv[]) printf(" Timing output flag = %i\n\n", print_timing); /* Create vectors */ - q = N_VNew_Serial(ProbData.N, sunctx); - if (check_flag(q, "N_VNew_Serial", 0)) { return 1; } - ProbData.diag = N_VClone(q); - if (check_flag(ProbData.diag, "N_VClone", 0)) { return 1; } + ProbData.diag = N_VNew_Serial(ProbData.N, sunctx); + if (check_flag(ProbData.diag, "N_VNew_Serial", 0)) { return 1; } /* Fill matrix diagonal and problem data */ // real diag is [3 4 5 ... N 0 0]*factor @@ -134,16 +127,16 @@ int main(int argc, char* argv[]) ProbData.imag_part = imagpart; /* Create Arnoldi DomEig estimator*/ - DEE = SUNDomEigEst_ArnI(q, krydim, sunctx); + DEE = SUNDomEigEst_ArnI(ProbData.diag, krydim, sunctx); if (check_flag(DEE, "SUNDomEigEst_ArnI", 0)) { return 1; } fails += Test_SUNDomEigEstGetID(DEE, SUNDSOMEIGESTIMATOR_ARNOLDI, 0); fails += Test_SUNDomEigEstSetATimes(DEE, &ProbData, ATimes, 0); - fails += Test_SUNDomEigEstSetNumPreProcess(DEE, numwarmups, 0); - // SUNDomEigEstSetMaxPowerIter is not an option for Arnoldi iteration. + // SUNDomEigEstSetMaxPowerIter is not an option for Arnoldi iteration. // It should return with SUN_SUCCESS max_powiter = krydim; fails += Test_SUNDomEigEstSetMaxPowerIter(DEE, max_powiter, 0); + fails += Test_SUNDomEigEstSetNumPreProcess(DEE, numwarmups, 0); fails += Test_SUNDomEigEstInitialize(DEE, 0); fails += Test_SUNDomEigEstPreProcess(DEE, 0); fails += Test_SUNDomEigEstComputeHess(DEE, 0); @@ -159,7 +152,7 @@ int main(int argc, char* argv[]) fails += Test_SUNDomEigEstRes(DEE, &res, 0); if (res > SUN_SMALL_REAL) { - printf(" >>> FAILED test -- Test_SUNDomEigEstRes return value\n"); + printf(" >>> FAILED test -- SUNDomEigEstRes return value\n"); fails++; } @@ -208,7 +201,7 @@ int main(int argc, char* argv[]) rel_error /= norm_of_dom_eig; - if (rel_error < rel_tol && passfail == 0) + if (rel_error < rel_tol) { printf("\n\nPASS: relative error = %lf\n\n", rel_error); } @@ -219,7 +212,6 @@ int main(int argc, char* argv[]) } /* Free solver and vectors */ - N_VDestroy(q); N_VDestroy(ProbData.diag); SUNContext_Free(&sunctx); DEE->ops->free(DEE); diff --git a/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c b/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c index af7bab1954..b6a567ae54 100644 --- a/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c +++ b/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c @@ -16,13 +16,9 @@ * ----------------------------------------------------------------- */ -#include -#include -#include - -#include - #include "../test_sundomeigest.h" +#include +#include /* constants */ #define ZERO SUN_RCONST(0.0) @@ -51,10 +47,9 @@ int check_flag(void* flagvalue, const char* funcname, int opt); * --------------------------------------------------------------------*/ int main(int argc, char* argv[]) { - int fails = 0; /* counter for test failures */ + int fails = 0; /* counter for test failures */ int passfail = 0; /* overall pass/fail flag */ SUNDomEigEstimator DEE = NULL; /* domeig estimator object */ - N_Vector q; /* test vectors */ UserData ProbData; /* problem data structure */ int numwarmups; /* Number of the preprocessing warmups */ int max_powiter; /* max power iteration */ @@ -76,8 +71,8 @@ int main(int argc, char* argv[]) /* check inputs: local problem size, timing flag */ if (argc < 5) { - printf("ERROR: TWO (4) Inputs required:\n"); - printf(" Problem size should be >0\n"); + printf("ERROR: FOUR (4) Inputs required:\n"); + printf(" Problem size should be >= 2\n"); printf(" Maximum number of power iterations should be >0\n"); printf(" Number of preprocessing should be >= 0\n"); return 1; @@ -111,10 +106,8 @@ int main(int argc, char* argv[]) printf(" Timing output flag = %i\n\n", print_timing); /* Create vectors */ - q = N_VNew_Serial(ProbData.N, sunctx); - if (check_flag(q, "N_VNew_Serial", 0)) { return 1; } - ProbData.diag = N_VClone(q); - if (check_flag(ProbData.diag, "N_VClone", 0)) { return 1; } + ProbData.diag = N_VNew_Serial(ProbData.N, sunctx); + if (check_flag(ProbData.diag, "N_VNew_Serial", 0)) { return 1; } /* Fill matrix diagonal and problem data */ // real diag is [3 4 5 ... N 0 0]*factor @@ -133,13 +126,13 @@ int main(int argc, char* argv[]) ProbData.A12 = nondiagonal; /* Create Arnoldi DomEig estimator*/ - DEE = SUNDomEigEst_PI(q, max_powiter, sunctx); + DEE = SUNDomEigEst_PI(ProbData.diag, max_powiter, sunctx); if (check_flag(DEE, "SUNDomEigEst_PI", 0)) { return 1; } fails += Test_SUNDomEigEstGetID(DEE, SUNDSOMEIGESTIMATOR_POWER, 0); fails += Test_SUNDomEigEstSetATimes(DEE, &ProbData, ATimes, 0); - fails += Test_SUNDomEigEstSetNumPreProcess(DEE, numwarmups, 0); fails += Test_SUNDomEigEstSetMaxPowerIter(DEE, max_powiter, 0); + fails += Test_SUNDomEigEstSetNumPreProcess(DEE, numwarmups, 0); fails += Test_SUNDomEigEstInitialize(DEE, 0); fails += Test_SUNDomEigEstPreProcess(DEE, 0); // Test_SUNDomEigEstComputeHess is not an option for power iteration. @@ -147,7 +140,7 @@ int main(int argc, char* argv[]) fails += Test_SUNDomEigEstComputeHess(DEE, 0); fails += Test_SUNDomEigEstimate(DEE, &lambdaR, &lambdaI, 0); fails += Test_SUNDomEigEstNumIters(DEE, &niter, 0); - if (niter == 0) + if (niter <= 0) { printf(" >>> FAILED test -- SUNDomEigEstNumIters return value\n"); fails++; @@ -155,7 +148,7 @@ int main(int argc, char* argv[]) fails += Test_SUNDomEigEstRes(DEE, &res, 0); if (res < SUN_SMALL_REAL) { - printf(" >>> FAILED test -- Test_SUNDomEigEstRes return value\n"); + printf(" >>> FAILED test -- SUNDomEigEstRes return value\n"); fails++; } @@ -207,7 +200,7 @@ int main(int argc, char* argv[]) rel_error /= norm_of_dom_eig; - if (rel_error < rel_tol && passfail == 0) + if (rel_error < rel_tol) { printf("\n\nPASS: relative error = %lf\n\n", rel_error); } @@ -218,7 +211,6 @@ int main(int argc, char* argv[]) } /* Free solver and vectors */ - N_VDestroy(q); N_VDestroy(ProbData.diag); SUNContext_Free(&sunctx); DEE->ops->free(DEE); diff --git a/test/unit_tests/sundomeigest/test_sundomeigest.c b/test/unit_tests/sundomeigest/test_sundomeigest.c index b2762a24fe..d8e6cb85b1 100644 --- a/test/unit_tests/sundomeigest/test_sundomeigest.c +++ b/test/unit_tests/sundomeigest/test_sundomeigest.c @@ -19,13 +19,6 @@ #include "test_sundomeigest.h" -#include -#include -#include -#include -#include -#include - #if defined(SUNDIALS_HAVE_POSIX_TIMERS) #include #include diff --git a/test/unit_tests/sundomeigest/test_sundomeigest.h b/test/unit_tests/sundomeigest/test_sundomeigest.h index f7b60fadc4..b27bd7bd7d 100644 --- a/test/unit_tests/sundomeigest/test_sundomeigest.h +++ b/test/unit_tests/sundomeigest/test_sundomeigest.h @@ -17,7 +17,6 @@ * ----------------------------------------------------------------- */ -#include #include /* define constants */ From 6d0caf78899b42ec775d07809152d5226226f249 Mon Sep 17 00:00:00 2001 From: maggul Date: Thu, 19 Jun 2025 22:35:45 -0500 Subject: [PATCH 060/128] applied swig.patch --- src/arkode/fmod_int32/farkode_lsrkstep_mod.c | 6 +++--- src/arkode/fmod_int32/farkode_lsrkstep_mod.f90 | 2 +- src/arkode/fmod_int64/farkode_lsrkstep_mod.c | 6 +++--- src/arkode/fmod_int64/farkode_lsrkstep_mod.f90 | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/arkode/fmod_int32/farkode_lsrkstep_mod.c b/src/arkode/fmod_int32/farkode_lsrkstep_mod.c index c360ea74e8..f2b5249d7c 100644 --- a/src/arkode/fmod_int32/farkode_lsrkstep_mod.c +++ b/src/arkode/fmod_int32/farkode_lsrkstep_mod.c @@ -500,14 +500,14 @@ SWIGEXPORT int _wrap_FLSRKStepGetMaxNumStages(void *farg1, int *farg2) { } -SWIGEXPORT int _wrap_FLSRKStepGetNumRHSinDQ(void *farg1, int *farg2) { +SWIGEXPORT int _wrap_FLSRKStepGetNumRHSinDQ(void *farg1, long *farg2) { int fresult ; void *arg1 = (void *) 0 ; - int *arg2 = (int *) 0 ; + long *arg2 = (long *) 0 ; int result; arg1 = (void *)(farg1); - arg2 = (int *)(farg2); + arg2 = (long *)(farg2); result = (int)LSRKStepGetNumRHSinDQ(arg1,arg2); fresult = (int)(result); return fresult; diff --git a/src/arkode/fmod_int32/farkode_lsrkstep_mod.f90 b/src/arkode/fmod_int32/farkode_lsrkstep_mod.f90 index cc763f6b0e..e9359f4c7b 100644 --- a/src/arkode/fmod_int32/farkode_lsrkstep_mod.f90 +++ b/src/arkode/fmod_int32/farkode_lsrkstep_mod.f90 @@ -545,7 +545,7 @@ function FLSRKStepGetNumRHSinDQ(arkode_mem, nfedq) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -integer(C_INT), dimension(*), target, intent(inout) :: nfedq +integer(C_LONG), dimension(*), target, intent(inout) :: nfedq integer(C_INT) :: fresult type(C_PTR) :: farg1 type(C_PTR) :: farg2 diff --git a/src/arkode/fmod_int64/farkode_lsrkstep_mod.c b/src/arkode/fmod_int64/farkode_lsrkstep_mod.c index c360ea74e8..f2b5249d7c 100644 --- a/src/arkode/fmod_int64/farkode_lsrkstep_mod.c +++ b/src/arkode/fmod_int64/farkode_lsrkstep_mod.c @@ -500,14 +500,14 @@ SWIGEXPORT int _wrap_FLSRKStepGetMaxNumStages(void *farg1, int *farg2) { } -SWIGEXPORT int _wrap_FLSRKStepGetNumRHSinDQ(void *farg1, int *farg2) { +SWIGEXPORT int _wrap_FLSRKStepGetNumRHSinDQ(void *farg1, long *farg2) { int fresult ; void *arg1 = (void *) 0 ; - int *arg2 = (int *) 0 ; + long *arg2 = (long *) 0 ; int result; arg1 = (void *)(farg1); - arg2 = (int *)(farg2); + arg2 = (long *)(farg2); result = (int)LSRKStepGetNumRHSinDQ(arg1,arg2); fresult = (int)(result); return fresult; diff --git a/src/arkode/fmod_int64/farkode_lsrkstep_mod.f90 b/src/arkode/fmod_int64/farkode_lsrkstep_mod.f90 index cc763f6b0e..e9359f4c7b 100644 --- a/src/arkode/fmod_int64/farkode_lsrkstep_mod.f90 +++ b/src/arkode/fmod_int64/farkode_lsrkstep_mod.f90 @@ -545,7 +545,7 @@ function FLSRKStepGetNumRHSinDQ(arkode_mem, nfedq) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -integer(C_INT), dimension(*), target, intent(inout) :: nfedq +integer(C_LONG), dimension(*), target, intent(inout) :: nfedq integer(C_INT) :: fresult type(C_PTR) :: farg1 type(C_PTR) :: farg2 From 5e65761cfa5c2d6bcc24c7eae6dfb23e8fca0cb4 Mon Sep 17 00:00:00 2001 From: maggul Date: Fri, 20 Jun 2025 00:15:14 -0500 Subject: [PATCH 061/128] CI Debug --- doc/arkode/guide/source/index.rst | 1 + doc/cvode/guide/source/index.rst | 1 + doc/cvodes/guide/source/index.rst | 1 + doc/ida/guide/source/index.rst | 1 + doc/idas/guide/source/index.rst | 1 + doc/kinsol/guide/source/index.rst | 1 + src/sundials/sundials_domeigestimator.c | 5 +---- test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c | 6 +++--- test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c | 4 ++-- 9 files changed, 12 insertions(+), 9 deletions(-) diff --git a/doc/arkode/guide/source/index.rst b/doc/arkode/guide/source/index.rst index 2df0cef963..c42a814193 100644 --- a/doc/arkode/guide/source/index.rst +++ b/doc/arkode/guide/source/index.rst @@ -64,6 +64,7 @@ with support by the `US Department of Energy `_, sunmatrix/index.rst sunlinsol/index.rst sunnonlinsol/index.rst + sundomeigest/index.rst sunadaptcontroller/index.rst sunstepper/index.rst sunadjoint/index.rst diff --git a/doc/cvode/guide/source/index.rst b/doc/cvode/guide/source/index.rst index a0f081e118..94a28b8cf4 100644 --- a/doc/cvode/guide/source/index.rst +++ b/doc/cvode/guide/source/index.rst @@ -33,6 +33,7 @@ CVODE Documentation sunmatrix/index.rst sunlinsol/index.rst sunnonlinsol/index.rst + sundomeigest/index.rst sunmemory/index.rst sundials/Install_link.rst Constants diff --git a/doc/cvodes/guide/source/index.rst b/doc/cvodes/guide/source/index.rst index b5755c7a93..b87c0157af 100644 --- a/doc/cvodes/guide/source/index.rst +++ b/doc/cvodes/guide/source/index.rst @@ -34,6 +34,7 @@ CVODES Documentation sunmatrix/index.rst sunlinsol/index.rst sunnonlinsol/index.rst + sundomeigest/index.rst sunmemory/index.rst sundials/Install_link.rst Constants diff --git a/doc/ida/guide/source/index.rst b/doc/ida/guide/source/index.rst index 8e96d8b461..c2ff400d75 100644 --- a/doc/ida/guide/source/index.rst +++ b/doc/ida/guide/source/index.rst @@ -34,6 +34,7 @@ IDA Documentation sunmatrix/index.rst sunlinsol/index.rst sunnonlinsol/index.rst + sundomeigest/index.rst sunmemory/index.rst sundials/Install_link.rst Constants diff --git a/doc/idas/guide/source/index.rst b/doc/idas/guide/source/index.rst index d649c5e780..ba261b2b26 100644 --- a/doc/idas/guide/source/index.rst +++ b/doc/idas/guide/source/index.rst @@ -34,6 +34,7 @@ IDAS Documentation sunmatrix/index.rst sunlinsol/index.rst sunnonlinsol/index.rst + sundomeigest/index.rst sunmemory/index.rst sundials/Install_link.rst Constants diff --git a/doc/kinsol/guide/source/index.rst b/doc/kinsol/guide/source/index.rst index 0828279e7f..404008d84f 100644 --- a/doc/kinsol/guide/source/index.rst +++ b/doc/kinsol/guide/source/index.rst @@ -33,6 +33,7 @@ KINSOL Documentation nvectors/index.rst sunmatrix/index.rst sunlinsol/index.rst + sundomeigest/index.rst sunmemory/index.rst sundials/Install_link.rst Constants diff --git a/src/sundials/sundials_domeigestimator.c b/src/sundials/sundials_domeigestimator.c index 344e25c6c9..7ec271a078 100644 --- a/src/sundials/sundials_domeigestimator.c +++ b/src/sundials/sundials_domeigestimator.c @@ -137,10 +137,7 @@ SUNErrCode SUNDomEigEstSetTol(SUNDomEigEstimator DEE, sunrealtype tol) { SUNErrCode ier; SUNDIALS_MARK_FUNCTION_BEGIN(getSUNProfiler(DEE)); - if (DEE->ops->settol) - { - ier = DEE->ops->settol(DEE, tol); - } + if (DEE->ops->settol) { ier = DEE->ops->settol(DEE, tol); } else { ier = SUN_SUCCESS; } SUNDIALS_MARK_FUNCTION_END(getSUNProfiler(DEE)); return (ier); diff --git a/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c b/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c index a75a447f97..b28d2c9ab0 100644 --- a/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c +++ b/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c @@ -16,9 +16,9 @@ * ----------------------------------------------------------------- */ -#include "../test_sundomeigest.h" -#include #include +#include +#include "../test_sundomeigest.h" /* constants */ #define ZERO SUN_RCONST(0.0) @@ -132,7 +132,7 @@ int main(int argc, char* argv[]) fails += Test_SUNDomEigEstGetID(DEE, SUNDSOMEIGESTIMATOR_ARNOLDI, 0); fails += Test_SUNDomEigEstSetATimes(DEE, &ProbData, ATimes, 0); - // SUNDomEigEstSetMaxPowerIter is not an option for Arnoldi iteration. + // SUNDomEigEstSetMaxPowerIter is not an option for Arnoldi iteration. // It should return with SUN_SUCCESS max_powiter = krydim; fails += Test_SUNDomEigEstSetMaxPowerIter(DEE, max_powiter, 0); diff --git a/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c b/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c index b6a567ae54..0ac164d6fc 100644 --- a/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c +++ b/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c @@ -16,9 +16,9 @@ * ----------------------------------------------------------------- */ -#include "../test_sundomeigest.h" -#include #include +#include +#include "../test_sundomeigest.h" /* constants */ #define ZERO SUN_RCONST(0.0) From 28cde31a78e6d45323333f7d16043582542674bb Mon Sep 17 00:00:00 2001 From: maggul Date: Fri, 20 Jun 2025 23:46:37 -0500 Subject: [PATCH 062/128] LAPACK int issue --- .../priv/sundials_domeigestimator_impl.h | 16 ++++++------ src/sundomeigest/ArnI/sundomeigest_arni.c | 25 ++++++++++++++----- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/include/sundials/priv/sundials_domeigestimator_impl.h b/include/sundials/priv/sundials_domeigestimator_impl.h index 963b7505fd..1cad719c7f 100644 --- a/include/sundials/priv/sundials_domeigestimator_impl.h +++ b/include/sundials/priv/sundials_domeigestimator_impl.h @@ -36,15 +36,15 @@ int sundomeigest_Compare(const void* a, const void* b); * ----------------------------------------------------------------- */ #if defined(SUNDIALS_DOUBLE_PRECISION) || defined(SUNDIALS_EXTENDED_PRECISION) -extern void dgeev_(char* jobvl, char* jobvr, int* n, sunrealtype* a, int* lda, - sunrealtype* wr, sunrealtype* wi, sunrealtype* vl, int* ldvl, - sunrealtype* vr, int* ldvr, sunrealtype* work, int* lwork, - int* info); +extern void dgeev_(char* jobvl, char* jobvr, int32_t* n, sunrealtype* a, int32_t* lda, + sunrealtype* wr, sunrealtype* wi, sunrealtype* vl, int32_t* ldvl, + sunrealtype* vr, int32_t* ldvr, sunrealtype* work, int32_t* lwork, + int32_t* info); #elif defined(SUNDIALS_SINGLE_PRECISION) -extern void sgeev_(char* jobvl, char* jobvr, int* n, sunrealtype* a, int* lda, - sunrealtype* wr, sunrealtype* wi, sunrealtype* vl, int* ldvl, - sunrealtype* vr, int* ldvr, sunrealtype* work, int* lwork, - int* info); +extern void sgeev_(char* jobvl, char* jobvr, int32_t* n, sunrealtype* a, int32_t* lda, + sunrealtype* wr, sunrealtype* wi, sunrealtype* vl, int32_t* ldvl, + sunrealtype* vr, int32_t* ldvr, sunrealtype* work, int32_t* lwork, + int32_t* info); #endif #ifdef __cplusplus diff --git a/src/sundomeigest/ArnI/sundomeigest_arni.c b/src/sundomeigest/ArnI/sundomeigest_arni.c index a4c77255aa..f1c57ef9fe 100644 --- a/src/sundomeigest/ArnI/sundomeigest_arni.c +++ b/src/sundomeigest/ArnI/sundomeigest_arni.c @@ -317,22 +317,34 @@ SUNErrCode SUNDomEigEstimate_ArnI(SUNDomEigEstimator DEE, sunrealtype* lambdaR, } } - int lda = n, ldvl = n, ldvr = n; - int info, lwork = 4 * n; - char jobvl = 'N'; // Do not compute left eigenvectors char jobvr = 'N'; // Do not compute right eigenvectors /* Call LAPACK's dgeev function return info values refer to = 0: successful exit - < 0: if INFO = -i, the i-th argument had an illegal value. - > 0: if INFO = i, the QR algorithm failed to compute all the + < 0: if info = -i, the i-th argument had an illegal value. + > 0: if info = i, the QR algorithm failed to compute all the eigenvalues, and no eigenvectors have been computed; elements i+1:N of LAPACK_wr and LAPACK_wi contain eigenvalues which have converged. */ -#if defined(SUNDIALS_DOUBLE_PRECISION) || defined(SUNDIALS_EXTENDED_PRECISION) +#if defined(SUNDIALS_INT32_T) + sunindextype lda = n; sunindextype ldvl = n; sunindextype ldvr = n; + sunindextype info; sunindextype lwork = 4 * n; +#if defined(SUNDIALS_DOUBLE_PRECISION) + dgeev_(&jobvl, &jobvr, &n, ArnI_CONTENT(DEE)->LAPACK_A, &lda, + ArnI_CONTENT(DEE)->LAPACK_wr, ArnI_CONTENT(DEE)->LAPACK_wi, NULL, + &ldvl, NULL, &ldvr, ArnI_CONTENT(DEE)->LAPACK_work, &lwork, &info); +#elif defined(SUNDIALS_SINGLE_PRECISION) + sgeev_(&jobvl, &jobvr, &n, ArnI_CONTENT(DEE)->LAPACK_A, &lda, + ArnI_CONTENT(DEE)->LAPACK_wr, ArnI_CONTENT(DEE)->LAPACK_wi, NULL, + &ldvl, NULL, &ldvr, ArnI_CONTENT(DEE)->LAPACK_work, &lwork, &info); +#endif +#elif defined(SUNDIALS_INT64_T) + int32_t lda = n; int32_t ldvl = n; int32_t ldvr = n; + int32_t info; int32_t lwork = 4 * n; +#if defined(SUNDIALS_DOUBLE_PRECISION) dgeev_(&jobvl, &jobvr, &n, ArnI_CONTENT(DEE)->LAPACK_A, &lda, ArnI_CONTENT(DEE)->LAPACK_wr, ArnI_CONTENT(DEE)->LAPACK_wi, NULL, &ldvl, NULL, &ldvr, ArnI_CONTENT(DEE)->LAPACK_work, &lwork, &info); @@ -340,6 +352,7 @@ SUNErrCode SUNDomEigEstimate_ArnI(SUNDomEigEstimator DEE, sunrealtype* lambdaR, sgeev_(&jobvl, &jobvr, &n, ArnI_CONTENT(DEE)->LAPACK_A, &lda, ArnI_CONTENT(DEE)->LAPACK_wr, ArnI_CONTENT(DEE)->LAPACK_wi, NULL, &ldvl, NULL, &ldvr, ArnI_CONTENT(DEE)->LAPACK_work, &lwork, &info); +#endif #endif if (info != 0) From e9689fa272f505c06e6c5685dbb3e03894cdbb83 Mon Sep 17 00:00:00 2001 From: maggul Date: Mon, 23 Jun 2025 17:26:40 -0500 Subject: [PATCH 063/128] documentation and several other updates --- CHANGELOG.md | 12 + .../source/Usage/LSRKStep/User_callable.rst | 54 +++- .../source/sundomeigest/ARKODE_interface.rst | 28 +- .../source/sundomeigest/CVODE_interface.rst | 28 +- .../source/sundomeigest/CVODES_interface.rst | 28 +- .../source/sundomeigest/IDA_interface.rst | 28 +- .../source/sundomeigest/IDAS_interface.rst | 28 +- .../source/sundomeigest/KINSOL_interface.rst | 28 +- doc/shared/sundomeigest/SUNDomEigEst_API.rst | 253 ++++++++++++------ doc/shared/sundomeigest/SUNDomEigEst_ARNI.rst | 82 +++--- .../sundomeigest/SUNDomEigEst_Examples.rst | 44 ++- doc/shared/sundomeigest/SUNDomEigEst_PI.rst | 90 +++++-- .../ark_analytic_lsrk_internal_domeig.out | 4 + include/arkode/arkode_lsrkstep.h | 4 +- include/sundials/sundials_domeigestimator.h | 5 +- include/sundomeigest/sundomeigest_arni.h | 6 +- include/sundomeigest/sundomeigest_pi.h | 13 +- src/arkode/arkode_lsrkstep.c | 35 ++- src/arkode/arkode_lsrkstep_io.c | 25 +- src/arkode/fmod_int32/farkode_lsrkstep_mod.c | 48 ++-- .../fmod_int32/farkode_lsrkstep_mod.f90 | 128 ++++----- src/arkode/fmod_int64/farkode_lsrkstep_mod.c | 48 ++-- .../fmod_int64/farkode_lsrkstep_mod.f90 | 128 ++++----- .../arni/test_sundomeigest_arni.c | 1 + .../sundomeigest/pi/test_sundomeigest_pi.c | 1 + .../sundomeigest/test_sundomeigest.c | 32 +++ .../sundomeigest/test_sundomeigest.h | 1 + 27 files changed, 775 insertions(+), 407 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b3b7593bb6..18b318dd60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # SUNDIALS Changelog +## Changes to SUNDIALS in release 7.5.0 + +### Major Features + +Added a dominant eigenvalue estimator module to SUNDIALS. This enables internal +dominant eigenvalue estimation for the LSRKStep step methods: +second-order Runge–Kutta–Chebyshev and Runge–Kutta–Legendre methods. Users no +longer need to provide dominant eigenvalue estimates manually. This module is +standalone and can also be used for other purposes. Currently available methods +include Power Iteration (PI) and Arnoldi Iteration (ArnI). The latter requires +enabling the LAPACK library, while PI is available without any additional flags. + ## Changes to SUNDIALS in release 7.4.0 ### New Features and Enhancements diff --git a/doc/arkode/guide/source/Usage/LSRKStep/User_callable.rst b/doc/arkode/guide/source/Usage/LSRKStep/User_callable.rst index ac150cd8d5..a5256096b4 100644 --- a/doc/arkode/guide/source/Usage/LSRKStep/User_callable.rst +++ b/doc/arkode/guide/source/Usage/LSRKStep/User_callable.rst @@ -174,9 +174,10 @@ Allowable Method Families .. c:function:: int LSRKStepSetDomEigFn(void* arkode_mem, ARKDomEigFn dom_eig); - Specifies the dominant eigenvalue approximation routine to + Specifies the user-supplied dominant eigenvalue approximation routine to be used for determining the number of stages that will be used by either the - RKC or RKL methods. + RKC or RKL methods. ``dom_eig = NULL`` input creates internal SUNDIALS Dominant + Eigenvalue Estimator (DEE) to serve this goal. **Arguments:** * *arkode_mem* -- pointer to the LSRKStep memory block. @@ -185,10 +186,35 @@ Allowable Method Families **Return value:** * *ARK_SUCCESS* if successful * *ARKLS_MEM_NULL* if ``arkode_mem`` was ``NULL``. - * *ARK_ILL_INPUT* ``dom_eig = NULL`` and LSRKStep does not currently estimate this internally. + * *ARK_DEE_FAIL* if ``dom_eig = NULL`` and DEE failed. + + .. note:: *ARK_DEE_FAIL* return should also produce error messages due to DEE error(s). These errors + are handled by :c:type:`SUNErrCode`. + + Either this function or the DEE creater function, :c:func:`LSRKStepDomEigEstCreateWithID` is required + when either the RKC or RKL methods are used. + + +.. c:function:: int LSRKStepDomEigEstCreateWithID(void* arkode_mem, SUNDomEigEstimator_ID DEE_id); + + Creates SUNDIALS DominantEigenvalue Estimator (DEE) with the provided ID. This approximation routine + is used for determining the number of stages that will be used by either the + RKC or RKL methods. + + **Arguments:** + * *arkode_mem* -- pointer to the LSRKStep memory block. + * *DEE_id* -- ID of the dominant eigenvalue estimator (of type c:enum::`SUNDomEigEstimator_ID`). + + **Return value:** + * *ARK_SUCCESS* if successful + * *ARKLS_MEM_NULL* if ``arkode_mem`` was ``NULL``. + * *ARK_DEE_FAIL* if DEE failed. - .. note:: This function is currently required when either the RKC or RKL methods are used. + .. note:: *ARK_DEE_FAIL* return should also produce error messages due to DEE error(s). These errors + are handled by :c:type:`SUNErrCode`. + Either this function or the user-supplied dominant eigenvalue estimator set function, + :c:func:`LSRKStepSetDomEigFn` is required when either the RKC or RKL methods are used. .. c:function:: int LSRKStepSetDomEigFrequency(void* arkode_mem, long int nsteps); @@ -298,6 +324,26 @@ Optional output functions **Return value:** * *ARK_SUCCESS* if successful * *ARK_MEM_NULL* if the LSRKStep memory was ``NULL`` + * *ARK_ILL_INPUT* if ``stage_max`` is illegal + + +.. c:function:: int LSRKStepGetNumRHSinDQ(void* arkode_mem, long int* nfeDQ); + + Returns the number of RHS function evaluations used in the difference quotient + Jacobian approximations (so far). + + **Arguments:** + * *arkode_mem* -- pointer to the LSRKStep memory block. + * *nfeDQ* -- number of rhs calls. + + **Return value:** + * *ARK_SUCCESS* if successful + * *ARK_MEM_NULL* if the LSRKStep memory was ``NULL`` + * *ARK_ILL_INPUT* if ``nfeDQ`` is illegal + +.. note:: Internal SUNDIALS dominant eigenvalue estimatior (DEE) needs this approximation. + Therefore, it returns 0 if DEE is not created at all. + .. _ARKODE.Usage.LSRKStep.Reinitialization: diff --git a/doc/arkode/guide/source/sundomeigest/ARKODE_interface.rst b/doc/arkode/guide/source/sundomeigest/ARKODE_interface.rst index 8a4a706cb3..1043b9eca3 100644 --- a/doc/arkode/guide/source/sundomeigest/ARKODE_interface.rst +++ b/doc/arkode/guide/source/sundomeigest/ARKODE_interface.rst @@ -40,42 +40,52 @@ the interested reader. +----------------------------------------------------+---------------------+---------------------+ | :c:func:`SUNDomEigEstSetATimes` | X | X | +----------------------------------------------------+---------------------+---------------------+ - | :c:func:`SUNDomEigEstSetMaxPowerIter` | O | O | + | :c:func:`SUNDomEigEstSetMaxPowerIter`\ :sup:`1` | O | N/A | +----------------------------------------------------+---------------------+---------------------+ | :c:func:`SUNDomEigEstSetNumPreProcess` | O | O | +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstSetTol`\ :sup:`2` | O | N/A | + +----------------------------------------------------+---------------------+---------------------+ | :c:func:`SUNDomEigEstInitialize` | X | X | +----------------------------------------------------+---------------------+---------------------+ | :c:func:`SUNDomEigEstPreProcess` | O | O | +----------------------------------------------------+---------------------+---------------------+ - | :c:func:`SUNDomEigEstComputeHess`\ :sup:`1` | N/A | X | + | :c:func:`SUNDomEigEstComputeHess`\ :sup:`3` | N/A | X | +----------------------------------------------------+---------------------+---------------------+ | :c:func:`SUNDomEigEstimate` | X | X | +----------------------------------------------------+---------------------+---------------------+ - | :c:func:`SUNDomEigEstNumIters`\ :sup:`2` | O | N/A | + | :c:func:`SUNDomEigEstNumIters`\ :sup:`4` | O | N/A | +----------------------------------------------------+---------------------+---------------------+ - | :c:func:`SUNDomEigEstRes`\ :sup:`3` | O | N/A | + | :c:func:`SUNDomEigEstRes`\ :sup:`5` | O | N/A | +----------------------------------------------------+---------------------+---------------------+ - | :c:func:`SUNDomEigEstFree`\ :sup:`4` | | | + | :c:func:`SUNDomEigEstFree`\ :sup:`6` | | | +----------------------------------------------------+---------------------+---------------------+ Notes: -1. :c:func:`SUNDomEigEstComputeHess()` might or might not be required depending on +1. :c:func:`SUNDomEigEstSetMaxPowerIter()` might or might not be required depending on + ``SUNDomEigEstimator`` implementation that is being used. This flag must be left + ``NULL`` if it is not applicable for an estimator. + +2. :c:func:`SUNDomEigEstSetTol()` might or might not be required depending on + ``SUNDomEigEstimator`` implementation that is being used. This flag must be left + ``NULL`` if it is not applicable for an estimator. + +3. :c:func:`SUNDomEigEstComputeHess()` might or might not be required depending on ``SUNDomEigEstimator`` implementation that is being used. This flag must be left ``NULL`` if it is not applicable for an estimator. -2. :c:func:`SUNDomEigEstNumIters()` is only used to accumulate overall +4. :c:func:`SUNDomEigEstNumIters()` is only used to accumulate overall iterative estimator statistics. If it is not implemented by the ``SUNDomEigEstimator`` module, then ARKDEE will consider all estimates as requiring zero iterations. -3. Although :c:func:`SUNDomEigEstRes()` is optional, if it is not +5. Although :c:func:`SUNDomEigEstRes()` is optional, if it is not implemented by the ``SUNDomEigEstimator`` then ARKDEE will consider all estimates a being *exact*. -4. Although ARKDEE does not call :c:func:`SUNDomEigEstFree()` +6. Although ARKDEE does not call :c:func:`SUNDomEigEstFree()` directly, this routine should be available for users to call when cleaning up from a simulation. diff --git a/doc/cvode/guide/source/sundomeigest/CVODE_interface.rst b/doc/cvode/guide/source/sundomeigest/CVODE_interface.rst index 8ae82e6aaa..c67754a2d1 100644 --- a/doc/cvode/guide/source/sundomeigest/CVODE_interface.rst +++ b/doc/cvode/guide/source/sundomeigest/CVODE_interface.rst @@ -40,42 +40,52 @@ the interested reader. +----------------------------------------------------+---------------------+---------------------+ | :c:func:`SUNDomEigEstSetATimes` | X | X | +----------------------------------------------------+---------------------+---------------------+ - | :c:func:`SUNDomEigEstSetMaxPowerIter` | O | O | + | :c:func:`SUNDomEigEstSetMaxPowerIter`\ :sup:`1` | O | N/A | +----------------------------------------------------+---------------------+---------------------+ | :c:func:`SUNDomEigEstSetNumPreProcess` | O | O | +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstSetTol`\ :sup:`2` | O | N/A | + +----------------------------------------------------+---------------------+---------------------+ | :c:func:`SUNDomEigEstInitialize` | X | X | +----------------------------------------------------+---------------------+---------------------+ | :c:func:`SUNDomEigEstPreProcess` | O | O | +----------------------------------------------------+---------------------+---------------------+ - | :c:func:`SUNDomEigEstComputeHess`\ :sup:`1` | N/A | X | + | :c:func:`SUNDomEigEstComputeHess`\ :sup:`3` | N/A | X | +----------------------------------------------------+---------------------+---------------------+ | :c:func:`SUNDomEigEstimate` | X | X | +----------------------------------------------------+---------------------+---------------------+ - | :c:func:`SUNDomEigEstNumIters`\ :sup:`2` | O | N/A | + | :c:func:`SUNDomEigEstNumIters`\ :sup:`4` | O | N/A | +----------------------------------------------------+---------------------+---------------------+ - | :c:func:`SUNDomEigEstRes`\ :sup:`3` | O | N/A | + | :c:func:`SUNDomEigEstRes`\ :sup:`5` | O | N/A | +----------------------------------------------------+---------------------+---------------------+ - | :c:func:`SUNDomEigEstFree`\ :sup:`4` | | | + | :c:func:`SUNDomEigEstFree`\ :sup:`6` | | | +----------------------------------------------------+---------------------+---------------------+ Notes: -1. :c:func:`SUNDomEigEstComputeHess()` might or might not be required depending on +1. :c:func:`SUNDomEigEstSetMaxPowerIter()` might or might not be required depending on + ``SUNDomEigEstimator`` implementation that is being used. This flag must be left + ``NULL`` if it is not applicable for an estimator. + +2. :c:func:`SUNDomEigEstSetTol()` might or might not be required depending on + ``SUNDomEigEstimator`` implementation that is being used. This flag must be left + ``NULL`` if it is not applicable for an estimator. + +3. :c:func:`SUNDomEigEstComputeHess()` might or might not be required depending on ``SUNDomEigEstimator`` implementation that is being used. This flag must be left ``NULL`` if it is not applicable for an estimator. -2. :c:func:`SUNDomEigEstNumIters()` is only used to accumulate overall +4. :c:func:`SUNDomEigEstNumIters()` is only used to accumulate overall iterative estimator statistics. If it is not implemented by the ``SUNDomEigEstimator`` module, then CVDEE will consider all estimates as requiring zero iterations. -3. Although :c:func:`SUNDomEigEstRes()` is optional, if it is not +5. Although :c:func:`SUNDomEigEstRes()` is optional, if it is not implemented by the ``SUNDomEigEstimator`` then CVDEE will consider all estimates a being *exact*. -4. Although CVDEE does not call :c:func:`SUNDomEigEstFree()` +6. Although CVDEE does not call :c:func:`SUNDomEigEstFree()` directly, this routine should be available for users to call when cleaning up from a simulation. diff --git a/doc/cvodes/guide/source/sundomeigest/CVODES_interface.rst b/doc/cvodes/guide/source/sundomeigest/CVODES_interface.rst index 7300d21c44..a9efef4ba5 100644 --- a/doc/cvodes/guide/source/sundomeigest/CVODES_interface.rst +++ b/doc/cvodes/guide/source/sundomeigest/CVODES_interface.rst @@ -40,42 +40,52 @@ the interested reader. +----------------------------------------------------+---------------------+---------------------+ | :c:func:`SUNDomEigEstSetATimes` | X | X | +----------------------------------------------------+---------------------+---------------------+ - | :c:func:`SUNDomEigEstSetMaxPowerIter` | O | O | + | :c:func:`SUNDomEigEstSetMaxPowerIter`\ :sup:`1` | O | N/A | +----------------------------------------------------+---------------------+---------------------+ | :c:func:`SUNDomEigEstSetNumPreProcess` | O | O | +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstSetTol`\ :sup:`2` | O | N/A | + +----------------------------------------------------+---------------------+---------------------+ | :c:func:`SUNDomEigEstInitialize` | X | X | +----------------------------------------------------+---------------------+---------------------+ | :c:func:`SUNDomEigEstPreProcess` | O | O | +----------------------------------------------------+---------------------+---------------------+ - | :c:func:`SUNDomEigEstComputeHess`\ :sup:`1` | N/A | X | + | :c:func:`SUNDomEigEstComputeHess`\ :sup:`3` | N/A | X | +----------------------------------------------------+---------------------+---------------------+ | :c:func:`SUNDomEigEstimate` | X | X | +----------------------------------------------------+---------------------+---------------------+ - | :c:func:`SUNDomEigEstNumIters`\ :sup:`2` | O | N/A | + | :c:func:`SUNDomEigEstNumIters`\ :sup:`4` | O | N/A | +----------------------------------------------------+---------------------+---------------------+ - | :c:func:`SUNDomEigEstRes`\ :sup:`3` | O | N/A | + | :c:func:`SUNDomEigEstRes`\ :sup:`5` | O | N/A | +----------------------------------------------------+---------------------+---------------------+ - | :c:func:`SUNDomEigEstFree`\ :sup:`4` | | | + | :c:func:`SUNDomEigEstFree`\ :sup:`6` | | | +----------------------------------------------------+---------------------+---------------------+ Notes: -1. :c:func:`SUNDomEigEstComputeHess()` might or might not be required depending on +1. :c:func:`SUNDomEigEstSetMaxPowerIter()` might or might not be required depending on + ``SUNDomEigEstimator`` implementation that is being used. This flag must be left + ``NULL`` if it is not applicable for an estimator. + +2. :c:func:`SUNDomEigEstSetTol()` might or might not be required depending on + ``SUNDomEigEstimator`` implementation that is being used. This flag must be left + ``NULL`` if it is not applicable for an estimator. + +3. :c:func:`SUNDomEigEstComputeHess()` might or might not be required depending on ``SUNDomEigEstimator`` implementation that is being used. This flag must be left ``NULL`` if it is not applicable for an estimator. -2. :c:func:`SUNDomEigEstNumIters()` is only used to accumulate overall +4. :c:func:`SUNDomEigEstNumIters()` is only used to accumulate overall iterative estimator statistics. If it is not implemented by the ``SUNDomEigEstimator`` module, then CVDEE will consider all estimates as requiring zero iterations. -3. Although :c:func:`SUNDomEigEstRes()` is optional, if it is not +5. Although :c:func:`SUNDomEigEstRes()` is optional, if it is not implemented by the ``SUNDomEigEstimator`` then CVDEE will consider all estimates a being *exact*. -4. Although CVDEE does not call :c:func:`SUNDomEigEstFree()` +6. Although CVDEE does not call :c:func:`SUNDomEigEstFree()` directly, this routine should be available for users to call when cleaning up from a simulation. diff --git a/doc/ida/guide/source/sundomeigest/IDA_interface.rst b/doc/ida/guide/source/sundomeigest/IDA_interface.rst index 1e3a10d441..64a2563017 100644 --- a/doc/ida/guide/source/sundomeigest/IDA_interface.rst +++ b/doc/ida/guide/source/sundomeigest/IDA_interface.rst @@ -40,42 +40,52 @@ the interested reader. +----------------------------------------------------+---------------------+---------------------+ | :c:func:`SUNDomEigEstSetATimes` | X | X | +----------------------------------------------------+---------------------+---------------------+ - | :c:func:`SUNDomEigEstSetMaxPowerIter` | O | O | + | :c:func:`SUNDomEigEstSetMaxPowerIter`\ :sup:`1` | O | N/A | +----------------------------------------------------+---------------------+---------------------+ | :c:func:`SUNDomEigEstSetNumPreProcess` | O | O | +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstSetTol`\ :sup:`2` | O | N/A | + +----------------------------------------------------+---------------------+---------------------+ | :c:func:`SUNDomEigEstInitialize` | X | X | +----------------------------------------------------+---------------------+---------------------+ | :c:func:`SUNDomEigEstPreProcess` | O | O | +----------------------------------------------------+---------------------+---------------------+ - | :c:func:`SUNDomEigEstComputeHess`\ :sup:`1` | N/A | X | + | :c:func:`SUNDomEigEstComputeHess`\ :sup:`3` | N/A | X | +----------------------------------------------------+---------------------+---------------------+ | :c:func:`SUNDomEigEstimate` | X | X | +----------------------------------------------------+---------------------+---------------------+ - | :c:func:`SUNDomEigEstNumIters`\ :sup:`2` | O | N/A | + | :c:func:`SUNDomEigEstNumIters`\ :sup:`4` | O | N/A | +----------------------------------------------------+---------------------+---------------------+ - | :c:func:`SUNDomEigEstRes`\ :sup:`3` | O | N/A | + | :c:func:`SUNDomEigEstRes`\ :sup:`5` | O | N/A | +----------------------------------------------------+---------------------+---------------------+ - | :c:func:`SUNDomEigEstFree`\ :sup:`4` | | | + | :c:func:`SUNDomEigEstFree`\ :sup:`6` | | | +----------------------------------------------------+---------------------+---------------------+ Notes: -1. :c:func:`SUNDomEigEstComputeHess()` might or might not be required depending on +1. :c:func:`SUNDomEigEstSetMaxPowerIter()` might or might not be required depending on + ``SUNDomEigEstimator`` implementation that is being used. This flag must be left + ``NULL`` if it is not applicable for an estimator. + +2. :c:func:`SUNDomEigEstSetTol()` might or might not be required depending on + ``SUNDomEigEstimator`` implementation that is being used. This flag must be left + ``NULL`` if it is not applicable for an estimator. + +3. :c:func:`SUNDomEigEstComputeHess()` might or might not be required depending on ``SUNDomEigEstimator`` implementation that is being used. This flag must be left ``NULL`` if it is not applicable for an estimator. -2. :c:func:`SUNDomEigEstNumIters()` is only used to accumulate overall +4. :c:func:`SUNDomEigEstNumIters()` is only used to accumulate overall iterative estimator statistics. If it is not implemented by the ``SUNDomEigEstimator`` module, then IDADEE will consider all estimates as requiring zero iterations. -3. Although :c:func:`SUNDomEigEstRes()` is optional, if it is not +5. Although :c:func:`SUNDomEigEstRes()` is optional, if it is not implemented by the ``SUNDomEigEstimator`` then IDADEE will consider all estimates a being *exact*. -4. Although IDADEE does not call :c:func:`SUNDomEigEstFree()` +6. Although IDADEE does not call :c:func:`SUNDomEigEstFree()` directly, this routine should be available for users to call when cleaning up from a simulation. diff --git a/doc/idas/guide/source/sundomeigest/IDAS_interface.rst b/doc/idas/guide/source/sundomeigest/IDAS_interface.rst index bc28fbfe97..5237a585e9 100644 --- a/doc/idas/guide/source/sundomeigest/IDAS_interface.rst +++ b/doc/idas/guide/source/sundomeigest/IDAS_interface.rst @@ -40,42 +40,52 @@ the interested reader. +----------------------------------------------------+---------------------+---------------------+ | :c:func:`SUNDomEigEstSetATimes` | X | X | +----------------------------------------------------+---------------------+---------------------+ - | :c:func:`SUNDomEigEstSetMaxPowerIter` | O | O | + | :c:func:`SUNDomEigEstSetMaxPowerIter`\ :sup:`1` | O | N/A | +----------------------------------------------------+---------------------+---------------------+ | :c:func:`SUNDomEigEstSetNumPreProcess` | O | O | +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstSetTol`\ :sup:`2` | O | N/A | + +----------------------------------------------------+---------------------+---------------------+ | :c:func:`SUNDomEigEstInitialize` | X | X | +----------------------------------------------------+---------------------+---------------------+ | :c:func:`SUNDomEigEstPreProcess` | O | O | +----------------------------------------------------+---------------------+---------------------+ - | :c:func:`SUNDomEigEstComputeHess`\ :sup:`1` | N/A | X | + | :c:func:`SUNDomEigEstComputeHess`\ :sup:`3` | N/A | X | +----------------------------------------------------+---------------------+---------------------+ | :c:func:`SUNDomEigEstimate` | X | X | +----------------------------------------------------+---------------------+---------------------+ - | :c:func:`SUNDomEigEstNumIters`\ :sup:`2` | O | N/A | + | :c:func:`SUNDomEigEstNumIters`\ :sup:`4` | O | N/A | +----------------------------------------------------+---------------------+---------------------+ - | :c:func:`SUNDomEigEstRes`\ :sup:`3` | O | N/A | + | :c:func:`SUNDomEigEstRes`\ :sup:`5` | O | N/A | +----------------------------------------------------+---------------------+---------------------+ - | :c:func:`SUNDomEigEstFree`\ :sup:`4` | | | + | :c:func:`SUNDomEigEstFree`\ :sup:`6` | | | +----------------------------------------------------+---------------------+---------------------+ Notes: -1. :c:func:`SUNDomEigEstComputeHess()` might or might not be required depending on +1. :c:func:`SUNDomEigEstSetMaxPowerIter()` might or might not be required depending on + ``SUNDomEigEstimator`` implementation that is being used. This flag must be left + ``NULL`` if it is not applicable for an estimator. + +2. :c:func:`SUNDomEigEstSetTol()` might or might not be required depending on + ``SUNDomEigEstimator`` implementation that is being used. This flag must be left + ``NULL`` if it is not applicable for an estimator. + +3. :c:func:`SUNDomEigEstComputeHess()` might or might not be required depending on ``SUNDomEigEstimator`` implementation that is being used. This flag must be left ``NULL`` if it is not applicable for an estimator. -2. :c:func:`SUNDomEigEstNumIters()` is only used to accumulate overall +4. :c:func:`SUNDomEigEstNumIters()` is only used to accumulate overall iterative estimator statistics. If it is not implemented by the ``SUNDomEigEstimator`` module, then IDADEE will consider all estimates as requiring zero iterations. -3. Although :c:func:`SUNDomEigEstRes()` is optional, if it is not +5. Although :c:func:`SUNDomEigEstRes()` is optional, if it is not implemented by the ``SUNDomEigEstimator`` then IDADEE will consider all estimates a being *exact*. -4. Although IDADEE does not call :c:func:`SUNDomEigEstFree()` +6. Although IDADEE does not call :c:func:`SUNDomEigEstFree()` directly, this routine should be available for users to call when cleaning up from a simulation. diff --git a/doc/kinsol/guide/source/sundomeigest/KINSOL_interface.rst b/doc/kinsol/guide/source/sundomeigest/KINSOL_interface.rst index 34c8681d30..636de673b9 100644 --- a/doc/kinsol/guide/source/sundomeigest/KINSOL_interface.rst +++ b/doc/kinsol/guide/source/sundomeigest/KINSOL_interface.rst @@ -40,42 +40,52 @@ the interested reader. +----------------------------------------------------+---------------------+---------------------+ | :c:func:`SUNDomEigEstSetATimes` | X | X | +----------------------------------------------------+---------------------+---------------------+ - | :c:func:`SUNDomEigEstSetMaxPowerIter` | O | O | + | :c:func:`SUNDomEigEstSetMaxPowerIter`\ :sup:`1` | O | N/A | +----------------------------------------------------+---------------------+---------------------+ | :c:func:`SUNDomEigEstSetNumPreProcess` | O | O | +----------------------------------------------------+---------------------+---------------------+ + | :c:func:`SUNDomEigEstSetTol`\ :sup:`2` | O | N/A | + +----------------------------------------------------+---------------------+---------------------+ | :c:func:`SUNDomEigEstInitialize` | X | X | +----------------------------------------------------+---------------------+---------------------+ | :c:func:`SUNDomEigEstPreProcess` | O | O | +----------------------------------------------------+---------------------+---------------------+ - | :c:func:`SUNDomEigEstComputeHess`\ :sup:`1` | N/A | X | + | :c:func:`SUNDomEigEstComputeHess`\ :sup:`3` | N/A | X | +----------------------------------------------------+---------------------+---------------------+ | :c:func:`SUNDomEigEstimate` | X | X | +----------------------------------------------------+---------------------+---------------------+ - | :c:func:`SUNDomEigEstNumIters`\ :sup:`2` | O | N/A | + | :c:func:`SUNDomEigEstNumIters`\ :sup:`4` | O | N/A | +----------------------------------------------------+---------------------+---------------------+ - | :c:func:`SUNDomEigEstRes`\ :sup:`3` | O | N/A | + | :c:func:`SUNDomEigEstRes`\ :sup:`5` | O | N/A | +----------------------------------------------------+---------------------+---------------------+ - | :c:func:`SUNDomEigEstFree`\ :sup:`4` | | | + | :c:func:`SUNDomEigEstFree`\ :sup:`6` | | | +----------------------------------------------------+---------------------+---------------------+ Notes: -1. :c:func:`SUNDomEigEstComputeHess()` might or might not be required depending on +1. :c:func:`SUNDomEigEstSetMaxPowerIter()` might or might not be required depending on + ``SUNDomEigEstimator`` implementation that is being used. This flag must be left + ``NULL`` if it is not applicable for an estimator. + +2. :c:func:`SUNDomEigEstSetTol()` might or might not be required depending on + ``SUNDomEigEstimator`` implementation that is being used. This flag must be left + ``NULL`` if it is not applicable for an estimator. + +3. :c:func:`SUNDomEigEstComputeHess()` might or might not be required depending on ``SUNDomEigEstimator`` implementation that is being used. This flag must be left ``NULL`` if it is not applicable for an estimator. -2. :c:func:`SUNDomEigEstNumIters()` is only used to accumulate overall +4. :c:func:`SUNDomEigEstNumIters()` is only used to accumulate overall iterative estimator statistics. If it is not implemented by the ``SUNDomEigEstimator`` module, then KINDEE will consider all estimates as requiring zero iterations. -3. Although :c:func:`SUNDomEigEstRes()` is optional, if it is not +5. Although :c:func:`SUNDomEigEstRes()` is optional, if it is not implemented by the ``SUNDomEigEstimator`` then KINDEE will consider all estimates a being *exact*. -4. Although KINDEE does not call :c:func:`SUNDomEigEstFree()` +6. Although KINDEE does not call :c:func:`SUNDomEigEstFree()` directly, this routine should be available for users to call when cleaning up from a simulation. diff --git a/doc/shared/sundomeigest/SUNDomEigEst_API.rst b/doc/shared/sundomeigest/SUNDomEigEst_API.rst index b24aa40e9f..2e7dc2cbf6 100644 --- a/doc/shared/sundomeigest/SUNDomEigEst_API.rst +++ b/doc/shared/sundomeigest/SUNDomEigEst_API.rst @@ -18,13 +18,12 @@ The SUNDomEigEstimator API ============================= The SUNDomEigEst API defines several dominant eigenvalue estimation operations that enable -SUNDIALS packages to utilize this API. These functions can be divided into -three categories. The first are the core dominant eigenvalue estimation functions. The -second consist of "set" routines to supply the dominant eigenvalue estimatitor with functions -provided by the SUNDIALS packages and to modify estimator parameters. The -final group consists of "get" routines for retrieving dominant eigenvalue estimation -statistics. All of these functions are defined in the header file -``sundials/sundials_domeigestimator.h``. +SUNDIALS packages to utilize this API. These functions can be divided into three categories. +The first are the core dominant eigenvalue estimation functions. The second consist of "set" +routines to supply the dominant eigenvalue estimator with functions provided by the SUNDIALS +packages and to modify estimator parameters. The final group consists of "get" routines for +retrieving dominant eigenvalue estimation statistics. All of these functions are defined in +the header file ``sundials/sundials_domeigestimator.h``. .. _SUNDomEigEst.CoreFn: @@ -35,14 +34,41 @@ SUNDomEigEstimator core functions The core dominant eigenvalue estimatimator functions consist of several **required** functions: :c:func:`SUNDomEigEstSetATimes` provides a :c:type:`SUNATimesFn` function pointer, as well as a ``void*`` pointer to a data structure used by this routine, -:c:func:`SUNDomEigEstInitialize` initializes the estimator object once -all estimator-specific options have been set, and :c:func:`SUNDomEigEstimate` estimates -the dominant eigenvalue. +:c:func:`SUNDomEigEstInitialize` initializes the estimator object once all estimator-specific +options have been set, :c:func:`SUNDomEigEstComputeHess` computes Hessenberg matrix +(if the estimator requires), :c:func:`SUNDomEigEstimate` estimates the dominant eigenvalue, and +:c:func:`SUNDomEigEstFree` destroys an estimator object. -The remaining **optional** functions returns the estimator ID (:c:func:`SUNDomEigEstGetID`), -preprocess the estimator object to "warm-up" the estimator for a more appropriate initial vector -for iterations (:c:func:`SUNDomEigEstPreProcess`), computes Hessenberg matrix (when necessary) -(:c:func:`SUNDomEigEstComputeHess`), and destroy an estimator object (:c:func:`SUNDomEigEstFree`). +The remaining **optional** functions returns the estimator ID :c:func:`SUNDomEigEstGetID`, and +preprocess the estimator object :c:func:`SUNDomEigEstPreProcess` to "warm-up" the estimator for +a more appropriate initial vector before starting iterations. + + +.. c:function:: SUNErrCode SUNDomEigEstSetATimes(SUNDomEigEstimator DEE, void* A_data, SUNATimesFn ATimes) + + *Required.* + + Provides a :c:type:`SUNATimesFn` function pointer, as well as a ``void*`` pointer to a + data structure used by this routine, to the dominant eigenvalue estimatimator object + *DEE*. SUNDIALS packages call this function to set the matrix-vector product function + to either an estimator-provided difference-quotient via vector operations or a user-supplied + estimator-specific routine. + + **Arguments:** + + * *DEE* -- a SUNDomEigEst object, + * *A_data* -- pointer to structure for ``ATimes``, + * *ATimes* -- function pointer to perform :math:`Av` product. + + **Return value:** + + A :c:type:`SUNErrCode`. + + **Usage:** + + .. code-block:: c + + retval = SUNDomEigEstSetATimes(DEE, A_data, ATimes); .. c:function:: SUNErrCode SUNDomEigEstInitialize(SUNDomEigEstimator DEE) @@ -52,6 +78,10 @@ for iterations (:c:func:`SUNDomEigEstPreProcess`), computes Hessenberg matrix (w Performs dominant eigenvalue estimatimator initialization (assuming that all estimator-specific options have been set). + **Arguments:** + + * *DEE* -- a SUNDomEigEst object. + **Return value:** A :c:type:`SUNErrCode`. @@ -65,10 +95,14 @@ for iterations (:c:func:`SUNDomEigEstPreProcess`), computes Hessenberg matrix (w .. c:function:: SUNErrCode SUNDomEigEstComputeHess(SUNDomEigEstimator DEE) - *Required* for some estimators (ARNOLDI) and *not applicable* for others (POWER) + *Required* for some estimators (e.g., ARNOLDI) and *not applicable* for others (e.g., POWER) Performs Hessenberg matrix computation (assuming that the estimator is - already initialized). + already initialized and preprocessed (if desired)). + + **Arguments:** + + * *DEE* -- a SUNDomEigEst object. **Return value:** @@ -83,6 +117,13 @@ for iterations (:c:func:`SUNDomEigEstPreProcess`), computes Hessenberg matrix (w retval = SUNDomEigEstComputeHess(DEE); + **Notes:** + + This routine must be called after initialization with :c:func:`SUNDomEigEstInitialize`. + + Optional :c:func:`SUNDomEigEstPreProcess` must be called (if requested) right after + the initialization and right before this function call. + .. c:function:: SUNErrCode SUNDomEigEstimate(SUNDomEigEstimator DEE, sunrealtype* lambdaR, sunrealtype* lambdaI) @@ -115,9 +156,9 @@ for iterations (:c:func:`SUNDomEigEstPreProcess`), computes Hessenberg matrix (w Frees memory allocated by the dominant eigenvalue estimatimator. - **Return value:** + **Arguments:** - A :c:type:`SUNErrCode`. + * *DEE* -- a SUNDomEigEst object. **Usage:** @@ -134,35 +175,20 @@ SUNDomEigEstimator "set" functions The following functions supply dominant eigenvalue estimatimator modules with functions defined by the SUNDIALS packages and modify estimator parameters. Only the routine for setting the matrix-vector product routine is required. -Otherwise, all other set functions are optional. SUNDomEigEst implementations +Otherwise, all other set functions are optional. SUNDomEigEst implementations that do not provide the functionality for any optional routine should leave the corresponding function pointer ``NULL`` instead of supplying a dummy routine. -.. c:function:: SUNErrCode SUNDomEigEstSetATimes(SUNDomEigEstimator DEE, void* A_data, SUNATimesFn ATimes) - - *Required.* - - Provides a :c:type:`SUNATimesFn` function pointer, as well as a ``void*`` - pointer to a data structure used by this routine, to the dominant eigenvalue estimatimator object - *DEE*. SUNDIALS packages call this function to set the matrix-vector product function to either - an estimator-provided difference-quotient via vector operations or a user-supplied - estimator-specific routine. - - **Return value:** - - A :c:type:`SUNErrCode`. - - **Usage:** - - .. code-block:: c +.. c:function:: SUNErrCode SUNDomEigEstSetNumPreProcess(SUNDomEigEstimator DEE, sunindextype numofperprocess) - retval = SUNDomEigEstSetATimes(DEE, A_data, ATimes); + This *optional* routine should set the number of "warm-up" matrix-vector multiplications, + which then should be executed by :c:func:`SUNDomEigEstPreProcess`. + **Arguments:** -.. c:function:: SUNErrCode SUNDomEigEstSetMaxPowerIter(SUNDomEigEstimator DEE, sunindextype max_powiter) - - This *optional* routine sets the number of max power iterations. + * *DEE* -- a SUNDomEigEst object, + * *numofperprocess* -- the number of preprocess. **Return value:** @@ -172,13 +198,18 @@ function pointer ``NULL`` instead of supplying a dummy routine. .. code-block:: c - retval = SUNDomEigEstSetMaxPowerIter(DEE, max_powiter); + retval = SUNDomEigEstSetNumPreProcess(DEE, numofperprocess); .. c:function:: SUNErrCode SUNDomEigEstSetTol(SUNDomEigEstimator DEE, sunrealtype tol) This *optional* routine sets the estimator tolerance. + **Arguments:** + + * *DEE* -- a SUNDomEigEst object, + * *tol* -- the tolerance of estimator. + **Return value:** A :c:type:`SUNErrCode`. @@ -190,10 +221,14 @@ function pointer ``NULL`` instead of supplying a dummy routine. retval = SUNDomEigEstSetTol(DEE, tol); -.. c:function:: SUNErrCode SUNDomEigEstPreProcess(SUNDomEigEstimator DEE) +.. c:function:: SUNErrCode SUNDomEigEstSetMaxPowerIter(SUNDomEigEstimator DEE, sunindextype max_powiter) - This *optional* routine executes the "warm-up" matrix-vector multiplications, - whose number is set by (:c:func:`SUNDomEigEstSetNumPreProcess`). + This *optional* routine sets the number of max power iterations. + + **Arguments:** + + * *DEE* -- a SUNDomEigEst object, + * *max_powiter* -- the maximum number of power iterations. **Return value:** @@ -203,13 +238,17 @@ function pointer ``NULL`` instead of supplying a dummy routine. .. code-block:: c - retval = SUNDomEigEstPreProcess(DEE); + retval = SUNDomEigEstSetMaxPowerIter(DEE, max_powiter); -.. c:function:: SUNErrCode SUNDomEigEstSetNumPreProcess(SUNDomEigEstimator DEE, sunindextype numofperprocess) +.. c:function:: SUNErrCode SUNDomEigEstPreProcess(SUNDomEigEstimator DEE) - This *optional* routine should set the number of "warm-up" matrix-vector multiplications, - which then should be executed by (:c:func:`SUNDomEigEstPreProcess`). + This *optional* routine executes the "warm-up" matrix-vector multiplications, + whose number is set by :c:func:`SUNDomEigEstSetNumPreProcess`. + + **Arguments:** + + * *DEE* -- a SUNDomEigEst object. **Return value:** @@ -219,7 +258,7 @@ function pointer ``NULL`` instead of supplying a dummy routine. .. code-block:: c - retval = SUNDomEigEstSetNumPreProcess(DEE, numofperprocess); + retval = SUNDomEigEstPreProcess(DEE); .. _SUNDomEigEst.GetFn: @@ -236,6 +275,10 @@ dominant eigenvalue estimatimate. *All routines are optional.* This *optional* routine returns a non-negative estimator identifier (of type ``int``) for the dominant eigenvalue estimator *DEE*. + **Arguments:** + + * *DEE* -- a SUNDomEigEst object. + **Return value:** Non-negative estimator identifier (of type ``int``), defined by the @@ -255,28 +298,50 @@ dominant eigenvalue estimatimate. *All routines are optional.* ``SUNDSOMEIGESTIMATOR_CUSTOM`` identifier. -.. c:function:: int SUNDomEigEstNumIters(SUNDomEigEstimator DEE) +.. c:function:: SUNErrCode SUNDomEigEstNumIters(SUNDomEigEstimator DEE, int* niter) This *optional* routine should return the number of estimator iterations performed in the most-recent "estimator" call. + **Arguments:** + + * *DEE* -- a SUNDomEigEst object, + * *niter* -- the number of iterations. + + **Return value:** + + A :c:type:`SUNErrCode`. + **Usage:** .. code-block:: c - its = SUNDomEigEstNumIters(DEE); + int niter; + retval = SUNDomEigEstNumIters(DEE, &niter); + -.. c:function:: sunrealtype SUNDomEigEstRes(SUNDomEigEstimator DEE) + +.. c:function:: SUNErrCode SUNDomEigEstRes(SUNDomEigEstimator DEE, sunrealtype* res) This *optional* routine should return the final residual from the most-recent "estimator" call. + **Arguments:** + + * *DEE* -- a SUNDomEigEst object. + * *res* -- the residual + + **Return value:** + + A :c:type:`SUNErrCode`. + **Usage:** .. code-block:: c - res = SUNDomEigEstRes(DEE); + sunrealtype res; + retval = SUNDomEigEstRes(DEE, &res); .. _SUNDomEigEst.SUNSuppliedFn: @@ -284,12 +349,11 @@ dominant eigenvalue estimatimate. *All routines are optional.* Functions provided by SUNDIALS packages --------------------------------------------- -To interface with SUNDomEigEst modules, the SUNDIALS packages supply -a routine (:c:type:`SUNATimesFn`) for evaluating the matrix-vector product. This package-provided +To interface with SUNDomEigEst modules, the SUNDIALS packages supply a routine +:c:type:`SUNATimesFn` for evaluating the matrix-vector product. This package-provided routine translate between the user-supplied ODE, DAE, or linear and nonlinear -systems and the generic dominant eigenvalue estimatimator API. The -function types for these routines are defined in the header file -``sundials/sundials_iterative.h``. +systems and the generic dominant eigenvalue estimatimator API. The function types +for these routines are defined in the header file ``sundials/sundials_iterative.h``. .. _SUNDomEigEst.ReturnCodes: @@ -298,18 +362,17 @@ SUNDomEigEstimator return codes The functions provided to SUNDomEigEst modules by each SUNDIALS package, and functions within the SUNDIALS-provided SUNDomEigEst implementations, -utilize a common set of return codes, listed in -:numref:`SUNDomEigEst.ErrorCodes`. These adhere to a common pattern: +utilize a common set of return codes, listed in :numref:`SUNDomEigEst.ErrorCodes`. +These adhere to a common pattern: * 0 indicates success * a positive value corresponds to a recoverable failure, and * a negative value indicates a non-recoverable failure. Aside from this pattern, the actual values of each error code -provide additional information to the user in case of an estimatitor +provide additional information to the user in case of an estimator failure. -TODO:Add the right list here! .. _SUNDomEigEst.ErrorCodes: .. table:: SUNDomEigEst error codes @@ -322,7 +385,7 @@ TODO:Add the right list here! +------------------------------------+-------+---------------------------------------------------+ | ``SUN_ERR_DEE_BAD_NVECTOR`` | -9973 | bad NVector | +------------------------------------+-------+---------------------------------------------------+ - | ``SUN_ERR_DEE_NULL_ATIMES`` | -9972 | the ``Atimes`` function is ``NULL`` | + | ``SUN_ERR_DEE_NULL_ATIMES`` | -9972 | the ``Atimes`` function ptr is ``NULL`` | +------------------------------------+-------+---------------------------------------------------+ | ``SUN_ERR_DEE_ATIMES_FAIL_REC`` | -9971 | an unrecoverable failure occurred in the | | | | ``ATimes`` routine | @@ -336,10 +399,15 @@ TODO:Add the right list here! +------------------------------------+-------+---------------------------------------------------+ | ``SUN_ERR_DEE_NULL_CONTENT`` | -9967 | the DEE content is ``NULL`` | +------------------------------------+-------+---------------------------------------------------+ - | ``SUN_ERR_DEE_LAPACK_FAIL`` | -9966 | LAPACK ``_dgeev`` function failure | + | ``SUN_ERR_DEE_LAPACK_FAIL`` | -9966 | LAPACK ``_dgeev/_sgeev`` function failure | + | | | | + +------------------------------------+-------+---------------------------------------------------+ + | ``SUN_ERR_DEE_NULL_ESTIMATE`` | -9965 | estimate function ptr is ``NULL`` | + | | | | + +------------------------------------+-------+---------------------------------------------------+ + | ``SUN_ERR_DEE_NULL_FREE`` | -9964 | free function ptr is ``NULL`` | | | | | +------------------------------------+-------+---------------------------------------------------+ - .. _SUNDomEigEst.Generic: @@ -347,23 +415,23 @@ TODO:Add the right list here! The generic SUNDomEigEstimator module ----------------------------------------- -SUNDIALS packages interact with dominant eigenvalue estimatitor implementations through the -:c:type:`SUNDomEigEstimator` class. A :c:type:`SUNDomEigEstimator` is a pointer to the +SUNDIALS packages interact with dominant eigenvalue estimator implementations through the +:c:type:`SUNDomEigEstimator` class. A :c:type:`SUNDomEigEstimator` is a pointer to the :c:struct:`_generic_SUNDomEigEstimator` structure: .. c:type:: struct _generic_SUNDomEigEstimator *SUNDomEigEstimator .. c:struct:: _generic_SUNDomEigEstimator - The structure defining the SUNDIALS dominant eigenvalue estimatitor class. + The structure defining the SUNDIALS dominant eigenvalue estimator class. .. c:member:: void *content - Pointer to the dominant eigenvalue estimatitor-specific member data + Pointer to the dominant eigenvalue estimator-specific member data .. c:member:: SUNDomEigEstimator_Ops ops - A virtual table of dominant eigenvalue estimatitor operations provided by a specific + A virtual table of dominant eigenvalue estimator operations provided by a specific implementation .. c:member:: SUNContext sunctx @@ -390,14 +458,14 @@ The virtual table structure is defined as The function implementing :c:func:`SUNDomEigEstSetMaxPowerIter` - .. c:member:: SUNErrCode (*settol)(SUNDomEigEstimator, sunrealtype) - - The function implementing :c:func:`SUNDomEigEstSetTol` - .. c:member:: SUNErrCode (*setnumofperprocess)(SUNDomEigEstimator, sunindextype) The function implementing :c:func:`SUNDomEigEstSetNumPreProcess` + .. c:member:: SUNErrCode (*settol)(SUNDomEigEstimator, sunrealtype) + + The function implementing :c:func:`SUNDomEigEstSetTol` + .. c:member:: SUNErrCode (*initialize)(SUNDomEigEstimator) The function implementing :c:func:`SUNDomEigEstInitialize` @@ -418,7 +486,7 @@ The virtual table structure is defined as The function implementing :c:func:`SUNDomEigEstNumIters` - .. c:member:: sunrealtype (*res)(SUNDomEigEstimator) + .. c:member:: sunrealtype (*getres)(SUNDomEigEstimator) The function implementing :c:func:`SUNDomEigEstRes` @@ -426,12 +494,12 @@ The virtual table structure is defined as The function implementing :c:func:`SUNDomEigEstFree` -The generic SUNDomEigEst class defines and implements the dominant eigenvalue estimatitor +The generic SUNDomEigEst class defines and implements the dominant eigenvalue estimator operations defined in :numref:`SUNDomEigEst.CoreFn` -- :numref:`SUNDomEigEst.GetFn`. -These routines are in fact only wrappers to the dominant eigenvalue estimatitor operations +These routines are in fact only wrappers to the dominant eigenvalue estimator operations defined by a particular SUNDomEigEst implementation, which are accessed through the *ops* field of the ``SUNDomEigEstimator`` structure. To illustrate this -point we show below the implementation of a typical dominant eigenvalue estimatitor operation +point we show below the implementation of a typical dominant eigenvalue estimator operation from the ``SUNDomEigEstimator`` base class, namely :c:func:`SUNDomEigEstInitialize`, that initializes a ``SUNDomEigEstimator`` object for use after it has been created and configured, and returns a flag denoting a successful or failed @@ -441,7 +509,7 @@ operation: SUNErrCode SUNDomEigEstInitialize(SUNDomEigEstimator DEE) { - return ((SUNErrCode) DEE->ops->initialize(DEE)); + return (DEE->ops->initialize(DEE)); } @@ -454,7 +522,7 @@ A particular implementation of the ``SUNDomEigEstimator`` module must: * Specify the *content* field of the SUNDomEigEst module. -* Define and implement the required dominant eigenvalue estimatitor operations. +* Define and implement the required dominant eigenvalue estimator operations. .. note:: @@ -466,7 +534,7 @@ A particular implementation of the ``SUNDomEigEstimator`` module must: * Define and implement user-callable constructor and destructor routines to create and free a ``SUNDomEigEstimator`` with the new *content* field and with *ops* pointing to the - new dominant eigenvalue estimatitor operations. + new dominant eigenvalue estimator operations. We note that the function pointers for all unsupported optional routines should be set to ``NULL`` in the *ops* structure. This @@ -475,9 +543,9 @@ to know whether the associated functionality is supported. To aid in the creation of custom ``SUNDomEigEstimator`` modules the generic ``SUNDomEigEstimator`` module provides the utility function -:c:func:`SUNDomEigEstNewEmpty`. When used in custom ``SUNDomEigEstimator`` +:c:func:`SUNDomEigEstNewEmpty`. When used in custom ``SUNDomEigEstimator`` constructors this function will ease the introduction of any new optional dominant -eigenvalue estimatitor operations to the ``SUNDomEigEstimator`` API by ensuring that only required +eigenvalue estimator operations to the ``SUNDomEigEstimator`` API by ensuring that only required operations need to be set. .. c:function:: SUNDomEigEstimator SUNDomEigEstNewEmpty(SUNContext sunctx) @@ -486,13 +554,18 @@ operations need to be set. initializes its content pointer and the function pointers in the operations structure to ``NULL``. + **Arguments:** + + * *sunctx* -- the :c:type:`SUNContext` object (see :numref:`SUNDIALS.SUNContext`) + **Return value:** If successful, this function returns a ``SUNDomEigEstimator`` object. If an error occurs when allocating the object, then this routine will return ``NULL``. -.. c:function:: void SUNDomEigEstFreeEmpty(SUNDomEigEstimator DEE) + +.. c:function:: SUNErrCode SUNDomEigEstFreeEmpty(SUNDomEigEstimator DEE) This routine frees the generic ``SUNDomEigEstimator`` object, under the assumption that any implementation-specific data that was allocated @@ -504,12 +577,16 @@ operations need to be set. * *DEE* -- a SUNDomEigEstimator object + **Return value:** + + A :c:type:`SUNErrCode`. + Additionally, a ``SUNDomEigEstimator`` implementation *may* do the following: * Define and implement additional user-callable "set" routines acting on the ``SUNDomEigEstimator``, e.g., for setting various - configuration options to tune the dominant eigenvalue estimatitor + configuration options to tune the dominant eigenvalue estimator for a particular problem. * Provide additional user-callable "get" routines acting on the @@ -520,7 +597,7 @@ Additionally, a ``SUNDomEigEstimator`` implementation *may* do the following: .. c:enum:: SUNDomEigEstimator_ID Each SUNDomEigEst implementation included in SUNDIALS has a unique identifier - specified in enumeration and shown in :numref:`SUNDomEigEst.API.IDs`. It is + specified in enumeration and shown in :numref:`SUNDomEigEst.API.IDs`. It is recommended that a user-supplied SUNDomEigEst implementation use the ``SUNDSOMEIGESTIMATOR_CUSTOM`` identifier. @@ -530,9 +607,9 @@ Additionally, a ``SUNDomEigEstimator`` implementation *may* do the following: :align: center ================================== ======================================================= ============ - SUNDomEigEst ID Dominant eigenvalue estimatitor type ID Value + SUNDomEigEst ID Dominant eigenvalue estimator type ID Value ================================== ======================================================= ============ SUNDSOMEIGESTIMATOR_POWER Power Iteration (internal) 0 SUNDSOMEIGESTIMATOR_ARNOLDI Arnoldi Iteration (internal) 1 - SUNDSOMEIGESTIMATOR_CUSTOM User-provided custom dominant eigenvalue estimatitor 15 + SUNDSOMEIGESTIMATOR_CUSTOM User-provided custom dominant eigenvalue estimator 15 ================================== ======================================================= ============ \ No newline at end of file diff --git a/doc/shared/sundomeigest/SUNDomEigEst_ARNI.rst b/doc/shared/sundomeigest/SUNDomEigEst_ARNI.rst index 50891f6de6..f7565c607b 100644 --- a/doc/shared/sundomeigest/SUNDomEigEst_ARNI.rst +++ b/doc/shared/sundomeigest/SUNDomEigEst_ARNI.rst @@ -18,18 +18,34 @@ The SUNDomEigEst_ARNI Module ====================================== The SUNDomEigEst_ARNI implementation of the ``SUNDomEigEstimator`` class performs -the Arnoldi Iteration :cite:p:`arnoldi51` method; this is an iterative dominant +the Arnoldi Iteration (ArnI) method :cite:p:`arnoldi51`; this is an iterative dominant eigenvalue estimator that is designed to be compatible with any ``N_Vector`` -implementation that supports a minimal subset of operations +implementation that supports a minimal subset of operations (:c:func:`N_VClone()`, +:c:func:`N_VCloneVectorArray()`, :c:func:`N_VRandom()`, :c:func:`N_VDotProd()`, +:c:func:`N_VLinearSum()`, :c:func:`N_VScale()`, :c:func:`N_VDestroy()`, and +:c:func:`N_VDestroyVectorArray()`). -TODO:Check the list. -(:c:func:`N_VClone()`, :c:func:`N_VDotProd()`, :c:func:`N_VScale()`, -:c:func:`N_VLinearSum()`, :c:func:`N_VProd()`, and -:c:func:`N_VDestroy()`). ARNI requires a prefixed amount of -memory that depends on the user provided dimension of Krylov subspaces. +ArnI is particularly effective for large, sparse matrices where only the dominant +eigenvalue is needed. It constructs an orthonormal basis of the Krylov subspace -The matrix :math:`A` is not required explicitly; only routines -that provide :math:`A` as operator is required. +.. math:: + + \mathcal{K}_m(A, \mathbf{v}) = \text{span}\{\mathbf{v}, A \mathbf{v}, A^2 \mathbf{v}, \dots, A^{m-1} \mathbf{v}\} + +using the Gram-Schmidt process. The matrix :math:`A` is projected onto this subspace +to form a small upper Hessenberg matrix :math:`H_m`. The eigenvalues of :math:`H_m` +approximate some of the eigenvalues of :math:`A`; the dominant eigenvalue of :math:`A` is +well-approximated by the dominant eigenvalue of :math:`H_m`. + +ArnI works for the matrices that have a **complex** dominant eigenvalue. It supports +estimations with a user specified fixed dimension of Krylov subspaces, at least 3. While +these choice requires a prefixed amount of memory (depending on the dimension), it stricly +determines how good an estimation is. To improve the estimation accuracy, we found preprocessing +with :c:func:`SUNDomEigEstPreProcess` particularly useful. This operation is free from any +additional memory requirement and explained below. + +The matrix :math:`A` is not required explicitly; only routines that provide :math:`A` +as operator is required. .. _SUNDomEigEst.ARNI.Usage: @@ -37,10 +53,15 @@ that provide :math:`A` as operator is required. SUNDomEigEst_ARNI Usage ----------------------- -The header file to be included when using this module is -``sundomeigest/sundomeigest_arni.h``. The SUNDomEigEst_ARNI module is accessible from all SUNDIALS solvers -*without* linking to the ``libsundials_sundomeigestarni`` module library after enabling LAPACK package. -This LAPACK dependence is limited to the ``dgeev_`` function after computing Hessenberg matrix internally. +The header file to be included when using this module is ``sundomeigest/sundomeigest_pi.h``. +The SUNDomEigEst_PI module is accessible from all SUNDIALS solvers *without* linking to the +``libsundials_sundomeigestpi`` module library. + +The header file to be included when using this module is ``sundomeigest/sundomeigest_arni.h``. +The SUNDomEigEst_ARNI module is accessible from all SUNDIALS solvers *without* linking to the +``libsundials_sundomeigestarni`` module library after enabling LAPACK package. +This LAPACK dependence is limited to the eigenvalue estimation of the Hessenberg matrix with +``dgeev_/sgeev_`` functions. The module SUNDomEigEst_ARNI provides the following user-callable routines: @@ -61,27 +82,12 @@ The module SUNDomEigEst_ARNI provides the following user-callable routines: **Notes:** This routine will perform consistency checks to ensure that it is - called with a consistent ``N_Vector`` implementation (i.e. that it + called with a consistent ``N_Vector`` implementation (i.e. that it supplies the requisite vector operations). A ``krydim`` argument that is :math:`\leq 2` will result in the default - value (3). - - -.. c:function:: SUNErrCode SUNDomEigEstComputeHess_ArnI(SUNDomEigEstimator DEE) - - This function computes the Hessenberg matrix. - - **Return value:** - - A :c:type:`SUNErrCode`. - - **Notes:** - This routine can be called with (:c:func:`SUNDomEigEstPreProcess`) as well. - It must be called after initialization (:c:func:`SUNDomEigEstInitialize`), - and also preprocess (if requested) should be performed (:c:func:`SUNDomEigEstPreProcess`) - before calling this function. - + value (3). This default value is particularly chosen to minimize the memory + footprint. .. _SUNDomEigEst.ARNI.Description: @@ -139,15 +145,19 @@ This estimator is constructed to perform the following operations: * User-facing "set" routines may be called to modify default estimator parameters. -* Additional "set" routines are called by the SUNDIALS estimator - that interfaces with SUNDomEigEst_ARNI to supply the - ``ATimes`` function pointers and the related data ``ATData``. +* An additional "set" routine must be called by the SUNDIALS estimator + that interfaces with SUNDomEigEst_ARNI to supply the ``ATimes`` + function pointers and the related data ``ATData``. * In the "initialize" call, the estimator parameters are checked for validity and ARNI estimator memory is allocated. * In the "preprocess" call, the initial random vector :math:`q_0` is warmed up - :math:`k=` ``numwarmups`` times as :math:`q_1 = \frac{Aq_0}{||Aq_0||} \cdots q_k = \frac{Aq_{k-1}}{||Aq_{k-1}||}`. + :math:`k=` ``numwarmups`` times as + +.. math:: + + q_1 = \frac{Aq_0}{||Aq_0||} \quad \cdots \quad q_k = \frac{Aq_{k-1}}{||Aq_{k-1}||}. * In the "estimate" call the ARNI estimator is performed. @@ -169,4 +179,4 @@ dominant eigenvalue estimator operations listed in * ``SUNDomEigEstimate_ArnI`` -* ``SUNDomEigEstFree_ArnI`` +* ``SUNDomEigEstFree_ArnI`` \ No newline at end of file diff --git a/doc/shared/sundomeigest/SUNDomEigEst_Examples.rst b/doc/shared/sundomeigest/SUNDomEigEst_Examples.rst index 832d3b4db1..9fde4cc789 100644 --- a/doc/shared/sundomeigest/SUNDomEigEst_Examples.rst +++ b/doc/shared/sundomeigest/SUNDomEigEst_Examples.rst @@ -32,9 +32,23 @@ The following is a list of the example functions in ``test_sundomeigest.c``: * ``Test_SUNDomEigEstSetATimes`` Verifies that ``SUNDomEigEstSetATimes`` can be called and returns successfully. +* ``Test_SUNDomEigEstSetMaxPowerIter`` Verifies that + ``SUNDomEigEstSetMaxPowerIter`` can be called and returns successfully. + + + ``SUNDomEigEstSetMaxPowerIter`` is not an option for some estimators, e.g., + Arnoldi iteration. In this case, it should return with SUN_SUCCESS. + * ``Test_SUNDomEigEstSetNumPreProcess`` Verifies that ``SUNDomEigEstSetNumPreProcess`` can be called and returns successfully. +* ``Test_SUNDomEigEstSetTol`` Verifies that + ``SUNDomEigEstSetTol`` can be called and returns successfully. + + + ``SUNDomEigEstSetTol`` is not an option for some estimators, e.g., + Arnoldi iteration. In this case, it should return with SUN_SUCCESS. + * ``Test_SUNDomEigEstInitialize``: Verifies that ``SUNDomEigEstInitialize`` can be called and returns successfully. @@ -44,20 +58,42 @@ The following is a list of the example functions in ``test_sundomeigest.c``: * ``Test_SUNDomEigEstComputeHess``: Verifies that ``SUNDomEigEstComputeHess`` can be called and returns successfully. + + ``SUNDomEigEstComputeHess`` is not an option for some estimators, e.g., + Power iteration. In this case, it should return with SUN_SUCCESS. + A failure flag returns otherwise. + * ``Test_SUNDomEigEstimate``: Verifies that ``SUNDomEigEstimate`` - can be called and returns successfully. Estimated dominant eigenvalue is + can be called and returns successfully. Estimated dominant eigenvalue is :math:`\lambda_{\max} = \lambda` such that :math:`|\lambda| = \max\{|\lambda_i| : A \vec{v_i} = \lambda_i \vec{v_i}, \ \vec{v_i} \neq \vec{0} \}`. This test compares the estimated dominant eigenvalue to the known value and returns a passing flag if the estimation is within a specified relative tolerance; otherwise, it returns a failure flag. +* ``Test_SUNDomEigEstNumIters`` Verifies that + ``SUNDomEigEstNumIters`` can be called and returns successfully. + + + ``SUNDomEigEstNumIters`` is not an option for some estimators, e.g., + Arnoldi iteration. In this case, it should return with SUN_SUCCESS + and `niter = 0`. A failure flag returns otherwise. + +* ``Test_SUNDomEigEstRes`` Verifies that + ``SUNDomEigEstRes`` can be called and returns successfully. + + + ``SUNDomEigEstRes`` is not an option for some estimators, e.g., + Arnoldi iteration. In this case, it should return with SUN_SUCCESS + and `res = 0`. A failure flag returns otherwise. We'll note that these tests should be performed in a particular order. For all estimators, -``Test_SUNDomEigEstSetATimes`` must be called -before ``Test_SUNDomEigEstInitialize``, which must be called -before ``Test_SUNDomEigEstPreProcess`` (if applicable). +``SUNDomEigEstSetATimes`` must be called +before other set routines e.g., ``SUNDomEigEstSetMaxPowerIter``, +``SUNDomEigEstSetNumPreProcess``, ``SUNDomEigEstSetTol`` (if applicable). +Then, ``Test_SUNDomEigEstInitialize`` must be called before +``Test_SUNDomEigEstPreProcess`` (if applicable). ``Test_SUNDomEigEstComputeHess`` (if the estimator requires) must be called next and before ``Test_SUNDomEigEstimate``. For the estimator stats ``Test_SUNDomEigEstNumIters`` and ``Test_SUNDomEigEstRes`` diff --git a/doc/shared/sundomeigest/SUNDomEigEst_PI.rst b/doc/shared/sundomeigest/SUNDomEigEst_PI.rst index f5a4c2cc7e..6a16444a7a 100644 --- a/doc/shared/sundomeigest/SUNDomEigEst_PI.rst +++ b/doc/shared/sundomeigest/SUNDomEigEst_PI.rst @@ -18,18 +18,43 @@ The SUNDomEigEst_PI Module ====================================== The SUNDomEigEst_PI implementation of the ``SUNDomEigEstimator`` class performs -the Power Iteration :cite:p:`vonmises29` method; this is an iterative dominant +the Power Iteration (PI) method :cite:p:`vonmises29`; this is an iterative dominant eigenvalue estimator that is designed to be compatible with any ``N_Vector`` -implementation that supports a minimal subset of operations +implementation that supports a minimal subset of operations (:c:func:`N_VClone()`, +:c:func:`N_VRandom()`, :c:func:`N_VDotProd()`, :c:func:`N_VScale()`, and +:c:func:`N_VDestroy()`). -TODO:Check the list. -(:c:func:`N_VClone()`, :c:func:`N_VDotProd()`, :c:func:`N_VScale()`, -:c:func:`N_VLinearSum()`, :c:func:`N_VProd()`, and -:c:func:`N_VDestroy()`). PI requires a fixed amount of memory regardless of -the number of Iterations. +PI is particularly effective for large, sparse matrices where only the dominant +eigenvalue is needed. The algorithm starts with a random non-zero vector +:math:`\mathbf{v}_{0}`. It then iteratively updates to obtain -The matrix :math:`A` is not required explicitly; only routines -that provide :math:`A` as operator is required. +.. math:: + + \mathbf{v}_{k+1} = \frac{A \mathbf{v}_k}{\|A \mathbf{v}_k\|}, + +where :math:`\| \cdot \|` denotes the Euclidean norm. Over successive iterations, +:math:`\mathbf{v}_k` converges to the eigenvector corresponding to +the dominant eigenvalue of :math:`A`. At each step, the corresponding eigenvalue +can be approximated using the Rayleigh quotient + +.. math:: + + \lambda_k = \frac{\mathbf{v}_k^T A \mathbf{v}_k}{\|\mathbf{v}_k\|^2}. + +The iteration continues until the two succesive eigenvalues are relatively close +enough to one another. That is, for some reletive tolerance :math:`\tau`, + +.. math:: + + \frac{\left|\lambda_k - \lambda_{k-1}\right|}{\left|\lambda_k \right|} < \tau. + +PI works for the matrices that have a **real** dominant eigenvalue. If it is strictly +greater than all others (in magnitude), convergence is guaranteed. The speed of convergence +depends on the ratios of the magnitude of the first two dominant eigenvalues. + +The matrix :math:`A` is not required explicitly; only routines that provide +:math:`A` as operator is required. Also, it requires a fixed amount of memory +regardless of the number of iterations. .. _SUNDomEigEst.PI.Usage: @@ -37,9 +62,9 @@ that provide :math:`A` as operator is required. SUNDomEigEst_PI Usage --------------------- -The header file to be included when using this module is -``sundomeigest/sundomeigest_pi.h``. The SUNDomEigEst_PI module is accessible from all SUNDIALS solvers -*without* linking to the ``libsundials_sundomeigestpi`` module library. +The header file to be included when using this module is ``sundomeigest/sundomeigest_pi.h``. +The SUNDomEigEst_PI module is accessible from all SUNDIALS solvers *without* linking to the +``libsundials_sundomeigestpi`` module library. The module SUNDomEigEst_PI provides the following user-callable routines: @@ -60,12 +85,19 @@ The module SUNDomEigEst_PI provides the following user-callable routines: **Notes:** This routine will perform consistency checks to ensure that it is - called with a consistent ``N_Vector`` implementation (i.e. that it + called with a consistent ``N_Vector`` implementation (i.e. that it supplies the requisite vector operations). A ``max_powiter`` argument that is :math:`\le0` will result in the default value (100). + Although this default number is not high for large martices, + it is reasonable since + + 1. most solvers do not need too tight tolerances and consider a safety factor, + + 2. an early (less costly) termination will be a good indicator if PI is compatible. + .. _SUNDomEigEst.PI.Description: @@ -83,11 +115,11 @@ The SUNDomEigEst_PI module defines the *content* field of a void* ATdata; N_Vector* V; N_Vector q; - sunindextype max_powiter; - sunindextype numwarmups; + int numwarmups; + int max_powiter; + int numiters; sunrealtype powiter_tol; sunrealtype res; - sunindextype numiters; }; @@ -100,15 +132,15 @@ information: * ``V, q`` - ``N_Vector`` used for workspace by the PI algorithm. +* ``numwarmups`` - number of preprocessing warmups (default is 0), + * ``max_powiter`` - maximum number of power iterations (default is 100), -* ``numwarmups`` - number of preprocessing warmups (default is 0), +* ``numiters`` - current number of power iterations, * ``powiter_tol`` - convergence criteria for the power iteration (default is 0.01), -* ``res`` - current residual of power iterations, - -* ``numiters`` - current number of power iterations. +* ``res`` - current residual of power iterations. This estimator is constructed to perform the following operations: @@ -120,20 +152,24 @@ This estimator is constructed to perform the following operations: * User-facing "set" routines may be called to modify default estimator parameters. -* Additional "set" routines are called by the SUNDIALS estimator - that interfaces with SUNDomEigEst_PI to supply the - ``ATimes`` function pointers and the related data ``ATData``. +* An additional "set" routine must be called by the SUNDIALS estimator + that interfaces with SUNDomEigEst_PI to supply the ``ATimes`` + function pointers and the related data ``ATData``. * In the "initialize" call, the estimator parameters are checked for validity and PI estimator memory is allocated. * In the "preprocess" call, the initial random vector :math:`q_0` is warmed up - :math:`k=` ``numwarmups`` times as :math:`q_1 = \frac{Aq_0}{||Aq_0||} \cdots q_k = \frac{Aq_{k-1}}{||Aq_{k-1}||}`. + :math:`k=` ``numwarmups`` times as + +.. math:: + + q_1 = \frac{Aq_0}{||Aq_0||} \quad \cdots \quad q_k = \frac{Aq_{k-1}}{||Aq_{k-1}||}. * In the "estimate" call the PI estimator is performed. -The SUNDomEigEst_PI module defines implementations of all -dominant eigenvalue estimator operations listed in +The SUNDomEigEst_PI module defines implementations of all dominant +eigenvalue estimator operations listed in :numref:`SUNDomEigEst.API`: * ``SUNDomEigEst_PIGetID`` @@ -144,6 +180,8 @@ dominant eigenvalue estimator operations listed in * ``SUNDomEigEstSetNumPreProcess_PI`` +* ``SUNDomEigEstSetTol_PI`` + * ``SUNDomEigEstSetMaxPowerIter_PI`` * ``SUNDomEigEstPreProcess_PI`` diff --git a/examples/arkode/C_serial/ark_analytic_lsrk_internal_domeig.out b/examples/arkode/C_serial/ark_analytic_lsrk_internal_domeig.out index 050c5258a0..80550d38a6 100644 --- a/examples/arkode/C_serial/ark_analytic_lsrk_internal_domeig.out +++ b/examples/arkode/C_serial/ark_analytic_lsrk_internal_domeig.out @@ -36,6 +36,10 @@ Last step size = 0.0231428573546272 Current step size = 0.0355887084904971 RHS fn evals = 134016 Number of dom_eig updates = 85 +Number of fe calls for DEE = 2940 +Krylov subspace dim. in DEE = 3 +Number of warmups in DEE = 0 +Max. num. of iters in DEE = 100 Max. num. of stages used = 199 Max. num. of stages allowed = 200 Max. spectral radius = 1010101.00085802 diff --git a/include/arkode/arkode_lsrkstep.h b/include/arkode/arkode_lsrkstep.h index e30d1a3466..c059f59563 100644 --- a/include/arkode/arkode_lsrkstep.h +++ b/include/arkode/arkode_lsrkstep.h @@ -75,8 +75,8 @@ SUNDIALS_EXPORT int LSRKStepSetSSPMethodByName(void* arkode_mem, SUNDIALS_EXPORT int LSRKStepSetDomEigFn(void* arkode_mem, ARKDomEigFn dom_eig); -SUNDIALS_EXPORT int LSRKStepSetDEECreateWithID(void* arkode_mem, - SUNDomEigEstimator_ID DEE_id); +SUNDIALS_EXPORT int LSRKStepDomEigEstCreateWithID(void* arkode_mem, + SUNDomEigEstimator_ID DEE_id); SUNDIALS_EXPORT int LSRKStepSetDomEigFrequency(void* arkode_mem, long int nsteps); diff --git a/include/sundials/sundials_domeigestimator.h b/include/sundials/sundials_domeigestimator.h index f6bb2d416c..40ac624115 100644 --- a/include/sundials/sundials_domeigestimator.h +++ b/include/sundials/sundials_domeigestimator.h @@ -98,7 +98,8 @@ SUNErrCode SUNDomEigEstSetATimes(SUNDomEigEstimator DEE, void* A_data, SUNATimesFn ATimes); SUNDIALS_EXPORT -SUNErrCode SUNDomEigEstInitialize(SUNDomEigEstimator DEE); +SUNErrCode SUNDomEigEstSetMaxPowerIter(SUNDomEigEstimator DEE, + int max_powiter); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstSetNumPreProcess(SUNDomEigEstimator DEE, @@ -108,7 +109,7 @@ SUNDIALS_EXPORT SUNErrCode SUNDomEigEstSetTol(SUNDomEigEstimator DEE, sunrealtype tol); SUNDIALS_EXPORT -SUNErrCode SUNDomEigEstSetMaxPowerIter(SUNDomEigEstimator DEE, int max_powiter); +SUNErrCode SUNDomEigEstInitialize(SUNDomEigEstimator DEE); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstPreProcess(SUNDomEigEstimator DEE); diff --git a/include/sundomeigest/sundomeigest_arni.h b/include/sundomeigest/sundomeigest_arni.h index 02d7567471..05e5bcd412 100644 --- a/include/sundomeigest/sundomeigest_arni.h +++ b/include/sundomeigest/sundomeigest_arni.h @@ -73,13 +73,13 @@ SUNDIALS_EXPORT SUNErrCode SUNDomEigEstSetATimes_ArnI(SUNDomEigEstimator DEE, void* A_data, SUNATimesFn ATimes); -SUNDIALS_EXPORT -SUNErrCode SUNDomEigEstInitialize_ArnI(SUNDomEigEstimator DEE); - SUNDIALS_EXPORT SUNErrCode SUNDomEigEstSetNumPreProcess_ArnI(SUNDomEigEstimator DEE, int numofperprocess); +SUNDIALS_EXPORT +SUNErrCode SUNDomEigEstInitialize_ArnI(SUNDomEigEstimator DEE); + SUNDIALS_EXPORT SUNErrCode SUNDomEigEstPreProcess_ArnI(SUNDomEigEstimator DEE); diff --git a/include/sundomeigest/sundomeigest_pi.h b/include/sundomeigest/sundomeigest_pi.h index 226beddd06..895e7086ab 100644 --- a/include/sundomeigest/sundomeigest_pi.h +++ b/include/sundomeigest/sundomeigest_pi.h @@ -44,12 +44,12 @@ struct _SUNDomEigEstimatorContent_PI N_Vector V, q; /* workspace vectors */ - int numwarmups; /* Power of A in the preprocessing; initial q = A^{numwarmups}q/||A^{numwarmups}q|| */ + int numwarmups; /* Power of A in the preprocessing; initial q = A^{numwarmups}q/||A^{numwarmups}q|| */ + int max_powiter; /* Maximum number of power iterations */ + int numiters; /* Current number of power iterations */ sunrealtype powiter_tol; /* Convergence criteria for the power iteration */ sunrealtype res; /* Current residual of power iterations */ - int max_powiter; /* Maximum number of power iterations */ - int numiters; /* Current number of power iterations */ }; typedef struct _SUNDomEigEstimatorContent_PI* SUNDomEigEstimatorContent_PI; @@ -70,7 +70,8 @@ SUNErrCode SUNDomEigEstSetATimes_PI(SUNDomEigEstimator DEE, void* A_data, SUNATimesFn ATimes); SUNDIALS_EXPORT -SUNErrCode SUNDomEigEstInitialize_PI(SUNDomEigEstimator DEE); +SUNErrCode SUNDomEigEstSetMaxPowerIter_PI(SUNDomEigEstimator DEE, + int max_powiter); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstSetNumPreProcess_PI(SUNDomEigEstimator DEE, @@ -80,8 +81,8 @@ SUNDIALS_EXPORT SUNErrCode SUNDomEigEstSetTol_PI(SUNDomEigEstimator DEE, sunrealtype tol); SUNDIALS_EXPORT -SUNErrCode SUNDomEigEstSetMaxPowerIter_PI(SUNDomEigEstimator DEE, - int max_powiter); +SUNErrCode SUNDomEigEstInitialize_PI(SUNDomEigEstimator DEE); + SUNDIALS_EXPORT SUNErrCode SUNDomEigEstPreProcess_PI(SUNDomEigEstimator DEE); diff --git a/src/arkode/arkode_lsrkstep.c b/src/arkode/arkode_lsrkstep.c index 018decb274..3cbbf3f7b1 100644 --- a/src/arkode/arkode_lsrkstep.c +++ b/src/arkode/arkode_lsrkstep.c @@ -2081,8 +2081,21 @@ void lsrkStep_PrintMem(ARKodeMem ark_mem, FILE* outfile) fprintf(outfile, "LSRKStep: dom_eig_freq = %li\n", step_mem->dom_eig_freq); + if(step_mem->DEE != NULL) + { + fprintf(outfile, "LSRKStep: dee_krydim = %i\n", + step_mem->dee_krydim); + fprintf(outfile, "LSRKStep: dee_numwarmups = %i\n", + step_mem->dee_numwarmups); + fprintf(outfile, "LSRKStep: dee_maxiters = %i\n", + step_mem->dee_maxiters); + } /* output long integer quantities */ fprintf(outfile, "LSRKStep: nfe = %li\n", step_mem->nfe); + if(step_mem->DEE != NULL) + { + fprintf(outfile, "LSRKStep: nfeDQ = %li\n", step_mem->nfeDQ); + } fprintf(outfile, "LSRKStep: dom_eig_num_evals = %li\n", step_mem->dom_eig_num_evals); @@ -2489,9 +2502,25 @@ int lsrkStep_DQJtimes(void* arkode_mem, N_Vector v, N_Vector Jv) sunrealtype t = ark_mem->tn; N_Vector y = ark_mem->yn; - N_Vector fy = ark_mem->fn; //make sure it is current! N_Vector work = ark_mem->tempv3; + /* Compute RHS function, if necessary. */ + if ((!ark_mem->fn_is_current && ark_mem->initsetup) || + (step_mem->step_nst != ark_mem->nst)) + { + retval = step_mem->fe(ark_mem->tn, ark_mem->yn, ark_mem->fn, + ark_mem->user_data); + step_mem->nfeDQ++; + if (retval != ARK_SUCCESS) + { + SUNLogExtraDebugVec(ARK_LOGGER, "stage RHS", ark_mem->fn, "F_0(:) ="); + SUNLogInfo(ARK_LOGGER, "end-stage", + "status = failed rhs eval, retval = %i", retval); + return (ARK_RHSFUNC_FAIL); + } + ark_mem->fn_is_current = SUNTRUE; + } + /* Initialize perturbation to 1/||v|| */ sig = ONE / N_VWrmsNorm(v, ark_mem->ewt); @@ -2514,9 +2543,9 @@ int lsrkStep_DQJtimes(void* arkode_mem, N_Vector v, N_Vector Jv) /* If retval still isn't 0, return with a recoverable failure */ if (retval > 0) { return (+1); } - /* Replace Jv by (Jv - fy)/sig */ + /* Replace Jv by (Jv - fn)/sig */ siginv = ONE / sig; - N_VLinearSum(siginv, Jv, -siginv, fy, Jv); + N_VLinearSum(siginv, Jv, -siginv, ark_mem->fn, Jv); return (0); } diff --git a/src/arkode/arkode_lsrkstep_io.c b/src/arkode/arkode_lsrkstep_io.c index 9b95652794..31a7dc54bd 100644 --- a/src/arkode/arkode_lsrkstep_io.c +++ b/src/arkode/arkode_lsrkstep_io.c @@ -237,10 +237,10 @@ int LSRKStepSetDomEigFn(void* arkode_mem, ARKDomEigFn dom_eig) } /*--------------------------------------------------------------- - LSRKStepSetDEECreateWithID creates DomEigEst with ID. + LSRKStepDomEigEstCreateWithID creates DomEigEst with ID. ---------------------------------------------------------------*/ -SUNDIALS_EXPORT int LSRKStepSetDEECreateWithID(void* arkode_mem, - SUNDomEigEstimator_ID DEE_id) +SUNDIALS_EXPORT int LSRKStepDomEigEstCreateWithID(void* arkode_mem, + SUNDomEigEstimator_ID DEE_id) { ARKodeMem ark_mem; ARKodeLSRKStepMem step_mem; @@ -648,6 +648,17 @@ int lsrkStep_PrintAllStats(ARKodeMem ark_mem, FILE* outfile, SUNOutputFormat fmt { sunfprintf_long(outfile, fmt, SUNFALSE, "Number of dom_eig updates", step_mem->dom_eig_num_evals); + if(step_mem->DEE != NULL) + { + sunfprintf_long(outfile, fmt, SUNFALSE, "Number of fe calls for DEE", + step_mem->nfeDQ); + sunfprintf_long(outfile, fmt, SUNFALSE, "Krylov subspace dim. in DEE", + step_mem->dee_krydim); + sunfprintf_long(outfile, fmt, SUNFALSE, "Number of warmups in DEE", + step_mem->dee_numwarmups); + sunfprintf_long(outfile, fmt, SUNFALSE, "Max. num. of iters in DEE", + step_mem->dee_maxiters); + } sunfprintf_long(outfile, fmt, SUNFALSE, "Max. num. of stages used", step_mem->stage_max); sunfprintf_long(outfile, fmt, SUNFALSE, "Max. num. of stages allowed", @@ -712,6 +723,14 @@ int lsrkStep_WriteParameters(ARKodeMem ark_mem, FILE* fp) case SUNFALSE: fprintf(fp, " Maximum number of stages allowed = %i\n", step_mem->stage_max_limit); + fprintf(fp, " Number of fe calls for DEE = %i\n", + step_mem->nfeDQ); + fprintf(fp, " Krylov subspace dimension in DEE = %i\n", + step_mem->dee_krydim); + fprintf(fp, " Number of warmups in DEE = %i\n", + step_mem->dee_numwarmups); + fprintf(fp, " Max. num. of iters in DEE = %i\n", + step_mem->dee_maxiters); fprintf(fp, " Current spectral radius = " SUN_FORMAT_G "\n", step_mem->spectral_radius); fprintf(fp, " Safety factor for the dom eig = " SUN_FORMAT_G "\n", diff --git a/src/arkode/fmod_int32/farkode_lsrkstep_mod.c b/src/arkode/fmod_int32/farkode_lsrkstep_mod.c index f2b5249d7c..91106e5814 100644 --- a/src/arkode/fmod_int32/farkode_lsrkstep_mod.c +++ b/src/arkode/fmod_int32/farkode_lsrkstep_mod.c @@ -207,15 +207,15 @@ enum { * the fortran.cxx file. */ #define SWIG_contract_assert(RETURNNULL, EXPR, MSG) \ - if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); } + if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); } -#define SWIGVERSION 0x040000 +#define SWIGVERSION 0x040000 #define SWIG_VERSION SWIGVERSION -#define SWIG_as_voidptr(a) (void *)((const void *)(a)) -#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) +#define SWIG_as_voidptr(a) (void *)((const void *)(a)) +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) #include "arkode/arkode_lsrkstep.h" @@ -266,7 +266,7 @@ SWIGEXPORT void * _wrap_FLSRKStepCreateSTS(ARKRhsFn farg1, double const *farg2, N_Vector arg3 = (N_Vector) 0 ; SUNContext arg4 = (SUNContext) 0 ; void *result = 0 ; - + arg1 = (ARKRhsFn)(farg1); arg2 = (sunrealtype)(*farg2); arg3 = (N_Vector)(farg3); @@ -284,7 +284,7 @@ SWIGEXPORT void * _wrap_FLSRKStepCreateSSP(ARKRhsFn farg1, double const *farg2, N_Vector arg3 = (N_Vector) 0 ; SUNContext arg4 = (SUNContext) 0 ; void *result = 0 ; - + arg1 = (ARKRhsFn)(farg1); arg2 = (sunrealtype)(*farg2); arg3 = (N_Vector)(farg3); @@ -302,7 +302,7 @@ SWIGEXPORT int _wrap_FLSRKStepReInitSTS(void *farg1, ARKRhsFn farg2, double cons sunrealtype arg3 ; N_Vector arg4 = (N_Vector) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (ARKRhsFn)(farg2); arg3 = (sunrealtype)(*farg3); @@ -320,7 +320,7 @@ SWIGEXPORT int _wrap_FLSRKStepReInitSSP(void *farg1, ARKRhsFn farg2, double cons sunrealtype arg3 ; N_Vector arg4 = (N_Vector) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (ARKRhsFn)(farg2); arg3 = (sunrealtype)(*farg3); @@ -336,7 +336,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetSTSMethod(void *farg1, int const *farg2) { void *arg1 = (void *) 0 ; ARKODE_LSRKMethodType arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (ARKODE_LSRKMethodType)(*farg2); result = (int)LSRKStepSetSTSMethod(arg1,arg2); @@ -350,7 +350,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetSSPMethod(void *farg1, int const *farg2) { void *arg1 = (void *) 0 ; ARKODE_LSRKMethodType arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (ARKODE_LSRKMethodType)(*farg2); result = (int)LSRKStepSetSSPMethod(arg1,arg2); @@ -364,7 +364,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetSTSMethodByName(void *farg1, SwigArrayWrapper * void *arg1 = (void *) 0 ; char *arg2 = (char *) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (char *)(farg2->data); result = (int)LSRKStepSetSTSMethodByName(arg1,(char const *)arg2); @@ -378,7 +378,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetSSPMethodByName(void *farg1, SwigArrayWrapper * void *arg1 = (void *) 0 ; char *arg2 = (char *) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (char *)(farg2->data); result = (int)LSRKStepSetSSPMethodByName(arg1,(char const *)arg2); @@ -392,7 +392,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetDomEigFn(void *farg1, ARKDomEigFn farg2) { void *arg1 = (void *) 0 ; ARKDomEigFn arg2 = (ARKDomEigFn) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (ARKDomEigFn)(farg2); result = (int)LSRKStepSetDomEigFn(arg1,arg2); @@ -401,16 +401,16 @@ SWIGEXPORT int _wrap_FLSRKStepSetDomEigFn(void *farg1, ARKDomEigFn farg2) { } -SWIGEXPORT int _wrap_FLSRKStepSetDEECreateWithID(void *farg1, SwigClassWrapper const *farg2) { +SWIGEXPORT int _wrap_FLSRKStepDomEigEstCreateWithID(void *farg1, SwigClassWrapper const *farg2) { int fresult ; void *arg1 = (void *) 0 ; SUNDomEigEstimator_ID arg2 ; int result; - + arg1 = (void *)(farg1); - SWIG_check_nonnull(*farg2, "SUNDomEigEstimator_ID", "SWIGTYPE_p_SUNDomEigEstimator_ID", "LSRKStepSetDEECreateWithID(void *,SUNDomEigEstimator_ID)", return 0); + SWIG_check_nonnull(*farg2, "SUNDomEigEstimator_ID", "SWIGTYPE_p_SUNDomEigEstimator_ID", "LSRKStepDomEigEstCreateWithID(void *,SUNDomEigEstimator_ID)", return 0); arg2 = *(SUNDomEigEstimator_ID *)(farg2->cptr); - result = (int)LSRKStepSetDEECreateWithID(arg1,arg2); + result = (int)LSRKStepDomEigEstCreateWithID(arg1,arg2); fresult = (int)(result); return fresult; } @@ -421,7 +421,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetDomEigFrequency(void *farg1, long const *farg2) void *arg1 = (void *) 0 ; long arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (long)(*farg2); result = (int)LSRKStepSetDomEigFrequency(arg1,arg2); @@ -435,7 +435,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetMaxNumStages(void *farg1, int const *farg2) { void *arg1 = (void *) 0 ; int arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (int)(*farg2); result = (int)LSRKStepSetMaxNumStages(arg1,arg2); @@ -449,7 +449,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetDomEigSafetyFactor(void *farg1, double const *f void *arg1 = (void *) 0 ; sunrealtype arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (sunrealtype)(*farg2); result = (int)LSRKStepSetDomEigSafetyFactor(arg1,arg2); @@ -463,7 +463,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetNumSSPStages(void *farg1, int const *farg2) { void *arg1 = (void *) 0 ; int arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (int)(*farg2); result = (int)LSRKStepSetNumSSPStages(arg1,arg2); @@ -477,7 +477,7 @@ SWIGEXPORT int _wrap_FLSRKStepGetNumDomEigUpdates(void *farg1, long *farg2) { void *arg1 = (void *) 0 ; long *arg2 = (long *) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (long *)(farg2); result = (int)LSRKStepGetNumDomEigUpdates(arg1,arg2); @@ -491,7 +491,7 @@ SWIGEXPORT int _wrap_FLSRKStepGetMaxNumStages(void *farg1, int *farg2) { void *arg1 = (void *) 0 ; int *arg2 = (int *) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (int *)(farg2); result = (int)LSRKStepGetMaxNumStages(arg1,arg2); @@ -505,7 +505,7 @@ SWIGEXPORT int _wrap_FLSRKStepGetNumRHSinDQ(void *farg1, long *farg2) { void *arg1 = (void *) 0 ; long *arg2 = (long *) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (long *)(farg2); result = (int)LSRKStepGetNumRHSinDQ(arg1,arg2); diff --git a/src/arkode/fmod_int32/farkode_lsrkstep_mod.f90 b/src/arkode/fmod_int32/farkode_lsrkstep_mod.f90 index e9359f4c7b..2024d65d94 100644 --- a/src/arkode/fmod_int32/farkode_lsrkstep_mod.f90 +++ b/src/arkode/fmod_int32/farkode_lsrkstep_mod.f90 @@ -60,7 +60,7 @@ module farkode_lsrkstep_mod type, public :: SWIGTYPE_p_SUNDomEigEstimator_ID type(SwigClassWrapper), public :: swigdata end type - public :: FLSRKStepSetDEECreateWithID + public :: FLSRKStepDomEigEstCreateWithID public :: FLSRKStepSetDomEigFrequency public :: FLSRKStepSetMaxNumStages public :: FLSRKStepSetDomEigSafetyFactor @@ -162,8 +162,8 @@ function swigc_FLSRKStepSetDomEigFn(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FLSRKStepSetDEECreateWithID(farg1, farg2) & -bind(C, name="_wrap_FLSRKStepSetDEECreateWithID") & +function swigc_FLSRKStepDomEigEstCreateWithID(farg1, farg2) & +bind(C, name="_wrap_FLSRKStepDomEigEstCreateWithID") & result(fresult) use, intrinsic :: ISO_C_BINDING import :: swigclasswrapper @@ -248,11 +248,11 @@ function FLSRKStepCreateSTS(rhs, t0, y0, sunctx) & real(C_DOUBLE), intent(in) :: t0 type(N_Vector), target, intent(inout) :: y0 type(C_PTR) :: sunctx -type(C_PTR) :: fresult -type(C_FUNPTR) :: farg1 -real(C_DOUBLE) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 +type(C_PTR) :: fresult +type(C_FUNPTR) :: farg1 +real(C_DOUBLE) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 farg1 = rhs farg2 = t0 @@ -270,11 +270,11 @@ function FLSRKStepCreateSSP(rhs, t0, y0, sunctx) & real(C_DOUBLE), intent(in) :: t0 type(N_Vector), target, intent(inout) :: y0 type(C_PTR) :: sunctx -type(C_PTR) :: fresult -type(C_FUNPTR) :: farg1 -real(C_DOUBLE) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 +type(C_PTR) :: fresult +type(C_FUNPTR) :: farg1 +real(C_DOUBLE) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 farg1 = rhs farg2 = t0 @@ -292,11 +292,11 @@ function FLSRKStepReInitSTS(arkode_mem, rhs, t0, y0) & type(C_FUNPTR), intent(in), value :: rhs real(C_DOUBLE), intent(in) :: t0 type(N_Vector), target, intent(inout) :: y0 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -real(C_DOUBLE) :: farg3 -type(C_PTR) :: farg4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +real(C_DOUBLE) :: farg3 +type(C_PTR) :: farg4 farg1 = arkode_mem farg2 = rhs @@ -314,11 +314,11 @@ function FLSRKStepReInitSSP(arkode_mem, rhs, t0, y0) & type(C_FUNPTR), intent(in), value :: rhs real(C_DOUBLE), intent(in) :: t0 type(N_Vector), target, intent(inout) :: y0 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -real(C_DOUBLE) :: farg3 -type(C_PTR) :: farg4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +real(C_DOUBLE) :: farg3 +type(C_PTR) :: farg4 farg1 = arkode_mem farg2 = rhs @@ -334,9 +334,9 @@ function FLSRKStepSetSTSMethod(arkode_mem, method) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(ARKODE_LSRKMethodType), intent(in) :: method -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = method @@ -350,9 +350,9 @@ function FLSRKStepSetSSPMethod(arkode_mem, method) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(ARKODE_LSRKMethodType), intent(in) :: method -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = method @@ -385,9 +385,9 @@ function FLSRKStepSetSTSMethodByName(arkode_mem, emethod) & type(C_PTR) :: arkode_mem character(kind=C_CHAR, len=*), target :: emethod character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 farg1 = arkode_mem call SWIG_string_to_chararray(emethod, farg2_chars, farg2) @@ -402,9 +402,9 @@ function FLSRKStepSetSSPMethodByName(arkode_mem, emethod) & type(C_PTR) :: arkode_mem character(kind=C_CHAR, len=*), target :: emethod character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 farg1 = arkode_mem call SWIG_string_to_chararray(emethod, farg2_chars, farg2) @@ -418,9 +418,9 @@ function FLSRKStepSetDomEigFn(arkode_mem, dom_eig) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: dom_eig -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = dom_eig @@ -428,19 +428,19 @@ function FLSRKStepSetDomEigFn(arkode_mem, dom_eig) & swig_result = fresult end function -function FLSRKStepSetDEECreateWithID(arkode_mem, dee_id) & +function FLSRKStepDomEigEstCreateWithID(arkode_mem, dee_id) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(SWIGTYPE_p_SUNDomEigEstimator_ID), intent(in) :: dee_id -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigClassWrapper) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigClassWrapper) :: farg2 farg1 = arkode_mem farg2 = dee_id%swigdata -fresult = swigc_FLSRKStepSetDEECreateWithID(farg1, farg2) +fresult = swigc_FLSRKStepDomEigEstCreateWithID(farg1, farg2) swig_result = fresult end function @@ -450,9 +450,9 @@ function FLSRKStepSetDomEigFrequency(arkode_mem, nsteps) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), intent(in) :: nsteps -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_LONG) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_LONG) :: farg2 farg1 = arkode_mem farg2 = nsteps @@ -466,9 +466,9 @@ function FLSRKStepSetMaxNumStages(arkode_mem, stage_max_limit) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: stage_max_limit -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = stage_max_limit @@ -482,9 +482,9 @@ function FLSRKStepSetDomEigSafetyFactor(arkode_mem, dom_eig_safety) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: dom_eig_safety -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = dom_eig_safety @@ -498,9 +498,9 @@ function FLSRKStepSetNumSSPStages(arkode_mem, num_of_stages) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: num_of_stages -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = num_of_stages @@ -514,9 +514,9 @@ function FLSRKStepGetNumDomEigUpdates(arkode_mem, dom_eig_num_evals) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: dom_eig_num_evals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(dom_eig_num_evals(1)) @@ -530,9 +530,9 @@ function FLSRKStepGetMaxNumStages(arkode_mem, stage_max) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), dimension(*), target, intent(inout) :: stage_max -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(stage_max(1)) @@ -546,9 +546,9 @@ function FLSRKStepGetNumRHSinDQ(arkode_mem, nfedq) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nfedq -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nfedq(1)) diff --git a/src/arkode/fmod_int64/farkode_lsrkstep_mod.c b/src/arkode/fmod_int64/farkode_lsrkstep_mod.c index f2b5249d7c..91106e5814 100644 --- a/src/arkode/fmod_int64/farkode_lsrkstep_mod.c +++ b/src/arkode/fmod_int64/farkode_lsrkstep_mod.c @@ -207,15 +207,15 @@ enum { * the fortran.cxx file. */ #define SWIG_contract_assert(RETURNNULL, EXPR, MSG) \ - if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); } + if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); } -#define SWIGVERSION 0x040000 +#define SWIGVERSION 0x040000 #define SWIG_VERSION SWIGVERSION -#define SWIG_as_voidptr(a) (void *)((const void *)(a)) -#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) +#define SWIG_as_voidptr(a) (void *)((const void *)(a)) +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) #include "arkode/arkode_lsrkstep.h" @@ -266,7 +266,7 @@ SWIGEXPORT void * _wrap_FLSRKStepCreateSTS(ARKRhsFn farg1, double const *farg2, N_Vector arg3 = (N_Vector) 0 ; SUNContext arg4 = (SUNContext) 0 ; void *result = 0 ; - + arg1 = (ARKRhsFn)(farg1); arg2 = (sunrealtype)(*farg2); arg3 = (N_Vector)(farg3); @@ -284,7 +284,7 @@ SWIGEXPORT void * _wrap_FLSRKStepCreateSSP(ARKRhsFn farg1, double const *farg2, N_Vector arg3 = (N_Vector) 0 ; SUNContext arg4 = (SUNContext) 0 ; void *result = 0 ; - + arg1 = (ARKRhsFn)(farg1); arg2 = (sunrealtype)(*farg2); arg3 = (N_Vector)(farg3); @@ -302,7 +302,7 @@ SWIGEXPORT int _wrap_FLSRKStepReInitSTS(void *farg1, ARKRhsFn farg2, double cons sunrealtype arg3 ; N_Vector arg4 = (N_Vector) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (ARKRhsFn)(farg2); arg3 = (sunrealtype)(*farg3); @@ -320,7 +320,7 @@ SWIGEXPORT int _wrap_FLSRKStepReInitSSP(void *farg1, ARKRhsFn farg2, double cons sunrealtype arg3 ; N_Vector arg4 = (N_Vector) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (ARKRhsFn)(farg2); arg3 = (sunrealtype)(*farg3); @@ -336,7 +336,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetSTSMethod(void *farg1, int const *farg2) { void *arg1 = (void *) 0 ; ARKODE_LSRKMethodType arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (ARKODE_LSRKMethodType)(*farg2); result = (int)LSRKStepSetSTSMethod(arg1,arg2); @@ -350,7 +350,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetSSPMethod(void *farg1, int const *farg2) { void *arg1 = (void *) 0 ; ARKODE_LSRKMethodType arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (ARKODE_LSRKMethodType)(*farg2); result = (int)LSRKStepSetSSPMethod(arg1,arg2); @@ -364,7 +364,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetSTSMethodByName(void *farg1, SwigArrayWrapper * void *arg1 = (void *) 0 ; char *arg2 = (char *) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (char *)(farg2->data); result = (int)LSRKStepSetSTSMethodByName(arg1,(char const *)arg2); @@ -378,7 +378,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetSSPMethodByName(void *farg1, SwigArrayWrapper * void *arg1 = (void *) 0 ; char *arg2 = (char *) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (char *)(farg2->data); result = (int)LSRKStepSetSSPMethodByName(arg1,(char const *)arg2); @@ -392,7 +392,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetDomEigFn(void *farg1, ARKDomEigFn farg2) { void *arg1 = (void *) 0 ; ARKDomEigFn arg2 = (ARKDomEigFn) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (ARKDomEigFn)(farg2); result = (int)LSRKStepSetDomEigFn(arg1,arg2); @@ -401,16 +401,16 @@ SWIGEXPORT int _wrap_FLSRKStepSetDomEigFn(void *farg1, ARKDomEigFn farg2) { } -SWIGEXPORT int _wrap_FLSRKStepSetDEECreateWithID(void *farg1, SwigClassWrapper const *farg2) { +SWIGEXPORT int _wrap_FLSRKStepDomEigEstCreateWithID(void *farg1, SwigClassWrapper const *farg2) { int fresult ; void *arg1 = (void *) 0 ; SUNDomEigEstimator_ID arg2 ; int result; - + arg1 = (void *)(farg1); - SWIG_check_nonnull(*farg2, "SUNDomEigEstimator_ID", "SWIGTYPE_p_SUNDomEigEstimator_ID", "LSRKStepSetDEECreateWithID(void *,SUNDomEigEstimator_ID)", return 0); + SWIG_check_nonnull(*farg2, "SUNDomEigEstimator_ID", "SWIGTYPE_p_SUNDomEigEstimator_ID", "LSRKStepDomEigEstCreateWithID(void *,SUNDomEigEstimator_ID)", return 0); arg2 = *(SUNDomEigEstimator_ID *)(farg2->cptr); - result = (int)LSRKStepSetDEECreateWithID(arg1,arg2); + result = (int)LSRKStepDomEigEstCreateWithID(arg1,arg2); fresult = (int)(result); return fresult; } @@ -421,7 +421,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetDomEigFrequency(void *farg1, long const *farg2) void *arg1 = (void *) 0 ; long arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (long)(*farg2); result = (int)LSRKStepSetDomEigFrequency(arg1,arg2); @@ -435,7 +435,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetMaxNumStages(void *farg1, int const *farg2) { void *arg1 = (void *) 0 ; int arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (int)(*farg2); result = (int)LSRKStepSetMaxNumStages(arg1,arg2); @@ -449,7 +449,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetDomEigSafetyFactor(void *farg1, double const *f void *arg1 = (void *) 0 ; sunrealtype arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (sunrealtype)(*farg2); result = (int)LSRKStepSetDomEigSafetyFactor(arg1,arg2); @@ -463,7 +463,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetNumSSPStages(void *farg1, int const *farg2) { void *arg1 = (void *) 0 ; int arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (int)(*farg2); result = (int)LSRKStepSetNumSSPStages(arg1,arg2); @@ -477,7 +477,7 @@ SWIGEXPORT int _wrap_FLSRKStepGetNumDomEigUpdates(void *farg1, long *farg2) { void *arg1 = (void *) 0 ; long *arg2 = (long *) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (long *)(farg2); result = (int)LSRKStepGetNumDomEigUpdates(arg1,arg2); @@ -491,7 +491,7 @@ SWIGEXPORT int _wrap_FLSRKStepGetMaxNumStages(void *farg1, int *farg2) { void *arg1 = (void *) 0 ; int *arg2 = (int *) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (int *)(farg2); result = (int)LSRKStepGetMaxNumStages(arg1,arg2); @@ -505,7 +505,7 @@ SWIGEXPORT int _wrap_FLSRKStepGetNumRHSinDQ(void *farg1, long *farg2) { void *arg1 = (void *) 0 ; long *arg2 = (long *) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (long *)(farg2); result = (int)LSRKStepGetNumRHSinDQ(arg1,arg2); diff --git a/src/arkode/fmod_int64/farkode_lsrkstep_mod.f90 b/src/arkode/fmod_int64/farkode_lsrkstep_mod.f90 index e9359f4c7b..2024d65d94 100644 --- a/src/arkode/fmod_int64/farkode_lsrkstep_mod.f90 +++ b/src/arkode/fmod_int64/farkode_lsrkstep_mod.f90 @@ -60,7 +60,7 @@ module farkode_lsrkstep_mod type, public :: SWIGTYPE_p_SUNDomEigEstimator_ID type(SwigClassWrapper), public :: swigdata end type - public :: FLSRKStepSetDEECreateWithID + public :: FLSRKStepDomEigEstCreateWithID public :: FLSRKStepSetDomEigFrequency public :: FLSRKStepSetMaxNumStages public :: FLSRKStepSetDomEigSafetyFactor @@ -162,8 +162,8 @@ function swigc_FLSRKStepSetDomEigFn(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FLSRKStepSetDEECreateWithID(farg1, farg2) & -bind(C, name="_wrap_FLSRKStepSetDEECreateWithID") & +function swigc_FLSRKStepDomEigEstCreateWithID(farg1, farg2) & +bind(C, name="_wrap_FLSRKStepDomEigEstCreateWithID") & result(fresult) use, intrinsic :: ISO_C_BINDING import :: swigclasswrapper @@ -248,11 +248,11 @@ function FLSRKStepCreateSTS(rhs, t0, y0, sunctx) & real(C_DOUBLE), intent(in) :: t0 type(N_Vector), target, intent(inout) :: y0 type(C_PTR) :: sunctx -type(C_PTR) :: fresult -type(C_FUNPTR) :: farg1 -real(C_DOUBLE) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 +type(C_PTR) :: fresult +type(C_FUNPTR) :: farg1 +real(C_DOUBLE) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 farg1 = rhs farg2 = t0 @@ -270,11 +270,11 @@ function FLSRKStepCreateSSP(rhs, t0, y0, sunctx) & real(C_DOUBLE), intent(in) :: t0 type(N_Vector), target, intent(inout) :: y0 type(C_PTR) :: sunctx -type(C_PTR) :: fresult -type(C_FUNPTR) :: farg1 -real(C_DOUBLE) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 +type(C_PTR) :: fresult +type(C_FUNPTR) :: farg1 +real(C_DOUBLE) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 farg1 = rhs farg2 = t0 @@ -292,11 +292,11 @@ function FLSRKStepReInitSTS(arkode_mem, rhs, t0, y0) & type(C_FUNPTR), intent(in), value :: rhs real(C_DOUBLE), intent(in) :: t0 type(N_Vector), target, intent(inout) :: y0 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -real(C_DOUBLE) :: farg3 -type(C_PTR) :: farg4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +real(C_DOUBLE) :: farg3 +type(C_PTR) :: farg4 farg1 = arkode_mem farg2 = rhs @@ -314,11 +314,11 @@ function FLSRKStepReInitSSP(arkode_mem, rhs, t0, y0) & type(C_FUNPTR), intent(in), value :: rhs real(C_DOUBLE), intent(in) :: t0 type(N_Vector), target, intent(inout) :: y0 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -real(C_DOUBLE) :: farg3 -type(C_PTR) :: farg4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +real(C_DOUBLE) :: farg3 +type(C_PTR) :: farg4 farg1 = arkode_mem farg2 = rhs @@ -334,9 +334,9 @@ function FLSRKStepSetSTSMethod(arkode_mem, method) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(ARKODE_LSRKMethodType), intent(in) :: method -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = method @@ -350,9 +350,9 @@ function FLSRKStepSetSSPMethod(arkode_mem, method) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(ARKODE_LSRKMethodType), intent(in) :: method -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = method @@ -385,9 +385,9 @@ function FLSRKStepSetSTSMethodByName(arkode_mem, emethod) & type(C_PTR) :: arkode_mem character(kind=C_CHAR, len=*), target :: emethod character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 farg1 = arkode_mem call SWIG_string_to_chararray(emethod, farg2_chars, farg2) @@ -402,9 +402,9 @@ function FLSRKStepSetSSPMethodByName(arkode_mem, emethod) & type(C_PTR) :: arkode_mem character(kind=C_CHAR, len=*), target :: emethod character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 farg1 = arkode_mem call SWIG_string_to_chararray(emethod, farg2_chars, farg2) @@ -418,9 +418,9 @@ function FLSRKStepSetDomEigFn(arkode_mem, dom_eig) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: dom_eig -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = dom_eig @@ -428,19 +428,19 @@ function FLSRKStepSetDomEigFn(arkode_mem, dom_eig) & swig_result = fresult end function -function FLSRKStepSetDEECreateWithID(arkode_mem, dee_id) & +function FLSRKStepDomEigEstCreateWithID(arkode_mem, dee_id) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(SWIGTYPE_p_SUNDomEigEstimator_ID), intent(in) :: dee_id -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigClassWrapper) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigClassWrapper) :: farg2 farg1 = arkode_mem farg2 = dee_id%swigdata -fresult = swigc_FLSRKStepSetDEECreateWithID(farg1, farg2) +fresult = swigc_FLSRKStepDomEigEstCreateWithID(farg1, farg2) swig_result = fresult end function @@ -450,9 +450,9 @@ function FLSRKStepSetDomEigFrequency(arkode_mem, nsteps) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), intent(in) :: nsteps -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_LONG) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_LONG) :: farg2 farg1 = arkode_mem farg2 = nsteps @@ -466,9 +466,9 @@ function FLSRKStepSetMaxNumStages(arkode_mem, stage_max_limit) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: stage_max_limit -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = stage_max_limit @@ -482,9 +482,9 @@ function FLSRKStepSetDomEigSafetyFactor(arkode_mem, dom_eig_safety) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: dom_eig_safety -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = dom_eig_safety @@ -498,9 +498,9 @@ function FLSRKStepSetNumSSPStages(arkode_mem, num_of_stages) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: num_of_stages -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = num_of_stages @@ -514,9 +514,9 @@ function FLSRKStepGetNumDomEigUpdates(arkode_mem, dom_eig_num_evals) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: dom_eig_num_evals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(dom_eig_num_evals(1)) @@ -530,9 +530,9 @@ function FLSRKStepGetMaxNumStages(arkode_mem, stage_max) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), dimension(*), target, intent(inout) :: stage_max -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(stage_max(1)) @@ -546,9 +546,9 @@ function FLSRKStepGetNumRHSinDQ(arkode_mem, nfedq) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nfedq -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nfedq(1)) diff --git a/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c b/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c index b28d2c9ab0..60cce14152 100644 --- a/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c +++ b/test/unit_tests/sundomeigest/arni/test_sundomeigest_arni.c @@ -137,6 +137,7 @@ int main(int argc, char* argv[]) max_powiter = krydim; fails += Test_SUNDomEigEstSetMaxPowerIter(DEE, max_powiter, 0); fails += Test_SUNDomEigEstSetNumPreProcess(DEE, numwarmups, 0); + fails += Test_SUNDomEigEstSetTol(DEE, rel_tol, 0); fails += Test_SUNDomEigEstInitialize(DEE, 0); fails += Test_SUNDomEigEstPreProcess(DEE, 0); fails += Test_SUNDomEigEstComputeHess(DEE, 0); diff --git a/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c b/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c index 0ac164d6fc..a09b114fea 100644 --- a/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c +++ b/test/unit_tests/sundomeigest/pi/test_sundomeigest_pi.c @@ -133,6 +133,7 @@ int main(int argc, char* argv[]) fails += Test_SUNDomEigEstSetATimes(DEE, &ProbData, ATimes, 0); fails += Test_SUNDomEigEstSetMaxPowerIter(DEE, max_powiter, 0); fails += Test_SUNDomEigEstSetNumPreProcess(DEE, numwarmups, 0); + fails += Test_SUNDomEigEstSetTol(DEE, rel_tol, 0); fails += Test_SUNDomEigEstInitialize(DEE, 0); fails += Test_SUNDomEigEstPreProcess(DEE, 0); // Test_SUNDomEigEstComputeHess is not an option for power iteration. diff --git a/test/unit_tests/sundomeigest/test_sundomeigest.c b/test/unit_tests/sundomeigest/test_sundomeigest.c index d8e6cb85b1..7800413412 100644 --- a/test/unit_tests/sundomeigest/test_sundomeigest.c +++ b/test/unit_tests/sundomeigest/test_sundomeigest.c @@ -160,6 +160,38 @@ int Test_SUNDomEigEstSetNumPreProcess(SUNDomEigEstimator DEE, int numwarmups, return (0); } +/* ---------------------------------------------------------------------- + * SUNDomEigEstSetTol Test + * --------------------------------------------------------------------*/ +int Test_SUNDomEigEstSetTol(SUNDomEigEstimator DEE, int tol, int myid) +{ + int failure; + double start_time, stop_time; + + /* try calling SUNDomEigEstSetTol routine: should pass/fail based on expected input */ + start_time = get_time(); + failure = SUNDomEigEstSetTol(DEE, tol); + // sync_device(); + stop_time = get_time(); + + if (failure) + { + printf(">>> FAILED test -- SUNDomEigEstSetTol check, Proc %d \n", + myid); + PRINT_TIME(" SUNDomEigEstSetTol Time: %22.15e \n \n", + stop_time - start_time); + return (1); + } + else if (myid == 0) + { + printf(" PASSED test -- SUNDomEigEstSetTol \n"); + PRINT_TIME(" SUNDomEigEstSetTol Time: %22.15e \n \n", + stop_time - start_time); + } + + return (0); +} + /* ---------------------------------------------------------------------- * SUNDomEigEstInitialize Test * --------------------------------------------------------------------*/ diff --git a/test/unit_tests/sundomeigest/test_sundomeigest.h b/test/unit_tests/sundomeigest/test_sundomeigest.h index b27bd7bd7d..43762497f2 100644 --- a/test/unit_tests/sundomeigest/test_sundomeigest.h +++ b/test/unit_tests/sundomeigest/test_sundomeigest.h @@ -38,6 +38,7 @@ int Test_SUNDomEigEstSetMaxPowerIter(SUNDomEigEstimator DEE, sunindextype max_powiter, int myid); int Test_SUNDomEigEstSetNumPreProcess(SUNDomEigEstimator DEE, int numwarmups, int myid); +int Test_SUNDomEigEstSetTol(SUNDomEigEstimator DEE, int tol, int myid); int Test_SUNDomEigEstInitialize(SUNDomEigEstimator DEE, int myid); int Test_SUNDomEigEstPreProcess(SUNDomEigEstimator DEE, int myid); int Test_SUNDomEigEstComputeHess(SUNDomEigEstimator DEE, int myid); From a0f6ffdddcfb0b143060d2481ae7352bd531a8cb Mon Sep 17 00:00:00 2001 From: maggul Date: Mon, 23 Jun 2025 17:40:19 -0500 Subject: [PATCH 064/128] swig --- src/arkode/arkode_lsrkstep_io.c | 2 +- src/arkode/fmod_int32/farkode_lsrkstep_mod.c | 42 +++---- .../fmod_int32/farkode_lsrkstep_mod.f90 | 118 +++++++++--------- src/arkode/fmod_int64/farkode_lsrkstep_mod.c | 42 +++---- .../fmod_int64/farkode_lsrkstep_mod.f90 | 118 +++++++++--------- 5 files changed, 161 insertions(+), 161 deletions(-) diff --git a/src/arkode/arkode_lsrkstep_io.c b/src/arkode/arkode_lsrkstep_io.c index 31a7dc54bd..75e533002c 100644 --- a/src/arkode/arkode_lsrkstep_io.c +++ b/src/arkode/arkode_lsrkstep_io.c @@ -723,7 +723,7 @@ int lsrkStep_WriteParameters(ARKodeMem ark_mem, FILE* fp) case SUNFALSE: fprintf(fp, " Maximum number of stages allowed = %i\n", step_mem->stage_max_limit); - fprintf(fp, " Number of fe calls for DEE = %i\n", + fprintf(fp, " Number of fe calls for DEE = %li\n", step_mem->nfeDQ); fprintf(fp, " Krylov subspace dimension in DEE = %i\n", step_mem->dee_krydim); diff --git a/src/arkode/fmod_int32/farkode_lsrkstep_mod.c b/src/arkode/fmod_int32/farkode_lsrkstep_mod.c index 91106e5814..5e0c484d3c 100644 --- a/src/arkode/fmod_int32/farkode_lsrkstep_mod.c +++ b/src/arkode/fmod_int32/farkode_lsrkstep_mod.c @@ -207,15 +207,15 @@ enum { * the fortran.cxx file. */ #define SWIG_contract_assert(RETURNNULL, EXPR, MSG) \ - if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); } + if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); } -#define SWIGVERSION 0x040000 +#define SWIGVERSION 0x040000 #define SWIG_VERSION SWIGVERSION -#define SWIG_as_voidptr(a) (void *)((const void *)(a)) -#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) +#define SWIG_as_voidptr(a) (void *)((const void *)(a)) +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) #include "arkode/arkode_lsrkstep.h" @@ -266,7 +266,7 @@ SWIGEXPORT void * _wrap_FLSRKStepCreateSTS(ARKRhsFn farg1, double const *farg2, N_Vector arg3 = (N_Vector) 0 ; SUNContext arg4 = (SUNContext) 0 ; void *result = 0 ; - + arg1 = (ARKRhsFn)(farg1); arg2 = (sunrealtype)(*farg2); arg3 = (N_Vector)(farg3); @@ -284,7 +284,7 @@ SWIGEXPORT void * _wrap_FLSRKStepCreateSSP(ARKRhsFn farg1, double const *farg2, N_Vector arg3 = (N_Vector) 0 ; SUNContext arg4 = (SUNContext) 0 ; void *result = 0 ; - + arg1 = (ARKRhsFn)(farg1); arg2 = (sunrealtype)(*farg2); arg3 = (N_Vector)(farg3); @@ -302,7 +302,7 @@ SWIGEXPORT int _wrap_FLSRKStepReInitSTS(void *farg1, ARKRhsFn farg2, double cons sunrealtype arg3 ; N_Vector arg4 = (N_Vector) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (ARKRhsFn)(farg2); arg3 = (sunrealtype)(*farg3); @@ -320,7 +320,7 @@ SWIGEXPORT int _wrap_FLSRKStepReInitSSP(void *farg1, ARKRhsFn farg2, double cons sunrealtype arg3 ; N_Vector arg4 = (N_Vector) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (ARKRhsFn)(farg2); arg3 = (sunrealtype)(*farg3); @@ -336,7 +336,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetSTSMethod(void *farg1, int const *farg2) { void *arg1 = (void *) 0 ; ARKODE_LSRKMethodType arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (ARKODE_LSRKMethodType)(*farg2); result = (int)LSRKStepSetSTSMethod(arg1,arg2); @@ -350,7 +350,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetSSPMethod(void *farg1, int const *farg2) { void *arg1 = (void *) 0 ; ARKODE_LSRKMethodType arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (ARKODE_LSRKMethodType)(*farg2); result = (int)LSRKStepSetSSPMethod(arg1,arg2); @@ -364,7 +364,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetSTSMethodByName(void *farg1, SwigArrayWrapper * void *arg1 = (void *) 0 ; char *arg2 = (char *) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (char *)(farg2->data); result = (int)LSRKStepSetSTSMethodByName(arg1,(char const *)arg2); @@ -378,7 +378,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetSSPMethodByName(void *farg1, SwigArrayWrapper * void *arg1 = (void *) 0 ; char *arg2 = (char *) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (char *)(farg2->data); result = (int)LSRKStepSetSSPMethodByName(arg1,(char const *)arg2); @@ -392,7 +392,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetDomEigFn(void *farg1, ARKDomEigFn farg2) { void *arg1 = (void *) 0 ; ARKDomEigFn arg2 = (ARKDomEigFn) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (ARKDomEigFn)(farg2); result = (int)LSRKStepSetDomEigFn(arg1,arg2); @@ -406,7 +406,7 @@ SWIGEXPORT int _wrap_FLSRKStepDomEigEstCreateWithID(void *farg1, SwigClassWrappe void *arg1 = (void *) 0 ; SUNDomEigEstimator_ID arg2 ; int result; - + arg1 = (void *)(farg1); SWIG_check_nonnull(*farg2, "SUNDomEigEstimator_ID", "SWIGTYPE_p_SUNDomEigEstimator_ID", "LSRKStepDomEigEstCreateWithID(void *,SUNDomEigEstimator_ID)", return 0); arg2 = *(SUNDomEigEstimator_ID *)(farg2->cptr); @@ -421,7 +421,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetDomEigFrequency(void *farg1, long const *farg2) void *arg1 = (void *) 0 ; long arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (long)(*farg2); result = (int)LSRKStepSetDomEigFrequency(arg1,arg2); @@ -435,7 +435,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetMaxNumStages(void *farg1, int const *farg2) { void *arg1 = (void *) 0 ; int arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (int)(*farg2); result = (int)LSRKStepSetMaxNumStages(arg1,arg2); @@ -449,7 +449,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetDomEigSafetyFactor(void *farg1, double const *f void *arg1 = (void *) 0 ; sunrealtype arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (sunrealtype)(*farg2); result = (int)LSRKStepSetDomEigSafetyFactor(arg1,arg2); @@ -463,7 +463,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetNumSSPStages(void *farg1, int const *farg2) { void *arg1 = (void *) 0 ; int arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (int)(*farg2); result = (int)LSRKStepSetNumSSPStages(arg1,arg2); @@ -477,7 +477,7 @@ SWIGEXPORT int _wrap_FLSRKStepGetNumDomEigUpdates(void *farg1, long *farg2) { void *arg1 = (void *) 0 ; long *arg2 = (long *) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (long *)(farg2); result = (int)LSRKStepGetNumDomEigUpdates(arg1,arg2); @@ -491,7 +491,7 @@ SWIGEXPORT int _wrap_FLSRKStepGetMaxNumStages(void *farg1, int *farg2) { void *arg1 = (void *) 0 ; int *arg2 = (int *) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (int *)(farg2); result = (int)LSRKStepGetMaxNumStages(arg1,arg2); @@ -505,7 +505,7 @@ SWIGEXPORT int _wrap_FLSRKStepGetNumRHSinDQ(void *farg1, long *farg2) { void *arg1 = (void *) 0 ; long *arg2 = (long *) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (long *)(farg2); result = (int)LSRKStepGetNumRHSinDQ(arg1,arg2); diff --git a/src/arkode/fmod_int32/farkode_lsrkstep_mod.f90 b/src/arkode/fmod_int32/farkode_lsrkstep_mod.f90 index 2024d65d94..424381cf1e 100644 --- a/src/arkode/fmod_int32/farkode_lsrkstep_mod.f90 +++ b/src/arkode/fmod_int32/farkode_lsrkstep_mod.f90 @@ -248,11 +248,11 @@ function FLSRKStepCreateSTS(rhs, t0, y0, sunctx) & real(C_DOUBLE), intent(in) :: t0 type(N_Vector), target, intent(inout) :: y0 type(C_PTR) :: sunctx -type(C_PTR) :: fresult -type(C_FUNPTR) :: farg1 -real(C_DOUBLE) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 +type(C_PTR) :: fresult +type(C_FUNPTR) :: farg1 +real(C_DOUBLE) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 farg1 = rhs farg2 = t0 @@ -270,11 +270,11 @@ function FLSRKStepCreateSSP(rhs, t0, y0, sunctx) & real(C_DOUBLE), intent(in) :: t0 type(N_Vector), target, intent(inout) :: y0 type(C_PTR) :: sunctx -type(C_PTR) :: fresult -type(C_FUNPTR) :: farg1 -real(C_DOUBLE) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 +type(C_PTR) :: fresult +type(C_FUNPTR) :: farg1 +real(C_DOUBLE) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 farg1 = rhs farg2 = t0 @@ -292,11 +292,11 @@ function FLSRKStepReInitSTS(arkode_mem, rhs, t0, y0) & type(C_FUNPTR), intent(in), value :: rhs real(C_DOUBLE), intent(in) :: t0 type(N_Vector), target, intent(inout) :: y0 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -real(C_DOUBLE) :: farg3 -type(C_PTR) :: farg4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +real(C_DOUBLE) :: farg3 +type(C_PTR) :: farg4 farg1 = arkode_mem farg2 = rhs @@ -314,11 +314,11 @@ function FLSRKStepReInitSSP(arkode_mem, rhs, t0, y0) & type(C_FUNPTR), intent(in), value :: rhs real(C_DOUBLE), intent(in) :: t0 type(N_Vector), target, intent(inout) :: y0 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -real(C_DOUBLE) :: farg3 -type(C_PTR) :: farg4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +real(C_DOUBLE) :: farg3 +type(C_PTR) :: farg4 farg1 = arkode_mem farg2 = rhs @@ -334,9 +334,9 @@ function FLSRKStepSetSTSMethod(arkode_mem, method) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(ARKODE_LSRKMethodType), intent(in) :: method -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = method @@ -350,9 +350,9 @@ function FLSRKStepSetSSPMethod(arkode_mem, method) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(ARKODE_LSRKMethodType), intent(in) :: method -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = method @@ -385,9 +385,9 @@ function FLSRKStepSetSTSMethodByName(arkode_mem, emethod) & type(C_PTR) :: arkode_mem character(kind=C_CHAR, len=*), target :: emethod character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 farg1 = arkode_mem call SWIG_string_to_chararray(emethod, farg2_chars, farg2) @@ -402,9 +402,9 @@ function FLSRKStepSetSSPMethodByName(arkode_mem, emethod) & type(C_PTR) :: arkode_mem character(kind=C_CHAR, len=*), target :: emethod character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 farg1 = arkode_mem call SWIG_string_to_chararray(emethod, farg2_chars, farg2) @@ -418,9 +418,9 @@ function FLSRKStepSetDomEigFn(arkode_mem, dom_eig) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: dom_eig -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = dom_eig @@ -434,9 +434,9 @@ function FLSRKStepDomEigEstCreateWithID(arkode_mem, dee_id) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(SWIGTYPE_p_SUNDomEigEstimator_ID), intent(in) :: dee_id -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigClassWrapper) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigClassWrapper) :: farg2 farg1 = arkode_mem farg2 = dee_id%swigdata @@ -450,9 +450,9 @@ function FLSRKStepSetDomEigFrequency(arkode_mem, nsteps) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), intent(in) :: nsteps -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_LONG) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_LONG) :: farg2 farg1 = arkode_mem farg2 = nsteps @@ -466,9 +466,9 @@ function FLSRKStepSetMaxNumStages(arkode_mem, stage_max_limit) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: stage_max_limit -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = stage_max_limit @@ -482,9 +482,9 @@ function FLSRKStepSetDomEigSafetyFactor(arkode_mem, dom_eig_safety) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: dom_eig_safety -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = dom_eig_safety @@ -498,9 +498,9 @@ function FLSRKStepSetNumSSPStages(arkode_mem, num_of_stages) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: num_of_stages -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = num_of_stages @@ -514,9 +514,9 @@ function FLSRKStepGetNumDomEigUpdates(arkode_mem, dom_eig_num_evals) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: dom_eig_num_evals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(dom_eig_num_evals(1)) @@ -530,9 +530,9 @@ function FLSRKStepGetMaxNumStages(arkode_mem, stage_max) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), dimension(*), target, intent(inout) :: stage_max -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(stage_max(1)) @@ -546,9 +546,9 @@ function FLSRKStepGetNumRHSinDQ(arkode_mem, nfedq) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nfedq -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nfedq(1)) diff --git a/src/arkode/fmod_int64/farkode_lsrkstep_mod.c b/src/arkode/fmod_int64/farkode_lsrkstep_mod.c index 91106e5814..5e0c484d3c 100644 --- a/src/arkode/fmod_int64/farkode_lsrkstep_mod.c +++ b/src/arkode/fmod_int64/farkode_lsrkstep_mod.c @@ -207,15 +207,15 @@ enum { * the fortran.cxx file. */ #define SWIG_contract_assert(RETURNNULL, EXPR, MSG) \ - if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); } + if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); } -#define SWIGVERSION 0x040000 +#define SWIGVERSION 0x040000 #define SWIG_VERSION SWIGVERSION -#define SWIG_as_voidptr(a) (void *)((const void *)(a)) -#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) +#define SWIG_as_voidptr(a) (void *)((const void *)(a)) +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) #include "arkode/arkode_lsrkstep.h" @@ -266,7 +266,7 @@ SWIGEXPORT void * _wrap_FLSRKStepCreateSTS(ARKRhsFn farg1, double const *farg2, N_Vector arg3 = (N_Vector) 0 ; SUNContext arg4 = (SUNContext) 0 ; void *result = 0 ; - + arg1 = (ARKRhsFn)(farg1); arg2 = (sunrealtype)(*farg2); arg3 = (N_Vector)(farg3); @@ -284,7 +284,7 @@ SWIGEXPORT void * _wrap_FLSRKStepCreateSSP(ARKRhsFn farg1, double const *farg2, N_Vector arg3 = (N_Vector) 0 ; SUNContext arg4 = (SUNContext) 0 ; void *result = 0 ; - + arg1 = (ARKRhsFn)(farg1); arg2 = (sunrealtype)(*farg2); arg3 = (N_Vector)(farg3); @@ -302,7 +302,7 @@ SWIGEXPORT int _wrap_FLSRKStepReInitSTS(void *farg1, ARKRhsFn farg2, double cons sunrealtype arg3 ; N_Vector arg4 = (N_Vector) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (ARKRhsFn)(farg2); arg3 = (sunrealtype)(*farg3); @@ -320,7 +320,7 @@ SWIGEXPORT int _wrap_FLSRKStepReInitSSP(void *farg1, ARKRhsFn farg2, double cons sunrealtype arg3 ; N_Vector arg4 = (N_Vector) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (ARKRhsFn)(farg2); arg3 = (sunrealtype)(*farg3); @@ -336,7 +336,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetSTSMethod(void *farg1, int const *farg2) { void *arg1 = (void *) 0 ; ARKODE_LSRKMethodType arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (ARKODE_LSRKMethodType)(*farg2); result = (int)LSRKStepSetSTSMethod(arg1,arg2); @@ -350,7 +350,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetSSPMethod(void *farg1, int const *farg2) { void *arg1 = (void *) 0 ; ARKODE_LSRKMethodType arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (ARKODE_LSRKMethodType)(*farg2); result = (int)LSRKStepSetSSPMethod(arg1,arg2); @@ -364,7 +364,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetSTSMethodByName(void *farg1, SwigArrayWrapper * void *arg1 = (void *) 0 ; char *arg2 = (char *) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (char *)(farg2->data); result = (int)LSRKStepSetSTSMethodByName(arg1,(char const *)arg2); @@ -378,7 +378,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetSSPMethodByName(void *farg1, SwigArrayWrapper * void *arg1 = (void *) 0 ; char *arg2 = (char *) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (char *)(farg2->data); result = (int)LSRKStepSetSSPMethodByName(arg1,(char const *)arg2); @@ -392,7 +392,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetDomEigFn(void *farg1, ARKDomEigFn farg2) { void *arg1 = (void *) 0 ; ARKDomEigFn arg2 = (ARKDomEigFn) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (ARKDomEigFn)(farg2); result = (int)LSRKStepSetDomEigFn(arg1,arg2); @@ -406,7 +406,7 @@ SWIGEXPORT int _wrap_FLSRKStepDomEigEstCreateWithID(void *farg1, SwigClassWrappe void *arg1 = (void *) 0 ; SUNDomEigEstimator_ID arg2 ; int result; - + arg1 = (void *)(farg1); SWIG_check_nonnull(*farg2, "SUNDomEigEstimator_ID", "SWIGTYPE_p_SUNDomEigEstimator_ID", "LSRKStepDomEigEstCreateWithID(void *,SUNDomEigEstimator_ID)", return 0); arg2 = *(SUNDomEigEstimator_ID *)(farg2->cptr); @@ -421,7 +421,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetDomEigFrequency(void *farg1, long const *farg2) void *arg1 = (void *) 0 ; long arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (long)(*farg2); result = (int)LSRKStepSetDomEigFrequency(arg1,arg2); @@ -435,7 +435,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetMaxNumStages(void *farg1, int const *farg2) { void *arg1 = (void *) 0 ; int arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (int)(*farg2); result = (int)LSRKStepSetMaxNumStages(arg1,arg2); @@ -449,7 +449,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetDomEigSafetyFactor(void *farg1, double const *f void *arg1 = (void *) 0 ; sunrealtype arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (sunrealtype)(*farg2); result = (int)LSRKStepSetDomEigSafetyFactor(arg1,arg2); @@ -463,7 +463,7 @@ SWIGEXPORT int _wrap_FLSRKStepSetNumSSPStages(void *farg1, int const *farg2) { void *arg1 = (void *) 0 ; int arg2 ; int result; - + arg1 = (void *)(farg1); arg2 = (int)(*farg2); result = (int)LSRKStepSetNumSSPStages(arg1,arg2); @@ -477,7 +477,7 @@ SWIGEXPORT int _wrap_FLSRKStepGetNumDomEigUpdates(void *farg1, long *farg2) { void *arg1 = (void *) 0 ; long *arg2 = (long *) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (long *)(farg2); result = (int)LSRKStepGetNumDomEigUpdates(arg1,arg2); @@ -491,7 +491,7 @@ SWIGEXPORT int _wrap_FLSRKStepGetMaxNumStages(void *farg1, int *farg2) { void *arg1 = (void *) 0 ; int *arg2 = (int *) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (int *)(farg2); result = (int)LSRKStepGetMaxNumStages(arg1,arg2); @@ -505,7 +505,7 @@ SWIGEXPORT int _wrap_FLSRKStepGetNumRHSinDQ(void *farg1, long *farg2) { void *arg1 = (void *) 0 ; long *arg2 = (long *) 0 ; int result; - + arg1 = (void *)(farg1); arg2 = (long *)(farg2); result = (int)LSRKStepGetNumRHSinDQ(arg1,arg2); diff --git a/src/arkode/fmod_int64/farkode_lsrkstep_mod.f90 b/src/arkode/fmod_int64/farkode_lsrkstep_mod.f90 index 2024d65d94..424381cf1e 100644 --- a/src/arkode/fmod_int64/farkode_lsrkstep_mod.f90 +++ b/src/arkode/fmod_int64/farkode_lsrkstep_mod.f90 @@ -248,11 +248,11 @@ function FLSRKStepCreateSTS(rhs, t0, y0, sunctx) & real(C_DOUBLE), intent(in) :: t0 type(N_Vector), target, intent(inout) :: y0 type(C_PTR) :: sunctx -type(C_PTR) :: fresult -type(C_FUNPTR) :: farg1 -real(C_DOUBLE) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 +type(C_PTR) :: fresult +type(C_FUNPTR) :: farg1 +real(C_DOUBLE) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 farg1 = rhs farg2 = t0 @@ -270,11 +270,11 @@ function FLSRKStepCreateSSP(rhs, t0, y0, sunctx) & real(C_DOUBLE), intent(in) :: t0 type(N_Vector), target, intent(inout) :: y0 type(C_PTR) :: sunctx -type(C_PTR) :: fresult -type(C_FUNPTR) :: farg1 -real(C_DOUBLE) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 +type(C_PTR) :: fresult +type(C_FUNPTR) :: farg1 +real(C_DOUBLE) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 farg1 = rhs farg2 = t0 @@ -292,11 +292,11 @@ function FLSRKStepReInitSTS(arkode_mem, rhs, t0, y0) & type(C_FUNPTR), intent(in), value :: rhs real(C_DOUBLE), intent(in) :: t0 type(N_Vector), target, intent(inout) :: y0 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -real(C_DOUBLE) :: farg3 -type(C_PTR) :: farg4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +real(C_DOUBLE) :: farg3 +type(C_PTR) :: farg4 farg1 = arkode_mem farg2 = rhs @@ -314,11 +314,11 @@ function FLSRKStepReInitSSP(arkode_mem, rhs, t0, y0) & type(C_FUNPTR), intent(in), value :: rhs real(C_DOUBLE), intent(in) :: t0 type(N_Vector), target, intent(inout) :: y0 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -real(C_DOUBLE) :: farg3 -type(C_PTR) :: farg4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +real(C_DOUBLE) :: farg3 +type(C_PTR) :: farg4 farg1 = arkode_mem farg2 = rhs @@ -334,9 +334,9 @@ function FLSRKStepSetSTSMethod(arkode_mem, method) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(ARKODE_LSRKMethodType), intent(in) :: method -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = method @@ -350,9 +350,9 @@ function FLSRKStepSetSSPMethod(arkode_mem, method) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(ARKODE_LSRKMethodType), intent(in) :: method -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = method @@ -385,9 +385,9 @@ function FLSRKStepSetSTSMethodByName(arkode_mem, emethod) & type(C_PTR) :: arkode_mem character(kind=C_CHAR, len=*), target :: emethod character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 farg1 = arkode_mem call SWIG_string_to_chararray(emethod, farg2_chars, farg2) @@ -402,9 +402,9 @@ function FLSRKStepSetSSPMethodByName(arkode_mem, emethod) & type(C_PTR) :: arkode_mem character(kind=C_CHAR, len=*), target :: emethod character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 farg1 = arkode_mem call SWIG_string_to_chararray(emethod, farg2_chars, farg2) @@ -418,9 +418,9 @@ function FLSRKStepSetDomEigFn(arkode_mem, dom_eig) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(C_FUNPTR), intent(in), value :: dom_eig -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 farg1 = arkode_mem farg2 = dom_eig @@ -434,9 +434,9 @@ function FLSRKStepDomEigEstCreateWithID(arkode_mem, dee_id) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem type(SWIGTYPE_p_SUNDomEigEstimator_ID), intent(in) :: dee_id -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigClassWrapper) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigClassWrapper) :: farg2 farg1 = arkode_mem farg2 = dee_id%swigdata @@ -450,9 +450,9 @@ function FLSRKStepSetDomEigFrequency(arkode_mem, nsteps) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), intent(in) :: nsteps -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_LONG) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_LONG) :: farg2 farg1 = arkode_mem farg2 = nsteps @@ -466,9 +466,9 @@ function FLSRKStepSetMaxNumStages(arkode_mem, stage_max_limit) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: stage_max_limit -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = stage_max_limit @@ -482,9 +482,9 @@ function FLSRKStepSetDomEigSafetyFactor(arkode_mem, dom_eig_safety) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem real(C_DOUBLE), intent(in) :: dom_eig_safety -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem farg2 = dom_eig_safety @@ -498,9 +498,9 @@ function FLSRKStepSetNumSSPStages(arkode_mem, num_of_stages) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), intent(in) :: num_of_stages -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 farg1 = arkode_mem farg2 = num_of_stages @@ -514,9 +514,9 @@ function FLSRKStepGetNumDomEigUpdates(arkode_mem, dom_eig_num_evals) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: dom_eig_num_evals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(dom_eig_num_evals(1)) @@ -530,9 +530,9 @@ function FLSRKStepGetMaxNumStages(arkode_mem, stage_max) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_INT), dimension(*), target, intent(inout) :: stage_max -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(stage_max(1)) @@ -546,9 +546,9 @@ function FLSRKStepGetNumRHSinDQ(arkode_mem, nfedq) & integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem integer(C_LONG), dimension(*), target, intent(inout) :: nfedq -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = arkode_mem farg2 = c_loc(nfedq(1)) From 0ade7f483fbdc3a33f120ab62ecdd75b5e822ed7 Mon Sep 17 00:00:00 2001 From: maggul Date: Mon, 23 Jun 2025 17:42:50 -0500 Subject: [PATCH 065/128] spelling --- doc/shared/sundomeigest/SUNDomEigEst_ARNI.rst | 2 +- doc/shared/sundomeigest/SUNDomEigEst_PI.rst | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/shared/sundomeigest/SUNDomEigEst_ARNI.rst b/doc/shared/sundomeigest/SUNDomEigEst_ARNI.rst index f7565c607b..47f87eba61 100644 --- a/doc/shared/sundomeigest/SUNDomEigEst_ARNI.rst +++ b/doc/shared/sundomeigest/SUNDomEigEst_ARNI.rst @@ -39,7 +39,7 @@ well-approximated by the dominant eigenvalue of :math:`H_m`. ArnI works for the matrices that have a **complex** dominant eigenvalue. It supports estimations with a user specified fixed dimension of Krylov subspaces, at least 3. While -these choice requires a prefixed amount of memory (depending on the dimension), it stricly +these choice requires a prefixed amount of memory (depending on the dimension), it strictly determines how good an estimation is. To improve the estimation accuracy, we found preprocessing with :c:func:`SUNDomEigEstPreProcess` particularly useful. This operation is free from any additional memory requirement and explained below. diff --git a/doc/shared/sundomeigest/SUNDomEigEst_PI.rst b/doc/shared/sundomeigest/SUNDomEigEst_PI.rst index 6a16444a7a..4846488977 100644 --- a/doc/shared/sundomeigest/SUNDomEigEst_PI.rst +++ b/doc/shared/sundomeigest/SUNDomEigEst_PI.rst @@ -41,8 +41,8 @@ can be approximated using the Rayleigh quotient \lambda_k = \frac{\mathbf{v}_k^T A \mathbf{v}_k}{\|\mathbf{v}_k\|^2}. -The iteration continues until the two succesive eigenvalues are relatively close -enough to one another. That is, for some reletive tolerance :math:`\tau`, +The iteration continues until the two successive eigenvalues are relatively close +enough to one another. That is, for some relative tolerance :math:`\tau`, .. math:: From f0263dbe69948dd03e15bde6f414db604bb54fe8 Mon Sep 17 00:00:00 2001 From: maggul Date: Mon, 23 Jun 2025 18:16:46 -0500 Subject: [PATCH 066/128] CI debug & formatting --- .../priv/sundials_domeigestimator_impl.h | 16 ++++++++-------- include/sundials/sundials_domeigestimator.h | 3 +-- include/sundomeigest/sundomeigest_pi.h | 3 +-- src/arkode/arkode_lsrkstep.c | 7 ++++--- src/arkode/arkode_lsrkstep_io.c | 11 ++++------- src/sundomeigest/ArnI/sundomeigest_arni.c | 14 ++++++++++---- test/unit_tests/sundomeigest/test_sundomeigest.c | 5 ++--- test/unit_tests/sundomeigest/test_sundomeigest.h | 2 +- 8 files changed, 31 insertions(+), 30 deletions(-) diff --git a/include/sundials/priv/sundials_domeigestimator_impl.h b/include/sundials/priv/sundials_domeigestimator_impl.h index 1cad719c7f..09db9ac175 100644 --- a/include/sundials/priv/sundials_domeigestimator_impl.h +++ b/include/sundials/priv/sundials_domeigestimator_impl.h @@ -36,15 +36,15 @@ int sundomeigest_Compare(const void* a, const void* b); * ----------------------------------------------------------------- */ #if defined(SUNDIALS_DOUBLE_PRECISION) || defined(SUNDIALS_EXTENDED_PRECISION) -extern void dgeev_(char* jobvl, char* jobvr, int32_t* n, sunrealtype* a, int32_t* lda, - sunrealtype* wr, sunrealtype* wi, sunrealtype* vl, int32_t* ldvl, - sunrealtype* vr, int32_t* ldvr, sunrealtype* work, int32_t* lwork, - int32_t* info); +extern void dgeev_(char* jobvl, char* jobvr, int32_t* n, sunrealtype* a, + int32_t* lda, sunrealtype* wr, sunrealtype* wi, + sunrealtype* vl, int32_t* ldvl, sunrealtype* vr, int32_t* ldvr, + sunrealtype* work, int32_t* lwork, int32_t* info); #elif defined(SUNDIALS_SINGLE_PRECISION) -extern void sgeev_(char* jobvl, char* jobvr, int32_t* n, sunrealtype* a, int32_t* lda, - sunrealtype* wr, sunrealtype* wi, sunrealtype* vl, int32_t* ldvl, - sunrealtype* vr, int32_t* ldvr, sunrealtype* work, int32_t* lwork, - int32_t* info); +extern void sgeev_(char* jobvl, char* jobvr, int32_t* n, sunrealtype* a, + int32_t* lda, sunrealtype* wr, sunrealtype* wi, + sunrealtype* vl, int32_t* ldvl, sunrealtype* vr, int32_t* ldvr, + sunrealtype* work, int32_t* lwork, int32_t* info); #endif #ifdef __cplusplus diff --git a/include/sundials/sundials_domeigestimator.h b/include/sundials/sundials_domeigestimator.h index 40ac624115..e559cab2bc 100644 --- a/include/sundials/sundials_domeigestimator.h +++ b/include/sundials/sundials_domeigestimator.h @@ -98,8 +98,7 @@ SUNErrCode SUNDomEigEstSetATimes(SUNDomEigEstimator DEE, void* A_data, SUNATimesFn ATimes); SUNDIALS_EXPORT -SUNErrCode SUNDomEigEstSetMaxPowerIter(SUNDomEigEstimator DEE, - int max_powiter); +SUNErrCode SUNDomEigEstSetMaxPowerIter(SUNDomEigEstimator DEE, int max_powiter); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstSetNumPreProcess(SUNDomEigEstimator DEE, diff --git a/include/sundomeigest/sundomeigest_pi.h b/include/sundomeigest/sundomeigest_pi.h index 895e7086ab..70172a7693 100644 --- a/include/sundomeigest/sundomeigest_pi.h +++ b/include/sundomeigest/sundomeigest_pi.h @@ -44,7 +44,7 @@ struct _SUNDomEigEstimatorContent_PI N_Vector V, q; /* workspace vectors */ - int numwarmups; /* Power of A in the preprocessing; initial q = A^{numwarmups}q/||A^{numwarmups}q|| */ + int numwarmups; /* Power of A in the preprocessing; initial q = A^{numwarmups}q/||A^{numwarmups}q|| */ int max_powiter; /* Maximum number of power iterations */ int numiters; /* Current number of power iterations */ @@ -83,7 +83,6 @@ SUNErrCode SUNDomEigEstSetTol_PI(SUNDomEigEstimator DEE, sunrealtype tol); SUNDIALS_EXPORT SUNErrCode SUNDomEigEstInitialize_PI(SUNDomEigEstimator DEE); - SUNDIALS_EXPORT SUNErrCode SUNDomEigEstPreProcess_PI(SUNDomEigEstimator DEE); diff --git a/src/arkode/arkode_lsrkstep.c b/src/arkode/arkode_lsrkstep.c index 3cbbf3f7b1..4dcd516e0e 100644 --- a/src/arkode/arkode_lsrkstep.c +++ b/src/arkode/arkode_lsrkstep.c @@ -2081,7 +2081,7 @@ void lsrkStep_PrintMem(ARKodeMem ark_mem, FILE* outfile) fprintf(outfile, "LSRKStep: dom_eig_freq = %li\n", step_mem->dom_eig_freq); - if(step_mem->DEE != NULL) + if (step_mem->DEE != NULL) { fprintf(outfile, "LSRKStep: dee_krydim = %i\n", step_mem->dee_krydim); @@ -2092,9 +2092,10 @@ void lsrkStep_PrintMem(ARKodeMem ark_mem, FILE* outfile) } /* output long integer quantities */ fprintf(outfile, "LSRKStep: nfe = %li\n", step_mem->nfe); - if(step_mem->DEE != NULL) + if (step_mem->DEE != NULL) { - fprintf(outfile, "LSRKStep: nfeDQ = %li\n", step_mem->nfeDQ); + fprintf(outfile, "LSRKStep: nfeDQ = %li\n", + step_mem->nfeDQ); } fprintf(outfile, "LSRKStep: dom_eig_num_evals = %li\n", step_mem->dom_eig_num_evals); diff --git a/src/arkode/arkode_lsrkstep_io.c b/src/arkode/arkode_lsrkstep_io.c index 75e533002c..af4ce2fa6a 100644 --- a/src/arkode/arkode_lsrkstep_io.c +++ b/src/arkode/arkode_lsrkstep_io.c @@ -648,7 +648,7 @@ int lsrkStep_PrintAllStats(ARKodeMem ark_mem, FILE* outfile, SUNOutputFormat fmt { sunfprintf_long(outfile, fmt, SUNFALSE, "Number of dom_eig updates", step_mem->dom_eig_num_evals); - if(step_mem->DEE != NULL) + if (step_mem->DEE != NULL) { sunfprintf_long(outfile, fmt, SUNFALSE, "Number of fe calls for DEE", step_mem->nfeDQ); @@ -723,14 +723,11 @@ int lsrkStep_WriteParameters(ARKodeMem ark_mem, FILE* fp) case SUNFALSE: fprintf(fp, " Maximum number of stages allowed = %i\n", step_mem->stage_max_limit); - fprintf(fp, " Number of fe calls for DEE = %li\n", - step_mem->nfeDQ); + fprintf(fp, " Number of fe calls for DEE = %li\n", step_mem->nfeDQ); fprintf(fp, " Krylov subspace dimension in DEE = %i\n", step_mem->dee_krydim); - fprintf(fp, " Number of warmups in DEE = %i\n", - step_mem->dee_numwarmups); - fprintf(fp, " Max. num. of iters in DEE = %i\n", - step_mem->dee_maxiters); + fprintf(fp, " Number of warmups in DEE = %i\n", step_mem->dee_numwarmups); + fprintf(fp, " Max. num. of iters in DEE = %i\n", step_mem->dee_maxiters); fprintf(fp, " Current spectral radius = " SUN_FORMAT_G "\n", step_mem->spectral_radius); fprintf(fp, " Safety factor for the dom eig = " SUN_FORMAT_G "\n", diff --git a/src/sundomeigest/ArnI/sundomeigest_arni.c b/src/sundomeigest/ArnI/sundomeigest_arni.c index f1c57ef9fe..acdd79b916 100644 --- a/src/sundomeigest/ArnI/sundomeigest_arni.c +++ b/src/sundomeigest/ArnI/sundomeigest_arni.c @@ -330,8 +330,11 @@ SUNErrCode SUNDomEigEstimate_ArnI(SUNDomEigEstimator DEE, sunrealtype* lambdaR, eigenvalues which have converged. */ #if defined(SUNDIALS_INT32_T) - sunindextype lda = n; sunindextype ldvl = n; sunindextype ldvr = n; - sunindextype info; sunindextype lwork = 4 * n; + sunindextype lda = n; + sunindextype ldvl = n; + sunindextype ldvr = n; + sunindextype info; + sunindextype lwork = 4 * n; #if defined(SUNDIALS_DOUBLE_PRECISION) dgeev_(&jobvl, &jobvr, &n, ArnI_CONTENT(DEE)->LAPACK_A, &lda, ArnI_CONTENT(DEE)->LAPACK_wr, ArnI_CONTENT(DEE)->LAPACK_wi, NULL, @@ -342,8 +345,11 @@ SUNErrCode SUNDomEigEstimate_ArnI(SUNDomEigEstimator DEE, sunrealtype* lambdaR, &ldvl, NULL, &ldvr, ArnI_CONTENT(DEE)->LAPACK_work, &lwork, &info); #endif #elif defined(SUNDIALS_INT64_T) - int32_t lda = n; int32_t ldvl = n; int32_t ldvr = n; - int32_t info; int32_t lwork = 4 * n; + int32_t lda = n; + int32_t ldvl = n; + int32_t ldvr = n; + int32_t info; + int32_t lwork = 4 * n; #if defined(SUNDIALS_DOUBLE_PRECISION) dgeev_(&jobvl, &jobvr, &n, ArnI_CONTENT(DEE)->LAPACK_A, &lda, ArnI_CONTENT(DEE)->LAPACK_wr, ArnI_CONTENT(DEE)->LAPACK_wi, NULL, diff --git a/test/unit_tests/sundomeigest/test_sundomeigest.c b/test/unit_tests/sundomeigest/test_sundomeigest.c index 7800413412..5987ce85c8 100644 --- a/test/unit_tests/sundomeigest/test_sundomeigest.c +++ b/test/unit_tests/sundomeigest/test_sundomeigest.c @@ -163,7 +163,7 @@ int Test_SUNDomEigEstSetNumPreProcess(SUNDomEigEstimator DEE, int numwarmups, /* ---------------------------------------------------------------------- * SUNDomEigEstSetTol Test * --------------------------------------------------------------------*/ -int Test_SUNDomEigEstSetTol(SUNDomEigEstimator DEE, int tol, int myid) +int Test_SUNDomEigEstSetTol(SUNDomEigEstimator DEE, sunrealtype tol, int myid) { int failure; double start_time, stop_time; @@ -176,8 +176,7 @@ int Test_SUNDomEigEstSetTol(SUNDomEigEstimator DEE, int tol, int myid) if (failure) { - printf(">>> FAILED test -- SUNDomEigEstSetTol check, Proc %d \n", - myid); + printf(">>> FAILED test -- SUNDomEigEstSetTol check, Proc %d \n", myid); PRINT_TIME(" SUNDomEigEstSetTol Time: %22.15e \n \n", stop_time - start_time); return (1); diff --git a/test/unit_tests/sundomeigest/test_sundomeigest.h b/test/unit_tests/sundomeigest/test_sundomeigest.h index 43762497f2..fc9c8d7532 100644 --- a/test/unit_tests/sundomeigest/test_sundomeigest.h +++ b/test/unit_tests/sundomeigest/test_sundomeigest.h @@ -38,7 +38,7 @@ int Test_SUNDomEigEstSetMaxPowerIter(SUNDomEigEstimator DEE, sunindextype max_powiter, int myid); int Test_SUNDomEigEstSetNumPreProcess(SUNDomEigEstimator DEE, int numwarmups, int myid); -int Test_SUNDomEigEstSetTol(SUNDomEigEstimator DEE, int tol, int myid); +int Test_SUNDomEigEstSetTol(SUNDomEigEstimator DEE, sunrealtype tol, int myid); int Test_SUNDomEigEstInitialize(SUNDomEigEstimator DEE, int myid); int Test_SUNDomEigEstPreProcess(SUNDomEigEstimator DEE, int myid); int Test_SUNDomEigEstComputeHess(SUNDomEigEstimator DEE, int myid); From 6fa8a9c899057b8359d55107e7cf886bc38a39f1 Mon Sep 17 00:00:00 2001 From: maggul Date: Mon, 23 Jun 2025 18:35:00 -0500 Subject: [PATCH 067/128] updated answers --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index d95b1a3b53..eb8bd1f51b 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit d95b1a3b531b0844854c0e08343c2d1addaf23aa +Subproject commit eb8bd1f51baf5dd2b963b34f4f7f8a10c0924477 From 691fe10be6c587d7db31afb006cc581c4724ea83 Mon Sep 17 00:00:00 2001 From: maggul Date: Mon, 23 Jun 2025 18:38:53 -0500 Subject: [PATCH 068/128] spelling issue --- doc/arkode/guide/source/Usage/LSRKStep/User_callable.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/arkode/guide/source/Usage/LSRKStep/User_callable.rst b/doc/arkode/guide/source/Usage/LSRKStep/User_callable.rst index a5256096b4..e7c64e63df 100644 --- a/doc/arkode/guide/source/Usage/LSRKStep/User_callable.rst +++ b/doc/arkode/guide/source/Usage/LSRKStep/User_callable.rst @@ -191,7 +191,7 @@ Allowable Method Families .. note:: *ARK_DEE_FAIL* return should also produce error messages due to DEE error(s). These errors are handled by :c:type:`SUNErrCode`. - Either this function or the DEE creater function, :c:func:`LSRKStepDomEigEstCreateWithID` is required + Either this function or the DEE creator function, :c:func:`LSRKStepDomEigEstCreateWithID` is required when either the RKC or RKL methods are used. From 4729b05ec6ec8a0f1860ae51b12099389ed34980 Mon Sep 17 00:00:00 2001 From: maggul Date: Tue, 24 Jun 2025 22:08:15 -0500 Subject: [PATCH 069/128] ark_heat2D_lsrk_internal_domeig --- .../source/Usage/LSRKStep/User_callable.rst | 25 +- examples/arkode/CXX_serial/CMakeLists.txt | 4 + .../ark_heat2D_lsrk_internal_domeig.cpp | 1002 +++++++++++++++++ .../ark_heat2D_lsrk_internal_domeig.out | 79 ++ .../ark_analytic_lsrk_internal_domeig.c | 11 +- .../ark_analytic_lsrk_internal_domeig.out | 7 +- include/arkode/arkode_lsrkstep.h | 5 +- include/sundials/sundials_domeigestimator.h | 8 + include/sundomeigest/sundomeigest_arni.h | 4 - include/sundomeigest/sundomeigest_pi.h | 4 - src/arkode/arkode_lsrkstep.c | 67 +- src/arkode/arkode_lsrkstep_impl.h | 10 +- src/arkode/arkode_lsrkstep_io.c | 64 +- src/sundials/sundials_domeigestimator.c | 14 +- src/sundomeigest/ArnI/sundomeigest_arni.c | 6 +- src/sundomeigest/PI/sundomeigest_pi.c | 8 +- 16 files changed, 1263 insertions(+), 55 deletions(-) create mode 100644 examples/arkode/CXX_serial/ark_heat2D_lsrk_internal_domeig.cpp create mode 100644 examples/arkode/CXX_serial/ark_heat2D_lsrk_internal_domeig.out diff --git a/doc/arkode/guide/source/Usage/LSRKStep/User_callable.rst b/doc/arkode/guide/source/Usage/LSRKStep/User_callable.rst index e7c64e63df..9cbada62bc 100644 --- a/doc/arkode/guide/source/Usage/LSRKStep/User_callable.rst +++ b/doc/arkode/guide/source/Usage/LSRKStep/User_callable.rst @@ -191,11 +191,25 @@ Allowable Method Families .. note:: *ARK_DEE_FAIL* return should also produce error messages due to DEE error(s). These errors are handled by :c:type:`SUNErrCode`. - Either this function or the DEE creator function, :c:func:`LSRKStepDomEigEstCreateWithID` is required + Either this function or the DEE creator function, :c:func:`LSRKStepDomEigEstCreate` is required when either the RKC or RKL methods are used. + :c:func:`LSRKStepSetDomEigFn` expects a user-provided spectral radius function pointer of type + :c:func:`ARKDomEigFn()`. As mentioned above, passing a ``NULL`` pointer for this function does + not return an error; instead, it triggers the creation of an internal DEE. While this appoach + works in many cases, we recommend explicitly creating a DEE using the :c:func:`LSRKStepDomEigEstCreate` + creator function. This function returns a pointer to the DEE, which can then be used with the + associated set/get routines. An example use case can be found in following example file: + /examples/arkode/CXX_serial/ark_heat2D_lsrk_internal_domeig.cpp -.. c:function:: int LSRKStepDomEigEstCreateWithID(void* arkode_mem, SUNDomEigEstimator_ID DEE_id); + Although, a DEE creation routine requires :c:func:`SUNDomEigEstSetATimes` with a valid + matrix-vector product function pointer, creating a DEE with :c:func:`LSRKStepSetDomEigFn` + uses an internal Jacobian-vector product estimation that is passed with the *arkode_mem* pointer. + Similarly, it estimates the eigenvalue as needed internally without requiring user to call + :c:func:`SUNDomEigEstimate` function. + + +.. c:function:: int LSRKStepDomEigEstCreate(void* arkode_mem, SUNDomEigEstimator_ID DEE_id, SUNDomEigEstimator* DEE); Creates SUNDIALS DominantEigenvalue Estimator (DEE) with the provided ID. This approximation routine is used for determining the number of stages that will be used by either the @@ -216,6 +230,13 @@ Allowable Method Families Either this function or the user-supplied dominant eigenvalue estimator set function, :c:func:`LSRKStepSetDomEigFn` is required when either the RKC or RKL methods are used. + Although, a DEE creation routine requires :c:func:`SUNDomEigEstSetATimes` with a valid + matrix-vector product function pointer, creating a DEE with :c:func:`LSRKStepDomEigEstCreate` + uses an internal Jacobian-vector product estimation that is passed with the *arkode_mem* pointer. + Similarly, it estimates the eigenvalue as needed internally without requiring user to call + :c:func:`SUNDomEigEstimate` function. + + .. c:function:: int LSRKStepSetDomEigFrequency(void* arkode_mem, long int nsteps); Specifies the number of steps after which the dominant eigenvalue information is diff --git a/examples/arkode/CXX_serial/CMakeLists.txt b/examples/arkode/CXX_serial/CMakeLists.txt index 7d11938810..b7d137543b 100644 --- a/examples/arkode/CXX_serial/CMakeLists.txt +++ b/examples/arkode/CXX_serial/CMakeLists.txt @@ -46,6 +46,10 @@ if(BUILD_CVODE) list(APPEND ARKODE_headers "ark_advection_diffusion_reaction.hpp") endif() +if(ENABLE_LAPACK) + list(APPEND ARKODE_examples "ark_heat2D_lsrk_internal_domeig.cpp\;\;exclude-single") +endif() + # Auxiliary files to install set(ARKODE_extras plot_heat2D.py plot_sol.py) diff --git a/examples/arkode/CXX_serial/ark_heat2D_lsrk_internal_domeig.cpp b/examples/arkode/CXX_serial/ark_heat2D_lsrk_internal_domeig.cpp new file mode 100644 index 0000000000..14fa8a2440 --- /dev/null +++ b/examples/arkode/CXX_serial/ark_heat2D_lsrk_internal_domeig.cpp @@ -0,0 +1,1002 @@ +/* ----------------------------------------------------------------------------- + * Programmer(s): Mustafa Aggul @ SMU + * + * (adapted from ark_heat2D.cpp and adapted from ark_heat2D_lsrk.cpp, + * co-authored by Daniel Reynolds and David Gardner (LLNL)) + * ----------------------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2025, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------------------- + * Example problem: + * + * The following test simulates a simple anisotropic 2D heat equation, + * + * u_t = kx u_xx + ky u_yy + b, + * + * TO-DO: update this to kx(t) and ky(t), and determine the corresponding + * changes required for b to ensure the same analytical solution. + * + * for t in [0, 1] and (x,y) in [0, 1]^2, with initial condition + * + * u(0,x,y) = sin^2(pi x) sin^2(pi y), + * + * stationary boundary conditions + * + * u_t(t,0,y) = u_t(t,1,y) = u_t(t,x,0) = u_t(t,x,1) = 0, + * + * and the heat source + * + * b(t,x,y) = -2 pi sin^2(pi x) sin^2(pi y) sin(pi t) cos(pi t) + * - kx 2 pi^2 (cos^2(pi x) - sin^2(pi x)) sin^2(pi y) cos^2(pi t) + * - ky 2 pi^2 (cos^2(pi y) - sin^2(pi y)) sin^2(pi x) cos^2(pi t). + * + * Under this setup, the problem has the analytical solution + * + * u(t,x,y) = sin^2(pi x) sin^2(pi y) cos^2(pi t). + * + * The spatial derivatives are computed using second-order centered differences, + * with the data distributed over nx * ny points on a uniform spatial grid. The + * problem is advanced in time with the LSRKStep module in ARKODE. + * Several command line options are available to change the problem parameters + * and ARKODE settings. Use the flag --help for more information. + * ---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "arkode/arkode_lsrkstep.h" // access to LSRKStep +#include "nvector/nvector_serial.h" // access to the serial N_Vector +#include "sunadaptcontroller/sunadaptcontroller_imexgus.h" +#include "sunadaptcontroller/sunadaptcontroller_soderlind.h" + +// Macros for problem constants +#define PI SUN_RCONST(3.141592653589793238462643383279502884197169) +#define ZERO SUN_RCONST(0.0) +#define ONE SUN_RCONST(1.0) +#define TWO SUN_RCONST(2.0) + +// Macro to access (x,y) location in 1D NVector array +#define IDX(x, y, n) ((n) * (y) + (x)) + +using namespace std; + +// ----------------------------------------------------------------------------- +// User data structure +// ----------------------------------------------------------------------------- + +struct UserData +{ + // Diffusion coefficients in the x and y directions + sunrealtype kx; + sunrealtype ky; + + // Enable/disable forcing + bool forcing; + + // Final time + sunrealtype tf; + + // Upper bounds in x and y directions + sunrealtype xu; + sunrealtype yu; + + // Number of nodes in the x and y directions + sunindextype nx; + sunindextype ny; + + // Total number of nodes + sunindextype nodes; + + // Mesh spacing in the x and y directions + sunrealtype dx; + sunrealtype dy; + + // Integrator settings + sunrealtype rtol; // relative tolerance + sunrealtype atol; // absolute tolerance + sunrealtype hfixed; // fixed step size + std::string controller; // step size adaptivity method + int maxsteps; // max number of steps between outputs + bool diagnostics; // output diagnostics + + // LSRKStep options + ARKODE_LSRKMethodType method; // LSRK method choice + long int eigfrequency; // dominant eigenvalue update frequency + int stage_max_limit; // maximum number of stages per step + sunrealtype eigsafety; // dominant eigenvalue safety factor + + // Output variables + int output; // output level + int nout; // number of output times + ofstream uout; // output file stream + ofstream eout; // error file stream + N_Vector e; // error vector + + // DEE options + SUNDomEigEstimator_ID dee_id; // DEE id + int dee_numofpreprocess; // number of DEE preprocessings + int dee_max_powiter; // max number of power iterations + double dee_tol; // tolerance + + // Timing variables + bool timing; // print timings + double evolvetime; + double rhstime; +}; + +// ----------------------------------------------------------------------------- +// Functions provided to the SUNDIALS integrator +// ----------------------------------------------------------------------------- + +// ODE right hand side function +static int f(sunrealtype t, N_Vector u, N_Vector f, void* user_data); + +// ----------------------------------------------------------------------------- +// UserData and input functions +// ----------------------------------------------------------------------------- + +// Set the default values in the UserData structure +static int InitUserData(UserData* udata); + +// Free memory allocated within UserData +static int FreeUserData(UserData* udata); + +// Read the command line inputs and set UserData values +static int ReadInputs(int* argc, char*** argv, UserData* udata); + +// ----------------------------------------------------------------------------- +// Output and utility functions +// ----------------------------------------------------------------------------- + +// Compute the true solution +static int Solution(sunrealtype t, N_Vector u, UserData* udata); + +// Compute the solution error solution +static int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData* udata); + +// Print the command line options +static void InputHelp(); + +// Print some UserData information +static int PrintUserData(UserData* udata); + +// Output solution and error +static int OpenOutput(UserData* udata); +static int WriteOutput(sunrealtype t, N_Vector u, UserData* udata); +static int CloseOutput(UserData* udata); + +// Print integration timing +static int OutputTiming(UserData* udata); + +// Check function return values +static int check_flag(void* flagvalue, const string funcname, int opt); + +// ----------------------------------------------------------------------------- +// Main Program +// ----------------------------------------------------------------------------- + +int main(int argc, char* argv[]) +{ + int flag; // reusable error-checking flag + UserData* udata = NULL; // user data structure + N_Vector u = NULL; // vector for storing solution + void* arkode_mem = NULL; // ARKODE memory structure + + // Timing variables + chrono::time_point t1; + chrono::time_point t2; + + // Create the SUNDIALS context object for this simulation + SUNContext ctx; + flag = SUNContext_Create(SUN_COMM_NULL, &ctx); + if (check_flag(&flag, "SUNContext_Create", 1)) { return 1; } + + // --------------- + // Setup UserData + // --------------- + + // Allocate and initialize user data structure with default values. The + // defaults may be overwritten by command line inputs in ReadInputs below. + udata = new UserData; + flag = InitUserData(udata); + if (check_flag(&flag, "InitUserData", 1)) { return 1; } + + // Parse command line inputs + flag = ReadInputs(&argc, &argv, udata); + if (flag != 0) { return 1; } + + // Output problem setup/options + flag = PrintUserData(udata); + if (check_flag(&flag, "PrintUserData", 1)) { return 1; } + + if (udata->diagnostics) + { + SUNLogger logger = NULL; + + flag = SUNContext_GetLogger(ctx, &logger); + if (check_flag(&flag, "SUNContext_GetLogger", 1)) { return 1; } + + flag = SUNLogger_SetInfoFilename(logger, "diagnostics.txt"); + if (check_flag(&flag, "SUNLogger_SetInfoFilename", 1)) { return 1; } + + flag = SUNLogger_SetDebugFilename(logger, "diagnostics.txt"); + if (check_flag(&flag, "SUNLogger_SetDebugFilename", 1)) { return 1; } + } + + // ---------------------- + // Create serial vectors + // ---------------------- + + // Create vector for solution + u = N_VNew_Serial(udata->nodes, ctx); + if (check_flag((void*)u, "N_VNew_Serial", 0)) { return 1; } + + // Set initial condition + flag = Solution(ZERO, u, udata); + if (check_flag(&flag, "Solution", 1)) { return 1; } + + // Create vector for error + udata->e = N_VClone(u); + if (check_flag((void*)(udata->e), "N_VClone", 0)) { return 1; } + + // -------------- + // Setup ARKODE + // -------------- + + // Create integrator + arkode_mem = LSRKStepCreateSTS(f, ZERO, u, ctx); + if (check_flag((void*)arkode_mem, "LSRKStepCreateSTS", 0)) { return 1; } + + // Specify tolerances + flag = ARKodeSStolerances(arkode_mem, udata->rtol, udata->atol); + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } + + // Attach user data + flag = ARKodeSetUserData(arkode_mem, (void*)udata); + if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; } + + // Select LSRK method + flag = LSRKStepSetSTSMethod(arkode_mem, udata->method); + if (check_flag(&flag, "LSRKStepSetSTSMethod", 1)) { return 1; } + + // Specify and create an internal dominant eigenvalue estimator (DEE) + SUNDomEigEstimator DEE = NULL; + flag = LSRKStepDomEigEstCreate(arkode_mem, udata->dee_id, &DEE); + flag = (int)(DEE == NULL || flag != 0); + if (check_flag(&flag, "LSRKStepDomEigEstCreate", 2)) { return 1; } + + flag = SUNDomEigEstSetNumPreProcess(DEE, udata->dee_numofpreprocess); + if (check_flag(&flag, "SUNDomEigEstSetNumPreProcess", 2)) { return 1; } + + if(udata->dee_id == 0) + { + flag = SUNDomEigEstSetMaxPowerIter(DEE, udata->dee_max_powiter); + if (check_flag(&flag, "SUNDomEigEstSetMaxPowerIter", 2)) { return 1; } + + flag = SUNDomEigEstSetTol(DEE, udata->dee_tol); + if (check_flag(&flag, "SUNDomEigEstSetTol", 2)) { return 1; } + } + + flag = LSRKStepSetDomEigFrequency(arkode_mem, udata->eigfrequency); + if (check_flag(&flag, "LSRKStepSetDomEigFrequency", 1)) { return 1; } + + // Set maximum number of stages per step + flag = LSRKStepSetMaxNumStages(arkode_mem, udata->stage_max_limit); + if (check_flag(&flag, "LSRKStepSetMaxNumStages", 1)) { return 1; } + + // Set spectral radius safety factor + flag = LSRKStepSetDomEigSafetyFactor(arkode_mem, udata->eigsafety); + if (check_flag(&flag, "LSRKStepSetDomEigSafetyFactor", 1)) { return 1; } + + // Set fixed step size or adaptivity method + if (udata->hfixed > ZERO) + { + flag = ARKodeSetFixedStep(arkode_mem, udata->hfixed); + if (check_flag(&flag, "ARKodeSetFixedStep", 1)) { return 1; } + } + else + { + flag = ARKodeSetAdaptControllerByName(arkode_mem, udata->controller.c_str()); + if (check_flag(&flag, "ARKodeSetAdaptControllerByName", 1)) { return 1; } + } + + // Set max steps between outputs + flag = ARKodeSetMaxNumSteps(arkode_mem, udata->maxsteps); + if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) { return 1; } + + // Set stopping time + flag = ARKodeSetStopTime(arkode_mem, udata->tf); + if (check_flag(&flag, "ARKodeSetStopTime", 1)) { return 1; } + + // ----------------------- + // Loop over output times + // ----------------------- + + sunrealtype t = ZERO; + sunrealtype dTout = udata->tf / udata->nout; + sunrealtype tout = dTout; + + // initial output + flag = OpenOutput(udata); + if (check_flag(&flag, "OpenOutput", 1)) { return 1; } + + flag = WriteOutput(t, u, udata); + if (check_flag(&flag, "WriteOutput", 1)) { return 1; } + + for (int iout = 0; iout < udata->nout; iout++) + { + // Start timer + t1 = chrono::steady_clock::now(); + + // Evolve in time + flag = ARKodeEvolve(arkode_mem, tout, u, &t, ARK_NORMAL); + if (check_flag(&flag, "ARKodeEvolve", 1)) { break; } + + // Stop timer + t2 = chrono::steady_clock::now(); + + // Update timer + udata->evolvetime += chrono::duration(t2 - t1).count(); + + // Output solution and error + flag = WriteOutput(t, u, udata); + if (check_flag(&flag, "WriteOutput", 1)) { return 1; } + + // Update output time + tout += dTout; + tout = (tout > udata->tf) ? udata->tf : tout; + } + + // Close output + flag = CloseOutput(udata); + if (check_flag(&flag, "CloseOutput", 1)) { return 1; } + + // -------------- + // Final outputs + // -------------- + + // Print final integrator stats + if (udata->output > 0) + { + cout << "Final integrator statistics:" << endl; + flag = ARKodePrintAllStats(arkode_mem, stdout, SUN_OUTPUTFORMAT_TABLE); + if (check_flag(&flag, "ARKodePrintAllStats", 1)) { return 1; } + } + + if (udata->forcing) + { + // Output final error + flag = SolutionError(t, u, udata->e, udata); + if (check_flag(&flag, "SolutionError", 1)) { return 1; } + + sunrealtype maxerr = N_VMaxNorm(udata->e); + + cout << scientific; + cout << setprecision(numeric_limits::digits10); + cout << " Max error = " << maxerr << endl; + } + + // Print timing + if (udata->timing) + { + flag = OutputTiming(udata); + if (check_flag(&flag, "OutputTiming", 1)) { return 1; } + } + + // -------------------- + // Clean up and return + // -------------------- + + ARKodeFree(&arkode_mem); // Free integrator memory + N_VDestroy(u); // Free vectors + FreeUserData(udata); // Free user data + delete udata; + SUNContext_Free(&ctx); // Free context + + return 0; +} + +// ----------------------------------------------------------------------------- +// Functions called by the integrator +// ----------------------------------------------------------------------------- + +// f routine to compute the ODE RHS function f(t,y). +static int f(sunrealtype t, N_Vector u, N_Vector f, void* user_data) +{ + // Timing variables + chrono::time_point t1; + chrono::time_point t2; + + // Start timer + t1 = chrono::steady_clock::now(); + + // Access problem data + UserData* udata = (UserData*)user_data; + + // Shortcuts to number of nodes + sunindextype nx = udata->nx; + sunindextype ny = udata->ny; + + // Constants for computing diffusion term + sunrealtype cx = udata->kx / (udata->dx * udata->dx); + sunrealtype cy = udata->ky / (udata->dy * udata->dy); + sunrealtype cc = -TWO * (cx + cy); + + // Access data arrays + sunrealtype* uarray = N_VGetArrayPointer(u); + if (check_flag((void*)uarray, "N_VGetArrayPointer", 0)) { return -1; } + + sunrealtype* farray = N_VGetArrayPointer(f); + if (check_flag((void*)farray, "N_VGetArrayPointer", 0)) { return -1; } + + // Initialize rhs vector to zero (handles boundary conditions) + N_VConst(ZERO, f); + + // Iterate over domain interior and compute rhs forcing term + if (udata->forcing) + { + sunrealtype x, y; + sunrealtype sin_sqr_x, sin_sqr_y; + sunrealtype cos_sqr_x, cos_sqr_y; + + sunrealtype bx = (udata->kx) * TWO * PI * PI; + sunrealtype by = (udata->ky) * TWO * PI * PI; + + sunrealtype sin_t_cos_t = sin(PI * t) * cos(PI * t); + sunrealtype cos_sqr_t = cos(PI * t) * cos(PI * t); + + for (sunindextype j = 1; j < ny - 1; j++) + { + for (sunindextype i = 1; i < nx - 1; i++) + { + x = i * udata->dx; + y = j * udata->dy; + + sin_sqr_x = sin(PI * x) * sin(PI * x); + sin_sqr_y = sin(PI * y) * sin(PI * y); + + cos_sqr_x = cos(PI * x) * cos(PI * x); + cos_sqr_y = cos(PI * y) * cos(PI * y); + + farray[IDX(i, j, nx)] = + -TWO * PI * sin_sqr_x * sin_sqr_y * sin_t_cos_t - + bx * (cos_sqr_x - sin_sqr_x) * sin_sqr_y * cos_sqr_t - + by * (cos_sqr_y - sin_sqr_y) * sin_sqr_x * cos_sqr_t; + } + } + } + + // Iterate over domain interior and add rhs diffusion term + for (sunindextype j = 1; j < ny - 1; j++) + { + for (sunindextype i = 1; i < nx - 1; i++) + { + farray[IDX(i, j, nx)] += + cc * uarray[IDX(i, j, nx)] + + cx * (uarray[IDX(i - 1, j, nx)] + uarray[IDX(i + 1, j, nx)]) + + cy * (uarray[IDX(i, j - 1, nx)] + uarray[IDX(i, j + 1, nx)]); + } + } + + // Stop timer + t2 = chrono::steady_clock::now(); + + // Update timer + udata->rhstime += chrono::duration(t2 - t1).count(); + + // Return success + return 0; +} + +// ----------------------------------------------------------------------------- +// UserData and input functions +// ----------------------------------------------------------------------------- + +// Initialize memory allocated within Userdata +static int InitUserData(UserData* udata) +{ + // Diffusion coefficient + udata->kx = SUN_RCONST(10.0); + udata->ky = SUN_RCONST(10.0); + + // Enable forcing + udata->forcing = true; + + // Final time + udata->tf = ONE; + + // Upper bounds in x and y directions + udata->xu = ONE; + udata->yu = ONE; + + // Number of nodes in the x and y directions + udata->nx = 64; + udata->ny = 64; + udata->nodes = udata->nx * udata->ny; + + // Mesh spacing in the x and y directions + udata->dx = udata->xu / (udata->nx - 1); + udata->dy = udata->yu / (udata->ny - 1); + + // Integrator settings + udata->rtol = SUN_RCONST(1.e-5); // relative tolerance + udata->atol = SUN_RCONST(1.e-10); // absolute tolerance + udata->hfixed = ZERO; // using adaptive step sizes + udata->controller = "I"; // I controller + udata->maxsteps = 0; // use default + udata->diagnostics = false; // output diagnostics + + // LSRKStep options + udata->method = ARKODE_LSRK_RKC_2; // RKC + udata->eigfrequency = 25; // update eigenvalue at least every 20 steps + udata->stage_max_limit = 1000; // allow up to 1000 stages/step + udata->eigsafety = SUN_RCONST(1.01); // 1% safety factor + + // Output variables + udata->output = 1; // 0 = no output, 1 = stats output, 2 = output to disk + udata->nout = 20; // Number of output times + udata->e = NULL; + + // DEE options + udata->dee_id = SUNDSOMEIGESTIMATOR_ARNOLDI; + udata->dee_numofpreprocess = 20; + udata->dee_max_powiter = 100; + udata->dee_tol = 0.01; + + // Timing variables + udata->timing = false; + udata->evolvetime = 0.0; + udata->rhstime = 0.0; + + // Return success + return 0; +} + +// Free memory allocated within Userdata +static int FreeUserData(UserData* udata) +{ + // Free error vector + if (udata->e) + { + N_VDestroy(udata->e); + udata->e = NULL; + } + + // Return success + return 0; +} + +// Read command line inputs +static int ReadInputs(int* argc, char*** argv, UserData* udata) +{ + // Check for input args + int arg_idx = 1; + + while (arg_idx < (*argc)) + { + string arg = (*argv)[arg_idx++]; + + // Mesh points + if (arg == "--mesh") + { + udata->nx = stoi((*argv)[arg_idx++]); + udata->ny = stoi((*argv)[arg_idx++]); + } + // Domain upper bounds + else if (arg == "--domain") + { + udata->xu = stoi((*argv)[arg_idx++]); + udata->yu = stoi((*argv)[arg_idx++]); + } + // Diffusion parameters + else if (arg == "--k") + { + udata->kx = stod((*argv)[arg_idx++]); + udata->ky = stod((*argv)[arg_idx++]); + } + // Disable forcing + else if (arg == "--noforcing") { udata->forcing = false; } + // Temporal domain settings + else if (arg == "--tf") { udata->tf = stod((*argv)[arg_idx++]); } + // Integrator settings + else if (arg == "--rtol") { udata->rtol = stod((*argv)[arg_idx++]); } + else if (arg == "--atol") { udata->atol = stod((*argv)[arg_idx++]); } + else if (arg == "--fixedstep") { udata->hfixed = stod((*argv)[arg_idx++]); } + else if (arg == "--controller") { udata->controller = (*argv)[arg_idx++]; } + else if (arg == "--diagnostics") { udata->diagnostics = true; } + else if (arg == "--method") + { + udata->method = (ARKODE_LSRKMethodType)stoi((*argv)[arg_idx++]); + } + else if (arg == "--eigfrequency") + { + udata->eigfrequency = stoi((*argv)[arg_idx++]); + } + else if (arg == "--stage_max_limit") + { + udata->stage_max_limit = stoi((*argv)[arg_idx++]); + } + else if (arg == "--eigsafety") + { + udata->eigsafety = stod((*argv)[arg_idx++]); + } + // Output settings + else if (arg == "--output") { udata->output = stoi((*argv)[arg_idx++]); } + else if (arg == "--nout") { udata->nout = stoi((*argv)[arg_idx++]); } + else if (arg == "--maxsteps") + { + udata->maxsteps = stoi((*argv)[arg_idx++]); + } + // DEE options + else if (arg == "--dee_id") + { + udata->dee_id = (SUNDomEigEstimator_ID)stoi((*argv)[arg_idx++]); + } + else if (arg == "--dee_numofpreprocess") + { + udata->dee_numofpreprocess = stoi((*argv)[arg_idx++]); + } + else if (arg == "--dee_max_powiter") + { + udata->dee_max_powiter = stoi((*argv)[arg_idx++]); + } + else if (arg == "--dee_tol") + { + udata->dee_tol = stod((*argv)[arg_idx++]); + } + else if (arg == "--timing") { udata->timing = true; } + // Help + else if (arg == "--help") + { + InputHelp(); + return -1; + } + // Unknown input + else + { + cerr << "ERROR: Invalid input " << arg << endl; + InputHelp(); + return -1; + } + } + + // Recompute total number of nodes + udata->nodes = udata->nx * udata->ny; + + // Recompute x and y mesh spacing + udata->dx = (udata->xu) / (udata->nx - 1); + udata->dy = (udata->yu) / (udata->ny - 1); + + // Return success + return 0; +} + +// ----------------------------------------------------------------------------- +// Output and utility functions +// ----------------------------------------------------------------------------- + +// Compute the exact solution +static int Solution(sunrealtype t, N_Vector u, UserData* udata) +{ + sunrealtype x, y; + sunrealtype cos_sqr_t; + sunrealtype sin_sqr_x, sin_sqr_y; + + // Constants for computing solution + cos_sqr_t = cos(PI * t) * cos(PI * t); + + // Initialize u to zero (handles boundary conditions) + N_VConst(ZERO, u); + + sunrealtype* uarray = N_VGetArrayPointer(u); + if (check_flag((void*)uarray, "N_VGetArrayPointer", 0)) { return -1; } + + for (sunindextype j = 1; j < udata->ny - 1; j++) + { + for (sunindextype i = 1; i < udata->nx - 1; i++) + { + x = i * udata->dx; + y = j * udata->dy; + + sin_sqr_x = sin(PI * x) * sin(PI * x); + sin_sqr_y = sin(PI * y) * sin(PI * y); + + uarray[IDX(i, j, udata->nx)] = sin_sqr_x * sin_sqr_y * cos_sqr_t; + } + } + + return 0; +} + +// Compute the solution error +static int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData* udata) +{ + // Compute true solution + int flag = Solution(t, e, udata); + if (flag != 0) { return -1; } + + // Compute absolute error + N_VLinearSum(ONE, u, -ONE, e, e); + N_VAbs(e, e); + + return 0; +} + +// Print command line options +static void InputHelp() +{ + cout << endl; + cout << "Command line options:" << endl; + cout << " --mesh : mesh points in the x and y directions" + << endl; + cout + << " --domain : domain upper bound in the x and y direction" + << endl; + cout << " --k : diffusion coefficients" << endl; + cout << " --noforcing : disable forcing term" << endl; + cout << " --tf