forked from csc-training/mpi-introduction
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheat.h
69 lines (48 loc) · 1.91 KB
/
heat.h
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef __HEAT_H__
#define __HEAT_H__
/* Datatype for temperature field */
typedef struct {
/* nx and ny are the true dimensions of the field. The array data
* contains also ghost layers, so it will have dimensions nx+2 x ny+2 */
int nx; /* Local dimensions of the field */
int ny;
int nx_full; /* Global dimensions of the field */
int ny_full; /* Global dimensions of the field */
double dx;
double dy;
double *data;
} field;
/* Datatype for basic parallelization information */
typedef struct {
int size; /* Number of MPI tasks */
int rank;
int nup, ndown; /* Ranks of neighbouring MPI tasks */
} parallel_data;
/* We use here fixed grid spacing */
#define DX 0.01
#define DY 0.01
#if __cplusplus
extern "C" {
#endif
/* Function prototypes */
void set_field_dimensions(field *temperature, int nx, int ny,
parallel_data *parallel);
void parallel_setup(parallel_data *parallel, int nx, int ny);
void parallel_set_dimensions(parallel_data *parallel, int nx, int ny);
void initialize(int argc, char *argv[], field *temperature1,
field *temperature2, int *nsteps, parallel_data *parallel);
void generate_field(field *temperature, parallel_data *parallel);
double average(field *temperature);
void exchange(field *temperature, parallel_data *parallel);
void evolve(field *curr, field *prev, double a, double dt);
void write_field(field *temperature, int iter, parallel_data *parallel);
void read_field(field *temperature1, field *temperature2,
char *filename, parallel_data *parallel);
void copy_field(field *temperature1, field *temperature2);
void swap_fields(field *temperature1, field *temperature2);
void allocate_field(field *temperature);
void finalize(field *temperature1, field *temperature2);
#if __cplusplus
}
#endif
#endif /* __HEAT_H__ */