Replace energy command with eea
This commit is contained in:
parent
f9d9d48154
commit
6b96c2d946
15
src/main.c
15
src/main.c
@ -41,9 +41,8 @@ _Complex double* set_driving(unsigned int driving, nstrophy_parameters parameter
|
||||
_Complex double* set_init(unsigned int init, nstrophy_parameters parameters);
|
||||
|
||||
#define COMMAND_UK 1
|
||||
#define COMMAND_ALPHA 2
|
||||
#define COMMAND_EEA 2
|
||||
#define COMMAND_QUIET 3
|
||||
#define COMMAND_ENERGY 4
|
||||
|
||||
#define DRIVING_ZERO 1
|
||||
#define DRIVING_TEST 2
|
||||
@ -93,10 +92,7 @@ int main (
|
||||
if (command==COMMAND_UK){
|
||||
uk(parameters.K1, parameters.K2, parameters.N1, parameters.N2, parameters.nsteps, parameters.nu, parameters.delta, parameters.L, u0, g, parameters.print_freq, nthreads);
|
||||
}
|
||||
else if (command==COMMAND_ENERGY){
|
||||
energy(parameters.K1, parameters.K2, parameters.N1, parameters.N2, parameters.nsteps, parameters.nu, parameters.delta, parameters.L, u0, g, parameters.print_freq, nthreads);
|
||||
}
|
||||
else if(command==COMMAND_ALPHA){
|
||||
else if(command==COMMAND_EEA){
|
||||
eea(parameters.K1, parameters.K2, parameters.N1, parameters.N2, parameters.nsteps, parameters.nu, parameters.delta, parameters.L, u0, g, parameters.print_freq, nthreads);
|
||||
}
|
||||
else if(command==COMMAND_QUIET){
|
||||
@ -251,15 +247,12 @@ int read_args(
|
||||
if(strcmp(argv[i], "uk")==0){
|
||||
*command=COMMAND_UK;
|
||||
}
|
||||
else if(strcmp(argv[i], "alpha")==0){
|
||||
*command=COMMAND_ALPHA;
|
||||
else if(strcmp(argv[i], "energy")==0){
|
||||
*command=COMMAND_EEA;
|
||||
}
|
||||
else if(strcmp(argv[i], "quiet")==0){
|
||||
*command=COMMAND_QUIET;
|
||||
}
|
||||
else if(strcmp(argv[i], "energy")==0){
|
||||
*command=COMMAND_ENERGY;
|
||||
}
|
||||
else{
|
||||
fprintf(stderr, "error: unrecognized command: '%s'\n",argv[i]);
|
||||
return(-1);
|
||||
|
@ -69,55 +69,6 @@ int uk(
|
||||
return(0);
|
||||
}
|
||||
|
||||
// compute the energy as a function of time
|
||||
int energy(
|
||||
int K1,
|
||||
int K2,
|
||||
int N1,
|
||||
int N2,
|
||||
unsigned int nsteps,
|
||||
double nu,
|
||||
double delta,
|
||||
double L,
|
||||
_Complex double* u0,
|
||||
_Complex double* g,
|
||||
unsigned int print_freq,
|
||||
unsigned int nthreads
|
||||
){
|
||||
_Complex double* u;
|
||||
_Complex double* tmp1;
|
||||
_Complex double* tmp2;
|
||||
_Complex double* tmp3;
|
||||
unsigned int t;
|
||||
fft_vect fft1;
|
||||
fft_vect fft2;
|
||||
fft_vect ifft;
|
||||
double energy;
|
||||
double avg;
|
||||
|
||||
ns_init_tmps(&u, &tmp1, &tmp2, &tmp3, &fft1, &fft2, &ifft, K1, K2, N1, N2, nthreads);
|
||||
// copy initial condition
|
||||
copy_u(u, u0, K1, K2);
|
||||
|
||||
// init running average
|
||||
avg=0;
|
||||
|
||||
// iterate
|
||||
for(t=0;t<nsteps;t++){
|
||||
ins_step(u, K1, K2, N1, N2, nu, delta, L, g, fft1, fft2, ifft, tmp1, tmp2, tmp3);
|
||||
|
||||
if(t%print_freq==0){
|
||||
energy=compute_energy(u, K1, K2);
|
||||
|
||||
fprintf(stderr,"%d % .8e % .8e\n",t,t*delta, energy);
|
||||
printf("%8d % .15e % .15e\n",t,t*delta,energy);
|
||||
}
|
||||
}
|
||||
|
||||
ns_free_tmps(u, tmp1, tmp2, tmp3, fft1, fft2, ifft);
|
||||
return(0);
|
||||
}
|
||||
|
||||
// compute energy, enstrophy, alpha as a function of time in the I-NS equation
|
||||
int eea(
|
||||
int K1,
|
||||
|
Loading…
Reference in New Issue
Block a user