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

Cache for auxiliary variables in step procedures #22

Closed
HugoMVale opened this issue Jul 10, 2023 · 0 comments · Fixed by #25
Closed

Cache for auxiliary variables in step procedures #22

HugoMVale opened this issue Jul 10, 2023 · 0 comments · Fixed by #25

Comments

@HugoMVale
Copy link
Contributor

HugoMVale commented Jul 10, 2023

The step procedures require a number of auxiliary variables to carry out the corresponding calculations, for instance f1,...f6 in the algorithm below.

module procedure rkf45
real(wp),dimension(me%n) :: f1,f2,f3,f4,f5,f6
...

For each time step, memory to store these variables needs to be allocated and then freed up. For very large ODE sets, these vectors will be huge and the corresponding memory operations can be significantly time consuming.

For optimal efficiency, the corresponding memory should be allocated once and then reused at each step, without repeated (de)allocation. AFAIU, DifferentialEquations.js also does so as well.

In principle, the abstract rk_class could include an allocatable component real(wp), allocatable :: cache(:,:). The cache would be allocated during the instantiation of the concrete method class. Inside the step method, we could then associate:

module procedure rkf45
associate (f1=>me%cache(:,1), f2=>me%cache(:,2), ... )
...

Quite likely, I am missing some important aspects, but I hope the main idea makes some sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant