Skip to content

Commit 3c5027d

Browse files
committed
Update Setup_geometry.jl
make it stable
1 parent fd39d65 commit 3c5027d

File tree

1 file changed

+26
-22
lines changed

1 file changed

+26
-22
lines changed

src/Setup_geometry.jl

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,11 @@ end
130130

131131

132132
"""
133-
add_box!(Phase, Temp, Grid::AbstractGeneralGrid; xlim=Tuple{2}, [ylim=Tuple{2}], zlim=Tuple{2},
133+
add_box!(Phase, Temp, Grid::AbstractGeneralGrid; xlim::NTuple{2, _T} = (20,100), [ylim::NTuple{2, _T} = (1,10)], zlim::NTuple{2, _T} = (10,80),
134134
Origin=nothing, StrikeAngle=0, DipAngle=0,
135135
phase = ConstantPhase(1),
136136
T=nothing,
137-
cell=false )
137+
cell=false ) where _T
138138
139139
Adds a box with phase & temperature structure to a 3D model setup. This simplifies creating model geometries in geodynamic models
140140
@@ -189,11 +189,11 @@ julia> write_paraview(Grid,"LaMEM_ModelSetup") # Save model to paraview
189189
```
190190
"""
191191
function add_box!(Phase, Temp, Grid::AbstractGeneralGrid; # required input
192-
xlim=Tuple{2}, ylim=nothing, zlim=Tuple{2}, # limits of the box
192+
xlim::NTuple{2, _T} = (20,100), ylim=nothing, zlim::NTuple{2, _T} = (10,80), # limits of the box
193193
Origin=nothing, StrikeAngle=0, DipAngle=0, # origin & dip/strike
194194
phase = ConstantPhase(1), # Sets the phase number(s) in the box
195195
T=nothing, # Sets the thermal structure (various functions are available)
196-
cell=false ) # if true, Phase and Temp are defined on cell centers
196+
cell=false ) where _T # if true, Phase and Temp are defined on cell centers
197197

198198
# Retrieve 3D data arrays for the grid
199199
X,Y,Z = coordinate_grids(Grid, cell=cell)
@@ -247,9 +247,10 @@ end
247247

248248

