@@ -550,24 +550,24 @@ function get_ind(x, xc, Nprocx)
550550end
551551
552552# 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)
554554
555555 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]
559559 else
560560 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)
563563 end
564564
565565 ix_start = cumsum ([0 ; xi[1 : (end - 1 )]]) .+ 1
566566 ix_end = cumsum (xi[1 : end ])
567567
568568 end
569569
570- return xi,ix_start,ix_end
570+ return xi, ix_start, ix_end
571571
572572end
573573
@@ -1112,11 +1112,7 @@ function Base.show(io::IO, d::LaMEM_partitioning_info)
11121112end
11131113
11141114function check_markers_directory (directory)
1115-
1116- if ! isdir (directory)
1117- mkdir (directory)
1118- end
1119-
1115+ return if ! isdir (directory) mkdir (directory) end
11201116end
11211117
11221118function 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)
11511147 Grid = LaMEM_grid (
11521148 nmark_x, nmark_y, nmark_z,
11531149 nump_x, nump_y, nump_z,
1154- nel_x, nel_y, nel_z,
1150+ nel_x, nel_y, nel_z,
11551151 W, L, H,
11561152 parsed_x, parsed_y, parsed_z,
1157- [],[],[],
1158- [],[],[],
1159- [],[],[],
1160- [],[],[]
1153+ [], [], [],
1154+ [], [], [],
1155+ [], [], [],
1156+ [], [], []
11611157 )
11621158
11631159 return Grid
@@ -1172,28 +1168,28 @@ end
11721168 P: LaMEM_partitioning_info
11731169 Returns a LaMEM_partitioning_info object with the distribution of particles in the grid
11741170"""
1175- function get_particles_distribution (Grid,P)
1171+ function get_particles_distribution (Grid, P)
11761172
11771173 # 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
11841180
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)
11861182
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
11901186
11911187 # % Get particles of respective procs
11921188 # % xi - amount of particles in x direction in each core
11931189 # % 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)
11971193
11981194 x_start = ix_start[num_i[:]]
11991195 y_start = iy_start[num_j[:]]
@@ -1202,7 +1198,7 @@ function get_particles_distribution(Grid,P)
12021198 y_end = iy_end[num_j[:]]
12031199 z_end = iz_end[num_k[:]]
12041200
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)
12061202
12071203 return p_dist
12081204
@@ -1218,23 +1214,23 @@ end
12181214 RandomNoise: add random noise to the grid (0/1)
12191215 Returns a LaMEM_grid object with the local grid for the current processor
12201216"""
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)
12221218
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 ]
12261222
12271223 loc_nump_x = p_dist. x_end[proc_num] - p_dist. x_start[proc_num] + 1
12281224 loc_nump_y = p_dist. y_end[proc_num] - p_dist. y_start[proc_num] + 1
12291225 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
12341226
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)
12381234
12391235 # marker grid
12401236 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)
12441240 H = z_proc_bound[2 ] - z_proc_bound[1 ]
12451241
12461242 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 , :)
12681264
12691265 end
12701266
@@ -1310,36 +1306,36 @@ p_dist_example = get_particles_distribution(Grid_example,P_example)
13101306proc_bounds = get_proc_bound(Grid_example,p_dist_example,2)
13111307```
13121308"""
1313- function get_proc_bound (Grid,p_dist,proc_num)
1309+ function get_proc_bound (Grid, p_dist, proc_num)
13141310
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
13181314
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
13221318
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 ]
13261322
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 ]
13301326
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
13371333
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 )]
13411337
1342- return [ x_proc_bound, y_proc_bound, z_proc_bound ]
1338+ return [x_proc_bound, y_proc_bound, z_proc_bound]
13431339
13441340end
13451341
@@ -1354,7 +1350,7 @@ end
13541350function crop_bounds (uncropped_bounds, proc_bounds, x, y, z)
13551351
13561352 # Crop boundaries from the whole model to only the extent of the current processor
1357- vecs = [x, y, z]
1353+ vecs = [x, y, z]
13581354 new_bounds = [zeros (size (vecs[i])) for i in eachindex (vecs)]
13591355 for i in eachindex (vecs)
13601356 vec = vecs[i]
@@ -1394,7 +1390,7 @@ function crop_bounds(uncropped_bounds, proc_bounds, x, y, z)
13941390end
13951391
13961392function closest_val (val, vec)
1397- return vec[argmin (abs .(vec .- val))]
1393+ return vec[argmin (abs .(vec .- val))]
13981394end
13991395
14001396"""
@@ -1555,9 +1551,9 @@ function setup_model_domain(coord_x::AbstractVector{<:Real},
15551551 xcoor[ix], ycoor[iy],zcoor[iz]
15561552 )
15571553
1558- xcoor= []
1559- ycoor= []
1560- zcoor= []
1554+ xcoor = []
1555+ ycoor = []
1556+ zcoor = []
15611557
15621558 return P
15631559
0 commit comments