Function that post processes the moments to obtain final quantities of interest. ! Function where the user enters computes quantities of interest from the solution. External function to compute user defined post processor routines.
In this example the moments equations are solved and this function is called by passing the moments at a particular time. The quantities of interest are chosen to be the non-dimensional scaled moments that become independent of time when the distribution becomes self preserving.
Open a file called output.txt FILE *fp; fp = fopen("output.txt", "a"); if(fp == NULL) { perror("failed to open output.txt"); return; } If verbose mode then print to stdout as well. Note that the vectors in this example contain the moments in the order [M_0, M_1, ..., M_{tot}]. The scaled moments that are being printed out are : (M_2/M_0)*(M_0/M_1)^2, (M_3/M_0)*(M_0/M_1)^3, (M_4/M_0)*(M_0/M_1)^4, (M53/M_0)*(M_0/M_1)^5 if(verbose_mode == 1){ printf("%.5e %10.5e %10.5e %10.5e %10.5e \n", time, (y[2]/y[0])*pow(y[0]/y[1],2.0), (y[3]/y[0])*pow(y[0]/y[1],3.0), (y[4]/y[0])*pow(y[0]/y[1],4.0), (y[5]/y[0])*pow(y[0]/y[1],5.0));} Print to the same to file output.txt. Note that new lines are added to this file as time progresses. This also means that before a new simulation is started, the file output.txt must be deleted. Otherwise new lines are added at the bottom of the existing file. fprintf(fp,"%.5e %10.5e %10.5e %10.5e %10.5e \n",
time, (y[2]/y[0])*pow(y[0]/y[1],2.0),
(y[3]/y[0])*pow(y[0]/y[1],3.0),
(y[4]/y[0])*pow(y[0]/y[1],4.0),
(y[5]/y[0])*pow(y[0]/y[1],5.0));
fclose(fp); Return control to the calling routines. return;
}
|