Skip to content

Commit 759c901

Browse files
committed
add extrema for various data types
1 parent 558e1f0 commit 759c901

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

src/data_types.jl

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This is data_types.jl
22
# contains type definitions to be used in GeophysicalModelGenerator
33

4-
import Base: show, size
4+
import Base: show, size, extrema
55

66
export GeoData, ParaviewData, UTMData, CartData, Q1Data, FEData,
77
lonlatdepth_grid, xyz_grid, velocity_spherical_to_cartesian!,
@@ -217,6 +217,7 @@ struct GeoData <: AbstractGeneralGrid
217217

218218
end
219219
size(d::GeoData) = size(d.lon.val)
220+
extrema(d::GeoData) = [extrema(d.lon); extrema(d.lat); extrema(d.depth)]
220221

221222
# Print an overview of the Geodata struct:
222223
function Base.show(io::IO, d::GeoData)
@@ -484,6 +485,7 @@ struct UTMData <: AbstractGeneralGrid
484485

485486
end
486487
size(d::UTMData) = size(d.EW.val)
488+
extrema(d::UTMData) = [extrema(d.EW.val); extrema(d.NS.val); extrema(d.depth.val)]
487489

488490
# Print an overview of the UTMData struct:
489491
function Base.show(io::IO, d::UTMData)
@@ -769,6 +771,7 @@ struct CartData <: AbstractGeneralGrid
769771

770772
end
771773
size(d::CartData) = size(d.x.val)
774+
extrema(d::CartData) = [extrema(d.x.val); extrema(d.y.val); extrema(d.z.val)]
772775

773776
# Print an overview of the UTMData struct:
774777
function Base.show(io::IO, d::CartData)
@@ -1354,6 +1357,7 @@ struct Q1Data <: AbstractGeneralGrid
13541357

13551358
end
13561359
size(d::Q1Data) = size(d.x.val) .- 1 # size of mesh
1360+
extrema(d::Q1Data) = [extrema(d.x.val); extrema(d.y.val); extrema(d.z.val)]
13571361

13581362
# Print an overview of the Q1Data struct:
13591363
function Base.show(io::IO, d::Q1Data)
@@ -1444,15 +1448,30 @@ struct FEData{dim, points_per_cell}
14441448

14451449
end
14461450

1451+
14471452
# Print an overview of the FEData struct:
14481453
function Base.show(io::IO, d::FEData{dim, points_per_cell}) where {dim, points_per_cell}
14491454
println(io,"FEData{$dim,$points_per_cell} ")
1450-
println(io," # elements : $(size(d.connectivity,2))")
1451-
println(io," # vertices : $(size(d.vertices,2))")
1452-
println(io," fields : $(keys(d.fields))")
1453-
println(io," cellfields : $(keys(d.cellfields))")
1455+
println(io," elements : $(size(d.connectivity,2))")
1456+
println(io," vertices : $(size(d.vertices,2))")
1457+
println(io," x ϵ [ $(minimum(d.vertices)[1]) : $(maximum(d.vertices)[1])]")
1458+
println(io," y ϵ [ $(minimum(d.vertices)[2]) : $(maximum(d.vertices)[2])]")
1459+
println(io," z ϵ [ $(minimum(d.vertices)[3]) : $(maximum(d.vertices)[3])]")
1460+
println(io," fields : $(keys(d.fields))")
1461+
println(io," cellfields : $(keys(d.cellfields))")
14541462
end
14551463

1464+
extrema(d::FEData) = extrema(d.vertices, dims=2)
1465+
size(d::FEData) = size(d.connectivity,2)
1466+
1467+
"""
1468+
convert2FEData(d::Q1Data
1469+
1470+
"""
1471+
convert2FEData(d::Q1Data)
1472+
1473+
1474+
14561475
"""
14571476
X,Y,Z = coordinate_grids(Data::Q1Data; cell=false)
14581477

0 commit comments

Comments
 (0)