@@ -550,24 +550,24 @@ function get_ind(x, xc, Nprocx)
550
550
end
551
551
552
552
# Same as get_ind but without the need for the x vector
553
- function get_ind2 (dx,xc,Nprocx)
553
+ function get_ind2 (dx, xc, Nprocx)
554
554
555
555
if Nprocx == 1
556
- xi = Int (round ((xc[end ] - xc[1 ]) / dx));
557
- ix_start = [1 ];
558
- ix_end = [xi];
556
+ xi = Int (round ((xc[end ] - xc[1 ]) / dx))
557
+ ix_start = [1 ]
558
+ ix_end = [xi]
559
559
else
560
560
xi = zeros (Int64, Nprocx)
561
- for k = 1 : Nprocx
562
- xi[k] = round ((xc[k+ 1 ] - xc[k])/ dx);
561
+ for k in 1 : Nprocx
562
+ xi[k] = round ((xc[k + 1 ] - xc[k]) / dx)
563
563
end
564
564
565
565
ix_start = cumsum ([0 ; xi[1 : (end - 1 )]]) .+ 1
566
566
ix_end = cumsum (xi[1 : end ])
567
567
568
568
end
569
569
570
- return xi,ix_start,ix_end
570
+ return xi, ix_start, ix_end
571
571
572
572
end
573
573
@@ -1112,11 +1112,7 @@ function Base.show(io::IO, d::LaMEM_partitioning_info)
1112
1112
end
1113
1113
1114
1114
function check_markers_directory (directory)
1115
-
1116
- if ! isdir (directory)
1117
- mkdir (directory)
1118
- end
1119
-
1115
+ return if ! isdir (directory) mkdir (directory) end
1120
1116
end
1121
1117
1122
1118
function get_LaMEM_grid_info (file; args:: Union{String, Nothing} = nothing )
@@ -1151,13 +1147,13 @@ function get_LaMEM_grid_info(file; args::Union{String, Nothing} = nothing)
1151
1147
Grid = LaMEM_grid (
1152
1148
nmark_x, nmark_y, nmark_z,
1153
1149
nump_x, nump_y, nump_z,
1154
- nel_x, nel_y, nel_z,
1150
+ nel_x, nel_y, nel_z,
1155
1151
W, L, H,
1156
1152
parsed_x, parsed_y, parsed_z,
1157
- [],[],[],
1158
- [],[],[],
1159
- [],[],[],
1160
- [],[],[]
1153
+ [], [], [],
1154
+ [], [], [],
1155
+ [], [], [],
1156
+ [], [], []
1161
1157
)
1162
1158
1163
1159
return Grid
@@ -1172,28 +1168,28 @@ end
1172
1168
P: LaMEM_partitioning_info
1173
1169
Returns a LaMEM_partitioning_info object with the distribution of particles in the grid
1174
1170
"""
1175
- function get_particles_distribution (Grid,P)
1171
+ function get_particles_distribution (Grid, P)
1176
1172
1177
1173
# get number of processors and processor coordnate bounds
1178
- nProcX = P. nProcX;
1179
- nProcY = P. nProcY;
1180
- nProcZ = P. nProcZ;
1181
- xc = P. xc;
1182
- yc = P. yc;
1183
- zc = P. zc;
1174
+ nProcX = P. nProcX
1175
+ nProcY = P. nProcY
1176
+ nProcZ = P. nProcZ
1177
+ xc = P. xc
1178
+ yc = P. yc
1179
+ zc = P. zc
1184
1180
1185
- (num, num_i, num_j, num_k) = get_numscheme (nProcX, nProcY, nProcZ);
1181
+ (num, num_i, num_j, num_k) = get_numscheme (nProcX, nProcY, nProcZ)
1186
1182
1187
- dx = Grid. W/ Grid. nump_x;
1188
- dy = Grid. L/ Grid. nump_y;
1189
- dz = Grid. H/ Grid. nump_z;
1183
+ dx = Grid. W / Grid. nump_x
1184
+ dy = Grid. L / Grid. nump_y
1185
+ dz = Grid. H / Grid. nump_z
1190
1186
1191
1187
# % Get particles of respective procs
1192
1188
# % xi - amount of particles in x direction in each core
1193
1189
# % ix_start - indexes where they start for each core
1194
- (xi,ix_start,ix_end) = get_ind2 (dx,xc,nProcX);
1195
- (yi,iy_start,iy_end) = get_ind2 (dy,yc,nProcY);
1196
- (zi,iz_start,iz_end) = get_ind2 (dz,zc,nProcZ);
1190
+ (xi, ix_start, ix_end) = get_ind2 (dx, xc, nProcX)
1191
+ (yi, iy_start, iy_end) = get_ind2 (dy, yc, nProcY)
1192
+ (zi, iz_start, iz_end) = get_ind2 (dz, zc, nProcZ)
1197
1193
1198
1194
x_start = ix_start[num_i[:]]
1199
1195
y_start = iy_start[num_j[:]]
@@ -1202,7 +1198,7 @@ function get_particles_distribution(Grid,P)
1202
1198
y_end = iy_end[num_j[:]]
1203
1199
z_end = iz_end[num_k[:]]
1204
1200
1205
- p_dist = particles_distribution (x_start,x_end,y_start,y_end,z_start,z_end);
1201
+ p_dist = particles_distribution (x_start, x_end, y_start, y_end, z_start, z_end)
1206
1202
1207
1203
return p_dist
1208
1204
@@ -1218,23 +1214,23 @@ end
1218
1214
RandomNoise: add random noise to the grid (0/1)
1219
1215
Returns a LaMEM_grid object with the local grid for the current processor
1220
1216
"""
1221
- function get_proc_grid (Grid_info,p_dist,proc_bounds,proc_num,RandomNoise)
1217
+ function get_proc_grid (Grid_info, p_dist, proc_bounds, proc_num, RandomNoise)
1222
1218
1223
- x_proc_bound = proc_bounds[1 ];
1224
- y_proc_bound = proc_bounds[2 ];
1225
- z_proc_bound = proc_bounds[3 ];
1219
+ x_proc_bound = proc_bounds[1 ]
1220
+ y_proc_bound = proc_bounds[2 ]
1221
+ z_proc_bound = proc_bounds[3 ]
1226
1222
1227
1223
loc_nump_x = p_dist. x_end[proc_num] - p_dist. x_start[proc_num] + 1
1228
1224
loc_nump_y = p_dist. y_end[proc_num] - p_dist. y_start[proc_num] + 1
1229
1225
loc_nump_z = p_dist. z_end[proc_num] - p_dist. z_start[proc_num] + 1
1230
-
1231
- loc_nel_x = loc_nump_x/ Grid_info. nmark_x
1232
- loc_nel_y = loc_nump_y/ Grid_info. nmark_y
1233
- loc_nel_z = loc_nump_z/ Grid_info. nmark_z
1234
1226
1235
- x = range (x_proc_bound[1 ], x_proc_bound[2 ], length= loc_nump_x)
1236
- y = range (y_proc_bound[1 ], y_proc_bound[2 ], length= loc_nump_y)
1237
- z = range (z_proc_bound[1 ], z_proc_bound[2 ], length= loc_nump_z)
1227
+ loc_nel_x = loc_nump_x / Grid_info. nmark_x
1228
+ loc_nel_y = loc_nump_y / Grid_info. nmark_y
1229
+ loc_nel_z = loc_nump_z / Grid_info. nmark_z
1230
+
1231
+ x = range (x_proc_bound[1 ], x_proc_bound[2 ], length = loc_nump_x)
1232
+ y = range (y_proc_bound[1 ], y_proc_bound[2 ], length = loc_nump_y)
1233
+ z = range (z_proc_bound[1 ], z_proc_bound[2 ], length = loc_nump_z)
1238
1234
1239
1235
# marker grid
1240
1236
X, Y, Z = GeophysicalModelGenerator. xyz_grid (x, y, z)
@@ -1244,27 +1240,27 @@ function get_proc_grid(Grid_info,p_dist,proc_bounds,proc_num,RandomNoise)
1244
1240
H = z_proc_bound[2 ] - z_proc_bound[1 ]
1245
1241
1246
1242
if RandomNoise == 1
1247
- dx = x[2 ] - x[1 ]
1248
- dy = y[2 ] - y[1 ]
1249
- dz = z[2 ] - z[1 ]
1250
- dXNoise = zeros (size (X)) + dx;
1251
- dYNoise = zeros (size (Y)) + dy;
1252
- dZNoise = zeros (size (Z)) + dz;
1253
-
1254
- dXNoise = dXNoise.* (rand (size (dXNoise))- 0.5 );
1255
- dYNoise = dYNoise.* (rand (size (dYNoise))- 0.5 );
1256
- dZNoise = dZNoise.* (rand (size (dZNoise))- 0.5 );
1257
-
1258
- Xpart = X + dXNoise;
1259
- Ypart = Y + dYNoise;
1260
- Zpart = Z + dZNoise;
1261
-
1262
- X = Xpart;
1263
- Y = Ypart;
1264
- Z = Zpart;
1265
- x = X (1 ,:, 1 );
1266
- y = Y (:,1 , 1 );
1267
- z = Z (1 ,1 ,:);
1243
+ dx = x[2 ] - x[1 ]
1244
+ dy = y[2 ] - y[1 ]
1245
+ dz = z[2 ] - z[1 ]
1246
+ dXNoise = zeros (size (X)) + dx
1247
+ dYNoise = zeros (size (Y)) + dy
1248
+ dZNoise = zeros (size (Z)) + dz
1249
+
1250
+ dXNoise = dXNoise .* (rand (size (dXNoise)) - 0.5 )
1251
+ dYNoise = dYNoise .* (rand (size (dYNoise)) - 0.5 )
1252
+ dZNoise = dZNoise .* (rand (size (dZNoise)) - 0.5 )
1253
+
1254
+ Xpart = X + dXNoise
1255
+ Ypart = Y + dYNoise
1256
+ Zpart = Z + dZNoise
1257
+
1258
+ X = Xpart
1259
+ Y = Ypart
1260
+ Z = Zpart
1261
+ x = X (1 , :, 1 )
1262
+ y = Y (:, 1 , 1 )
1263
+ z = Z (1 , 1 , :)
1268
1264
1269
1265
end
1270
1266
@@ -1310,36 +1306,36 @@ p_dist_example = get_particles_distribution(Grid_example,P_example)
1310
1306
proc_bounds = get_proc_bound(Grid_example,p_dist_example,2)
1311
1307
```
1312
1308
"""
1313
- function get_proc_bound (Grid,p_dist,proc_num)
1309
+ function get_proc_bound (Grid, p_dist, proc_num)
1314
1310
1315
- dx = Grid. W/ Grid. nump_x;
1316
- dy = Grid. L/ Grid. nump_y;
1317
- dz = Grid. H/ Grid. nump_z;
1311
+ dx = Grid. W / Grid. nump_x
1312
+ dy = Grid. L / Grid. nump_y
1313
+ dz = Grid. H / Grid. nump_z
1318
1314
1319
- parsed_x = Grid. coord_x
1320
- parsed_y = Grid. coord_y
1321
- parsed_z = Grid. coord_z
1315
+ parsed_x = Grid. coord_x
1316
+ parsed_y = Grid. coord_y
1317
+ parsed_z = Grid. coord_z
1322
1318
1323
- model_x = [ parsed_x[1 ] + dx/ 2 , parsed_x[end ] - dx/ 2 ]
1324
- model_y = [ parsed_y[1 ] + dy/ 2 , parsed_y[end ] - dy/ 2 ]
1325
- model_z = [ parsed_z[1 ] + dz/ 2 , parsed_z[end ] - dz/ 2 ]
1319
+ model_x = [parsed_x[1 ] + dx / 2 , parsed_x[end ] - dx / 2 ]
1320
+ model_y = [parsed_y[1 ] + dy / 2 , parsed_y[end ] - dy / 2 ]
1321
+ model_z = [parsed_z[1 ] + dz / 2 , parsed_z[end ] - dz / 2 ]
1326
1322
1327
- x_left = model_x[1 ];
1328
- y_front = model_y[1 ];
1329
- z_bot = model_z[1 ];
1323
+ x_left = model_x[1 ]
1324
+ y_front = model_y[1 ]
1325
+ z_bot = model_z[1 ]
1330
1326
1331
- x_start = p_dist. x_start;
1332
- x_end = p_dist. x_end;
1333
- y_start = p_dist. y_start;
1334
- y_end = p_dist. y_end;
1335
- z_start = p_dist. z_start;
1336
- z_end = p_dist. z_end;
1327
+ x_start = p_dist. x_start
1328
+ x_end = p_dist. x_end
1329
+ y_start = p_dist. y_start
1330
+ y_end = p_dist. y_end
1331
+ z_start = p_dist. z_start
1332
+ z_end = p_dist. z_end
1337
1333
1338
- x_proc_bound = [ x_left + dx* ( x_start[proc_num] - 1 ), x_left + dx* ( x_end[proc_num] - 1 ) ];
1339
- y_proc_bound = [ y_front + dy* ( y_start[proc_num] - 1 ), y_front + dy* ( y_end[proc_num] - 1 ) ];
1340
- z_proc_bound = [ z_bot + dz* ( z_start[proc_num] - 1 ), z_bot + dz* ( z_end[proc_num] - 1 ) ];
1334
+ x_proc_bound = [x_left + dx * ( x_start[proc_num] - 1 ), x_left + dx * ( x_end[proc_num] - 1 )]
1335
+ y_proc_bound = [y_front + dy * ( y_start[proc_num] - 1 ), y_front + dy * ( y_end[proc_num] - 1 )]
1336
+ z_proc_bound = [z_bot + dz * ( z_start[proc_num] - 1 ), z_bot + dz * ( z_end[proc_num] - 1 )]
1341
1337
1342
- return [ x_proc_bound, y_proc_bound, z_proc_bound ]
1338
+ return [x_proc_bound, y_proc_bound, z_proc_bound]
1343
1339
1344
1340
end
1345
1341
@@ -1354,7 +1350,7 @@ end
1354
1350
function crop_bounds (uncropped_bounds, proc_bounds, x, y, z)
1355
1351
1356
1352
# Crop boundaries from the whole model to only the extent of the current processor
1357
- vecs = [x, y, z]
1353
+ vecs = [x, y, z]
1358
1354
new_bounds = [zeros (size (vecs[i])) for i in eachindex (vecs)]
1359
1355
for i in eachindex (vecs)
1360
1356
vec = vecs[i]
@@ -1394,7 +1390,7 @@ function crop_bounds(uncropped_bounds, proc_bounds, x, y, z)
1394
1390
end
1395
1391
1396
1392
function closest_val (val, vec)
1397
- return vec[argmin (abs .(vec .- val))]
1393
+ return vec[argmin (abs .(vec .- val))]
1398
1394
end
1399
1395
1400
1396
"""
@@ -1555,9 +1551,9 @@ function setup_model_domain(coord_x::AbstractVector{<:Real},
1555
1551
xcoor[ix], ycoor[iy],zcoor[iz]
1556
1552
)
1557
1553
1558
- xcoor= []
1559
- ycoor= []
1560
- zcoor= []
1554
+ xcoor = []
1555
+ ycoor = []
1556
+ zcoor = []
1561
1557
1562
1558
return P
1563
1559
0 commit comments