From a6ae7e934737f29e13093666da7cba2ff61dc664 Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Fri, 16 Oct 2026 13:58:07 -0400 Subject: [PATCH 1/2] use a pool instead --- .../src/main/java/cnuphys/rk4/RungeKutta.java | 58 +++++++++++++++---- 1 file changed, 46 insertions(+), 12 deletions(-) diff --git a/common-tools/cnuphys/swimmer/src/main/java/cnuphys/rk4/RungeKutta.java b/common-tools/cnuphys/swimmer/src/main/java/cnuphys/rk4/RungeKutta.java index 667a48473f..f78ed975ca 100644 --- a/common-tools/cnuphys/swimmer/src/main/java/cnuphys/rk4/RungeKutta.java +++ b/common-tools/cnuphys/swimmer/src/main/java/cnuphys/rk4/RungeKutta.java @@ -2,6 +2,7 @@ import java.util.ArrayDeque; import java.util.List; +import java.util.concurrent.ConcurrentLinkedQueue; /** * Static methods for Runge-Kutta 4 integration, including a constant stepsize @@ -1062,6 +1063,41 @@ private int driver(double yo[], // A uniform step size advancer class UniformAdvance implements IAdvance { + static class State { + double k2[]; + double k3[]; + double k4[]; + double ytemp[]; + State(int dim) { + k2 = new double[dim]; + k3 = new double[dim]; + k4 = new double[dim]; + ytemp = new double[dim]; + } + State reset() { + for (int i=0; i { + StatePool(int size, int dim) { + for (int i=0; i Date: Fri, 16 Oct 2026 17:01:33 -0400 Subject: [PATCH 2/2] add missings --- .../cnuphys/swimmer/src/main/java/cnuphys/rk4/RungeKutta.java | 1 + 1 file changed, 1 insertion(+) diff --git a/common-tools/cnuphys/swimmer/src/main/java/cnuphys/rk4/RungeKutta.java b/common-tools/cnuphys/swimmer/src/main/java/cnuphys/rk4/RungeKutta.java index f78ed975ca..f362f412b2 100644 --- a/common-tools/cnuphys/swimmer/src/main/java/cnuphys/rk4/RungeKutta.java +++ b/common-tools/cnuphys/swimmer/src/main/java/cnuphys/rk4/RungeKutta.java @@ -1094,6 +1094,7 @@ static class StatePool extends ConcurrentLinkedQueue { } static StatePool[] statePool = new StatePool[]{ + null, null, null, new StatePool(1000,3),new StatePool(1000,4), new StatePool(1000,5),new StatePool(1000,6) };