aboutsummaryrefslogtreecommitdiff
path: root/Carpet/CarpetRegrid2/src/property.hh
blob: d5540d6fe1792e995db4fa30750174195363e179 (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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#ifndef PROPERTY_HH
#define PROPERTY_HH

// Consistency properties for the grid structure

#include <vector>

#include <bboxset.hh>
#include <defs.hh>
#include <dh.hh>
#include <gh.hh>



namespace CarpetRegrid2 {
  
  
  
  // Each property consists of a test, which returns true or false
  // depending on whether the property is satisfied, and an action
  // that enforces the property.
  class property {
  protected:
    virtual bool test_impl (gh const& hh, dh const& dd,
                            level_boundary const& bnd,
                            vector<ibset> const& regions, int rl) = 0;
    virtual void enforce_impl (gh const& hh, dh const& dd,
                               level_boundary const& bnd,
                               vector<ibset>& regions, int rl) = 0;
  public:
    virtual ~property() {}
    bool test (gh const& hh, dh const& dd,
               level_boundary const& bnd,
               vector<ibset> const& regions, int rl);
    void enforce (gh const& hh, dh const& dd,
                  level_boundary const& bnd,
                  vector<ibset>& regions, int rl);
  };
  
  
  
  // Ensure that this grid contains the next finer grid
  class proper_nesting: public property {
    ibset enlarged_fine_grid (gh const& hh, dh const& dd,
                              level_boundary const& bnd,
                              vector<ibset> const& regions, int rl);
    bool test_impl (gh const& hh, dh const& dd,
                    level_boundary const& bnd,
                     vector<ibset> const& regions, int rl);
    void enforce_impl (gh const& hh, dh const& dd,
                       level_boundary const& bnd,
                       vector<ibset>& regions, int rl);
  };
  
  
  
  // Add buffer zones (do this only once)
  class add_buffers: public property {
    ibset buffered_regions (gh const& hh, dh const& dd,
                            level_boundary const& bnd,
                            vector<ibset> const& regions, int rl);
    bool test_impl (gh const& hh, dh const& dd,
                    level_boundary const& bnd,
                    vector<ibset> const& regions, int rl);
    void enforce_impl (gh const& hh, dh const& dd,
                       level_boundary const& bnd,
                       vector<ibset>& regions, int rl);
  };
  
  
  
  // Combine all regions into a single region, if this is worthwhile
  class combine_regions: public property {
    ibbox combined_regions (gh const& hh, dh const& dd,
                            level_boundary const& bnd,
                            vector<ibset> const& regions, int rl);
    bool test_impl (gh const& hh, dh const& dd,
                    level_boundary const& bnd,
                    vector<ibset> const& regions, int rl);
    void enforce_impl (gh const& hh, dh const& dd,
                       level_boundary const& bnd,
                       vector<ibset>& regions, int rl);
  };
  
  
  
  // Align the boxes with the next coarser grid
  class snap_coarse: public property {
    ibset snapped_regions (gh const& hh, dh const& dd,
                           level_boundary const& bnd,
                           vector<ibset> const& regions, int rl);
    bool test_impl (gh const& hh, dh const& dd,
                    level_boundary const& bnd,
                    vector<ibset> const& regions, int rl);
    void enforce_impl (gh const& hh, dh const& dd,
                       level_boundary const& bnd,
                       vector<ibset>& regions, int rl);
  };
  
  
  
  // Make the boxes rotating-90 symmetric
  class rotsym90: public property {
    ibset symmetrised_regions (gh const& hh, dh const& dd,
                               level_boundary const& bnd,
                               vector<ibset> const& regions, int rl);
    bool test_impl (gh const& hh, dh const& dd,
                    level_boundary const& bnd,
                    vector<ibset> const& regions, int rl);
    void enforce_impl (gh const& hh, dh const& dd,
                       level_boundary const& bnd,
                       vector<ibset>& regions, int rl);
  };
  
  
  
  // Make the boxes rotating-180 symmetric
  class rotsym180: public property {
    ibset symmetrised_regions (gh const& hh, dh const& dd,
                               level_boundary const& bnd,
                               vector<ibset> const& regions, int rl);
    bool test_impl (gh const& hh, dh const& dd,
                    level_boundary const& bnd,
                    vector<ibset> const& regions, int rl);
    void enforce_impl (gh const& hh, dh const& dd,
                       level_boundary const& bnd,
                       vector<ibset>& regions, int rl);
  };
  
  
  
  // Make the boxes periodic in one direction
  template<int dir>
  class periodic: public property {
    ibset symmetrised_regions (gh const& hh, dh const& dd,
                               level_boundary const& bnd,
                               vector<ibset> const& regions, int rl);
    bool test_impl (gh const& hh, dh const& dd,
                    level_boundary const& bnd,
                    vector<ibset> const& regions, int rl);
    void enforce_impl (gh const& hh, dh const& dd,
                       level_boundary const& bnd,
                       vector<ibset>& regions, int rl);
  };
  
  
  
  // Clip at the outer boundary
  class boundary_clip: public property {
    ibset clipped_regions (gh const& hh, dh const& dd,
                           level_boundary const& bnd,
                           vector<ibset> const& regions, int rl);
    bool test_impl (gh const& hh, dh const& dd,
                    level_boundary const& bnd,
                    vector<ibset> const& regions, int rl);
    void enforce_impl (gh const& hh, dh const& dd,
                       level_boundary const& bnd,
                       vector<ibset>& regions, int rl);
  };
  
  
  
  // Ensure that this grid is contained in the domain
  class in_domain: public property {
    bool test_impl (gh const& hh, dh const& dd,
                    level_boundary const& bnd,
                    vector<ibset> const& regions, int rl);
    void enforce_impl (gh const& hh, dh const& dd,
                       level_boundary const& bnd,
                       vector<ibset>& regions, int rl);
  };
  
  
  
  // Ensure that this grid is symmetric, if desired
  class is_symmetric: public property {
    ibset symmetrised_regions (gh const& hh, dh const& dd,
                               level_boundary const& bnd,
                               vector<ibset> const& regions, int rl);
    bool test_impl (gh const& hh, dh const& dd,
                    level_boundary const& bnd,
                    vector<ibset> const& regions, int rl);
    void enforce_impl (gh const& hh, dh const& dd,
                       level_boundary const& bnd,
                       vector<ibset>& regions, int rl);
  };
  
  
  
} // namespace CarpetRegrid2



#endif  // #ifndef PROPERTY_HH