Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert ARKode interfaces to conform to our callback policy. #15223

Merged
merged 5 commits into from May 19, 2023

Conversation

bangerth
Copy link
Member

Like in #15178 and #15186. Implements the resolution in #15112, #15146.

I have not actually managed to write a test case where ARKode recovers after a recoverable error, but it correctly reports that it has received a recoverable error code. The new test checks this.

@drwells
Copy link
Member

drwells commented May 18, 2023

I'm getting caught up on the new convention for exceptions - I like it.

Things are failing to compile because of some ODE routines with attached linear solvers. Something like this compiles but doesn't handle the exception correctly:

    template <typename VectorType>
    int
    arkode_linsol_solve(SUNLinearSolver LS,
                        SUNMatrix /*ignored*/,
                        N_Vector x,
                        N_Vector b,
                        realtype tol)
    {
      auto content = access_content<VectorType>(LS);

      auto *src_b = unwrap_nvector_const<VectorType>(b);
      auto *dst_x = unwrap_nvector<VectorType>(x);

      SundialsOperator<VectorType> op(content->A_data,
                                      content->a_times_fn
#  if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
                                      ,
                                      content->linsol_ctx
#  endif
      );

      SundialsPreconditioner<VectorType> preconditioner(
        content->P_data,
        content->preconditioner_solve,
#  if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
        content->linsol_ctx,
#  endif
        tol);

      try
        {
          content->lsolve(op, preconditioner, *dst_x, *src_b, tol);
          return 0;
        }
      catch (RecoverableUserCallbackError &)
        {
          return SUNLS_PACKAGE_FAIL_REC;
        }
      catch (...)
        {
          return SUNLS_PACKAGE_FAIL_UNREC;
        }
    }

@bangerth
Copy link
Member Author

I don't know how I missed that. I'll get to it on Monday (travel and family stuff before then).

@bangerth
Copy link
Member Author

@drwells I got it done today after all.

@drwells drwells merged commit 81eca64 into dealii:master May 19, 2023
14 checks passed
@bangerth bangerth deleted the arkode branch May 20, 2023 03:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants