Skip to content

Commit f933def

Browse files
committed
Easier handling
Changed input style for add_polygon! Now it is the same as for add_box !
1 parent b6da4ce commit f933def

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

docs/src/man/tutorial_Polygon_structures.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ To include the geological structures of a passive margin into the model, we use
4747
# unlimited number of points possible to create the polygon
4848

4949
# add sediment basin
50-
add_polygon!(Phase, Temp, Cart; xlim=[0.0,0.0, 160.0, 200.0],ylim=[100.0,300.0], zlim=[0.0,-10.0,-20.0,0.0], phase = ConstantPhase(8), T=LinearTemp(Ttop=20, Tbot=30));
50+
add_polygon!(Phase, Temp, Cart; xlim=(0.0,0.0, 160.0, 200.0),ylim=(100.0,300.0), zlim=(0.0,-10.0,-20.0,0.0), phase = ConstantPhase(8), T=LinearTemp(Ttop=20, Tbot=30));
5151

5252
# add thinning of the continental crust attached to the slab and its thickness
53-
add_polygon!(Phase, Temp, Cart; xlim=[0.0, 200.0, 0.0],ylim=[500.0,800.0], zlim=[-100.0,-150.0,-150.0], phase = ConstantPhase(5), T=LinearTemp(Ttop=1000, Tbot=1100));
53+
add_polygon!(Phase, Temp, Cart; xlim=(0.0, 200.0, 0.0),ylim=(500.0,800.0), zlim=(-100.0,-150.0,-150.0), phase = ConstantPhase(5), T=LinearTemp(Ttop=1000, Tbot=1100));
5454

5555
# add accretionary prism
56-
add_polygon!(Phase, Temp, Cart; xlim=[800.0, 600.0, 800.0],ylim=[100.0,800.0], zlim=[0.0,0.0,-60.0], phase = ConstantPhase(8), T=LinearTemp(Ttop=20, Tbot=30));
56+
add_polygon!(Phase, Temp, Cart; xlim=(800.0, 600.0, 800.0),ylim=(100.0,800.0), zlim=(0.0,0.0,-60.0), phase = ConstantPhase(8), T=LinearTemp(Ttop=20, Tbot=30));
5757
```
5858

5959
#### 3. Export final model setup to a paraview file

src/Setup_geometry.jl

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ end
593593

594594

595595
"""
596-
add_polygon!(Phase, Temp, Grid::AbstractGeneralGrid; xlim::Vector(), ylim=Vector(2), zlim=Vector(), phase = ConstantPhase(1), T=nothing, cell=false )
596+
add_polygon!(Phase, Temp, Grid::AbstractGeneralGrid; xlim=Tuple{}, ylim=nothing, zlim=Tuple{}, phase = ConstantPhase(1), T=nothing, cell=false )
597597
598598
Adds a polygon with phase & temperature structure to a 3D model setup. This simplifies creating model geometries in geodynamic models
599599
@@ -625,7 +625,7 @@ LaMEM Grid:
625625
z ϵ [-2.0 : 0.0]
626626
julia> Phases = zeros(Int32, size(Grid.X));
627627
julia> Temp = zeros(Float64, size(Grid.X));
628-
julia> add_polygon!(Phase, Temp, Cart; xlim=[0.0,0.0, 1.6, 2.0],ylim=[0.0,0.8], zlim=[0.0,-1.0,-2.0,0.0], phase = ConstantPhase(8), T=ConstantTemp(30))
628+
julia> add_polygon!(Phase, Temp, Cart; xlim=(0,0, 1.6, 2.0),ylim=(0,0.8), zlim=(0,-1,-2,0), phase = ConstantPhase(8), T=ConstantTemp(30))
629629
julia> Model3D = ParaviewData(Grid, (Phases=Phases,Temp=Temp)); # Create Cartesian model
630630
julia> write_paraview(Model3D,"LaMEM_ModelSetup") # Save model to paraview
631631
1-element Vector{String}:
@@ -634,10 +634,20 @@ julia> write_paraview(Model3D,"LaMEM_ModelSetup") # Save model to para
634634
635635
"""
636636
function add_polygon!(Phase, Temp, Grid::AbstractGeneralGrid; # required input
637-
xlim::Vector=[], ylim::Vector=[], zlim::Vector=[], # limits of the box
637+
xlim=Tuple{}, ylim=nothing, zlim=Tuple{}, # limits of the box
638638
phase = ConstantPhase(1), # Sets the phase number(s) in the box
639639
T=nothing, cell=false ) # Sets the thermal structure (various functions are available)
640640

641+
642+
xlim = collect(xlim)
643+
ylim = collect(ylim)
644+
zlim = collect(zlim)
645+
646+
xlim = Float64.(xlim)
647+
ylim = Float64.(ylim)
648+
zlim = Float64.(zlim)
649+
650+
641651
# Retrieve 3D data arrays for the grid
642652
X,Y,Z = coordinate_grids(Grid, cell=cell)
643653

test/test_setup_geometry.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ Temp = ones(Float64,(length(x),length(y),length(z)))*1350;
230230
add_box!(Phase, Temp, Cart; xlim=(0.0,600.0),ylim=(0.0,600.0), zlim=(-80.0, 0.0), phase = ConstantPhase(5), T=T=ConstantTemp(120.0));
231231

232232
# add accretionary prism
233-
add_polygon!(Phase, Temp, Cart; xlim=[500.0, 200.0, 500.0],ylim=[100.0,400.0], zlim=[0.0,0.0,-60.0], phase = ConstantPhase(8), T=LinearTemp(Ttop=20, Tbot=30))
233+
add_polygon!(Phase, Temp, Cart; xlim=(500.0, 200.0, 500.0),ylim=(100.0,400.0), zlim=(0.0,0.0,-60.0), phase = ConstantPhase(8), T=LinearTemp(Ttop=20, Tbot=30))
234234

235235
@test maximum(Phase) == 8
236236
@test minimum(Temp) == 21.40845070422536

0 commit comments

Comments
 (0)