@@ -54,18 +54,15 @@ def run(n, backend, datatype, benchmark_mode):
54
54
if backend == "sharpy" :
55
55
import sharpy as np
56
56
from sharpy import fini , init , sync
57
- from sharpy .numpy import fromfunction as _fromfunction
58
57
59
58
device = os .getenv ("SHARPY_DEVICE" , "" )
60
59
create_full = partial (np .full , device = device )
61
- fromfunction = partial (_fromfunction , device = device )
62
60
63
61
all_axes = [0 , 1 ]
64
62
init (False )
65
63
66
64
elif backend == "numpy" :
67
65
import numpy as np
68
- from numpy import fromfunction
69
66
70
67
if comm is not None :
71
68
assert (
@@ -110,17 +107,24 @@ def run(n, backend, datatype, benchmark_mode):
110
107
t_export = 0.02
111
108
t_end = 1.0
112
109
113
- # coordinate arrays
114
- x_t_2d = fromfunction (
115
- lambda i , j : xmin + i * dx + dx / 2 , (nx , ny ), dtype = dtype
116
- )
117
- y_t_2d = fromfunction (
118
- lambda i , j : ymin + j * dy + dy / 2 , (nx , ny ), dtype = dtype
119
- )
110
+ def ind_arr (shape , columns = False ):
111
+ """Construct an (nx, ny) array where each row/col is an arange"""
112
+ nx , ny = shape
113
+ if columns :
114
+ ind = np .arange (0 , nx * ny , 1 , dtype = np .int32 ) % nx
115
+ ind = np .reshape (ind , (ny , nx ))
116
+ ind = np .permute_dims (ind , [1 , 0 ])
117
+ else :
118
+ ind = np .arange (0 , nx * ny , 1 , dtype = np .int32 ) % ny
119
+ ind = np .reshape (ind , (nx , ny ))
120
+ return ind .astype (dtype )
120
121
122
+ # coordinate arrays
121
123
T_shape = (nx , ny )
122
124
U_shape = (nx + 1 , ny )
123
125
V_shape = (nx , ny + 1 )
126
+ x_t_2d = xmin + ind_arr (T_shape , True ) * dx + dx / 2
127
+ y_t_2d = ymin + ind_arr (T_shape ) * dy + dy / 2
124
128
125
129
dofs_T = int (numpy .prod (numpy .asarray (T_shape )))
126
130
dofs_U = int (numpy .prod (numpy .asarray (U_shape )))
0 commit comments