Skip to content

Commit 9c08e12

Browse files
committed
Added documentation
1 parent e524217 commit 9c08e12

File tree

2 files changed

+59
-5
lines changed

2 files changed

+59
-5
lines changed

src/Setup_geometry.jl

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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_polygon_xy!, add_slab!, add_stripes!, add_volcano!, add_fault!,
14+
export add_box!, add_sphere!, add_ellipsoid!, add_cylinder!, add_layer!, add_polygon!, add_plate!, add_slab!, add_stripes!, add_volcano!, add_fault!,
1515
make_volc_topo,
1616
ConstantTemp, LinearTemp, HalfspaceCoolingTemp, SpreadingRateTemp, LithosphericTemp, LinearWeightedTemperature,
1717
McKenzie_subducting_slab,
@@ -754,7 +754,61 @@ function add_polygon!(Phase, Temp, Grid::AbstractGeneralGrid; # required input
754754
return nothing
755755
end
756756

757-
function add_polygon_xy!(Phase, Temp, Grid::AbstractGeneralGrid;
757+
"""
758+
add_plate!(Phase, Temp, Grid::AbstractGeneralGrid; xlim=(), ylim=(), zlim::Tuple = (0.0,0.8), phase = ConstantPhase(1), T=nothing, segments=nothing, cell=false )
759+
760+
Adds a polygon with phase & temperature structure to a 3D model setup in the xy plane. This function extends the capabilities of `add_polygon!` by allowing the creation of polygons in the xy plane and projecting them along the z-axis, making it particularly useful for creating tectonic plates with varying geometries.
761+
762+
Parameters
763+
==========
764+
- `Phase` - Phase array (consistent with Grid)
765+
- `Temp` - Temperature array (consistent with Grid)
766+
- `Grid` - Grid structure (usually obtained with read_LaMEM_inputfile)
767+
- `xlim` - `x`-coordinate of the polygon points, same ordering as ylim, number of points unlimited
768+
- `ylim` - `y`-coordinate of the polygon points, same ordering as xlim, number of points unlimited
769+
- `zlim` - `z`-coordinate range for projecting the polygon (start and stop, two values)
770+
- `phase` - Specifies the phase of the polygon. See `ConstantPhase()`
771+
- `T` - Specifies the temperature of the polygon. See `ConstantTemp()`, `LinearTemp()`, `HalfspaceCoolingTemp()`, `SpreadingRateTemp()`
772+
- `segments` - Optional. Allows for thermal segmentation within the polygon. Useful for ridge systems or complex thermal structures.
773+
- `cell` - If true, `Phase` and `Temp` are defined on cell centers
774+
775+
Example
776+
========
777+
778+
Polygon in the xy plane with constant phase and temperature:
779+
780+
```julia-repl
781+
julia> Grid = CartData(xyz_grid(x, y, z))
782+
783+
Grid:
784+
nel : (512, 512, 128)
785+
marker/cell : (1, 1, 1)
786+
markers : (512, 512, 128)
787+
x ϵ [-1000.0 : 0.0]
788+
y ϵ [-1000.0 : 1000.0]
789+
z ϵ [-660.0 : 0.0]
790+
julia> Phases = zeros(Int32, size(Grid.X))
791+
julia> Temp = zeros(Float64, size(Grid.X))
792+
julia> segments = [
793+
((-500.0, -1000.0), (-500.0, 0.0)), # Segment 1
794+
((-250.0, 0.0), (-250.0, 200.0)), # Segment 2
795+
((-750.0, 200.0), (-750.0, 1000.0)) # Segment 3
796+
]
797+
julia> lith = LithosphericPhases(Layers=[15 55], Phases=[1 2], Tlab=1250)
798+
julia> add_plate!(Phases, Temp, Grid;
799+
xlim=(-1000.0, -750.0, -250.0, 0.0, -250.0, -750.0),
800+
ylim=(0.0, 500.0, 500.0, 0.0, -500.0, -500.0),
801+
zlim=(-150.0, 0.0),
802+
phase=lith,
803+
T=SpreadingRateTemp(SpreadingVel=3),
804+
segments=segments)
805+
julia> Grid = addfield(Grid, (; Phases, Temp)) # Add fields
806+
julia> write_paraview(Grid, "Plate") # Save model to Paraview
807+
1-element Vector{String}:
808+
"Plate.vts"
809+
"""
810+
811+
function add_plate!(Phase, Temp, Grid::AbstractGeneralGrid;
758812
xlim=(), ylim=(), zlim::Tuple = (0.0,0.8),
759813
phase = ConstantPhase(1),
760814
T=nothing, segments=nothing, cell=false )

test/test_polygon_xy.jl renamed to test/test_plate.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using GeophysicalModelGenerator
22
using Test
33

4-
@testset "Ridge Thermal Structure Tests" begin
4+
@testset "Plate Tests" begin
55
# Grid parameters
66
nx, ny, nz = 512, 512, 128
77
x = range(-1000, 0, length=nx)
@@ -24,7 +24,7 @@ using Test
2424
lith = LithosphericPhases(Layers=[15 55], Phases=[1 2], Tlab=1250)
2525

2626
# Replace add_box with add_polygon_xy to allow for arbitrary-shaped ridges
27-
add_polygon_xy!(Phases, Temp, Grid;
27+
add_plate!(Phases, Temp, Grid;
2828
xlim=(-1000.0, -750.0, -250.0, 0.0, -250.0, -750.0),
2929
ylim=(0.0, 500.0, 500.0, 0.0, -500.0, -500.0),
3030
zlim=(-150.0, 0.0),
@@ -34,7 +34,7 @@ using Test
3434

3535
# Add and save results
3636
Grid = addfield(Grid, (; Phases, Temp))
37-
write_paraview(Grid, "Ridge_Thermal_Structure_test_2")
37+
write_paraview(Grid, "Plate")
3838

3939
@test minimum(Temp) >= 0.0 # Minimum temperature
4040
@test maximum(Temp) <= 1350.0 # Maximum temperature

0 commit comments

Comments
 (0)