-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changed input style for add_polygon! #119
Changes from 2 commits
f933def
41b06b6
fd39d65
3c5027d
e0a2be1
db96858
c82028d
6c597cf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -593,7 +593,7 @@ end | |
|
||
|
||
""" | ||
add_polygon!(Phase, Temp, Grid::AbstractGeneralGrid; xlim::Vector(), ylim=Vector(2), zlim=Vector(), phase = ConstantPhase(1), T=nothing, cell=false ) | ||
add_polygon!(Phase, Temp, Grid::AbstractGeneralGrid; xlim=Tuple{}, ylim=Tuple{2}, zlim=Tuple{}, phase = ConstantPhase(1), T=nothing, cell=false ) | ||
|
||
Adds a polygon with phase & temperature structure to a 3D model setup. This simplifies creating model geometries in geodynamic models | ||
|
||
|
@@ -625,7 +625,7 @@ LaMEM Grid: | |
z ϵ [-2.0 : 0.0] | ||
julia> Phases = zeros(Int32, size(Grid.X)); | ||
julia> Temp = zeros(Float64, size(Grid.X)); | ||
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)) | ||
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)) | ||
julia> Model3D = ParaviewData(Grid, (Phases=Phases,Temp=Temp)); # Create Cartesian model | ||
julia> write_paraview(Model3D,"LaMEM_ModelSetup") # Save model to paraview | ||
1-element Vector{String}: | ||
|
@@ -634,10 +634,20 @@ julia> write_paraview(Model3D,"LaMEM_ModelSetup") # Save model to para | |
|
||
""" | ||
function add_polygon!(Phase, Temp, Grid::AbstractGeneralGrid; # required input | ||
xlim::Vector=[], ylim::Vector=[], zlim::Vector=[], # limits of the box | ||
xlim=Tuple{}, ylim=Tuple{2}, zlim=Tuple{}, # limits of the box | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above, these are not empty tuples. |
||
phase = ConstantPhase(1), # Sets the phase number(s) in the box | ||
T=nothing, cell=false ) # Sets the thermal structure (various functions are available) | ||
|
||
|
||
xlim = collect(xlim) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here you are changing the type of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for your comments. I changed the names of xlim, ylim and zlim. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It would be a good idea to change everything that looks like that indeed. I have the suspicion that all/most those functions will crash if the keyword arguments are not provided There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Many functions need a Tuple with a specific length and not an empty one. Would e. g. Tuple{Float64, Float64} be better even though at the moment Int64 and Float64 are possible or is it better to place everywhere empty tuples and define it only in the help function what kind of input is needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem is the following. If you do, for example, x=Tuple{2} you can see that julia> typeof(x)
DataType This means that if the user calls any of these functions without explicitly passing julia> function foo(; x::NTuple{2, T} = (1,1)) where T
return x
end
foo (generic function with 1 method) Now you can see how this works depending on what I pass as julia> foo(; x=(1,1))
(1, 1)
julia> foo()
(1, 1)
julia> foo(; x=(1.0, 1.0))
(1.0, 1.0)
julia> foo(; x=(1.0, 1.0, 1.0))
ERROR: MethodError: no method matching var"#foo#5"(::Tuple{Float64, Float64, Float64}, ::typeof(foo))
Closest candidates are:
var"#foo#5"(::Tuple{T, T}, ::typeof(foo)) where T
@ Main ~/Desktop/DevPkgs/GeophysicalModelGenerator.jl/volcano.jl:70
Stacktrace:
[1] top-level scope
@ ~/Desktop/DevPkgs/GeophysicalModelGenerator.jl/volcano.jl:77 if you define Hope this makes any sense! |
||
ylim = collect(ylim) | ||
zlim = collect(zlim) | ||
|
||
xlim = Float64.(xlim) | ||
ylim = Float64.(ylim) | ||
zlim = Float64.(zlim) | ||
|
||
|
||
# Retrieve 3D data arrays for the grid | ||
X,Y,Z = coordinate_grids(Grid, cell=cell) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the point of
Tuple{}
andTuple{2}
? If you want to make empty tuples you can to justxlim=()