Skip to content

Commit

Permalink
Merge branch 'master' into kam/dotmacro
Browse files Browse the repository at this point in the history
  • Loading branch information
KnutAM committed May 31, 2024
2 parents a5f8a17 + 258540f commit 7c9bd8c
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
16 changes: 12 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
<!-- ## Unreleased -->

## [1.16.1]

### Bugfixes

- Fix that `tovoigt!(::Vector{TA}, ::AbstractTensor{order,dim,TB})` didn't work after v1.15 unless `TA==TB` [#212][github-212]

## [1.16.0]

Expand All @@ -19,8 +25,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* `dot(::Tensor{D1}, ::Tensor{D2})` for (D1,D2) in ((3,1), (1,3), (2,3), (3,2))

<!-- Release links -->
[Unreleased]: https://github.com/Ferrite-FEM/Tensors.jl/compare/v1.15.1...HEAD
[1.15.1]: https://github.com/Ferrite-FEM/Tensors.jl/compare/v1.15.0...v1.15.1
[Unreleased]: https://github.com/Ferrite-FEM/Tensors.jl/compare/v1.16.1...HEAD
[1.16.1]: https://github.com/Ferrite-FEM/Tensors.jl/compare/v1.16.0...v1.16.1
[1.16.0]: https://github.com/Ferrite-FEM/Tensors.jl/compare/v1.15.0...v1.16.0

<!-- GitHub pull request/issue links -->
[github-205]: https://github.com/Ferrite-FEM/Tensors.jl/pull/205
[github-212]: https://github.com/Ferrite-FEM/Tensors.jl/pull/212
[github-205]: https://github.com/Ferrite-FEM/Tensors.jl/pull/205
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "Tensors"
uuid = "48a634ad-e948-5137-8d70-aa71f2a747f4"
version = "1.16.0"
version = "1.16.1"

[deps]
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
Expand All @@ -15,6 +15,8 @@ ForwardDiff = "0.10"
SIMD = "2, 3"
PrecompileTools = "1"
StaticArrays = "1"
LinearAlgebra = "1"
Statistics = "1"
julia = "1"

[extras]
Expand Down
4 changes: 2 additions & 2 deletions docs/Manifest.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is machine-generated - editing it directly is not advised

julia_version = "1.9.2"
julia_version = "1.9.3"
manifest_format = "2.0"
project_hash = "063b18da735845e327fc97d98706d227f804d89d"

Expand Down Expand Up @@ -302,7 +302,7 @@ version = "1.10.0"
deps = ["ForwardDiff", "LinearAlgebra", "PrecompileTools", "SIMD", "StaticArrays", "Statistics"]
path = ".."
uuid = "48a634ad-e948-5137-8d70-aa71f2a747f4"
version = "1.15.0"
version = "1.16.1"

[[deps.Test]]
deps = ["InteractiveUtils", "Logging", "Random", "Serialization"]
Expand Down
6 changes: 3 additions & 3 deletions src/voigt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,14 @@ Base.@propagate_inbounds function tovoigt!(v::AbstractMatrix{T}, A::SymmetricTen
end

# default voigt order (faster than custom voigt order)
Base.@propagate_inbounds function _tovoigt!(v::AbstractVecOrMat{T}, A::SecondOrderTensor{dim,T}, ::Nothing; offset=0, offdiagscale=one(T)) where {dim,T}
Base.@propagate_inbounds function _tovoigt!(v::AbstractVecOrMat{T}, A::SecondOrderTensor{dim}, ::Nothing; offset=0, offdiagscale=one(T)) where {dim,T}
tuple_data, = _to_voigt_tuple(A, offdiagscale)
for i in eachindex(tuple_data)
v[offset+i] = tuple_data[i]
end
return v
end
Base.@propagate_inbounds function _tovoigt!(v::AbstractVecOrMat{T}, A::SymmetricTensor{4,dim,T}, ::Nothing; offdiagscale=one(T), offset_i=0, offset_j=0) where {dim,T}
Base.@propagate_inbounds function _tovoigt!(v::AbstractVecOrMat{T}, A::SymmetricTensor{4,dim}, ::Nothing; offdiagscale=one(T), offset_i=0, offset_j=0) where {dim,T}
tuple_data, N = _to_voigt_tuple(A, offdiagscale)
cartesian = CartesianIndices(((offset_i+1):(offset_i+N), (offset_j+1):(offset_j+N)))
for i in eachindex(tuple_data)
Expand All @@ -154,7 +154,7 @@ Base.@propagate_inbounds function _tovoigt!(v::AbstractVecOrMat{T}, A::Symmetric
return v
end

Base.@propagate_inbounds function _tovoigt!(v::AbstractVecOrMat{T}, A::Tensor{4,dim,T}, ::Nothing; kwargs...) where {dim,T}
Base.@propagate_inbounds function _tovoigt!(v::AbstractVecOrMat{T}, A::Tensor{4,dim}, ::Nothing; kwargs...) where {dim,T}
return _tovoigt!(v, A, DEFAULT_VOIGT_ORDER[dim]; kwargs...)
end

Expand Down
7 changes: 7 additions & 0 deletions test/test_ops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,16 @@ end
@test (@inferred frommandel(Tensor{4,dim}, tomandel(AA))) AA

if T==Float64
# Check that Boolean values are supported for fromvoigt
num_components = Int((dim^2+dim)/2)
@test isa(fromvoigt(SymmetricTensor{2,dim}, rand(num_components) .> 0.5), SymmetricTensor{2,dim,Bool})
@test isa(fromvoigt(SymmetricTensor{4,dim}, rand(num_components,num_components) .> 0.5), SymmetricTensor{4,dim,Bool})

# Check that different types in the vector and tensor is supported via conversion
@test tovoigt!(zeros(Float32, nc(A)), A)::Vector{Float32} tovoigt(A)
@test tovoigt!(zeros(Float32, nc(A_sym)), A_sym)::Vector{Float32} tovoigt(A_sym)
@test tovoigt!(zeros(Float32, nc(AA), nc(AA)), AA)::Matrix{Float32} tovoigt(AA)
@test tovoigt!(zeros(Float32, nc(AA_sym), nc(AA_sym)), AA_sym)::Matrix{Float32} tovoigt(AA_sym)
end

# Static voigt/mandel that use default order
Expand Down

0 comments on commit 7c9bd8c

Please sign in to comment.