comparison Notes.md @ 890:eb03bda76bae feature/variable_derivatives

Add some ideas for how to handle communication of regions and region sizes
author Jonatan Werpers <jonatan@werpers.com>
date Tue, 08 Feb 2022 10:58:14 +0100
parents fe8fe3f01162
children d8da3a1060b7
comparison
equal deleted inserted replaced
889:069e58fb3829 890:eb03bda76bae
152 - [ ] Use a trait to indicate if a TensorMapping uses indices with regions. 152 - [ ] Use a trait to indicate if a TensorMapping uses indices with regions.
153 The default should be that they do NOT. 153 The default should be that they do NOT.
154 - [ ] What to name this trait? Can we call it IndexStyle but not export it to avoid conflicts with Base.IndexStyle? 154 - [ ] What to name this trait? Can we call it IndexStyle but not export it to avoid conflicts with Base.IndexStyle?
155 - [ ] Figure out repeated application of regioned TensorMappings. Maybe an instance of a tensor mapping needs to know the exact size of the range and domain for this to work? 155 - [ ] Figure out repeated application of regioned TensorMappings. Maybe an instance of a tensor mapping needs to know the exact size of the range and domain for this to work?
156 156
157 ### Ideas for information sharing functions
158 ```julia
159 using StaticArrays
160
161 function regions(op::SecondDerivativeVariable)
162 t = ntuple(i->(Interior(),),range_dim(op))
163 return Base.setindex(t, (Lower(), Interior(), Upper()), derivative_direction(op))
164 end
165
166 function regionsizes(op::SecondDerivativeVariable)
167 sz = tuple.(range_size(op))
168
169 cl = closuresize(op)
170 return Base.setindex(sz, (cl, n-2cl, cl), derivative_direction(op))
171 end
172
173
174 g = EquidistantGrid((11,9), (0.,0.), (10.,8.)) # h = 1
175 c = evalOn(g, (x,y)->x+y)
176
177 D₂ᶜ = SecondDerivativeVariable(g, c, interior_stencil, closure_stencils,1)
178 @test regions(D₂ᶜ) == (
179 (Lower(), Interior(), Upper()),
180 (Interior(),),
181 )
182 @test regionsizes(D₂ᶜ) == ((1,9,1),(9,))
183
184
185 D₂ᶜ = SecondDerivativeVariable(g, c, interior_stencil, closure_stencils,2)
186 @test regions(D₂ᶜ) == (
187 (Interior(),),
188 (Lower(), Interior(), Upper()),
189 )
190 @test regionsizes(D₂ᶜ) == ((11,),(1,7,1))
191 ```
192
193
157 ## Boundschecking and dimension checking 194 ## Boundschecking and dimension checking
158 Does it make sense to have boundschecking only in getindex methods? 195 Does it make sense to have boundschecking only in getindex methods?
159 This would mean no bounds checking in applys, however any indexing that they do would be boundschecked. The only loss would be readability of errors. But users aren't really supposed to call apply directly anyway. 196 This would mean no bounds checking in applys, however any indexing that they do would be boundschecked. The only loss would be readability of errors. But users aren't really supposed to call apply directly anyway.
160 197
161 Preferably dimensions and sizes should be checked when lazy objects are created, for example TensorApplication, TensorComposition and so on. If dimension checks decreases performance we can make them skippable later. 198 Preferably dimensions and sizes should be checked when lazy objects are created, for example TensorApplication, TensorComposition and so on. If dimension checks decreases performance we can make them skippable later.