-
Notifications
You must be signed in to change notification settings - Fork 100
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
Refactoring Gridap.TensorValues #210
Labels
enhancement
New feature or request
Comments
# Conversions
convert(::Type{VectorValue{D,T}}, a::NTuple{D} ) where {D,T}
convert(::Type{NTuple{D,T}}, a::VectorValue{D} ) where {D,T}
convert(::Type{VectorValue{D,T}}, a::VectorValue{D} ) where {D,T}
convert(::Type{TensorValue{D1,D2,T,L}}, a::NTuple{L} ) where {D1,D2,T,L}
convert(::Type{NTuple{T,L}}, a::TensorValue{D1,D2,S,L} where {D1,D2,S} ) where {T,L}
convert(::Type{TensorValue{D1,D2,T,L}}, a::TensorValue{D1,D2} ) where {D1,D2,T,L}
convert(::Type{SymTensorValue{D,T,L}}, a::NTuple{L} ) where {D,T,L}
convert(::Type{NTuple{T,L}}, a::SymTensorValue{D,S,L} where {D,S} ) where {T,L}
convert(::Type{SymTensorValue{D,T,L}}, a::SymTensorValue{D} ) where {D,T,L}
convert(::Type{TensorValue{D,D,T,L}}, a::SymTensorValue{D} ) where {D,T,L}
convert(::Type{SymFourthOrderTensorValue{D,T,L}}, a::NTuple{L} ) where {D,T,L}
convert(::Type{NTuple{T,L}}, a::SymFourthOrderTensorValue{D,S,L} where {D,S} ) where {T,L}
convert(::Type{SymFourthOrderTensorValue{D,T,L}}, a::SymFourthOrderTensorValue{D} ) where {D,T,L}
# + two-way conversion to SArray for VectorValue + TensorValue
# other constructors
zero(::Type{VectorValue{D,T}}) where {D,T}
zero(::Type{TensorValue{D1,D2,T}}) where {D1,D2,T}
zero(::Type{SymTensorValue{D,T}}) where {D,T}
zero(::Type{SymFourthOrderTensorValue{D,T}}) where {D,T}
# + idem on instances
one(::Type{TensorValue{D1,D2,T}}) where {D1,D2,T}
one(::Type{SymTensorValue{D,T}}) where {D,T}
one(::Type{SymFourthOrderTensorValue{D,T}}) where {D,T}
# + idem on instances
mutable(::Type{VectorValue{D,T}}) where {D,T}
mutable(::Type{TensorValue{D1,D2,T}}) where {D1,D2,T}
convert(::Type{VectorValue{D,T}}, a::MVector{D} ) where {D,T}
convert(::Type{MVector{D,T}}, a::VectorValue{D} ) where {D,T}
convert(::Type{TensorValue{D1,D2,T}}, a::MMatrix{D1,D2} ) where {D1,D2,T}
convert(::Type{MMatrix{D1,D2,T}}, a::TensorValue{D1,D2} ) where {D1,D2,T}
# + idem on instances
change_eltype(::Type{<:VectorValue{D}},::Type{T}) where {D,T}
change_eltype(::Type{<:TensorValue{D1,D2}},::Type{T}) where {D1,D2,T}
change_eltype(::Type{<:SymTensorValue{D}},::Type{T}) where {D,T}
change_eltype(::Type{<:SymFourthOrderTensorValue{D}},::Type{T}) where {D,T}
change_eltype(::Type{<:Real},::Type{T}) where T
# + idem on instances
Tuple(a::VectorValue)
Tuple(a::TensorValue)
Tuple(a::SymTensorValue)
Tuple(a::SymFourthOrderTensorValue)
SArray(a::VectorValue)
SArray(a::TensorValue)
SVector(a::VectorValue)
SMatrix(a::TensorValue)
|
# Getters
eltype(::Type{VectorValue{D,T}}) where {D,T}
eltype(::Type{TensorValue{D1,D2,T}}) where {D1,D2,T}
eltype(::Type{SymTensorValue{D,T}}) where {D,T}
eltype(::Type{SymFourthOrderTensorValue{D,T}}) where {D,T}
# + idem on instances
size(::Type{VectorValue{D,T}}) where {D,T}
size(::Type{TensorValue{D1,D2,T}}) where {D1,D2,T}
size(::Type{SymTensorValue{D,T}}) where {D,T}
size(::Type{SymFourthOrderTensorValue{D,T}}) where {D,T}
# + idem on instances
length(::Type{VectorValue{D,T}}) where {D,T}
length(::Type{TensorValue{D1,D2,T}}) where {D1,D2,T}
length(::Type{SymTensorValue{D,T}}) where {D,T}
length(::Type{SymFourthOrderTensorValue{D,T}}) where {D,T}
# + idem on instances
num_components(::Type{VectorValue{D,T}}) where {D,T}
num_components(::Type{TensorValue{D1,D2,T}}) where {D1,D2,T}
num_components(::Type{SymTensorValue{D,T}}) where {D,T}
num_components(::Type{SymFourthOrderTensorValue{D,T}}) where {D,T}
# + idem on instances
getindex(a::VectorValue,i::Integer)
getindex(a::TensorValue,i::Integer,j::Integer)
getindex(a::SymTensorValue,i::Integer,j::Integer)
getindex(a::SymFourthOrderTensorValue,i::Integer,j::Integer,k::Integer,l::Integer)
getindex(a::VectorValue,i::CartesianIndex{1})
getindex(a::TensorValue,i::CartesianIndex{2})
getindex(a::SymTensorValue,i::CartesianIndex{2})
getindex(a::SymFourthOrderTensorValue,i::CartesianIndex{4})
getindex(a::TensorValue,i::Integer)
getindex(a::SymTensorValue,i::Integer)
getindex(a::SymFourthOrderTensorValue,i::Integer)
CartesianIndices(a::VectorValue)
CartesianIndices(a::TensorValue)
CartesianIndices(a::SymTensorValue)
CartesianIndices(a::SymFourthOrderTensorValue)
LinearIndices(a::VectorValue)
LinearIndices(a::TensorValue)
LinearIndices(a::SymTensorValue)
LinearIndices(a::SymFourthOrderTensorValue)
eachindex(a::VectorValue)
eachindex(a::TensorValue)
eachindex(a::SymTensorValue)
eachindex(a::SymFourthOrderTensorValue)
iterate(a::VectorValue)
iterate(a::VectorValue,state)
# iterate(a::TensorValue)
# iterate(a::TensorValue,state)
# iterate(a::SymTensorValue)
# iterate(a::SymTensorValue,state)
# iterate(a::SymFourthOrderTensorValue)
# iterate(a::SymFourthOrderTensorValue,state)
|
# Algebraic operations (for all cases they make sense)
import LinearAlgebra: det, inv, tr, dot, norm
import Base: adjoint, transpose, conj,+, -, *, /, \, ==, ≈ # for us * is equivalent to dot
inner, outer, meas
:+(a::VectorValue,b::VectorValue) -> VectorValue
:+(a::VectorValue,b::Real) -> VectorValue
:+(a::Real,b::VectorValue) -> VectorValue
:-(a::VectorValue,b::VectorValue) -> VectorValue
:-(a::VectorValue,b::Real) -> VectorValue
:-(a::Real,b::VectorValue) -> VectorValue
:*(a::VectorValue,b::Real) -> VectorValue
:*(a::Real,b::VectorValue) -> VectorValue
# Simple contraction *, or dot
:*(a::VectorValue,b::VectorValue) -> Real
:*(a::TensorValue,b::VectorValue) -> VectorValue
:*(a::SymTensorValue,b::VectorValue) -> VectorValue
# Double contraction
dotdot(a::(Sym)TensorValue,b::(Sym)TensorValue) -> Real
dotdot(a::SymFourthOrderTensorValue,b::SymTensorValue) -> SymTensorValue
# Full contraction
inner(a::VectorValue,b::VectorValue) -> Real
inner(a::(Sym)TensorValue,b::(Sym)TensorValue) -> Real
# dyadic product
outer(a::VectorValue,b::VectorValue) -> SymTensorValue
outer(a::SymTensorValue,b::SymTensorValue) -> SymFourthOrderTensorValue
# Operators returning symmetric objects
symmetic_part(a::TensorValue)
symmetic_part(a::SymTensorValue)
symmetic_part(a::SymFourthOrderTensorValue)
diagonal_tensor(v::VectorValue)
# Reductions
import Base: sum, maximum, minimum
# IO
import Base: show
|
victorsndvg
added a commit
that referenced
this issue
Mar 25, 2020
Needs to clean and reorder the code
Enhanced type signatures abstract type MultiValue{S,T,N,L} <: Number
struct VectorValue{D,T} <: MultiValue{Tuple{D},T,1,D}
data::NTuple{D,T}
function VectorValue{D,T}(data::NTuple{D,T}) where {D,T}
new{D,T}(data)
end
end
struct TensorValue{D1,D2,T,L} <: MultiValue{Tuple{D1,D2},T,2,L}
data::NTuple{L,T}
function TensorValue{D1,D2,T}(data::NTuple{L,T}) where {D1,D2,T,L}
@assert L == D1*D2
new{D1,D2,T,L}(data)
end
end
struct SymTensorValue{D,T,L} <: MultiValue{Tuple{D,D},T,2,L}
data::NTuple{L,T}
function SymTensorValue{D,T}(data::NTuple{L,T}) where {D,T,L}
@assert L == D*(D+1)/2
new{D,T,L}(data)
end
end
struct SymFourthOrderTensorValue{D,T,L} <: MultiValue{Tuple{D,D,D,D},T,4,L}
data::NTuple{L,T}
function SymFourthOrderTensorValue{D,T}(data::NTuple{L,T}) where {D,T,L}
@assert L == (D*(D+1)/2)^2
new{D,T,L}(data)
end
end |
victorsndvg
added a commit
that referenced
this issue
Mar 30, 2020
victorsndvg
added a commit
that referenced
this issue
Apr 7, 2020
Some operations pending and its corresponding tests
victorsndvg
added a commit
that referenced
this issue
Apr 7, 2020
victorsndvg
added a commit
that referenced
this issue
Apr 15, 2020
…sorValue. #210 Pending: Some operations and tests (ongoing)
Merged
Done in PR #239 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The text was updated successfully, but these errors were encountered: