-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathoutput.cpp
40 lines (25 loc) · 911 Bytes
/
output.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//#include "output.h"
#include "poisson.h"
namespace poisson {
void write_output(Domain domain, int proc_rank) {
int i,l,m;
int N_local = domain.u->N;
int N_local_x = domain.u->Nx;
int N_local_y = domain.u->Ny;
FILE *fp;
char filename[10];
//offset of cell numbering for the subdomain
offset[X_DIR] = P_grid_coord[X_DIR] * (N_local_x-2);
offset[Y_DIR] = P_grid_coord[Y_DIR] * (N_local_y-2);
sprintf(filename, "data%d", proc_rank);
fp = fopen(filename, "w");
for(i=0;i<N_local;i++){
if(domain.u->bc[i] == NONE){
l=i%N_local_x;
m=(int) i/N_local_x;
fprintf(fp,"%lf %lf %lf\n", (l+offset[X_DIR])*(domain.constant->h), (m+offset[Y_DIR])*(domain.constant->h), domain.u->val[i]);
}
}
fclose(fp);
}
}