aboutsummaryrefslogtreecommitdiff
path: root/Carpet/CarpetReduce/src/mask_init.c
blob: 77e0d77e283ff950bed8880411d753d4bbce9b3f (plain)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/* $Header:$ */

#include "cctk.h"
#include "cctk_Arguments.h"
#include "cctk_Parameters.h"

#include "util_Table.h"



void
MaskBase_InitMask (CCTK_ARGUMENTS)
{
  DECLARE_CCTK_ARGUMENTS;
  DECLARE_CCTK_PARAMETERS;
  
#if 0
  CCTK_INT symtable;
  CCTK_INT symmetry_handle[6];
  CCTK_INT symmetry_zone_width[6];
#endif
  
  int imin[3], imax[3];         /* boundary extent */
  
  int i, j, k;
  int d, f;
  int dd;
  
#if 0
  int istat;
#endif
  
  
  
  /* Initialise the weight to 1 everywhere */
  if (verbose) {
    CCTK_INFO ("Initialising to weight 1");
  }
  
  for (k=0; k<cctk_lsh[2]; ++k) {
    for (j=0; j<cctk_lsh[1]; ++j) {
      for (i=0; i<cctk_lsh[0]; ++i) {
        
        int const ind = CCTK_GFINDEX3D (cctkGH, i, j, k);
        weight[ind] = 1.0;
        
      }
    }
  }
  
  
  
  /* Set the weight to 0 on inter-processor boundaries */
  if (verbose) {
    CCTK_INFO ("Setting inter-processor boundaries to weight 0");
  }
  
  /* Loop over all dimensions and faces */
  for (d=0; d<3; ++d) {
    for (f=0; f<2; ++f) {
      /* If this is an inter-processor boundary */
      if (! cctk_bbox[2*d+f]) {
        
        /* Calculate the extent of the boundary hyperslab */
        for (dd=0; dd<3; ++dd) {
          imin[dd] = 0;
          imax[dd] = cctk_lsh[dd];
        }
        if (f==0) {
          /* lower face */
          imax[d] = imin[d] + cctk_nghostzones[d];
        } else {
          /* upper face */
          imin[d] = imax[d] - cctk_nghostzones[d];
        }
        
        /* Loop over the boundary slab */
        for (k=imin[2]; k<imax[2]; ++k) {
          for (j=imin[1]; j<imax[1]; ++j) {
            for (i=imin[0]; i<imax[0]; ++i) {
              
              int const ind = CCTK_GFINDEX3D (cctkGH, i, j, k);
              weight[ind] = 0.0;
              
            }
          }
        }
        
      }
    }
  }
  
  
  
#if 0
  
  /* Take the symmetry boundaries into account */
  if (verbose) {
    CCTK_INFO ("Setting symmetry boundaries to weight 0");
  }
  
  /* Get symmetry information */
  symtable = SymmetryTableHandleForGrid (cctkGH);
  if (symtable < 0) {
    CCTK_WARN (0, "Could not get symmetry table");
  }
  istat = Util_TableGetIntArray
    (symtable, 6, symmetry_handle, "symmetry_handle");
  if (istat != 6) {
    CCTK_WARN (0, "Could not get \"symmetry_handle\" entry from symmetry table");
  }
  istat = Util_TableGetIntArray
    (symtable, 6, symmetry_zone_width, "symmetry_zone_width");
  if (istat != 6) {
    CCTK_WARN (0, "Could not get \"symmetry_zone_width\" entry from symmetry table");
  }
  
  /* Loop over all dimensions and faces */
  for (d=0; d<3; ++d) {
    for (f=0; f<2; ++f) {
      /* If this is a symmetry face */
      if (symmetry_handle[2*d+f] >= 0) {
        /* If this processor has the outer boundary */
        if (cctk_bbox[2*d+f]) {
          
          if (symmetry_zone_width[2*d+f] < 0
              || symmetry_zone_width[2*d+f] > cctk_lsh[d]) {
            CCTK_WARN (0, "The symmetry table entry \"symmetry_zone_width\" contains illegal values");
          }
          
          /* Calculate the extent of the boundary hyperslab */
          for (dd=0; dd<3; ++dd) {
            imin[dd] = 0;
            imax[dd] = cctk_lsh[dd];
          }
          if (f==0) {
            /* lower face */
            imax[d] = imin[d] + symmetry_zone_width[2*d+f];
          } else {
            /* upper face */
            imin[d] = imax[d] - symmetry_zone_width[2*d+f];
          }
          
          /* Loop over the boundary slab */
          for (k=imin[2]; k<imax[2]; ++k) {
            for (j=imin[1]; j<imax[1]; ++j) {
              for (i=imin[0]; i<imax[0]; ++i) {
        
                int const ind = CCTK_GFINDEX3D (cctkGH, i, j, k);
                weight[ind] = 0.0;
                
              }
            }
          }
          
        }
      }
    }
  }
#endif
}