Skip to content

Commit a43ead8

Browse files
vchuravyranocha
andauthored
Apply suggestions from code review
Co-authored-by: Hendrik Ranocha <[email protected]>
1 parent 2e8a389 commit a43ead8

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

src/auxiliary/containers.jl

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -397,46 +397,46 @@ function unsafe_wrap_or_alloc(to, vector, size)
397397
end
398398
end
399399

400-
struct TrixiAdaptor{Storage, Real} end
400+
struct TrixiAdaptor{Storage, RealT} end
401401

402402
"""
403-
trixi_adapt(storage, real, x)
403+
trixi_adapt(Storage, RealT, x)
404404
405-
Adapt `x` to the storage type `Storage` and real type `Real`.
405+
Adapt `x` to the storage type `Storage` and real type `RealT`.
406406
"""
407-
function trixi_adapt(storage, real, x)
408-
adapt(TrixiAdaptor{storage, real}(), x)
407+
function trixi_adapt(Storage, RealT, x)
408+
adapt(TrixiAdaptor{Storage, RealT}(), x)
409409
end
410410

411411
# Custom rules
412412
# 1. handling of StaticArrays
413-
function Adapt.adapt_storage(::TrixiAdaptor{<:Any, Real},
414-
x::StaticArrays.StaticArray{S, T, N}) where {Real, S, T, N}
415-
StaticArrays.similar_type(x, Real)(x)
413+
function Adapt.adapt_storage(::TrixiAdaptor{<:Any, RealT},
414+
x::StaticArrays.StaticArray) where {RealT}
415+
StaticArrays.similar_type(x, RealT)(x)
416416
end
417417

418418
# 2. Handling of Arrays
419-
function Adapt.adapt_storage(::TrixiAdaptor{Storage, Real},
420-
x::AbstractArray{T}) where {Storage, Real,
419+
function Adapt.adapt_storage(::TrixiAdaptor{Storage, RealT},
420+
x::AbstractArray{T}) where {Storage, RealT,
421421
T <: AbstractFloat}
422-
adapt(Storage{Real}, x)
422+
adapt(Storage{RealT}, x)
423423
end
424424

425-
function Adapt.adapt_storage(::TrixiAdaptor{Storage, Real},
426-
x::AbstractArray{T}) where {Storage, Real,
425+
function Adapt.adapt_storage(::TrixiAdaptor{Storage, RealT},
426+
x::AbstractArray{T}) where {Storage, RealT,
427427
T <: StaticArrays.StaticArray}
428-
adapt(Storage{StaticArrays.similar_type(T, Real)}, x)
428+
adapt(Storage{StaticArrays.similar_type(T, RealT)}, x)
429429
end
430430

431431
# Our threaded cache contains MArray, it is unlikely that we would want to adapt those
432-
function Adapt.adapt_storage(::TrixiAdaptor{Storage, Real},
433-
x::Array{T}) where {Storage, Real,
432+
function Adapt.adapt_storage(::TrixiAdaptor{Storage, RealT},
433+
x::Array{T}) where {Storage, RealT,
434434
T <: StaticArrays.MArray}
435-
adapt(Array{StaticArrays.similar_type(T, Real)}, x)
435+
adapt(Array{StaticArrays.similar_type(T, RealT)}, x)
436436
end
437437

438-
function Adapt.adapt_storage(::TrixiAdaptor{Storage, Real},
439-
x::AbstractArray) where {Storage, Real}
438+
function Adapt.adapt_storage(::TrixiAdaptor{Storage, RealT},
439+
x::AbstractArray) where {Storage, RealT}
440440
adapt(Storage, x)
441441
end
442442

0 commit comments

Comments
 (0)