Skip to content

Commit

Permalink
Added type for traceless symmetric tensors
Browse files Browse the repository at this point in the history
- Added SymTracelessTensorValue (alias QTensorValue)
    It is a symmetric tensor Multivalue with null trace, the last diagonal
    value should not be provided in the constructor, the latter computes it and
    stores it in the data field
- Added AbstractSymTensorValue{D} <: Multivalue{Tuple{D,D}} as abstract
    supertype for SymTensorValue and SymTracelessTensorValue
  • Loading branch information
Antoinemarteau committed Aug 5, 2024
1 parent 109cac8 commit fdf0b28
Show file tree
Hide file tree
Showing 9 changed files with 599 additions and 123 deletions.
6 changes: 3 additions & 3 deletions src/TensorValues/Indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function getindex(arg::TensorValue{D},i::Integer,j::Integer) where D
arg.data[index]
end

function getindex(arg::SymTensorValue{D},i::Integer,j::Integer) where D
function getindex(arg::AbstractSymTensorValue{D},i::Integer,j::Integer) where D
index = _2d_sym_tensor_linear_index(D,i,j)
arg.data[index]
end
Expand All @@ -31,7 +31,7 @@ end

getindex(arg::VectorValue, ci::CartesianIndex{1}) = getindex(arg,ci[1])
getindex(arg::TensorValue,ci::CartesianIndex{2}) = getindex(arg,ci[1],ci[2])
getindex(arg::SymTensorValue,ci::CartesianIndex{2}) = getindex(arg,ci[1],ci[2])
getindex(arg::AbstractSymTensorValue,ci::CartesianIndex{2}) = getindex(arg,ci[1],ci[2])
getindex(arg::ThirdOrderTensorValue,ci::CartesianIndex{3}) = getindex(arg,ci[1],ci[2],ci[3])
getindex(arg::SymFourthOrderTensorValue,ci::CartesianIndex{4}) = getindex(arg,ci[1],ci[2],ci[3],ci[4])

Expand All @@ -44,7 +44,7 @@ getindex(arg::ThirdOrderTensorValue, i::Integer) = arg.data[i]

data_index(::Type{<:VectorValue},i) = i
data_index(::Type{<:TensorValue{D}},i,j) where D = _2d_tensor_linear_index(D,i,j)
data_index(::Type{<:SymTensorValue{D}},i,j) where D = _2d_sym_tensor_linear_index(D,i,j)
data_index(::Type{<:AbstractSymTensorValue{D}},i,j) where D = _2d_sym_tensor_linear_index(D,i,j)
data_index(::Type{<:ThirdOrderTensorValue{D1,D2}},i,j,k) where {D1,D2} = _3d_tensor_linear_index(D1,D2,i,j,k)
data_index(::Type{<:SymFourthOrderTensorValue{D}},i,j,k,l) where D = _4d_sym_tensor_linear_index(D,i,j,k,l)

Expand Down
Loading

0 comments on commit fdf0b28

Please sign in to comment.