From dffa3780847158142000734bb7c5e07e5a8008fd Mon Sep 17 00:00:00 2001 From: Ian Jauslin Date: Wed, 17 May 2023 16:59:15 -0400 Subject: [PATCH] Rename RKBS23 to RKBS32 --- src/constants.cpp | 2 +- src/main.c | 8 ++++---- src/navier-stokes.c | 20 ++++++++++---------- src/navier-stokes.h | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/constants.cpp b/src/constants.cpp index 70a3e8b..18ed222 100644 --- a/src/constants.cpp +++ b/src/constants.cpp @@ -34,5 +34,5 @@ limitations under the License. #define ALGORITHM_ADAPTIVE_THRESHOLD 1000 // adaptive algorithms: index > ALGORITHM_ADAPTIVE_THRESHOLD #define ALGORITHM_RKF45 1001 -#define ALGORITHM_RKBS23 1002 +#define ALGORITHM_RKBS32 1002 diff --git a/src/main.c b/src/main.c index dadba17..43b5218 100644 --- a/src/main.c +++ b/src/main.c @@ -265,8 +265,8 @@ int print_params( case ALGORITHM_RKF45: fprintf(file,", algorithm=RKF45, tolerance=%.15e, factor=%.15e",parameters.adaptive_tolerance, parameters.adaptive_factor); break; - case ALGORITHM_RKBS23: - fprintf(file,", algorithm=RKBS23, tolerance=%.15e, factor=%.15e",parameters.adaptive_tolerance, parameters.adaptive_factor); + case ALGORITHM_RKBS32: + fprintf(file,", algorithm=RKBS32, tolerance=%.15e, factor=%.15e",parameters.adaptive_tolerance, parameters.adaptive_factor); break; default: fprintf(file,", algorithm=RK4"); @@ -674,8 +674,8 @@ int set_parameter( else if (strcmp(rhs,"RKF45")==0){ parameters->algorithm=ALGORITHM_RKF45; } - else if (strcmp(rhs,"RKBS23")==0){ - parameters->algorithm=ALGORITHM_RKBS23; + else if (strcmp(rhs,"RKBS32")==0){ + parameters->algorithm=ALGORITHM_RKBS32; } else{ fprintf(stderr, "error: unrecognized algorithm '%s'\n",rhs); diff --git a/src/navier-stokes.c b/src/navier-stokes.c index 0523bf5..12338bd 100644 --- a/src/navier-stokes.c +++ b/src/navier-stokes.c @@ -90,9 +90,9 @@ int uk( ns_step_rk4(u, K1, K2, N1, N2, nu, step, L, g, fft1, fft2, ifft, tmp1, tmp2, tmp3, irreversible); } else if (algorithm==ALGORITHM_RKF45) { ns_step_rkf45(u, adaptive_tolerance, adaptive_factor, K1, K2, N1, N2, nu, &step, &next_step, L, g, fft1, fft2, ifft, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, irreversible, true); - } else if (algorithm==ALGORITHM_RKBS23) { + } else if (algorithm==ALGORITHM_RKBS32) { // only compute k1 on the first step - ns_step_rkbs23(u, adaptive_tolerance, adaptive_factor, K1, K2, N1, N2, nu, &step, &next_step, L, g, fft1, fft2, ifft, &tmp1, tmp2, tmp3, &tmp4, tmp5, irreversible, time==starting_time); + ns_step_rkbs32(u, adaptive_tolerance, adaptive_factor, K1, K2, N1, N2, nu, &step, &next_step, L, g, fft1, fft2, ifft, &tmp1, tmp2, tmp3, &tmp4, tmp5, irreversible, time==starting_time); } else { fprintf(stderr,"bug: unknown algorithm: %u, contact ian.jauslin@rutgers,edu\n",algorithm); } @@ -196,9 +196,9 @@ int enstrophy( ns_step_rk4(u, K1, K2, N1, N2, nu, step, L, g, fft1, fft2, ifft, tmp1, tmp2, tmp3, irreversible); } else if (algorithm==ALGORITHM_RKF45) { ns_step_rkf45(u, adaptive_tolerance, adaptive_factor, K1, K2, N1, N2, nu, &step, &next_step, L, g, fft1, fft2, ifft, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, irreversible, true); - } else if (algorithm==ALGORITHM_RKBS23) { + } else if (algorithm==ALGORITHM_RKBS32) { // only compute k1 on the first step - ns_step_rkbs23(u, adaptive_tolerance, adaptive_factor, K1, K2, N1, N2, nu, &step, &next_step, L, g, fft1, fft2, ifft, &tmp1, tmp2, tmp3, &tmp4, tmp5, irreversible, time==starting_time); + ns_step_rkbs32(u, adaptive_tolerance, adaptive_factor, K1, K2, N1, N2, nu, &step, &next_step, L, g, fft1, fft2, ifft, &tmp1, tmp2, tmp3, &tmp4, tmp5, irreversible, time==starting_time); } else { fprintf(stderr,"bug: unknown algorithm: %u, contact ian.jauslin@rutgers,edu\n",algorithm); } @@ -351,9 +351,9 @@ int quiet( ns_step_rk4(u, K1, K2, N1, N2, nu, step, L, g, fft1, fft2, ifft, tmp1, tmp2, tmp3, irreversible); } else if (algorithm==ALGORITHM_RKF45) { ns_step_rkf45(u, adaptive_tolerance, adaptive_factor, K1, K2, N1, N2, nu, &step, &next_step, L, g, fft1, fft2, ifft, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, irreversible, true); - } else if (algorithm==ALGORITHM_RKBS23) { + } else if (algorithm==ALGORITHM_RKBS32) { // only compute k1 on the first step - ns_step_rkbs23(u, adaptive_tolerance, adaptive_factor, K1, K2, N1, N2, nu, &step, &next_step, L, g, fft1, fft2, ifft, &tmp1, tmp2, tmp3, &tmp4, tmp5, irreversible, time==starting_time); + ns_step_rkbs32(u, adaptive_tolerance, adaptive_factor, K1, K2, N1, N2, nu, &step, &next_step, L, g, fft1, fft2, ifft, &tmp1, tmp2, tmp3, &tmp4, tmp5, irreversible, time==starting_time); } else { fprintf(stderr,"bug: unknown algorithm: %u, contact ian.jauslin@rutgers,edu\n",algorithm); } @@ -409,7 +409,7 @@ int ns_init_tmps( *tmp5=calloc(sizeof(_Complex double),K1*(2*K2+1)+K2); *tmp6=calloc(sizeof(_Complex double),K1*(2*K2+1)+K2); *tmp7=calloc(sizeof(_Complex double),K1*(2*K2+1)+K2); - } else if (algorithm==ALGORITHM_RKBS23){ + } else if (algorithm==ALGORITHM_RKBS32){ *tmp1=calloc(sizeof(_Complex double),K1*(2*K2+1)+K2); *tmp2=calloc(sizeof(_Complex double),K1*(2*K2+1)+K2); *tmp3=calloc(sizeof(_Complex double),K1*(2*K2+1)+K2); @@ -474,7 +474,7 @@ int ns_free_tmps( free(tmp5); free(tmp6); free(tmp7); - } else if (algorithm==ALGORITHM_RKBS23){ + } else if (algorithm==ALGORITHM_RKBS32){ free(tmp1); free(tmp2); free(tmp3); @@ -741,7 +741,7 @@ int ns_step_rkf45( // next time step // adaptive RK algorithm (Runge-Kutta-Bogacki-Shampine method) -int ns_step_rkbs23( +int ns_step_rkbs32( _Complex double* u, double tolerance, double factor, @@ -832,7 +832,7 @@ int ns_step_rkbs23( else{ *delta=factor*(*delta)*pow(relative*tolerance/err,1./3); // this will reuse the same k1 without re-computing it - ns_step_rkbs23(u,tolerance,factor,K1,K2,N1,N2,nu,delta,next_delta,L,g,fft1,fft2,ifft,k1,k2,k3,k4,tmp,irreversible,false); + ns_step_rkbs32(u,tolerance,factor,K1,K2,N1,N2,nu,delta,next_delta,L,g,fft1,fft2,ifft,k1,k2,k3,k4,tmp,irreversible,false); } return 0; diff --git a/src/navier-stokes.h b/src/navier-stokes.h index 3f1f6dc..ec35052 100644 --- a/src/navier-stokes.h +++ b/src/navier-stokes.h @@ -58,7 +58,7 @@ int ns_step_rk2( _Complex double* u, int K1, int K2, int N1, int N2, double nu, // adaptive RK algorithm (Runge-Kutta-Fehlberg) int ns_step_rkf45( _Complex double* u, double tolerance, double factor, int K1, int K2, int N1, int N2, double nu, double* delta, double* next_delta, double L, _Complex double* g, fft_vect fft1, fft_vect fft2, fft_vect ifft, _Complex double* k1, _Complex double* k2, _Complex double* k3, _Complex double* k4, _Complex double* k5, _Complex double* k6, _Complex double* tmp, bool irreversible, bool compute_k1); // Runge-Kutta-Bogacki-Shampine -int ns_step_rkbs23( _Complex double* u, double tolerance, double factor, int K1, int K2, int N1, int N2, double nu, double* delta, double* next_delta, double L, _Complex double* g, fft_vect fft1, fft_vect fft2, fft_vect ifft, _Complex double** k1, _Complex double* k2, _Complex double* k3, _Complex double** k4, _Complex double* tmp, bool irreversible, bool compute_k1); +int ns_step_rkbs32( _Complex double* u, double tolerance, double factor, int K1, int K2, int N1, int N2, double nu, double* delta, double* next_delta, double L, _Complex double* g, fft_vect fft1, fft_vect fft2, fft_vect ifft, _Complex double** k1, _Complex double* k2, _Complex double* k3, _Complex double** k4, _Complex double* tmp, bool irreversible, bool compute_k1); // right side of Irreversible/reversible Navier-Stokes equation int ns_rhs( _Complex double* out, _Complex double* u, int K1, int K2, int N1, int N2, double nu, double L, _Complex double* g, fft_vect fft1, fft_vect fft2, fft_vect ifft, bool irreversible);