Skip to content

Commit 2bddc76

Browse files
committed
Modified Setup_Geometry
1 parent c318c36 commit 2bddc76

File tree

2 files changed

+11
-19
lines changed

2 files changed

+11
-19
lines changed

src/Setup_geometry.jl

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -822,12 +822,12 @@ function add_plate!(Phase, Temp, Grid::AbstractGeneralGrid;
822822
ind = zeros(Bool, size(X))
823823
ind_slice = zeros(Bool, size(X[:, :, 1]))
824824

825-
for k = 1:size(Z)[3]
826-
if Z[1, 1, k] >= zlim_[1] && Z[1, 1, k] <= zlim_[2]
825+
for k = 1:size(Z, 3)
826+
if zlim_[1] <= Z[1, 1, k] <= zlim_[2]
827827
inpolygon!(ind_slice, xlim_, ylim_, X[:, :, k], Y[:, :, k])
828-
ind[:, :, k] = ind_slice
828+
@views ind[:, :, k] = ind_slice
829829
else
830-
ind[:, :, k] = zeros(size(X[:, :, 1]))
830+
@views ind[:, :, k] = zeros(size(X[:, :, 1]))
831831
end
832832
end
833833

@@ -1312,7 +1312,7 @@ function compute_thermal_structure(Temp, X, Y, Z, Phase, s::SpreadingRateTemp, s
13121312
Distance = perpendicular_distance_to_segment(px, py, x1, y1, x2, y2)
13131313

13141314
# Calculate thermal age
1315-
ThermalAge = abs(Distance * 1e3 * 1e2) / SpreadingVel + AgeRidge * 1e6 # Thermal age in years
1315+
ThermalAge = abs(Distance * 1e5) / SpreadingVel + AgeRidge * 1e6 # Thermal age in years
13161316
if ThermalAge > maxAge * 1e6
13171317
ThermalAge = maxAge * 1e6
13181318
end
@@ -1342,11 +1342,7 @@ end
13421342
# Function to determine the side of a point with respect to a line (adjusted for segment direction)
13431343
function side_of_line(x, y, x1, y1, x2, y2, direction)
13441344
side = (x2 - x1) * (y - y1) - (y2 - y1) * (x - x1)
1345-
if direction == :left
1346-
return side > 0
1347-
else
1348-
return side < 0
1349-
end
1345+
direction == :left ? side > 0 : side < 0
13501346
end
13511347

13521348
# Function to determine in which region a point lies (based on delimiters)
@@ -1356,11 +1352,7 @@ function determine_region(px, py, delimiters, segments)
13561352
x2, y2 = delimiters[i][2]
13571353

13581354
# Determine the direction of the segments
1359-
if x2 < x1
1360-
direction = :left # Shift left
1361-
else
1362-
direction = :right # Shift to the right
1363-
end
1355+
direction = x2 < x1 ? :left : :right
13641356

13651357
# Check the side of the line considering the direction
13661358
if side_of_line(px, py, x1, y1, x2, y2, direction)

test/test_plate.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ using Test
3838

3939
@test minimum(Temp) >= 0.0 # Minimum temperature
4040
@test maximum(Temp) <= 1350.0 # Maximum temperature
41-
@test all(Temp .>= 0.0) # Ensure no negative temperatures
42-
@test all(Temp .<= 1350.0) # Ensure no temperatures above max
41+
@test all((0), Temp) # Ensure no negative temperatures
42+
@test all((1350), Temp) # Ensure no temperatures above max
4343

4444
# Check if phases are correctly assigned in expected regions
45-
@test Phases[1, 1, 1] == 2 # Example: Verify a point's phase
46-
@test Phases[end, end, end] == 2 # Example: Verify another point's phase
45+
@test first(Phases) == 2 # Example: Verify a point's phase
46+
@test last(Phases) == 2 # Example: Verify another point's phase
4747
end

0 commit comments

Comments
 (0)