Mercurial > repos > public > sbplib_julia
comparison src/Grids/manifolds.jl @ 1951:6c1bb9bdb092 feature/grids/geometry_functions
Merge feature/grids/manifolds
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Fri, 07 Feb 2025 22:38:39 +0100 |
parents | dd77b45ee1ac |
children | 3fb5b03162ee |
comparison
equal
deleted
inserted
replaced
1916:6859089b361e | 1951:6c1bb9bdb092 |
---|---|
31 which will both allow calling `jacobian(c,ξ)`. | 31 which will both allow calling `jacobian(c,ξ)`. |
32 """ | 32 """ |
33 jacobian(c::Chart, ξ) = jacobian(c.mapping, ξ) | 33 jacobian(c::Chart, ξ) = jacobian(c.mapping, ξ) |
34 # TBD: Can we register a error hint for when jacobian is called with a function that doesn't have a registered jacobian? | 34 # TBD: Can we register a error hint for when jacobian is called with a function that doesn't have a registered jacobian? |
35 | 35 |
36 boundary_identifiers(c::Chart) = boundary_identifiers(parameterspace(c)) | |
36 | 37 |
37 # TBD: Should Charts, parameterspaces, Atlases, have boundary names? | |
38 | 38 |
39 """ | 39 """ |
40 Atlas | 40 Atlas |
41 | 41 |
42 A collection of charts and their connections. | 42 A collection of charts and their connections. |
52 function charts end | 52 function charts end |
53 | 53 |
54 """ | 54 """ |
55 connections(::Atlas) | 55 connections(::Atlas) |
56 | 56 |
57 TBD: What exactly should this return? | 57 Collection of pairs of multiblock boundary identifiers. |
58 """ | 58 """ |
59 function connections end | 59 function connections end |
60 | 60 |
61 struct CartesianAtlas <: Atlas | 61 |
62 charts::Matrix{Chart} | 62 """ |
63 CartesianAtlas{D,C<:Chart,AT<:AbstractArray{C,D}} <: Atlas | |
64 | |
65 An atlas where the charts are arranged and connected like an array. | |
66 """ | |
67 struct CartesianAtlas{D,C<:Chart,AT<:AbstractArray{C,D}} <: Atlas | |
68 charts::AT | |
63 end | 69 end |
64 | 70 |
65 charts(a::CartesianAtlas) = a.charts | 71 charts(a::CartesianAtlas) = a.charts |
66 connections(a::CartesianAtlas) = nothing | |
67 | 72 |
68 struct UnstructuredAtlas <: Atlas | 73 function connections(a::CartesianAtlas) |
69 charts::Vector{Chart} | 74 c = Tuple{MultiBlockBoundary, MultiBlockBoundary}[] |
70 connections | 75 |
76 for d ∈ 1:ndims(charts(a)) | |
77 Is = eachslice(CartesianIndices(charts(a)); dims=d) | |
78 for i ∈ 1:length(Is)-1 # For each interface between slices | |
79 for jk ∈ eachindex(Is[i]) # For each block in slice | |
80 Iᵢⱼₖ = Tuple(Is[i][jk]) | |
81 Iᵢ₊₁ⱼₖ = Tuple(Is[i+1][jk]) | |
82 push!(c, | |
83 ( | |
84 MultiBlockBoundary{Iᵢⱼₖ, CartesianBoundary{d,UpperBoundary}}(), | |
85 MultiBlockBoundary{Iᵢ₊₁ⱼₖ, CartesianBoundary{d,LowerBoundary}}(), | |
86 ) | |
87 ) | |
88 end | |
89 end | |
90 end | |
91 | |
92 return c | |
93 end | |
94 | |
95 """ | |
96 boundary_identifiers(a::CartesianAtlas) | |
97 | |
98 All non-connected boundaries of the charts of `a`. | |
99 """ | |
100 function boundary_identifiers(a::CartesianAtlas) | |
101 bs = MultiBlockBoundary[] | |
102 | |
103 for d ∈ 1:ndims(charts(a)) | |
104 Is = eachslice(CartesianIndices(charts(a)); dims=d) | |
105 | |
106 for (i,b) ∈ ((1,LowerBoundary),(length(Is),UpperBoundary)) # For first and last slice | |
107 for jk ∈ eachindex(Is[i]) # For each block in slice | |
108 Iᵢⱼₖ = Tuple(Is[i][jk]) | |
109 push!(bs, | |
110 MultiBlockBoundary{Iᵢⱼₖ, CartesianBoundary{d,b}}(), | |
111 ) | |
112 end | |
113 end | |
114 end | |
115 | |
116 return bs | |
117 end | |
118 | |
119 | |
120 """ | |
121 UnstructuredAtlas{C<:Chart, CN<:Tuple{MultiBlockBoundary,MultiBlockBoundary}, ...} <: Atlas | |
122 | |
123 An atlas with connections determined by a vector `MultiBlockBoundary` pairs. | |
124 """ | |
125 struct UnstructuredAtlas{C<:Chart, CN<:Tuple{MultiBlockBoundary,MultiBlockBoundary}, CV<:AbstractVector{C}, CNV<:AbstractVector{CN}} <: Atlas | |
126 charts::CV | |
127 connections::CNV | |
71 end | 128 end |
72 | 129 |
73 charts(a::UnstructuredAtlas) = a.charts | 130 charts(a::UnstructuredAtlas) = a.charts |
74 connections(a::UnstructuredAtlas) = nothing | 131 connections(a::UnstructuredAtlas) = a.connections |
132 | |
133 """ | |
134 boundary_identifiers(a::UnstructuredAtlas) | |
135 | |
136 All non-connected boundaries of the charts of `a`. | |
137 """ | |
138 function boundary_identifiers(a::UnstructuredAtlas) | |
139 bs = MultiBlockBoundary[] | |
140 | |
141 for (i,c) ∈ enumerate(charts(a)) | |
142 for b ∈ boundary_identifiers(c) | |
143 mbb = MultiBlockBoundary{i,typeof(b)}() | |
144 | |
145 if !any(cn->mbb∈cn, connections(a)) | |
146 push!(bs, mbb) | |
147 end | |
148 end | |
149 end | |
150 | |
151 return bs | |
152 end |