@@ -130,7 +130,7 @@ function Base.show(io::IO, data::AbstractData)
130
130
:limit => true ,
131
131
:displaysize => (rows, cols - indent_width),
132
132
),
133
- map (x-> vec (x), parent (data). arrays),
133
+ map (x -> vec (x), parent (data). arrays),
134
134
)
135
135
return io
136
136
end
242
242
n = union_all (T)
243
243
P = Base. tail (type_params (T))
244
244
SS = fieldtype (S, i)
245
- return :(Base. @_inline_meta ; $ n {$SS, $P...} (DataLayouts. generic_property_view (data, $ i)))
245
+ return :(
246
+ Base. @_inline_meta ; $ n {$SS, $P...} (
247
+ DataLayouts. generic_property_view (data, $ i),
248
+ )
249
+ )
246
250
end
247
251
248
252
@inline function Base. getproperty (data:: AbstractData{S} , name:: Symbol ) where {S}
@@ -291,7 +295,10 @@ Base.@propagate_inbounds @generated function _property_view(
291
295
))
292
296
end
293
297
294
- @inline function generic_property_view (data:: AbstractData{S} , i:: Integer ) where {S}
298
+ @inline function generic_property_view (
299
+ data:: AbstractData{S} ,
300
+ i:: Integer ,
301
+ ) where {S}
295
302
fa = parent (data)
296
303
T = eltype (fa)
297
304
SS = fieldtype (S, i)
301
308
return FieldArray (ntuple (jf -> parent (data). arrays[offset + jf], nbytes))
302
309
end
303
310
304
- @inline @generated function generic_property_view (data:: AbstractData{S} , :: Val{Idx} ) where {S, Idx}
305
- :(FieldArray (ntuple (jf -> parent (data). arrays[fieldtypeoffset (eltype (parent (data)), S, i) + jf], typesize (eltype (parent (data)), fieldtype (S, i)))))
311
+ @inline @generated function generic_property_view (
312
+ data:: AbstractData{S} ,
313
+ :: Val{Idx} ,
314
+ ) where {S, Idx}
315
+ :(FieldArray (
316
+ ntuple (
317
+ jf -> parent (data). arrays[fieldtypeoffset (
318
+ eltype (parent (data)),
319
+ S,
320
+ i,
321
+ ) + jf],
322
+ typesize (eltype (parent (data)), fieldtype (S, i)),
323
+ ),
324
+ ))
306
325
end
307
326
308
327
@propagate_inbounds function Base. getindex (
341
360
342
361
A 3D DataLayout. TODO: Add more docs
343
362
"""
344
- struct IJKFVH{S, Nij, Nk, Nv, Nh, FA<: FieldArray } <: Data3D{S, Nij, Nk}
363
+ struct IJKFVH{S, Nij, Nk, Nv, Nh, FA <: FieldArray } <: Data3D{S, Nij, Nk}
345
364
fa:: FA
346
365
end
347
366
IJKFVH {S, Nij, Nk, Nv, Nh} (fa:: FieldArray ) where {S, Nij, Nk, Nv, Nh} =
@@ -391,7 +410,8 @@ struct IJFH{S, Nij, Nh, FA <: FieldArray} <: Data2D{S, Nij}
391
410
array:: FA
392
411
end
393
412
394
- parent_array_type (:: Type{IJFH{S, Nij, Nh, A}} ) where {S, Nij, Nh, A} = parent_array_type (A)
413
+ parent_array_type (:: Type{IJFH{S, Nij, Nh, A}} ) where {S, Nij, Nh, A} =
414
+ parent_array_type (A)
395
415
396
416
function IJFH {S, Nij, Nh} (fa:: FieldArray ) where {S, Nij, Nh}
397
417
IJFH {S, Nij, Nh, typeof(fa)} (fa)
@@ -447,10 +467,7 @@ Base.length(data::IJFH) = get_Nh(data)
447
467
@boundscheck (1 <= h <= get_Nh (data)) || throw (BoundsError (data, (h,)))
448
468
fa = parent (data)
449
469
sub_arrays = ntuple (ncomponents (fa)) do jf
450
- view (
451
- fa. arrays[jf],
452
- :, :, h,
453
- )
470
+ view (fa. arrays[jf], :, :, h)
454
471
end
455
472
dataview = FieldArray (sub_arrays)
456
473
IJF {S, Nij, typeof(dataview)} (dataview)
466
483
@boundscheck (1 <= j <= Nij && 1 <= i <= Nij && 1 <= h <= get_Nh (data)) ||
467
484
throw (BoundsError (data, (i, j, h)))
468
485
fa = parent (data)
469
- dataview = @inbounds FieldArray (ntuple (jf-> view (parent (fa. arrays[jf]), i, j, h), ncomponents (fa)))
486
+ dataview = @inbounds FieldArray (
487
+ ntuple (jf -> view (parent (fa. arrays[jf]), i, j, h), ncomponents (fa)),
488
+ )
470
489
DataF {S, typeof(dataview)} (dataview)
471
490
end
472
491
@@ -508,9 +527,11 @@ struct IFH{S, Ni, Nh, FA <: FieldArray} <: Data1D{S, Ni}
508
527
array:: FA
509
528
end
510
529
511
- IFH {S, Ni, Nh} (fa:: FieldArray ) where {S, Ni, Nh} = IFH {S, Ni, Nh, typeof(fa)} (fa)
530
+ IFH {S, Ni, Nh} (fa:: FieldArray ) where {S, Ni, Nh} =
531
+ IFH {S, Ni, Nh, typeof(fa)} (fa)
512
532
513
- parent_array_type (:: Type{IFH{S, Ni, Nh, A}} ) where {S, Ni, Nh, A} = parent_array_type (A)
533
+ parent_array_type (:: Type{IFH{S, Ni, Nh, A}} ) where {S, Ni, Nh, A} =
534
+ parent_array_type (A)
514
535
515
536
function IFH {S, Ni, Nh} (array:: AbstractArray{T, 3} ) where {S, Ni, Nh, T}
516
537
check_basetype (T, S)
531
552
@inline function slab (data:: IFH{S, Ni} , h:: Integer ) where {S, Ni}
532
553
@boundscheck (1 <= h <= get_Nh (data)) || throw (BoundsError (data, (h,)))
533
554
# dataview = @inbounds view(parent(data), :, :, h)
534
- toa_view = @inbounds ntuple (i-> view (parent (data). arrays[i], :, h), ncomponents (data))
555
+ toa_view = @inbounds ntuple (
556
+ i -> view (parent (data). arrays[i], :, h),
557
+ ncomponents (data),
558
+ )
535
559
dataview = FieldArray (toa_view)
536
560
IF {S, Ni} (dataview)
537
561
end
@@ -540,7 +564,9 @@ Base.@propagate_inbounds slab(data::IFH, v::Integer, h::Integer) = slab(data, h)
540
564
@inline function column (data:: IFH{S, Ni} , i, h) where {S, Ni}
541
565
@boundscheck (1 <= h <= get_Nh (data) && 1 <= i <= Ni) ||
542
566
throw (BoundsError (data, (i, h)))
543
- dataview = @inbounds FieldArray (ntuple (jf-> view (parent (fa. arrays[jf]), i, h), ncomponents (fa)))
567
+ dataview = @inbounds FieldArray (
568
+ ntuple (jf -> view (parent (fa. arrays[jf]), i, h), ncomponents (fa)),
569
+ )
544
570
DataF {S, typeof(dataview)} (dataview)
545
571
end
546
572
Base. @propagate_inbounds column (data:: IFH{S, Ni} , i, j, h) where {S, Ni} =
@@ -579,7 +605,7 @@ Base.length(data::Data0D) = 1
579
605
580
606
Backing `DataLayout` for 0D point data.
581
607
"""
582
- struct DataF{S, FA<: FieldArray } <: Data0D{S}
608
+ struct DataF{S, FA <: FieldArray } <: Data0D{S}
583
609
array:: FA
584
610
end
585
611
@@ -672,7 +698,8 @@ struct IJF{S, Nij, FA <: FieldArray} <: DataSlab2D{S, Nij}
672
698
array:: FA
673
699
end
674
700
675
- parent_array_type (:: Type{IJF{S, Nij, A}} ) where {S, Nij, A} = parent_array_type (A)
701
+ parent_array_type (:: Type{IJF{S, Nij, A}} ) where {S, Nij, A} =
702
+ parent_array_type (A)
676
703
677
704
function IJF {S, Nij} (array:: AbstractArray{T, 3} ) where {S, Nij, T}
678
705
@assert size (array, 1 ) == Nij
730
757
@inline function column (data:: IJF{S, Nij} , i, j) where {S, Nij}
731
758
@boundscheck (1 <= j <= Nij && 1 <= i <= Nij) ||
732
759
throw (BoundsError (data, (i, j)))
733
- dataview = @inbounds FieldArray (ntuple (jf-> view (parent (fa. arrays[jf]), i, j), ncomponents (fa)))
760
+ dataview = @inbounds FieldArray (
761
+ ntuple (jf -> view (parent (fa. arrays[jf]), i, j), ncomponents (fa)),
762
+ )
734
763
DataF {S, typeof(dataview)} (dataview)
735
764
end
736
765
814
843
@inline function column (data:: IF{S, Ni} , i) where {S, Ni}
815
844
@boundscheck (1 <= i <= Ni) || throw (BoundsError (data, (i,)))
816
845
fa = parent (data)
817
- dataview = @inbounds FieldArray (ntuple (jf-> view (parent (fa. arrays[jf]), i), ncomponents (fa)))
846
+ dataview = @inbounds FieldArray (
847
+ ntuple (jf -> view (parent (fa. arrays[jf]), i), ncomponents (fa)),
848
+ )
818
849
DataF {S, typeof(dataview)} (dataview)
819
850
end
820
851
@@ -923,7 +954,8 @@ struct VIJFH{S, Nv, Nij, Nh, FA <: FieldArray} <: Data2DX{S, Nv, Nij}
923
954
array:: FA
924
955
end
925
956
926
- VIJFH {S, Nv, Nij, Nh} (fa:: FieldArray ) where {S, Nv, Nij, Nh} = VIJFH {S, Nv, Nij, Nh, typeof(fa)} (fa)
957
+ VIJFH {S, Nv, Nij, Nh} (fa:: FieldArray ) where {S, Nv, Nij, Nh} =
958
+ VIJFH {S, Nv, Nij, Nh, typeof(fa)} (fa)
927
959
928
960
parent_array_type (:: Type{VIJFH{S, Nv, Nij, Nh, A}} ) where {S, Nv, Nij, Nh, A} =
929
961
parent_array_type (A)
@@ -975,12 +1007,11 @@ end
975
1007
@boundscheck (1 <= i <= Nij && 1 <= j <= Nij && 1 <= h <= Nh) ||
976
1008
throw (BoundsError (data, (i, j, h)))
977
1009
Nf = ncomponents (data)
978
- dataview = @inbounds FieldArray (ntuple (ncomponents (fa)) do jf
979
- SubArray (
980
- parent (fa. arrays[jf]),
981
- (Base. Slice (Base. OneTo (Nv)), i, j, h),
982
- )
983
- end )
1010
+ dataview = @inbounds FieldArray (
1011
+ ntuple (ncomponents (fa)) do jf
1012
+ SubArray (parent (fa. arrays[jf]), (Base. Slice (Base. OneTo (Nv)), i, j, h))
1013
+ end ,
1014
+ )
984
1015
VF {S, Nv, typeof(dataview)} (dataview)
985
1016
end
986
1017
@@ -1045,9 +1076,11 @@ struct VIFH{S, Nv, Ni, Nh, FA <: FieldArray} <: Data1DX{S, Nv, Ni}
1045
1076
array:: FA
1046
1077
end
1047
1078
1048
- VIFH {S, Nv, Ni, Nh} (fa:: FieldArray ) where {S, Nv, Ni, Nh} = VIFH {S, Nv, Ni, Nh, typeof(fa)} (fa)
1079
+ VIFH {S, Nv, Ni, Nh} (fa:: FieldArray ) where {S, Nv, Ni, Nh} =
1080
+ VIFH {S, Nv, Ni, Nh, typeof(fa)} (fa)
1049
1081
1050
- parent_array_type (:: Type{VIFH{S, Nv, Ni, Nh, A}} ) where {S, Nv, Ni, Nh, A} = parent_array_type (A)
1082
+ parent_array_type (:: Type{VIFH{S, Nv, Ni, Nh, A}} ) where {S, Nv, Ni, Nh, A} =
1083
+ parent_array_type (A)
1051
1084
1052
1085
function VIFH {S, Nv, Ni, Nh} (
1053
1086
array:: AbstractArray{T, 4} ,
@@ -1159,7 +1192,8 @@ struct IH1JH2{S, Nij, A} <: Data2D{S, Nij}
1159
1192
array:: A
1160
1193
end
1161
1194
1162
- parent_array_type (:: Type{IH1JH2{S, Nij, A}} ) where {S, Nij, A} = parent_array_type (A)
1195
+ parent_array_type (:: Type{IH1JH2{S, Nij, A}} ) where {S, Nij, A} =
1196
+ parent_array_type (A)
1163
1197
1164
1198
function IH1JH2 {S, Nij} (array:: AbstractMatrix{S} ) where {S, Nij}
1165
1199
@assert size (array, 1 ) % Nij == 0
@@ -1202,7 +1236,8 @@ struct IV1JH2{S, n1, Ni, A} <: Data1DX{S, n1, Ni}
1202
1236
array:: A
1203
1237
end
1204
1238
1205
- parent_array_type (:: Type{IV1JH2{S, n1, Ni, A}} ) where {S, n1, Ni, A} = parent_array_type (A)
1239
+ parent_array_type (:: Type{IV1JH2{S, n1, Ni, A}} ) where {S, n1, Ni, A} =
1240
+ parent_array_type (A)
1206
1241
1207
1242
function IV1JH2 {S, n1, Ni} (array:: AbstractMatrix{S} ) where {S, n1, Ni}
1208
1243
@assert size (array, 2 ) % Ni == 0
@@ -1239,7 +1274,7 @@ end
1239
1274
1240
1275
rebuild (data:: AbstractData , :: Type{DA} ) where {DA} =
1241
1276
rebuild (data, rebuild (getfield (data, :array ), DA))
1242
- # rebuild(data, Adapt.adapt_structure(DA, getfield(data, :array)))
1277
+ # rebuild(data, Adapt.adapt_structure(DA, getfield(data, :array)))
1243
1278
1244
1279
Base. copy (data:: AbstractData ) =
1245
1280
union_all (data){type_params (data)... }(copy (parent (data)))
@@ -1478,7 +1513,19 @@ _device_dispatch(x::AbstractData) = _device_dispatch(parent(x))
1478
1513
_device_dispatch (x:: SArray ) = ToCPU ()
1479
1514
_device_dispatch (x:: MArray ) = ToCPU ()
1480
1515
1481
- for DL in (:IJKFVH ,:IJFH ,:IFH ,:DataF ,:IJF ,:IF ,:VF ,:VIJFH ,:VIFH ,:IH1JH2 ,:IV1JH2 )
1516
+ for DL in (
1517
+ :IJKFVH ,
1518
+ :IJFH ,
1519
+ :IFH ,
1520
+ :DataF ,
1521
+ :IJF ,
1522
+ :IF ,
1523
+ :VF ,
1524
+ :VIJFH ,
1525
+ :VIFH ,
1526
+ :IH1JH2 ,
1527
+ :IV1JH2 ,
1528
+ )
1482
1529
@eval singleton (:: $DL ) = $ (Symbol (DL, :Singleton ))()
1483
1530
end
1484
1531
@@ -1490,15 +1537,19 @@ include("non_extruded_broadcasted.jl")
1490
1537
include (" has_uniform_datalayouts.jl" )
1491
1538
1492
1539
1493
- float_type (:: Type{IJKFVH{S, Nij, Nk, Nv, Nh, FA}} ) where {S, Nij, Nk, Nv, Nh, FA} = eltype (FA)
1540
+ float_type (
1541
+ :: Type{IJKFVH{S, Nij, Nk, Nv, Nh, FA}} ,
1542
+ ) where {S, Nij, Nk, Nv, Nh, FA} = eltype (FA)
1494
1543
float_type (:: Type{IJFH{S, Nij, Nh, FA}} ) where {S, Nij, Nh, FA} = eltype (FA)
1495
1544
float_type (:: Type{IFH{S, Ni, Nh, FA}} ) where {S, Ni, Nh, FA} = eltype (FA)
1496
1545
float_type (:: Type{DataF{S, FA}} ) where {S, FA} = eltype (FA)
1497
1546
float_type (:: Type{IJF{S, Nij, FA}} ) where {S, Nij, FA} = eltype (FA)
1498
1547
float_type (:: Type{IF{S, Ni, FA}} ) where {S, Ni, FA} = eltype (FA)
1499
1548
float_type (:: Type{VF{S, Nv, FA}} ) where {S, Nv, FA} = eltype (FA)
1500
- float_type (:: Type{VIJFH{S, Nv, Nij, Nh, FA}} ) where {S, Nv, Nij, Nh, FA} = eltype (FA)
1501
- float_type (:: Type{VIFH{S, Nv, Ni, Nh, FA}} ) where {S, Nv, Ni, Nh, FA} = eltype (FA)
1549
+ float_type (:: Type{VIJFH{S, Nv, Nij, Nh, FA}} ) where {S, Nv, Nij, Nh, FA} =
1550
+ eltype (FA)
1551
+ float_type (:: Type{VIFH{S, Nv, Ni, Nh, FA}} ) where {S, Nv, Ni, Nh, FA} =
1552
+ eltype (FA)
1502
1553
float_type (:: Type{IH1JH2{S, Nij, A}} ) where {S, Nij, A} = eltype (A)
1503
1554
float_type (:: Type{IV1JH2{S, n1, Ni, A}} ) where {S, n1, Ni, A} = eltype (A)
1504
1555
0 commit comments