Ian Jauslin
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Jauslin <ian@jauslin.org>2022-05-17 14:31:22 +0200
committerIan Jauslin <ian@jauslin.org>2022-05-17 14:31:22 +0200
commitc32c52c94ab393f970e2e0a1289ae22e7ca08c9c (patch)
tree5aba027b6ffad2f5a90e5cc735ae998f7f40d51a /src/main.c
parent35d91830a2548370f7ecbc13d42729cbc5d70cac (diff)
Fixes in cli argument parsing
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/main.c b/src/main.c
index 10b1e70..bbdf143 100644
--- a/src/main.c
+++ b/src/main.c
@@ -52,8 +52,8 @@ int print_usage(){
// read command line arguments
#define CP_FLAG_TIMESTEP 1
#define CP_FLAG_NSTEPS 2
-#define CP_FLAG_MODES 2
-#define CP_FLAG_NU 3
+#define CP_FLAG_MODES 3
+#define CP_FLAG_NU 4
int read_args(int argc, const char* argv[], ns_params* params, unsigned int* nsteps, unsigned int* computation_nr){
int i;
int ret;
@@ -78,11 +78,11 @@ int read_args(int argc, const char* argv[], ns_params* params, unsigned int* nst
params->nu=1./1024/(2*params->K+1);
*/
params->K=16;
+ //h=2^-13
params->h=0.0001220703125;
- params->h=0.001953125;
+ //nu=2^-11
*nsteps=10000000;
- //params->nu=0.00048828125;
- params->nu=0.0078125;
+ params->nu=0.00048828125;
// loop over arguments
for(i=1;i<argc;i++){
@@ -138,14 +138,14 @@ int read_args(int argc, const char* argv[], ns_params* params, unsigned int* nst
*nsteps=tmp_uint;
flag=0;
}
- // nsteps
+ // modes
else if(flag==CP_FLAG_MODES){
ret=sscanf(argv[i],"%d",&tmp_int);
if(ret!=1){
fprintf(stderr, "error: '-K' should be followed by an int\n got '%s'\n",argv[i]);
return(-1);
}
- params->K=tmp_uint;
+ params->K=tmp_int;
flag=0;
}
// friction
@@ -206,6 +206,7 @@ int enstrophy(ns_params params, unsigned int Nsteps){
tmp2=calloc(sizeof(_Complex double),params.S*params.S);
tmp3=calloc(sizeof(_Complex double),params.S*params.S);
+ /*
srand(17);
// initial value
@@ -236,14 +237,19 @@ int enstrophy(ns_params params, unsigned int Nsteps){
u[KLOOKUP(kx,ky,params.S)]=u[KLOOKUP(kx,ky,params.S)]*sqrt(155.1/rescale);
}
}
-
+ */
/*
for(kx=-params.K;kx<=params.K;kx++){
for(ky=-params.K;ky<=params.K;ky++){
- printf("%d %d % .8e % .8e\n",kx,ky, __real__ u[KLOOKUP(kx,ky,params.S)], __imag__ u[KLOOKUP(kx,ky,params.S)]);
+ u[KLOOKUP(kx,ky,params.S)]=1.;
}
}
*/
+ for(kx=-params.K;kx<=params.K;kx++){
+ for(ky=-params.K;ky<=params.K;ky++){
+ u[KLOOKUP(kx,ky,params.S)]=exp(-sqrt(kx*kx+ky*ky));
+ }
+ }
// driving force
@@ -278,7 +284,7 @@ int enstrophy(ns_params params, unsigned int Nsteps){
for(t=0;t<Nsteps;t++){
ins_step(u, params, fft_vects, tmp1, tmp2, tmp3);
alpha=compute_alpha(u, params);
-
+
/*
// to avoid errors building up in imaginary part
for(kx=-params.K;kx<=params.K;kx++){
@@ -294,8 +300,8 @@ int enstrophy(ns_params params, unsigned int Nsteps){
}
if(t>0 && t%1000==0){
- fprintf(stderr,"%8d % .8e % .8e % .8e % .8e\n",t, __real__ avg, __imag__ avg, __real__ alpha, __imag__ alpha);
- printf("%8d % .8e % .8e % .8e % .8e\n",t, __real__ avg, __imag__ avg, __real__ alpha, __imag__ alpha);
+ fprintf(stderr,"% .15e % .15e % .15e % .15e % .15e\n",t*params.h, __real__ avg, __imag__ avg, __real__ alpha, __imag__ alpha);
+ printf("% .15e % .15e % .15e % .15e % .15e\n",t*params.h, __real__ avg, __imag__ avg, __real__ alpha, __imag__ alpha);
}
}