|
1 | 1 | from devito.types.dimension import Thickness |
2 | 2 |
|
3 | 3 |
|
4 | | -class SubDimMax(Thickness): |
5 | | - """ |
6 | | - Local index of a SubDimension's right global boundary, which may not correspond |
7 | | - to a locally owned point. Not used for indexing into data. |
8 | | - """ |
| 4 | +class _SubDimBound(Thickness): |
9 | 5 | def __init_finalize__(self, *args, **kwargs): |
10 | 6 | self._subdim = kwargs.pop('subdim') |
11 | 7 | self._dtype = self._subdim.dtype |
12 | | - |
13 | 8 | super().__init_finalize__(*args, **kwargs) |
14 | 9 |
|
15 | 10 | @property |
16 | 11 | def subdim(self): |
17 | 12 | return self._subdim |
18 | 13 |
|
| 14 | + |
| 15 | +class _SpaceDimBound(Thickness): |
| 16 | + def __init_finalize__(self, *args, **kwargs): |
| 17 | + self._space_dim = kwargs.pop('space_dim') |
| 18 | + self._dtype = self._space_dim.dtype |
| 19 | + super().__init_finalize__(*args, **kwargs) |
| 20 | + |
| 21 | + @property |
| 22 | + def space_dim(self): |
| 23 | + return self._space_dim |
| 24 | + |
| 25 | + |
| 26 | +class SubDimMax(_SubDimBound): |
| 27 | + """ |
| 28 | + Local index of a SubDimension's right global boundary, which may not correspond |
| 29 | + to a locally owned point. Not used for indexing into data. |
| 30 | + """ |
19 | 31 | def _arg_values(self, grid=None, **kwargs): |
20 | 32 | dist = grid.distributor |
21 | | - # global rtkn |
22 | 33 | grtkn = kwargs.get(self.subdim.rtkn.name, self.subdim.rtkn.value) |
23 | | - # decomposition info |
24 | 34 | decomp = dist.decomposition[self.subdim.parent] |
25 | | - glb_max = decomp.glb_max |
26 | | - val = decomp.index_glb_to_loc_unsafe(glb_max - grtkn) |
| 35 | + val = decomp.index_glb_to_loc_unsafe(decomp.glb_max - grtkn) |
27 | 36 | return {self.name: int(val)} |
28 | 37 |
|
29 | 38 |
|
30 | | -class SubDimMin(Thickness): |
| 39 | +class SubDimMin(_SubDimBound): |
31 | 40 | """ |
32 | 41 | Local index of a SubDimension's left global boundary, which may not correspond |
33 | 42 | to a locally owned point. Not used for indexing into data. |
34 | 43 | """ |
35 | | - def __init_finalize__(self, *args, **kwargs): |
36 | | - self._subdim = kwargs.pop('subdim') |
37 | | - self._dtype = self._subdim.dtype |
38 | | - |
39 | | - super().__init_finalize__(*args, **kwargs) |
40 | | - |
41 | | - @property |
42 | | - def subdim(self): |
43 | | - return self._subdim |
44 | | - |
45 | 44 | def _arg_values(self, grid=None, **kwargs): |
46 | 45 | dist = grid.distributor |
47 | | - # global ltkn |
48 | 46 | gltkn = kwargs.get(self.subdim.ltkn.name, self.subdim.ltkn.value) |
49 | | - # decomposition info |
50 | 47 | decomp = dist.decomposition[self.subdim.parent] |
51 | | - glb_min = decomp.glb_min |
52 | | - val = decomp.index_glb_to_loc_unsafe(glb_min + gltkn) |
| 48 | + val = decomp.index_glb_to_loc_unsafe(decomp.glb_min + gltkn) |
53 | 49 | return {self.name: int(val)} |
54 | 50 |
|
55 | 51 |
|
56 | | -class SpaceDimMax(Thickness): |
| 52 | +class SpaceDimMax(_SpaceDimBound): |
57 | 53 | """ |
58 | 54 | Local index of a SpaceDimension's right global boundary, which may not correspond |
59 | 55 | to a locally owned point. Not used for indexing into data. |
60 | 56 | """ |
61 | | - def __init_finalize__(self, *args, **kwargs): |
62 | | - self._space_dim = kwargs.pop('space_dim') |
63 | | - self._dtype = self._space_dim.dtype |
64 | | - |
65 | | - super().__init_finalize__(*args, **kwargs) |
66 | | - |
67 | | - @property |
68 | | - def space_dim(self): |
69 | | - return self._space_dim |
70 | | - |
71 | 57 | def _arg_values(self, grid=None, **kwargs): |
72 | 58 | dist = grid.distributor |
73 | 59 | decomp = dist.decomposition[self.space_dim] |
74 | | - glb_max = decomp.glb_max |
75 | | - val = decomp.index_glb_to_loc_unsafe(glb_max) |
| 60 | + val = decomp.index_glb_to_loc_unsafe(decomp.glb_max) |
76 | 61 | return {self.name: int(val)} |
77 | 62 |
|
78 | 63 |
|
79 | | -class SpaceDimMin(Thickness): |
| 64 | +class SpaceDimMin(_SpaceDimBound): |
80 | 65 | """ |
81 | 66 | Local index of a SpaceDimension's left global boundary, which may not correspond |
82 | 67 | to a locally owned point. Not used for indexing into data. |
83 | 68 | """ |
84 | | - def __init_finalize__(self, *args, **kwargs): |
85 | | - self._space_dim = kwargs.pop('space_dim') |
86 | | - self._dtype = self._space_dim.dtype |
87 | | - |
88 | | - super().__init_finalize__(*args, **kwargs) |
89 | | - |
90 | | - @property |
91 | | - def space_dim(self): |
92 | | - return self._space_dim |
93 | | - |
94 | 69 | def _arg_values(self, grid=None, **kwargs): |
95 | 70 | dist = grid.distributor |
96 | 71 | decomp = dist.decomposition[self.space_dim] |
97 | | - glb_min = decomp.glb_min |
98 | | - val = decomp.index_glb_to_loc_unsafe(glb_min) |
| 72 | + val = decomp.index_glb_to_loc_unsafe(decomp.glb_min) |
99 | 73 | return {self.name: int(val)} |
0 commit comments