llnl / llnl/sundials

Examples for `CVodeResizeHistory` when `y` changes size

Open
#715 4 comments 0 reactions 1 assignee View on GitHub

@gardner48 is already working on this.

Since Jun 13, 2025.

question
Dominant language
C
Stars
686
Forks
167
Avg merge
1d 20h
Merged PRs (30d)
17

Description

CVodeResizeHistory is a very nice function and I am glad it was released in v7.3.0. I'm working on a project that requires dynamically resizing the ODE system during integration using CVodeResizeHistory(). While the documentation explains the API, I’m unclear on how to handle some scenarios.

1. Resizing when the solution vector y changes size
  • When the ODE system increases or decreases in size, how should y_hist and f_hist be constructed to accommodate the new variables?

  • For example, consider this case:

    Time t_n t_{n-1} t_{n-2} t_{n-3}
    Number of equations 6 5 4 5
    Notes y6 added shrinks below original intermediate (y1) or last (y5) removed back to original size
  • What should the sizes of y_hist and f_hist be in this case?
    At t_n, should the sizes of the vectors in history remain as [6, 5, 4, 5], or should all history vectors be resized to [6, 6, 6, 6] to match the new system size?

  • If resizing history vectors, how should the new components be filled? Is zero-initialization acceptable, or should they be extrapolated or estimated in a specific way?


2. Clarification on test behavior

In this test case, I noticed two different behaviors:
https://github.com/LLNL/sundials/blob/967f4d9d18563b8d0f7c79d056a7d1fa607f145a/test/unit_tests/cvode/CXX_serial/cv_test_resize_history.cpp#L127-L129

  • Resizing while keeping the same problem size
  • Growing the problem by one element each time step

Could you clarify the purpose of each approach? How do they differ in terms of results, stability, or accuracy?


3. Request for a complete working example

It would be incredibly helpful to see a full example that demonstrates a dynamic resize where the number of unknowns (NEQ) both expands and shrinks


Thank you for your work on this excellent integration library!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.