249249
"""
250-
add_layer!(Phase, Temp, Grid::AbstractGeneralGrid; xlim=Tuple{2}, [ylim=Tuple{2}], zlim=Tuple{2},
250+
add_layer!(Phase, Temp, Grid::AbstractGeneralGrid; xlim::NTuple{2, _T} = (1,100), [ylim::NTuple{2, _T} = (0,20)], zlim::NTuple{2, _T} = (0,-100),
251251
phase = ConstantPhase(1),
252-
T=nothing, cell=false )
252+
T=nothing, cell=false ) where _T
253+
253254
254255
Adds a layer with phase & temperature structure to a 3D model setup. The most common use would be to add a lithospheric layer to a model setup.
255256
This simplifies creating model geometries in geodynamic models
@@ -348,9 +349,10 @@ end
348349

349350

350351
"""
351-
add_sphere!(Phase, Temp, Grid::AbstractGeneralGrid; cen=Tuple{3}, radius=Tuple{1},
352+
add_sphere!(Phase, Temp, Grid::AbstractGeneralGrid; cen::NTuple{3, _T} = (0,0,-1), radius::NTuple{1, _T} = (0.5),
352353
phase = ConstantPhase(1).
353-
T=nothing, cell=false )
354+
T=nothing, cell=false ) where _T
355+
354356
355357
Adds a sphere with phase & temperature structure to a 3D model setup. This simplifies creating model geometries in geodynamic models
356358
@@ -390,9 +392,9 @@ julia> write_paraview(Model3D,"LaMEM_ModelSetup") # Save model to para
390392
```
391393
"""
392394
function add_sphere!(Phase, Temp, Grid::AbstractGeneralGrid; # required input
393-
cen=Tuple{3}, radius=Tuple{1}, # center and radius of the sphere
395+
cen::NTuple{3, _T} = (0,0,-1), radius::NTuple{1, _T} = (0.5), # center and radius of the sphere
394396
phase = ConstantPhase(1), # Sets the phase number(s) in the sphere
395-
T=nothing, cell=false ) # Sets the thermal structure (various functions are available)
397+
T=nothing, cell=false ) where _T # Sets the thermal structure (various functions are available)
396398

397399
# Retrieve 3D data arrays for the grid
398400
X,Y,Z = coordinate_grids(Grid, cell=cell)
@@ -412,10 +414,10 @@ function add_sphere!(Phase, Temp, Grid::AbstractGeneralGrid; # required input
412414
end
413415

414416
"""
415-
add_ellipsoid!(Phase, Temp, Grid::AbstractGeneralGrid; cen=Tuple{3}, axes=Tuple{3},
417+
add_ellipsoid!(Phase, Temp, Grid::AbstractGeneralGrid; cen::NTuple{3, _T} = (-1,-1,-1), axes::NTuple{3, _T} = (0.2,0.1,0.5),
416418
Origin=nothing, StrikeAngle=0, DipAngle=0,
417419
phase = ConstantPhase(1).
418-
T=nothing, cell=false )
420+
T=nothing, cell=false ) where _T
419421
420422
Adds an Ellipsoid with phase & temperature structure to a 3D model setup. This simplifies creating model geometries in geodynamic models
421423
@@ -457,10 +459,10 @@ julia> write_paraview(Model3D,"LaMEM_ModelSetup") # Save model to para
457459
```
458460
"""
459461
function add_ellipsoid!(Phase, Temp, Grid::AbstractGeneralGrid; # required input
460-
cen=Tuple{3}, axes=Tuple{3}, # center and semi-axes of the ellpsoid
462+
cen::NTuple{3, _T} = (-1,-1,-1), axes::NTuple{3, _T} = (0.2,0.1,0.5), # center and semi-axes of the ellpsoid
461463
Origin=nothing, StrikeAngle=0, DipAngle=0, # origin & dip/strike
462464
phase = ConstantPhase(1), # Sets the phase number(s) in the box
463-
T=nothing, cell=false ) # Sets the thermal structure (various functions are available)
465+
T=nothing, cell=false ) where _T # Sets the thermal structure (various functions are available)
464466

465467
if Origin==nothing
466468
Origin = cen # center
@@ -496,9 +498,10 @@ function add_ellipsoid!(Phase, Temp, Grid::AbstractGeneralGrid; # required i
496498
end
497499

498500
"""
499-
add_cylinder!(Phase, Temp, Grid::AbstractGeneralGrid; base=Tuple{3}, cap=Tuple{3}, radius=Tuple{1},
500-
phase = ConstantPhase(1).
501-
T=nothing, cell=false )
501+
add_cylinder!(Phase, Temp, Grid::AbstractGeneralGrid; base::NTuple{3, _T} = (-1,-1,-1.5), cap::NTuple{3, _T} = (-1,-1,-0.5), radius::NTuple{1, _T} = (0.25),
502+
phase = ConstantPhase(1),
503+
T=nothing, cell=false ) where _T
504+
502505
503506
Adds a cylinder with phase & temperature structure to a 3D model setup. This simplifies creating model geometries in geodynamic models
504507
@@ -539,9 +542,9 @@ julia> write_paraview(Model3D,"LaMEM_ModelSetup") # Save model to para
539542
```
540543
"""
541544
function add_cylinder!(Phase, Temp, Grid::AbstractGeneralGrid; # required input
542-
base=Tuple{3}, cap=Tuple{3}, radius=Tuple{1}, # center and radius of the sphere
545+
base::NTuple{3, _T} = (-1,-1,-1.5), cap::NTuple{3, _T} = (-1,-1,-0.5), radius=::NTuple{1, _T} = (0.25), # center and radius of the sphere
543546
phase = ConstantPhase(1), # Sets the phase number(s) in the sphere
544-
T=nothing, cell=false ) # Sets the thermal structure (various functions are available)
547+
T=nothing, cell=false ) where _T # Sets the thermal structure (various functions are available)
545548

546549
# axis vector of cylinder
547550
axVec = cap .- base
@@ -593,7 +596,8 @@ end
593596

594597

595598
"""
596-
add_polygon!(Phase, Temp, Grid::AbstractGeneralGrid; xlim=Tuple{}, ylim=Tuple{2}, zlim=Tuple{}, phase = ConstantPhase(1), T=nothing, cell=false )
599+
add_polygon!(Phase, Temp, Grid::AbstractGeneralGrid; xlim=(), ylim::NTuple{2, _T} = (0,0.8), zlim=(), phase = ConstantPhase(1), T=nothing, cell=false ) where _T
600+
597601
598602
Adds a polygon with phase & temperature structure to a 3D model setup. This simplifies creating model geometries in geodynamic models
599603
@@ -634,9 +638,9 @@ julia> write_paraview(Model3D,"LaMEM_ModelSetup") # Save model to para
634638
635639
"""
636640
function add_polygon!(Phase, Temp, Grid::AbstractGeneralGrid; # required input
637-
xlim=Tuple{}, ylim=Tuple{2}, zlim=Tuple{}, # limits of the box
641+
xlim=(), ylim=::NTuple{2, _T} = (0,0.8), zlim=(), # limits of the box
638642
phase = ConstantPhase(1), # Sets the phase number(s) in the box
639-
T=nothing, cell=false ) # Sets the thermal structure (various functions are available)
643+
T=nothing, cell=false ) where _T # Sets the thermal structure (various functions are available)
640644

641645

642646
xlim_ = Float64.(collect(xlim))

0 commit comments

Comments
 (0)