|
9 | 9 | from collections import namedtuple |
10 | 10 |
|
11 | 11 |
|
12 | | -def soa_real_comps(self, num_comps, spacedim=3, rotate=True): |
13 | | - """ |
14 | | - Name the ParticleReal components in SoA. |
15 | | -
|
16 | | - Parameters |
17 | | - ---------- |
18 | | - self : SoA Type |
19 | | - maybe unused, depending on implementation |
20 | | - num_comps : int |
21 | | - number of components to generate names for. |
22 | | - spacedim : int |
23 | | - AMReX dimensionality |
24 | | - rotate : bool = True |
25 | | - start with "x", "y", "z", "a", "b", ... |
26 | | -
|
27 | | - Returns |
28 | | - ------- |
29 | | - A list of length num_comps with values |
30 | | - rotate=True (for pure SoA layout): |
31 | | - - 3D: "x", "y", "z", "a", "b", ... "w", "r0", "r1", ... |
32 | | - - 2D: "x", "y", "a", "b", ... "w", "r0", "r1", ... |
33 | | - - 1D: "x", "a", "b", ... "w", "r0", "r1", ... |
34 | | - rotate=False (for legacy layout): |
35 | | - - 1D-3D: "a", "b", ... "w", "r0", "r1", ... |
36 | | - """ |
37 | | - import string |
38 | | - |
39 | | - # x, y, z, a, b, ... |
40 | | - comp_names = list(string.ascii_lowercase) |
41 | | - if rotate: |
42 | | - # rotate x, y, z to be beginning (positions) |
43 | | - comp_names = comp_names[-3:] + comp_names[:-3] |
44 | | - else: |
45 | | - # cut off x, y, z to avoid confusion |
46 | | - comp_names = comp_names[:-3] |
47 | | - |
48 | | - num_named = len(comp_names) |
49 | | - if num_comps < num_named: |
50 | | - comp_names = list(comp_names)[0:num_comps] |
51 | | - elif num_comps > num_named: |
52 | | - comp_names.extend(["r" + str(i) for i in range(num_comps - num_named)]) |
53 | | - |
54 | | - return comp_names |
55 | | - |
56 | | - |
57 | | -def soa_int_comps(self, num_comps): |
58 | | - """ |
59 | | - Name the int components in SoA. |
60 | | -
|
61 | | - Parameters |
62 | | - ---------- |
63 | | - self : SoA Type |
64 | | - maybe unused, depending on implementation |
65 | | - num_comps : int |
66 | | - number of components to generate names for. |
67 | | -
|
68 | | - Returns |
69 | | - ------- |
70 | | - A list of length num_comps with values "i1", "i2", "i3", ... |
71 | | - """ |
72 | | - comp_names = ["i" + str(i) for i in range(num_comps)] |
73 | | - |
74 | | - return comp_names |
75 | | - |
76 | | - |
77 | 12 | def soa_to_numpy(self, copy=False): |
78 | 13 | """ |
79 | 14 | Provide NumPy views into a StructOfArrays. |
@@ -226,10 +161,6 @@ def register_SoA_extension(amr): |
226 | 161 | and member.__module__ == amr.__name__ |
227 | 162 | and member.__name__.startswith("StructOfArrays_"), |
228 | 163 | ): |
229 | | - # name providers |
230 | | - SoA_type.soa_real_comps = soa_real_comps |
231 | | - SoA_type.soa_int_comps = soa_int_comps |
232 | | - |
233 | 164 | # converters |
234 | 165 | SoA_type.to_numpy = soa_to_numpy |
235 | 166 | SoA_type.to_cupy = soa_to_cupy |
|
0 commit comments