1//---------------------------------------------------------------------
2//---------------------------------------------------------------------
3#include "header.h"
4
5void compute_buffer_size(int dim) {
6
7//---------------------------------------------------------------------
8//---------------------------------------------------------------------
9
10      int  c, face_size;
11
12      if (ncells == 1) return;
13
14//---------------------------------------------------------------------
15//     compute the actual sizes of the buffers; note that there is
16//     always one cell face that doesn't need buffer space, because it
17//     is at the boundary of the grid
18//---------------------------------------------------------------------
19      west_size = 0;
20      east_size = 0;
21
22      for (c = 1; c <= ncells; c++) {
23         face_size = cell_size(2,c) * cell_size(3,c) * dim * 2;
24         if (cell_coord(1,c)!=1) west_size = west_size + face_size;
25         if (cell_coord(1,c)!=ncells) east_size = east_size +
26              face_size ;
27      }
28
29      north_size = 0;
30      south_size = 0;
31      for (c = 1; c <= ncells; c++) {
32         face_size = cell_size(1,c)*cell_size(3,c) * dim * 2;
33         if (cell_coord(2,c)!=1) south_size = south_size + face_size;
34         if (cell_coord(2,c)!=ncells) north_size = north_size +
35              face_size ;
36      }
37
38      top_size = 0;
39      bottom_size = 0;
40      for (c = 1; c <= ncells; c++) {
41         face_size = cell_size(1,c) * cell_size(2,c) * dim * 2;
42         if (cell_coord(3,c)!=1) bottom_size = bottom_size +
43              face_size;
44         if (cell_coord(3,c)!=ncells) top_size = top_size +
45              face_size     ;
46      }
47
48      start_send_west   = 1;
49      start_send_east   = start_send_west   + west_size;
50      start_send_south  = start_send_east   + east_size;
51      start_send_north  = start_send_south  + south_size;
52      start_send_bottom = start_send_north  + north_size;
53      start_send_top    = start_send_bottom + bottom_size;
54      start_recv_west   = 1;
55      start_recv_east   = start_recv_west   + west_size;
56      start_recv_south  = start_recv_east   + east_size;
57      start_recv_north  = start_recv_south  + south_size;
58      start_recv_bottom = start_recv_north  + north_size;
59      start_recv_top    = start_recv_bottom + bottom_size;
60
61      return;
62}
63
64