|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- #include "gridRoutines.h"
-
- typedef struct UserDataTag{
- UserGrid grid;
- FILE* gridOutput;
- } *UserData;
-
- int main(){
-
- int ier=0;
-
- UserData data;
- data = (UserData) malloc(sizeof *data);
- data->grid=(UserGrid) malloc(sizeof *data->grid);
- FILE *input;input=fopen("input.dat","r");
- ier=getGridSettings(input,data->grid);
- if(ier==-1)return(-1);
- fclose(input);
-
- ier=initializeGrid(data->grid);
- if(ier==-1)return(-1);
-
- ier=reGrid(data->grid, data->grid->position);
- if(ier==-1)return(-1);
-
- FILE* output1;output1=fopen("grid.dat","w");
- for(size_t i=0;i<data->grid->nPts;i++){
- if(i==0){
- fprintf(output1, "%ld\t%15.15e\t%15.15e\n",i,data->grid->x[i],data->grid->x[1]-data->grid->x[0]);
- }
- else{
- fprintf(output1, "%ld\t%15.15e\t%15.15e\n",i,data->grid->x[i],data->grid->x[i]-data->grid->x[i-1]);
- }
- }
- fclose(output1);
-
-
- if(data->grid->xOld!=NULL){
- delete[] data->grid->xOld;
- printf("old grid array Deleted!\n");
- }
- if(data->grid->x!=NULL){
- delete[] data->grid->x;
- printf("current grid array Deleted!\n");
- }
- if(data->grid!=NULL){
- free(data->grid);
- printf("grid object Freed!\n");
- }
-
- return(0);
- }
|