@@ -11,7 +11,7 @@ import Base: show
1111# These are routines that help to create input geometries, such as slabs with a given angle
1212#
1313
14- export add_box!, add_sphere!, add_ellipsoid!, add_cylinder!, add_layer!, add_polygon!, add_slab!, add_stripes!, add_volcano!, add_fault!,
14+ export add_box!, add_sphere!, add_ellipsoid!, add_cylinder!, add_layer!, add_polygon!, add_polygon_xy!, add_slab!, add_stripes!, add_volcano!, add_fault!,
1515 make_volc_topo,
1616 ConstantTemp, LinearTemp, HalfspaceCoolingTemp, SpreadingRateTemp, LithosphericTemp, LinearWeightedTemperature,
1717 McKenzie_subducting_slab,
@@ -754,6 +754,42 @@ function add_polygon!(Phase, Temp, Grid::AbstractGeneralGrid; # required input
754754 return nothing
755755end
756756
757+ function add_polygon_xy! (Phase, Temp, Grid:: AbstractGeneralGrid ;
758+ xlim= (), ylim= (), zlim:: Tuple = (0.0 ,0.8 ),
759+ phase = ConstantPhase (1 ),
760+ T= nothing , segments= nothing , cell= false )
761+
762+ xlim_ = Float64 .(collect (xlim))
763+ ylim_ = Float64 .(collect (ylim))
764+ zlim_ = Float64 .(collect (zlim))
765+
766+ X, Y, Z = coordinate_grids (Grid, cell= cell)
767+ ind = zeros (Bool, size (X))
768+ ind_slice = zeros (Bool, size (X[:, :, 1 ]))
769+
770+ for k = 1 : size (Z)[3 ]
771+ if Z[1 , 1 , k] >= zlim_[1 ] && Z[1 , 1 , k] <= zlim_[2 ]
772+ inpolygon! (ind_slice, xlim_, ylim_, X[:, :, k], Y[:, :, k])
773+ ind[:, :, k] = ind_slice
774+ else
775+ ind[:, :, k] = zeros (size (X[:, :, 1 ]))
776+ end
777+ end
778+
779+ if ! isempty (ind)
780+ if T != nothing
781+ if segments != = nothing
782+ Temp[ind] = compute_thermal_structure (Temp[ind], X[ind], Y[ind], Z[ind], Phase[ind], T, segments)
783+ else
784+ Temp[ind] = compute_thermal_structure (Temp[ind], X[ind], Y[ind], Z[ind], Phase[ind], T)
785+ end
786+ end
787+ Phase[ind] = compute_phase (Phase[ind], Temp[ind], X[ind], Y[ind], Z[ind], phase)
788+ end
789+
790+ return nothing
791+ end
792+
757793"""
758794 xrot, yrot, zrot = Rot3D(X::Number,Y::Number,Z::Number, cosStrikeAngle, sindStrikeAngle, cosDipAngle, sinDipAngle)
759795
0 commit comments