print_alpha
This commit is contained in:
parent
cf48b23d4d
commit
9fa10c8db4
@ -130,6 +130,9 @@ should be a `;` sperated list of `key=value` pairs. The possible keys are
|
|||||||
* `keep_en_cst` (0 or 1, default 0): impose that the enstrophy is constant at
|
* `keep_en_cst` (0 or 1, default 0): impose that the enstrophy is constant at
|
||||||
each step (only really useful for the reversible equation).
|
each step (only really useful for the reversible equation).
|
||||||
|
|
||||||
|
* `print_alpha` (0 or 1, default 0): if this is set to 1, then whenever alpha
|
||||||
|
is negative, its value is printed as a comment.
|
||||||
|
|
||||||
|
|
||||||
# Interrupting and resuming the computation
|
# Interrupting and resuming the computation
|
||||||
|
|
||||||
|
14
src/main.c
14
src/main.c
@ -58,6 +58,7 @@ typedef struct nstrophy_parameters {
|
|||||||
FILE* drivingfile;
|
FILE* drivingfile;
|
||||||
double lyapunov_reset;
|
double lyapunov_reset;
|
||||||
double D_epsilon;
|
double D_epsilon;
|
||||||
|
bool print_alpha;
|
||||||
} nstrophy_parameters;
|
} nstrophy_parameters;
|
||||||
|
|
||||||
// usage message
|
// usage message
|
||||||
@ -277,7 +278,7 @@ int main (
|
|||||||
// register signal handler to handle aborts
|
// register signal handler to handle aborts
|
||||||
signal(SIGINT, sig_handler);
|
signal(SIGINT, sig_handler);
|
||||||
signal(SIGTERM, sig_handler);
|
signal(SIGTERM, sig_handler);
|
||||||
enstrophy(parameters.K1, parameters.K2, parameters.N1, parameters.N2, parameters.final_time, parameters.nu, parameters.delta, parameters.L, parameters.adaptive_tolerance, parameters.adaptive_factor, parameters.max_delta, parameters.adaptive_norm, u0, g, parameters.irreversible, parameters.keep_en_cst, parameters.init_en, parameters.algorithm, parameters.print_freq, parameters.starting_time, nthreads, savefile, utfile, (char*)argv[0], dstring_to_str_noinit(¶m_str), dstring_to_str_noinit(&savefile_str), dstring_to_str_noinit(&utfile_str));
|
enstrophy(parameters.K1, parameters.K2, parameters.N1, parameters.N2, parameters.final_time, parameters.nu, parameters.delta, parameters.L, parameters.adaptive_tolerance, parameters.adaptive_factor, parameters.max_delta, parameters.adaptive_norm, u0, g, parameters.irreversible, parameters.keep_en_cst, parameters.init_en, parameters.algorithm, parameters.print_freq, parameters.starting_time, parameters.print_alpha, nthreads, savefile, utfile, (char*)argv[0], dstring_to_str_noinit(¶m_str), dstring_to_str_noinit(&savefile_str), dstring_to_str_noinit(&utfile_str));
|
||||||
}
|
}
|
||||||
else if(command==COMMAND_QUIET){
|
else if(command==COMMAND_QUIET){
|
||||||
quiet(parameters.K1, parameters.K2, parameters.N1, parameters.N2, parameters.final_time, parameters.nu, parameters.delta, parameters.L, parameters.adaptive_tolerance, parameters.adaptive_factor, parameters.max_delta, parameters.adaptive_norm, parameters.starting_time, u0, g, parameters.irreversible, parameters.keep_en_cst, parameters.init_en, parameters.algorithm, nthreads, savefile);
|
quiet(parameters.K1, parameters.K2, parameters.N1, parameters.N2, parameters.final_time, parameters.nu, parameters.delta, parameters.L, parameters.adaptive_tolerance, parameters.adaptive_factor, parameters.max_delta, parameters.adaptive_norm, parameters.starting_time, u0, g, parameters.irreversible, parameters.keep_en_cst, parameters.init_en, parameters.algorithm, nthreads, savefile);
|
||||||
@ -555,6 +556,8 @@ int set_default_params(
|
|||||||
parameters->algorithm=ALGORITHM_RK4;
|
parameters->algorithm=ALGORITHM_RK4;
|
||||||
parameters->keep_en_cst=false;
|
parameters->keep_en_cst=false;
|
||||||
|
|
||||||
|
parameters->print_alpha=false;
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -885,6 +888,15 @@ int set_parameter(
|
|||||||
}
|
}
|
||||||
parameters->keep_en_cst=(tmp==1);
|
parameters->keep_en_cst=(tmp==1);
|
||||||
}
|
}
|
||||||
|
else if (strcmp(lhs,"print_alpha")==0){
|
||||||
|
int tmp;
|
||||||
|
ret=sscanf(rhs,"%d",&tmp);
|
||||||
|
if(ret!=1 || (tmp!=0 && tmp!=1)){
|
||||||
|
fprintf(stderr, "error: parameter 'print_alpha' should be 0 or 1\n got '%s'\n",rhs);
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
parameters->print_alpha=(tmp==1);
|
||||||
|
}
|
||||||
else{
|
else{
|
||||||
fprintf(stderr, "error: unrecognized parameter '%s'\n",lhs);
|
fprintf(stderr, "error: unrecognized parameter '%s'\n",lhs);
|
||||||
return(-1);
|
return(-1);
|
||||||
|
@ -145,6 +145,7 @@ int enstrophy(
|
|||||||
unsigned int algorithm,
|
unsigned int algorithm,
|
||||||
double print_freq,
|
double print_freq,
|
||||||
double starting_time,
|
double starting_time,
|
||||||
|
bool print_alpha,
|
||||||
unsigned int nthreads,
|
unsigned int nthreads,
|
||||||
FILE* savefile,
|
FILE* savefile,
|
||||||
FILE* utfile,
|
FILE* utfile,
|
||||||
@ -236,7 +237,7 @@ int enstrophy(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// print alpha when it gets negative
|
// print alpha when it gets negative
|
||||||
if(alpha<0){
|
if(print_alpha && alpha<0){
|
||||||
fprintf(stderr,"## negative alpha: % .8e at time % .8e\n",alpha, time);
|
fprintf(stderr,"## negative alpha: % .8e at time % .8e\n",alpha, time);
|
||||||
printf("## negative alpha: % .15e at time % .15e\n",alpha, time);
|
printf("## negative alpha: % .15e at time % .15e\n",alpha, time);
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ typedef struct fft_vects {
|
|||||||
int uk( int K1, int K2, int N1, int N2, double final_time, double nu, double delta, double L, double adaptive_tolerance, double adaptive_factor, double max_delta, unsigned int adaptive_norm, _Complex double* u0, _Complex double* g, bool irreversible, bool keep_en_cst, double target_en, unsigned int algorithm, double print_freq, double starting_time, unsigned int nthreadsl, FILE* savefile);
|
int uk( int K1, int K2, int N1, int N2, double final_time, double nu, double delta, double L, double adaptive_tolerance, double adaptive_factor, double max_delta, unsigned int adaptive_norm, _Complex double* u0, _Complex double* g, bool irreversible, bool keep_en_cst, double target_en, unsigned int algorithm, double print_freq, double starting_time, unsigned int nthreadsl, FILE* savefile);
|
||||||
|
|
||||||
// compute enstrophy and alpha
|
// compute enstrophy and alpha
|
||||||
int enstrophy( int K1, int K2, int N1, int N2, double final_time, double nu, double delta, double L, double adaptive_tolerance, double adaptive_factor, double max_delta, unsigned int adaptive_norm, _Complex double* u0, _Complex double* g, bool irreversible, bool keep_en_cst, double target_en, unsigned int algorithm, double print_freq, double starting_time, unsigned int nthreads, FILE* savefile, FILE* utfile, const char* cmd_string, const char* params_string, const char* savefile_string, const char* utfile_string);
|
int enstrophy( int K1, int K2, int N1, int N2, double final_time, double nu, double delta, double L, double adaptive_tolerance, double adaptive_factor, double max_delta, unsigned int adaptive_norm, _Complex double* u0, _Complex double* g, bool irreversible, bool keep_en_cst, double target_en, unsigned int algorithm, double print_freq, double starting_time, bool print_alpha, unsigned int nthreads, FILE* savefile, FILE* utfile, const char* cmd_string, const char* params_string, const char* savefile_string, const char* utfile_string);
|
||||||
|
|
||||||
// compute solution as a function of time, but do not print anything (useful for debugging)
|
// compute solution as a function of time, but do not print anything (useful for debugging)
|
||||||
int quiet( int K1, int K2, int N1, int N2, double final_time, double nu, double delta, double L, double adaptive_tolerance, double adaptive_factor, double max_delta, unsigned int adaptive_norm, double starting_time, _Complex double* u0, _Complex double* g, bool irreversible, bool keep_en_cst, double target_en, unsigned int algorithm, unsigned int nthreads, FILE* savefile);
|
int quiet( int K1, int K2, int N1, int N2, double final_time, double nu, double delta, double L, double adaptive_tolerance, double adaptive_factor, double max_delta, unsigned int adaptive_norm, double starting_time, _Complex double* u0, _Complex double* g, bool irreversible, bool keep_en_cst, double target_en, unsigned int algorithm, unsigned int nthreads, FILE* savefile);
|
||||||
|
Loading…
Reference in New Issue
Block a user