-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f4518bc
commit f1a4336
Showing
4 changed files
with
45 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
import Base.Array | ||
|
||
@inline remove_parameters(::T) where T = Base.typename(T).wrapper | ||
|
||
function Array(x::T) where T<:Union{SymmetricTensor, ThermalArrays, Velocity, Residual} | ||
nfields = fieldcount(T) | ||
cpu_fields = ntuple(Val(nfields)) do i | ||
Base.@_inline_meta | ||
Array(getfield(x, i)) | ||
end | ||
T_clean = remove_parameters(x) | ||
return T_clean(cpu_fields...) | ||
end | ||
|
||
function Array(x::StokesArrays{T,A,B,C,M,nDim}) where {T,A,B,C,M,nDim} | ||
nfields = fieldcount(StokesArrays) | ||
cpu_fields = ntuple(Val(nfields)) do i | ||
Base.@_inline_meta | ||
Array(getfield(x, i)) | ||
end | ||
T_clean = remove_parameters(x) | ||
return T_clean(cpu_fields...) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using JustRelax, Test | ||
model = PS_Setup(:Threads, Float64, 2) | ||
environment!(model) | ||
|
||
@testset "Array conversions" begin | ||
ni = 10, 10 | ||
stokes = StokesArrays(ni, ViscoElastic) | ||
thermal = ThermalArrays(ni) | ||
|
||
@test Array(stokes.V) isa Velocity{Matrix{Float64}} | ||
@test Array(stokes.τ) isa SymmetricTensor{Matrix{Float64}} | ||
@test Array(stokes.R) isa Residual{Matrix{Float64}} | ||
@test Array(stokes.P) isa Matrix | ||
@test Array(stokes) isa StokesArrays | ||
@test Array(thermal) isa ThermalArrays{Matrix{Float64}} | ||
end |