From b51470fc4ce03c0c035679992b403d6a96ffffe4 Mon Sep 17 00:00:00 2001 From: Kristoffer Date: Fri, 30 Dec 2022 08:38:32 +0100 Subject: [PATCH 01/16] add a precompile workload just add them explicitly --- Project.toml | 4 +++- src/Tensors.jl | 3 +-- src/precompile.jl | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 src/precompile.jl diff --git a/Project.toml b/Project.toml index 40c5407a..eef367de 100644 --- a/Project.toml +++ b/Project.toml @@ -6,13 +6,15 @@ version = "1.13.0" ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" SIMD = "fdea26ae-647d-5447-a871-4b548cad5224" +SnoopPrecompile = "66db9d55-30c0-4569-8b51-7e840670fc0c" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" [compat] -StaticArrays = "1" ForwardDiff = "0.10" SIMD = "2, 3" +SnoopPrecompile = "1" +StaticArrays = "1" julia = "1" [extras] diff --git a/src/Tensors.jl b/src/Tensors.jl index 6088d80d..89bfb8b4 100644 --- a/src/Tensors.jl +++ b/src/Tensors.jl @@ -1,5 +1,3 @@ -__precompile__() - module Tensors import Base.@pure @@ -176,5 +174,6 @@ include("eigen.jl") include("special_ops.jl") include("simd.jl") include("voigt.jl") +include("precompile.jl") end # module diff --git a/src/precompile.jl b/src/precompile.jl new file mode 100644 index 00000000..7ea5d15a --- /dev/null +++ b/src/precompile.jl @@ -0,0 +1,34 @@ +using SnoopPrecompile + +@precompile_all_calls begin + for dim in (2, 3) + v = ones(Tensor{1, dim, Float64,}) + σ = one(SymmetricTensor{2, dim, Float64}) + F = one(Tensor{2, dim, Float64,}) + E = one(SymmetricTensor{4, dim, Float64}) + C = one(Tensor{4, dim, Float64,}) + v * 1.0 + v ⋅ v + v ⊗ v + σ ⋅ v + F ⋅ v + σ ⊗ σ + F ⊗ F + σ * 1.0 + F * 1.0 + σ ⊡ σ + F ⊡ F + E ⊡ σ + C ⊡ F + E * 1.0 + C * 1.0 + + # TODO: AD? + end + + # See discussion in https://github.com/Ferrite-FEM/Tensors.jl/pull/190 + if @isdefined var"#102#103" + precompile(Tuple{typeof(apply_all), Type{Tensor{1, 2, T, M} where M where T}, var"#102#103"{Float64}}) + precompile(Tuple{typeof(apply_all), Type{Tensor{1, 3, T, M} where M where T}, var"#102#103"{Float64}}) + end +end From 312df966fff2deadf5450f8c0fd20bebb321836e Mon Sep 17 00:00:00 2001 From: Kristoffer Date: Fri, 30 Dec 2022 10:31:35 +0100 Subject: [PATCH 02/16] update manifest --- docs/Manifest.toml | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/docs/Manifest.toml b/docs/Manifest.toml index 06a2dc13..37491d2a 100644 --- a/docs/Manifest.toml +++ b/docs/Manifest.toml @@ -7,6 +7,7 @@ version = "0.0.1" [[ArgTools]] uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" +version = "1.1.1" [[Artifacts]] uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" @@ -41,6 +42,7 @@ version = "3.41.0" [[CompilerSupportLibraries_jll]] deps = ["Artifacts", "Libdl"] uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" +version = "1.0.1+0" [[Dates]] deps = ["Printf"] @@ -74,15 +76,17 @@ version = "0.8.6" [[Documenter]] deps = ["ANSIColoredPrinters", "Base64", "Dates", "DocStringExtensions", "IOCapture", "InteractiveUtils", "JSON", "LibGit2", "Logging", "Markdown", "REPL", "Test", "Unicode"] -git-tree-sha1 = "17f267e238a032fe9238af600f6a31f2845e2ad7" -repo-rev = "master" -repo-url = "https://github.com/JuliaDocs/Documenter.jl.git" +git-tree-sha1 = "6030186b00a38e9d0434518627426570aac2ef95" uuid = "e30172f5-a6a5-5a46-863b-614d45cd2de4" -version = "0.27.12" +version = "0.27.23" [[Downloads]] -deps = ["ArgTools", "LibCURL", "NetworkOptions"] +deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"] uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6" +version = "1.6.0" + +[[FileWatching]] +uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" [[ForwardDiff]] deps = ["CommonSubexpressions", "DiffResults", "DiffRules", "LinearAlgebra", "LogExpFunctions", "NaNMath", "Preferences", "Printf", "Random", "SpecialFunctions", "StaticArrays"] @@ -126,10 +130,12 @@ version = "0.21.2" [[LibCURL]] deps = ["LibCURL_jll", "MozillaCACerts_jll"] uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" +version = "0.6.3" [[LibCURL_jll]] deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" +version = "7.84.0+0" [[LibGit2]] deps = ["Base64", "NetworkOptions", "Printf", "SHA"] @@ -138,6 +144,7 @@ uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" [[LibSSH2_jll]] deps = ["Artifacts", "Libdl", "MbedTLS_jll"] uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" +version = "1.10.2+0" [[Libdl]] uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" @@ -168,12 +175,14 @@ uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" [[MbedTLS_jll]] deps = ["Artifacts", "Libdl"] uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" +version = "2.28.0+0" [[Mmap]] uuid = "a63ad114-7e13-5084-954f-fe012c677804" [[MozillaCACerts_jll]] uuid = "14a3606d-f60d-562e-9121-12d972cd8159" +version = "2022.2.1" [[NaNMath]] git-tree-sha1 = "f755f36b19a5116bb580de457cda0c140153f283" @@ -182,14 +191,17 @@ version = "0.3.6" [[NetworkOptions]] uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" +version = "1.2.0" [[OpenBLAS_jll]] deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"] uuid = "4536629a-c528-5b80-bd46-f80d51c5b363" +version = "0.3.20+0" [[OpenLibm_jll]] deps = ["Artifacts", "Libdl"] uuid = "05823500-19ac-5b8b-9628-191a04bc5112" +version = "0.8.1+0" [[OpenSpecFun_jll]] deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Pkg"] @@ -206,6 +218,7 @@ version = "2.2.0" [[Pkg]] deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" +version = "1.8.0" [[Preferences]] deps = ["TOML"] @@ -227,6 +240,7 @@ uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" [[SHA]] uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" +version = "0.7.0" [[SIMD]] git-tree-sha1 = "39e3df417a0dd0c4e1f89891a281f82f5373ea3b" @@ -240,6 +254,11 @@ uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" deps = ["Distributed", "Mmap", "Random", "Serialization"] uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383" +[[SnoopPrecompile]] +git-tree-sha1 = "f604441450a3c0569830946e5b33b78c928e1a85" +uuid = "66db9d55-30c0-4569-8b51-7e840670fc0c" +version = "1.0.1" + [[Sockets]] uuid = "6462fe0b-24de-5631-8697-dd941f90decc" @@ -266,16 +285,18 @@ uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" [[TOML]] deps = ["Dates"] uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76" +version = "1.0.0" [[Tar]] deps = ["ArgTools", "SHA"] uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" +version = "1.10.1" [[Tensors]] -deps = ["ForwardDiff", "LinearAlgebra", "SIMD", "StaticArrays", "Statistics"] +deps = ["ForwardDiff", "LinearAlgebra", "SIMD", "SnoopPrecompile", "StaticArrays", "Statistics"] path = ".." uuid = "48a634ad-e948-5137-8d70-aa71f2a747f4" -version = "1.10.0" +version = "1.13.0" [[Test]] deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] @@ -291,15 +312,19 @@ uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" [[Zlib_jll]] deps = ["Libdl"] uuid = "83775a58-1f1d-513f-b197-d71354ab007a" +version = "1.2.12+3" [[libblastrampoline_jll]] deps = ["Artifacts", "Libdl", "OpenBLAS_jll"] uuid = "8e850b90-86db-534c-a0d3-1478176c7d93" +version = "5.1.1+0" [[nghttp2_jll]] deps = ["Artifacts", "Libdl"] uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" +version = "1.48.0+0" [[p7zip_jll]] deps = ["Artifacts", "Libdl"] uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" +version = "17.4.0+0" From 20eae862692077e1501b3aa068f5a8c604e084df Mon Sep 17 00:00:00 2001 From: Kristoffer Carlsson Date: Fri, 30 Dec 2022 21:30:57 +0100 Subject: [PATCH 03/16] bump version --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index eef367de..654e8657 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "Tensors" uuid = "48a634ad-e948-5137-8d70-aa71f2a747f4" -version = "1.13.0" +version = "1.13.1" [deps] ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" From 96f6bfa149f1b4a082f9e798ea56439733ba9a75 Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Wed, 1 Feb 2023 10:06:47 +0100 Subject: [PATCH 04/16] Improve documentation for tdot and dott. (#193) --- .github/workflows/CI.yml | 1 + src/tensor_products.jl | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index c554f209..06540252 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -17,6 +17,7 @@ jobs: version: - '1.6' - '1' + - '~1.9.0-0' - 'nightly' os: - ubuntu-latest diff --git a/src/tensor_products.jl b/src/tensor_products.jl index 8b2836d1..7760b894 100644 --- a/src/tensor_products.jl +++ b/src/tensor_products.jl @@ -350,6 +350,8 @@ end Compute the dot product of a symmetric second order tensor with itself. Return a `SymmetricTensor`. +See also [`tdot`](@ref) and [`dott`](@ref). + # Examples ```jldoctest julia> A = rand(SymmetricTensor{2,3}) @@ -368,9 +370,9 @@ julia> dot(A) @inline LinearAlgebra.dot(S::SymmetricTensor{2}) = tdot(S) """ - tdot(::SecondOrderTensor) + tdot(A::SecondOrderTensor) -Compute the transpose-dot product of a second order tensor with itself. +Compute the transpose-dot product of `A` with itself, i.e. `dot(A', A)`. Return a `SymmetricTensor`. # Examples @@ -391,9 +393,9 @@ julia> tdot(A) @inline tdot(S::SecondOrderTensor) = unsafe_symmetric(S' ⋅ S) """ - dott(::SecondOrderTensor) + dott(A::SecondOrderTensor) -Compute the dot-transpose product of a second order tensor with itself. +Compute the dot-transpose product of `A` with itself, i.e. `dot(A, A')`. Return a `SymmetricTensor`. # Examples From e303602931c8fc4af7ae9d081adb322accd1ac40 Mon Sep 17 00:00:00 2001 From: Knut Andreas Meyer Date: Fri, 17 Mar 2023 12:24:10 +0100 Subject: [PATCH 05/16] Update immutable -> struct in documentation (#196) --- docs/src/man/storing_tensors.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/man/storing_tensors.md b/docs/src/man/storing_tensors.md index ab92443b..2c4dd040 100644 --- a/docs/src/man/storing_tensors.md +++ b/docs/src/man/storing_tensors.md @@ -14,7 +14,7 @@ Leaving out the `M` and `N` would lead to bad performance. !!! tip The number of independent elements `N` are already included in the `typealias` `Vec` so they can be stored with e.g. ```julia - immutable VecContainer{dim, T} + struct VecContainer{dim, T} vec::Vec{dim, T} end ``` From cbd1cc018a360e52a5d06f339adb581aec78529c Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Tue, 18 Apr 2023 00:01:07 +0200 Subject: [PATCH 06/16] Create CITATION.cff --- CITATION.cff | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 CITATION.cff diff --git a/CITATION.cff b/CITATION.cff new file mode 100644 index 00000000..865e1ac0 --- /dev/null +++ b/CITATION.cff @@ -0,0 +1,29 @@ +cff-version: 1.2.0 +title: Tensors.jl +message: >- + If you use this software, please cite this software using + the metadata from "preferred-citation". +type: software +authors: + - family-names: Carlsson + given-names: Kristoffer + orcid: "https://orcid.org/0000-0001-9092-3092" + - family-names: Ekre + given-names: Fredrik + orcid: "https://orcid.org/0000-0003-2476-5406" + - name: "Tensors.jl contributors" +repository-code: "https://github.com/Ferrite-FEM/Tensors.jl" +license: MIT +preferred-citation: + authors: + - family-names: Carlsson + given-names: Kristoffer + orcid: "https://orcid.org/0000-0001-9092-3092" + - family-names: Ekre + given-names: Fredrik + orcid: "https://orcid.org/0000-0003-2476-5406" + doi: "10.5334/jors.182" + journal: "Journal of Open Research Software" + title: "Tensors.jl — Tensor Computations in Julia" + type: article + year: 2019 From cb430d7680193e6bd6798ec172d9f928da39edee Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Tue, 18 Apr 2023 00:47:29 +0200 Subject: [PATCH 07/16] Update CITATION.cff with Zenodo DOI. --- CITATION.cff | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/CITATION.cff b/CITATION.cff index 865e1ac0..7a9533d3 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -7,23 +7,29 @@ type: software authors: - family-names: Carlsson given-names: Kristoffer - orcid: "https://orcid.org/0000-0001-9092-3092" + orcid: 'https://orcid.org/0000-0001-9092-3092' - family-names: Ekre given-names: Fredrik - orcid: "https://orcid.org/0000-0003-2476-5406" - - name: "Tensors.jl contributors" -repository-code: "https://github.com/Ferrite-FEM/Tensors.jl" + orcid: 'https://orcid.org/0000-0003-2476-5406' + - name: Tensors.jl contributors +identifiers: + - type: doi + value: 10.5281/zenodo.802356 + description: >- + DOI representing all versions of Tensors.jl (Zenodo + Concept DOI) +repository-code: 'https://github.com/Ferrite-FEM/Tensors.jl' license: MIT preferred-citation: authors: - family-names: Carlsson given-names: Kristoffer - orcid: "https://orcid.org/0000-0001-9092-3092" + orcid: 'https://orcid.org/0000-0001-9092-3092' - family-names: Ekre given-names: Fredrik - orcid: "https://orcid.org/0000-0003-2476-5406" - doi: "10.5334/jors.182" - journal: "Journal of Open Research Software" - title: "Tensors.jl — Tensor Computations in Julia" + orcid: 'https://orcid.org/0000-0003-2476-5406' + doi: 10.5334/jors.182 + journal: Journal of Open Research Software + title: Tensors.jl — Tensor Computations in Julia type: article year: 2019 From 795df1ff83e5853a16a08ae991f3d4476d2adf04 Mon Sep 17 00:00:00 2001 From: Knut Andreas Meyer Date: Tue, 2 May 2023 11:17:42 +0200 Subject: [PATCH 08/16] Publish docstring of rotation_tensor (#200) --- docs/src/man/other_operators.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/src/man/other_operators.md b/docs/src/man/other_operators.md index 63fbfc63..bf1f8377 100644 --- a/docs/src/man/other_operators.md +++ b/docs/src/man/other_operators.md @@ -224,6 +224,7 @@ Tensors.sqrt ```@docs Tensors.rotate +Tensors.rotation_tensor ``` ## Special operations From f902ca4211b34114f6469aa104d4698e2b760ae9 Mon Sep 17 00:00:00 2001 From: Knut Andreas Meyer Date: Thu, 11 May 2023 11:43:29 +0200 Subject: [PATCH 09/16] VarArg{Any} instead of VarArg{<:Any} (#201) --- src/Tensors.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Tensors.jl b/src/Tensors.jl index 89bfb8b4..75bfbe5a 100644 --- a/src/Tensors.jl +++ b/src/Tensors.jl @@ -135,7 +135,7 @@ for TensorType in (SymmetricTensor, Tensor) end if N > 1 # To avoid overwriting ::Tuple{Any} # Heterogeneous tuple - @eval @inline $TensorType{$order, $dim}(t::Tuple{Vararg{<:Any,$N}}) = $TensorType{$order, $dim}(promote(t...)) + @eval @inline $TensorType{$order, $dim}(t::Tuple{Vararg{Any,$N}}) = $TensorType{$order, $dim}(promote(t...)) end end if TensorType == Tensor @@ -143,7 +143,7 @@ for TensorType in (SymmetricTensor, Tensor) @eval @inline Tensor{1, $dim}(t::NTuple{$dim, T}) where {T} = Tensor{1, $dim, T, $dim}(t) if dim > 1 # To avoid overwriting ::Tuple{Any} # Heterogeneous tuple - @eval @inline Tensor{1, $dim}(t::Tuple{Vararg{<:Any,$dim}}) = Tensor{1, $dim}(promote(t...)) + @eval @inline Tensor{1, $dim}(t::Tuple{Vararg{Any,$dim}}) = Tensor{1, $dim}(promote(t...)) end end end From 9508112bdcc735330e99fcba4c64cdaadf7a9aed Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Thu, 11 May 2023 04:44:23 -0500 Subject: [PATCH 10/16] Migrate from SnoopPrecompile to PrecompileTools (#199) --- Project.toml | 4 +- docs/Manifest.toml | 154 ++++++++++++++++++--------------------------- src/precompile.jl | 4 +- 3 files changed, 64 insertions(+), 98 deletions(-) diff --git a/Project.toml b/Project.toml index 654e8657..71772a30 100644 --- a/Project.toml +++ b/Project.toml @@ -6,14 +6,14 @@ version = "1.13.1" ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" SIMD = "fdea26ae-647d-5447-a871-4b548cad5224" -SnoopPrecompile = "66db9d55-30c0-4569-8b51-7e840670fc0c" +PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" [compat] ForwardDiff = "0.10" SIMD = "2, 3" -SnoopPrecompile = "1" +PrecompileTools = "1" StaticArrays = "1" julia = "1" diff --git a/docs/Manifest.toml b/docs/Manifest.toml index 37491d2a..541b837b 100644 --- a/docs/Manifest.toml +++ b/docs/Manifest.toml @@ -7,7 +7,6 @@ version = "0.0.1" [[ArgTools]] uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" -version = "1.1.1" [[Artifacts]] uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" @@ -17,15 +16,15 @@ uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" [[ChainRulesCore]] deps = ["Compat", "LinearAlgebra", "SparseArrays"] -git-tree-sha1 = "54fc4400de6e5c3e27be6047da2ef6ba355511f8" +git-tree-sha1 = "c6d890a52d2c4d55d326439580c3b8d0875a77d9" uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" -version = "1.11.6" +version = "1.15.7" [[ChangesOfVariables]] deps = ["ChainRulesCore", "LinearAlgebra", "Test"] -git-tree-sha1 = "bf98fa45a0a4cee295de98d4c1462be26345b9a1" +git-tree-sha1 = "485193efd2176b88e6622a39a246f8c5b600e74e" uuid = "9e997f8a-9a97-42d5-a9f1-ce6bfc15e2c0" -version = "0.1.2" +version = "0.1.6" [[CommonSubexpressions]] deps = ["MacroTools", "Test"] @@ -34,65 +33,52 @@ uuid = "bbf7d656-a473-5ed7-a52c-81e309532950" version = "0.3.0" [[Compat]] -deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "SHA", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"] -git-tree-sha1 = "44c37b4636bc54afac5c574d2d02b625349d6582" +deps = ["Dates", "LinearAlgebra", "UUIDs"] +git-tree-sha1 = "7a60c856b9fa189eb34f5f8a6f6b5529b7942957" uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" -version = "3.41.0" +version = "4.6.1" [[CompilerSupportLibraries_jll]] deps = ["Artifacts", "Libdl"] uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" -version = "1.0.1+0" [[Dates]] deps = ["Printf"] uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" -[[DelimitedFiles]] -deps = ["Mmap"] -uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab" - [[DiffResults]] -deps = ["StaticArrays"] -git-tree-sha1 = "c18e98cba888c6c25d1c3b048e4b3380ca956805" +deps = ["StaticArraysCore"] +git-tree-sha1 = "782dd5f4561f5d267313f23853baaaa4c52ea621" uuid = "163ba53b-c6d8-5494-b064-1a9d43ac40c5" -version = "1.0.3" +version = "1.1.0" [[DiffRules]] -deps = ["LogExpFunctions", "NaNMath", "Random", "SpecialFunctions"] -git-tree-sha1 = "9bc5dac3c8b6706b58ad5ce24cffd9861f07c94f" +deps = ["IrrationalConstants", "LogExpFunctions", "NaNMath", "Random", "SpecialFunctions"] +git-tree-sha1 = "a4ad7ef19d2cdc2eff57abbbe68032b1cd0bd8f8" uuid = "b552c78f-8df3-52c6-915a-8e097449b14b" -version = "1.9.0" - -[[Distributed]] -deps = ["Random", "Serialization", "Sockets"] -uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" +version = "1.13.0" [[DocStringExtensions]] deps = ["LibGit2"] -git-tree-sha1 = "b19534d1895d702889b219c382a6e18010797f0b" +git-tree-sha1 = "2fb1e02f2b635d0845df5d7c167fec4dd739b00d" uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" -version = "0.8.6" +version = "0.9.3" [[Documenter]] deps = ["ANSIColoredPrinters", "Base64", "Dates", "DocStringExtensions", "IOCapture", "InteractiveUtils", "JSON", "LibGit2", "Logging", "Markdown", "REPL", "Test", "Unicode"] -git-tree-sha1 = "6030186b00a38e9d0434518627426570aac2ef95" +git-tree-sha1 = "58fea7c536acd71f3eef6be3b21c0df5f3df88fd" uuid = "e30172f5-a6a5-5a46-863b-614d45cd2de4" -version = "0.27.23" +version = "0.27.24" [[Downloads]] -deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"] +deps = ["ArgTools", "LibCURL", "NetworkOptions"] uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6" -version = "1.6.0" - -[[FileWatching]] -uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" [[ForwardDiff]] deps = ["CommonSubexpressions", "DiffResults", "DiffRules", "LinearAlgebra", "LogExpFunctions", "NaNMath", "Preferences", "Printf", "Random", "SpecialFunctions", "StaticArrays"] -git-tree-sha1 = "1bd6fc0c344fc0cbee1f42f8d2e7ec8253dda2d2" +git-tree-sha1 = "00e252f4d706b3d55a8863432e742bf5717b498d" uuid = "f6369f11-7733-5829-9624-2563aa707210" -version = "0.10.25" +version = "0.10.35" [[IOCapture]] deps = ["Logging", "Random"] @@ -106,36 +92,34 @@ uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" [[InverseFunctions]] deps = ["Test"] -git-tree-sha1 = "a7254c0acd8e62f1ac75ad24d5db43f5f19f3c65" +git-tree-sha1 = "49510dfcb407e572524ba94aeae2fced1f3feb0f" uuid = "3587e190-3f89-42d0-90ee-14403ec27112" -version = "0.1.2" +version = "0.1.8" [[IrrationalConstants]] -git-tree-sha1 = "7fd44fd4ff43fc60815f8e764c0f352b83c49151" +git-tree-sha1 = "630b497eafcc20001bba38a4651b327dcfc491d2" uuid = "92d709cd-6900-40b7-9082-c6be49f344b6" -version = "0.1.1" +version = "0.2.2" [[JLLWrappers]] deps = ["Preferences"] -git-tree-sha1 = "22df5b96feef82434b07327e2d3c770a9b21e023" +git-tree-sha1 = "abc9885a7ca2052a736a600f7fa66209f96506e1" uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210" -version = "1.4.0" +version = "1.4.1" [[JSON]] deps = ["Dates", "Mmap", "Parsers", "Unicode"] -git-tree-sha1 = "8076680b162ada2a031f707ac7b4953e30667a37" +git-tree-sha1 = "31e996f0a15c7b280ba9f76636b3ff9e2ae58c9a" uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" -version = "0.21.2" +version = "0.21.4" [[LibCURL]] deps = ["LibCURL_jll", "MozillaCACerts_jll"] uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" -version = "0.6.3" [[LibCURL_jll]] deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" -version = "7.84.0+0" [[LibGit2]] deps = ["Base64", "NetworkOptions", "Printf", "SHA"] @@ -144,29 +128,28 @@ uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" [[LibSSH2_jll]] deps = ["Artifacts", "Libdl", "MbedTLS_jll"] uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" -version = "1.10.2+0" [[Libdl]] uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" [[LinearAlgebra]] -deps = ["Libdl", "libblastrampoline_jll"] +deps = ["Libdl"] uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" [[LogExpFunctions]] deps = ["ChainRulesCore", "ChangesOfVariables", "DocStringExtensions", "InverseFunctions", "IrrationalConstants", "LinearAlgebra"] -git-tree-sha1 = "e5718a00af0ab9756305a0392832c8952c7426c1" +git-tree-sha1 = "0a1b7c2863e44523180fdb3146534e265a91870b" uuid = "2ab3a3ac-af41-5b50-aa03-7779005ae688" -version = "0.3.6" +version = "0.3.23" [[Logging]] uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" [[MacroTools]] deps = ["Markdown", "Random"] -git-tree-sha1 = "3d3e902b31198a27340d0bf00d6ac452866021cf" +git-tree-sha1 = "42324d08725e200c23d4dfb549e0d5d89dede2d2" uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09" -version = "0.5.9" +version = "0.5.10" [[Markdown]] deps = ["Base64"] @@ -175,33 +158,25 @@ uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" [[MbedTLS_jll]] deps = ["Artifacts", "Libdl"] uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" -version = "2.28.0+0" [[Mmap]] uuid = "a63ad114-7e13-5084-954f-fe012c677804" [[MozillaCACerts_jll]] uuid = "14a3606d-f60d-562e-9121-12d972cd8159" -version = "2022.2.1" [[NaNMath]] -git-tree-sha1 = "f755f36b19a5116bb580de457cda0c140153f283" +deps = ["OpenLibm_jll"] +git-tree-sha1 = "0877504529a3e5c3343c6f8b4c0381e57e4387e4" uuid = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3" -version = "0.3.6" +version = "1.0.2" [[NetworkOptions]] uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" -version = "1.2.0" - -[[OpenBLAS_jll]] -deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"] -uuid = "4536629a-c528-5b80-bd46-f80d51c5b363" -version = "0.3.20+0" [[OpenLibm_jll]] deps = ["Artifacts", "Libdl"] uuid = "05823500-19ac-5b8b-9628-191a04bc5112" -version = "0.8.1+0" [[OpenSpecFun_jll]] deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Pkg"] @@ -210,21 +185,20 @@ uuid = "efe28fd5-8261-553b-a9e1-b2916fc3738e" version = "0.5.5+0" [[Parsers]] -deps = ["Dates"] -git-tree-sha1 = "92f91ba9e5941fc781fecf5494ac1da87bdac775" +deps = ["Dates", "SnoopPrecompile"] +git-tree-sha1 = "478ac6c952fddd4399e71d4779797c538d0ff2bf" uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" -version = "2.2.0" +version = "2.5.8" [[Pkg]] deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" -version = "1.8.0" [[Preferences]] deps = ["TOML"] -git-tree-sha1 = "2cf929d64681236a2e074ffafb8d568733d2e6af" +git-tree-sha1 = "47e5f437cc0e7ef2ce8406ce1e7e24d44915f88d" uuid = "21216c6a-2e73-6563-6e65-726566657250" -version = "1.2.3" +version = "1.3.0" [[Printf]] deps = ["Unicode"] @@ -235,29 +209,26 @@ deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"] uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" [[Random]] -deps = ["SHA", "Serialization"] +deps = ["Serialization"] uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" [[SHA]] uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" -version = "0.7.0" [[SIMD]] -git-tree-sha1 = "39e3df417a0dd0c4e1f89891a281f82f5373ea3b" +deps = ["SnoopPrecompile"] +git-tree-sha1 = "8b20084a97b004588125caebf418d8cab9e393d1" uuid = "fdea26ae-647d-5447-a871-4b548cad5224" -version = "3.4.0" +version = "3.4.4" [[Serialization]] uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" -[[SharedArrays]] -deps = ["Distributed", "Mmap", "Random", "Serialization"] -uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383" - [[SnoopPrecompile]] -git-tree-sha1 = "f604441450a3c0569830946e5b33b78c928e1a85" +deps = ["Preferences"] +git-tree-sha1 = "e760a70afdcd461cf01a575947738d359234665c" uuid = "66db9d55-30c0-4569-8b51-7e840670fc0c" -version = "1.0.1" +version = "1.0.3" [[Sockets]] uuid = "6462fe0b-24de-5631-8697-dd941f90decc" @@ -268,15 +239,20 @@ uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" [[SpecialFunctions]] deps = ["ChainRulesCore", "IrrationalConstants", "LogExpFunctions", "OpenLibm_jll", "OpenSpecFun_jll"] -git-tree-sha1 = "e6bf188613555c78062842777b116905a9f9dd49" +git-tree-sha1 = "ef28127915f4229c971eb43f3fc075dd3fe91880" uuid = "276daf66-3868-5448-9aa4-cd146d93841b" -version = "2.1.0" +version = "2.2.0" [[StaticArrays]] -deps = ["LinearAlgebra", "Random", "Statistics"] -git-tree-sha1 = "2884859916598f974858ff01df7dfc6c708dd895" +deps = ["LinearAlgebra", "Random", "StaticArraysCore", "Statistics"] +git-tree-sha1 = "63e84b7fdf5021026d0f17f76af7c57772313d99" uuid = "90137ffa-7385-5640-81b9-e52037218182" -version = "1.3.3" +version = "1.5.21" + +[[StaticArraysCore]] +git-tree-sha1 = "6b7ba252635a5eff6a0b0664a41ee140a1c9e72a" +uuid = "1e83bf80-4336-4d27-bf5d-d5a4f845583c" +version = "1.4.0" [[Statistics]] deps = ["LinearAlgebra", "SparseArrays"] @@ -285,18 +261,16 @@ uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" [[TOML]] deps = ["Dates"] uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76" -version = "1.0.0" [[Tar]] deps = ["ArgTools", "SHA"] uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" -version = "1.10.1" [[Tensors]] deps = ["ForwardDiff", "LinearAlgebra", "SIMD", "SnoopPrecompile", "StaticArrays", "Statistics"] -path = ".." +git-tree-sha1 = "71f054343e85ab1eab12bf8336004309002ff82d" uuid = "48a634ad-e948-5137-8d70-aa71f2a747f4" -version = "1.13.0" +version = "1.13.1" [[Test]] deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] @@ -312,19 +286,11 @@ uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" [[Zlib_jll]] deps = ["Libdl"] uuid = "83775a58-1f1d-513f-b197-d71354ab007a" -version = "1.2.12+3" - -[[libblastrampoline_jll]] -deps = ["Artifacts", "Libdl", "OpenBLAS_jll"] -uuid = "8e850b90-86db-534c-a0d3-1478176c7d93" -version = "5.1.1+0" [[nghttp2_jll]] deps = ["Artifacts", "Libdl"] uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" -version = "1.48.0+0" [[p7zip_jll]] deps = ["Artifacts", "Libdl"] uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" -version = "17.4.0+0" diff --git a/src/precompile.jl b/src/precompile.jl index 7ea5d15a..3a1de888 100644 --- a/src/precompile.jl +++ b/src/precompile.jl @@ -1,6 +1,6 @@ -using SnoopPrecompile +using PrecompileTools -@precompile_all_calls begin +@compile_workload begin for dim in (2, 3) v = ones(Tensor{1, dim, Float64,}) σ = one(SymmetricTensor{2, dim, Float64}) From b6f276cb32c706776c2d6a6565538d5ffbccd3b5 Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Thu, 11 May 2023 11:52:32 +0200 Subject: [PATCH 11/16] Update CI to not run on 1.9 twice, re-resolve docs project for 1.9. --- .github/workflows/CI.yml | 2 +- docs/Manifest.toml | 240 +++++++++++++++++++++++---------------- 2 files changed, 142 insertions(+), 100 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 06540252..08b68fab 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -17,7 +17,7 @@ jobs: version: - '1.6' - '1' - - '~1.9.0-0' + # - '~1.9.0-0' - 'nightly' os: - ubuntu-latest diff --git a/docs/Manifest.toml b/docs/Manifest.toml index 541b837b..bbaeae21 100644 --- a/docs/Manifest.toml +++ b/docs/Manifest.toml @@ -1,296 +1,338 @@ # This file is machine-generated - editing it directly is not advised -[[ANSIColoredPrinters]] +julia_version = "1.9.0" +manifest_format = "2.0" +project_hash = "063b18da735845e327fc97d98706d227f804d89d" + +[[deps.ANSIColoredPrinters]] git-tree-sha1 = "574baf8110975760d391c710b6341da1afa48d8c" uuid = "a4c015fc-c6ff-483c-b24f-f7ea428134e9" version = "0.0.1" -[[ArgTools]] +[[deps.ArgTools]] uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" +version = "1.1.1" -[[Artifacts]] +[[deps.Artifacts]] uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" -[[Base64]] +[[deps.Base64]] uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" -[[ChainRulesCore]] -deps = ["Compat", "LinearAlgebra", "SparseArrays"] -git-tree-sha1 = "c6d890a52d2c4d55d326439580c3b8d0875a77d9" -uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" -version = "1.15.7" - -[[ChangesOfVariables]] -deps = ["ChainRulesCore", "LinearAlgebra", "Test"] -git-tree-sha1 = "485193efd2176b88e6622a39a246f8c5b600e74e" -uuid = "9e997f8a-9a97-42d5-a9f1-ce6bfc15e2c0" -version = "0.1.6" - -[[CommonSubexpressions]] +[[deps.CommonSubexpressions]] deps = ["MacroTools", "Test"] git-tree-sha1 = "7b8a93dba8af7e3b42fecabf646260105ac373f7" uuid = "bbf7d656-a473-5ed7-a52c-81e309532950" version = "0.3.0" -[[Compat]] -deps = ["Dates", "LinearAlgebra", "UUIDs"] -git-tree-sha1 = "7a60c856b9fa189eb34f5f8a6f6b5529b7942957" -uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" -version = "4.6.1" - -[[CompilerSupportLibraries_jll]] +[[deps.CompilerSupportLibraries_jll]] deps = ["Artifacts", "Libdl"] uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" +version = "1.0.2+0" -[[Dates]] +[[deps.Dates]] deps = ["Printf"] uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" -[[DiffResults]] +[[deps.DiffResults]] deps = ["StaticArraysCore"] git-tree-sha1 = "782dd5f4561f5d267313f23853baaaa4c52ea621" uuid = "163ba53b-c6d8-5494-b064-1a9d43ac40c5" version = "1.1.0" -[[DiffRules]] +[[deps.DiffRules]] deps = ["IrrationalConstants", "LogExpFunctions", "NaNMath", "Random", "SpecialFunctions"] git-tree-sha1 = "a4ad7ef19d2cdc2eff57abbbe68032b1cd0bd8f8" uuid = "b552c78f-8df3-52c6-915a-8e097449b14b" version = "1.13.0" -[[DocStringExtensions]] +[[deps.DocStringExtensions]] deps = ["LibGit2"] git-tree-sha1 = "2fb1e02f2b635d0845df5d7c167fec4dd739b00d" uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" version = "0.9.3" -[[Documenter]] +[[deps.Documenter]] deps = ["ANSIColoredPrinters", "Base64", "Dates", "DocStringExtensions", "IOCapture", "InteractiveUtils", "JSON", "LibGit2", "Logging", "Markdown", "REPL", "Test", "Unicode"] git-tree-sha1 = "58fea7c536acd71f3eef6be3b21c0df5f3df88fd" uuid = "e30172f5-a6a5-5a46-863b-614d45cd2de4" version = "0.27.24" -[[Downloads]] -deps = ["ArgTools", "LibCURL", "NetworkOptions"] +[[deps.Downloads]] +deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"] uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6" +version = "1.6.0" + +[[deps.FileWatching]] +uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" -[[ForwardDiff]] -deps = ["CommonSubexpressions", "DiffResults", "DiffRules", "LinearAlgebra", "LogExpFunctions", "NaNMath", "Preferences", "Printf", "Random", "SpecialFunctions", "StaticArrays"] +[[deps.ForwardDiff]] +deps = ["CommonSubexpressions", "DiffResults", "DiffRules", "LinearAlgebra", "LogExpFunctions", "NaNMath", "Preferences", "Printf", "Random", "SpecialFunctions"] git-tree-sha1 = "00e252f4d706b3d55a8863432e742bf5717b498d" uuid = "f6369f11-7733-5829-9624-2563aa707210" version = "0.10.35" +weakdeps = ["StaticArrays"] -[[IOCapture]] + [deps.ForwardDiff.extensions] + ForwardDiffStaticArraysExt = "StaticArrays" + +[[deps.IOCapture]] deps = ["Logging", "Random"] git-tree-sha1 = "f7be53659ab06ddc986428d3a9dcc95f6fa6705a" uuid = "b5f81e59-6552-4d32-b1f0-c071b021bf89" version = "0.2.2" -[[InteractiveUtils]] +[[deps.InteractiveUtils]] deps = ["Markdown"] uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" -[[InverseFunctions]] -deps = ["Test"] -git-tree-sha1 = "49510dfcb407e572524ba94aeae2fced1f3feb0f" -uuid = "3587e190-3f89-42d0-90ee-14403ec27112" -version = "0.1.8" - -[[IrrationalConstants]] +[[deps.IrrationalConstants]] git-tree-sha1 = "630b497eafcc20001bba38a4651b327dcfc491d2" uuid = "92d709cd-6900-40b7-9082-c6be49f344b6" version = "0.2.2" -[[JLLWrappers]] +[[deps.JLLWrappers]] deps = ["Preferences"] git-tree-sha1 = "abc9885a7ca2052a736a600f7fa66209f96506e1" uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210" version = "1.4.1" -[[JSON]] +[[deps.JSON]] deps = ["Dates", "Mmap", "Parsers", "Unicode"] git-tree-sha1 = "31e996f0a15c7b280ba9f76636b3ff9e2ae58c9a" uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" version = "0.21.4" -[[LibCURL]] +[[deps.LibCURL]] deps = ["LibCURL_jll", "MozillaCACerts_jll"] uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" +version = "0.6.3" -[[LibCURL_jll]] +[[deps.LibCURL_jll]] deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" +version = "7.84.0+0" -[[LibGit2]] +[[deps.LibGit2]] deps = ["Base64", "NetworkOptions", "Printf", "SHA"] uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" -[[LibSSH2_jll]] +[[deps.LibSSH2_jll]] deps = ["Artifacts", "Libdl", "MbedTLS_jll"] uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" +version = "1.10.2+0" -[[Libdl]] +[[deps.Libdl]] uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" -[[LinearAlgebra]] -deps = ["Libdl"] +[[deps.LinearAlgebra]] +deps = ["Libdl", "OpenBLAS_jll", "libblastrampoline_jll"] uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" -[[LogExpFunctions]] -deps = ["ChainRulesCore", "ChangesOfVariables", "DocStringExtensions", "InverseFunctions", "IrrationalConstants", "LinearAlgebra"] +[[deps.LogExpFunctions]] +deps = ["DocStringExtensions", "IrrationalConstants", "LinearAlgebra"] git-tree-sha1 = "0a1b7c2863e44523180fdb3146534e265a91870b" uuid = "2ab3a3ac-af41-5b50-aa03-7779005ae688" version = "0.3.23" -[[Logging]] + [deps.LogExpFunctions.extensions] + LogExpFunctionsChainRulesCoreExt = "ChainRulesCore" + LogExpFunctionsChangesOfVariablesExt = "ChangesOfVariables" + LogExpFunctionsInverseFunctionsExt = "InverseFunctions" + + [deps.LogExpFunctions.weakdeps] + ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" + ChangesOfVariables = "9e997f8a-9a97-42d5-a9f1-ce6bfc15e2c0" + InverseFunctions = "3587e190-3f89-42d0-90ee-14403ec27112" + +[[deps.Logging]] uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" -[[MacroTools]] +[[deps.MacroTools]] deps = ["Markdown", "Random"] git-tree-sha1 = "42324d08725e200c23d4dfb549e0d5d89dede2d2" uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09" version = "0.5.10" -[[Markdown]] +[[deps.Markdown]] deps = ["Base64"] uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" -[[MbedTLS_jll]] +[[deps.MbedTLS_jll]] deps = ["Artifacts", "Libdl"] uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" +version = "2.28.2+0" -[[Mmap]] +[[deps.Mmap]] uuid = "a63ad114-7e13-5084-954f-fe012c677804" -[[MozillaCACerts_jll]] +[[deps.MozillaCACerts_jll]] uuid = "14a3606d-f60d-562e-9121-12d972cd8159" +version = "2022.10.11" -[[NaNMath]] +[[deps.NaNMath]] deps = ["OpenLibm_jll"] git-tree-sha1 = "0877504529a3e5c3343c6f8b4c0381e57e4387e4" uuid = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3" version = "1.0.2" -[[NetworkOptions]] +[[deps.NetworkOptions]] uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" +version = "1.2.0" -[[OpenLibm_jll]] +[[deps.OpenBLAS_jll]] +deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"] +uuid = "4536629a-c528-5b80-bd46-f80d51c5b363" +version = "0.3.21+4" + +[[deps.OpenLibm_jll]] deps = ["Artifacts", "Libdl"] uuid = "05823500-19ac-5b8b-9628-191a04bc5112" +version = "0.8.1+0" -[[OpenSpecFun_jll]] +[[deps.OpenSpecFun_jll]] deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Pkg"] git-tree-sha1 = "13652491f6856acfd2db29360e1bbcd4565d04f1" uuid = "efe28fd5-8261-553b-a9e1-b2916fc3738e" version = "0.5.5+0" -[[Parsers]] +[[deps.Parsers]] deps = ["Dates", "SnoopPrecompile"] git-tree-sha1 = "478ac6c952fddd4399e71d4779797c538d0ff2bf" uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" version = "2.5.8" -[[Pkg]] -deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] +[[deps.Pkg]] +deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" +version = "1.9.0" + +[[deps.PrecompileTools]] +deps = ["Preferences"] +git-tree-sha1 = "259e206946c293698122f63e2b513a7c99a244e8" +uuid = "aea7be01-6a6a-4083-8856-8a6e6704d82a" +version = "1.1.1" -[[Preferences]] +[[deps.Preferences]] deps = ["TOML"] -git-tree-sha1 = "47e5f437cc0e7ef2ce8406ce1e7e24d44915f88d" +git-tree-sha1 = "7eb1686b4f04b82f96ed7a4ea5890a4f0c7a09f1" uuid = "21216c6a-2e73-6563-6e65-726566657250" -version = "1.3.0" +version = "1.4.0" -[[Printf]] +[[deps.Printf]] deps = ["Unicode"] uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" -[[REPL]] +[[deps.REPL]] deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"] uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" -[[Random]] -deps = ["Serialization"] +[[deps.Random]] +deps = ["SHA", "Serialization"] uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" -[[SHA]] +[[deps.SHA]] uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" +version = "0.7.0" -[[SIMD]] -deps = ["SnoopPrecompile"] -git-tree-sha1 = "8b20084a97b004588125caebf418d8cab9e393d1" +[[deps.SIMD]] +deps = ["PrecompileTools"] +git-tree-sha1 = "0e270732477b9e551d884e6b07e23bb2ec947790" uuid = "fdea26ae-647d-5447-a871-4b548cad5224" -version = "3.4.4" +version = "3.4.5" -[[Serialization]] +[[deps.Serialization]] uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" -[[SnoopPrecompile]] +[[deps.SnoopPrecompile]] deps = ["Preferences"] git-tree-sha1 = "e760a70afdcd461cf01a575947738d359234665c" uuid = "66db9d55-30c0-4569-8b51-7e840670fc0c" version = "1.0.3" -[[Sockets]] +[[deps.Sockets]] uuid = "6462fe0b-24de-5631-8697-dd941f90decc" -[[SparseArrays]] -deps = ["LinearAlgebra", "Random"] +[[deps.SparseArrays]] +deps = ["Libdl", "LinearAlgebra", "Random", "Serialization", "SuiteSparse_jll"] uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" -[[SpecialFunctions]] -deps = ["ChainRulesCore", "IrrationalConstants", "LogExpFunctions", "OpenLibm_jll", "OpenSpecFun_jll"] +[[deps.SpecialFunctions]] +deps = ["IrrationalConstants", "LogExpFunctions", "OpenLibm_jll", "OpenSpecFun_jll"] git-tree-sha1 = "ef28127915f4229c971eb43f3fc075dd3fe91880" uuid = "276daf66-3868-5448-9aa4-cd146d93841b" version = "2.2.0" -[[StaticArrays]] + [deps.SpecialFunctions.extensions] + SpecialFunctionsChainRulesCoreExt = "ChainRulesCore" + + [deps.SpecialFunctions.weakdeps] + ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" + +[[deps.StaticArrays]] deps = ["LinearAlgebra", "Random", "StaticArraysCore", "Statistics"] -git-tree-sha1 = "63e84b7fdf5021026d0f17f76af7c57772313d99" +git-tree-sha1 = "c262c8e978048c2b095be1672c9bee55b4619521" uuid = "90137ffa-7385-5640-81b9-e52037218182" -version = "1.5.21" +version = "1.5.24" -[[StaticArraysCore]] +[[deps.StaticArraysCore]] git-tree-sha1 = "6b7ba252635a5eff6a0b0664a41ee140a1c9e72a" uuid = "1e83bf80-4336-4d27-bf5d-d5a4f845583c" version = "1.4.0" -[[Statistics]] +[[deps.Statistics]] deps = ["LinearAlgebra", "SparseArrays"] uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" +version = "1.9.0" + +[[deps.SuiteSparse_jll]] +deps = ["Artifacts", "Libdl", "Pkg", "libblastrampoline_jll"] +uuid = "bea87d4a-7f5b-5778-9afe-8cc45184846c" +version = "5.10.1+6" -[[TOML]] +[[deps.TOML]] deps = ["Dates"] uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76" +version = "1.0.3" -[[Tar]] +[[deps.Tar]] deps = ["ArgTools", "SHA"] uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" +version = "1.10.0" -[[Tensors]] +[[deps.Tensors]] deps = ["ForwardDiff", "LinearAlgebra", "SIMD", "SnoopPrecompile", "StaticArrays", "Statistics"] git-tree-sha1 = "71f054343e85ab1eab12bf8336004309002ff82d" uuid = "48a634ad-e948-5137-8d70-aa71f2a747f4" version = "1.13.1" -[[Test]] +[[deps.Test]] deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" -[[UUIDs]] +[[deps.UUIDs]] deps = ["Random", "SHA"] uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" -[[Unicode]] +[[deps.Unicode]] uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" -[[Zlib_jll]] +[[deps.Zlib_jll]] deps = ["Libdl"] uuid = "83775a58-1f1d-513f-b197-d71354ab007a" +version = "1.2.13+0" + +[[deps.libblastrampoline_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "8e850b90-86db-534c-a0d3-1478176c7d93" +version = "5.7.0+0" -[[nghttp2_jll]] +[[deps.nghttp2_jll]] deps = ["Artifacts", "Libdl"] uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" +version = "1.48.0+0" -[[p7zip_jll]] +[[deps.p7zip_jll]] deps = ["Artifacts", "Libdl"] uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" +version = "17.4.0+0" From 4633a907605ba348715eace88372948e58e63ee7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20K=C3=B6hler?= Date: Fri, 12 May 2023 19:03:58 +0200 Subject: [PATCH 12/16] 3D rotation by Euler angles in `rotation_tensor` (#198) --- src/math_ops.jl | 23 +++++++++++++++++++++++ test/test_ops.jl | 3 +++ 2 files changed, 26 insertions(+) diff --git a/src/math_ops.jl b/src/math_ops.jl index d9b2925a..4e94abd6 100644 --- a/src/math_ops.jl +++ b/src/math_ops.jl @@ -346,6 +346,29 @@ function rotation_tensor(θ::Number) return Tensor{2, 2}((c, s, -s, c)) end +""" + rotation_tensor(ψ::Number, θ::Number, ϕ::Number) + +Return the three-dimensional rotation matrix corresponding to the rotation described +by the three Euler angles ``ψ``, ``θ``, ``ϕ``. + +```math +R(ψ,θ,ϕ) = R_x(ψ)R_y(θ)R_z(ϕ) +``` +see e.g. for a complete description. + +Note that the [gimbal lock phenomena](https://en.wikipedia.org/wiki/Gimbal_lock) can occur when using +this rotation tensor parametrization. +""" +function rotation_tensor(ψ::Number,θ::Number,ϕ::Number) + sψ, cψ = sincos(ψ) + sθ, cθ = sincos(θ) + sϕ, cϕ = sincos(ϕ) + return Tensor{2,3}((cθ * cϕ, cθ * sϕ, -sθ, #first column + sψ * sθ * cϕ - cψ * sϕ, sψ * sθ * sϕ + cψ * cϕ, sψ * cθ, #second column + cψ * sθ * cϕ + sψ * sϕ, cψ * sθ * sϕ - sψ * cϕ, cψ * cθ)) #third column +end + """ rotation_tensor(u::Vec{3}, θ::Number) diff --git a/test/test_ops.jl b/test/test_ops.jl index c457fdce..957626a1 100644 --- a/test/test_ops.jl +++ b/test/test_ops.jl @@ -229,6 +229,9 @@ end # of testsection @test rotate(rotate(rotate(A_sym, x, π), y, π), z, π)::SymmetricTensor ≈ A_sym @test rotate(A_sym, a, 0) ≈ A_sym @test rotate(A_sym, a, π/2) ≈ rotate(A_sym, -a, -π/2) + @test rotate(A_sym, π/4, π/4, π/4) ≈ rotate(A_sym, -3π/4, 3π/4, -3π/4) + @test rotate(A, π/4, π/4, π/4) ≈ rotate(A, -3π/4, 3π/4, -3π/4) + @test rotate(one(A), π/4, π/4, π/4) ≈ rotate(one(A), -3π/4, 3π/4, -3π/4) ≈ one(A) @test rotate(AA, x, π)::Tensor ≈ rotate(AA, x, -π) @test rotate(rotate(rotate(AA, x, π), y, π), z, π) ≈ AA From 4030dd347c8304df5f41c4ab55053634f843d4ff Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Fri, 12 May 2023 19:05:54 +0200 Subject: [PATCH 13/16] Set version to 1.14.0. --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 71772a30..04ba640b 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "Tensors" uuid = "48a634ad-e948-5137-8d70-aa71f2a747f4" -version = "1.13.1" +version = "1.14.0" [deps] ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" From d63b54fb42ff8061bd9895a096a5d181dd397745 Mon Sep 17 00:00:00 2001 From: Knut Andreas Meyer Date: Mon, 24 Jul 2023 16:18:12 +0200 Subject: [PATCH 14/16] Document tomandel/frommandel (#202) --- src/voigt.jl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/voigt.jl b/src/voigt.jl index 6a736849..c868d46a 100644 --- a/src/voigt.jl +++ b/src/voigt.jl @@ -133,9 +133,19 @@ Base.@propagate_inbounds function tovoigt!(v::AbstractMatrix{T}, A::SymmetricTen return v end +""" + tomandel(A; kwargs...) + +Convert the tensor `A` to voigt-form using the Mandel convention, see [`tovoigt`](@ref). +""" @inline tomandel(A::SymmetricTensor{o, dim, T}; kwargs...) where{o,dim,T} = tovoigt(A; offdiagscale=√(2one(T)), kwargs...) @inline tomandel(A::Tensor; kwargs...) = tovoigt(A; kwargs...) +""" + tomandel!(v, A; kwargs...) + +Fill the array `v` with the values in `A` on voigt-form using the Mandel convention, see [`tovoigt!`](@ref). +""" Base.@propagate_inbounds tomandel!(v::AbstractVecOrMat{T}, A::SymmetricTensor; kwargs...) where{T} = tovoigt!(v, A; offdiagscale=√(2one(T)), kwargs...) Base.@propagate_inbounds tomandel!(v::AbstractVecOrMat, A::Tensor; kwargs...) = tovoigt!(v, A; kwargs...) @@ -189,5 +199,10 @@ Base.@propagate_inbounds function fromvoigt(TT::Type{<: SymmetricTensor{4, dim}} end) end +""" + frommandel(TT, v; kwargs...) + +Convert the Array `v` in voigt-format, following the Mandel convention, to a tensor of type `TT`, see [`fromvoigt`](@ref). +""" Base.@propagate_inbounds frommandel(TT::Type{<: SymmetricTensor}, v::AbstractVecOrMat{T}; kwargs...) where{T} = fromvoigt(TT, v; offdiagscale=√(2one(T)), kwargs...) Base.@propagate_inbounds frommandel(TT::Type{<: Tensor}, v::AbstractVecOrMat; kwargs...) = fromvoigt(TT, v; kwargs...) From 800fa66024a215896ee9c9b6b0142204c5c6e2c3 Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Mon, 24 Jul 2023 16:18:58 +0200 Subject: [PATCH 15/16] Set version to 1.14.1. --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 04ba640b..820fa918 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "Tensors" uuid = "48a634ad-e948-5137-8d70-aa71f2a747f4" -version = "1.14.0" +version = "1.14.1" [deps] ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" From 996043c3c102416aff62e88ea6e6ad2e409966a6 Mon Sep 17 00:00:00 2001 From: Knut Andreas Meyer Date: Fri, 4 Aug 2023 11:39:23 +0200 Subject: [PATCH 16/16] Implement Voigt conversion to StaticArrays This patch implements `tovoigt(SArray, tensor)` to convert tensors to `SVector`/`SMatrix` in Voigt format. Closes #194. Co-authored-by: Knut Andreas Meyer Co-authored-by: Kim Louisa Auth --- src/voigt.jl | 205 +++++++++++++++++++++++++++++++++++++++++------ test/runtests.jl | 1 + test/test_ops.jl | 14 ++++ 3 files changed, 197 insertions(+), 23 deletions(-) diff --git a/src/voigt.jl b/src/voigt.jl index c868d46a..d9594729 100644 --- a/src/voigt.jl +++ b/src/voigt.jl @@ -1,12 +1,16 @@ const DEFAULT_VOIGT_ORDER = ([1], [1 3; 4 2], [1 6 5; 9 2 4; 8 7 3]) """ - tovoigt(A::Union{SecondOrderTensor, FourthOrderTensor}; kwargs...) + tovoigt([type::Type{<:AbstractArray}, ]A::Union{SecondOrderTensor, FourthOrderTensor}; kwargs...) Converts a tensor to "Voigt"-format. +Optional argument: +- `type`: determines the returned Array type. Possible types are `Array` and `SArray` (see + [`StaticArrays`](https://juliaarrays.github.io/StaticArrays.jl/stable/)). + Keyword arguments: - - `offdiagscale`: determines the scaling factor for the offdiagonal elements. - This argument is only applicable for `SymmetricTensor`s. `tomandel` can also + - `offdiagscale`: determines the scaling factor for the offdiagonal elements. + This argument is only applicable for `SymmetricTensor`s. `tomandel` can also be used for the "Mandel"-format which sets `offdiagscale = √2` for `SymmetricTensor`s, and is equivalent to `tovoigt` for `Tensor`s. - `order`: matrix of the linear indices determining the Voigt order. The default @@ -43,24 +47,39 @@ julia> tovoigt(Tensor{4,2}(1:16)) 4 16 12 8 3 15 11 7 2 14 10 6 + +julia> tovoigt(SMatrix, Tensor{4,2}(1:16)) +4×4 SMatrix{4, 4, Int64, 16} with indices SOneTo(4)×SOneTo(4): + 1 13 9 5 + 4 16 12 8 + 3 15 11 7 + 2 14 10 6 ``` + """ function tovoigt end -@inline function tovoigt(A::Tensor{2, dim, T, M}; order=DEFAULT_VOIGT_ORDER[dim]) where {dim, T, M} - @inbounds tovoigt!(Vector{T}(undef, M), A; order=order) +# default to regular Array +@inline function tovoigt(A::AbstractTensor; kwargs...) + return tovoigt(Array, A; kwargs...) end -@inline function tovoigt(A::Tensor{4, dim, T, M}; order=DEFAULT_VOIGT_ORDER[dim]) where {dim, T, M} - @inbounds tovoigt!(Matrix{T}(undef, Int(√M), Int(√M)), A; order=order) +@inline tovoigt(::Type{Array}, A::SecondOrderTensor; kwargs...) = tovoigt(Vector, A; kwargs...) +@inline tovoigt(::Type{Array}, A::FourthOrderTensor; kwargs...) = tovoigt(Matrix, A; kwargs...) + +@inline function tovoigt(::Type{<:Vector}, A::Tensor{2, dim, T, M}; order=nothing) where {dim, T, M} + @inbounds _tovoigt!(Vector{T}(undef, M), A, order) +end +@inline function tovoigt(::Type{<:Matrix}, A::Tensor{4, dim, T, M}; order=nothing) where {dim, T, M} + @inbounds _tovoigt!(Matrix{T}(undef, Int(√M), Int(√M)), A, order) end -@inline function tovoigt(A::SymmetricTensor{2, dim, T, M}; offdiagscale=one(T), order=DEFAULT_VOIGT_ORDER[dim]) where {dim, T, M} - @inbounds tovoigt!(Vector{T}(undef, M), A; offdiagscale=offdiagscale, order=order) +@inline function tovoigt(::Type{<:Vector}, A::SymmetricTensor{2, dim, T, M}; offdiagscale=one(T), order=nothing) where {dim, T, M} + @inbounds _tovoigt!(Vector{T}(undef, M), A, order; offdiagscale=offdiagscale) end -@inline function tovoigt(A::SymmetricTensor{4, dim, T, M}; offdiagscale=one(T), order=DEFAULT_VOIGT_ORDER[dim]) where {dim, T, M} - @inbounds tovoigt!(Matrix{T}(undef, Int(√M), Int(√M)), A; offdiagscale=offdiagscale, order=order) +@inline function tovoigt(::Type{<:Matrix}, A::SymmetricTensor{4, dim, T, M}; offdiagscale=one(T), order=nothing) where {dim, T, M} + @inbounds _tovoigt!(Matrix{T}(undef, Int(√M), Int(√M)), A, order; offdiagscale=offdiagscale) end """ - tovoigt!(v::Array, A::Union{SecondOrderTensor, FourthOrderTensor}; kwargs...) + tovoigt!(v::AbstractArray, A::Union{SecondOrderTensor, FourthOrderTensor}; kwargs...) Converts a tensor to "Voigt"-format using the following index order: `[11, 22, 33, 23, 13, 12, 32, 31, 21]`. @@ -69,8 +88,8 @@ Keyword arguments: - `offset`: offset index for where in the array `A` the tensor should be stored. For 4th order tensors the keyword arguments are `offset_i` and `offset_j`, respectively. Defaults to `0`. - - `offdiagscale`: determines the scaling factor for the offdiagonal elements. - This argument is only applicable for `SymmetricTensor`s. `frommandel!` can also + - `offdiagscale`: determines the scaling factor for the offdiagonal elements. + This argument is only applicable for `SymmetricTensor`s. `frommandel!` can also be used for the "Mandel"-format which sets `offdiagscale = √2` for `SymmetricTensor`s, and is equivalent to `fromvoigt!` for `Tensor`s. - `order`: matrix of the linear indices determining the Voigt order. The default @@ -105,25 +124,60 @@ julia> tovoigt!(x, T; offset=1) ``` """ function tovoigt! end -Base.@propagate_inbounds function tovoigt!(v::AbstractVector, A::Tensor{2, dim}; offset::Int=0, order=DEFAULT_VOIGT_ORDER[dim]) where {dim} +Base.@propagate_inbounds function tovoigt!(v::AbstractVector, A::Tensor{2}; offset::Int=0, order=nothing) + _tovoigt!(v, A, order; offset=offset) +end +Base.@propagate_inbounds function tovoigt!(v::AbstractMatrix, A::Tensor{4}; offset_i::Int=0, offset_j::Int=0, order=nothing) + _tovoigt!(v, A, order; offset_i=offset_i, offset_j=offset_j) +end +Base.@propagate_inbounds function tovoigt!(v::AbstractVector{T}, A::SymmetricTensor{2}; offdiagscale=one(T), offset::Int=0, order=nothing) where T + _tovoigt!(v, A, order; offdiagscale=offdiagscale, offset=offset) +end +Base.@propagate_inbounds function tovoigt!(v::AbstractMatrix{T}, A::SymmetricTensor{4}; offdiagscale=one(T), offset_i::Int=0, offset_j::Int=0, order=nothing) where T + _tovoigt!(v, A, order; offdiagscale=offdiagscale, offset_i=offset_i, offset_j=offset_j) +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} + 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} + 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) + v[cartesian[i]] = tuple_data[i] + end + return v +end + +Base.@propagate_inbounds function _tovoigt!(v::AbstractVecOrMat{T}, A::Tensor{4,dim,T}, ::Nothing; kwargs...) where {dim,T} + return _tovoigt!(v, A, DEFAULT_VOIGT_ORDER[dim]; kwargs...) +end + +# custom voigt order (slower than default voigt order) +Base.@propagate_inbounds function _tovoigt!(v::AbstractVector, A::Tensor{2, dim}, order::AbstractVecOrMat; offset::Int=0) where {dim} for j in 1:dim, i in 1:dim v[offset + order[i, j]] = A[i, j] end return v end -Base.@propagate_inbounds function tovoigt!(v::AbstractMatrix, A::Tensor{4, dim}; offset_i::Int=0, offset_j::Int=0, order=DEFAULT_VOIGT_ORDER[dim]) where {dim} +Base.@propagate_inbounds function _tovoigt!(v::AbstractMatrix, A::Tensor{4, dim}, order::AbstractVecOrMat; offset_i::Int=0, offset_j::Int=0) where {dim} for l in 1:dim, k in 1:dim, j in 1:dim, i in 1:dim v[offset_i + order[i, j], offset_j + order[k, l]] = A[i, j, k, l] end return v end -Base.@propagate_inbounds function tovoigt!(v::AbstractVector{T}, A::SymmetricTensor{2, dim}; offdiagscale=one(T), offset::Int=0, order=DEFAULT_VOIGT_ORDER[dim]) where {T, dim} +Base.@propagate_inbounds function _tovoigt!(v::AbstractVector{T}, A::SymmetricTensor{2, dim}, order::AbstractVecOrMat; offdiagscale=one(T), offset::Int=0) where {T, dim} for j in 1:dim, i in 1:j v[offset + order[i, j]] = i == j ? A[i, j] : A[i, j] * offdiagscale end return v end -Base.@propagate_inbounds function tovoigt!(v::AbstractMatrix{T}, A::SymmetricTensor{4, dim}; offdiagscale=one(T), offset_i::Int=0, offset_j::Int=0, order=DEFAULT_VOIGT_ORDER[dim]) where {T, dim} +Base.@propagate_inbounds function _tovoigt!(v::AbstractMatrix{T}, A::SymmetricTensor{4, dim}, order::AbstractVecOrMat; offdiagscale=one(T), offset_i::Int=0, offset_j::Int=0) where {T, dim} for l in 1:dim, k in 1:l, j in 1:dim, i in 1:j v[offset_i + order[i, j], offset_j + order[k, l]] = (i == j && k == l) ? A[i, j, k, l] : @@ -138,8 +192,9 @@ end Convert the tensor `A` to voigt-form using the Mandel convention, see [`tovoigt`](@ref). """ -@inline tomandel(A::SymmetricTensor{o, dim, T}; kwargs...) where{o,dim,T} = tovoigt(A; offdiagscale=√(2one(T)), kwargs...) -@inline tomandel(A::Tensor; kwargs...) = tovoigt(A; kwargs...) +@inline tomandel(A::AbstractTensor; kwargs...) = tomandel(Array, A; kwargs...) +@inline tomandel(::Type{AT}, A::SymmetricTensor{o, dim, T}; kwargs...) where{AT,o,dim,T} = tovoigt(AT, A; offdiagscale=√(2one(T)), kwargs...) +@inline tomandel(::Type{AT}, A::Tensor; kwargs...) where AT = tovoigt(AT, A; kwargs...) """ tomandel!(v, A; kwargs...) @@ -150,7 +205,7 @@ Base.@propagate_inbounds tomandel!(v::AbstractVecOrMat{T}, A::SymmetricTensor; k Base.@propagate_inbounds tomandel!(v::AbstractVecOrMat, A::Tensor; kwargs...) = tovoigt!(v, A; kwargs...) """ - fromvoigt(S::Type{<:AbstractTensor}, A::Array{T}; kwargs...) + fromvoigt(S::Type{<:AbstractTensor}, A::AbstractArray{T}; kwargs...) Converts an array `A` stored in Voigt format to a Tensor of type `S`. @@ -158,8 +213,8 @@ Keyword arguments: - `offset`: offset index for where in the array `A` the tensor starts. For 4th order tensors the keyword arguments are `offset_i` and `offset_j`, respectively. Defaults to `0`. - - `offdiagscale`: determines the scaling factor for the offdiagonal elements. - This argument is only applicable for `SymmetricTensor`s. `frommandel` can also + - `offdiagscale`: determines the scaling factor for the offdiagonal elements. + This argument is only applicable for `SymmetricTensor`s. `frommandel` can also be used for the "Mandel"-format which sets `offdiagscale = √2` for `SymmetricTensor`s, and is equivalent to `fromvoigt` for `Tensor`s. - `order`: matrix of the linear indices determining the Voigt order. The default @@ -206,3 +261,107 @@ Convert the Array `v` in voigt-format, following the Mandel convention, to a ten """ Base.@propagate_inbounds frommandel(TT::Type{<: SymmetricTensor}, v::AbstractVecOrMat{T}; kwargs...) where{T} = fromvoigt(TT, v; offdiagscale=√(2one(T)), kwargs...) Base.@propagate_inbounds frommandel(TT::Type{<: Tensor}, v::AbstractVecOrMat; kwargs...) = fromvoigt(TT, v; kwargs...) + +############################################################## +# Reorder tensor data to tuple in default voigt format order # +############################################################## +function __to_voigt_tuple(A::Type{TT}, s=one(T)) where {TT<:SecondOrderTensor{dim,T}} where {dim,T} + # Define internals for generation + idx_fun(i, j) = compute_index(get_base(A), i, j) + maxind(j) = TT<:SymmetricTensor ? j : dim + N = n_components(get_base(A)) + + exps = Expr(:tuple) + append!(exps.args, [nothing for _ in 1:N]) # "Preallocate" to allow indexing directly + + for j in 1:dim, i in 1:maxind(j) + voigt_ind = DEFAULT_VOIGT_ORDER[dim][i,j] + if i==j + exps.args[voigt_ind] = :(get_data(A)[$(idx_fun(i, j))]) + else + exps.args[voigt_ind] = :(s*get_data(A)[$(idx_fun(i, j))]) + end + end + return exps, N +end + +function __to_voigt_tuple(A::Type{TT}, s=one(T)) where {TT<:FourthOrderTensor{dim,T}} where {dim,T} + # Define internals for generation + idx_fun(i, j, k, l) = compute_index(get_base(A), i, j, k, l) # why no change needed above? + maxind(j) = TT<:SymmetricTensor ? j : dim + N = Int(sqrt(n_components(get_base(A)))) + voigt_lin_index(vi, vj) = (vj-1)*N + vi + + exps = Expr(:tuple) + append!(exps.args, [nothing for _ in 1:N^2]) # "Preallocate" to allow indexing directly + + for l in 1:dim, k in 1:maxind(l), j in 1:dim, i in 1:maxind(j) + voigt_lin_ind = voigt_lin_index(DEFAULT_VOIGT_ORDER[dim][i,j], DEFAULT_VOIGT_ORDER[dim][k,l]) + if i==j && k==l + exps.args[voigt_lin_ind] = :(get_data(A)[$(idx_fun(i, j, k, l))]) + elseif i!=j && k!=l + exps.args[voigt_lin_ind] = :(s*s*get_data(A)[$(idx_fun(i, j, k, l))]) + else + exps.args[voigt_lin_ind] = :(s*get_data(A)[$(idx_fun(i, j, k, l))]) + end + end + return exps, N +end + +@generated function _to_voigt_tuple(A::AbstractTensor{order, dim, T}, s=one(T)) where {order,dim,T} + exps, N = __to_voigt_tuple(A, s) + quote + $(Expr(:meta, :inline)) + @inbounds return $exps, $N + end +end + +######################## +# StaticArrays support # +######################## +@inline tovoigt(::Type{SArray}, A::SecondOrderTensor; kwargs...) = tovoigt(SVector, A; kwargs...) +@inline tovoigt(::Type{SArray}, A::FourthOrderTensor; kwargs...) = tovoigt(SMatrix, A; kwargs...) +@inline function tovoigt(::Type{<:SVector}, A::Tensor{2, dim, T, M}; order=nothing) where {dim, T, M} + @inbounds _to_static_voigt(A, order) +end +@inline function tovoigt(::Type{<:SMatrix}, A::Tensor{4, dim, T, M}; order=nothing) where {dim, T, M} + @inbounds _to_static_voigt(A, order) +end +@inline function tovoigt(::Type{<:SVector}, A::SymmetricTensor{2, dim, T, M}; offdiagscale=one(T), order=nothing) where {dim, T, M} + @inbounds _to_static_voigt(A, order; offdiagscale=offdiagscale) +end +@inline function tovoigt(::Type{<:SMatrix}, A::SymmetricTensor{4, dim, T}; offdiagscale=one(T), order=nothing) where {dim, T} + @inbounds _to_static_voigt(A, order; offdiagscale=offdiagscale) +end + +# default voigt order +Base.@propagate_inbounds function _to_static_voigt(A::TT, ::Nothing; offdiagscale=one(T)) where {TT<:SecondOrderTensor{dim,T}} where {dim,T} + tuple_data, N = _to_voigt_tuple(A, offdiagscale) + return SVector{N, T}(tuple_data) +end +Base.@propagate_inbounds function _to_static_voigt(A::TT, ::Nothing; offdiagscale=one(T)) where {TT<:FourthOrderTensor{dim,T}} where {dim,T} + tuple_data, N = _to_voigt_tuple(A, offdiagscale) + return SMatrix{N, N, T}(tuple_data) +end + +# custom voigt order +@inline function _to_static_voigt(A::Tensor{2, dim, T, M}, order::AbstractVecOrMat) where {dim, T, M} + v = MVector{M, T}(undef) + @inbounds _tovoigt!(v, A, order) + return SVector(v) +end +@inline function _to_static_voigt(A::Tensor{4, dim, T, M}, order::AbstractVecOrMat) where {dim, T, M} + m = MMatrix{Int(√M), Int(√M), T}(undef) + @inbounds _tovoigt!(m, A, order) + return SMatrix(m) +end +@inline function _to_static_voigt(A::SymmetricTensor{2, dim, T, M}, order::AbstractVecOrMat; offdiagscale=one(T)) where {dim, T, M} + v = MVector{M, T}(undef) + @inbounds _tovoigt!(v, A, order; offdiagscale=offdiagscale) + return SVector(v) +end +@inline function _to_static_voigt(A::SymmetricTensor{4, dim, T, M}, order::AbstractVecOrMat; offdiagscale=one(T)) where {dim, T, M} + m = MMatrix{Int(√M), Int(√M), T}(undef) + @inbounds _tovoigt!(m, A, order; offdiagscale=offdiagscale) + return SMatrix(m) +end diff --git a/test/runtests.jl b/test/runtests.jl index 036373be..99487afe 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -4,6 +4,7 @@ using TimerOutputs using LinearAlgebra using Random using Statistics: mean +using StaticArrays macro testsection(str, block) return quote diff --git a/test/test_ops.jl b/test/test_ops.jl index 957626a1..e12e9f6f 100644 --- a/test/test_ops.jl +++ b/test/test_ops.jl @@ -321,6 +321,20 @@ end @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}) end + + # Static voigt/mandel that use default order + s2 = [rand(SymmetricTensor{2,dim}) for dim in 1:3] + s4 = [rand(SymmetricTensor{4,dim}) for dim in 1:3] + t2 = [rand(Tensor{2,dim}) for dim in 1:3] + t4 = [rand(Tensor{4,dim}) for dim in 1:3] + for a in (s2, s4, t2, t4) + for b in a + @test tovoigt(SArray, b) == tovoigt(b) + @test tomandel(SArray, b) ≈ tomandel(b) + @test fromvoigt(Tensors.get_base(typeof(b)), tovoigt(SArray, b)) ≈ b + @test frommandel(Tensors.get_base(typeof(b)), tomandel(SArray, b)) ≈ b + end + end end end # of testsection end # of testsection